|
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
|
|
|
|