13
13
use Magento \TestFramework \Helper \Bootstrap ;
14
14
use Magento \TestFramework \TestCase \WebapiAbstract ;
15
15
16
+ /**
17
+ * Tests Magento\Catalog\Model\Product\Option\Repository.
18
+ */
16
19
class ProductCustomOptionRepositoryTest extends WebapiAbstract
17
20
{
21
+ const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1 ' ;
22
+
18
23
/**
19
24
* @var \Magento\Framework\ObjectManagerInterface
20
25
*/
21
26
protected $ objectManager ;
22
27
23
- const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1 ' ;
24
-
25
28
/**
26
29
* @var \Magento\Catalog\Model\ProductFactory
27
30
*/
@@ -30,19 +33,20 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract
30
33
protected function setUp ()
31
34
{
32
35
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
33
- $ this ->productFactory = $ this ->objectManager ->get (' Magento\Catalog\Model\ProductFactory ' );
36
+ $ this ->productFactory = $ this ->objectManager ->get (\ Magento \Catalog \Model \ProductFactory::class );
34
37
}
35
38
36
39
/**
37
40
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
38
41
* @magentoAppIsolation enabled
42
+ * @return void
39
43
*/
40
44
public function testRemove ()
41
45
{
42
46
$ sku = 'simple ' ;
43
47
/** @var ProductRepository $productRepository */
44
48
$ productRepository = $ this ->objectManager ->create (
45
- ' Magento\Catalog\Model\ProductRepository '
49
+ \ Magento \Catalog \Model \ProductRepository::class
46
50
);
47
51
/** @var \Magento\Catalog\Model\Product $product */
48
52
$ product = $ productRepository ->get ($ sku , false , null , true );
@@ -69,13 +73,14 @@ public function testRemove()
69
73
/**
70
74
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
71
75
* @magentoAppIsolation enabled
76
+ * @return void
72
77
*/
73
78
public function testGet ()
74
79
{
75
80
$ productSku = 'simple ' ;
76
81
/** @var \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $service */
77
82
$ service = Bootstrap::getObjectManager ()
78
- ->get (' Magento\Catalog\Api\ProductCustomOptionRepositoryInterface ' );
83
+ ->get (\ Magento \Catalog \Api \ProductCustomOptionRepositoryInterface::class );
79
84
$ options = $ service ->getList ('simple ' );
80
85
$ option = current ($ options );
81
86
$ optionId = $ option ->getOptionId ();
@@ -100,6 +105,7 @@ public function testGet()
100
105
/**
101
106
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
102
107
* @magentoAppIsolation enabled
108
+ * @return void
103
109
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
104
110
*/
105
111
public function testGetList ()
@@ -144,6 +150,7 @@ public function testGetList()
144
150
* @magentoAppIsolation enabled
145
151
* @dataProvider optionDataProvider
146
152
* @param array $optionData
153
+ * @return void
147
154
*/
148
155
public function testSave ($ optionData )
149
156
{
@@ -174,6 +181,9 @@ public function testSave($optionData)
174
181
$ this ->assertEquals ($ optionData , $ result );
175
182
}
176
183
184
+ /**
185
+ * @return array
186
+ */
177
187
public function optionDataProvider ()
178
188
{
179
189
$ fixtureOptions = [];
@@ -191,6 +201,7 @@ public function optionDataProvider()
191
201
* @magentoApiDataFixture Magento/Catalog/_files/product_without_options.php
192
202
* @magentoAppIsolation enabled
193
203
* @dataProvider optionNegativeDataProvider
204
+ * @return void
194
205
*/
195
206
public function testAddNegative ($ optionData )
196
207
{
@@ -221,6 +232,9 @@ public function testAddNegative($optionData)
221
232
$ this ->_webApiCall ($ serviceInfo , ['option ' => $ optionDataPost ]);
222
233
}
223
234
235
+ /**
236
+ * @return array
237
+ */
224
238
public function optionNegativeDataProvider ()
225
239
{
226
240
$ fixtureOptions = [];
@@ -237,13 +251,14 @@ public function optionNegativeDataProvider()
237
251
/**
238
252
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
239
253
* @magentoAppIsolation enabled
254
+ * @return void
240
255
*/
241
256
public function testUpdate ()
242
257
{
243
258
$ productSku = 'simple ' ;
244
259
/** @var ProductRepository $productRepository */
245
260
$ productRepository = $ this ->objectManager ->create (
246
- ' Magento\Catalog\Model\ProductRepository '
261
+ \ Magento \Catalog \Model \ProductRepository::class
247
262
);
248
263
249
264
$ options = $ productRepository ->get ($ productSku , true )->getOptions ();
@@ -290,6 +305,7 @@ public function testUpdate()
290
305
291
306
/**
292
307
* @param string $optionType
308
+ * @return void
293
309
*
294
310
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
295
311
* @magentoAppIsolation enabled
@@ -309,7 +325,7 @@ public function testUpdateOptionAddingNewValue($optionType)
309
325
310
326
/** @var ProductRepository $productRepository */
311
327
$ productRepository = $ this ->objectManager ->create (
312
- ' Magento\Catalog\Model\ProductRepository '
328
+ \ Magento \Catalog \Model \ProductRepository::class
313
329
);
314
330
/** @var \Magento\Catalog\Model\Product $product */
315
331
$ product = $ productRepository ->get ('simple ' , false , null , true );
@@ -372,6 +388,9 @@ public function testUpdateOptionAddingNewValue($optionType)
372
388
$ this ->assertEquals (100 , $ values ['sort_order ' ]);
373
389
}
374
390
391
+ /**
392
+ * @return array
393
+ */
375
394
public function validOptionDataProvider ()
376
395
{
377
396
return [
@@ -388,8 +407,10 @@ public function validOptionDataProvider()
388
407
* @dataProvider optionNegativeUpdateDataProvider
389
408
* @param array $optionData
390
409
* @param string $message
410
+ * @param int $exceptionCode
411
+ * @return void
391
412
*/
392
- public function testUpdateNegative ($ optionData , $ message )
413
+ public function testUpdateNegative ($ optionData , $ message, $ exceptionCode )
393
414
{
394
415
$ productSku = 'simple ' ;
395
416
/** @var ProductRepository $productRepository */
@@ -413,7 +434,7 @@ public function testUpdateNegative($optionData, $message)
413
434
if (TESTS_WEB_API_ADAPTER == self ::ADAPTER_SOAP ) {
414
435
$ this ->setExpectedException ('SoapFault ' );
415
436
} else {
416
- $ this ->setExpectedException ('Exception ' , $ message , 400 );
437
+ $ this ->setExpectedException ('Exception ' , $ message , $ exceptionCode );
417
438
}
418
439
$ this ->_webApiCall ($ serviceInfo , ['option ' => $ optionData ]);
419
440
}
0 commit comments