private function runJobs() { JobQueueGroup::destroySingletons(); $jobs = new RunJobs(); $jobs->loadParamsAndArgs(null, ['quiet' => true], null); $jobs->execute(); }
function testTemplateCategories() { $title = Title::newFromText("Categorized from template"); $page = WikiPage::factory($title); $user = new User(); $user->mRights = array('createpage', 'edit', 'purge'); $status = $page->doEditContent(new WikitextContent('{{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->doEditContent(new WikitextContent('[[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()); }
function testTemplateCategories() { global $wgUser; $title = Title::newFromText("Categorized from template"); $article = new Article($title); $wgUser = new User(); $wgUser->mRights['*'] = array('createpage', 'edit', 'purge'); $status = $article->doEdit('{{Categorising template}}', 'Create a page with a template', 0); $this->assertEquals(array(), $title->getParentCategories()); $template = new Article(Title::newFromText('Template:Categorising template')); $status = $template->doEdit('[[Category:Solved bugs]]', 'Add a category through a template', 0); // 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()); }
/** * @covers Title::getParentCategories */ public function testTemplateCategories() { $user = new User(); $user->mRights = array('createpage', 'edit', 'purge', 'delete'); $title = Title::newFromText("Categorized from template"); $page = WikiPage::factory($title); $page->doEditContent(new WikitextContent('{{Categorising template}}'), 'Create a page with a template', 0, false, $user); $this->assertEquals(array(), $title->getParentCategories(), 'Verify that the category doesn\'t contain the page before the template is created'); // Create template $template = WikiPage::factory(Title::newFromText('Template:Categorising template')); $template->doEditContent(new WikitextContent('[[Category:Solved bugs]]'), 'Add a category through a template', 0, false, $user); // Run the job queue JobQueueGroup::destroySingletons(); $jobs = new RunJobs(); $jobs->loadParamsAndArgs(null, array('quiet' => true), null); $jobs->execute(); // Make sure page is in the category $this->assertEquals(array('Category:Solved_bugs' => $title->getPrefixedText()), $title->getParentCategories(), 'Verify that the page is in the category after the template is created'); // Edit the template $template->doEditContent(new WikitextContent('[[Category:Solved bugs 2]]'), 'Change the category added by the template', 0, false, $user); // Run the job queue JobQueueGroup::destroySingletons(); $jobs = new RunJobs(); $jobs->loadParamsAndArgs(null, array('quiet' => true), null); $jobs->execute(); // Make sure page is in the right category $this->assertEquals(array('Category:Solved_bugs_2' => $title->getPrefixedText()), $title->getParentCategories(), 'Verify that the page is in the right category after the template is edited'); // Now delete the template $error = ''; $template->doDeleteArticleReal('Delete the template', false, 0, true, $error, $user); // Run the job queue JobQueueGroup::destroySingletons(); $jobs = new RunJobs(); $jobs->loadParamsAndArgs(null, array('quiet' => true), null); $jobs->execute(); // Make sure the page is no longer in the category $this->assertEquals(array(), $title->getParentCategories(), 'Verify that the page is no longer in the category after template deletion'); }
/** * @covers WikiPage::doDeleteUpdates */ public function testDoDeleteUpdates() { $page = $this->createPage("WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT); $id = $page->getId(); // Similar to MovePage logic wfGetDB(DB_MASTER)->delete('page', array('page_id' => $id), __METHOD__); $page->doDeleteUpdates($id); // Run the job queue JobQueueGroup::destroySingletons(); $jobs = new RunJobs(); $jobs->loadParamsAndArgs(null, array('quiet' => true), null); $jobs->execute(); # ------------------------ $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('pagelinks', '*', array('pl_from' => $id)); $n = $res->numRows(); $res->free(); $this->assertEquals(0, $n, 'pagelinks should contain no more links from the page'); }