Skip to content

Commit 0fc90fd

Browse files
committed
Merge branch 'MAGETWO-63190' of github.com:magento-troll/magento2ce into Troll_PR
2 parents a2db060 + 802863d commit 0fc90fd

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Model\Product;
99
use Magento\Framework\Registry;
1010
use Magento\TestFramework\ObjectManager;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
1112

1213
/**
1314
* @magentoAppArea adminhtml
@@ -16,13 +17,15 @@ class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendControl
1617
{
1718
/**
1819
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
20+
* @magentoDataFixture Magento/ConfigurableProduct/_files/associated_products.php
1921
*/
2022
public function testSaveActionAssociatedProductIds()
2123
{
22-
$associatedProductIds = [3, 14, 15, 92];
24+
$associatedProductIds = ['3', '14', '15', '92'];
2325
$associatedProductIdsJSON = json_encode($associatedProductIds);
2426
$this->getRequest()->setPostValue(
2527
[
28+
'id' => 1,
2629
'attributes' => [$this->_getConfigurableAttribute()->getId()],
2730
'associated_product_ids_serialized' => $associatedProductIdsJSON,
2831
]
@@ -35,8 +38,21 @@ public function testSaveActionAssociatedProductIds()
3538

3639
/** @var $product Product */
3740
$product = $objectManager->get(Registry::class)->registry('current_product');
41+
$configurableProductLinks = array_values($product->getExtensionAttributes()->getConfigurableProductLinks());
42+
self::assertEquals(
43+
$associatedProductIds,
44+
$configurableProductLinks,
45+
'Product links are not available in the registry'
46+
);
3847

39-
self::assertEquals($associatedProductIds, $product->getExtensionAttributes()->getConfigurableProductLinks());
48+
/** @var $product \Magento\Catalog\Api\Data\ProductInterface */
49+
$product = $objectManager->get(ProductRepositoryInterface::class)->getById(1, false, null, true);
50+
$configurableProductLinks = array_values($product->getExtensionAttributes()->getConfigurableProductLinks());
51+
self::assertEquals(
52+
$associatedProductIds,
53+
$configurableProductLinks,
54+
'Product links are not available in the database'
55+
);
4056
}
4157

4258
/**
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
8+
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
9+
->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
10+
11+
/** @var $product \Magento\Catalog\Model\Product */
12+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
13+
->create(\Magento\Catalog\Model\Product::class);
14+
$product
15+
->setTypeId('simple')
16+
->setId(3)
17+
->setAttributeSetId(4)
18+
->setWebsiteIds([1])
19+
->setName('Simple Product 3')
20+
->setSku('simple_3')
21+
->setPrice(10)
22+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
23+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
24+
->setQty(22);
25+
$product = $productRepository->save($product);
26+
27+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
28+
->create(\Magento\Catalog\Model\Product::class);
29+
$product
30+
->setTypeId('simple')
31+
->setId(14)
32+
->setAttributeSetId(4)
33+
->setWebsiteIds([1])
34+
->setName('Simple Product 14')
35+
->setSku('simple_14')
36+
->setPrice(10)
37+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
38+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
39+
->setQty(22);
40+
$product = $productRepository->save($product);
41+
42+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
43+
->create(\Magento\Catalog\Model\Product::class);
44+
$product
45+
->setTypeId('simple')
46+
->setId(15)
47+
->setAttributeSetId(4)
48+
->setWebsiteIds([1])
49+
->setName('Simple Product 15')
50+
->setSku('simple_15')
51+
->setPrice(10)
52+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
53+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
54+
->setQty(22);
55+
$product = $productRepository->save($product);
56+
57+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
58+
->create(\Magento\Catalog\Model\Product::class);
59+
$product
60+
->setTypeId('simple')
61+
->setId(92)
62+
->setAttributeSetId(4)
63+
->setWebsiteIds([1])
64+
->setName('Simple Product 92')
65+
->setSku('simple_92')
66+
->setPrice(10)
67+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
68+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
69+
->setQty(22);
70+
$product = $productRepository->save($product);

0 commit comments

Comments
 (0)