Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class IterableAverageTest extends TestCase |
||
12 | { |
||
13 | use ProvideIterablesTrait; |
||
14 | |||
15 | public function intProvider() |
||
16 | { |
||
17 | return $this->provideIterables([10, 99, 24, 122], true); |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @dataProvider intProvider |
||
22 | */ |
||
23 | public function testAggregateInt($values) |
||
24 | { |
||
25 | $result = iterable_average($values); |
||
26 | |||
27 | $this->assertEquals(63.75, $result); |
||
28 | } |
||
29 | |||
30 | public function floatProvider() |
||
31 | { |
||
32 | return $this->provideIterables([7.5, 99.1, 8], true); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @dataProvider floatProvider |
||
37 | */ |
||
38 | public function testAggregateFloat($values) |
||
39 | { |
||
40 | $result = iterable_average($values); |
||
41 | |||
42 | $this->assertEquals(38.2, $result); |
||
43 | } |
||
44 | |||
45 | public function testAggregateEmpty() |
||
46 | { |
||
47 | $result = iterable_average(new \EmptyIterator()); |
||
48 | |||
49 | $this->assertNan($result); |
||
50 | } |
||
52 |