Skip to content

Commit d468cd8

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into FearlessKiwis-MAGETWO-67496
2 parents d5996b7 + 86794cb commit d468cd8

File tree

4 files changed

+150
-5
lines changed

4 files changed

+150
-5
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);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
/* global jQuery */
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'jquery',
9+
'squire',
10+
'mage/backend/notification'
11+
], function ($, Squire) {
12+
'use strict';
13+
14+
var injector = new Squire();
15+
16+
describe('mage/backend/bootstrap', function () {
17+
beforeEach(function (done) {
18+
injector.require(['mage/backend/bootstrap'], function () {
19+
done();
20+
});
21+
});
22+
describe('"sendPostponeRequest" method', function () {
23+
it('should insert "Error" notification if request failed', function () {
24+
jQuery('<div class="page-main-actions"></div>').appendTo('body');
25+
jQuery('body').notification();
26+
27+
jQuery.ajax().abort();
28+
29+
expect(jQuery('.message-error').length).toBe(1);
30+
expect(jQuery('body:contains("A technical problem with the server created an error")').length).toBe(1);
31+
});
32+
});
33+
});
34+
});

lib/web/mage/backend/bootstrap.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
define([
88
'jquery',
99
'mage/apply/main',
10+
'mage/backend/notification',
1011
'Magento_Ui/js/lib/knockout/bootstrap',
11-
'mage/mage'
12-
], function ($, mage) {
12+
'mage/mage',
13+
'mage/translate'
14+
], function ($, mage, notification) {
1315
'use strict';
1416

1517
var bootstrap;
@@ -67,6 +69,29 @@ define([
6769
}
6870
} catch (e) {}
6971
}
72+
},
73+
74+
/**
75+
* Error callback.
76+
*/
77+
error: function () {
78+
$('body').notification('clear')
79+
.notification('add', {
80+
error: true,
81+
message: $.mage.__(
82+
'A technical problem with the server created an error. ' +
83+
'Try again to continue what you were doing. If the problem persists, try again later.'
84+
),
85+
86+
/**
87+
* @param {String} message
88+
*/
89+
insertMethod: function (message) {
90+
var $wrapper = $('<div/>').html(message);
91+
92+
$('.page-main-actions').after($wrapper);
93+
}
94+
});
7095
}
7196
});
7297

@@ -83,7 +108,7 @@ define([
83108
/*
84109
* Initialization of notification widget
85110
*/
86-
$('body').mage('notification');
111+
notification({}, $('body'));
87112
};
88113

89114
$(bootstrap);

0 commit comments

Comments
 (0)