Skip to content

Commit

Permalink
Merge pull request #1663 from magento-engcom/2.2-develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests

#11959 #11898 - Change NL PostCode Pattern by @osrecio
#11949 11868: "Add Products" button has been duplicated after the customer group was changed. by @nmalevanec
#11917 [BACKPORT 2.2] [TASK] Add resetPassword call to the webapi by @lewisvoncken
#11889 Save background color correctly in images. [backport 2.2] by @raumatbel
#11869 Resolve Error While Trying To Load Quote Item Collection Using Magent… by @neeta-wagento
#11858 #11697 Theme: Added html node to page xml root, cause validation error by @adrian-martinez-interactiv4
#11405 Allow setting of http response status code in a Redirection by @gabrielqs-redstage

Fixed Public Issues

#11898 Zip code Netherlands should allow zipcode without space
#11868 "Add Products" button has been duplicated after the customer group was changed
#8799 Image brackground
#8954 Error While Trying To Load Quote Item Collection Using Magento\Quote\Model\ResourceModel\QuoteItem\Collection::getItems()
#11697 Theme: Added html node to page xml root, cause validation error
#9028 You cannot set a 303 redirect response using a result factory
  • Loading branch information
Oleksii Korshenko authored Nov 4, 2017
2 parents fd715d7 + 88d5dfc commit 13a933a
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 29 deletions.
11 changes: 8 additions & 3 deletions app/code/Magento/Catalog/Model/ImageExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
*/
namespace Magento\Catalog\Model;

use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
use Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface;

