--- /dev/null
+<?php
+/**
+ * Generic providers for the MediaWiki PHPUnit test suite
+ *
+ * @author Ashar Voultoiz
+ * @copyright Copyright © 2011, Ashar Voultoiz
+ * @file
+ */
+
+/** */
+class MediaWikiProvide {
+
+ /* provide an array of numbers from 1 up to @param $num */
+ private function createProviderUpTo( $num ) {
+ $ret = array();
+ for( $i=1; $i<=$num;$i++ ) {
+ $ret[] = array( $i );
+ }
+ return $ret;
+ }
+
+ /* array of months numbers (as an integer) */
+ public function Months() {
+ return $this->createProviderUpTo( 12 );
+ }
+
+ /* array of days numbers (as an integer) */
+ public function Days() {
+ return $this->createProviderUpTo( 31 );
+ }
+
+ public function DaysMonths() {
+ $ret = array();
+
+ $months = self::Months();
+ $days = self::Days();
+ foreach( $months as $month) {
+ foreach( $days as $day ) {
+ $ret[] = array( $day[0], $month[0] );
+ }
+ }
+ return $ret;
+ }
+}
# day
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testCurrentdayIsUnPadded( $day ) {
$this->assertUnPadded( 'currentday', $day );
}
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testCurrentdaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'currentday2', $day );
}
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testLocaldayIsUnPadded( $day ) {
$this->assertUnPadded( 'localday', $day );
}
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testLocaldaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'localday2', $day );
}
# month
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testCurrentmonthIsZeroPadded( $month ) {
$this->assertZeroPadded( 'currentmonth', $month );
}
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testCurrentmonthoneIsUnPadded( $month ) {
$this->assertUnPadded( 'currentmonth1', $month );
}
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testLocalmonthIsZeroPadded( $month ) {
$this->assertZeroPadded( 'localmonth', $month );
}
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testLocalmonthoneIsUnPadded( $month ) {
$this->assertUnPadded( 'localmonth1', $month );
}
# revision day
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testRevisiondayIsUnPadded( $day ) {
$this->assertUnPadded( 'revisionday', $day );
}
- /** @dataProvider provideDays */
+ /** @dataProvider MediaWikiProvide::Days */
function testRevisiondaytwoIsZeroPadded( $day ) {
$this->assertZeroPadded( 'revisionday2', $day );
}
# revision month
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testRevisionmonthIsZeroPadded( $month ) {
$this->assertZeroPadded( 'revisionmonth', $month );
}
- /** @dataProvider provideMonths */
+ /** @dataProvider MediaWikiProvide::Months */
function testRevisionmonthoneIsUnPadded( $month ) {
$this->assertUnPadded( 'revisionmonth1', $month );
}
$msg
);
}
-
-
- ############## PROVIDERS ##########################################
-
- /* provide an array of numbers from 1 up to @param $num */
- private function createProviderUpTo( $num ) {
- $ret = array();
- for( $i=1; $i<=$num;$i++ ) {
- $ret[] = array( $i );
- }
- return $ret;
- }
-
- /* array of months numbers (as an integer) */
- public function provideMonths() {
- return $this->createProviderUpTo( 12 );
- }
-
- /* array of days numbers (as an integer) */
- public function provideDays() {
- return $this->createProviderUpTo( 31 );
- }
}