Skip to content

Commit dec34b3

Browse files
MC-31269: Admin: Add/edit/delete custom options to configurable product
1 parent ba8fae3 commit dec34b3

File tree

6 files changed

+99
-9
lines changed

6 files changed

+99
-9
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/CreateCustomOptionsTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@
1919
*
2020
* @magentoAppArea adminhtml
2121
* @magentoDbIsolation enabled
22+
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
2223
*/
2324
class CreateCustomOptionsTest extends AbstractBackendController
2425
{
26+
/**
27+
* @var string
28+
*/
29+
protected $productSku = 'simple';
30+
2531
/**
2632
* @var ProductRepositoryInterface
2733
*/
@@ -46,8 +52,6 @@ protected function setUp()
4652
/**
4753
* Test add to product custom option with type "field".
4854
*
49-
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
50-
*
5155
* @dataProvider productWithNewOptionsDataProvider
5256
*
5357
* @param array $productPostData
@@ -57,7 +61,7 @@ protected function setUp()
5761
public function testSaveCustomOptionWithTypeField(array $productPostData): void
5862
{
5963
$this->getRequest()->setPostValue($productPostData);
60-
$product = $this->productRepository->get('simple');
64+
$product = $this->productRepository->get($this->productSku);
6165
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
6266
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
6367
$this->assertSessionMessages(

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/DeleteCustomOptionsTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121
*
2222
* @magentoAppArea adminhtml
2323
* @magentoDbIsolation enabled
24+
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
2425
*/
2526
class DeleteCustomOptionsTest extends AbstractBackendController
2627
{
28+
/**
29+
* @var string
30+
*/
31+
protected $productSku = 'simple';
32+
2733
/**
2834
* @var ProductRepositoryInterface
2935
*/
@@ -54,16 +60,14 @@ protected function setUp()
5460
/**
5561
* Test delete custom option with type "field".
5662
*
57-
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
58-
*
5963
* @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Field::getDataForCreateOptions
6064
*
6165
* @param array $optionData
6266
* @return void
6367
*/
6468
public function testDeleteCustomOptionWithTypeField(array $optionData): void
6569
{
66-
$product = $this->productRepository->get('simple');
70+
$product = $this->productRepository->get($this->productSku);
6771
/** @var ProductCustomOptionInterface $option */
6872
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
6973
$option->setProductSku($product->getSku());

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@
2222
*
2323
* @magentoAppArea adminhtml
2424
* @magentoDbIsolation enabled
25+
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
2526
*/
2627
class UpdateCustomOptionsTest extends AbstractBackendController
2728
{
29+
/**
30+
* @var string
31+
*/
32+
protected $productSku = 'simple';
33+
2834
/**
2935
* @var ProductRepositoryInterface
3036
*/
@@ -55,8 +61,6 @@ protected function setUp()
5561
/**
5662
* Test add to product custom option with type "field".
5763
*
58-
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
59-
*
6064
* @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Field::getDataForUpdateOptions
6165
*
6266
* @param array $optionData
@@ -65,7 +69,7 @@ protected function setUp()
6569
*/
6670
public function testUpdateCustomOptionWithTypeField(array $optionData, array $updateData): void
6771
{
68-
$product = $this->productRepository->get('simple');
72+
$product = $this->productRepository->get($this->productSku);
6973
/** @var ProductCustomOptionInterface|Option $option */
7074
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
7175
$option->setProductSku($product->getSku());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Save;
9+
10+
use Magento\Catalog\Controller\Adminhtml\Product\Save\CreateCustomOptionsTest as SimpleProductOptionsTest;
11+
12+
/**
13+
* Base test cases for configurable product custom options with type "field".
14+
* Option add via dispatch product controller action save with options data in POST data.
15+
*
16+
* @magentoAppArea adminhtml
17+
* @magentoDbIsolation enabled
18+
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
19+
*/
20+
class CreateCustomOptionsTest extends SimpleProductOptionsTest
21+
{
22+
/**
23+
* @var string
24+
*/
25+
protected $productSku = 'configurable';
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Save;
9+
10+
use Magento\Catalog\Controller\Adminhtml\Product\Save\DeleteCustomOptionsTest as SimpleProductOptionsTest;
11+
12+
/**
13+
* Base test cases for delete configurable product custom option with type "field".
14+
* Option deleting via product controller action save.
15+
*
16+
* @magentoAppArea adminhtml
17+
* @magentoDbIsolation enabled
18+
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
19+
*/
20+
class DeleteCustomOptionsTest extends SimpleProductOptionsTest
21+
{
22+
/**
23+
* @var string
24+
*/
25+
protected $productSku = 'configurable';
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Save;
9+
10+
use Magento\Catalog\Controller\Adminhtml\Product\Save\UpdateCustomOptionsTest as SimpleProductOptionsTest;
11+
12+
/**
13+
* Base test cases for update configurable product custom options with type "field".
14+
* Option updating via dispatch product controller action save with updated options data in POST data.
15+
*
16+
* @magentoAppArea adminhtml
17+
* @magentoDbIsolation enabled
18+
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
19+
*/
20+
class UpdateCustomOptionsTest extends SimpleProductOptionsTest
21+
{
22+
/**
23+
* @var string
24+
*/
25+
protected $productSku = 'configurable';
26+
}

0 commit comments

Comments
 (0)