class ImageExtractor implements \Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface
class ImageExtractor implements TypeDataExtractorInterface
{
/**
* Extract configuration data of images from the DOM structure
Expand All @@ -30,8 +31,11 @@ public function process(\DOMElement $mediaNode, $mediaParentTag)
if ($attribute->nodeType != XML_ELEMENT_NODE) {
continue;
}
if ($attribute->tagName == 'background') {
$attributeTagName = $attribute->tagName;
if ($attributeTagName === 'background') {
$nodeValue = $this->processImageBackground($attribute->nodeValue);
} elseif ($attributeTagName === 'width' || $attributeTagName === 'height') {
$nodeValue = intval($attribute->nodeValue);
} else {
$nodeValue = $attribute->nodeValue;
}
Expand All @@ -55,6 +59,7 @@ private function processImageBackground($backgroundString)
$backgroundArray = [];
if (preg_match($pattern, $backgroundString, $backgroundArray)) {
array_shift($backgroundArray);
$backgroundArray = array_map('intval', $backgroundArray);
}
return $backgroundArray;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp()
public function testProcess()
{
$expectedArray = include(__DIR__ . '/_files/converted_view.php');
$this->assertEquals($expectedArray, $this->model->process($this->getDomElement(), 'media'));
$this->assertSame($expectedArray, $this->model->process($this->getDomElement(), 'media'));
}

/**
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Customer/etc/webapi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/customers/resetPassword" method="POST">
<service class="Magento\Customer\Api\AccountManagementInterface" method="resetPassword"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/customers/:customerId/confirm" method="GET">
<service class="Magento\Customer\Api\AccountManagementInterface" method="getConfirmationStatus"/>
<resources>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Directory/etc/zip_codes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
</zip>
<zip countryCode="NL">
<codes>
<code id="pattern_1" active="true" example="1234 AB">^[0-9]{4}\s?[a-zA-Z]{2}$</code>
<code id="pattern_1" active="true" example="1234 AB/1234AB">^[1-9][0-9]{3}\s?[a-zA-Z]{2}$</code>
</codes>
</zip>
<zip countryCode="NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function _construct()
*/
public function getStoreId()
{
return (int)$this->_quote->getStoreId();
return (int)$this->_productCollectionFactory->create()->getStoreId();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ define([
}
});

var searchButton = new ControlButton(jQuery.mage.__('Add Products')),
var searchButtonId = 'add_products',
searchButton = new ControlButton(jQuery.mage.__('Add Products'), searchButtonId),
searchAreaId = this.getAreaId('search');
searchButton.onClick = function() {
$(searchAreaId).show();
Expand All @@ -74,7 +75,7 @@ define([

this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) {
proceed();
if ($(searchAreaId) && !$(searchAreaId).visible()) {
if ($(searchAreaId) && !$(searchAreaId).visible() && !$(searchButtonId)) {
this.addControlButton(searchButton);
}
});
Expand Down Expand Up @@ -1394,12 +1395,15 @@ define([
_label: '',
_node: null,

initialize: function(label){
initialize: function(label, id){
this._label = label;
this._node = new Element('button', {
'class': 'action-secondary action-add',
'type': 'button'
});
if (typeof id !== 'undefined') {
this._node.setAttribute('id', id)
}
},

onClick: function(){
Expand Down
18 changes: 13 additions & 5 deletions lib/internal/Magento/Framework/Controller/Result/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magento\Framework\App;
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
use Magento\Framework\Controller\AbstractResult;
use Magento\Framework\App\Response\RedirectInterface;
use Magento\Framework\UrlInterface;

/**
* In many cases controller actions may result in a redirect
Expand All @@ -18,13 +20,14 @@
*/
class Redirect extends AbstractResult
{

/**
* @var \Magento\Framework\App\Response\RedirectInterface
* @var RedirectInterface
*/
protected $redirect;

/**
* @var \Magento\Framework\UrlInterface
* @var UrlInterface
*/
protected $urlBuilder;

Expand All @@ -37,11 +40,11 @@ class Redirect extends AbstractResult
* Constructor
*
* @param App\Response\RedirectInterface $redirect
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param UrlInterface $urlBuilder
*/
public function __construct(
App\Response\RedirectInterface $redirect,
\Magento\Framework\UrlInterface $urlBuilder
UrlInterface $urlBuilder
) {
$this->redirect = $redirect;
$this->urlBuilder = $urlBuilder;
Expand Down Expand Up @@ -70,6 +73,7 @@ public function setRefererOrBaseUrl()
}

/**
* URL Setter
* @param string $url
* @return $this
*/
Expand Down Expand Up @@ -97,7 +101,11 @@ public function setPath($path, array $params = [])
*/
protected function render(HttpResponseInterface $response)
{
$response->setRedirect($this->url);
if (empty($this->httpResponseCode)) {
$response->setRedirect($this->url);
} else {
$response->setRedirect($this->url, $this->httpResponseCode);
}
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

namespace Magento\Framework\Controller\Test\Unit\Result;

use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
use \PHPUnit\Framework\TestCase;
use \Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
use \Magento\Framework\App\Response\RedirectInterface;
use \Magento\Framework\Controller\Result\Redirect;
use \Magento\Framework\UrlInterface;

class RedirectTest extends \PHPUnit\Framework\TestCase
class RedirectTest extends TestCase
{
/** @var \Magento\Framework\Controller\Result\Redirect */
protected $redirect;
Expand All @@ -28,9 +31,9 @@ class RedirectTest extends \PHPUnit\Framework\TestCase

protected function setUp()
{
$this->redirectInterface = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
$this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
$this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
$this->redirectInterface = $this->createMock(RedirectInterface::class);
$this->urlBuilder = $this->createMock(UrlInterface::class);
$this->urlInterface = $this->createMock(UrlInterface::class);
$this->response = $this->createMock(HttpResponseInterface::class);
$this->redirect = new Redirect($this->redirectInterface, $this->urlInterface);
}
Expand All @@ -39,7 +42,7 @@ public function testSetRefererUrl()
{
$this->redirectInterface->expects($this->once())->method('getRefererUrl');
$this->assertInstanceOf(
\Magento\Framework\Controller\Result\Redirect::class,
Redirect::class,
$this->redirect->setRefererUrl()
);
}
Expand All @@ -48,15 +51,15 @@ public function testSetRefererOrBaseUrl()
{
$this->redirectInterface->expects($this->once())->method('getRedirectUrl');
$this->assertInstanceOf(
\Magento\Framework\Controller\Result\Redirect::class,
Redirect::class,
$this->redirect->setRefererOrBaseUrl()
);
}

public function testSetUrl()
{
$url = 'http://test.com';
$this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $this->redirect->setUrl($url));
$this->assertInstanceOf(Redirect::class, $this->redirect->setUrl($url));
}

public function testSetPath()
Expand All @@ -67,17 +70,36 @@ public function testSetPath()
$this->returnValue($params)
);
$this->assertInstanceOf(
\Magento\Framework\Controller\Result\Redirect::class,
Redirect::class,
$this->redirect->setPath($path, $params)
);
}

public function testRender()
public function httpRedirectResponseStatusCodes()
{
$this->response->expects($this->once())->method('setRedirect');
$this->assertInstanceOf(
\Magento\Framework\Controller\Result\Redirect::class,
$this->redirect->renderResult($this->response)
);
return [
[302, null],
[302, 302],
[303, 303]
];
}

/**
* @param int $expectedStatusCode
* @param int|null $actualStatusCode
* @dataProvider httpRedirectResponseStatusCodes
*/
public function testRender($expectedStatusCode, $actualStatusCode)
{
$url = 'http://test.com';
$this->redirect->setUrl($url);
$this->redirect->setHttpResponseCode($actualStatusCode);

$this->response
->expects($this->once())
->method('setRedirect')
->with($url, $expectedStatusCode);

$this->redirect->renderResult($this->response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/html.xsd"/>

<xs:element name="layout">
<xs:annotation>
Expand Down Expand Up @@ -45,6 +46,7 @@
<xs:element ref="referenceBlock" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="html" type="htmlType" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>

Expand Down

0 comments on commit 13a933a

Please sign in to comment.