2011-11-27 16:12:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
2012-08-29 08:07:10 +00:00
|
|
|
require __DIR__ . "/../../../maintenance/runJobs.php";
|
2011-11-27 16:12:20 +00:00
|
|
|
|
|
|
|
|
class TemplateCategoriesTest extends MediaWikiLangTestCase {
|
|
|
|
|
|
|
|
|
|
function testTemplateCategories() {
|
|
|
|
|
$title = Title::newFromText( "Categorized from template" );
|
2012-02-12 15:22:01 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
|
|
|
|
$user = new User();
|
|
|
|
|
$user->mRights = array( 'createpage', 'edit', 'purge' );
|
2011-11-27 16:12:20 +00:00
|
|
|
|
2013-04-26 07:48:46 +00:00
|
|
|
$page->doEditContent( new WikitextContent( '{{Categorising template}}' ), 'Create a page with a template', 0, false, $user );
|
2012-01-12 16:42:33 +00:00
|
|
|
$this->assertEquals(
|
|
|
|
|
array()
|
|
|
|
|
, $title->getParentCategories()
|
|
|
|
|
);
|
2011-11-27 16:12:20 +00:00
|
|
|
|
2012-02-12 15:22:01 +00:00
|
|
|
$template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
|
2013-04-26 07:48:46 +00:00
|
|
|
$template->doEditContent( new WikitextContent( '[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false, $user );
|
2011-11-27 16:12:20 +00:00
|
|
|
|
|
|
|
|
// Run the job queue
|
2013-01-14 22:06:11 +00:00
|
|
|
JobQueueGroup::destroySingletons();
|
2011-11-27 16:12:20 +00:00
|
|
|
$jobs = new RunJobs;
|
|
|
|
|
$jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
|
|
|
|
|
$jobs->execute();
|
|
|
|
|
|
2012-01-12 16:42:33 +00:00
|
|
|
$this->assertEquals(
|
|
|
|
|
array( 'Category:Solved_bugs' => $title->getPrefixedText() )
|
|
|
|
|
, $title->getParentCategories()
|
|
|
|
|
);
|
2011-11-27 16:12:20 +00:00
|
|
|
}
|
|
|
|
|
}
|