Skip to content

Commit 57f4ad2

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #13783: [Forwardport] Add option to add IP address to existing list + add test (by @serhii-balko) - #13818: [Forwardport] Cast handling fee to float (by @serhii-balko) - #13819: [Forwardport] Fix bug Magento 2.2.2 password reset strength meter #13429 (by @serhii-balko) - #13785: [Forwardport] Remove forced setting of cache_lifetime to false in constructor and set default cache_lifetime to 3600 (by @nmalevanec) - #13786: [Forwardport] Add ObserverInterface to the api (by @nmalevanec) - #13788: [Forwardport] Add RewriteBase directive template in .htaccess file into pub/static folder (by @nmalevanec) - #13795: [Forwardport] Fixes #12791 - Use a selector to only select the correct tax rate sel (by @nmalevanec) - #13792: [Forwardport] Ensure DeploymentConfig Reader always returns an array (by @nmalevanec) - #13794: [Forwardport] Typo (address not addres) (by @nmalevanec) - #13741: [Forwardport] Add MagentoStyle as Console Input/output helper object to allow easier access to io helpers in symfony/console (by @nmalevanec) - #13439: [2.3] Product image builder - Override attributes when builder used multiple times (by @ihor-sviziev) - #13687: Change the way the minify_exclude configurations can be used. (by @hostep) Fixed GitHub Issues: - #13429: Magento 2.2.2 password reset strength meter (reported by @zukovasmartynas) has been fixed in #13819 by @serhii-balko in 2.3-develop branch Related commits: 1. 99b32cf 2. fd5e0b5 - #13595: loadCache for Block Magento\Theme\Block\Html\Footer dont work (reported by @larsroettig) has been fixed in #13785 by @nmalevanec in 2.3-develop branch Related commits: 1. 53c7321 2. 2407845 - #12791: Customer & Product Tax class wrongly styled (reported by @duckchip) has been fixed in #13795 by @nmalevanec in 2.3-develop branch Related commits: 1. 37a3794 - #11577: TinyMCE (WYSIWYG) doesn't work in admin when JS minify is enabled (reported by @jordy2607) has been fixed in #13687 by @hostep in 2.3-develop branch Related commits: 1. d1f1252
2 parents ddf6862 + 82c1f32 commit 57f4ad2

File tree

23 files changed

+1356
-98
lines changed

23 files changed

+1356
-98
lines changed

app/code/Magento/Catalog/Block/Product/ImageBuilder.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Block\Product;
77

88
use Magento\Catalog\Helper\ImageFactory as HelperFactory;
9+
use Magento\Catalog\Model\Product;
910
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
1011

1112
class ImageBuilder
@@ -21,7 +22,7 @@ class ImageBuilder
2122
protected $helperFactory;
2223

2324
/**
24-
* @var \Magento\Catalog\Model\Product
25+
* @var Product
2526
*/
2627
protected $product;
2728

