'convertDoubleWidth() with the full alphabet and digits'
);
}
-
- function testFormatTimePeriod() {
- $this->assertEquals(
- "9.5s",
- $this->lang->formatTimePeriod( 9.45 ),
- 'formatTimePeriod() rounding (<10s)'
- );
-
- $this->assertEquals(
- "10s",
- $this->lang->formatTimePeriod( 9.95 ),
- 'formatTimePeriod() rounding (<10s)'
- );
-
- $this->assertEquals(
- "1m 0s",
- $this->lang->formatTimePeriod( 59.55 ),
- 'formatTimePeriod() rounding (<60s)'
- );
-
- $this->assertEquals(
- "2m 0s",
- $this->lang->formatTimePeriod( 119.55 ),
- 'formatTimePeriod() rounding (<1h)'
- );
-
- $this->assertEquals(
- "1h 0m 0s",
- $this->lang->formatTimePeriod( 3599.55 ),
- 'formatTimePeriod() rounding (<1h)'
- );
-
- $this->assertEquals(
- "2h 0m 0s",
- $this->lang->formatTimePeriod( 7199.55 ),
- 'formatTimePeriod() rounding (>=1h)'
- );
-
- $this->assertEquals(
- "2h 0m",
- $this->lang->formatTimePeriod( 7199.55, 'avoidseconds' ),
- 'formatTimePeriod() rounding (>=1h), avoidseconds'
- );
-
- $this->assertEquals(
- "2h 0m",
- $this->lang->formatTimePeriod( 7199.55, 'avoidminutes' ),
- 'formatTimePeriod() rounding (>=1h), avoidminutes'
- );
-
- $this->assertEquals(
- "48h 0m",
- $this->lang->formatTimePeriod( 172799.55, 'avoidseconds' ),
- 'formatTimePeriod() rounding (=48h), avoidseconds'
- );
-
- $this->assertEquals(
- "3d 0h",
- $this->lang->formatTimePeriod( 259199.55, 'avoidminutes' ),
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- );
-
- $this->assertEquals(
- "2d 1h 0m",
- $this->lang->formatTimePeriod( 176399.55, 'avoidseconds' ),
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- );
-
- $this->assertEquals(
- "2d 1h",
- $this->lang->formatTimePeriod( 176399.55, 'avoidminutes' ),
- 'formatTimePeriod() rounding (>48h), avoidminutes'
- );
-
- $this->assertEquals(
- "3d 0h 0m",
- $this->lang->formatTimePeriod( 259199.55, 'avoidseconds' ),
- 'formatTimePeriod() rounding (>48h), avoidseconds'
- );
-
- $this->assertEquals(
- "2d 0h 0m",
- $this->lang->formatTimePeriod( 172801.55, 'avoidseconds' ),
- 'formatTimePeriod() rounding, (>48h), avoidseconds'
- );
-
- $this->assertEquals(
- "2d 1h 1m 1s",
- $this->lang->formatTimePeriod( 176460.55 ),
- 'formatTimePeriod() rounding, recursion, (>48h)'
- );
+
+ /** @dataProvider provideFormattableTimes */
+ function testFormatTimePeriod( $seconds, $avoid, $expected, $desc ) {
+ $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $avoid ), $desc );
+ }
+
+ function provideFormattableTimes() {
+ return array(
+ array( 9.45, false, '9.5s', 'formatTimePeriod() rounding (<10s)' ),
+ array( 9.95, false, '10s', 'formatTimePeriod() rounding (<10s)' ),
+ array( 59.55, false, '1m 0s', 'formatTimePeriod() rounding (<60s)' ),
+ array( 119.55, false, '2m 0s', 'formatTimePeriod() rounding (<1h)' ),
+ array( 3599.55, false, '1h 0m 0s', 'formatTimePeriod() rounding (<1h)' ),
+ array( 7199.55, false, '2h 0m 0s', 'formatTimePeriod() rounding (>=1h)' ),
+ array( 7199.55, 'avoidseconds', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidseconds' ),
+ array( 7199.55, 'avoidminutes', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidminutes' ),
+ array( 172799.55, 'avoidseconds', '48h 0m', 'formatTimePeriod() rounding (=48h), avoidseconds' ),
+ array( 259199.55, 'avoidminutes', '3d 0h', 'formatTimePeriod() rounding (>48h), avoidminutes' ),
+ array( 176399.55, 'avoidseconds', '2d 1h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ),
+ array( 176399.55, 'avoidminutes', '2d 1h', 'formatTimePeriod() rounding (>48h), avoidminutes' ),
+ array( 259199.55, 'avoidseconds', '3d 0h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ),
+ array( 172801.55, 'avoidseconds', '2d 0h 0m', 'formatTimePeriod() rounding, (>48h), avoidseconds' ),
+ array( 176460.55, false, '2d 1h 1m 1s', 'formatTimePeriod() rounding, recursion, (>48h)' ),
+ );
+
}
function testTruncate() {