Skip to content

Commit 0ad7b15

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-64521' into 2.1-develop-pr33
2 parents 2e18329 + b42a295 commit 0ad7b15

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
use Magento\TestFramework\Helper\Bootstrap;
1414
use Magento\TestFramework\TestCase\WebapiAbstract;
1515

16+
/**
17+
* Tests Magento\Catalog\Model\Product\Option\Repository.
18+
*/
1619
class ProductCustomOptionRepositoryTest extends WebapiAbstract
1720
{
21+
const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1';
22+
1823
/**
1924
* @var \Magento\Framework\ObjectManagerInterface
2025
*/
2126
protected $objectManager;
2227

23-
const SERVICE_NAME = 'catalogProductCustomOptionRepositoryV1';
24-
2528
/**
2629
* @var \Magento\Catalog\Model\ProductFactory
2730
*/
@@ -30,19 +33,20 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract
3033
protected function setUp()
3134
{
3235
$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);
3437
}
3538

3639
/**
3740
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
3841
* @magentoAppIsolation enabled
42+
* @return void
3943
*/
4044
public function testRemove()
4145
{
4246
$sku = 'simple';
4347
/** @var ProductRepository $productRepository */
4448
$productRepository = $this->objectManager->create(
45-
'Magento\Catalog\Model\ProductRepository'
49+
\Magento\Catalog\Model\ProductRepository::class
4650
);
4751
/** @var \Magento\Catalog\Model\Product $product */
4852
$product = $productRepository->get($sku, false, null, true);
@@ -69,13 +73,14 @@ public function testRemove()
6973
/**
7074
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
7175
* @magentoAppIsolation enabled
76+
* @return void
7277
*/
7378
public function testGet()
7479
{
7580
$productSku = 'simple';
7681
/** @var \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $service */
7782
$service = Bootstrap::getObjectManager()
78-
->get('Magento\Catalog\Api\ProductCustomOptionRepositoryInterface');
83+
->get(\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface::class);
7984
$options = $service->getList('simple');
8085
$option = current($options);
8186
$optionId = $option->getOptionId();
@@ -100,6 +105,7 @@ public function testGet()
100105
/**
101106
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
102107
* @magentoAppIsolation enabled
108+
* @return void
103109
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
104110
*/
105111
public function testGetList()
@@ -144,6 +150,7 @@ public function testGetList()
144150
* @magentoAppIsolation enabled
145151
* @dataProvider optionDataProvider
146152
* @param array $optionData
153+
* @return void
147154
*/
148155
public function testSave($optionData)
149156
{
@@ -174,6 +181,9 @@ public function testSave($optionData)
174181
$this->assertEquals($optionData, $result);
175182
}
176183

184+
/**
185+
* @return array
186+
*/
177187
public function optionDataProvider()
178188
{
179189
$fixtureOptions = [];
@@ -191,6 +201,7 @@ public function optionDataProvider()
191201
* @magentoApiDataFixture Magento/Catalog/_files/product_without_options.php
192202
* @magentoAppIsolation enabled
193203
* @dataProvider optionNegativeDataProvider
204+
* @return void
194205
*/
195206
public function testAddNegative($optionData)
196207
{
@@ -221,6 +232,9 @@ public function testAddNegative($optionData)
221232
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
222233
}
223234

235+
/**
236+
* @return array
237+
*/
224238
public function optionNegativeDataProvider()
225239
{
226240
$fixtureOptions = [];
@@ -237,13 +251,14 @@ public function optionNegativeDataProvider()
237251
/**
238252
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
239253
* @magentoAppIsolation enabled
254+
* @return void
240255
*/
241256
public function testUpdate()
242257
{
243258
$productSku = 'simple';
244259
/** @var ProductRepository $productRepository */
245260
$productRepository = $this->objectManager->create(
246-
'Magento\Catalog\Model\ProductRepository'
261+
\Magento\Catalog\Model\ProductRepository::class
247262
);
248263

249264
$options = $productRepository->get($productSku, true)->getOptions();
@@ -290,6 +305,7 @@ public function testUpdate()
290305

291306
/**
292307
* @param string $optionType
308+
* @return void
293309
*
294310
* @magentoApiDataFixture Magento/Catalog/_files/product_with_options.php
295311
* @magentoAppIsolation enabled
@@ -309,7 +325,7 @@ public function testUpdateOptionAddingNewValue($optionType)
309325

310326
/** @var ProductRepository $productRepository */
311327
$productRepository = $this->objectManager->create(
312-
'Magento\Catalog\Model\ProductRepository'
328+
\Magento\Catalog\Model\ProductRepository::class
313329
);
314330
/** @var \Magento\Catalog\Model\Product $product */
315331
$product = $productRepository->get('simple', false, null, true);
@@ -372,6 +388,9 @@ public function testUpdateOptionAddingNewValue($optionType)
372388
$this->assertEquals(100, $values['sort_order']);
373389
}
374390

391+
/**
392+
* @return array
393+
*/
375394
public function validOptionDataProvider()
376395
{
377396
return [
@@ -388,8 +407,10 @@ public function validOptionDataProvider()
388407
* @dataProvider optionNegativeUpdateDataProvider
389408
* @param array $optionData
390409
* @param string $message
410+
* @param int $exceptionCode
411+
* @return void
391412
*/
392-
public function testUpdateNegative($optionData, $message)
413+
public function testUpdateNegative($optionData, $message, $exceptionCode)
393414
{
394415
$productSku = 'simple';
395416
/** @var ProductRepository $productRepository */
@@ -413,7 +434,7 @@ public function testUpdateNegative($optionData, $message)
413434
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
414435
$this->setExpectedException('SoapFault');
415436
} else {
416-
$this->setExpectedException('Exception', $message, 400);
437+
$this->setExpectedException('Exception', $message, $exceptionCode);
417438
}
418439
$this->_webApiCall($serviceInfo, ['option' => $optionData]);
419440
}

dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_update_negative.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
'max_characters' => 10,
1919
],
2020
'ProductSku should be specified',
21-
]
21+
400,
22+
],
2223
];

0 commit comments

Comments
 (0)