|
9 | 9 | namespace Magento\ConfigurableProduct\Api;
|
10 | 10 |
|
11 | 11 | use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
|
| 12 | +use Magento\Eav\Api\AttributeRepositoryInterface; |
12 | 13 | use Magento\Eav\Model\AttributeRepository;
|
13 | 14 | use Magento\Eav\Model\Entity\Attribute\Option;
|
14 | 15 | use Magento\Framework\Webapi\Rest\Request;
|
| 16 | +use Magento\TestFramework\Helper\Bootstrap; |
15 | 17 | use Magento\TestFramework\TestCase\WebapiAbstract;
|
16 | 18 |
|
17 | 19 | /**
|
@@ -87,6 +89,52 @@ public function testAddChild(): void
|
87 | 89 | $this->assertTrue($res);
|
88 | 90 | }
|
89 | 91 |
|
| 92 | + /** |
| 93 | + * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php |
| 94 | + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php |
| 95 | + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_simple_77.php |
| 96 | + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/delete_association.php |
| 97 | + * |
| 98 | + * @return void |
| 99 | + */ |
| 100 | + public function testAddChildToConfigurableProdWithoutOption(): void |
| 101 | + { |
| 102 | + /** @var AttributeRepositoryInterface $attributeRepository */ |
| 103 | + $attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class); |
| 104 | + |
| 105 | + /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */ |
| 106 | + $attribute = $attributeRepository->get('catalog_product', 'test_configurable'); |
| 107 | + |
| 108 | + $productSku = 'simple'; |
| 109 | + $serviceInfo = [ |
| 110 | + 'rest' => [ |
| 111 | + 'resourcePath' => self::RESOURCE_PATH . '/' . $productSku . '/options', |
| 112 | + 'httpMethod' => Request::HTTP_METHOD_POST |
| 113 | + ], |
| 114 | + 'soap' => [ |
| 115 | + 'service' => self::SERVICE_NAME, |
| 116 | + 'serviceVersion' => self::SERVICE_VERSION, |
| 117 | + 'operation' => self::SERVICE_NAME . 'Save' |
| 118 | + ] |
| 119 | + ]; |
| 120 | + $option = [ |
| 121 | + 'attribute_id' => $attribute->getAttributeId(), |
| 122 | + 'label' => 'Test', |
| 123 | + 'values' => [ |
| 124 | + [ |
| 125 | + 'value_index' => 1, |
| 126 | + ] |
| 127 | + ], |
| 128 | + ]; |
| 129 | + /** @var int $result */ |
| 130 | + $result = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'option' => $option]); |
| 131 | + $this->assertGreaterThan(0, $result); |
| 132 | + |
| 133 | + $childSku = 'simple_77'; |
| 134 | + $res = $this->addChild($productSku, $childSku); |
| 135 | + $this->assertTrue($res); |
| 136 | + } |
| 137 | + |
90 | 138 | /**
|
91 | 139 | * Test the full flow of creating a configurable product and adding a child via REST
|
92 | 140 | *
|
|
0 commit comments