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

Commit 74a70a0

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#13735: [Forwardport] Fix adding values to system variable collection (by @nmalevanec) - magento/magento2#13733: [Forwardport] Refactoring: remove unuseful temporary variable (by @nmalevanec) - magento/magento2#13731: [Forwardport] Display a more meaningful error message in case of misspelt module name (by @nmalevanec) - magento/magento2#13727: [Forwardport] Show maintenance IP-address without commas (by @nmalevanec) - magento/magento2#13729: [Forwardport] Update StorageInterface.php (by @nmalevanec) - magento/magento2#13635: [Forwardport] magento/magento2#13498 issue #13497 - Method getUrl in Magento\Catalog\Model\Product\Attribute\Frontend\Image (by @nmalevanec) - magento/magento2#13686: #13685: Replaced .size() with .length to be compatible with jQuery 3.* (by @kirmorozov) - magento-engcom/magento2ce#1203: Report error csv doesn't work when trying to import a csv file with semicolon delimiter[forwardport]. (by @nmalevanec) - magento/magento2#13361: Fix URL passed to static.php in PHP in-development server (by @nieltg) Fixed GitHub Issues: - magento/magento2#5015: Report error csv doesn't work when trying to import a csv file with semicolon delimiter (reported by @agoeurysky) has been fixed in magento-engcom/magento2ce#1203 by @nmalevanec in 2.3-develop branch Related commits: 1. 7c03614
2 parents e14f93b + 2712100 commit 74a70a0

File tree

15 files changed

+184
-40
lines changed

15 files changed

+184
-40
lines changed

app/code/Magento/Backend/Model/Auth/StorageInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface StorageInterface
2323
public function processLogin();
2424

2525
/**
26-
* Perform login specific actions
26+
* Perform logout specific actions
2727
*
2828
* @return $this
2929
* @abstract

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ public function execute()
127127
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
128128
}
129129

130-
$data['general'] = $this->getRequest()->getPostValue();
131-
$categoryPostData = $data['general'];
130+
$categoryPostData = $this->getRequest()->getPostValue();
132131

133132
$isNewCategory = !isset($categoryPostData['entity_id']);
134133
$categoryPostData = $this->stringToBoolConverting($categoryPostData);

app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@
99
*
1010
* @author Magento Core Team <[email protected]>
1111
*/
12+
1213
namespace Magento\Catalog\Model\Product\Attribute\Frontend;
1314

