testEnvironment = new TestEnvironment(); $store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' ) ->disableOriginalConstructor() ->setMethods( [ 'getPropertyValues', 'service' ] ) ->getMock(); $store->expects( $this->any() ) ->method( 'getPropertyValues' ) ->willReturn( [] ); $this->testEnvironment->registerObject( 'Store', $store ); $this->stringValidator = $this->testEnvironment->newValidatorFactory()->newStringValidator(); } protected function tearDown(): void { $this->testEnvironment->tearDown(); parent::tearDown(); } public function testCanConstruct() { $this->assertInstanceOf( '\SMW\MediaWiki\Specials\SpecialPageProperty', new SpecialPageProperty() ); } /** * @dataProvider queryParameterProvider */ public function testQueryParameter( $query, $expected ) { $instance = new SpecialPageProperty(); $instance->getContext()->setTitle( MediaWikiServices::getInstance()->getTitleFactory()->newFromText( 'PageProperty' ) ); $instance->execute( $query ); $this->stringValidator->assertThatStringContains( $expected, $instance->getOutput()->getHtml() ); } public function testRequestParameter() { $request = [ 'type' => 'Has subobject', 'from' => 'Bar' ]; $expected = [ 'value="Has subobject"', 'value="Bar"' ]; $instance = new SpecialPageProperty(); $instance->getContext()->setTitle( MediaWikiServices::getInstance()->getTitleFactory()->newFromText( 'PageProperty' ) ); $instance->getContext()->setRequest( new FauxRequest( $request, true ) ); $instance->execute( null ); $this->stringValidator->assertThatStringContains( $expected, $instance->getOutput()->getHtml() ); } public function queryParameterProvider() { # 0 $provider[] = [ 'Has page::Has prop', [ 'type=Has+prop', 'from=Has+page' ] ]; return $provider; } }