Skip to content

Commit c70222d

Browse files
committed
MC-20508: Api-functional tests for Product prices including FPT
- splitting fixtures to make work integration tests and webapi
2 parents 37d9f6c + d7f8c4a commit c70222d

File tree

5 files changed

+107
-57
lines changed

5 files changed

+107
-57
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceWithFPTTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ public function catalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAp
547547
* @return void
548548
*
549549
* @dataProvider catalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSettingsProvider
550-
* @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php
551-
* @magentoApiDataFixture Magento/Weee/_files/fixed_product_attribute.php
550+
* @magentoApiDataFixture Magento/Weee/_files/product_with_two_fpt.php
552551
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
553552
*/
554553
public function testCatalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTs(array $weeTaxSettings)

dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute.php

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

8-
use Magento\Catalog\Model\Product;
9-
use Magento\TestFramework\Helper\Bootstrap;
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
10+
11+
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
12+
$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class);
1013

11-
/** @var \Magento\Catalog\Setup\CategorySetup $installer */
12-
$installer = Bootstrap::getObjectManager()->create(
13-
\Magento\Catalog\Setup\CategorySetup::class
14-
);
15-
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
16-
$entityModel = Bootstrap::getObjectManager()->create(\Magento\Eav\Model\Entity::class);
17-
$entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId();
18-
$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
14+
$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product');
15+
$defaultSetId = $objectManager->create(\Magento\Catalog\Model\Product::class)->getDefaultAttributeSetid();
1916

20-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
21-
$attribute = Bootstrap::getObjectManager()->create(
22-
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
23-
);
24-
$attribute->setAttributeCode(
25-
'fixed_product_attribute'
26-
)->setEntityTypeId(
27-
$entityTypeId
28-
)->setAttributeGroupId(
29-
$groupId
30-
)->setAttributeSetId(
31-
$attributeSetId
32-
)->setFrontendLabel(
33-
'fixed_product_attribute_front_label'
34-
)->setFrontendInput(
35-
'weee'
36-
)->setIsUserDefined(
37-
1
38-
)->save();
17+
$attributeGroupId = $attributeSet->getDefaultGroupId($entityType->getDefaultAttributeSetId());
3918

40-
/** @var $product \Magento\Catalog\Model\Product */
41-
$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
19+
$attributeData = [
20+
'entity_type_id' => $entityType->getId(),
21+
'attribute_code' => 'fixed_product_attribute',
22+
'backend_model' => 'Magento\Weee\Model\Attribute\Backend\Weee\Tax',
23+
'is_required' => 0,
24+
'is_user_defined' => 1,
25+
'is_static' => 1,
26+
'attribute_set_id' => $defaultSetId,
27+
'attribute_group_id' => $attributeGroupId,
28+
];
4229

43-
$product = $product->loadByAttribute('sku', 'simple-with-ftp');
44-
if ($product && $product->getId()) {
45-
$product->setFixedProductAttribute(
46-
[['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10.00, 'delete' => '']]
47-
)->save();
48-
}
30+
/** @var \Magento\Catalog\Model\Entity\Attribute $attribute */
31+
$attribute = $objectManager->create(\Magento\Eav\Model\Entity\Attribute::class);
32+
$attribute->setData($attributeData);
33+
$attribute->save();

dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute_rollback.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
7-
8-
use Magento\TestFramework\Helper\Bootstrap;
96

10-
$objectManager = Bootstrap::getObjectManager();
11-
/** @var \Magento\Framework\Registry $registry */
12-
$registry = $objectManager->get(\Magento\Framework\Registry::class);
13-
14-
$registry->unregister('isSecureArea');
15-
$registry->register('isSecureArea', true);
7+
declare(strict_types=1);
168

17-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
18-
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
19-
->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
20-
$attribute->load('fixed_product_attribute', 'attribute_code');
21-
if ($attribute->getId()) {
22-
$attribute->delete();
23-
}
9+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
2410

25-
$registry->unregister('isSecureArea');
26-
$registry->register('isSecureArea', false);
11+
/* @var \Magento\Eav\Model\Entity\Attribute $attribute */
12+
$attribute = $objectManager->get(\Magento\Eav\Model\Entity\Attribute::class);
13+
$attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'fixed_product_attribute');
14+
$attribute->delete();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
use Magento\Catalog\Model\Product;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
11+
require __DIR__ . '/product_with_fpt.php';
12+
13+
/** @var \Magento\Catalog\Setup\CategorySetup $installer */
14+
$installer = Bootstrap::getObjectManager()->create(
15+
\Magento\Catalog\Setup\CategorySetup::class
16+
);
17+
$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
18+
$entityModel = Bootstrap::getObjectManager()->create(\Magento\Eav\Model\Entity::class);
19+
$entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId();
20+
$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
21+
22+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
23+
$attribute = Bootstrap::getObjectManager()->create(
24+
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
25+
);
26+
$attribute->setAttributeCode(
27+
'fixed_product_attribute'
28+
)->setEntityTypeId(
29+
$entityTypeId
30+
)->setAttributeGroupId(
31+
$groupId
32+
)->setAttributeSetId(
33+
$attributeSetId
34+
)->setFrontendLabel(
35+
'fixed_product_attribute_front_label'
36+
)->setFrontendInput(
37+
'weee'
38+
)->setIsUserDefined(
39+
1
40+
)->save();
41+
42+
/** @var $product \Magento\Catalog\Model\Product */
43+
$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
44+
45+
$product = $product->loadByAttribute('sku', 'simple-with-ftp');
46+
if ($product && $product->getId()) {
47+
$product->setFixedProductAttribute(
48+
[['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10.00, 'delete' => '']]
49+
)->save();
50+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
use Magento\TestFramework\Helper\Bootstrap;
9+
10+
$objectManager = Bootstrap::getObjectManager();
11+
/** @var \Magento\Framework\Registry $registry */
12+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
13+
14+
$registry->unregister('isSecureArea');
15+
$registry->register('isSecureArea', true);
16+
17+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
18+
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
19+
->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
20+
$attribute->load('fixed_product_attribute', 'attribute_code');
21+
if ($attribute->getId()) {
22+
$attribute->delete();
23+
}
24+
25+
require __DIR__ . '/product_with_fpt_rollback.php';
26+
27+
$registry->unregister('isSecureArea');
28+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)