Skip to content

Commit 8516f4f

Browse files
committed
MC-40051: Create automated test for: "Try to delete by API call already deleted configurable option"
1 parent cd857f9 commit 8516f4f

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
78

89
namespace Magento\ConfigurableProduct\Api;
910

@@ -21,8 +22,10 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac
2122

2223
/**
2324
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
25+
*
26+
* @return void
2427
*/
25-
public function testGet()
28+
public function testGet(): void
2629
{
2730
$productSku = 'configurable';
2831

@@ -54,8 +57,10 @@ public function testGet()
5457

5558
/**
5659
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
60+
*
61+
* @return void
5762
*/
58-
public function testGetList()
63+
public function testGetList(): void
5964
{
6065
$productSku = 'configurable';
6166

@@ -90,8 +95,9 @@ public function testGetList()
9095
}
9196

9297
/**
98+
* @return void
9399
*/
94-
public function testGetUndefinedProduct()
100+
public function testGetUndefinedProduct(): void
95101
{
96102
$this->expectException(\Exception::class);
97103
$this->expectExceptionMessage(
@@ -104,8 +110,10 @@ public function testGetUndefinedProduct()
104110

105111
/**
106112
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
113+
*
114+
* @return void
107115
*/
108-
public function testGetUndefinedOption()
116+
public function testGetUndefinedOption(): void
109117
{
110118
$expectedMessage = 'The "%1" entity that was requested doesn\'t exist. Verify the entity and try again.';
111119
$productSku = 'configurable';
@@ -127,8 +135,10 @@ public function testGetUndefinedOption()
127135

128136
/**
129137
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
138+
*
139+
* @return void
130140
*/
131-
public function testDelete()
141+
public function testDelete(): void
132142
{
133143
$productSku = 'configurable';
134144

@@ -144,8 +154,10 @@ public function testDelete()
144154
/**
145155
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
146156
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php
157+
*
158+
* @return void
147159
*/
148-
public function testAdd()
160+
public function testAdd(): void
149161
{
150162
/** @var AttributeRepositoryInterface $attributeRepository */
151163
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
@@ -181,8 +193,10 @@ public function testAdd()
181193

182194
/**
183195
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
196+
*
197+
* @return void
184198
*/
185-
public function testUpdate()
199+
public function testUpdate(): void
186200
{
187201
$productSku = 'configurable';
188202
$configurableAttribute = $this->getConfigurableAttribute($productSku);
@@ -218,8 +232,10 @@ public function testUpdate()
218232

219233
/**
220234
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
235+
*
236+
* @return void
221237
*/
222-
public function testUpdateWithoutOptionId()
238+
public function testUpdateWithoutOptionId(): void
223239
{
224240
$productSku = 'configurable';
225241
/** @var AttributeRepositoryInterface $attributeRepository */
@@ -257,6 +273,19 @@ public function testUpdateWithoutOptionId()
257273
$this->assertEquals($option['label'], $configurableAttribute[0]['label']);
258274
}
259275

276+
/**
277+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
278+
*
279+
* @return void
280+
*/
281+
public function testDeleteNotExistsOption(): void
282+
{
283+
$message = (string)__('The option that was requested doesn\'t exist. Verify the entity and try again.');
284+
$this->expectExceptionMessage($message);
285+
$this->expectException(\Exception::class);
286+
$this->delete('configurable', 555);
287+
}
288+
260289
/**
261290
* @param string $productSku
262291
* @return array

0 commit comments

Comments
 (0)