1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2012 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Controller\Frontend\Service; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
private $context; |
17
|
|
|
private static $basket; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
protected function setUp() |
21
|
|
|
{ |
22
|
|
|
\Aimeos\MShop::cache( true ); |
23
|
|
|
|
24
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
25
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Service\Standard( $this->context ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
public static function setUpBeforeClass() |
30
|
|
|
{ |
31
|
|
|
$orderManager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperFrontend::getContext() ); |
32
|
|
|
$orderBaseMgr = $orderManager->getSubManager( 'base' ); |
33
|
|
|
self::$basket = $orderBaseMgr->createItem(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
protected function tearDown() |
38
|
|
|
{ |
39
|
|
|
\Aimeos\MShop::cache( false ); |
40
|
|
|
unset( $this->object, $this->context ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
public function testCompare() |
45
|
|
|
{ |
46
|
|
|
$this->assertEquals( 1, count( $this->object->compare( '==', 'service.type', 'delivery' )->search() ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function testFind() |
51
|
|
|
{ |
52
|
|
|
$item = $this->object->uses( ['price'] )->find( 'unitcode' ); |
53
|
|
|
|
54
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Service\Item\Iface::class, $item ); |
55
|
|
|
$this->assertEquals( 2, count( $item->getRefItems( 'price' ) ) ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
public function testGet() |
60
|
|
|
{ |
61
|
|
|
$item = $this->object->uses( ['price'] )->get( $this->getServiceItem()->getId() ); |
62
|
|
|
|
63
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Service\Item\Iface::class, $item ); |
64
|
|
|
$this->assertEquals( 2, count( $item->getRefItems( 'price' ) ) ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
public function testGetProvider() |
69
|
|
|
{ |
70
|
|
|
$provider = $this->object->getProvider( $this->getServiceItem()->getId() ); |
71
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Service\Provider\Iface::class, $provider ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
public function testGetProviders() |
76
|
|
|
{ |
77
|
|
|
$providers = $this->object->getProviders( 'delivery' ); |
78
|
|
|
$this->assertGreaterThan( 0, count( $providers ) ); |
79
|
|
|
|
80
|
|
|
foreach( $providers as $provider ) { |
81
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Service\Provider\Iface::class, $provider ); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
public function testParse() |
87
|
|
|
{ |
88
|
|
|
$cond = ['&&' => [['>' => ['service.status' => 0]], ['==' => ['service.type' => 'delivery']]]]; |
89
|
|
|
$this->assertEquals( 1, count( $this->object->parse( $cond )->search() ) ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
public function testProcess() |
94
|
|
|
{ |
95
|
|
|
$form = new \Aimeos\MShop\Common\Helper\Form\Standard(); |
96
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
97
|
|
|
$serviceId = \Aimeos\MShop::create( $this->context, 'service' )->findItem( 'unitcode' )->getId(); |
98
|
|
|
|
99
|
|
|
$provider = $this->getMockBuilder( \Aimeos\MShop\Service\Provider\Delivery\Standard::class ) |
100
|
|
|
->disableOriginalConstructor() |
101
|
|
|
->setMethods( ['process'] ) |
102
|
|
|
->getMock(); |
103
|
|
|
|
104
|
|
|
$manager = $this->getMockBuilder( \Aimeos\MShop\Service\Manager\Standard::class ) |
105
|
|
|
->setConstructorArgs( [$this->context] ) |
106
|
|
|
->setMethods( ['getProvider'] ) |
107
|
|
|
->getMock(); |
108
|
|
|
|
109
|
|
|
\Aimeos\MShop::inject( 'service', $manager ); |
110
|
|
|
|
111
|
|
|
$manager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
112
|
|
|
$provider->expects( $this->once() )->method( 'process' )->will( $this->returnValue( $form ) ); |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
$object = new \Aimeos\Controller\Frontend\Service\Standard( $this->context ); |
116
|
|
|
$result = $object->process( $item, $serviceId, [], [] ); |
|
|
|
|
117
|
|
|
|
118
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Helper\Form\Iface::class, $result ); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
|
122
|
|
|
public function testSearch() |
123
|
|
|
{ |
124
|
|
|
$total = 0; |
125
|
|
|
$items = $this->object->uses( ['price'] )->type( 'delivery' )->search( $total ); |
126
|
|
|
|
127
|
|
|
$this->assertEquals( 1, count( $items ) ); |
128
|
|
|
$this->assertEquals( 1, $total ); |
129
|
|
|
$this->assertEquals( 2, count( current( $items )->getRefItems( 'price' ) ) ); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
public function testSlice() |
134
|
|
|
{ |
135
|
|
|
$this->assertEquals( 2, count( $this->object->slice( 0, 2 )->search() ) ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
public function testSort() |
140
|
|
|
{ |
141
|
|
|
$this->assertEquals( 4, count( $this->object->sort( 'type' )->search() ) ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
public function testSortGeneric() |
146
|
|
|
{ |
147
|
|
|
$this->assertEquals( 4, count( $this->object->sort( 'service.status' )->search() ) ); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
public function testSortType() |
152
|
|
|
{ |
153
|
|
|
$result = $this->object->sort( 'type' )->search(); |
154
|
|
|
$this->assertEquals( 'unitcode', current( $result )->getCode() ); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
public function testSortTypeDesc() |
159
|
|
|
{ |
160
|
|
|
$result = $this->object->sort( '-type' )->search(); |
161
|
|
|
$this->assertStringStartsWith( 'unitpaymentcode', current( $result )->getCode() ); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
public function testUpdatePush() |
166
|
|
|
{ |
167
|
|
|
$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
168
|
|
|
$response = $this->getMockBuilder( \Psr\Http\Message\ResponseInterface::class )->getMock(); |
169
|
|
|
|
170
|
|
|
$response->expects( $this->once() )->method( 'withStatus' )->will( $this->returnValue( $response ) ); |
171
|
|
|
|
172
|
|
|
$this->assertInstanceOf( \Psr\Http\Message\ResponseInterface::class, $this->object->updatePush( $request, $response, 'unitcode' ) ); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
|
176
|
|
|
public function testUpdateSync() |
177
|
|
|
{ |
178
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'order' )->createItem(); |
179
|
|
|
$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
180
|
|
|
|
181
|
|
|
$provider = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard' ) |
182
|
|
|
->setMethods( ['updateSync', 'query', 'isImplemented'] ) |
183
|
|
|
->disableOriginalConstructor() |
184
|
|
|
->getMock(); |
185
|
|
|
|
186
|
|
|
$orderManager = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
187
|
|
|
->setConstructorArgs( array( $this->context ) ) |
188
|
|
|
->setMethods( ['getItem'] ) |
189
|
|
|
->getMock(); |
190
|
|
|
|
191
|
|
|
$serviceManager = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' ) |
192
|
|
|
->setConstructorArgs( array( $this->context ) ) |
193
|
|
|
->setMethods( ['getProvider'] ) |
194
|
|
|
->getMock(); |
195
|
|
|
|
196
|
|
|
\Aimeos\MShop::inject( 'order', $orderManager ); |
197
|
|
|
\Aimeos\MShop::inject( 'service', $serviceManager ); |
198
|
|
|
|
199
|
|
|
|
200
|
|
|
$orderManager->expects( $this->once() )->method( 'getItem' )->will( $this->returnValue( $item ) ); |
201
|
|
|
$serviceManager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
202
|
|
|
$provider->expects( $this->once() )->method( 'updateSync' )->will( $this->returnValue( $item ) ); |
203
|
|
|
$provider->expects( $this->once() )->method( 'isImplemented' )->will( $this->returnValue( true ) ); |
204
|
|
|
$provider->expects( $this->once() )->method( 'query' ); |
205
|
|
|
|
206
|
|
|
|
207
|
|
|
$object = new \Aimeos\Controller\Frontend\Service\Standard( $this->context ); |
208
|
|
|
$object->updateSync( $request, 'unitcode', -1 ); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
|
212
|
|
|
public function testUses() |
213
|
|
|
{ |
214
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['text'] ) ); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @return \Aimeos\MShop\Service\Item\Iface |
220
|
|
|
*/ |
221
|
|
|
protected function getServiceItem() |
222
|
|
|
{ |
223
|
|
|
$manager = \Aimeos\MShop\Service\Manager\Factory::create( \TestHelperFrontend::getContext() ); |
224
|
|
|
return $manager->findItem( 'unitcode' ); |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|
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