summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php
new file mode 100644
index 00000000..0110b99a
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Jobs/EntityIdDisposerJobTest.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace SMW\Tests\MediaWiki\Jobs;
+
+use SMW\DIWikiPage;
+use SMW\MediaWiki\Jobs\EntityIdDisposerJob;
+use SMW\Tests\TestEnvironment;
+
+/**
+ * @covers \SMW\MediaWiki\Jobs\EntityIdDisposerJob
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.5
+ *
+ * @author mwjames
+ */
+class EntityIdDisposerJobTest extends \PHPUnit_Framework_TestCase {
+
+ private $testEnvironment;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->testEnvironment = new TestEnvironment();
+
+ $connection = $this->getMockBuilder( '\SMW\MediaWiki\Database' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $connection->expects( $this->any() )
+ ->method( 'select' )
+ ->will( $this->returnValue( [ 'Foo' ] ) );
+
+ $store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' )
+ ->getMockForAbstractClass();
+
+ $connectionManager = $this->getMockBuilder( '\SMW\Connection\ConnectionManager' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $connectionManager->expects( $this->any() )
+ ->method( 'getConnection' )
+ ->will( $this->returnValue( $connection ) );
+
+ $store->setConnectionManager( $connectionManager );
+
+ $this->testEnvironment->registerObject( 'Store', $store );
+ }
+
+ protected function tearDown() {
+ $this->testEnvironment->tearDown();
+ parent::tearDown();
+ }
+
+ public function testCanConstruct() {
+
+ $title = $this->getMockBuilder( 'Title' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->assertInstanceOf(
+ EntityIdDisposerJob::class,
+ new EntityIdDisposerJob( $title )
+ );
+ }
+
+ /**
+ * @dataProvider parametersProvider
+ */
+ public function testJobRun( $parameters ) {
+
+ $subject = DIWikiPage::newFromText( __METHOD__ );
+
+ $instance = new EntityIdDisposerJob(
+ $subject->getTitle(),
+ $parameters
+ );
+
+ $this->assertTrue(
+ $instance->run()
+ );
+ }
+
+ public function parametersProvider() {
+
+ $provider[] = [
+ []
+ ];
+
+ $provider[] = [
+ [ 'id' => 42 ]
+ ];
+
+ return $provider;
+ }
+
+}