1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\Tests\v3\edm; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationEndType; |
6
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\TOnActionType; |
7
|
|
|
use AlgoWeb\ODataMetadata\Tests\TestCase; |
8
|
|
|
use Mockery as m; |
9
|
|
|
|
10
|
|
|
class TAssociationEndTypeTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
public function testBadMultiplicity() |
13
|
|
|
{ |
14
|
|
|
$expected = "Multiplicity must be a valid TMultiplicity"; |
15
|
|
|
$actual = null; |
16
|
|
|
|
17
|
|
|
$foo = new TAssociationEndType(); |
18
|
|
|
$mult = 'abc'; |
19
|
|
|
|
20
|
|
|
try { |
21
|
|
|
$foo->setMultiplicity($mult); |
22
|
|
|
} catch (\InvalidArgumentException $e) { |
23
|
|
|
$actual = $e->getMessage(); |
24
|
|
|
} |
25
|
|
|
$this->assertEquals($expected, $actual); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testAddToOnDeleteBadData() |
29
|
|
|
{ |
30
|
|
|
$expected = ""; |
31
|
|
|
$actual = null; |
32
|
|
|
|
33
|
|
|
$foo = new TAssociationEndType(); |
34
|
|
|
$onDelete = m::mock(TOnActionType::class)->makePartial(); |
35
|
|
|
$onDelete->shouldReceive('isOK')->andReturn(false)->once(); |
36
|
|
|
|
37
|
|
|
try { |
38
|
|
|
$foo->addToOnDelete($onDelete); |
|
|
|
|
39
|
|
|
} catch (\InvalidArgumentException $e) { |
40
|
|
|
$actual = $e->getMessage(); |
41
|
|
|
} |
42
|
|
|
$this->assertEquals($expected, $actual); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
View Code Duplication |
public function testAddToOnDeleteGoodData() |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$foo = new TAssociationEndType(); |
48
|
|
|
$onDelete = m::mock(TOnActionType::class)->makePartial(); |
49
|
|
|
$onDelete->shouldReceive('isOK')->andReturn(true)->once(); |
50
|
|
|
|
51
|
|
|
$foo->addToOnDelete($onDelete); |
|
|
|
|
52
|
|
|
$this->assertTrue($foo->issetOnDelete(0)); |
53
|
|
|
$this->assertFalse($foo->issetOnDelete(1)); |
54
|
|
|
|
55
|
|
|
$foo->unsetOnDelete(0); |
56
|
|
|
$this->assertFalse($foo->issetOnDelete(0)); |
57
|
|
|
$this->assertFalse($foo->issetOnDelete(1)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
View Code Duplication |
public function testSetOnDeleteBadItem() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
$expected = ""; |
63
|
|
|
$actual = null; |
64
|
|
|
|
65
|
|
|
$foo = new TAssociationEndType(); |
66
|
|
|
$onDelete = m::mock(TOnActionType::class)->makePartial(); |
67
|
|
|
$onDelete->shouldReceive('isOK')->andReturn(false)->once(); |
68
|
|
|
$delete = [$onDelete]; |
69
|
|
|
|
70
|
|
|
try { |
71
|
|
|
$foo->setOnDelete($delete); |
|
|
|
|
72
|
|
|
} catch (\InvalidArgumentException $e) { |
73
|
|
|
$actual = $e->getMessage(); |
74
|
|
|
} |
75
|
|
|
$this->assertEquals($expected, $actual); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
View Code Duplication |
public function testIsTOperationsOKBadData() |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
$expected = ""; |
81
|
|
|
$actual = null; |
82
|
|
|
|
83
|
|
|
$foo = new TAssociationEndType(); |
84
|
|
|
$onDelete = m::mock(TOnActionType::class)->makePartial(); |
85
|
|
|
$onDelete->shouldReceive('isOK')->andReturn(true, false)->twice(); |
86
|
|
|
$delete = [$onDelete]; |
87
|
|
|
|
88
|
|
|
$foo->setOnDelete($delete); |
|
|
|
|
89
|
|
|
|
90
|
|
|
$this->assertFalse($foo->isTOperationsOK($actual)); |
91
|
|
|
$this->assertEquals($expected, $actual); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: