Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #13735: [Forwardport] Fix adding values to system variable collection (by @nmalevanec)
 - #13733: [Forwardport] Refactoring: remove unuseful temporary variable (by @nmalevanec)
 - #13731: [Forwardport] Display a more meaningful error message in case of misspelt module name (by @nmalevanec)
 - #13727: [Forwardport] Show maintenance IP-address without commas (by @nmalevanec)
 - #13729: [Forwardport] Update StorageInterface.php (by @nmalevanec)
 - #13635: [Forwardport] #13498 issue #13497 - Method getUrl in Magento\Catalog\Model\Product\Attribute\Frontend\Image (by @nmalevanec)
 - #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)
 - #13361: Fix URL passed to static.php in PHP in-development server (by @nieltg)


Fixed GitHub Issues:
 - #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
  • Loading branch information
magento-engcom-team authored Feb 21, 2018
2 parents e14f93b + 2712100 commit 74a70a0
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Model/Auth/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface StorageInterface
public function processLogin();

/**
* Perform login specific actions
* Perform logout specific actions
*
* @return $this
* @abstract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ public function execute()
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
}

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

$isNewCategory = !isset($categoryPostData['entity_id']);
$categoryPostData = $this->stringToBoolConverting($categoryPostData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@
*
* @author Magento Core Team <core@magentocommerce.com>
*/

namespace Magento\Catalog\Model\Product\Attribute\Frontend;

class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;

class Image extends AbstractFrontend
{
/**
* Store manager
*
* @var \Magento\Store\Model\StoreManagerInterface
* @var StoreManagerInterface
*/
protected $_storeManager;

/**
* Construct
*
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param StoreManagerInterface $storeManager
*/
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
public function __construct(StoreManagerInterface $storeManager)
{
$this->_storeManager = $storeManager;
}
Expand All @@ -42,9 +47,9 @@ public function getUrl($product)
$image = $product->getData($this->getAttribute()->getAttributeCode());
$url = false;
if (!empty($image)) {
$url = $this->_storeManager->getStore($product->getStore())
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
. 'catalog/product/' . $image;
$url = $this->_storeManager
->getStore($product->getStore())
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . ltrim($image, '/');
}
return $url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,71 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Frontend;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Frontend\Image;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use PHPUnit\Framework\TestCase;

class ImageTest extends \PHPUnit\Framework\TestCase
class ImageTest extends TestCase
{
/**
* @var \Magento\Catalog\Model\Product\Attribute\Frontend\Image
* @var Image
*/
private $model;

public function testGetUrl()
/**
* @dataProvider getUrlDataProvider
* @param string $expectedImage
* @param string $productImage
*/
public function testGetUrl(string $expectedImage, string $productImage)
{
$this->assertEquals($expectedImage, $this->model->getUrl($this->getMockedProduct($productImage)));
}

/**
* Data provider for testGetUrl
*
* @return array
*/
public function getUrlDataProvider(): array
{
$this->assertEquals('catalog/product/img.jpg', $this->model->getUrl($this->getMockedProduct()));
return [
['catalog/product/img.jpg', 'img.jpg'],
['catalog/product/img.jpg', '/img.jpg'],
];
}

protected function setUp()
{
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
\Magento\Catalog\Model\Product\Attribute\Frontend\Image::class,
Image::class,
['storeManager' => $this->getMockedStoreManager()]
);
$this->model->setAttribute($this->getMockedAttribute());
}

/**
* @return \Magento\Catalog\Model\Product
* @param string $productImage
* @return Product
*/
private function getMockedProduct()
private function getMockedProduct(string $productImage): Product
{
$mockBuilder = $this->getMockBuilder(\Magento\Catalog\Model\Product::class);
$mockBuilder = $this->getMockBuilder(Product::class);
$mock = $mockBuilder->setMethods(['getData', 'getStore', '__wakeup'])
->disableOriginalConstructor()
->getMock();

$mock->expects($this->any())
->method('getData')
->will($this->returnValue('img.jpg'));
->will($this->returnValue($productImage));

$mock->expects($this->any())
->method('getStore');
Expand All @@ -50,13 +76,13 @@ private function getMockedProduct()
}

/**
* @return \Magento\Store\Model\StoreManagerInterface
* @return StoreManagerInterface
*/
private function getMockedStoreManager()
private function getMockedStoreManager(): StoreManagerInterface
{
$mockedStore = $this->getMockedStore();

$mockBuilder = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class);
$mockBuilder = $this->getMockBuilder(StoreManagerInterface::class);
$mock = $mockBuilder->setMethods(['getStore'])
->disableOriginalConstructor()
->getMockForAbstractClass();
Expand All @@ -69,11 +95,11 @@ private function getMockedStoreManager()
}

/**
* @return \Magento\Store\Model\Store
* @return Store
*/
private function getMockedStore()
private function getMockedStore(): Store
{
$mockBuilder = $this->getMockBuilder(\Magento\Store\Model\Store::class);
$mockBuilder = $this->getMockBuilder(Store::class);
$mock = $mockBuilder->setMethods(['getBaseUrl', '__wakeup'])
->disableOriginalConstructor()
->getMockForAbstractClass();
Expand All @@ -86,11 +112,11 @@ private function getMockedStore()
}

