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

IterableConcatTest.php$0 ➔ testMixed()   A

Complexity

Conditions 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace Jasny\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use function Jasny\iterable_concat;
7
8
/**
9
 * @covers \Jasny\iterable_concat
10
 */
11
class IterableConcatTest extends TestCase
12
{
13
    use ProvideIterablesTrait;
14
15
    public function provider()
16
    {
17
        return $this->provideIterables(['a', 'b', 'c', 'd'], true);
18
    }
19
20
    /**
21
     * @dataProvider provider
22
     */
23
    public function test($values)
24
    {
25
        $result = iterable_concat($values);
26
27
        $this->assertEquals('abcd', $result);
28
    }
29
30
    public function testMixed()
31
    {
32
        $bind = new class() {
33
            public function __toString(): string
34
            {
35
                return 'bind';
36
            }
37
        };
38
39
        $values = [1, 'ring', 2, $bind];
40
        $iterator = new \ArrayIterator($values);
41
42
        $result = iterable_concat($iterator);
43
44
        $this->assertEquals('1ring2bind', $result);
45
    }
46
47
    public function testGlue()
48
    {
49
        $values = ['one', 'ring', 'to', 'bind'];
50
        $iterator = new \ArrayIterator($values);
51
52
        $result = iterable_concat($iterator, '<->');
53
54
        $this->assertEquals('one<->ring<->to<->bind', $result);
55
    }
56
57
    public function testEmpty()
58
    {
59
        $result = iterable_concat(new \EmptyIterator());
60
61
        $this->assertEquals('', $result);
62
    }
63
}
64