38ca85eb0aad6e5fac410d26d7eb028db0fe31cc
[lhc/web/wiklou.git] / tests / phpunit / includes / TemplateCategoriesTest.php
1 <?php
2
3 /**
4 * @group Database
5 */
6 require dirname( __FILE__ ) . "/../../../maintenance/runJobs.php";
7
8 class TemplateCategoriesTest extends MediaWikiLangTestCase {
9
10 function testTemplateCategories() {
11 $title = Title::newFromText( "Categorized from template" );
12 $page = WikiPage::factory( $title );
13 $user = new User();
14 $user->mRights = array( 'createpage', 'edit', 'purge' );
15
16 $status = $page->doEditContent( new WikitextContent( '{{Categorising template}}' ), 'Create a page with a template', 0, false, $user );
17 $this->assertEquals(
18 array()
19 , $title->getParentCategories()
20 );
21
22 $template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
23 $status = $template->doEditContent( new WikitextContent( '[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false, $user );
24
25 // Run the job queue
26 $jobs = new RunJobs;
27 $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
28 $jobs->execute();
29
30 $this->assertEquals(
31 array( 'Category:Solved_bugs' => $title->getPrefixedText() )
32 , $title->getParentCategories()
33 );
34 }
35
36 }