tests: Use Title::makeTitle instead of Title::newFromText

Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
This commit is contained in:
Umherirrender 2022-09-23 21:53:11 +02:00
parent 1e60c7337a
commit 89b2d11a0d
26 changed files with 72 additions and 72 deletions

View file

@ -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' ),

View file

@ -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() );

View file

@ -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,

View file

@ -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 );

View file

@ -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();

View file

@ -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' ] ],

View file

@ -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 ) {

View file

@ -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" );
}

View file

@ -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() );
}

View file

@ -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,

View file

@ -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' ]
);

View file

@ -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' => [

View file

@ -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' ] )
);

View file

@ -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 );

View file

@ -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' ] ],
];

View file

@ -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;
}

View file

@ -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 = [

View file

@ -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" );

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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',

View file

@ -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 );

View file

@ -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();

View file

@ -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' => [

View file

@ -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" );
}