wiki.techinc.nl/tests/phpunit/includes/TemplateCategoriesTest.php
Alexandre Emsenhuber 2aecd77a15 * Use WikiPage instead of Article to call doEdit()
* Use a local user object and pass it WikiPage::doEdit()
* User::$mRights is a flat array of permissions, not a 2-D array like $wgGroupPermissions
2012-02-12 15:22:01 +00:00

36 lines
1 KiB
PHP

<?php
/**
* @group Database
*/
require dirname( __FILE__ ) . "/../../../maintenance/runJobs.php";
class TemplateCategoriesTest extends MediaWikiLangTestCase {
function testTemplateCategories() {
$title = Title::newFromText( "Categorized from template" );
$page = WikiPage::factory( $title );
$user = new User();
$user->mRights = array( 'createpage', 'edit', 'purge' );
$status = $page->doEdit( '{{Categorising template}}', 'Create a page with a template', 0, false, $user );
$this->assertEquals(
array()
, $title->getParentCategories()
);
$template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
$status = $template->doEdit( '[[Category:Solved bugs]]', 'Add a category through a template', 0, false, $user );
// Run the job queue
$jobs = new RunJobs;
$jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
$jobs->execute();
$this->assertEquals(
array( 'Category:Solved_bugs' => $title->getPrefixedText() )
, $title->getParentCategories()
);
}
}