testEnvironment = new TestEnvironment(); $this->store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->outputFormatter = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\OutputFormatter' ) ->disableOriginalConstructor() ->getMock(); $this->testEnvironment->registerObject( 'Store', $this->store ); } protected function tearDown(): void { $this->testEnvironment->tearDown(); parent::tearDown(); } public function testCanConstruct() { $this->assertInstanceOf( SupplementTaskHandler::class, new SupplementTaskHandler( $this->outputFormatter, [] ) ); } public function testGetHtml() { $taskHandler = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\TaskHandler' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $instance = new SupplementTaskHandler( $this->outputFormatter, [ $taskHandler ] ); $this->assertIsString( $instance->getHtml() ); } public function testIsTaskFor() { $taskHandler = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\ActionableTask' ) ->disableOriginalConstructor() ->getMock(); $taskHandler->expects( $this->once() ) ->method( 'isTaskFor' ) ->with( 'foo' ) ->willReturn( true ); $instance = new SupplementTaskHandler( $this->outputFormatter, [ $taskHandler ] ); $this->assertTrue( $instance->isTaskFor( 'foo' ) ); } public function testHandleSubRequest() { $webRequest = $this->getMockBuilder( '\MediaWiki\Request\WebRequest' ) ->disableOriginalConstructor() ->getMock(); $webRequest->expects( $this->once() ) ->method( 'getText' ) ->with( 'action' ) ->willReturn( 'foo' ); $taskHandler = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\ActionableTask' ) ->disableOriginalConstructor() ->getMock(); $taskHandler->expects( $this->once() ) ->method( 'isTaskFor' ) ->willReturn( true ); $taskHandler->expects( $this->once() ) ->method( 'handleRequest' ) ->with( $webRequest ); $instance = new SupplementTaskHandler( $this->outputFormatter, [ $taskHandler ] ); $instance->setStore( $this->store ); $instance->handleRequest( $webRequest ); } }