Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 9762618

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-91608-seo-url
2 parents 3483dd5 + 919dd8c commit 9762618

File tree

142 files changed

+3890
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+3890
-703
lines changed

app/code/Magento/Backend/App/AbstractAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request)
217217
$this->_view->loadLayout(['default', 'adminhtml_denied'], true, true, false);
218218
$this->_view->renderLayout();
219219
$this->_request->setDispatched(true);
220+
220221
return $this->_response;
221222
}
222223

@@ -226,6 +227,11 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request)
226227

227228
$this->_processLocaleSettings();
228229

230+
// Need to preload isFirstPageAfterLogin (see https://github.com/magento/magento2/issues/15510)
231+
if ($this->_auth->isLoggedIn()) {
232+
$this->_auth->getAuthStorage()->isFirstPageAfterLogin();
233+
}
234+
229235
return parent::dispatch($request);
230236
}
231237

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPric
6161

6262
if (!$useRegularPrice) {
6363
$selectionsCollection->addAttributeToSelect('special_price');
64-
$selectionsCollection->addAttributeToSelect('special_price_from');
65-
$selectionsCollection->addAttributeToSelect('special_price_to');
64+
$selectionsCollection->addAttributeToSelect('special_from_date');
65+
$selectionsCollection->addAttributeToSelect('special_to_date');
6666
$selectionsCollection->addAttributeToSelect('tax_class_id');
6767
}
6868