14-
class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
15+
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
16+
use Magento\Framework\UrlInterface;
17+
use Magento\Store\Model\StoreManagerInterface;
18+
19+
class Image extends AbstractFrontend
1520
{
1621
/**
1722
* Store manager
1823
*
19-
* @var \Magento\Store\Model\StoreManagerInterface
24+
* @var StoreManagerInterface
2025
*/
2126
protected $_storeManager;
2227

2328
/**
2429
* Construct
2530
*
26-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
31+
* @param StoreManagerInterface $storeManager
2732
*/
28-
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
33+
public function __construct(StoreManagerInterface $storeManager)
2934
{
3035
$this->_storeManager = $storeManager;
3136
}
@@ -42,9 +47,9 @@ public function getUrl($product)
4247
$image = $product->getData($this->getAttribute()->getAttributeCode());
4348
$url = false;
4449
if (!empty($image)) {
45-
$url = $this->_storeManager->getStore($product->getStore())
46-
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
47-
. 'catalog/product/' . $image;
50+
$url = $this->_storeManager
51+
->getStore($product->getStore())
52+
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . ltrim($image, '/');
4853
}
4954
return $url;
5055
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Frontend/ImageTest.php

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,71 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Frontend;
78

9+
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\Product\Attribute\Frontend\Image;
11+
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
812
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Store\Model\Store;
14+
use Magento\Store\Model\StoreManagerInterface;
15+
use PHPUnit\Framework\TestCase;
916

10-
class ImageTest extends \PHPUnit\Framework\TestCase
17+
class ImageTest extends TestCase
1118
{
1219
/**
13-
* @var \Magento\Catalog\Model\Product\Attribute\Frontend\Image
20+
* @var Image
1421
*/
1522
private $model;
1623

17-
public function testGetUrl()
24+
/**
25+
* @dataProvider getUrlDataProvider
26+
* @param string $expectedImage
27+
* @param string $productImage
28+
*/
29+
public function testGetUrl(string $expectedImage, string $productImage)
30+
{
31+
$this->assertEquals($expectedImage, $this->model->getUrl($this->getMockedProduct($productImage)));
32+
}
33+
34+
/**
35+
* Data provider for testGetUrl
36+
*
37+
* @return array
38+
*/
39+
public function getUrlDataProvider(): array
1840
{
19-
$this->assertEquals('catalog/product/img.jpg', $this->model->getUrl($this->getMockedProduct()));
41+
return [
42+
['catalog/product/img.jpg', 'img.jpg'],
43+
['catalog/product/img.jpg', '/img.jpg'],
44+
];
2045
}
2146

2247
protected function setUp()
2348
{
2449
$helper = new ObjectManager($this);
2550
$this->model = $helper->getObject(
26-
\Magento\Catalog\Model\Product\Attribute\Frontend\Image::class,
51+
Image::class,
2752
['storeManager' => $this->getMockedStoreManager()]
2853
);
2954
$this->model->setAttribute($this->getMockedAttribute());
3055
}
3156

3257
/**
33-
* @return \Magento\Catalog\Model\Product
58+
* @param string $productImage
59+
* @return Product
3460
*/
35-
private function getMockedProduct()
61+
private function getMockedProduct(string $productImage): Product
3662
{
37-
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class);
63+
$mockBuilder = $this->getMockBuilder(Product::class);
3864
$mock = $mockBuilder->setMethods(['getData', 'getStore', '__wakeup'])
3965
->disableOriginalConstructor()
4066
->getMock();
4167

4268
$mock->expects($this->any())
4369
->method('getData')
44-
->will($this->returnValue('img.jpg'));
70+
->will($this->returnValue($productImage));
4571

4672
$mock->expects($this->any())
4773
->method('getStore');
@@ -50,13 +76,13 @@ private function getMockedProduct()
5076
}
5177

5278
/**
53-
* @return \Magento\Store\Model\StoreManagerInterface
79+
* @return StoreManagerInterface
5480
*/
55-
private function getMockedStoreManager()
81+
private function getMockedStoreManager(): StoreManagerInterface
5682
{
5783
$mockedStore = $this->getMockedStore();
5884

59-
$mockBuilder = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class);
85+
$mockBuilder = $this->getMockBuilder(StoreManagerInterface::class);
6086
$mock = $mockBuilder->setMethods(['getStore'])
6187
->disableOriginalConstructor()
6288
->getMockForAbstractClass();
@@ -69,11 +95,11 @@ private function getMockedStoreManager()
6995
}
7096

7197
/**
72-
* @return \Magento\Store\Model\Store
98+
* @return Store
7399
*/
74-
private function getMockedStore()
100+
private function getMockedStore(): Store
75101
{
76-
$mockBuilder = $this->getMockBuilder(\Magento\Store\Model\Store::class);
102+
$mockBuilder = $this->getMockBuilder(Store::class);
77103
$mock = $mockBuilder->setMethods(['getBaseUrl', '__wakeup'])
78104
->disableOriginalConstructor()
79105
->getMockForAbstractClass();
@@ -86,11 +112,11 @@ private function getMockedStore()
86112
}
87113

