r69849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69848‎ | r69849 | r69850 >
Date:21:24, 24 July 2010
Author:aaron
Status:ok
Tags:
Comment:
* Renamed vars
* Added some tests
Modified paths:
  • /trunk/extensions/FlaggedRevs/maintenance/tests/FRInclusionManagerTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/tests/FRInclusionManagerTest.php
@@ -38,46 +38,50 @@
3939
4040 class FRInclusionManagerTest extends PHPUnit_Framework_TestCase {
4141 /* starting input */
42 - protected static $inputTmps = array(
 42+ protected static $inputTemplates = array(
4343 10 => array('XX' => '1242', 'YY' => '0'),
4444 4 => array('cite' => '30', 'moo' => 0),
45 - 0 => array('ZZ' => 464)
 45+ 0 => array('ZZ' => 464, '0' => 13)
4646 );
4747 protected static $inputFiles = array(
4848 'fXX' => array('ts' => '20100405192110', 'sha1' => 'abc1'),
4949 'fYY' => array('ts' => '20000403101300', 'sha1' => 'ffc2'),
5050 'fZZ' => array('ts' => '0', 'sha1' => ''),
51 - 'fle' => array('ts' => 0, 'sha1' => '')
 51+ 'fle' => array('ts' => 0, 'sha1' => ''),
 52+ '0' => array('ts' => '20000203101350', 'sha1' => 'ae33'),
5253 );
53 - /* output to test against (test# => test) */
54 - protected static $rOutputTmps = array(
 54+ /* output to test against (test# => <NS,dbkey,expected rev ID>) */
 55+ protected static $reviewedOutputTemplates = array(
5556 0 => array( 10, 'XX', 1242 ),
5657 1 => array( 10, 'YY', 0 ),
5758 2 => array( 4, 'cite', 30 ),
5859 3 => array( 4, 'moo', 0 ),
5960 4 => array( 0, 'ZZ', 464 ),
60 - 5 => array( 0, 'notexists', null )
 61+ 5 => array( 0, 'notexists', null ),
 62+ 6 => array( 0, '0', 13 ),
6163 );
62 - protected static $rOutputFiles = array(
63 - 0 => array( 'fXX', '20100405192110', 'abc1'),
64 - 1 => array( 'fYY', '20000403101300', 'ffc2'),
65 - 2 => array( 'fZZ', '0', ''),
66 - 3 => array( 'fle', '0', ''),
67 - 4 => array( 'notgiven', null, null),
68 - );
69 - protected static $sOutputTmps = array(
 64+ protected static $stableOutputTemplates = array(
7065 0 => array( 10, 'XX', 1242 ),
7166 1 => array( 10, 'YY', 0 ),
7267 2 => array( 4, 'cite', 30 ),
7368 3 => array( 4, 'moo', 0 ),
7469 4 => array( 0, 'ZZ', 464 ),
75 - 5 => array( 0, 'notexists', 0 )
 70+ 5 => array( 0, 'notexists', 0 ),
 71+ 6 => array( 0, '0', 13 ),
7672 );
77 - protected static $sOutputFiles = array(
 73+ /* output to test against (test# => <dbkey,expected TS,expected sha1>) */
 74+ protected static $reviewedOutputFiles = array(
7875 0 => array( 'fXX', '20100405192110', 'abc1'),
7976 1 => array( 'fYY', '20000403101300', 'ffc2'),
8077 2 => array( 'fZZ', '0', ''),
8178 3 => array( 'fle', '0', ''),
 79+ 4 => array( 'notgiven', null, null),
 80+ );
 81+ protected static $stableOutputFiles = array(
 82+ 0 => array( 'fXX', '20100405192110', 'abc1'),
 83+ 1 => array( 'fYY', '20000403101300', 'ffc2'),
 84+ 2 => array( 'fZZ', '0', ''),
 85+ 3 => array( 'fle', '0', ''),
8286 4 => array( 'notgiven', '0', ''),
8387 );
8488
@@ -108,15 +112,15 @@
109113
110114 public function testManagerClear() {
111115 $im = FRInclusionManager::singleton();
112 - $im->setReviewedVersions( self::$inputTmps, self::$inputFiles );
 116+ $im->setReviewedVersions( self::$inputTemplates, self::$inputFiles );
113117 $im->clear();
114118 $this->assertEquals( false, $im->parserOutputIsStabilized(), "Empty on clear()" );
115119 }
116120
117121 public function testReviewedTemplateVersions() {
118122 $im = FRInclusionManager::singleton();
119 - $im->setReviewedVersions( self::$inputTmps, self::$inputFiles );
120 - foreach ( self::$rOutputTmps as $x => $triple ) {
 123+ $im->setReviewedVersions( self::$inputTemplates, self::$inputFiles );
 124+ foreach ( self::$reviewedOutputTemplates as $x => $triple ) {
121125 list($ns,$dbKey,$expId) = $triple;
122126 $title = Title::makeTitleSafe( $ns, $dbKey );
123127 $actual = $im->getReviewedTemplateVersion( $title );
@@ -126,8 +130,8 @@
127131
128132 public function testReviewedFileVersions() {
129133 $im = FRInclusionManager::singleton();
130 - $im->setReviewedVersions( self::$inputTmps, self::$inputFiles );
131 - foreach ( self::$rOutputFiles as $x => $triple ) {
 134+ $im->setReviewedVersions( self::$inputTemplates, self::$inputFiles );
 135+ foreach ( self::$reviewedOutputFiles as $x => $triple ) {
132136 list($dbKey,$expTS,$expSha1) = $triple;
133137 $title = Title::makeTitleSafe( NS_FILE, $dbKey );
134138 list($actualTS,$actualSha1) = $im->getReviewedFileVersion( $title );
@@ -139,8 +143,8 @@
140144 public function testStableTemplateVersions() {
141145 $im = FRInclusionManager::singleton();
142146 $im->setReviewedVersions( array(), array() );
143 - $im->setStableVersionCache( self::$inputTmps, self::$inputFiles );
144 - foreach ( self::$sOutputTmps as $x => $triple ) {
 147+ $im->setStableVersionCache( self::$inputTemplates, self::$inputFiles );
 148+ foreach ( self::$stableOutputTemplates as $x => $triple ) {
145149 list($ns,$dbKey,$expId) = $triple;
146150 $title = Title::makeTitleSafe( $ns, $dbKey );
147151 $actual = $im->getStableTemplateVersion( $title );
@@ -151,8 +155,8 @@
152156 public function testStableFileVersions() {
153157 $im = FRInclusionManager::singleton();
154158 $im->setReviewedVersions( array(), array() );
155 - $im->setStableVersionCache( self::$inputTmps, self::$inputFiles );
156 - foreach ( self::$sOutputFiles as $x => $triple ) {
 159+ $im->setStableVersionCache( self::$inputTemplates, self::$inputFiles );
 160+ foreach ( self::$stableOutputFiles as $x => $triple ) {
157161 list($dbKey,$expTS,$expSha1) = $triple;
158162 $title = Title::makeTitleSafe( NS_FILE, $dbKey );
159163 list($actualTS,$actualSha1) = $im->getStableFileVersion( $title );

Status & tagging log