app/code/Magento/Bundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"suggest": {
2727
"magento/module-webapi": "*",
28-
"magento/module-bundle-sample-data": "*"
28+
"magento/module-bundle-sample-data": "*",
29+
"magento/module-sales-rule": "*"
2930
},
3031
"type": "magento2-module",
3132
"license": [

app/code/Magento/Bundle/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,11 @@
207207
</argument>
208208
</arguments>
209209
</type>
210+
<type name="Magento\SalesRule\Model\Quote\ChildrenValidationLocator">
211+
<arguments>
212+
<argument name="productTypeChildrenValidationMap" xsi:type="array">
213+
<item name="bundle" xsi:type="boolean">false</item>
214+
</argument>
215+
</arguments>
216+
</type>
210217
</config>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
namespace Magento\Captcha\Test\Unit\Observer;
9+
10+
use Magento\Captcha\Helper\Data as CaptchaDataHelper;
11+
use Magento\Captcha\Observer\CaptchaStringResolver;
12+
use Magento\Framework\App\Request\Http as HttpRequest;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
15+
class CaptchaStringResolverTest extends \PHPUnit\Framework\TestCase
16+
{
17+
/**
18+
* @var ObjectManager
19+
*/
20+
private $objectManagerHelper;
21+
22+
/**
23+
* @var CaptchaStringResolver
24+
*/
25+
private $captchaStringResolver;
26+
27+
/**
28+
* @var HttpRequest|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $requestMock;
31+
32+
protected function setUp()
33+
{
34+
$this->objectManagerHelper = new ObjectManager($this);
35+
$this->requestMock = $this->createMock(HttpRequest::class);
36+
$this->captchaStringResolver = $this->objectManagerHelper->getObject(CaptchaStringResolver::class);
37+
}
38+
39+
public function testResolveWithFormIdSet()
40+
{
41+
$formId = 'contact_us';
42+
$captchaValue = 'some-value';
43+
44+
$this->requestMock->expects($this->once())
45+
->method('getPost')
46+
->with(CaptchaDataHelper::INPUT_NAME_FIELD_VALUE)
47+
->willReturn([$formId => $captchaValue]);
48+
49+
self::assertEquals(
50+
$this->captchaStringResolver->resolve($this->requestMock, $formId),
51+
$captchaValue
52+
);
53+
}
54+
55+
public function testResolveWithNoFormIdInRequest()
56+
{
57+
$formId = 'contact_us';
58+
59+
$this->requestMock->expects($this->once())
60+
->method('getPost')
61+
->with(CaptchaDataHelper::INPUT_NAME_FIELD_VALUE)
62+
->willReturn([]);
63+
64+
self::assertEquals(
65+
$this->captchaStringResolver->resolve($this->requestMock, $formId),
66+
''
67+
);
68+
}
69+
}

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ protected function setUp()
6363
'getAttributes',
6464
'getStore',
6565
'getAttributeDefaultValue',
66-
'getExistsStoreValueFlag'
66+
'getExistsStoreValueFlag',
67+
'isLockedAttribute'
6768
])->getMockForAbstractClass();
6869
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
6970
->setMethods(['load', 'getId', 'getConfig'])
@@ -81,9 +82,6 @@ protected function setUp()
8182
$this->arrayManagerMock->expects($this->any())
8283
->method('set')
8384
->willReturnArgument(1);
84-
$this->arrayManagerMock->expects($this->any())
85-
->method('merge')
86-
->willReturnArgument(1);
8785
$this->arrayManagerMock->expects($this->any())
8886
->method('remove')
8987
->willReturnArgument(1);

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AttributeSetTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

8+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
89
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AttributeSet;
910
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
1011
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection;
@@ -84,7 +85,30 @@ protected function createModel()
8485

8586
public function testModifyMeta()
8687
{
87-
$this->assertNotEmpty($this->getModel()->modifyMeta(['test_group' => []]));
88+
$modifyMeta = $this->getModel()->modifyMeta(['test_group' => []]);
89+
$this->assertNotEmpty($modifyMeta);
90+
}
91+
92+
/**
93+
* @param bool $locked
94+
* @dataProvider modifyMetaLockedDataProvider
95+
*/
96+
public function testModifyMetaLocked($locked)
97+
{
98+
$this->productMock->expects($this->any())
99+
->method('isLockedAttribute')
100+
->willReturn($locked);
101+
$modifyMeta = $this->getModel()->modifyMeta([AbstractModifier::DEFAULT_GENERAL_PANEL => []]);
102+
$children = $modifyMeta[AbstractModifier::DEFAULT_GENERAL_PANEL]['children'];
103+
$this->assertEquals(
104+
$locked,
105+
$children['attribute_set_id']['arguments']['data']['config']['disabled']
106+
);
107+
}
108+
109+
public function modifyMetaLockedDataProvider()
110+
{
111+
return [[true], [false]];
88112
}
89113

90114
public function testModifyMetaToBeEmpty()

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,44 @@ public function testModifyMeta()
114114
$this->assertArrayHasKey($groupCode, $this->getModel()->modifyMeta($meta));
115115
}
116116

117+
/**
118+
* @param bool $locked
119+
* @dataProvider modifyMetaLockedDataProvider
120+
*/
121+
public function testModifyMetaLocked($locked)
122+
{
123+
$groupCode = 'test_group_code';
124+
$meta = [
125+
$groupCode => [
126+
'children' => [
127+
'category_ids' => [
128+
'sortOrder' => 10,
129+
],
130+
],
131+
],
132+
];
133+
134+
$this->arrayManagerMock->expects($this->any())
135+
->method('findPath')
136+
->willReturn('path');
137+
138+
$this->productMock->expects($this->any())
139+
->method('isLockedAttribute')
140+
->willReturn($locked);
141+
142+
$this->arrayManagerMock->expects($this->any())
143+
->method('merge')
144+
->willReturnArgument(2);
145+
146+
$modifyMeta = $this->createModel()->modifyMeta($meta);
147+
$this->assertEquals($locked, $modifyMeta['arguments']['data']['config']['disabled']);
148+
}
149+
150+
public function modifyMetaLockedDataProvider()
151+
{
152+
return [[true], [false]];
153+
}
154+
117155
public function testModifyMetaWithCaching()
118156
{
119157
$this->arrayManagerMock->expects($this->exactly(2))

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public function testModifyData()
462462
* @param bool $productRequired
463463
* @param string|null $attrValue
464464
* @param array $expected
465-
* @return void
465+
* @param bool $locked
466466
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
467467
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
468468
* @dataProvider setupAttributeMetaDataProvider
@@ -471,7 +471,8 @@ public function testSetupAttributeMetaDefaultAttribute(
471471
$productId,
472472
bool $productRequired,
473473
$attrValue,
474-
array $expected
474+
array $expected,
475+
$locked = false
475476
) : void {
476477
$configPath = 'arguments/data/config';
477478
$groupCode = 'product-details';
@@ -492,6 +493,7 @@ public function testSetupAttributeMetaDefaultAttribute(
492493
];
493494

494495
$this->productMock->method('getId')->willReturn($productId);
496+
$this->productMock->expects($this->any())->method('isLockedAttribute')->willReturn($locked);
495497
$this->productAttributeMock->method('getIsRequired')->willReturn($productRequired);
496498
$this->productAttributeMock->method('getDefaultValue')->willReturn('required_value');
497499
$this->productAttributeMock->method('getAttributeCode')->willReturn('code');
@@ -520,14 +522,14 @@ public function testSetupAttributeMetaDefaultAttribute(
520522
)
521523
->willReturn($expected);
522524

523-
$this->arrayManagerMock->expects($this->once())
525+
$this->arrayManagerMock->expects($this->any())
524526
->method('merge')
525527
->with(
526528
$this->anything(),
527529
$this->anything(),
528530
$this->callback(
529531
function ($value) use ($attributeOptionsExpected) {
530-
return $value['options'] === $attributeOptionsExpected;
532+
return isset($value['options']) ? $value['options'] === $attributeOptionsExpected : true;
531533
}
532534
)
533535
)
@@ -544,6 +546,7 @@ function ($value) use ($attributeOptionsExpected) {
544546

545547
/**
546548
* @return array
549+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
547550
*/
548551
public function setupAttributeMetaDataProvider()
549552
{
@@ -567,6 +570,26 @@ public function setupAttributeMetaDataProvider()
567570
'sortOrder' => 0,
568571
],
569572
],
573+
'default_null_prod_not_new_locked_and_required' => [
574+
'productId' => 1,
575+
'productRequired' => true,
576+
'attrValue' => 'val',
577+
'expected' => [
578+
'dataType' => null,
579+
'formElement' => null,
580+
'visible' => null,
581+
'required' => true,
582+
'notice' => null,
583+
'default' => null,
584+
'label' => new Phrase(null),
585+
'code' => 'code',
586+
'source' => 'product-details',
587+
'scopeLabel' => '',
588+
'globalScope' => false,
589+
'sortOrder' => 0,
590+
],
591+
'locked' => true,
592+
],
570593
'default_null_prod_not_new_and_not_required' => [
571594
'productId' => 1,
572595
'productRequired' => false,
@@ -605,6 +628,26 @@ public function setupAttributeMetaDataProvider()
605628
'sortOrder' => 0,
606629
],
607630
],
631+
'default_null_prod_new_locked_and_not_required' => [
632+
'productId' => null,
633+
'productRequired' => false,
634+
'attrValue' => null,
635+
'expected' => [
636+
'dataType' => null,
637+
'formElement' => null,
638+
'visible' => null,
639+
'required' => false,
640+
'notice' => null,
641+
'default' => 'required_value',
642+
'label' => new Phrase(null),
643+
'code' => 'code',
644+
'source' => 'product-details',
645+
'scopeLabel' => '',
646+
'globalScope' => false,
647+
'sortOrder' => 0,
648+
],
649+
'locked' => true,
650+
],
608651
'default_null_prod_new_and_required' => [
609652
'productId' => null,
610653
'productRequired' => false,

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ protected function createModel()
6060

6161
public function testModifyMeta()
6262
{
63+
$this->arrayManagerMock->expects($this->any())
64+
->method('merge')
65+
->willReturnArgument(2);
6366
$this->assertNotEmpty($this->getModel()->modifyMeta([
6467
'first_panel_code' => [
6568
'arguments' => [

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdateTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ protected function createModel()
2424

2525
public function testModifyMeta()
2626
{
27+
$this->arrayManagerMock->expects($this->any())
28+
->method('merge')
29+
->willReturnArgument(1);
2730
$this->assertSame([], $this->getModel()->modifyMeta([]));
2831
}
2932

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ class WebsitesTest extends AbstractModifierTest
7676

7777
protected function setUp()
7878
{
79-
$this->objectManager = new ObjectManager($this);
79+
parent::setUp();
80+
$this->productMock->expects($this->any())
81+
->method('getId')
82+
->willReturn(self::PRODUCT_ID);
8083
$this->assignedWebsites = [self::SECOND_WEBSITE_ID];
8184
$this->websiteMock = $this->getMockBuilder(\Magento\Store\Model\Website::class)
8285
->setMethods(['getId', 'getName'])
@@ -101,15 +104,9 @@ protected function setUp()
101104
$this->storeRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\StoreRepositoryInterface::class)
102105
->setMethods(['getList'])
103106
->getMockForAbstractClass();
104-
$this->locatorMock = $this->getMockBuilder(\Magento\Catalog\Model\Locator\LocatorInterface::class)
105-
->setMethods(['getProduct', 'getWebsiteIds'])
106-
->getMockForAbstractClass();
107107
$this->productMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
108108
->setMethods(['getId'])
109109
->getMockForAbstractClass();
110-
$this->locatorMock->expects($this->any())
111-
->method('getProduct')
112-
->willReturn($this->productMock);
113110
$this->locatorMock->expects($this->any())
114111
->method('getWebsiteIds')
115112
->willReturn($this->assignedWebsites);
@@ -148,9 +145,6 @@ protected function setUp()
148145
$this->storeRepositoryMock->expects($this->any())
149146
->method('getList')
150147
->willReturn([$this->storeViewMock]);
151-
$this->productMock->expects($this->any())
152-
->method('getId')
153-
->willReturn(self::PRODUCT_ID);
154148
$this->secondWebsiteMock->expects($this->any())
155149
->method('getId')
156150
->willReturn($this->assignedWebsites[0]);

0 commit comments

Comments
 (0)