88114
/**
89-
* @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
115+
* @return AbstractAttribute
90116
*/
91-
private function getMockedAttribute()
117+
private function getMockedAttribute(): AbstractAttribute
92118
{
93-
$mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
119+
$mockBuilder = $this->getMockBuilder(AbstractAttribute::class);
94120
$mockBuilder->setMethods(['getAttributeCode', '__wakeup']);
95121
$mockBuilder->disableOriginalConstructor();
96122
$mock = $mockBuilder->getMockForAbstractClass();

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ define([
9090
$title,
9191
$corner;
9292

93-
if (!$element.size()) {
93+
if (!$element.length) {
9494
$element = $('<div class="' +
9595
$widget.options.tooltipClass +
9696
'"><div class="image"></div><div class="title"></div><div class="corner"></div></div>'
@@ -810,7 +810,7 @@ define([
810810
$widget._Rewind(controls);
811811

812812
// done if nothing selected
813-
if (selected.size() <= 0) {
813+
if (selected.length <= 0) {
814814
return;
815815
}
816816

@@ -820,7 +820,7 @@ define([
820820
id = $this.attr('attribute-id'),
821821
products = $widget._CalcProducts(id);
822822

823-
if (selected.size() === 1 && selected.first().attr('attribute-id') === id) {
823+
if (selected.length === 1 && selected.first().attr('attribute-id') === id) {
824824
return;
825825
}
826826

@@ -1016,7 +1016,7 @@ define([
10161016
_EnableProductMediaLoader: function ($this) {
10171017
var $widget = this;
10181018

1019-
if ($('body.catalog-product-view').size() > 0) {
1019+
if ($('body.catalog-product-view').length > 0) {
10201020
$this.parents('.column.main').find('.photo.image')
10211021
.addClass($widget.options.classes.loader);
10221022
} else {
@@ -1035,7 +1035,7 @@ define([
10351035
_DisableProductMediaLoader: function ($this) {
10361036
var $widget = this;
10371037

1038-
if ($('body.catalog-product-view').size() > 0) {
1038+
if ($('body.catalog-product-view').length > 0) {
10391039
$this.parents('.column.main').find('.photo.image')
10401040
.removeClass($widget.options.classes.loader);
10411041
} else {

app/code/Magento/Variable/Model/ResourceModel/Variable/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function addValuesToResult()
6262
$this->getSelect()->join(
6363
['value_table' => $this->getTable('variable_value')],
6464
'value_table.variable_id = main_table.variable_id',
65-
['value_table.value']
65+
['value_table.plain_value', 'value_table.html_value']
6666
);
6767
$this->addFieldToFilter('value_table.store_id', ['eq' => $this->getStoreId()]);
6868
return $this;
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/***
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Variable\Test\Unit\Model\ResourceModel\Variable;
8+
9+
use Magento\Framework\DB\Adapter\AdapterInterface;
10+
use Magento\Framework\DB\Select;
11+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Variable\Model\ResourceModel\Variable\Collection;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Provide tests for Variable collection class.
18+
*/
19+
class CollectionTest extends TestCase
20+
{
21+
/**
22+
* Test Collection::addValuesToResult() build correct query.
23+
*
24+
* @return void
25+
*/
26+
public function testAddValuesToResult()
27+
{
28+
$mainTableName = 'testMainTable';
29+
$tableName = 'variable_value';
30+
$field = 'value_table.store_id';
31+
32+
$select = $this->getMockBuilder(Select::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
$select->expects($this->once())
36+
->method('from')
37+
->with($this->identicalTo(['main_table' => $mainTableName]))
38+
->willReturnSelf();
39+
$select->expects($this->once())
40+
->method('join')
41+
->with(
42+
$this->identicalTo(['value_table' => $tableName]),
43+
$this->identicalTo('value_table.variable_id = main_table.variable_id'),
44+
$this->identicalTo(['value_table.plain_value', 'value_table.html_value'])
45+
)->willReturnSelf();
46+
47+
$connection = $this->getMockBuilder(AdapterInterface::class)
48+
->disableOriginalConstructor()
49+
->setMethods(['select', 'prepareSqlCondition', 'quoteIdentifier'])
50+
->getMockForAbstractClass();
51+
$connection->expects($this->any())
52+
->method('select')
53+
->willReturn($select);
54+
$connection->expects($this->once())
55+
->method('quoteIdentifier')
56+
->with($this->identicalTo($field))
57+
->willReturn($field);
58+
$connection->expects($this->once())
59+
->method('prepareSqlCondition')
60+
->with(
61+
$this->identicalTo($field),
62+
$this->identicalTo(['eq' => 0])
63+
)->willReturn('testResultCondition');
64+
65+
$resource = $this->getMockBuilder(AbstractDb::class)
66+
->setMethods(['getTable', 'getMainTable', 'getConnection'])
67+
->disableOriginalConstructor()
68+
->getMockForAbstractClass();
69+
$resource->expects($this->any())
70+
->method('getConnection')
71+
->willReturn($connection);
72+
$resource->expects($this->once())
73+
->method('getMainTable')
74+
->willReturn('testMainTable');
75+
$resource->expects($this->exactly(2))
76+
->method('getTable')
77+
->withConsecutive(
78+
[$mainTableName],
79+
[$tableName]
80+
)->willReturnOnConsecutiveCalls(
81+
$mainTableName,
82+
$tableName
83+
);
84+
85+
$objectManager = new ObjectManager($this);
86+
$collection = $objectManager->getObject(
87+
Collection::class,
88+
[
89+
'resource' => $resource,
90+
]
91+
);
92+
$this->assertInstanceOf(Collection::class, $collection->addValuesToResult());
93+
}
94+
}

lib/internal/Magento/Framework/Module/Dir.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public function getDir($moduleName, $type = '')
4646
{
4747
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
4848

49+
// An empty $type means it's getting the directory of the module itself.
50+
if (empty($type) && !isset($path)) {
51+
// Note: do not throw \LogicException, as it would break backwards-compatibility.
52+
throw new \InvalidArgumentException("Module '$moduleName' is not correctly registered.");
53+
}
54+
4955
if ($type) {
5056
if (!in_array($type, [
5157
self::MODULE_ETC_DIR,

lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,17 @@ public function testGetDirModuleSubDirUnknown()
6969

7070
$this->_model->getDir('Test_Module', 'unknown');
7171
}
72+
73+
/**
74+
* @expectedException \InvalidArgumentException
75+
* @expectedExceptionMessage Module 'Test Module' is not correctly registered.
76+
*/
77+
public function testGetDirModuleIncorrectlyRegistered()
78+
{
79+
$this->moduleRegistryMock->expects($this->once())
80+
->method('getPath')
81+
->with($this->identicalTo(ComponentRegistrar::MODULE), $this->identicalTo('Test Module'))
82+
->willReturn(null);
83+
$this->_model->getDir('Test Module');
84+
}
7285
}

phpserver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For more informations about the installation process using the CLI, you can cons
3131

3232
### How to run Magento
3333

34-
Example usage: ```php -S 127.0.0.1:8082 -t ./pub/ ./phpserver/router.php```
34+
Example usage: ```php -S 127.0.0.1:8082 -t ./pub/ ../phpserver/router.php```
3535

3636
### What exactly the script does
3737

phpserver/router.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
} else {
104104
$debug('file does not exist');
105105
if (strpos($route, 'static/') === 0) {
106+
$route = preg_replace('#static/#', '', $route, 1);
106107
$_GET['resource'] = $route;
107108
$debug("static: $route");
108109
include($magentoPackagePubDir.'/static.php');

setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9393
if (!empty($addresses)) {
9494
$this->maintenanceMode->setAddresses(implode(',', $addresses));
9595
$output->writeln(
96-
'<info>Set exempt IP-addresses: ' . implode(', ', $this->maintenanceMode->getAddressInfo()) .
96+
'<info>Set exempt IP-addresses: ' . implode(' ', $this->maintenanceMode->getAddressInfo()) .
9797
'</info>'
9898
);
9999
}

0 commit comments

Comments
 (0)