MediaWiki  master
TemplateCategoriesTest.php
Go to the documentation of this file.
00001 <?php
00002 
00006 require __DIR__ . "/../../../maintenance/runJobs.php";
00007 
00008 class TemplateCategoriesTest extends MediaWikiLangTestCase {
00009 
00010         function testTemplateCategories() {
00011                 $title = Title::newFromText( "Categorized from template" );
00012                 $page = WikiPage::factory( $title );
00013                 $user = new User();
00014                 $user->mRights = array( 'createpage', 'edit', 'purge' );
00015 
00016                 $status = $page->doEditContent( new WikitextContent( '{{Categorising template}}' ), 'Create a page with a template', 0, false, $user );
00017                 $this->assertEquals(
00018                         array()
00019                         , $title->getParentCategories()
00020                 );
00021 
00022                 $template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
00023                 $status = $template->doEditContent( new WikitextContent( '[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false, $user );
00024 
00025                 // Run the job queue
00026                 $jobs = new RunJobs;
00027                 $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
00028                 $jobs->execute();
00029 
00030                 $this->assertEquals(
00031                         array( 'Category:Solved_bugs' => $title->getPrefixedText() )
00032                         , $title->getParentCategories()
00033                 );
00034         }
00035 
00036 }