Index: trunk/phase3/tests/phpunit/languages/LanguageTest.php |
— | — | @@ -19,97 +19,31 @@ |
20 | 20 | 'convertDoubleWidth() with the full alphabet and digits' |
21 | 21 | ); |
22 | 22 | } |
23 | | - |
24 | | - function testFormatTimePeriod() { |
25 | | - $this->assertEquals( |
26 | | - "9.5s", |
27 | | - $this->lang->formatTimePeriod( 9.45 ), |
28 | | - 'formatTimePeriod() rounding (<10s)' |
| 23 | + |
| 24 | + /** @dataProvider provideFormattableTimes */ |
| 25 | + function testFormatTimePeriod( $seconds, $avoid, $expected, $desc ) { |
| 26 | + $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $avoid ), $desc ); |
| 27 | + } |
| 28 | + |
| 29 | + function provideFormattableTimes() { |
| 30 | + return array( |
| 31 | + array( 9.45, false, '9.5s', 'formatTimePeriod() rounding (<10s)' ), |
| 32 | + array( 9.95, false, '10s', 'formatTimePeriod() rounding (<10s)' ), |
| 33 | + array( 59.55, false, '1m 0s', 'formatTimePeriod() rounding (<60s)' ), |
| 34 | + array( 119.55, false, '2m 0s', 'formatTimePeriod() rounding (<1h)' ), |
| 35 | + array( 3599.55, false, '1h 0m 0s', 'formatTimePeriod() rounding (<1h)' ), |
| 36 | + array( 7199.55, false, '2h 0m 0s', 'formatTimePeriod() rounding (>=1h)' ), |
| 37 | + array( 7199.55, 'avoidseconds', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidseconds' ), |
| 38 | + array( 7199.55, 'avoidminutes', '2h 0m', 'formatTimePeriod() rounding (>=1h), avoidminutes' ), |
| 39 | + array( 172799.55, 'avoidseconds', '48h 0m', 'formatTimePeriod() rounding (=48h), avoidseconds' ), |
| 40 | + array( 259199.55, 'avoidminutes', '3d 0h', 'formatTimePeriod() rounding (>48h), avoidminutes' ), |
| 41 | + array( 176399.55, 'avoidseconds', '2d 1h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ), |
| 42 | + array( 176399.55, 'avoidminutes', '2d 1h', 'formatTimePeriod() rounding (>48h), avoidminutes' ), |
| 43 | + array( 259199.55, 'avoidseconds', '3d 0h 0m', 'formatTimePeriod() rounding (>48h), avoidseconds' ), |
| 44 | + array( 172801.55, 'avoidseconds', '2d 0h 0m', 'formatTimePeriod() rounding, (>48h), avoidseconds' ), |
| 45 | + array( 176460.55, false, '2d 1h 1m 1s', 'formatTimePeriod() rounding, recursion, (>48h)' ), |
29 | 46 | ); |
30 | | - |
31 | | - $this->assertEquals( |
32 | | - "10s", |
33 | | - $this->lang->formatTimePeriod( 9.95 ), |
34 | | - 'formatTimePeriod() rounding (<10s)' |
35 | | - ); |
36 | | - |
37 | | - $this->assertEquals( |
38 | | - "1m 0s", |
39 | | - $this->lang->formatTimePeriod( 59.55 ), |
40 | | - 'formatTimePeriod() rounding (<60s)' |
41 | | - ); |
42 | | - |
43 | | - $this->assertEquals( |
44 | | - "2m 0s", |
45 | | - $this->lang->formatTimePeriod( 119.55 ), |
46 | | - 'formatTimePeriod() rounding (<1h)' |
47 | | - ); |
48 | | - |
49 | | - $this->assertEquals( |
50 | | - "1h 0m 0s", |
51 | | - $this->lang->formatTimePeriod( 3599.55 ), |
52 | | - 'formatTimePeriod() rounding (<1h)' |
53 | | - ); |
54 | | - |
55 | | - $this->assertEquals( |
56 | | - "2h 0m 0s", |
57 | | - $this->lang->formatTimePeriod( 7199.55 ), |
58 | | - 'formatTimePeriod() rounding (>=1h)' |
59 | | - ); |
60 | | - |
61 | | - $this->assertEquals( |
62 | | - "2h 0m", |
63 | | - $this->lang->formatTimePeriod( 7199.55, 'avoidseconds' ), |
64 | | - 'formatTimePeriod() rounding (>=1h), avoidseconds' |
65 | | - ); |
66 | | - |
67 | | - $this->assertEquals( |
68 | | - "2h 0m", |
69 | | - $this->lang->formatTimePeriod( 7199.55, 'avoidminutes' ), |
70 | | - 'formatTimePeriod() rounding (>=1h), avoidminutes' |
71 | | - ); |
72 | | - |
73 | | - $this->assertEquals( |
74 | | - "48h 0m", |
75 | | - $this->lang->formatTimePeriod( 172799.55, 'avoidseconds' ), |
76 | | - 'formatTimePeriod() rounding (=48h), avoidseconds' |
77 | | - ); |
78 | | - |
79 | | - $this->assertEquals( |
80 | | - "3d 0h", |
81 | | - $this->lang->formatTimePeriod( 259199.55, 'avoidminutes' ), |
82 | | - 'formatTimePeriod() rounding (>48h), avoidminutes' |
83 | | - ); |
84 | | - |
85 | | - $this->assertEquals( |
86 | | - "2d 1h 0m", |
87 | | - $this->lang->formatTimePeriod( 176399.55, 'avoidseconds' ), |
88 | | - 'formatTimePeriod() rounding (>48h), avoidseconds' |
89 | | - ); |
90 | | - |
91 | | - $this->assertEquals( |
92 | | - "2d 1h", |
93 | | - $this->lang->formatTimePeriod( 176399.55, 'avoidminutes' ), |
94 | | - 'formatTimePeriod() rounding (>48h), avoidminutes' |
95 | | - ); |
96 | | - |
97 | | - $this->assertEquals( |
98 | | - "3d 0h 0m", |
99 | | - $this->lang->formatTimePeriod( 259199.55, 'avoidseconds' ), |
100 | | - 'formatTimePeriod() rounding (>48h), avoidseconds' |
101 | | - ); |
102 | | - |
103 | | - $this->assertEquals( |
104 | | - "2d 0h 0m", |
105 | | - $this->lang->formatTimePeriod( 172801.55, 'avoidseconds' ), |
106 | | - 'formatTimePeriod() rounding, (>48h), avoidseconds' |
107 | | - ); |
108 | | - |
109 | | - $this->assertEquals( |
110 | | - "2d 1h 1m 1s", |
111 | | - $this->lang->formatTimePeriod( 176460.55 ), |
112 | | - 'formatTimePeriod() rounding, recursion, (>48h)' |
113 | | - ); |
| 47 | + |
114 | 48 | } |
115 | 49 | |
116 | 50 | function testTruncate() { |