);
}
- public static function provideEquals() {
- return [
- [ 'Main Page', 'Main Page', true ],
- [ 'Main Page', 'Not The Main Page', false ],
- [ 'Main Page', 'Project:Main Page', false ],
- [ 'File:Example.png', 'Image:Example.png', true ],
- [ 'Special:Version', 'Special:Version', true ],
- [ 'Special:Version', 'Special:Recentchanges', false ],
- [ 'Special:Version', 'Main Page', false ],
- ];
- }
-
- /**
- * @dataProvider provideEquals
- * @covers Title::equals
- */
- public function testEquals( $titleA, $titleB, $expectedBool ) {
- $titleA = Title::newFromText( $titleA );
- $titleB = Title::newFromText( $titleB );
-
- $this->assertEquals( $expectedBool, $titleA->equals( $titleB ) );
- $this->assertEquals( $expectedBool, $titleB->equals( $titleA ) );
- }
-
public static function provideInNamespace() {
return [
[ 'Main Page', NS_MAIN, true ],
[ 'Main Page', false ],
];
}
+
+ public function provideEquals() {
+ yield [
+ Title::newFromText( 'Main Page' ),
+ Title::newFromText( 'Main Page' ),
+ true
+ ];
+ yield [
+ Title::newFromText( 'Main Page' ),
+ Title::newFromText( 'Not The Main Page' ),
+ false
+ ];
+ yield [
+ Title::newFromText( 'Main Page' ),
+ Title::newFromText( 'Project:Main Page' ),
+ false
+ ];
+ yield [
+ Title::newFromText( 'File:Example.png' ),
+ Title::newFromText( 'Image:Example.png' ),
+ true
+ ];
+ yield [
+ Title::newFromText( 'Special:Version' ),
+ Title::newFromText( 'Special:Version' ),
+ true
+ ];
+ yield [
+ Title::newFromText( 'Special:Version' ),
+ Title::newFromText( 'Special:Recentchanges' ),
+ false
+ ];
+ yield [
+ Title::newFromText( 'Special:Version' ),
+ Title::newFromText( 'Main Page' ),
+ false
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ true
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ Title::makeTitle( NS_MAIN, 'Bar', '', '' ),
+ false
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ Title::makeTitle( NS_TALK, 'Foo', '', '' ),
+ false
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+ Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+ true
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+ Title::makeTitle( NS_MAIN, 'Foo', 'Baz', '' ),
+ true
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', 'Bar', '' ),
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ true
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+ Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+ true
+ ];
+ yield [
+ Title::makeTitle( NS_MAIN, 'Foo', '', '' ),
+ Title::makeTitle( NS_MAIN, 'Foo', '', 'baz' ),
+ false
+ ];
+ }
+
+ /**
+ * @covers Title::equals
+ * @dataProvider provideEquals
+ */
+ public function testEquals( Title $firstValue, /* LinkTarget */ $secondValue, $expectedSame ) {
+ $this->assertSame(
+ $expectedSame,
+ $firstValue->equals( $secondValue )
+ );
+ }
}