rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / TemplateCategoriesTest.php
blobab2313635da395aa67df22a1bb3439e1ba1f3641
1 <?php
3 /**
4 * @group Database
5 */
6 require __DIR__ . "/../../../maintenance/runJobs.php";
8 class TemplateCategoriesTest extends MediaWikiLangTestCase {
10 /**
11 * Broken per T165099.
13 * @group Broken
14 * @covers Title::getParentCategories
16 public function testTemplateCategories() {
17 $user = new User();
18 $user->mRights = [ 'createpage', 'edit', 'purge', 'delete' ];
20 $title = Title::newFromText( "Categorized from template" );
21 $page = WikiPage::factory( $title );
22 $page->doEditContent(
23 new WikitextContent( '{{Categorising template}}' ),
24 'Create a page with a template',
26 false,
27 $user
30 $this->assertEquals(
31 [],
32 $title->getParentCategories(),
33 'Verify that the category doesn\'t contain the page before the template is created'
36 // Create template
37 $template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
38 $template->doEditContent(
39 new WikitextContent( '[[Category:Solved bugs]]' ),
40 'Add a category through a template',
42 false,
43 $user
46 // Run the job queue
47 JobQueueGroup::destroySingletons();
48 $jobs = new RunJobs;
49 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
50 $jobs->execute();
52 // Make sure page is in the category
53 $this->assertEquals(
54 [ 'Category:Solved_bugs' => $title->getPrefixedText() ],
55 $title->getParentCategories(),
56 'Verify that the page is in the category after the template is created'
59 // Edit the template
60 $template->doEditContent(
61 new WikitextContent( '[[Category:Solved bugs 2]]' ),
62 'Change the category added by the template',
64 false,
65 $user
68 // Run the job queue
69 JobQueueGroup::destroySingletons();
70 $jobs = new RunJobs;
71 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
72 $jobs->execute();
74 // Make sure page is in the right category
75 $this->assertEquals(
76 [ 'Category:Solved_bugs_2' => $title->getPrefixedText() ],
77 $title->getParentCategories(),
78 'Verify that the page is in the right category after the template is edited'
81 // Now delete the template
82 $error = '';
83 $template->doDeleteArticleReal( 'Delete the template', false, 0, true, $error, $user );
85 // Run the job queue
86 JobQueueGroup::destroySingletons();
87 $jobs = new RunJobs;
88 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
89 $jobs->execute();
91 // Make sure the page is no longer in the category
92 $this->assertEquals(
93 [],
94 $title->getParentCategories(),
95 'Verify that the page is no longer in the category after template deletion'