BindTraitTest::testBindData()
last analyzed

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Tests\Unit\Dms\MySQL\QueryBuilder\Traits;
4
5
use Janisbiz\LightOrm\Dms\MySQL\QueryBuilder\Traits\BindTrait;
6
7
class BindTraitTest extends AbstractTraitTestCase
8
{
9
    const BIND = [
10
        'key2' => 'val2',
11
        'key3' => 'val3',
12
        'key4' => 'val4',
13
    ];
14
    const BIND_DEFAULT = [
15
        'key1' => 'val1',
16
    ];
17
    const BIND_OVERRIDE = [
18
        'key1' => 'valN',
19
    ];
20
21
    /**
22
     * @var BindTrait
23
     */
24
    private $bindTraitClass;
25
26
    public function setUp()
27
    {
28
        $this->bindTraitClass = new class (BindTraitTest::BIND_DEFAULT)
29
        {
30
            use BindTrait;
31
32
            /**
33
             * @param array $bindDefault
34
             */
35
            public function __construct(array $bindDefault)
36
            {
37
                $this->bind = $bindDefault;
38
            }
39
        };
40
    }
41
42
    public function testBind()
43
    {
44
        $this->assertEquals(static::BIND_DEFAULT, $this->bindTraitClass->bindData());
45
46
        $object = $this->bindTraitClass->bind(static::BIND);
47
        $this->assertObjectUsesTrait(BindTrait::class, $object);
48
        $this->assertEquals(\array_merge(static::BIND_DEFAULT, static::BIND), $this->bindTraitClass->bindData());
49
50
        $object = $this->bindTraitClass->bind(static::BIND_OVERRIDE);
51
        $this->assertObjectUsesTrait(BindTrait::class, $object);
52
        $this->assertEquals(
53
            \array_merge(static::BIND_DEFAULT, static::BIND, static::BIND_OVERRIDE),
54
            $this->bindTraitClass->bindData()
55
        );
56
    }
57
58
    public function testBindData()
59
    {
60
        $this->assertEquals(
61
            static::BIND_DEFAULT,
62
            $this->bindTraitClass->bindData()
63
        );
64
    }
65
}
66