Skip to content

Commit 03c4b12

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-qwerty/MAGETWO-89540
2 parents 0c8d45c + 4cf1a32 commit 03c4b12

File tree

38 files changed

+496
-44
lines changed

38 files changed

+496
-44
lines changed

app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ define([
480480
* @param {String} directive
481481
*/
482482
makeDirectiveUrl: function (directive) {
483-
return this.config['directives_url'].replace(/directive.*/, 'directive/___directive/' + directive);
483+
return this.config['directives_url']
484+
.replace(/directive/, 'directive/___directive/' + directive)
485+
.replace(/\/$/, '');
484486
},
485487

486488
/**
@@ -537,12 +539,18 @@ define([
537539
* @return {*}
538540
*/
539541
decodeDirectives: function (content) {
540-
// escape special chars in directives url to use it in regular expression
541-
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
542-
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9%,_-]+)\/?'));
543-
544-
return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind
545-
return Base64.mageDecode(decodeURIComponent(match[1])).replace(/"/g, '"');
542+
var directiveUrl = this.makeDirectiveUrl('%directive%').split('?')[0], // remove query string from directive
543+
// escape special chars in directives url to use in regular expression
544+
regexEscapedDirectiveUrl = directiveUrl.replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
545+
regexDirectiveUrl = regexEscapedDirectiveUrl
546+
.replace(
547+
'%directive%',
548+
'([a-zA-Z0-9,_-]+(?:%2[A-Z]|)+\/?)(?:(?!").)*'
549+
) + '/?(\\\\?[^"]*)?', // allow optional query string
550+
reg = new RegExp(regexDirectiveUrl);
551+
552+
return content.gsub(reg, function (match) {
553+
return Base64.mageDecode(decodeURIComponent(match[1]).replace(/\/$/, '')).replace(/"/g, '"');
546554
});
547555
},
548556

app/code/Magento/Ui/Component/Form/Element/DataType/Media/Image.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public function getComponentName()
6464
public function prepare()
6565
{
6666
// dynamically set max file size based on php ini config if not present in XML
67-
$maxFileSize = $this->getConfiguration()['maxFileSize'] ?? $this->fileSize->getMaxFileSize();
67+
$maxFileSize = min(array_filter([
68+
$this->getConfiguration()['maxFileSize'] ?? 0,
69+
$this->fileSize->getMaxFileSize()
70+
]));
6871

6972
$data = array_replace_recursive(
7073
$this->getData(),
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Ui\Test\Unit\Component\Form\Element\DataType\Media;
10+
11+
use Magento\Ui\Component\Form\Element\DataType\Media\Image;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Store\Api\Data\StoreInterface;
14+
use Magento\Framework\File\Size;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
17+
class ImageTest extends \Magento\Ui\Test\Unit\Component\Form\Element\DataType\MediaTest
18+
{
19+
/**
20+
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
private $store;
23+
24+
/**
25+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
private $storeManager;
28+
29+
/**
30+
* @var Size|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $fileSize;
33+
34+
/**
35+
* @var ObjectManager
36+
*/
37+
private $objectManager;
38+
39+
/**
40+
* @var Image
41+
*/
42+
private $image;
43+
44+
public function setUp()
45+
{
46+
parent::setUp();
47+
48+
$this->processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class)
49+
->disableOriginalConstructor()
50+
->getMock();
51+
52+
$this->context->expects($this->atLeastOnce())->method('getProcessor')->willReturn($this->processor);
53+
54+
$this->storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class);
55+
56+
$this->store = $this->getMockBuilder(StoreInterface::class)
57+
->disableOriginalConstructor()
58+
->getMock();
59+
60+
$this->store->expects($this->any())->method('getId')->willReturn(0);
61+
62+
$this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
63+
64+
$this->fileSize = $this->getMockBuilder(Size::class)->getMock();
65+
66+
$this->objectManager = new ObjectManager($this);
67+
68+
$this->image = $this->objectManager->getObject(Image::class, [
69+
'context' => $this->context,
70+
'storeManager' => $this->storeManager,
71+
'fileSize' => $this->fileSize
72+
]);
73+
74+
$this->image->setData([
75+
'config' => [
76+
'initialMediaGalleryOpenSubpath' => 'open/sesame',
77+
],
78+
]);
79+
}
80+
81+
/**
82+
* @dataProvider prepareDataProvider
83+
*/
84+
public function testPrepare()
85+
{
86+
$this->assertExpectedPreparedConfiguration(...func_get_args());
87+
}
88+
89+
/**
90+
* Data provider for testPrepare
91+
* @return array
92+
*/
93+
public function prepareDataProvider(): array
94+
{
95+
return [
96+
[['maxFileSize' => 10], 10, ['maxFileSize' => 10]],
97+
[['maxFileSize' => null], 10, ['maxFileSize' => 10]],
98+
[['maxFileSize' => 10], 5, ['maxFileSize' => 5]],
99+
[['maxFileSize' => 10], 20, ['maxFileSize' => 10]],
100+
[['maxFileSize' => 0], 10, ['maxFileSize' => 10]],
101+
];
102+
}
103+
104+
/**
105+
* @param array $initialConfig
106+
* @param int $maxFileSizeSupported
107+
* @param array $expectedPreparedConfig
108+
*/
109+
private function assertExpectedPreparedConfiguration(
110+
array $initialConfig,
111+
int $maxFileSizeSupported,
112+
array $expectedPreparedConfig
113+
) {
114+
$this->image->setData(array_merge_recursive(['config' => $initialConfig], $this->image->getData()));
115+
116+
$this->fileSize->expects($this->any())->method('getMaxFileSize')->willReturn($maxFileSizeSupported);
117+
118+
$this->image->prepare();
119+
120+
$actualRelevantPreparedConfig = array_intersect_key($this->image->getConfiguration(), $initialConfig);
121+
122+
$this->assertEquals(
123+
$expectedPreparedConfig,
124+
$actualRelevantPreparedConfig
125+
);
126+
}
127+
}

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/paypal/button.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ define([
6464
});
6565
});
6666

