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

IterableValuesTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 46
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_values;
7
8
/**
9
 * @covers \Jasny\iterable_values
10
 */
11
class IterableValuesTest extends TestCase
12
{
13
    use ProvideIterablesTrait;
14
    use LazyExecutionIteratorTrait;
15
16
    public function provider()
17
    {
18
        $assoc = ['one' => 'uno', 'two' => 'dos', 'three' => 'tres', 'four' => 'cuatro', 'five' => 'cinco'];
19
        $tests = $this->provideIterables($assoc, true);
20
21
        foreach ($tests as &$test) {
22
            $test[1] = array_values($test[1]);
23
        }
24
25
        return $tests;
26
    }
27
28
    /**
29
     * @dataProvider provider
30
     */
31
    public function testIterate($assoc, $expected)
32
    {
33
        $iterator = iterable_values($assoc);
34
        $result = iterator_to_array($iterator);
35
36
        $this->assertEquals($expected, $result);
37
    }
38
39
    public function testIterateEmpty()
40
    {
41
        $iterator = iterable_values(new \EmptyIterator());
42
        $result = iterator_to_array($iterator);
43
44
        $this->assertEquals([], $result);
45
    }
46
47
    /**
48
     * Test that nothing happens when not iterating
49
     */
50
    public function testLazyExecution()
51
    {
52
        $iterator = $this->createLazyExecutionIterator();
53
54
        iterable_values($iterator);
55
56
        $this->assertTrue(true, "No warning");
57
    }
58
}
59