Test Failed
Push — master ( 475bfc...ca0e1d )
by Oss
05:46
created

ColumnExpressionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A tearDown() 0 4 1
A testToArray() 0 8 1
A createExpression() 0 26 1
1
<?php
2
3
namespace Test\Brownie\BpmOnline\DataService\Column;
4
5
use Brownie\BpmOnline\DataService\Column\ColumnExpression;
6
use Brownie\BpmOnline\DataService\Column\Expression\ColumnPath;
7
use PHPUnit\Framework\TestCase;
8
use Prophecy\Prophecy\MethodProphecy;
9
10
class ColumnExpressionTest extends TestCase
11
{
12
13
    /**
14
     * @var ColumnExpression
15
     */
16
    private $columnExpression;
17
18
    protected function setUp()
19
    {
20
        $this->columnExpression = new ColumnExpression(
21
            $this->createExpression('TestKey1', 'TestValue1'),
22
            $this->createExpression('TestKey2', 'TestValue2'),
23
            $this->createExpression('TestKey3', 'TestValue3')
24
        );
25
    }
26
27
    protected function tearDown()
28
    {
29
        $this->columnExpression = null;
30
    }
31
32
    public function testToArray()
33
    {
34
        $this->assertEquals([
35
            'TestKey1' => 'TestValue1',
36
            'TestKey2' => 'TestValue2',
37
            'TestKey3' => 'TestValue3',
38
        ], $this->columnExpression->toArray());
39
    }
40
41
    private function createExpression($key, $value)
42
    {
43
        $expression = $this->prophesize(ColumnPath::class);
44
45
        $columnExpressionMethodGetKeyName = new MethodProphecy(
46
            $expression,
47
            'getKeyName',
48
            []
49
        );
50
        $expression
51
            ->addMethodProphecy(
52
                $columnExpressionMethodGetKeyName->willReturn($key)
53
            );
54
55
        $columnExpressionMethodGetValue = new MethodProphecy(
56
            $expression,
57
            'getValue',
58
            []
59
        );
60
        $expression
61
            ->addMethodProphecy(
62
                $columnExpressionMethodGetValue->willReturn($value)
63
            );
64
65
        return $expression->reveal();
66
    }
67
}
68