1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlgoWeb\ODataMetadata\Tests\v3\edm\ssdl; |
4
|
|
|
|
5
|
|
|
use AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityPropertyType; |
6
|
|
|
use AlgoWeb\ODataMetadata\Tests\TestCase; |
7
|
|
|
use Mockery as m; |
8
|
|
|
|
9
|
|
View Code Duplication |
class TEntityPropertyTypeTest extends TestCase |
|
|
|
|
10
|
|
|
{ |
11
|
|
|
public function testSetNullDefaultValue() |
12
|
|
|
{ |
13
|
|
|
$foo = new TEntityPropertyType(); |
14
|
|
|
$foo->setDefaultValue(null); |
15
|
|
|
$this->assertEquals(null, $foo->getDefaultValue()); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testSetStringDefaultValue() |
19
|
|
|
{ |
20
|
|
|
$foo = new TEntityPropertyType(); |
21
|
|
|
$foo->setDefaultValue('abc'); |
22
|
|
|
$this->assertEquals('abc', $foo->getDefaultValue()); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testSetNumericDefaultValue() |
26
|
|
|
{ |
27
|
|
|
$foo = new TEntityPropertyType(); |
28
|
|
|
$foo->setDefaultValue(1234); |
29
|
|
|
$this->assertEquals('1234', $foo->getDefaultValue()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testSetObjectDefaultValue() |
33
|
|
|
{ |
34
|
|
|
$expected = "Default value cannot be empty"; |
35
|
|
|
$actual = null; |
36
|
|
|
|
37
|
|
|
$foo = new TEntityPropertyType(); |
38
|
|
|
try { |
39
|
|
|
$foo->setDefaultValue(new \DateTime()); |
40
|
|
|
} catch (\InvalidArgumentException $e) { |
41
|
|
|
$actual = $e->getMessage(); |
42
|
|
|
} |
43
|
|
|
$this->assertEquals($expected, $actual); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testSetEmptyArrayDefaultValue() |
47
|
|
|
{ |
48
|
|
|
$expected = "Default value cannot be empty"; |
49
|
|
|
$actual = null; |
50
|
|
|
|
51
|
|
|
$foo = new TEntityPropertyType(); |
52
|
|
|
try { |
53
|
|
|
$foo->setDefaultValue([]); |
54
|
|
|
} catch (\InvalidArgumentException $e) { |
55
|
|
|
$actual = $e->getMessage(); |
56
|
|
|
} |
57
|
|
|
$this->assertEquals($expected, $actual); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testSetNonEmptyArrayDefaultValue() |
61
|
|
|
{ |
62
|
|
|
$expected = "Default value cannot be empty"; |
63
|
|
|
$actual = null; |
64
|
|
|
|
65
|
|
|
$foo = new TEntityPropertyType(); |
66
|
|
|
try { |
67
|
|
|
$foo->setDefaultValue(['a']); |
68
|
|
|
} catch (\InvalidArgumentException $e) { |
69
|
|
|
$actual = $e->getMessage(); |
70
|
|
|
} |
71
|
|
|
$this->assertEquals($expected, $actual); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.