Completed
Push — master ( 670f0c...07e238 )
by Pavel
12:30
created

createConfigurator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Tests\Unit;
4
5
use Doctrine\Common\Collections\Criteria;
6
use Prophecy\Argument;
7
use ScayTrase\Api\Cruds\Criteria\DefaultCriteriaConfigurator;
8
use ScayTrase\Api\Cruds\CriteriaConfiguratorInterface;
9
10
class DefaultCriteriaConfiguratorTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testDefaultReplacesMissing()
13
    {
14
        $defaults = [
15
            'a' => 0,
16
            'b' => null,
17
            'c' => 'data',
18
            'e' => 'extra defaults',
19
        ];
20
21
        $provided = [
22
            'a' => 5,
23
            'c' => 'new data',
24
            'd' => 'extra data',
25
        ];
26
27
        $criteria = Criteria::create();
28
        $fqcn     = \stdClass::class;
29
30
        $decorated = $this->createConfigurator(
31
            $fqcn,
32
            $criteria,
33
            [
34
                'a' => 5,
35
                'b' => null,
36
                'c' => 'new data',
37
                'd' => 'extra data',
38
                'e' => 'extra defaults',
39
            ]
40
        );
41
42
        $default = new DefaultCriteriaConfigurator($decorated, $defaults);
43
        $default->configure($fqcn, $criteria, $provided);
44
    }
45
46
47
    private function createConfigurator($fqcn, Criteria $criteria, $data)
48
    {
49
        $mock = self::prophesize(CriteriaConfiguratorInterface::class);
50
        $mock->configure(Argument::exact($fqcn), Argument::exact($criteria), Argument::exact($data))
51
            ->shouldBeCalled();
52
53
        return $mock->reveal();
54
    }
55
}
56