+ /**
+ * @covers Title::newFromLinkTarget
+ * @dataProvider provideNewFromTitleValue
+ */
+ public function testNewFromLinkTarget( LinkTarget $value ) {
+ $title = Title::newFromLinkTarget( $value );
+
+ $dbkey = str_replace( ' ', '_', $value->getText() );
+ $this->assertEquals( $dbkey, $title->getDBkey() );
+ $this->assertEquals( $value->getNamespace(), $title->getNamespace() );
+ $this->assertEquals( $value->getFragment(), $title->getFragment() );
+ }
+
+ /**
+ * @covers Title::newFromLinkTarget
+ */
+ public function testNewFromLinkTarget_clone() {
+ $title = Title::newFromText( __METHOD__ );
+ $this->assertSame( $title, Title::newFromLinkTarget( $title ) );
+
+ // The Title::NEW_CLONE flag should ensure that a fresh instance is returned.
+ $clone = Title::newFromLinkTarget( $title, Title::NEW_CLONE );
+ $this->assertNotSame( $title, $clone );
+ $this->assertTrue( $clone->equals( $title ) );
+ }
+