@@ -50,10 +51,10 @@ public function __construct(
5051
/**
5152
* Set product
5253
*
53-
* @param \Magento\Catalog\Model\Product $product
54+
* @param Product $product
5455
* @return $this
5556
*/
56-
public function setProduct(\Magento\Catalog\Model\Product $product)
57+
public function setProduct(Product $product)
5758
{
5859
$this->product = $product;
5960
return $this;
@@ -79,9 +80,7 @@ public function setImageId($imageId)
7980
*/
8081
public function setAttributes(array $attributes)
8182
{
82-
if ($attributes) {
83-
$this->attributes = $attributes;
84-
}
83+
$this->attributes = $attributes;
8584
return $this;
8685
}
8786

app/code/Magento/Catalog/Test/Unit/Block/Product/ImageBuilderTest.php

Lines changed: 172 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,43 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Product;
77

8+
use Magento\Catalog\Block\Product\ImageBuilder;
9+
use Magento\Catalog\Block\Product\ImageFactory;
10+
use Magento\Catalog\Helper\Image;
11+
use Magento\Catalog\Model\Product;
12+
813
class ImageBuilderTest extends \PHPUnit\Framework\TestCase
914
{
1015
/**
11-
* @var \Magento\Catalog\Block\Product\ImageBuilder
16+
* @var ImageBuilder
1217
*/
13-
protected $model;
18+
private $model;
1419

1520
/**
1621
* @var \Magento\Catalog\Helper\ImageFactory|\PHPUnit_Framework_MockObject_MockObject
1722
*/
18-
protected $helperFactory;
23+
private $helperFactory;
1924

2025
/**
21-
* @var \Magento\Catalog\Block\Product\ImageFactory|\PHPUnit_Framework_MockObject_MockObject
26+
* @var ImageFactory|\PHPUnit_Framework_MockObject_MockObject
2227
*/
23-
protected $imageFactory;
28+
private $imageFactory;
2429

2530
protected function setUp()
2631
{
27-
$this->helperFactory = $this->getMockBuilder(\Magento\Catalog\Helper\ImageFactory::class)
28-
->disableOriginalConstructor()
29-
->setMethods(['create'])
30-
->getMock();
31-
32-
$this->imageFactory = $this->getMockBuilder(\Magento\Catalog\Block\Product\ImageFactory::class)
33-
->disableOriginalConstructor()
34-
->setMethods(['create'])
35-
->getMock();
36-
37-
$this->model = new \Magento\Catalog\Block\Product\ImageBuilder(
38-
$this->helperFactory,
39-
$this->imageFactory
40-
);
32+
$this->helperFactory = $this->createPartialMock(\Magento\Catalog\Helper\ImageFactory::class, ['create']);
33+
34+
$this->imageFactory = $this->createPartialMock(ImageFactory::class, ['create']);
35+
36+
$this->model = new ImageBuilder($this->helperFactory, $this->imageFactory);
4137
}
4238

4339
public function testSetProduct()
4440
{
45-
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
46-
->disableOriginalConstructor()
47-
->getMock();
41+
$productMock = $this->createMock(Product::class);
4842

4943
$this->assertInstanceOf(
50-
\Magento\Catalog\Block\Product\ImageBuilder::class,
44+
ImageBuilder::class,
5145
$this->model->setProduct($productMock)
5246
);
5347
}
@@ -57,7 +51,7 @@ public function testSetImageId()
5751
$imageId = 'test_image_id';
5852

5953
$this->assertInstanceOf(
60-
\Magento\Catalog\Block\Product\ImageBuilder::class,
54+
ImageBuilder::class,
6155
$this->model->setImageId($imageId)
6256
);
6357
}
@@ -68,7 +62,7 @@ public function testSetAttributes()
6862
'name' => 'value',
6963
];
7064
$this->assertInstanceOf(
71-
\Magento\Catalog\Block\Product\ImageBuilder::class,
65+
ImageBuilder::class,
7266
$this->model->setAttributes($attributes)
7367
);
7468
}
@@ -81,13 +75,9 @@ public function testCreate($data, $expected)
8175
{
8276
$imageId = 'test_image_id';
8377

84-
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
85-
->disableOriginalConstructor()
86-
->getMock();
78+
$productMock = $this->createMock(Product::class);
8779

88-
$helperMock = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
89-
->disableOriginalConstructor()
90-
->getMock();
80+
$helperMock = $this->createMock(Image::class);
9181
$helperMock->expects($this->once())
9282
->method('init')
9383
->with($productMock, $imageId)
@@ -116,9 +106,7 @@ public function testCreate($data, $expected)
116106
->method('create')
117107
->willReturn($helperMock);
118108

119-
$imageMock = $this->getMockBuilder(\Magento\Catalog\Block\Product\Image::class)
120-
->disableOriginalConstructor()
121-
->getMock();
109+
$imageMock = $this->createMock(\Magento\Catalog\Block\Product\Image::class);
122110

123111
$this->imageFactory->expects($this->once())
124112
->method('create')
@@ -131,61 +119,173 @@ public function testCreate($data, $expected)
131119
$this->assertInstanceOf(\Magento\Catalog\Block\Product\Image::class, $this->model->create());
132120
}
133121

