outputFormatter = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\OutputFormatter' ) ->disableOriginalConstructor() ->getMock(); $this->outputFormatter->expects( $this->any() ) ->method( 'encodeAsJson' ) ->willReturn( '' ); $this->webRequest = $this->getMockBuilder( '\MediaWiki\Request\WebRequest' ) ->disableOriginalConstructor() ->getMock(); $this->store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->setMethods( [ 'getConnection' ] ) ->getMockForAbstractClass(); $this->store->expects( $this->any() ) ->method( 'getConnection' ) ->willReturn( new DummyClient() ); } public function testCanConstruct() { $this->assertInstanceOf( NodesInfoProvider::class, new NodesInfoProvider( $this->outputFormatter ) ); } public function testGetTask() { $instance = new NodesInfoProvider( $this->outputFormatter ); $this->assertEquals( 'nodes', $instance->getSupplementTask() ); $this->assertEquals( 'elastic/nodes', $instance->getTask() ); } public function testGetHtml() { $instance = new NodesInfoProvider( $this->outputFormatter ); $this->assertIsString( $instance->getHtml() ); } public function testHandleRequest() { $this->outputFormatter->expects( $this->once() ) ->method( 'addParentLink' ) ->with( [ 'action' => 'elastic' ] ); $instance = new NodesInfoProvider( $this->outputFormatter ); $instance->setStore( $this->store ); $instance->handleRequest( $this->webRequest ); } }