wiki.techinc.nl/tests/phpunit/includes/TitleMethodsTest.php

470 lines
12 KiB
PHP
Raw Normal View History

<?php
use MediaWiki\Interwiki\InterwikiLookup;
use MediaWiki\MediaWikiServices;
/**
* @group ContentHandler
* @group Database
*
* @note We don't make assumptions about the main namespace.
* But we do expect the Help namespace to contain Wikitext.
*/
class TitleMethodsTest extends MediaWikiLangTestCase {
protected function setUp() : void {
parent::setUp();
$this->mergeMwGlobalArrayValue(
'wgExtraNamespaces',
[
12302 => 'TEST-JS',
12303 => 'TEST-JS_TALK',
]
);
2012-04-19 10:55:46 +00:00
$this->mergeMwGlobalArrayValue(
'wgNamespaceContentModels',
[
12302 => CONTENT_MODEL_JAVASCRIPT,
]
);
2012-04-26 10:11:34 +00:00
}
2012-04-19 10:55:46 +00:00
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
public static function provideInNamespace() {
return [
[ 'Main Page', NS_MAIN, true ],
[ 'Main Page', NS_TALK, false ],
[ 'Main Page', NS_USER, false ],
[ 'User:Foo', NS_USER, true ],
[ 'User:Foo', NS_USER_TALK, false ],
[ 'User:Foo', NS_TEMPLATE, false ],
[ 'User_talk:Foo', NS_USER_TALK, true ],
[ 'User_talk:Foo', NS_USER, false ],
];
}
/**
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
* @dataProvider provideInNamespace
* @covers Title::inNamespace
*/
public function testInNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->inNamespace( $ns ) );
}
/**
* @covers Title::inNamespaces
*/
public function testInNamespaces() {
$mainpage = Title::newFromText( 'Main Page' );
$this->assertTrue( $mainpage->inNamespaces( NS_MAIN, NS_USER ) );
$this->assertTrue( $mainpage->inNamespaces( [ NS_MAIN, NS_USER ] ) );
$this->assertTrue( $mainpage->inNamespaces( [ NS_USER, NS_MAIN ] ) );
$this->assertFalse( $mainpage->inNamespaces( [ NS_PROJECT, NS_TEMPLATE ] ) );
}
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
public static function provideHasSubjectNamespace() {
return [
[ 'Main Page', NS_MAIN, true ],
[ 'Main Page', NS_TALK, true ],
[ 'Main Page', NS_USER, false ],
[ 'User:Foo', NS_USER, true ],
[ 'User:Foo', NS_USER_TALK, true ],
[ 'User:Foo', NS_TEMPLATE, false ],
[ 'User_talk:Foo', NS_USER_TALK, true ],
[ 'User_talk:Foo', NS_USER, true ],
];
}
/**
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
* @dataProvider provideHasSubjectNamespace
* @covers Title::hasSubjectNamespace
*/
public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->hasSubjectNamespace( $ns ) );
}
public function dataGetContentModel() {
return [
[ 'Help:Foo', CONTENT_MODEL_WIKITEXT ],
[ 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ],
[ 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ],
[ 'User:Foo', CONTENT_MODEL_WIKITEXT ],
[ 'User:Foo.js', CONTENT_MODEL_WIKITEXT ],
[ 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ],
[ 'User:Foo/bar.css', CONTENT_MODEL_CSS ],
[ 'User talk:Foo/bar.css', CONTENT_MODEL_WIKITEXT ],
[ 'User:Foo/bar.js.xxx', CONTENT_MODEL_WIKITEXT ],
[ 'User:Foo/bar.xxx', CONTENT_MODEL_WIKITEXT ],
[ 'MediaWiki:Foo.js', CONTENT_MODEL_JAVASCRIPT ],
[ 'MediaWiki:Foo.css', CONTENT_MODEL_CSS ],
[ 'MediaWiki:Foo/bar.css', CONTENT_MODEL_CSS ],
[ 'MediaWiki:Foo.JS', CONTENT_MODEL_WIKITEXT ],
[ 'MediaWiki:Foo.CSS', CONTENT_MODEL_WIKITEXT ],
[ 'MediaWiki:Foo.css.xxx', CONTENT_MODEL_WIKITEXT ],
[ 'TEST-JS:Foo', CONTENT_MODEL_JAVASCRIPT ],
[ 'TEST-JS:Foo.js', CONTENT_MODEL_JAVASCRIPT ],
[ 'TEST-JS:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ],
[ 'TEST-JS_TALK:Foo.js', CONTENT_MODEL_WIKITEXT ],
];
2012-04-26 10:11:34 +00:00
}
/**
* @dataProvider dataGetContentModel
* @covers Title::getContentModel
2012-04-26 10:11:34 +00:00
*/
public function testGetContentModel( $title, $expectedModelId ) {
2012-04-26 10:11:34 +00:00
$title = Title::newFromText( $title );
$this->assertEquals( $expectedModelId, $title->getContentModel() );
2012-04-26 10:11:34 +00:00
}
/**
* @dataProvider dataGetContentModel
* @covers Title::hasContentModel
2012-04-26 10:11:34 +00:00
*/
public function testHasContentModel( $title, $expectedModelId ) {
2012-04-26 10:11:34 +00:00
$title = Title::newFromText( $title );
$this->assertTrue( $title->hasContentModel( $expectedModelId ) );
2012-04-26 10:11:34 +00:00
}
public static function provideIsSiteConfigPage() {
return [
[ 'Help:Foo', false ],
[ 'Help:Foo.js', false ],
[ 'Help:Foo/bar.js', false ],
[ 'User:Foo', false ],
[ 'User:Foo.js', false ],
[ 'User:Foo/bar.js', false ],
[ 'User:Foo/bar.json', false ],
[ 'User:Foo/bar.css', false ],
[ 'User:Foo/bar.JS', false ],
[ 'User:Foo/bar.JSON', false ],
[ 'User:Foo/bar.CSS', false ],
[ 'User talk:Foo/bar.css', false ],
[ 'User:Foo/bar.js.xxx', false ],
[ 'User:Foo/bar.xxx', false ],
[ 'MediaWiki:Foo.js', true ],
[ 'MediaWiki:Foo.json', true ],
[ 'MediaWiki:Foo.css', true ],
[ 'MediaWiki:Foo.JS', false ],
[ 'MediaWiki:Foo.JSON', false ],
[ 'MediaWiki:Foo.CSS', false ],
[ 'MediaWiki:Foo/bar.css', true ],
[ 'MediaWiki:Foo.css.xxx', false ],
[ 'TEST-JS:Foo', false ],
[ 'TEST-JS:Foo.js', false ],
];
}
/**
* @dataProvider provideIsSiteConfigPage
* @covers Title::isSiteConfigPage
*/
public function testSiteConfigPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isSiteConfigPage() );
}
public static function provideIsUserConfigPage() {
return [
[ 'Help:Foo', false ],
[ 'Help:Foo.js', false ],
[ 'Help:Foo/bar.js', false ],
[ 'User:Foo', false ],
[ 'User:Foo.js', false ],
[ 'User:Foo/bar.js', true ],
[ 'User:Foo/bar.JS', false ],
[ 'User:Foo/bar.json', true ],
[ 'User:Foo/bar.JSON', false ],
[ 'User:Foo/bar.css', true ],
[ 'User:Foo/bar.CSS', false ],
[ 'User talk:Foo/bar.css', false ],
[ 'User:Foo/bar.js.xxx', false ],
[ 'User:Foo/bar.xxx', false ],
[ 'MediaWiki:Foo.js', false ],
[ 'MediaWiki:Foo.json', false ],
[ 'MediaWiki:Foo.css', false ],
[ 'MediaWiki:Foo.JS', false ],
[ 'MediaWiki:Foo.JSON', false ],
[ 'MediaWiki:Foo.CSS', false ],
[ 'MediaWiki:Foo.css.xxx', false ],
[ 'TEST-JS:Foo', false ],
[ 'TEST-JS:Foo.js', false ],
];
}
/**
* @dataProvider provideIsUserConfigPage
* @covers Title::isUserConfigPage
*/
public function testIsUserConfigPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isUserConfigPage() );
}
public static function provideIsUserCssConfigPage() {
return [
[ 'Help:Foo', false ],
[ 'Help:Foo.css', false ],
[ 'User:Foo', false ],
[ 'User:Foo.js', false ],
[ 'User:Foo.json', false ],
[ 'User:Foo.css', false ],
[ 'User:Foo/bar.js', false ],
[ 'User:Foo/bar.json', false ],
[ 'User:Foo/bar.css', true ],
];
}
/**
* @dataProvider provideIsUserCssConfigPage
* @covers Title::isUserCssConfigPage
*/
public function testIsUserCssConfigPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isUserCssConfigPage() );
}
public static function provideIsUserJsConfigPage() {
return [
[ 'Help:Foo', false ],
[ 'Help:Foo.css', false ],
[ 'User:Foo', false ],
[ 'User:Foo.js', false ],
[ 'User:Foo.json', false ],
[ 'User:Foo.css', false ],
[ 'User:Foo/bar.js', true ],
[ 'User:Foo/bar.json', false ],
[ 'User:Foo/bar.css', false ],
];
}
/**
* @dataProvider provideIsUserJsConfigPage
* @covers Title::isUserJsConfigPage
*/
public function testIsUserJsConfigPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isUserJsConfigPage() );
}
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
public static function provideIsWikitextPage() {
return [
[ 'Help:Foo', true ],
[ 'Help:Foo.js', true ],
[ 'Help:Foo/bar.js', true ],
[ 'User:Foo', true ],
[ 'User:Foo.js', true ],
[ 'User:Foo/bar.js', false ],
[ 'User:Foo/bar.json', false ],
[ 'User:Foo/bar.css', false ],
[ 'User talk:Foo/bar.css', true ],
[ 'User:Foo/bar.js.xxx', true ],
[ 'User:Foo/bar.xxx', true ],
[ 'MediaWiki:Foo.js', false ],
[ 'User:Foo/bar.JS', true ],
[ 'User:Foo/bar.JSON', true ],
[ 'User:Foo/bar.CSS', true ],
[ 'MediaWiki:Foo.json', false ],
[ 'MediaWiki:Foo.css', false ],
[ 'MediaWiki:Foo.JS', true ],
[ 'MediaWiki:Foo.JSON', true ],
[ 'MediaWiki:Foo.CSS', true ],
[ 'MediaWiki:Foo.css.xxx', true ],
[ 'TEST-JS:Foo', false ],
[ 'TEST-JS:Foo.js', false ],
];
}
/**
Clean and repair many phpunit tests (+ fix implied configuration) This commit depends on the introduction of MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4. Various tests already set their globals, but forgot to restore them afterwards, or forgot to call the parent setUp, tearDown... Either way they won't have to anymore with setMwGlobals. Consistent use of function characteristics: * protected function setUp * protected function tearDown * public static function (provide..) (Matching the function signature with PHPUnit/Framework/TestCase.php) Replaces: * public function (setUp|tearDown)\( * protected function $1( * \tfunction (setUp|tearDown)\( * \tprotected function $1( * \tfunction (data|provide)\( * \tpublic static function $1\( Also renamed a few "data#", "provider#" and "provides#" functions to "provide#" for consistency. This also removes confusion where the /media tests had a few private methods called dataFile(), which were sometimes expected to be data providers. Fixes: TimestampTest often failed due to a previous test setting a different language (it tests "1 hour ago" so need to make sure it is set to English). MWNamespaceTest became a lot cleaner now that it executes with a known context. Though the now-redundant code that was removed didn't work anyway because wgContentNamespaces isn't keyed by namespace id, it had them was values... FileBackendTest: * Fixed: "PHP Fatal: Using $this when not in object context" HttpTest * Added comment about: "PHP Fatal: Call to protected MWHttpRequest::__construct()" (too much unrelated code to fix in this commit) ExternalStoreTest * Add an assertTrue as well, without it the test is useless because regardless of whether wgExternalStores is true or false it only uses it if it is an array. Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-08 10:56:20 +00:00
* @dataProvider provideIsWikitextPage
* @covers Title::isWikitextPage
*/
public function testIsWikitextPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isWikitextPage() );
}
public static function provideGetOtherPage() {
return [
[ 'Main Page', 'Talk:Main Page' ],
[ 'Talk:Main Page', 'Main Page' ],
[ 'Help:Main Page', 'Help talk:Main Page' ],
[ 'Help talk:Main Page', 'Help:Main Page' ],
[ 'Special:FooBar', null ],
[ 'Media:File.jpg', null ],
];
}
/**
* @dataProvider provideGetOtherpage
* @covers Title::getOtherPage
*
* @param string $text
* @param string|null $expected
*/
public function testGetOtherPage( $text, $expected ) {
if ( $expected === null ) {
$this->expectException( MWException::class );
}
$title = Title::newFromText( $text );
$this->assertEquals( $expected, $title->getOtherPage()->getPrefixedText() );
}
/**
* @covers Title::clearCaches
*/
public function testClearCaches() {
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
$title1 = Title::newFromText( 'Foo' );
$linkCache->addGoodLinkObj( 23, $title1 );
Title::clearCaches();
$title2 = Title::newFromText( 'Foo' );
$this->assertNotSame( $title1, $title2, 'title cache should be empty' );
$this->assertSame( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' );
}
public function provideGetLinkURL() {
yield 'Simple' => [
'/wiki/Goats',
NS_MAIN,
'Goats'
];
yield 'Fragment' => [
'/wiki/Goats#Goatificatiön',
NS_MAIN,
'Goats',
'Goatificatiön'
];
yield 'Unknown interwiki with fragment' => [
'https://xx.wiki.test/wiki/xyzzy:Goats#Goatificatiön',
NS_MAIN,
'Goats',
'Goatificatiön',
'xyzzy'
];
yield 'Interwiki with fragment' => [
'https://acme.test/Goats#Goatificati.C3.B6n',
NS_MAIN,
'Goats',
'Goatificatiön',
'acme'
];
yield 'Interwiki with query' => [
'https://acme.test/Goats?a=1&b=blank+blank#Goatificati.C3.B6n',
NS_MAIN,
'Goats',
'Goatificatiön',
'acme',
[
'a' => 1,
'b' => 'blank blank'
]
];
yield 'Local interwiki with fragment' => [
'https://yy.wiki.test/wiki/Goats#Goatificatiön',
NS_MAIN,
'Goats',
'Goatificatiön',
'yy'
];
}
/**
* @dataProvider provideGetLinkURL
*
* @covers Title::getLinkURL
* @covers Title::getFullURL
* @covers Title::getLocalURL
* @covers Title::getFragmentForURL
*/
public function testGetLinkURL(
$expected,
$ns,
$title,
$fragment = '',
$interwiki = '',
$query = '',
$query2 = false,
$proto = false
) {
$this->setMwGlobals( [
'wgServer' => 'https://xx.wiki.test',
'wgArticlePath' => '/wiki/$1',
'wgExternalInterwikiFragmentMode' => 'legacy',
'wgFragmentMode' => [ 'html5', 'legacy' ]
] );
$interwikiLookup = $this->createMock( InterwikiLookup::class );
$interwikiLookup->method( 'fetch' )
->willReturnCallback( function ( $interwiki ) {
switch ( $interwiki ) {
case '':
return null;
case 'acme':
return new Interwiki(
'acme',
'https://acme.test/$1'
);
case 'yy':
return new Interwiki(
'yy',
'https://yy.wiki.test/wiki/$1',
'/w/api.php',
'yywiki',
true
);
default:
return false;
}
} );
$this->setService( 'InterwikiLookup', $interwikiLookup );
$title = Title::makeTitle( $ns, $title, $fragment, $interwiki );
$this->assertSame( $expected, $title->getLinkURL( $query, $query2, $proto ) );
}
/**
* Integration test to catch regressions like T74870. Taken and modified
* from SemanticMediaWiki
*
* @covers Title::moveTo
*/
public function testTitleMoveCompleteIntegrationTest() {
$this->hideDeprecated( 'Title::moveTo' );
$oldTitle = Title::newFromText( 'Help:Some title' );
WikiPage::factory( $oldTitle )->doEditContent( new WikitextContent( 'foo' ), 'bar' );
$newTitle = Title::newFromText( 'Help:Some other title' );
$this->assertNull(
WikiPage::factory( $newTitle )->getRevision()
);
$this->assertTrue( $oldTitle->moveTo( $newTitle, false, 'test1', true ) );
$this->assertNotNull(
WikiPage::factory( $oldTitle )->getRevision()
);
$this->assertNotNull(
WikiPage::factory( $newTitle )->getRevision()
);
}
public function tearDown() : void {
Title::clearCaches();
parent::tearDown();
}
}