1 | <?php |
||
19 | class UnboundedQuantityValueTest extends DataValueTest { |
||
20 | |||
21 | /** |
||
22 | * @see DataValueTest::getClass |
||
23 | * |
||
24 | * @return string |
||
25 | */ |
||
26 | public function getClass() { |
||
29 | |||
30 | public function validConstructorArgumentsProvider() { |
||
39 | |||
40 | public function invalidConstructorArgumentsProvider() { |
||
48 | |||
49 | /** |
||
50 | * @dataProvider instanceProvider |
||
51 | */ |
||
52 | public function testGetValue( UnboundedQuantityValue $quantity, array $arguments ) { |
||
55 | |||
56 | /** |
||
57 | * @dataProvider instanceProvider |
||
58 | */ |
||
59 | public function testGetAmount( UnboundedQuantityValue $quantity, array $arguments ) { |
||
62 | |||
63 | /** |
||
64 | * @dataProvider instanceProvider |
||
65 | */ |
||
66 | public function testGetUnit( UnboundedQuantityValue $quantity, array $arguments ) { |
||
69 | |||
70 | /** |
||
71 | * @dataProvider newFromNumberProvider |
||
72 | */ |
||
73 | public function testNewFromNumber( $amount, $unit, UnboundedQuantityValue $expected ) { |
||
78 | |||
79 | public function newFromNumberProvider() { |
||
111 | |||
112 | /** |
||
113 | * @see https://phabricator.wikimedia.org/T110728 |
||
114 | * @see http://www.regular-expressions.info/anchors.html#realend |
||
115 | */ |
||
116 | public function testTrailingNewlineRobustness() { |
||
127 | |||
128 | /** |
||
129 | * @dataProvider instanceProvider |
||
130 | */ |
||
131 | public function testGetSortKey( UnboundedQuantityValue $quantity ) { |
||
134 | |||
135 | /** |
||
136 | * @dataProvider transformProvider |
||
137 | */ |
||
138 | public function testTransform( UnboundedQuantityValue $quantity, $transformation, UnboundedQuantityValue $expected ) { |
||
149 | |||
150 | public function transformProvider() { |
||
176 | |||
177 | public function provideNewFromArray() { |
||
178 | return array( |
||
179 | 'unbounded' => array( |
||
180 | array( |
||
181 | 'amount' => '+2', |
||
182 | 'unit' => '1', |
||
183 | ), |
||
184 | UnboundedQuantityValue::newFromNumber( '+2', '1' ) |
||
185 | ), |
||
186 | 'with-extra' => array( |
||
187 | array( |
||
188 | 'amount' => '+2', |
||
189 | 'unit' => '1', |
||
190 | 'upperBound' => '+2.5', |
||
191 | 'lowerBound' => '+1.5', |
||
192 | ), |
||
193 | UnboundedQuantityValue::newFromNumber( '+2', '1' ) |
||
194 | ), |
||
195 | ); |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * @dataProvider provideNewFromArray |
||
200 | */ |
||
201 | public function testNewFromArray( $data, DataValue $expected ) { |
||
205 | |||
206 | public function provideNewFromArray_failure() { |
||
207 | return array( |
||
208 | 'no-amount' => array( |
||
209 | array( |
||
210 | 'unit' => '1', |
||
211 | ) |
||
212 | ), |
||
213 | 'no-unit' => array( |
||
214 | array( |
||
215 | 'amount' => '+2', |
||
216 | ) |
||
217 | ), |
||
218 | 'bad-amount' => array( |
||
219 | array( |
||
220 | 'amount' => 'x', |
||
221 | 'unit' => '1', |
||
222 | ) |
||
223 | ), |
||
224 | ); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @dataProvider provideNewFromArray_failure |
||
229 | */ |
||
230 | public function testNewFromArray_failure( $data ) { |
||
234 | |||
235 | } |
||
236 |