outputFormatter = $this->getMockBuilder( '\SMW\MediaWiki\Specials\Admin\OutputFormatter' ) ->disableOriginalConstructor() ->getMock(); $this->replicationCheck = $this->getMockBuilder( '\SMW\Elastic\Indexer\Replication\ReplicationCheck' ) ->disableOriginalConstructor() ->getMock(); $this->entityCache = $this->getMockBuilder( '\SMW\EntityCache' ) ->disableOriginalConstructor() ->setMethods( [ 'fetch' ] ) ->getMock(); $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( ReplicationInfoProvider::class, new ReplicationInfoProvider( $this->outputFormatter, $this->replicationCheck, $this->entityCache ) ); } public function testGetTask() { $instance = new ReplicationInfoProvider( $this->outputFormatter, $this->replicationCheck, $this->entityCache ); $this->assertEquals( 'replication', $instance->getSupplementTask() ); $this->assertEquals( 'elastic/replication', $instance->getTask() ); } public function testGetHtml() { $instance = new ReplicationInfoProvider( $this->outputFormatter, $this->replicationCheck, $this->entityCache ); $this->assertIsString( $instance->getHtml() ); } public function tesHandleRequest_NoFailures() { $this->outputFormatter->expects( $this->once() ) ->method( 'addParentLink' ) ->with( [ 'action' => 'elastic' ] ); $this->replicationCheck->expects( $this->once() ) ->method( 'getReplicationFailures' ) ->willReturn( [] ); $instance = new ReplicationInfoProvider( $this->outputFormatter, $this->replicationCheck, $this->entityCache ); $instance->setStore( $this->store ); $instance->handleRequest( $this->webRequest ); } public function testHandleRequest_WithFailuresOnPages() { $ns = NS_FILE; $this->replicationCheck->expects( $this->once() ) ->method( 'getReplicationFailures' ) ->willReturn( [ 'Foo#0##', "Bar#$ns##" ] ); $instance = new ReplicationInfoProvider( $this->outputFormatter, $this->replicationCheck, $this->entityCache ); $instance->setStore( $this->store ); $instance->handleRequest( $this->webRequest ); } }