6 require __DIR__
. "/../../../maintenance/runJobs.php";
8 class TemplateCategoriesTest
extends MediaWikiLangTestCase
{
11 * @covers Title::getParentCategories
13 public function testTemplateCategories() {
15 $user->mRights
= array( 'createpage', 'edit', 'purge', 'delete' );
17 $title = Title
::newFromText( "Categorized from template" );
18 $page = WikiPage
::factory( $title );
20 new WikitextContent( '{{Categorising template}}' ),
21 'Create a page with a template',
29 $title->getParentCategories(),
30 'Verify that the category doesn\'t contain the page before the template is created'
34 $template = WikiPage
::factory( Title
::newFromText( 'Template:Categorising template' ) );
35 $template->doEditContent(
36 new WikitextContent( '[[Category:Solved bugs]]' ),
37 'Add a category through a template',
44 JobQueueGroup
::destroySingletons();
46 $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
49 // Make sure page is in the category
51 array( 'Category:Solved_bugs' => $title->getPrefixedText() ),
52 $title->getParentCategories(),
53 'Verify that the page is in the category after the template is created'
57 $template->doEditContent(
58 new WikitextContent( '[[Category:Solved bugs 2]]' ),
59 'Change the category added by the template',
66 JobQueueGroup
::destroySingletons();
68 $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
71 // Make sure page is in the right category
73 array( 'Category:Solved_bugs_2' => $title->getPrefixedText() ),
74 $title->getParentCategories(),
75 'Verify that the page is in the right category after the template is edited'
78 // Now delete the template
80 $template->doDeleteArticleReal( 'Delete the template', false, 0, true, $error, $user );
83 JobQueueGroup
::destroySingletons();
85 $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
88 // Make sure the page is no longer in the category
91 $title->getParentCategories(),
92 'Verify that the page is no longer in the category after template deletion'