diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Admin/TableSchemaTaskHandlerTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Admin/TableSchemaTaskHandlerTest.php | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Admin/TableSchemaTaskHandlerTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Admin/TableSchemaTaskHandlerTest.php new file mode 100644 index 00000000..d6d0d371 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/MediaWiki/Specials/Admin/TableSchemaTaskHandlerTest.php @@ -0,0 +1,109 @@ +<?php + +namespace SMW\Tests\MediaWiki\Specials\Admin; + +use SMW\MediaWiki\Specials\Admin\TableSchemaTaskHandler; +use SMW\Tests\TestEnvironment; + +/** + * @covers \SMW\MediaWiki\Specials\Admin\TableSchemaTaskHandler + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.5 + * + * @author mwjames + */ +class TableSchemaTaskHandlerTest extends \PHPUnit_Framework_TestCase { + + private $testEnvironment; + private $store; + private $htmlFormRenderer; + private $outputFormatter; + + protected function setUp() { + parent::setUp(); + + $this->testEnvironment = new TestEnvironment(); + + $this->store = $this->getMockBuilder( '\SMW\Store' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->htmlFormRenderer = $this->getMockBuilder( '\SMW\MediaWiki\Renderer\HtmlFormRenderer' ) + ->disableOriginalConstructor() + ->getMock(); + + $this->outputFormatter = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\OutputFormatter' ) + ->disableOriginalConstructor() + ->getMock(); + + $this->testEnvironment->registerObject( 'Store', $this->store ); + } + + protected function tearDown() { + $this->testEnvironment->tearDown(); + parent::tearDown(); + } + + public function testCanConstruct() { + + $this->assertInstanceOf( + '\SMW\MediaWiki\Specials\Admin\TableSchemaTaskHandler', + new TableSchemaTaskHandler( $this->store, $this->htmlFormRenderer, $this->outputFormatter ) + ); + } + + public function testGetHtml() { + + $methods = [ + 'setName', + 'setMethod', + 'addHiddenField', + 'addHeader', + 'addParagraph', + 'addSubmitButton' + ]; + + foreach ( $methods as $method ) { + $this->htmlFormRenderer->expects( $this->any() ) + ->method( $method ) + ->will( $this->returnSelf() ); + } + + $this->htmlFormRenderer->expects( $this->atLeastOnce() ) + ->method( 'getForm' ); + + $instance = new TableSchemaTaskHandler( + $this->store, + $this->htmlFormRenderer, + $this->outputFormatter + ); + + $instance->getHtml(); + } + + public function testHandleRequest() { + + $this->store->expects( $this->once() ) + ->method( 'setup' ); + + $webRequest = $this->getMockBuilder( '\WebRequest' ) + ->disableOriginalConstructor() + ->getMock(); + + $webRequest->expects( $this->once() ) + ->method( 'getVal' ) + ->will( $this->returnValue( 'done' ) ); + + $instance = new TableSchemaTaskHandler( + $this->store, + $this->htmlFormRenderer, + $this->outputFormatter + ); + + $instance->setEnabledFeatures( SMW_ADM_SETUP ); + $instance->handleRequest( $webRequest ); + } + +} |