1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2024 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Base\Criteria\Attribute; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
$func = function() {}; |
21
|
|
|
|
22
|
|
|
$values = array( |
23
|
|
|
'type' => 'attribute_type', |
24
|
|
|
'internaltype' => 'internaltype', |
25
|
|
|
'code' => 'attribute_code', |
26
|
|
|
'internalcode' => 'internalcode', |
27
|
|
|
'internaldeps' => array( 'test' ), |
28
|
|
|
'label' => 'labelname', |
29
|
|
|
'default' => 'default value', |
30
|
|
|
'public' => false, |
31
|
|
|
'required' => false, |
32
|
|
|
'function' => $func, |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$this->object = new \Aimeos\Base\Criteria\Attribute\Standard( $values ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
protected function tearDown() : void |
40
|
|
|
{ |
41
|
|
|
unset( $this->object ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
public function testMagicGet() |
46
|
|
|
{ |
47
|
|
|
$this->assertEquals( 'attribute_type', $this->object->__get( 'type' ) ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function testMagicIsset() |
52
|
|
|
{ |
53
|
|
|
$this->assertTrue( $this->object->__isset( 'type' ) ); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
public function testGetType() |
58
|
|
|
{ |
59
|
|
|
$this->assertEquals( 'attribute_type', $this->object->getType() ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function testGetInternalType() |
64
|
|
|
{ |
65
|
|
|
$this->assertEquals( 'internaltype', $this->object->getInternalType() ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
public function testGetCode() |
70
|
|
|
{ |
71
|
|
|
$this->assertEquals( 'attribute_code', $this->object->getCode() ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function testGetInternalCode() |
76
|
|
|
{ |
77
|
|
|
$this->assertEquals( 'internalcode', $this->object->getInternalCode() ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
public function testGetInternalDeps() |
82
|
|
|
{ |
83
|
|
|
$this->assertEquals( array( 'test' ), $this->object->getInternalDeps() ); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
public function testGetFunction() |
88
|
|
|
{ |
89
|
|
|
$this->assertInstanceOf( \Closure::class, $this->object->getFunction() ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
public function testGetLabel() |
94
|
|
|
{ |
95
|
|
|
$this->assertEquals( 'labelname', $this->object->getLabel() ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
public function testGetDefault() |
100
|
|
|
{ |
101
|
|
|
$this->assertEquals( 'default value', $this->object->getDefault() ); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
public function testIsPublic() |
106
|
|
|
{ |
107
|
|
|
$this->assertEquals( false, $this->object->isPublic() ); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
public function testIsRequired() |
112
|
|
|
{ |
113
|
|
|
$this->assertEquals( false, $this->object->isRequired() ); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
public function testToArray() |
118
|
|
|
{ |
119
|
|
|
$expected = array( |
120
|
|
|
'code' => 'attribute_code', |
121
|
|
|
'type' => 'attribute_type', |
122
|
|
|
'label' => 'labelname', |
123
|
|
|
'public' => false, |
124
|
|
|
'default' => 'default value', |
125
|
|
|
'required' => false, |
126
|
|
|
'value' => null, |
127
|
|
|
); |
128
|
|
|
|
129
|
|
|
$this->assertEquals( $expected, $this->object->toArray() ); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
public function testToArrayAll() |
134
|
|
|
{ |
135
|
|
|
$expected = array( |
136
|
|
|
'code' => 'attribute_code', |
137
|
|
|
'type' => 'attribute_type', |
138
|
|
|
'label' => 'labelname', |
139
|
|
|
'public' => false, |
140
|
|
|
'default' => 'default value', |
141
|
|
|
'required' => false, |
142
|
|
|
'value' => null, |
143
|
|
|
'internalcode' => 'internalcode', |
144
|
|
|
'internaldeps' => ['test'], |
145
|
|
|
'internaltype' => 'internaltype', |
146
|
|
|
); |
147
|
|
|
|
148
|
|
|
$this->assertEquals( $expected, $this->object->toArray( true ) ); |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|