/**
* @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
* @return AbstractAttribute
*/
private function getMockedAttribute()
private function getMockedAttribute(): AbstractAttribute
{
$mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
$mockBuilder = $this->getMockBuilder(AbstractAttribute::class);
$mockBuilder->setMethods(['getAttributeCode', '__wakeup']);
$mockBuilder->disableOriginalConstructor();
$mock = $mockBuilder->getMockForAbstractClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ define([
$title,
$corner;

if (!$element.size()) {
if (!$element.length) {
$element = $('<div class="' +
$widget.options.tooltipClass +
'"><div class="image"></div><div class="title"></div><div class="corner"></div></div>'
Expand Down Expand Up @@ -810,7 +810,7 @@ define([
$widget._Rewind(controls);

// done if nothing selected
if (selected.size() <= 0) {
if (selected.length <= 0) {
return;
}

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

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

Expand Down Expand Up @@ -1016,7 +1016,7 @@ define([
_EnableProductMediaLoader: function ($this) {
var $widget = this;

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

if ($('body.catalog-product-view').size() > 0) {
if ($('body.catalog-product-view').length > 0) {
$this.parents('.column.main').find('.photo.image')
.removeClass($widget.options.classes.loader);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function addValuesToResult()
$this->getSelect()->join(
['value_table' => $this->getTable('variable_value')],
'value_table.variable_id = main_table.variable_id',
['value_table.value']
['value_table.plain_value', 'value_table.html_value']
);
$this->addFieldToFilter('value_table.store_id', ['eq' => $this->getStoreId()]);
return $this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/***
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Variable\Test\Unit\Model\ResourceModel\Variable;

use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Variable\Model\ResourceModel\Variable\Collection;
use PHPUnit\Framework\TestCase;

/**
* Provide tests for Variable collection class.
*/
class CollectionTest extends TestCase
{
/**
* Test Collection::addValuesToResult() build correct query.
*
* @return void
*/
public function testAddValuesToResult()
{
$mainTableName = 'testMainTable';
$tableName = 'variable_value';
$field = 'value_table.store_id';

$select = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$select->expects($this->once())
->method('from')
->with($this->identicalTo(['main_table' => $mainTableName]))
->willReturnSelf();
$select->expects($this->once())
->method('join')
->with(
$this->identicalTo(['value_table' => $tableName]),
$this->identicalTo('value_table.variable_id = main_table.variable_id'),
$this->identicalTo(['value_table.plain_value', 'value_table.html_value'])
)->willReturnSelf();

$connection = $this->getMockBuilder(AdapterInterface::class)
->disableOriginalConstructor()
->setMethods(['select', 'prepareSqlCondition', 'quoteIdentifier'])
->getMockForAbstractClass();
$connection->expects($this->any())
->method('select')
->willReturn($select);
$connection->expects($this->once())
->method('quoteIdentifier')
->with($this->identicalTo($field))
->willReturn($field);
$connection->expects($this->once())
->method('prepareSqlCondition')
->with(
$this->identicalTo($field),
$this->identicalTo(['eq' => 0])
)->willReturn('testResultCondition');

$resource = $this->getMockBuilder(AbstractDb::class)
->setMethods(['getTable', 'getMainTable', 'getConnection'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$resource->expects($this->any())
->method('getConnection')
->willReturn($connection);
$resource->expects($this->once())
->method('getMainTable')
->willReturn('testMainTable');
$resource->expects($this->exactly(2))
->method('getTable')
->withConsecutive(
[$mainTableName],
[$tableName]
)->willReturnOnConsecutiveCalls(
$mainTableName,
$tableName
);

$objectManager = new ObjectManager($this);
$collection = $objectManager->getObject(
Collection::class,
[
'resource' => $resource,
]
);
$this->assertInstanceOf(Collection::class, $collection->addValuesToResult());
}
}
6 changes: 6 additions & 0 deletions lib/internal/Magento/Framework/Module/Dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public function getDir($moduleName, $type = '')
{
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);

// An empty $type means it's getting the directory of the module itself.
if (empty($type) && !isset($path)) {
// Note: do not throw \LogicException, as it would break backwards-compatibility.
throw new \InvalidArgumentException("Module '$moduleName' is not correctly registered.");
}

if ($type) {
if (!in_array($type, [
self::MODULE_ETC_DIR,
Expand Down
13 changes: 13 additions & 0 deletions lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,17 @@ public function testGetDirModuleSubDirUnknown()

$this->_model->getDir('Test_Module', 'unknown');
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Module 'Test Module' is not correctly registered.
*/
public function testGetDirModuleIncorrectlyRegistered()
{
$this->moduleRegistryMock->expects($this->once())
->method('getPath')
->with($this->identicalTo(ComponentRegistrar::MODULE), $this->identicalTo('Test Module'))
->willReturn(null);
$this->_model->getDir('Test Module');
}
}
2 changes: 1 addition & 1 deletion phpserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For more informations about the installation process using the CLI, you can cons

### How to run Magento

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

### What exactly the script does

Expand Down
1 change: 1 addition & 0 deletions phpserver/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
} else {
$debug('file does not exist');
if (strpos($route, 'static/') === 0) {
$route = preg_replace('#static/#', '', $route, 1);
$_GET['resource'] = $route;
$debug("static: $route");
include($magentoPackagePubDir.'/static.php');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!empty($addresses)) {
$this->maintenanceMode->setAddresses(implode(',', $addresses));
$output->writeln(
'<info>Set exempt IP-addresses: ' . implode(', ', $this->maintenanceMode->getAddressInfo()) .
'<info>Set exempt IP-addresses: ' . implode(' ', $this->maintenanceMode->getAddressInfo()) .
'</info>'
);
}
Expand Down
Loading

0 comments on commit 74a70a0

Please sign in to comment.