122+
/**
123+
* Check if custom attributes will be overridden when builder used few times
124+
* @param array $data
125+
* @dataProvider createMultipleCallsDataProvider
126+
*/
127+
public function testCreateMultipleCalls($data)
128+
{
129+
list ($firstCall, $secondCall) = array_values($data);
130+
131+
$imageId = 'test_image_id';
132+
133+
$productMock = $this->createMock(Product::class);
134+
135+
$helperMock = $this->createMock(Image::class);
136+
$helperMock->expects($this->exactly(2))
137+
->method('init')
138+
->with($productMock, $imageId)
139+
->willReturnSelf();
140+
141+
$helperMock->expects($this->exactly(2))
142+
->method('getFrame')
143+
->willReturnOnConsecutiveCalls($firstCall['data']['frame'], $secondCall['data']['frame']);
144+
$helperMock->expects($this->exactly(2))
145+
->method('getUrl')
146+
->willReturnOnConsecutiveCalls($firstCall['data']['url'], $secondCall['data']['url']);
147+
$helperMock->expects($this->exactly(4))
148+
->method('getWidth')
149+
->willReturnOnConsecutiveCalls(
150+
$firstCall['data']['width'],
151+
$firstCall['data']['width'],
152+
$secondCall['data']['width'],
153+
$secondCall['data']['width']
154+
);
155+
$helperMock->expects($this->exactly(4))
156+
->method('getHeight')
157+
->willReturnOnConsecutiveCalls(
158+
$firstCall['data']['height'],
159+
$firstCall['data']['height'],
160+
$secondCall['data']['height'],
161+
$secondCall['data']['height']
162+
);
163+
$helperMock->expects($this->exactly(2))
164+
->method('getLabel')
165+
->willReturnOnConsecutiveCalls($firstCall['data']['label'], $secondCall['data']['label']);
166+
$helperMock->expects($this->exactly(2))
167+
->method('getResizedImageInfo')
168+
->willReturnOnConsecutiveCalls($firstCall['data']['imagesize'], $secondCall['data']['imagesize']);
169+
$this->helperFactory->expects($this->exactly(2))
170+
->method('create')
171+
->willReturn($helperMock);
172+
173+
$imageMock = $this->createMock(\Magento\Catalog\Block\Product\Image::class);
174+
175+
$this->imageFactory->expects($this->at(0))
176+
->method('create')
177+
->with($firstCall['expected'])
178+
->willReturn($imageMock);
179+
180+
$this->imageFactory->expects($this->at(1))
181+
->method('create')
182+
->with($secondCall['expected'])
183+
->willReturn($imageMock);
184+
185+
$this->model->setProduct($productMock);
186+
$this->model->setImageId($imageId);
187+
$this->model->setAttributes($firstCall['data']['custom_attributes']);
188+
189+
$this->assertInstanceOf(\Magento\Catalog\Block\Product\Image::class, $this->model->create());
190+
191+
$this->model->setProduct($productMock);
192+
$this->model->setImageId($imageId);
193+
$this->model->setAttributes($secondCall['data']['custom_attributes']);
194+
$this->assertInstanceOf(\Magento\Catalog\Block\Product\Image::class, $this->model->create());
195+
}
196+
197+
/**
198+
* @return array
199+
*/
200+
public function createDataProvider(): array
201+
{
202+
return [
203+
$this->getTestDataWithoutAttributes(),
204+
$this->getTestDataWithAttributes(),
205+
];
206+
}
207+
134208
/**
135209
* @return array
136210
*/
137-
public function createDataProvider()
211+
public function createMultipleCallsDataProvider(): array
138212
{
139213
return [
140214
[
215+
[
216+
'without_attributes' => $this->getTestDataWithoutAttributes(),
217+
'with_attributes' => $this->getTestDataWithAttributes(),
218+
],
219+
],
220+
[
221+
[
222+
'with_attributes' => $this->getTestDataWithAttributes(),
223+
'without_attributes' => $this->getTestDataWithoutAttributes(),
224+
],
225+
],
226+
];
227+
}
228+
229+
/**
230+
* @return array
231+
*/
232+
private function getTestDataWithoutAttributes(): array
233+
{
234+
return [
235+
'data' => [
236+
'frame' => 0,
237+
'url' => 'test_url_1',
238+
'width' => 100,
239+
'height' => 100,
240+
'label' => 'test_label',
241+
'custom_attributes' => [],
242+
'imagesize' => [100, 100],
243+
],
244+
'expected' => [
141245
'data' => [
142-
'frame' => 0,
143-
'url' => 'test_url_1',
246+
'template' => 'Magento_Catalog::product/image_with_borders.phtml',
247+
'image_url' => 'test_url_1',
144248
'width' => 100,
145249
'height' => 100,
146250
'label' => 'test_label',
147-
'custom_attributes' => [],
148-
'imagesize' => [100, 100],
251+
'ratio' => 1,
252+
'custom_attributes' => '',
253+
'resized_image_width' => 100,
254+
'resized_image_height' => 100,
149255
],
150-
'expected' => [
151-
'data' => [
152-
'template' => 'Magento_Catalog::product/image_with_borders.phtml',
153-
'image_url' => 'test_url_1',
154-
'width' => 100,
155-
'height' => 100,
156-
'label' => 'test_label',
157-
'ratio' => 1,
158-
'custom_attributes' => '',
159-
'resized_image_width' => 100,
160-
'resized_image_height' => 100,
161-
],
256+
],
257+
];
258+
}
259+
260+
/**
261+
* @return array
262+
*/
263+
private function getTestDataWithAttributes(): array
264+
{
265+
return [
266+
'data' => [
267+
'frame' => 1,
268+
'url' => 'test_url_2',
269+
'width' => 100,
270+
'height' => 50,
271+
'label' => 'test_label_2',
272+
'custom_attributes' => [
273+
'name_1' => 'value_1',
274+
'name_2' => 'value_2',
162275
],
276+
'imagesize' => [120, 70],
163277
],
164-
[
278+
'expected' => [
165279
'data' => [
166-
'frame' => 1,
167-
'url' => 'test_url_2',
280+
'template' => 'Magento_Catalog::product/image.phtml',
281+
'image_url' => 'test_url_2',
168282
'width' => 100,
169283
'height' => 50,
170284
'label' => 'test_label_2',
171-
'custom_attributes' => [
172-
'name_1' => 'value_1',
173-
'name_2' => 'value_2',
174-
],
175-
'imagesize' => [120, 70],
176-
],
177-
'expected' => [
178-
'data' => [
179-
'template' => 'Magento_Catalog::product/image.phtml',
180-
'image_url' => 'test_url_2',
181-
'width' => 100,
182-
'height' => 50,
183-
'label' => 'test_label_2',
184-
'ratio' => 0.5,
185-
'custom_attributes' => 'name_1="value_1" name_2="value_2"',
186-
'resized_image_width' => 120,
187-
'resized_image_height' => 70,
188-
],
285+
'ratio' => 0.5,
286+
'custom_attributes' => 'name_1="value_1" name_2="value_2"',
287+
'resized_image_width' => 120,
288+
'resized_image_height' => 70,
189289
],
190290
],
191291
];

app/code/Magento/Customer/etc/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<observer name="customer_address_before_save_viv_observer" instance="Magento\Customer\Observer\BeforeAddressSaveObserver" />
1111
</event>
1212
<event name="customer_address_save_after">
13-
<observer name="customer_addres_after_save_viv_observer" instance="Magento\Customer\Observer\AfterAddressSaveObserver" />
13+
<observer name="customer_address_after_save_viv_observer" instance="Magento\Customer\Observer\AfterAddressSaveObserver" />
1414
</event>
1515
<event name="sales_quote_save_after">
1616
<observer name="customer_visitor" instance="Magento\Customer\Observer\Visitor\BindQuoteCreateObserver" />

app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ define([
3131
this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element);
3232

3333
// We need to look outside the module for backward compatibility, since someone can already use the module.
34+
// @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the
35+
// newsletter email field or any other "email" field.
3436
this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
3537
this._bind();
3638
},
@@ -74,7 +76,9 @@ define([
7476
'password-not-equal-to-user-name': this.options.cache.email.val()
7577
});
7678

77-
if (password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
79+
// We should only perform this check in case there is an email field on screen
80+
if (this.options.cache.email.length &&
81+
password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
7882
displayScore = 1;
7983
} else {
8084
isValid = $.validator.validateSingleElement(this.options.cache.input);

0 commit comments

Comments
 (0)