1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Customer\Decorator; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class BaseTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
private $stub; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
22
|
|
|
|
23
|
|
|
$this->stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Standard::class ) |
24
|
|
|
->disableOriginalConstructor() |
25
|
|
|
->getMock(); |
26
|
|
|
|
27
|
|
|
$this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Decorator\Base::class ) |
28
|
|
|
->setConstructorArgs( [$this->stub, $this->context] ) |
29
|
|
|
->getMockForAbstractClass(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
protected function tearDown() |
34
|
|
|
{ |
35
|
|
|
unset( $this->context, $this->object, $this->stub ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testConstructException() |
40
|
|
|
{ |
41
|
|
|
$stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Iface::class )->getMock(); |
42
|
|
|
|
43
|
|
|
$this->setExpectedException( \Aimeos\MW\Common\Exception::class ); |
44
|
|
|
|
45
|
|
|
$this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Decorator\Base::class ) |
46
|
|
|
->setConstructorArgs( [$stub, $this->context] ) |
47
|
|
|
->getMockForAbstractClass(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function testCall() |
52
|
|
|
{ |
53
|
|
|
$stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Standard::class ) |
54
|
|
|
->disableOriginalConstructor() |
55
|
|
|
->setMethods( ['invalid'] ) |
56
|
|
|
->getMock(); |
57
|
|
|
|
58
|
|
|
$object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Decorator\Base::class ) |
59
|
|
|
->setConstructorArgs( [$stub, $this->context] ) |
60
|
|
|
->getMockForAbstractClass(); |
61
|
|
|
|
62
|
|
|
$stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
63
|
|
|
|
64
|
|
|
$this->assertTrue( $object->invalid() ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
public function testAdd() |
69
|
|
|
{ |
70
|
|
|
$this->stub->expects( $this->once() )->method( 'add' ); |
71
|
|
|
$this->assertSame( $this->object, $this->object->add( [] ) ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function testAddAddressItem() |
76
|
|
|
{ |
77
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->createItem(); |
78
|
|
|
|
79
|
|
|
$this->stub->expects( $this->once() )->method( 'addAddressItem' ); |
80
|
|
|
$this->assertSame( $this->object, $this->object->addAddressItem( $item ) ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
public function testAddListItem() |
85
|
|
|
{ |
86
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->createItem(); |
87
|
|
|
|
88
|
|
|
$this->stub->expects( $this->once() )->method( 'addListItem' ); |
89
|
|
|
$this->assertSame( $this->object, $this->object->addListItem( 'customer', $listItem ) ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
public function testAddPropertyItem() |
94
|
|
|
{ |
95
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->createItem(); |
96
|
|
|
|
97
|
|
|
$this->stub->expects( $this->once() )->method( 'addPropertyItem' ); |
98
|
|
|
$this->assertSame( $this->object, $this->object->addPropertyItem( $item ) ); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
public function testCreateAddressItem() |
103
|
|
|
{ |
104
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->createItem(); |
105
|
|
|
|
106
|
|
|
$this->stub->expects( $this->once() )->method( 'createAddressItem' )->will( $this->returnValue( $item ) ); |
107
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Address\Iface::class, $this->object->createAddressItem() ); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
public function testCreateListItem() |
112
|
|
|
{ |
113
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/lists' )->createItem(); |
114
|
|
|
|
115
|
|
|
$this->stub->expects( $this->once() )->method( 'createListItem' )->will( $this->returnValue( $item ) ); |
116
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Lists\Iface::class, $this->object->createListItem() ); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
public function testCreatePropertyItem() |
121
|
|
|
{ |
122
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->createItem(); |
123
|
|
|
|
124
|
|
|
$this->stub->expects( $this->once() )->method( 'createPropertyItem' )->will( $this->returnValue( $item ) ); |
125
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $this->object->createPropertyItem() ); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
|
129
|
|
|
public function testDeleteItem() |
130
|
|
|
{ |
131
|
|
|
$this->stub->expects( $this->once() )->method( 'delete' ); |
132
|
|
|
$this->assertSame( $this->object, $this->object->delete() ); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
public function testDeleteAddressItem() |
137
|
|
|
{ |
138
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->createItem(); |
139
|
|
|
|
140
|
|
|
$this->stub->expects( $this->once() )->method( 'deleteAddressItem' ); |
141
|
|
|
$this->assertSame( $this->object, $this->object->deleteAddressItem( $item ) ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
public function testDeleteListItem() |
146
|
|
|
{ |
147
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->createItem(); |
148
|
|
|
|
149
|
|
|
$this->stub->expects( $this->once() )->method( 'deleteListItem' ); |
150
|
|
|
$this->assertSame( $this->object, $this->object->deleteListItem( 'customer', $listItem ) ); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
public function testDeletePropertyItem() |
155
|
|
|
{ |
156
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->createItem(); |
157
|
|
|
|
158
|
|
|
$this->stub->expects( $this->once() )->method( 'deletePropertyItem' ); |
159
|
|
|
$this->assertSame( $this->object, $this->object->deletePropertyItem( $item ) ); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
|
163
|
|
|
public function testFind() |
164
|
|
|
{ |
165
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer' )->createItem(); |
166
|
|
|
|
167
|
|
|
$this->stub->expects( $this->once() )->method( 'find' ) |
168
|
|
|
->will( $this->returnValue( $item ) ); |
169
|
|
|
|
170
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $this->object->find( 'test' ) ); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
public function testGet() |
175
|
|
|
{ |
176
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer' )->createItem(); |
177
|
|
|
|
178
|
|
|
$this->stub->expects( $this->once() )->method( 'get' ) |
179
|
|
|
->will( $this->returnValue( $item ) ); |
180
|
|
|
|
181
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $this->object->get() ); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
public function testStore() |
186
|
|
|
{ |
187
|
|
|
$this->stub->expects( $this->once() )->method( 'store' ); |
188
|
|
|
$this->assertSame( $this->object, $this->object->store() ); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
|
192
|
|
|
public function testUses() |
193
|
|
|
{ |
194
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['text'] ) ); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
|
198
|
|
|
public function testGetController() |
199
|
|
|
{ |
200
|
|
|
$this->assertSame( $this->stub, $this->access( 'getController' )->invokeArgs( $this->object, [] ) ); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
|
204
|
|
|
protected function access( $name ) |
205
|
|
|
{ |
206
|
|
|
$class = new \ReflectionClass( \Aimeos\Controller\Frontend\Customer\Decorator\Base::class ); |
207
|
|
|
$method = $class->getMethod( $name ); |
208
|
|
|
$method->setAccessible( true ); |
209
|
|
|
|
210
|
|
|
return $method; |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths