r114327 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114326‎ | r114327 | r114328 >
Date:23:04, 20 March 2012
Author:kaldari
Status:resolved (Comments)
Tags:
Comment:
adding our first (mostly bogus) unit test, to test our unit testing
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/tests/phpunit/SpecialPageTriageTest.php (added) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/tests/phpunit/SpecialPageTriageTest.php
@@ -0,0 +1,33 @@
 2+<?php
 3+/**
 4+ * Tests for SpecialPageTriage class (PageTriage list view)
 5+ *
 6+ * @group EditorEngagement
 7+ * @author Ryan Kaldari
 8+ */
 9+class SpecialPageTriageTest extends PHPUnit_Framework_TestCase {
 10+
 11+ protected $pageTriage;
 12+
 13+ protected function setUp() {
 14+ parent::setUp();
 15+ $this->pageTriage = new SpecialPageTriage;
 16+
 17+ // Insert some made up articles into the database
 18+ }
 19+
 20+ protected function tearDown() {
 21+ parent::tearDown();
 22+
 23+ // Remove the made up articles
 24+ }
 25+
 26+ // This is a sample test (not actually very useful)
 27+ public function testGetTriageHeader() {
 28+ $this->assertEquals(
 29+ '<p>Page Triage Header goes here</p>',
 30+ $this->pageTriage->getTriageHeader()
 31+ );
 32+ }
 33+
 34+}
Property changes on: trunk/extensions/PageTriage/tests/phpunit/SpecialPageTriageTest.php
___________________________________________________________________
Added: svn:eol-style
135 + native
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -43,6 +43,10 @@
4444 'descriptionmsg' => 'pagetriage-desc',
4545 );
4646
 47+// Begin configuration variables
 48+$wgPageTriagePageIdPerRequest = 20;
 49+// End configuration variables
 50+
4751 $dir = dirname( __FILE__ ) . '/';
4852
4953 $wgExtensionMessagesFiles['PageTriage'] = $dir . 'PageTriage.i18n.php';
@@ -73,6 +77,7 @@
7478 $wgHooks['NewRevisionFromEditComplete'][] = 'PageTriageHooks::onNewRevisionFromEditComplete';
7579 $wgHooks['ArticleInsertComplete'][] = 'PageTriageHooks::onArticleInsertComplete';
7680 $wgHooks['ArticleSaveComplete'][] = 'PageTriageHooks::onArticleSaveComplete';
 81+$wgHooks['UnitTestsList'][] = 'efPageTriageUnitTests'; // unit tests
7782
7883 /**
7984 * @param $updater DatabaseUpdater
@@ -98,7 +103,16 @@
99104 return true;
100105 }
101106
102 -$wgPageTriagePageIdPerRequest = 20;
 107+/**
 108+ * UnitTestsList hook handler - adds unit test files to the unit tester
 109+ * @param $files array
 110+ * @return bool
 111+ */
 112+function efPageTriageUnitTests( &$files ) {
 113+ $base = dirname( __FILE__ ) . '/tests';
 114+ $files[] = $base . '/phpunit/SpecialPageTriageTest.php';
 115+ return true;
 116+}
103117
104118 // Register ResourceLoader modules
105119 $wgResourceModules['ext.pageTriage.core'] = array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r114351follow-up to r114327 - using MediaWikiTestCase instead of PHPUnit_Framework_T...kaldari08:01, 21 March 2012

Comments

#Comment by 😂 (talk | contribs)   05:34, 21 March 2012

You should extend MediaWikiTestCase, rather than PHPUnit_Framework_TestCase.

#Comment by Kaldari (talk | contribs)   08:01, 21 March 2012

Fixed in r114351.

Status & tagging log