Completed
Push — master ( a8b608...dc5b75 )
by Valentin
02:10
created

SequenceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Cycle\ORM\Promise\Tests\Declaration\ConflictResolver;
5
6
use Cycle\ORM\Promise\ConflictResolver\Sequences;
7
use PHPUnit\Framework\TestCase;
8
use Spiral\Core\Container;
9
10
class SequenceTest extends TestCase
11
{
12
    /**
13
     * @dataProvider findProvider
14
     *
15
     * @param array $sequence
16
     * @param int   $pos
17
     * @param int   $expected
18
     */
19
    public function testFind(array $sequence, int $pos, int $expected)
20
    {
21
        $this->assertEquals($expected, $this->sequences()->find($sequence, $pos));
22
    }
23
24
    public function findProvider(): array
25
    {
26
        return [
27
            // empty input
28
            [[], 5, 5],
29
            // in the gap (not taken)
30
            [[3, 4, 8, 9,], 6, 6],
31
            [[3, 4, 8, 9,], 1, 1],
32
            // in the sequence (taken)
33
            [[3, 4, 8, 9,], 4, 0],
34
            [[0, 1, 4, 5,], 5, 2],
35
            // do not use "1"
36
            [[0, 3, 4, 8,], 4, 2],
37
            // full sequence, take next
38
            [[0, 1, 2, 3,], 3, 4],
39
            [[0], 0, 2],
40
        ];
41
    }
42
43
    private function sequences(): Sequences
44
    {
45
        $container = new Container();
46
47
        return $container->get(Sequences::class);
48
    }
49
}