assertSame( $wikiId, $pageReference->getWikiId() ); $this->assertSame( $namespace, $pageReference->getNamespace() ); $this->assertSame( $dbKey, $pageReference->getDBkey() ); } public static function badConstructorProvider() { return [ [ NS_MAIN, 'Test', 2.3 ], ]; } /** * @dataProvider badConstructorProvider */ public function testConstructionErrors( $namespace, $dbKey, $wikiId ) { $this->expectException( ParameterAssertionException::class ); new PageReferenceValue( $namespace, $dbKey, $wikiId ); } public static function provideToString() { yield [ new PageReferenceValue( 0, 'Foo', PageReference::LOCAL ), '[0:Foo]' ]; yield [ new PageReferenceValue( 1, 'Bar_Baz', PageReference::LOCAL ), '[1:Bar_Baz]' ]; yield [ new PageReferenceValue( 200, 'tea', 'codewiki' ), '[200:tea]@codewiki' ]; } /** * @dataProvider provideToString */ public function testToString( PageReferenceValue $value, $expected ) { $this->assertSame( $expected, $value->__toString() ); } public static function provideIsSamePageAs() { yield [ new PageReferenceValue( 0, 'Foo', PageReference::LOCAL ), new PageReferenceValue( 0, 'Foo', PageReference::LOCAL ), true ]; yield [ new PageReferenceValue( 1, 'Bar_Baz', PageReference::LOCAL ), new PageReferenceValue( 1, 'Bar_Baz', PageReference::LOCAL ), true ]; yield [ new PageReferenceValue( 0, 'Foo', PageReference::LOCAL ), new PageReferenceValue( 0, 'Foozz', PageReference::LOCAL ), false ]; yield [ new PageReferenceValue( 0, 'Foo', PageReference::LOCAL ), new PageReferenceValue( 1, 'Foo', PageReference::LOCAL ), false ]; yield [ new PageReferenceValue( 0, 'Foo', '' ), new PageReferenceValue( 0, 'Foo', 'bar' ), false ]; yield [ new PageReferenceValue( 0, 'Foo', '' ), new PageReferenceValue( 0, 'Foo', 'bar' ), false ]; yield [ new PageReferenceValue( 0, 'Foo', 'bar' ), new PageReferenceValue( 0, 'Foo', 'bar' ), true ]; } /** * @dataProvider provideIsSamePageAs */ public function testIsSamePageAs( PageReferenceValue $a, PageReferenceValue $b, $expected ) { $this->assertSame( $expected, $a->isSamePageAs( $b ) ); $this->assertSame( $expected, $b->isSamePageAs( $a ) ); } /** * @covers \MediaWiki\Page\PageReferenceValue::localReference */ public function testLocalIdentity() { $page = PageReferenceValue::localReference( NS_MAIN, __METHOD__ ); $this->assertSame( NS_MAIN, $page->getNamespace() ); $this->assertSame( __METHOD__, $page->getDBkey() ); $this->assertSame( PageReference::LOCAL, $page->getWikiId() ); } }