r104341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104340‎ | r104341 | r104342 >
Date:16:12, 27 November 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Test to ensure that after adding a category to a template, the articles get moved into that category.

Articles containing [[es:Plantilla:Ficha_de_película]] showed the categories at the bottom, but were
not in categorylinks (solved by a doing a null edit to the template and waiting for the job queue, but
how did that situation happen to begin with?).
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/TemplateCategoriesTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/TemplateCategoriesTest.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * @group Database
 6+ */
 7+require dirname( __FILE__ ) . "/../../../maintenance/runJobs.php";
 8+
 9+class TemplateCategoriesTest extends MediaWikiLangTestCase {
 10+
 11+ function testTemplateCategories() {
 12+ global $wgUser;
 13+
 14+ $title = Title::newFromText( "Categorized from template" );
 15+ $article = new Article( $title );
 16+ $wgUser = new User();
 17+ $wgUser->mRights['*'] = array( 'createpage', 'edit', 'purge' );
 18+
 19+ $status = $article->doEdit( '{{Categorising template}}', 'Create a page with a template', 0 );
 20+ $this->assertEquals( $title->getParentCategories(), array() );
 21+
 22+ $template = new Article( Title::newFromText( 'Template:Categorising template' ) );
 23+ $status = $template->doEdit( '[[Category:Solved bugs]]', 'Add a category through a template', 0 );
 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( $title->getParentCategories(), array( 'Category:Solved_bugs' => $title->getPrefixedText() ) );
 31+ }
 32+
 33+}
Property changes on: trunk/phase3/tests/phpunit/includes/TemplateCategoriesTest.php
___________________________________________________________________
Added: svn:eol-style
134 + native

Comments

#Comment by Hashar (talk | contribs)   22:41, 28 November 2011
$jobs = new RunJobs;

That is a great idea :-)

Status & tagging log