Index: trunk/phase3/tests/phpunit/includes/parser/MagicVariableTest.php |
— | — | @@ -52,38 +52,38 @@ |
53 | 53 | |
54 | 54 | # day |
55 | 55 | |
56 | | - /** @dataProvider provideDays */ |
| 56 | + /** @dataProvider MediaWikiProvide::Days */ |
57 | 57 | function testCurrentdayIsUnPadded( $day ) { |
58 | 58 | $this->assertUnPadded( 'currentday', $day ); |
59 | 59 | } |
60 | | - /** @dataProvider provideDays */ |
| 60 | + /** @dataProvider MediaWikiProvide::Days */ |
61 | 61 | function testCurrentdaytwoIsZeroPadded( $day ) { |
62 | 62 | $this->assertZeroPadded( 'currentday2', $day ); |
63 | 63 | } |
64 | | - /** @dataProvider provideDays */ |
| 64 | + /** @dataProvider MediaWikiProvide::Days */ |
65 | 65 | function testLocaldayIsUnPadded( $day ) { |
66 | 66 | $this->assertUnPadded( 'localday', $day ); |
67 | 67 | } |
68 | | - /** @dataProvider provideDays */ |
| 68 | + /** @dataProvider MediaWikiProvide::Days */ |
69 | 69 | function testLocaldaytwoIsZeroPadded( $day ) { |
70 | 70 | $this->assertZeroPadded( 'localday2', $day ); |
71 | 71 | } |
72 | 72 | |
73 | 73 | # month |
74 | 74 | |
75 | | - /** @dataProvider provideMonths */ |
| 75 | + /** @dataProvider MediaWikiProvide::Months */ |
76 | 76 | function testCurrentmonthIsZeroPadded( $month ) { |
77 | 77 | $this->assertZeroPadded( 'currentmonth', $month ); |
78 | 78 | } |
79 | | - /** @dataProvider provideMonths */ |
| 79 | + /** @dataProvider MediaWikiProvide::Months */ |
80 | 80 | function testCurrentmonthoneIsUnPadded( $month ) { |
81 | 81 | $this->assertUnPadded( 'currentmonth1', $month ); |
82 | 82 | } |
83 | | - /** @dataProvider provideMonths */ |
| 83 | + /** @dataProvider MediaWikiProvide::Months */ |
84 | 84 | function testLocalmonthIsZeroPadded( $month ) { |
85 | 85 | $this->assertZeroPadded( 'localmonth', $month ); |
86 | 86 | } |
87 | | - /** @dataProvider provideMonths */ |
| 87 | + /** @dataProvider MediaWikiProvide::Months */ |
88 | 88 | function testLocalmonthoneIsUnPadded( $month ) { |
89 | 89 | $this->assertUnPadded( 'localmonth1', $month ); |
90 | 90 | } |
— | — | @@ -91,22 +91,22 @@ |
92 | 92 | |
93 | 93 | # revision day |
94 | 94 | |
95 | | - /** @dataProvider provideDays */ |
| 95 | + /** @dataProvider MediaWikiProvide::Days */ |
96 | 96 | function testRevisiondayIsUnPadded( $day ) { |
97 | 97 | $this->assertUnPadded( 'revisionday', $day ); |
98 | 98 | } |
99 | | - /** @dataProvider provideDays */ |
| 99 | + /** @dataProvider MediaWikiProvide::Days */ |
100 | 100 | function testRevisiondaytwoIsZeroPadded( $day ) { |
101 | 101 | $this->assertZeroPadded( 'revisionday2', $day ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | # revision month |
105 | 105 | |
106 | | - /** @dataProvider provideMonths */ |
| 106 | + /** @dataProvider MediaWikiProvide::Months */ |
107 | 107 | function testRevisionmonthIsZeroPadded( $month ) { |
108 | 108 | $this->assertZeroPadded( 'revisionmonth', $month ); |
109 | 109 | } |
110 | | - /** @dataProvider provideMonths */ |
| 110 | + /** @dataProvider MediaWikiProvide::Months */ |
111 | 111 | function testRevisionmonthoneIsUnPadded( $month ) { |
112 | 112 | $this->assertUnPadded( 'revisionmonth1', $month ); |
113 | 113 | } |
— | — | @@ -174,26 +174,4 @@ |
175 | 175 | $msg |
176 | 176 | ); |
177 | 177 | } |
178 | | - |
179 | | - |
180 | | - ############## PROVIDERS ########################################## |
181 | | - |
182 | | - /* provide an array of numbers from 1 up to @param $num */ |
183 | | - private function createProviderUpTo( $num ) { |
184 | | - $ret = array(); |
185 | | - for( $i=1; $i<=$num;$i++ ) { |
186 | | - $ret[] = array( $i ); |
187 | | - } |
188 | | - return $ret; |
189 | | - } |
190 | | - |
191 | | - /* array of months numbers (as an integer) */ |
192 | | - public function provideMonths() { |
193 | | - return $this->createProviderUpTo( 12 ); |
194 | | - } |
195 | | - |
196 | | - /* array of days numbers (as an integer) */ |
197 | | - public function provideDays() { |
198 | | - return $this->createProviderUpTo( 31 ); |
199 | | - } |
200 | 178 | } |
Index: trunk/phase3/tests/phpunit/includes/Providers.php |
— | — | @@ -0,0 +1,44 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Generic providers for the MediaWiki PHPUnit test suite |
| 5 | + * |
| 6 | + * @author Ashar Voultoiz |
| 7 | + * @copyright Copyright © 2011, Ashar Voultoiz |
| 8 | + * @file |
| 9 | + */ |
| 10 | + |
| 11 | +/** */ |
| 12 | +class MediaWikiProvide { |
| 13 | + |
| 14 | + /* provide an array of numbers from 1 up to @param $num */ |
| 15 | + private function createProviderUpTo( $num ) { |
| 16 | + $ret = array(); |
| 17 | + for( $i=1; $i<=$num;$i++ ) { |
| 18 | + $ret[] = array( $i ); |
| 19 | + } |
| 20 | + return $ret; |
| 21 | + } |
| 22 | + |
| 23 | + /* array of months numbers (as an integer) */ |
| 24 | + public function Months() { |
| 25 | + return $this->createProviderUpTo( 12 ); |
| 26 | + } |
| 27 | + |
| 28 | + /* array of days numbers (as an integer) */ |
| 29 | + public function Days() { |
| 30 | + return $this->createProviderUpTo( 31 ); |
| 31 | + } |
| 32 | + |
| 33 | + public function DaysMonths() { |
| 34 | + $ret = array(); |
| 35 | + |
| 36 | + $months = self::Months(); |
| 37 | + $days = self::Days(); |
| 38 | + foreach( $months as $month) { |
| 39 | + foreach( $days as $day ) { |
| 40 | + $ret[] = array( $day[0], $month[0] ); |
| 41 | + } |
| 42 | + } |
| 43 | + return $ret; |
| 44 | + } |
| 45 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/Providers.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 46 | + native |
Index: trunk/phase3/tests/TestsAutoLoader.php |
— | — | @@ -19,5 +19,8 @@ |
20 | 20 | |
21 | 21 | //Selenium |
22 | 22 | 'SeleniumTestConstants' => "$testFolder/selenium/SeleniumTestConstants.php", |
| 23 | + |
| 24 | + //Generic providers |
| 25 | + 'MediaWikiProvide' => "$testFolder/phpunit/includes/Providers.php", |
23 | 26 | ); |
24 | 27 | |