aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2022-09-23 21:53:11 +0200
committerUmherirrender <umherirrender_de.wp@web.de>2022-09-23 21:53:11 +0200
commit89b2d11a0dfbf9233166ca6df33819877d7ced1d (patch)
treea0cd0ce12e8892f55794b0bb22530e51dff1d504 /tests
parent1e60c7337ae7022863754c485d7e218d92cf3cb8 (diff)
downloadmediawikicore-89b2d11a0dfbf9233166ca6df33819877d7ced1d.tar.gz
mediawikicore-89b2d11a0dfbf9233166ca6df33819877d7ced1d.zip
tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
Diffstat (limited to 'tests')
-rw-r--r--tests/phpunit/MediaWikiIntegrationTestCase.php2
-rw-r--r--tests/phpunit/includes/CategoryTest.php4
-rw-r--r--tests/phpunit/includes/EditPageConstraintsTest.php4
-rw-r--r--tests/phpunit/includes/ExtraParserTest.php4
-rw-r--r--tests/phpunit/includes/MergeHistoryTest.php20
-rw-r--r--tests/phpunit/includes/MovePageTest.php16
-rw-r--r--tests/phpunit/includes/OutputPageTest.php16
-rw-r--r--tests/phpunit/includes/SampleTest.php4
-rw-r--r--tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php2
-rw-r--r--tests/phpunit/includes/TemplateCategoriesTest.php4
-rw-r--r--tests/phpunit/includes/api/ApiChangeContentModelTest.php8
-rw-r--r--tests/phpunit/includes/api/ApiComparePagesTest.php20
-rw-r--r--tests/phpunit/includes/api/ApiOptionsTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiResultTest.php4
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatXmlTest.php2
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBasicTest.php2
-rw-r--r--tests/phpunit/includes/cache/BacklinkCacheTest.php2
-rw-r--r--tests/phpunit/includes/cache/MessageCacheTest.php2
-rw-r--r--tests/phpunit/includes/htmlform/HTMLFormFieldTest.php2
-rw-r--r--tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php2
-rw-r--r--tests/phpunit/includes/page/ArticleTablesTest.php2
-rw-r--r--tests/phpunit/includes/page/PageArchiveTest.php2
-rw-r--r--tests/phpunit/includes/page/UndeletePageTest.php2
-rw-r--r--tests/phpunit/integration/includes/CommentFormatter/CommentParserTest.php10
-rw-r--r--tests/phpunit/languages/LanguageConverterTest.php4
-rw-r--r--tests/phpunit/languages/converters/KkConverterTest.php2
26 files changed, 72 insertions, 72 deletions
diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php
index 62ba032097a1..604d386557e8 100644
--- a/tests/phpunit/MediaWikiIntegrationTestCase.php
+++ b/tests/phpunit/MediaWikiIntegrationTestCase.php
@@ -1600,7 +1600,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
$user = static::getTestSysop()->getUser();
// Make 1 page with 1 revision
- $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( Title::newFromText( 'UTPage' ) );
+ $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( Title::makeTitle( NS_MAIN, 'UTPage' ) );
if ( $page->getId() == 0 ) {
$page->doUserEditContent(
new WikitextContent( 'UTContent' ),
diff --git a/tests/phpunit/includes/CategoryTest.php b/tests/phpunit/includes/CategoryTest.php
index 4be8c8a4da99..66143ce5caa2 100644
--- a/tests/phpunit/includes/CategoryTest.php
+++ b/tests/phpunit/includes/CategoryTest.php
@@ -102,7 +102,7 @@ class CategoryTest extends MediaWikiIntegrationTestCase {
* @covers Category::newFromTitle()
*/
public function testNewFromTitle() {
- $title = Title::newFromText( 'Category:Example' );
+ $title = Title::makeTitle( NS_CATEGORY, 'Example' );
$category = Category::newFromTitle( $title );
$this->assertSame( 'Example', $category->getName() );
$this->assertTrue( $title->isSamePageAs( $category->getPage() ) );
@@ -167,7 +167,7 @@ class CategoryTest extends MediaWikiIntegrationTestCase {
$category = Category::newFromRow(
$row,
- Title::newFromText( NS_CATEGORY, 'Example' )
+ Title::makeTitle( NS_CATEGORY, 'Example' )
);
$this->assertFalse( $category->getID() );
diff --git a/tests/phpunit/includes/EditPageConstraintsTest.php b/tests/phpunit/includes/EditPageConstraintsTest.php
index 40d4484bc1ea..96604413cf3b 100644
--- a/tests/phpunit/includes/EditPageConstraintsTest.php
+++ b/tests/phpunit/includes/EditPageConstraintsTest.php
@@ -263,7 +263,7 @@ class EditPageConstraintsTest extends MediaWikiLangTestCase {
'format' => CONTENT_FORMAT_TEXT,
];
- $title = Title::newFromText( 'Example', NS_MAIN );
+ $title = Title::makeTitle( NS_MAIN, 'Example' );
$this->assertSame(
CONTENT_MODEL_WIKITEXT,
$title->getContentModel(),
@@ -449,7 +449,7 @@ class EditPageConstraintsTest extends MediaWikiLangTestCase {
'wpSummary' => 'Summary'
];
- $title = Title::newFromText( 'Example.jpg', NS_FILE );
+ $title = Title::makeTitle( NS_FILE, 'Example.jpg' );
$this->assertEdit(
$title,
null,
diff --git a/tests/phpunit/includes/ExtraParserTest.php b/tests/phpunit/includes/ExtraParserTest.php
index 5244c6f22ccc..64d7a7014c26 100644
--- a/tests/phpunit/includes/ExtraParserTest.php
+++ b/tests/phpunit/includes/ExtraParserTest.php
@@ -45,7 +45,7 @@ class ExtraParserTest extends MediaWikiIntegrationTestCase {
public function testLongNumericLinesDontKillTheParser() {
$longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
- $title = Title::newFromText( 'Unit test' );
+ $title = Title::makeTitle( NS_MAIN, 'Unit test' );
$options = ParserOptions::newFromUser( new User() );
$this->assertEquals( "<p>$longLine</p>",
$this->parser->parse( $longLine, $title, $options )->getText( [ 'unwrap' => true ] ) );
@@ -57,7 +57,7 @@ class ExtraParserTest extends MediaWikiIntegrationTestCase {
*/
public function testSpecialPageTransclusionRestoresGlobalState() {
$text = "{{Special:ApiHelp/help}}";
- $title = Title::newFromText( 'testSpecialPageTransclusionRestoresGlobalState' );
+ $title = Title::makeTitle( NS_MAIN, 'TestSpecialPageTransclusionRestoresGlobalState' );
$options = ParserOptions::newFromUser( new User() );
RequestContext::getMain()->setTitle( $title );
diff --git a/tests/phpunit/includes/MergeHistoryTest.php b/tests/phpunit/includes/MergeHistoryTest.php
index 2817805f75c5..de6e3da0fac6 100644
--- a/tests/phpunit/includes/MergeHistoryTest.php
+++ b/tests/phpunit/includes/MergeHistoryTest.php
@@ -82,8 +82,8 @@ class MergeHistoryTest extends MediaWikiIntegrationTestCase {
$mh = $this->getMockBuilder( MergeHistory::class )
->onlyMethods( [ 'getRevisionCount' ] )
->setConstructorArgs( [
- Title::newFromText( 'Test' ),
- Title::newFromText( 'Test2' ),
+ Title::makeTitle( NS_MAIN, 'Test' ),
+ Title::makeTitle( NS_MAIN, 'Test2' ),
null,
$this->getServiceContainer()->getDBLoadBalancer(),
$this->getServiceContainer()->getContentHandlerFactory(),
@@ -115,8 +115,8 @@ class MergeHistoryTest extends MediaWikiIntegrationTestCase {
public function testCheckPermissions() {
$factory = $this->getServiceContainer()->getMergeHistoryFactory();
$mh = $factory->newMergeHistory(
- Title::newFromText( 'Test' ),
- Title::newFromText( 'Test2' )
+ Title::makeTitle( NS_MAIN, 'Test' ),
+ Title::makeTitle( NS_MAIN, 'Test2' )
);
foreach ( [ 'authorizeMerge', 'probablyCanMerge' ] as $method ) {
@@ -142,8 +142,8 @@ class MergeHistoryTest extends MediaWikiIntegrationTestCase {
public function testGetMergedRevisionCount() {
$factory = $this->getServiceContainer()->getMergeHistoryFactory();
$mh = $factory->newMergeHistory(
- Title::newFromText( 'Merge1' ),
- Title::newFromText( 'Merge2' )
+ Title::makeTitle( NS_MAIN, 'Merge1' ),
+ Title::makeTitle( NS_MAIN, 'Merge2' )
);
$sysop = static::getTestSysop()->getUser();
@@ -158,8 +158,8 @@ class MergeHistoryTest extends MediaWikiIntegrationTestCase {
* @covers MergeHistory::merge
*/
public function testSourceUpdateWithRedirectSupport() {
- $title = Title::newFromText( 'Merge1' );
- $title2 = Title::newFromText( 'Merge2' );
+ $title = Title::makeTitle( NS_MAIN, 'Merge1' );
+ $title2 = Title::makeTitle( NS_MAIN, 'Merge2' );
$factory = $this->getServiceContainer()->getMergeHistoryFactory();
$mh = $factory->newMergeHistory( $title, $title2 );
@@ -195,9 +195,9 @@ class MergeHistoryTest extends MediaWikiIntegrationTestCase {
]
] );
- $title = Title::newFromText( 'Merge3' );
+ $title = Title::makeTitle( NS_MAIN, 'Merge3' );
$title->setContentModel( 'testing' );
- $title2 = Title::newFromText( 'Merge4' );
+ $title2 = Title::makeTitle( NS_MAIN, 'Merge4' );
$title2->setContentModel( 'testing' );
$factory = $this->getServiceContainer()->getMergeHistoryFactory();
diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php
index 98eb91614ba1..8caee4138beb 100644
--- a/tests/phpunit/includes/MovePageTest.php
+++ b/tests/phpunit/includes/MovePageTest.php
@@ -350,13 +350,13 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
}
);
- $oldTitle = Title::newFromText( 'Some old title' );
+ $oldTitle = Title::makeTitle( NS_MAIN, 'Some old title' );
WikiPage::factory( $oldTitle )->doUserEditContent(
new WikitextContent( 'foo' ),
$this->getTestSysop()->getUser(),
'bar'
);
- $newTitle = Title::newFromText( 'A brand new title' );
+ $newTitle = Title::makeTitle( NS_MAIN, 'A brand new title' );
$mp = $this->newMovePageWithMocks( $oldTitle, $newTitle );
$user = User::newFromName( 'TitleMove tester' );
$status = $mp->move( $user, 'Reason', true );
@@ -481,8 +481,8 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
public function testRedirects() {
$this->editPage( 'ExistentRedirect', '#REDIRECT [[Existent]]' );
$mp = $this->newMovePageWithMocks(
- Title::newFromText( 'Existent' ),
- Title::newFromText( 'ExistentRedirect' )
+ Title::makeTitle( NS_MAIN, 'Existent' ),
+ Title::makeTitle( NS_MAIN, 'ExistentRedirect' )
);
$this->assertSame(
[],
@@ -492,8 +492,8 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
$this->editPage( 'ExistentRedirect3', '#REDIRECT [[Existent]]' );
$mp = $this->newMovePageWithMocks(
- Title::newFromText( 'Existent2' ),
- Title::newFromText( 'ExistentRedirect3' )
+ Title::makeTitle( NS_MAIN, 'Existent2' ),
+ Title::makeTitle( NS_MAIN, 'ExistentRedirect3' )
);
$this->assertSame(
[ [ 'redirectexists', 'ExistentRedirect3' ] ],
@@ -503,8 +503,8 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
$this->editPage( 'ExistentRedirect3', '#REDIRECT [[Existent2]]' );
$mp = $this->newMovePageWithMocks(
- Title::newFromText( 'Existent' ),
- Title::newFromText( 'ExistentRedirect3' )
+ Title::makeTitle( NS_MAIN, 'Existent' ),
+ Title::makeTitle( NS_MAIN, 'ExistentRedirect3' )
);
$this->assertSame(
[ [ 'articleexists', 'ExistentRedirect3' ] ],
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index f58e9bb9b7e5..736f8ef17c37 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -792,7 +792,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
$this->assertSame( 'My test page', $op->getTitle()->getPrefixedText() );
- $op->setTitle( Title::newFromText( 'Another test page' ) );
+ $op->setTitle( Title::makeTitle( NS_MAIN, 'Another test page' ) );
$this->assertSame( 'Another test page', $op->getTitle()->getPrefixedText() );
}
@@ -1285,7 +1285,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
->onlyMethods( [ 'addCategoryLinksToLBAndGetResult', 'getTitle' ] )
->getMock();
- $title = Title::newFromText( 'My test page' );
+ $title = Title::makeTitle( NS_MAIN, 'My test page' );
$op->method( 'getTitle' )
->willReturn( $title );
@@ -1725,10 +1725,10 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
[ '== Title ==' ],
"<h2><span class=\"mw-headline\" id=\"Title\">Title</span></h2>",
], 'With title at start' => [
- [ '* {{PAGENAME}}', true, Title::newFromText( 'Talk:Some page' ) ],
+ [ '* {{PAGENAME}}', true, Title::makeTitle( NS_TALK, 'Some page' ) ],
"<ul><li>Some page</li></ul>\n",
], 'With title not at start' => [
- [ '* {{PAGENAME}}', false, Title::newFromText( 'Talk:Some page' ) ],
+ [ '* {{PAGENAME}}', false, Title::makeTitle( NS_TALK, 'Some page' ) ],
"<p>* Some page</p>",
], 'Untidy input' => [
[ '<b>{{PAGENAME}}', true, $somePageRef ],
@@ -1746,10 +1746,10 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
[ '* <b>Not a list', false ],
'<p>* <b>Not a list</b></p>',
], 'With title at start' => [
- [ '* {{PAGENAME}}', true, Title::newFromText( 'Talk:Some page' ) ],
+ [ '* {{PAGENAME}}', true, Title::makeTitle( NS_TALK, 'Some page' ) ],
"<ul><li>Some page</li></ul>",
], 'With title not at start' => [
- [ '* {{PAGENAME}}', false, Title::newFromText( 'Talk:Some page' ) ],
+ [ '* {{PAGENAME}}', false, Title::makeTitle( NS_TALK, 'Some page' ) ],
"<p>* Some page</p>",
], 'EditPage' => [
[ "<div class='mw-editintro'>{{PAGENAME}}", true, $somePageRef ],
@@ -3274,7 +3274,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
*/
public function testGetJsVarsEditable( Authority $performer, array $expectedEditableConfig ) {
$op = $this->newInstance( [], null, null, $performer );
- $op->getContext()->getSkin()->setRelevantTitle( Title::newFromText( 'RelevantTitle' ) );
+ $op->getContext()->getSkin()->setRelevantTitle( Title::makeTitle( NS_MAIN, 'RelevantTitle' ) );
$this->assertArraySubmapSame( $expectedEditableConfig, $op->getJSVars() );
}
@@ -3374,7 +3374,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
] ) );
if ( $option !== 'notitle' ) {
- $context->setTitle( Title::newFromText( 'My test page' ) );
+ $context->setTitle( Title::makeTitle( NS_MAIN, 'My test page' ) );
}
if ( $request ) {
diff --git a/tests/phpunit/includes/SampleTest.php b/tests/phpunit/includes/SampleTest.php
index c01c64b26e78..73cdb586f5c0 100644
--- a/tests/phpunit/includes/SampleTest.php
+++ b/tests/phpunit/includes/SampleTest.php
@@ -37,11 +37,11 @@ class SampleTest extends MediaWikiLangTestCase {
* https://phpunit.de/manual/6.5/en/other-uses-for-tests.html
*/
public function testTitleObjectStringConversion() {
- $title = Title::newFromText( "text" );
+ $title = Title::makeTitle( NS_MAIN, "Text" );
$this->assertInstanceOf( Title::class, $title, "Title creation" );
$this->assertEquals( "Text", $title, "Automatic string conversion" );
- $title = Title::newFromText( "text", NS_MEDIA );
+ $title = Title::makeTitle( NS_MEDIA, "Text" );
$this->assertEquals( "Media:Text", $title, "Title creation with namespace" );
}
diff --git a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php
index a8be45a18905..72261661f928 100644
--- a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php
+++ b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php
@@ -958,7 +958,7 @@ class DerivedPageDataUpdaterTest extends MediaWikiIntegrationTestCase {
*/
public function testIsCountableNotContentPage() {
$updater = $this->getDerivedPageDataUpdater(
- Title::newFromText( 'Main_Page', NS_TALK )
+ Title::makeTitle( NS_TALK, 'Main_Page' )
);
self::assertFalse( $updater->isCountable() );
}
diff --git a/tests/phpunit/includes/TemplateCategoriesTest.php b/tests/phpunit/includes/TemplateCategoriesTest.php
index 4a6a2054015e..27aac5b26658 100644
--- a/tests/phpunit/includes/TemplateCategoriesTest.php
+++ b/tests/phpunit/includes/TemplateCategoriesTest.php
@@ -13,7 +13,7 @@ class TemplateCategoriesTest extends MediaWikiIntegrationTestCase {
$this->overrideUserPermissions( $user, [ 'createpage', 'edit', 'purge', 'delete' ] );
$wikiPageFactory = $this->getServiceContainer()->getWikiPageFactory();
- $title = Title::newFromText( "Categorized from template" );
+ $title = Title::makeTitle( NS_MAIN, "Categorized from template" );
$page = $wikiPageFactory->newFromTitle( $title );
$page->doUserEditContent(
new WikitextContent( '{{Categorising template}}' ),
@@ -28,7 +28,7 @@ class TemplateCategoriesTest extends MediaWikiIntegrationTestCase {
);
// Create template
- $template = $wikiPageFactory->newFromTitle( Title::newFromText( 'Template:Categorising template' ) );
+ $template = $wikiPageFactory->newFromTitle( Title::makeTitle( NS_TEMPLATE, 'Categorising template' ) );
$template->doUserEditContent(
new WikitextContent( '[[Category:Solved bugs]]' ),
$user,
diff --git a/tests/phpunit/includes/api/ApiChangeContentModelTest.php b/tests/phpunit/includes/api/ApiChangeContentModelTest.php
index bf18e3074182..74bc305e4205 100644
--- a/tests/phpunit/includes/api/ApiChangeContentModelTest.php
+++ b/tests/phpunit/includes/api/ApiChangeContentModelTest.php
@@ -82,7 +82,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
public function testChangeNeeded() {
$this->assertSame(
'wikitext',
- Title::newFromText( 'ExistingPage' )->getContentModel(),
+ Title::makeTitle( NS_MAIN, 'ExistingPage' )->getContentModel(),
'`ExistingPage` should be wikitext'
);
@@ -134,7 +134,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
* @param string $expectedMessage expected fatal
*/
public function testEditFilterMergedContent( $customMessage, $expectedMessage ) {
- $title = Title::newFromText( 'ExistingPage' );
+ $title = Title::makeTitle( NS_MAIN, 'ExistingPage' );
$this->assertSame(
'wikitext',
@@ -180,7 +180,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
* Test the ContentModelCanBeUsedOn hook can be intercepted
*/
public function testContentModelCanBeUsedOn() {
- $title = Title::newFromText( 'ExistingPage' );
+ $title = Title::makeTitle( NS_MAIN, 'ExistingPage' );
$this->assertSame(
'wikitext',
@@ -267,7 +267,7 @@ class ApiChangeContentModelTest extends ApiTestCase {
* Test that it works
*/
public function testEverythingWorks() {
- $title = Title::newFromText( 'ExistingPage' );
+ $title = Title::makeTitle( NS_MAIN, 'ExistingPage' );
$performer = $this->mockAnonAuthorityWithPermissions(
[ 'edit', 'editcontentmodel', 'writeapi', 'applychangetags' ]
);
diff --git a/tests/phpunit/includes/api/ApiComparePagesTest.php b/tests/phpunit/includes/api/ApiComparePagesTest.php
index 7c07d4121307..d52c22aae471 100644
--- a/tests/phpunit/includes/api/ApiComparePagesTest.php
+++ b/tests/phpunit/includes/api/ApiComparePagesTest.php
@@ -41,13 +41,13 @@ class ApiComparePagesTest extends ApiTestCase {
self::$repl['revA2'] = $this->addPage( 'A', 'A 2' );
self::$repl['revA3'] = $this->addPage( 'A', 'A 3' );
self::$repl['revA4'] = $this->addPage( 'A', 'A 4' );
- self::$repl['pageA'] = Title::newFromText( 'ApiComparePagesTest A' )->getArticleID();
+ self::$repl['pageA'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest A' )->getArticleID();
self::$repl['revB1'] = $this->addPage( 'B', 'B 1' );
self::$repl['revB2'] = $this->addPage( 'B', 'B 2' );
self::$repl['revB3'] = $this->addPage( 'B', 'B 3' );
self::$repl['revB4'] = $this->addPage( 'B', 'B 4' );
- self::$repl['pageB'] = Title::newFromText( 'ApiComparePagesTest B' )->getArticleID();
+ self::$repl['pageB'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest B' )->getArticleID();
$updateTimestamps = [
self::$repl['revB1'] => '20010101011101',
self::$repl['revB2'] => '20020202022202',
@@ -66,35 +66,35 @@ class ApiComparePagesTest extends ApiTestCase {
self::$repl['revC1'] = $this->addPage( 'C', 'C 1' );
self::$repl['revC2'] = $this->addPage( 'C', 'C 2' );
self::$repl['revC3'] = $this->addPage( 'C', 'C 3' );
- self::$repl['pageC'] = Title::newFromText( 'ApiComparePagesTest C' )->getArticleID();
+ self::$repl['pageC'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest C' )->getArticleID();
$id = $this->addPage( 'D', 'D 1' );
- self::$repl['pageD'] = Title::newFromText( 'ApiComparePagesTest D' )->getArticleID();
+ self::$repl['pageD'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest D' )->getArticleID();
wfGetDB( DB_PRIMARY )->delete( 'revision', [ 'rev_id' => $id ] );
self::$repl['revE1'] = $this->addPage( 'E', 'E 1' );
self::$repl['revE2'] = $this->addPage( 'E', 'E 2' );
self::$repl['revE3'] = $this->addPage( 'E', 'E 3' );
self::$repl['revE4'] = $this->addPage( 'E', 'E 4' );
- self::$repl['pageE'] = Title::newFromText( 'ApiComparePagesTest E' )->getArticleID();
+ self::$repl['pageE'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest E' )->getArticleID();
wfGetDB( DB_PRIMARY )->update(
'page', [ 'page_latest' => 0 ], [ 'page_id' => self::$repl['pageE'] ]
);
self::$repl['revF1'] = $this->addPage( 'F', "== Section 1 ==\nF 1.1\n\n== Section 2 ==\nF 1.2" );
- self::$repl['pageF'] = Title::newFromText( 'ApiComparePagesTest F' )->getArticleID();
+ self::$repl['pageF'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest F' )->getArticleID();
self::$repl['revG1'] = $this->addPage( 'G', "== Section 1 ==\nG 1.1", CONTENT_MODEL_TEXT );
- self::$repl['pageG'] = Title::newFromText( 'ApiComparePagesTest G' )->getArticleID();
+ self::$repl['pageG'] = Title::makeTitle( NS_MAIN, 'ApiComparePagesTest G' )->getArticleID();
$page = $this->getServiceContainer()->getWikiPageFactory()
- ->newFromTitle( Title::newFromText( 'ApiComparePagesTest C' ) );
+ ->newFromTitle( Title::makeTitle( NS_MAIN, 'ApiComparePagesTest C' ) );
$this->deletePage( $page, 'Test for ApiComparePagesTest', $user );
RevisionDeleter::createList(
'revision',
RequestContext::getMain(),
- Title::newFromText( 'ApiComparePagesTest B' ),
+ Title::makeTitle( NS_MAIN, 'ApiComparePagesTest B' ),
[ self::$repl['revB2'] ]
)->setVisibility( [
'value' => [
@@ -108,7 +108,7 @@ class ApiComparePagesTest extends ApiTestCase {
RevisionDeleter::createList(
'revision',
RequestContext::getMain(),
- Title::newFromText( 'ApiComparePagesTest B' ),
+ Title::makeTitle( NS_MAIN, 'ApiComparePagesTest B' ),
[ self::$repl['revB3'] ]
)->setVisibility( [
'value' => [
diff --git a/tests/phpunit/includes/api/ApiOptionsTest.php b/tests/phpunit/includes/api/ApiOptionsTest.php
index bdeb00ff8f00..ba0fa076dbcc 100644
--- a/tests/phpunit/includes/api/ApiOptionsTest.php
+++ b/tests/phpunit/includes/api/ApiOptionsTest.php
@@ -39,7 +39,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
// Create a new context
$this->mContext = new DerivativeContext( new RequestContext() );
- $this->mContext->getContext()->setTitle( Title::newFromText( 'Test' ) );
+ $this->mContext->getContext()->setTitle( Title::makeTitle( NS_MAIN, 'Test' ) );
$this->mContext->setAuthority(
$this->mockUserAuthorityWithPermissions( $this->mUserMock, [ 'editmyoptions' ] )
);
diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php
index 03b2121a46b8..a771b83f0c9e 100644
--- a/tests/phpunit/includes/api/ApiResultTest.php
+++ b/tests/phpunit/includes/api/ApiResultTest.php
@@ -87,7 +87,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
}
$arr = [];
- $title = Title::newFromText( "MediaWiki:Foobar" );
+ $title = Title::makeTitle( NS_MEDIAWIKI, "Foobar" );
$obj = (object)[ 'foo' => 1, 'bar' => 2 ];
ApiResult::setValue( $arr, 'title', $title );
ApiResult::setValue( $arr, 'obj', $obj );
@@ -334,7 +334,7 @@ class ApiResultTest extends MediaWikiIntegrationTestCase {
}
$result->reset();
- $title = Title::newFromText( "MediaWiki:Foobar" );
+ $title = Title::makeTitle( NS_MEDIAWIKI, "Foobar" );
$obj = (object)[ 'foo' => 1, 'bar' => 2 ];
$result->addValue( null, 'title', $title );
$result->addValue( null, 'obj', $obj );
diff --git a/tests/phpunit/includes/api/format/ApiFormatXmlTest.php b/tests/phpunit/includes/api/format/ApiFormatXmlTest.php
index 28a9e9e971e7..0a8b94520c1f 100644
--- a/tests/phpunit/includes/api/format/ApiFormatXmlTest.php
+++ b/tests/phpunit/includes/api/format/ApiFormatXmlTest.php
@@ -124,7 +124,7 @@ class ApiFormatXmlTest extends ApiFormatTestBase {
[ 'xslt' => 'MediaWiki:ApiFormatXmlTest' ] ],
[ [],
'<?xml version="1.0"?><?xml-stylesheet href="' .
- htmlspecialchars( Title::newFromText( 'MediaWiki:ApiFormatXmlTest.xsl' )->getLocalURL( 'action=raw' ) ) .
+ htmlspecialchars( Title::makeTitle( NS_MEDIAWIKI, 'ApiFormatXmlTest.xsl' )->getLocalURL( 'action=raw' ) ) .
'" type="text/xsl" ?><api />',
[ 'xslt' => 'MediaWiki:ApiFormatXmlTest.xsl' ] ],
];
diff --git a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
index 20fe86ec1691..f9cd579546f5 100644
--- a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php
@@ -38,7 +38,7 @@ class ApiQueryBasicTest extends ApiQueryTestBase {
*/
public function addDBDataOnce() {
try {
- if ( Title::newFromText( 'AQBT-All' )->exists() ) {
+ if ( Title::makeTitle( NS_MAIN, 'AQBT-All' )->exists() ) {
return;
}
diff --git a/tests/phpunit/includes/cache/BacklinkCacheTest.php b/tests/phpunit/includes/cache/BacklinkCacheTest.php
index 4fa8a19ba5ce..a98bae8d96b8 100644
--- a/tests/phpunit/includes/cache/BacklinkCacheTest.php
+++ b/tests/phpunit/includes/cache/BacklinkCacheTest.php
@@ -141,7 +141,7 @@ class BacklinkCacheTest extends MediaWikiIntegrationTestCase {
*/
public function testPartition() {
$targetId = $this->getServiceContainer()->getLinkTargetLookup()->acquireLinkTargetId(
- Title::newFromText( 'BLCTest1234' ),
+ Title::makeTitle( NS_MAIN, 'BLCTest1234' ),
$this->db
);
$targetRow = [
diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php
index a659c3ba51a1..292919fd9e24 100644
--- a/tests/phpunit/includes/cache/MessageCacheTest.php
+++ b/tests/phpunit/includes/cache/MessageCacheTest.php
@@ -69,7 +69,7 @@ class MessageCacheTest extends MediaWikiLangTestCase {
$title = "$title/$lang";
}
- $title = Title::newFromText( $title, NS_MEDIAWIKI );
+ $title = Title::makeTitle( NS_MEDIAWIKI, $title );
$wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
$content = ContentHandler::makeContent( $content, $title );
$summary = CommentStoreComment::newUnsavedComment( "$lang translation test case" );
diff --git a/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php b/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php
index 73412e4c578b..a150e518f063 100644
--- a/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php
+++ b/tests/phpunit/includes/htmlform/HTMLFormFieldTest.php
@@ -15,7 +15,7 @@ class HTMLFormFieldTest extends PHPUnit\Framework\TestCase {
$context = new DerivativeContext( RequestContext::getMain() );
$context->setRequest( $request );
$form = HTMLForm::factory( 'ooui', $descriptor, $context );
- $form->setTitle( Title::newFromText( 'Main Page' ) )->setSubmitCallback( static function () {
+ $form->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) )->setSubmitCallback( static function () {
return true;
} )->prepareForm();
$status = $form->trySubmit();
diff --git a/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php b/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php
index bdb5cedd064c..eea532f388c1 100644
--- a/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php
+++ b/tests/phpunit/includes/htmlform/HTMLRestrictionsFieldTest.php
@@ -35,7 +35,7 @@ class HTMLRestrictionsFieldTest extends PHPUnit\Framework\TestCase {
$form = HTMLForm::factory( 'ooui', [
'restrictions' => [ 'class' => HTMLRestrictionsField::class ],
], $context );
- $form->setTitle( Title::newFromText( 'Main Page' ) )->setSubmitCallback( static function () {
+ $form->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) )->setSubmitCallback( static function () {
return true;
} )->prepareForm();
$status = $form->trySubmit();
diff --git a/tests/phpunit/includes/page/ArticleTablesTest.php b/tests/phpunit/includes/page/ArticleTablesTest.php
index f7e3402200d9..d7cd78196ed1 100644
--- a/tests/phpunit/includes/page/ArticleTablesTest.php
+++ b/tests/phpunit/includes/page/ArticleTablesTest.php
@@ -14,7 +14,7 @@ class ArticleTablesTest extends MediaWikiLangTestCase {
* @covers Title::getLinksFrom
*/
public function testTemplatelinksUsesContentLanguage() {
- $title = Title::newFromText( 'T16404' );
+ $title = Title::makeTitle( NS_MAIN, 'T16404' );
$wikiPageFactory = $this->getServiceContainer()->getWikiPageFactory();
$page = $wikiPageFactory->newFromTitle( $title );
$user = new User();
diff --git a/tests/phpunit/includes/page/PageArchiveTest.php b/tests/phpunit/includes/page/PageArchiveTest.php
index 027212bbb35d..ddbcba0e0602 100644
--- a/tests/phpunit/includes/page/PageArchiveTest.php
+++ b/tests/phpunit/includes/page/PageArchiveTest.php
@@ -69,7 +69,7 @@ class PageArchiveTest extends MediaWikiIntegrationTestCase {
);
// First create our dummy page
- $this->archivedPage = Title::newFromText( 'PageArchiveTest_thePage' );
+ $this->archivedPage = Title::makeTitle( NS_MAIN, 'PageArchiveTest_thePage' );
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $this->archivedPage );
$content = ContentHandler::makeContent(
'testing',
diff --git a/tests/phpunit/includes/page/UndeletePageTest.php b/tests/phpunit/includes/page/UndeletePageTest.php
index e8965ef5a38f..6e3b92e42358 100644
--- a/tests/phpunit/includes/page/UndeletePageTest.php
+++ b/tests/phpunit/includes/page/UndeletePageTest.php
@@ -58,7 +58,7 @@ class UndeletePageTest extends MediaWikiIntegrationTestCase {
* @param string $content
*/
private function setupPage( string $titleText, int $ns, string $content ): void {
- $title = Title::newFromText( $titleText, $ns );
+ $title = Title::makeTitle( $ns, $titleText );
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
$performer = static::getTestUser()->getUser();
$content = ContentHandler::makeContent( $content, $page->getTitle(), CONTENT_MODEL_WIKITEXT );
diff --git a/tests/phpunit/integration/includes/CommentFormatter/CommentParserTest.php b/tests/phpunit/integration/includes/CommentFormatter/CommentParserTest.php
index a44e118c7c7b..608bff4e20fc 100644
--- a/tests/phpunit/integration/includes/CommentFormatter/CommentParserTest.php
+++ b/tests/phpunit/integration/includes/CommentFormatter/CommentParserTest.php
@@ -297,7 +297,7 @@ class CommentParserTest extends \MediaWikiIntegrationTestCase {
] );
$this->setupInterwiki();
- $this->addGoodLinkObject( 1, Title::newFromText( 'Present' ) );
+ $this->addGoodLinkObject( 1, Title::makeTitle( NS_MAIN, 'Present' ) );
if ( $title === false ) {
// We need a page title that exists
@@ -378,8 +378,8 @@ class CommentParserTest extends \MediaWikiIntegrationTestCase {
$this->tablesUsed[] = 'page';
$this->setupConf();
$services = $this->getServiceContainer();
- $present = Title::newFromText( 'Present' );
- $absent = Title::newFromText( 'Absent' );
+ $present = Title::makeTitle( NS_MAIN, 'Present' );
+ $absent = Title::makeTitle( NS_MAIN, 'Absent' );
$this->editPage(
$present,
'content'
@@ -439,7 +439,7 @@ class CommentParserTest extends \MediaWikiIntegrationTestCase {
$this->tablesUsed[] = 'page';
$this->setupConf();
$this->setupInterwiki();
- $present = Title::newFromText( 'Template:Present' );
+ $present = Title::makeTitle( NS_TEMPLATE, 'Present' );
$this->editPage(
$present,
'content'
@@ -467,7 +467,7 @@ class CommentParserTest extends \MediaWikiIntegrationTestCase {
}
);
- $title = Title::newFromText( 'User:AlwaysKnownFoo' );
+ $title = Title::makeTitle( NS_USER, 'AlwaysKnownFoo' );
$this->assertFalse( $title->exists() );
$parser = $this->getParser();
diff --git a/tests/phpunit/languages/LanguageConverterTest.php b/tests/phpunit/languages/LanguageConverterTest.php
index 63bd7cde11d2..266872915fe4 100644
--- a/tests/phpunit/languages/LanguageConverterTest.php
+++ b/tests/phpunit/languages/LanguageConverterTest.php
@@ -216,11 +216,11 @@ class LanguageConverterTest extends MediaWikiLangTestCase {
public function provideTitlesToConvert(): array {
return [
'Title FromText default' => [
- Title::newFromText( 'Dummy_title' ),
+ Title::makeTitle( NS_MAIN, 'Dummy_title' ),
'Dummy title',
],
'Title FromText with NS' => [
- Title::newFromText( 'Dummy_title', NS_FILE ),
+ Title::makeTitle( NS_FILE, 'Dummy_title' ),
'Акс:Dummy title',
],
'Title MainPage default' => [
diff --git a/tests/phpunit/languages/converters/KkConverterTest.php b/tests/phpunit/languages/converters/KkConverterTest.php
index ce5de3be0edf..d957db65f329 100644
--- a/tests/phpunit/languages/converters/KkConverterTest.php
+++ b/tests/phpunit/languages/converters/KkConverterTest.php
@@ -40,7 +40,7 @@ class KkConverterTest extends MediaWikiIntegrationTestCase {
public function testFindVariantLinks() {
$old = "sample_link";
$newLink = $old;
- $title = Title::newFromText( "Same page for link" );
+ $title = Title::makeTitle( NS_MAIN, "Same page for link" );
$this->getLanguageConverter()->findVariantLink( $newLink, $title );
$this->assertSame( $old, $newLink, "inks should'n be changed" );
}