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\Basket\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\Basket\Standard::class ) |
24
|
|
|
->disableOriginalConstructor() |
25
|
|
|
->getMock(); |
26
|
|
|
|
27
|
|
|
$this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Basket\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\Basket\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\Basket\Standard::class ) |
54
|
|
|
->disableOriginalConstructor() |
55
|
|
|
->setMethods( ['invalid'] ) |
56
|
|
|
->getMock(); |
57
|
|
|
|
58
|
|
|
$object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Basket\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 testClear() |
76
|
|
|
{ |
77
|
|
|
$this->stub->expects( $this->once() )->method( 'clear' ); |
78
|
|
|
$this->assertSame( $this->object, $this->object->clear() ); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
public function testGet() |
83
|
|
|
{ |
84
|
|
|
$context = \TestHelperFrontend::getContext(); |
85
|
|
|
$order = \Aimeos\MShop::create( $context, 'order/base' )->createItem(); |
86
|
|
|
|
87
|
|
|
$this->stub->expects( $this->once() )->method( 'get' )->will( $this->returnValue( $order ) ); |
88
|
|
|
|
89
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $this->object->get() ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
public function testSave() |
94
|
|
|
{ |
95
|
|
|
$this->stub->expects( $this->once() )->method( 'save' ); |
96
|
|
|
$this->assertSame( $this->object, $this->object->save() ); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
public function testSetType() |
101
|
|
|
{ |
102
|
|
|
$this->stub->expects( $this->once() )->method( 'setType' ); |
103
|
|
|
$this->assertSame( $this->object, $this->object->setType( 'test' ) ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
public function testStore() |
108
|
|
|
{ |
109
|
|
|
$basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
110
|
|
|
|
111
|
|
|
$this->stub->expects( $this->once() )->method( 'store' )->will( $this->returnValue( $basket ) ); |
112
|
|
|
|
113
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $this->object->store() ); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
public function testLoad() |
118
|
|
|
{ |
119
|
|
|
$basket = \Aimeos\MShop::create( $this->context, 'order/base' )->createItem(); |
120
|
|
|
|
121
|
|
|
$this->stub->expects( $this->once() )->method( 'load' )->will( $this->returnValue( $basket ) ); |
122
|
|
|
|
123
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $this->object->load( -1 ) ); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
public function testAddProduct() |
128
|
|
|
{ |
129
|
|
|
$product = \Aimeos\MShop::create( $this->context, 'product' )->createItem(); |
130
|
|
|
|
131
|
|
|
$this->stub->expects( $this->once() )->method( 'addProduct' ); |
132
|
|
|
|
133
|
|
|
$this->assertSame( $this->object, $this->object->addProduct( $product ) ); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
public function testDeleteProduct() |
138
|
|
|
{ |
139
|
|
|
$this->stub->expects( $this->once() )->method( 'deleteProduct' ); |
140
|
|
|
|
141
|
|
|
$this->assertSame( $this->object, $this->object->deleteProduct( 0 ) ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
public function testUpdateProduct() |
146
|
|
|
{ |
147
|
|
|
$this->stub->expects( $this->once() )->method( 'updateProduct' ); |
148
|
|
|
|
149
|
|
|
$this->assertSame( $this->object, $this->object->updateProduct( 0, 1 ) ); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function testAddCoupon() |
154
|
|
|
{ |
155
|
|
|
$this->stub->expects( $this->once() )->method( 'addCoupon' ); |
156
|
|
|
|
157
|
|
|
$this->assertSame( $this->object, $this->object->addCoupon( 'test' ) ); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
public function testDeleteCoupon() |
162
|
|
|
{ |
163
|
|
|
$this->stub->expects( $this->once() )->method( 'deleteCoupon' ); |
164
|
|
|
|
165
|
|
|
$this->assertSame( $this->object, $this->object->deleteCoupon( 'test' ) ); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
public function testSetAddress() |
170
|
|
|
{ |
171
|
|
|
$this->stub->expects( $this->once() )->method( 'setAddress' ); |
172
|
|
|
|
173
|
|
|
$this->assertSame( $this->object, $this->object->setAddress( 'payment', null ) ); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
public function testAddService() |
178
|
|
|
{ |
179
|
|
|
$this->stub->expects( $this->once() )->method( 'addService' ); |
180
|
|
|
|
181
|
|
|
$this->assertSame( $this->object, $this->object->addService( 'payment', -1 ) ); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
public function testDeleteService() |
186
|
|
|
{ |
187
|
|
|
$this->stub->expects( $this->once() )->method( 'deleteService' ); |
188
|
|
|
|
189
|
|
|
$this->assertSame( $this->object, $this->object->deleteService( 'payment' ) ); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
|
193
|
|
|
public function testGetController() |
194
|
|
|
{ |
195
|
|
|
$result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
196
|
|
|
|
197
|
|
|
$this->assertSame( $this->stub, $result ); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
|
201
|
|
|
protected function access( $name ) |
202
|
|
|
{ |
203
|
|
|
$class = new \ReflectionClass( \Aimeos\Controller\Frontend\Basket\Decorator\Base::class ); |
204
|
|
|
$method = $class->getMethod( $name ); |
205
|
|
|
$method->setAccessible( true ); |
206
|
|
|
|
207
|
|
|
return $method; |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
|
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