67+
afterEach(function () {
68+
try {
69+
injector.clean();
70+
injector.remove();
71+
} catch (e) {}
72+
});
73+
6774
afterAll(function (done) {
6875
tplElement.remove();
6976
registry.remove(component.integrationName);
77+
7078
done();
7179
});
7280

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer/cc-form.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ define([
5656
});
5757
});
5858

59+
afterEach(function () {
60+
try {
61+
injector.clean();
62+
injector.remove();
63+
} catch (e) {}
64+
});
65+
5966
it('Check if payment code and message container are restored after onActiveChange call.', function () {
6067
var expectedMessageContainer = braintreeCcForm.messageContainer,
6168
expectedCode = braintreeCcForm.code;

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer/paypal.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ define([
6464
});
6565
});
6666

67+
afterEach(function () {
68+
try {
69+
injector.clean();
70+
injector.remove();
71+
} catch (e) {}
72+
});
73+
6774
it('The PayPal::initAuthFlow throws an exception.', function () {
6875

6976
spyOn(additionalValidator, 'validate').and.returnValue(true);

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/base/js/product/list/columns/final-price.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ define([
2828
});
2929
});
3030

31+
afterEach(function () {
32+
try {
33+
injector.clean();
34+
injector.remove();
35+
} catch (e) {}
36+
});
37+
3138
describe('Magento_Catalog/js/product/list/columns/final-price', function () {
3239
describe('"getPrice" method', function () {
3340
it('Check returned value', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/base/js/product/list/columns/image.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ define([
3737
});
3838
});
3939

40+
afterEach(function () {
41+
try {
42+
injector.clean();
43+
injector.remove();
44+
} catch (e) {}
45+
});
46+
4047
describe('Magento_Catalog/js/product/list/columns/image', function () {
4148
var image = {
4249
url: 'url',

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/breadcrumbs.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ define([
4848
);
4949
});
5050

51+
afterEach(function () {
52+
try {
53+
injector.clean();
54+
injector.remove();
55+
} catch (e) {}
56+
});
57+
5158
describe('Magento_Catalog/js/product/breadcrumbs', function () {
5259
it('mixin is applied to Magento_Theme/js/view/breadcrumbs', function () {
5360
var breadcrumbMixins = defaultContext.config.config.mixins['Magento_Theme/js/view/breadcrumbs'];

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/storage/data-storage.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ define([
4444
});
4545
});
4646

47+
afterEach(function () {
48+
try {
49+
injector.clean();
50+
injector.remove();
51+
} catch (e) {}
52+
});
53+
4754
describe('Magento_Catalog/js/product/storage/data-storage', function () {
4855
describe('"initCustomerDataInvalidateListener" method', function () {
4956
it('check returned value', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/storage/ids-storage-compare.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ define([
2828
});
2929
});
3030

31+
afterEach(function () {
32+
try {
33+
injector.clean();
34+
injector.remove();
35+
} catch (e) {}
36+
});
37+
3138
describe('Magento_Catalog/js/product/storage/ids-storage-compare', function () {
3239
describe('"providerDataHandler" method', function () {
3340
it('check calls "prepareData" and "add" method', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/storage/ids-storage.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ define([
2222
});
2323
});
2424

25+
afterEach(function () {
26+
try {
27+
injector.clean();
28+
injector.remove();
29+
} catch (e) {}
30+
});
31+
2532
describe('Magento_Catalog/js/product/storage/ids-storage', function () {
2633
describe('"getDataFromLocalStorage" method', function () {
2734
it('check calls localStorage get method', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/storage/storage-service.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ define([
2929
});
3030
});
3131

32+
afterEach(function () {
33+
try {
34+
injector.clean();
35+
injector.remove();
36+
} catch (e) {}
37+
});
38+
3239
describe('Magento_Catalog/js/product/storage/storage-service', function () {
3340
var config = {
3441
namespace: 'namespace',

dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/storage-manager.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ define([
3636
});
3737
});
3838

39+
afterEach(function () {
40+
try {
41+
injector.clean();
42+
injector.remove();
43+
} catch (e) {}
44+
});
45+
3946
describe('Magento_Catalog/js/storage-manager', function () {
4047
describe('"initStorages" method', function () {
4148
beforeEach(function () {

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/redirect-on-success.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ define([
2727
});
2828
});
2929

30+
afterEach(function () {
31+
try {
32+
injector.clean();
33+
injector.remove();
34+
} catch (e) {}
35+
});
36+
3037
it('Checks if loader is called before redirect to success page.', function () {
3138
spyOn(window.location, 'replace').and.returnValue(false);
3239

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/cache.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ define([
3030
});
3131
});
3232

33+
afterEach(function () {
34+
try {
35+
injector.clean();
36+
injector.remove();
37+
} catch (e) {}
38+
});
39+
3340
describe('Magento_Checkout/js/model/cart/cache', function () {
3441
describe('Check the "get" method', function () {
3542
it('Check default call with "cart-data" key', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/estimate-service.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ define([
6565
});
6666
});
6767

68+
afterEach(function () {
69+
try {
70+
injector.clean();
71+
injector.remove();
72+
} catch (e) {}
73+
});
74+
6875
describe('Magento_Checkout/js/model/cart/estimate-service', function () {
6976

7077
it('test subscribe when billingAddress was changed for virtual quote', function () {

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ define([
8989
});
9090
});
9191

92+
afterEach(function () {
93+
try {
94+
injector.clean();
95+
injector.remove();
96+
} catch (e) {}
97+
});
98+
9299
describe('Magento_Checkout/js/model/cart/totals-processor/default', function () {
93100

94101
it('estimateTotals if data was cached', function () {

0 commit comments

Comments
 (0)