Index: trunk/extensions/FlaggedRevs/maintenance/tests/FRInclusionManagerTest.php |
— | — | @@ -38,46 +38,50 @@ |
39 | 39 | |
40 | 40 | class FRInclusionManagerTest extends PHPUnit_Framework_TestCase { |
41 | 41 | /* starting input */ |
42 | | - protected static $inputTmps = array( |
| 42 | + protected static $inputTemplates = array( |
43 | 43 | 10 => array('XX' => '1242', 'YY' => '0'), |
44 | 44 | 4 => array('cite' => '30', 'moo' => 0), |
45 | | - 0 => array('ZZ' => 464) |
| 45 | + 0 => array('ZZ' => 464, '0' => 13) |
46 | 46 | ); |
47 | 47 | protected static $inputFiles = array( |
48 | 48 | 'fXX' => array('ts' => '20100405192110', 'sha1' => 'abc1'), |
49 | 49 | 'fYY' => array('ts' => '20000403101300', 'sha1' => 'ffc2'), |
50 | 50 | 'fZZ' => array('ts' => '0', 'sha1' => ''), |
51 | | - 'fle' => array('ts' => 0, 'sha1' => '') |
| 51 | + 'fle' => array('ts' => 0, 'sha1' => ''), |
| 52 | + '0' => array('ts' => '20000203101350', 'sha1' => 'ae33'), |
52 | 53 | ); |
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( |
55 | 56 | 0 => array( 10, 'XX', 1242 ), |
56 | 57 | 1 => array( 10, 'YY', 0 ), |
57 | 58 | 2 => array( 4, 'cite', 30 ), |
58 | 59 | 3 => array( 4, 'moo', 0 ), |
59 | 60 | 4 => array( 0, 'ZZ', 464 ), |
60 | | - 5 => array( 0, 'notexists', null ) |
| 61 | + 5 => array( 0, 'notexists', null ), |
| 62 | + 6 => array( 0, '0', 13 ), |
61 | 63 | ); |
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( |
70 | 65 | 0 => array( 10, 'XX', 1242 ), |
71 | 66 | 1 => array( 10, 'YY', 0 ), |
72 | 67 | 2 => array( 4, 'cite', 30 ), |
73 | 68 | 3 => array( 4, 'moo', 0 ), |
74 | 69 | 4 => array( 0, 'ZZ', 464 ), |
75 | | - 5 => array( 0, 'notexists', 0 ) |
| 70 | + 5 => array( 0, 'notexists', 0 ), |
| 71 | + 6 => array( 0, '0', 13 ), |
76 | 72 | ); |
77 | | - protected static $sOutputFiles = array( |
| 73 | + /* output to test against (test# => <dbkey,expected TS,expected sha1>) */ |
| 74 | + protected static $reviewedOutputFiles = array( |
78 | 75 | 0 => array( 'fXX', '20100405192110', 'abc1'), |
79 | 76 | 1 => array( 'fYY', '20000403101300', 'ffc2'), |
80 | 77 | 2 => array( 'fZZ', '0', ''), |
81 | 78 | 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', ''), |
82 | 86 | 4 => array( 'notgiven', '0', ''), |
83 | 87 | ); |
84 | 88 | |
— | — | @@ -108,15 +112,15 @@ |
109 | 113 | |
110 | 114 | public function testManagerClear() { |
111 | 115 | $im = FRInclusionManager::singleton(); |
112 | | - $im->setReviewedVersions( self::$inputTmps, self::$inputFiles ); |
| 116 | + $im->setReviewedVersions( self::$inputTemplates, self::$inputFiles ); |
113 | 117 | $im->clear(); |
114 | 118 | $this->assertEquals( false, $im->parserOutputIsStabilized(), "Empty on clear()" ); |
115 | 119 | } |
116 | 120 | |
117 | 121 | public function testReviewedTemplateVersions() { |
118 | 122 | $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 ) { |
121 | 125 | list($ns,$dbKey,$expId) = $triple; |
122 | 126 | $title = Title::makeTitleSafe( $ns, $dbKey ); |
123 | 127 | $actual = $im->getReviewedTemplateVersion( $title ); |
— | — | @@ -126,8 +130,8 @@ |
127 | 131 | |
128 | 132 | public function testReviewedFileVersions() { |
129 | 133 | $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 ) { |
132 | 136 | list($dbKey,$expTS,$expSha1) = $triple; |
133 | 137 | $title = Title::makeTitleSafe( NS_FILE, $dbKey ); |
134 | 138 | list($actualTS,$actualSha1) = $im->getReviewedFileVersion( $title ); |
— | — | @@ -139,8 +143,8 @@ |
140 | 144 | public function testStableTemplateVersions() { |
141 | 145 | $im = FRInclusionManager::singleton(); |
142 | 146 | $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 ) { |
145 | 149 | list($ns,$dbKey,$expId) = $triple; |
146 | 150 | $title = Title::makeTitleSafe( $ns, $dbKey ); |
147 | 151 | $actual = $im->getStableTemplateVersion( $title ); |
— | — | @@ -151,8 +155,8 @@ |
152 | 156 | public function testStableFileVersions() { |
153 | 157 | $im = FRInclusionManager::singleton(); |
154 | 158 | $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 ) { |
157 | 161 | list($dbKey,$expTS,$expSha1) = $triple; |
158 | 162 | $title = Title::makeTitleSafe( NS_FILE, $dbKey ); |
159 | 163 | list($actualTS,$actualSha1) = $im->getStableFileVersion( $title ); |