6 require __DIR__
. "/../../../maintenance/runJobs.php";
8 class TemplateCategoriesTest
extends MediaWikiLangTestCase
{
14 * @covers Title::getParentCategories
16 public function testTemplateCategories() {
18 $user->mRights
= [ 'createpage', 'edit', 'purge', 'delete' ];
20 $title = Title
::newFromText( "Categorized from template" );
21 $page = WikiPage
::factory( $title );
23 new WikitextContent( '{{Categorising template}}' ),
24 'Create a page with a template',
32 $title->getParentCategories(),
33 'Verify that the category doesn\'t contain the page before the template is created'
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',
47 JobQueueGroup
::destroySingletons();
49 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
52 // Make sure page is in the category
54 [ 'Category:Solved_bugs' => $title->getPrefixedText() ],
55 $title->getParentCategories(),
56 'Verify that the page is in the category after the template is created'
60 $template->doEditContent(
61 new WikitextContent( '[[Category:Solved bugs 2]]' ),
62 'Change the category added by the template',
69 JobQueueGroup
::destroySingletons();
71 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
74 // Make sure page is in the right category
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
83 $template->doDeleteArticleReal( 'Delete the template', false, 0, true, $error, $user );
86 JobQueueGroup
::destroySingletons();
88 $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
91 // Make sure the page is no longer in the category
94 $title->getParentCategories(),
95 'Verify that the page is no longer in the category after template deletion'