Failed Conditions
Branch master (01ba0d)
by Arnold
06:58 queued 01:45
created

IterableAverageTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
3
namespace Jasny\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use function Jasny\iterable_average;
7
8
/**
9
 * @covers \Jasny\iterable_average
10
 */
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
    }
51
}
52