Skip to content

Commit 3dbe4a7

Browse files
committed
MC-20668: Edit custom options of simple product
1 parent e7ff49d commit 3dbe4a7

File tree

12 files changed

+63
-40
lines changed

12 files changed

+63
-40
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
1212
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
1313
use Magento\Catalog\Api\ProductRepositoryInterface;
14+
use Magento\Catalog\Model\Product\Option;
1415
use Magento\Framework\App\Request\Http as HttpRequest;
1516
use Magento\Framework\Message\MessageInterface;
1617
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -60,10 +61,12 @@ protected function setUp()
6061
*
6162
* @param array $optionData
6263
* @param array $updateData
64+
* @return void
6365
*/
6466
public function testUpdateCustomOptionWithTypeField(array $optionData, array $updateData): void
6567
{
6668
$product = $this->productRepository->get('simple');
69+
/** @var ProductCustomOptionInterface|Option $option */
6770
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
6871
$option->setProductSku($product->getSku());
6972
$product->setOptions([$option]);
@@ -87,9 +90,9 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
8790
'price' => $currentOption->getPrice(),
8891
'price_type' => $currentOption->getPriceType(),
8992
'is_use_default' => false,
90-
]
91-
]
92-
]
93+
],
94+
],
95+
],
9396
];
9497

9598
foreach ($updateData as $methodKey => $newValue) {
@@ -100,7 +103,7 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
100103
'options' => [
101104
0 => [
102105
$methodKey => $newValue,
103-
]
106+
],
104107
],
105108
],
106109
]
@@ -114,12 +117,11 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
114117
);
115118
$updatedOptions = $this->optionRepository->getProductOptions($product);
116119
$this->assertCount(1, $updatedOptions);
117-
/** @var ProductCustomOptionInterface $updatedOption */
120+
/** @var ProductCustomOptionInterface|Option $updatedOption */
118121
$updatedOption = reset($updatedOptions);
119-
$methodName = str_replace('_', '', ucwords($methodKey, '_'));
120-
$this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
122+
$this->assertEquals($newValue, $updatedOption->getDataUsingMethod($methodKey));
121123
$this->assertEquals($option->getOptionId(), $updatedOption->getOptionId());
122-
$this->assertNotEquals($option->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
124+
$this->assertNotEquals($option->getDataUsingMethod($methodKey), $updatedOption->getDataUsingMethod($methodKey));
123125
}
124126
}
125127
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
1112

1213
/**
@@ -19,6 +20,6 @@ class Date extends AbstractBase
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'date';
23+
return ProductCustomOptionInterface::OPTION_GROUP_DATE;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
1112

1213
/**
@@ -19,6 +20,6 @@ class DateTime extends AbstractBase
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'date_time';
23+
return ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
1112

1213
/**
@@ -19,6 +20,6 @@ class Time extends AbstractBase
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'time';
23+
return ProductCustomOptionInterface::OPTION_TYPE_TIME;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\File;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
1112

1213
/**
@@ -85,6 +86,6 @@ public function getDataForUpdateOptions(): array
8586
*/
8687
protected function getType(): string
8788
{
88-
return 'file';
89+
return ProductCustomOptionInterface::OPTION_TYPE_FILE;
8990
}
9091
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
1112

1213
/**
@@ -19,6 +20,6 @@ class Checkbox extends AbstractSelect
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'checkbox';
23+
return ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
1112

1213
/**
@@ -19,6 +20,6 @@ class DropDown extends AbstractSelect
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'drop_down';
23+
return ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
1112

1213
/**
@@ -19,6 +20,6 @@ class MultipleSelect extends AbstractSelect
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'multiple';
23+
return ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
1112

1213
/**
@@ -19,6 +20,6 @@ class RadioButtons extends AbstractSelect
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'radio';
23+
return ProductCustomOptionInterface::OPTION_TYPE_RADIO;
2324
}
2425
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
1011
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\AbstractText;
1112

1213
/**
@@ -19,6 +20,6 @@ class Area extends AbstractText
1920
*/
2021
protected function getType(): string
2122
{
22-
return 'area';
23+
return ProductCustomOptionInterface::OPTION_TYPE_AREA;
2324
}
2425
}

0 commit comments

Comments
 (0)