Skip to content

Commit

Permalink
Merge pull request #796 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
Merged Community Pull Requests:

#8354
#8161
#8341
#8155
#8336
#8327
#8307
  • Loading branch information
Oleksii Korshenko authored Feb 3, 2017
2 parents 119b950 + 71f37b0 commit 7647dce
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 19 deletions.
8 changes: 8 additions & 0 deletions app/code/Magento/Checkout/Block/Onepage/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ protected function canViewOrder(Order $order)
return $this->httpContext->getValue(Context::CONTEXT_AUTH)
&& $this->isVisible($order);
}

/**
* @return string
*/
public function getContinueUrl()
{
return $this->_storeManager->getStore()->getBaseUrl();
}
}
65 changes: 62 additions & 3 deletions app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Class SuccessTest
* @package Magento\Checkout\Block\Onepage
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class SuccessTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -18,6 +19,11 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
*/
protected $block;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $layout;

/**
* @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject
*/
Expand All @@ -28,21 +34,65 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
*/
protected $checkoutSession;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $storeManagerMock;

protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

$this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false);
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false);

$this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->checkoutSession = $this->getMockBuilder(\Magento\Checkout\Model\Session::class)
->disableOriginalConstructor()
->getMock();

$this->checkoutSession = $this->getMockBuilder(
\Magento\Checkout\Model\Session::class
)
$eventManager = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();
$scopeConfig->expects($this->any())
->method('getValue')
->with(
$this->stringContains(
'advanced/modules_disable_output/'
),
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
->will($this->returnValue(false));

$context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
->disableOriginalConstructor()
->setMethods(['getLayout', 'getEventManager', 'getUrlBuilder', 'getScopeConfig', 'getStoreManager'])
->getMock();
$context->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
$context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
$context->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilder));
$context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
$context->expects($this->any())->method('getStoreManager')->will($this->returnValue($this->storeManagerMock));

$this->block = $objectManager->getObject(
\Magento\Checkout\Block\Onepage\Success::class,
[
'context' => $context,
'orderConfig' => $this->orderConfig,
'checkoutSession' => $this->checkoutSession
]
Expand Down Expand Up @@ -110,4 +160,13 @@ public function invisibleStatusesProvider()
[['status1', 'status2'], true]
];
}

public function testGetContinueUrl()
{
$storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false);
$this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
$storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('Expected Result'));

$this->assertEquals('Expected Result', $this->block->getContinueUrl());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?php /* @escapeNotVerified */ echo $block->getUrl() ?>"><span><?php /* @escapeNotVerified */ echo __('Continue Shopping') ?></span></a>
<a class="action primary continue" href="<?php /* @escapeNotVerified */ echo $block->getContinueUrl() ?>"><span><?php /* @escapeNotVerified */ echo __('Continue Shopping') ?></span></a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,12 @@ public function getColumns()
{
return $this->_columns;
}

/**
* @return string
*/
public function getAddButtonLabel()
{
return $this->_addButtonLabel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@

class AbstractTest extends \PHPUnit_Framework_TestCase
{
public function testGetArrayRows()
/**
* @var \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
*/
private $model;

protected function setUp()
{
/** @var $block \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray */
$block = $this->getMockForAbstractClass(
$this->model = $this->getMockForAbstractClass(
\Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray::class,
[],
'',
Expand All @@ -19,12 +23,15 @@ public function testGetArrayRows()
true,
['escapeHtml']
);
$block->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
}

public function testGetArrayRows()
{
$this->model->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$element = $objectManager->getObject(\Magento\Framework\Data\Form\Element\Multiselect::class);
$element->setValue([['te<s>t' => 't<e>st', 'data&1' => 'da&ta1']]);
$block->setElement($element);
$this->model->setElement($element);
$this->assertEquals(
[
new \Magento\Framework\DataObject(
Expand All @@ -36,7 +43,17 @@ public function testGetArrayRows()
]
),
],
$block->getArrayRows()
$this->model->getArrayRows()
);
}

public function testGetAddButtonLabel()
{
$contextMock = $this->getMockBuilder(\Magento\Backend\Block\Template\Context::class)
->disableOriginalConstructor()
->getMock();
$this->model->__construct($contextMock);

$this->assertEquals("Add", $this->model->getAddButtonLabel());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $_colspan = $block->isAddAfter() ? 2 : 1;
<tr>
<td colspan="<?php echo count($block->getColumns())+$_colspan; ?>" class="col-actions-add">
<button id="addToEndBtn<?php /* @escapeNotVerified */ echo $_htmlId; ?>" class="action-add" title="<?php /* @escapeNotVerified */ echo __('Add'); ?>" type="button">
<span><?php /* @escapeNotVerified */ echo $block->getAddButtonLabel(); ?><?php /* @escapeNotVerified */ echo __('Add'); ?></span>
<span><?php /* @escapeNotVerified */ echo $block->getAddButtonLabel(); ?></span>
</button>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Email/Model/AbstractTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function getProcessedTemplate(array $variables = [])
$result = $processor->filter($this->getTemplateText());
} catch (\Exception $e) {
$this->cancelDesignConfig();
throw new \LogicException(__($e->getMessage()), $e);
throw new \LogicException(__($e->getMessage()), $e->getCode(), $e);
}
if ($isDesignApplied) {
$this->cancelDesignConfig();
Expand Down
61 changes: 61 additions & 0 deletions app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,67 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
$this->assertEquals($expectedResult, $model->getProcessedTemplate($variables));
}

/**
* @expectedException \LogicException
*/
public function testGetProcessedTemplateException() {
$filterTemplate = $this->getMockBuilder(\Magento\Email\Model\Template\Filter::class)
->setMethods([
'setUseSessionInUrl',
'setPlainTemplateMode',
'setIsChildTemplate',
'setDesignParams',
'setVariables',
'setStoreId',
'filter',
'getStoreId',
'getInlineCssFiles',
])
->disableOriginalConstructor()
->getMock();
$filterTemplate->expects($this->once())
->method('setUseSessionInUrl')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setPlainTemplateMode')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setIsChildTemplate')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setDesignParams')
->will($this->returnSelf());
$filterTemplate->expects($this->any())
->method('setStoreId')
->will($this->returnSelf());
$filterTemplate->expects($this->any())
->method('getStoreId')
->will($this->returnValue(1));

$model = $this->getModelMock([
'getDesignParams',
'applyDesignConfig',
'getTemplateText',
'isPlain',
]);

$designParams = [
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'theme' => 'themeId',
'locale' => 'localeId',
];
$model->expects($this->any())
->method('getDesignParams')
->will($this->returnValue($designParams));
$model->setTemplateFilter($filterTemplate);
$model->setTemplateType(\Magento\Framework\App\TemplateTypesInterface::TYPE_TEXT);

$filterTemplate->expects($this->once())
->method('filter')
->will($this->throwException(new \Exception));
$model->getProcessedTemplate([]);
}

/**
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Purchase Date</item>
<item name="dateFormat" xsi:type="string">MMM dd, YYYY, H:MM:SS A</item>
<item name="dateFormat" xsi:type="string">MMM dd, YYYY, H:mm:ss A</item>
</item>
</argument>
</column>
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Search/view/frontend/web/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ define([
setTimeout($.proxy(function () {
if (this.autoComplete.is(':hidden')) {
this.setActiveState(false);
} else {
this.element.trigger('focus');
}
this.autoComplete.hide();
this._updateAriaHasPopup(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@ public function testGetTopics()
$this->assertEquals($expectedParsedTopics, $topics);
}

/**
* Get topic configuration by its name
*
* @expectedException \LogicException
* @expectedExceptionMessage Service method specified in the definition of topic "customerDeletedNumbers" is not av
*/
public function testGetTopicsNumeric()
{
$this->getConfigInstance(__DIR__ . '/_files/valid_communication_numeric.xml')->getTopics();
}

// @codingStandardsIgnoreStart
/**
* Get topic configuration by its name
*
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Invalid XML in file 0:
Element 'topic', attribute 'schema': [facet 'pattern'] The value '55\Customer\Api\CustomerRepositoryInterface::delete' is not accepted by the pattern '[a-zA-Z]+[a-zA-Z0-9\\]+::[a-zA-Z0-9]+'.
Line: 9
Element 'topic', attribute 'schema': '55\Customer\Api\CustomerRepositoryInterface::delete' is not a valid value of the atomic type 'schemaType'.
Line: 9
Element 'handler', attribute 'type': [facet 'pattern'] The value '55\Customer\Api\CustomerRepositoryInterface' is not accepted by the pattern '[a-zA-Z]+[a-zA-Z0-9\\]+'.
Line: 10
Element 'handler', attribute 'type': '55\Customer\Api\CustomerRepositoryInterface' is not a valid value of the atomic type 'serviceTypeType'.
Line: 10
*
*/
// @codingStandardsIgnoreEnd
public function testGetTopicsNumericInvalid()
{
$this->getConfigInstance(__DIR__ . '/_files/invalid_communication_numeric.xml')->getTopics();
}

/**
* Get topic configuration by its name
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="customerDeletedNumbers" schema="55\Customer\Api\CustomerRepositoryInterface::99delete">
<handler name="customHandler" type="55\Customer\Api\CustomerRepositoryInterface" method="99deleteById"/>
</topic>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="customerDeletedNumbers" schema="V55\Customer\Api\CustomerRepositoryInterface::delete99">
<handler name="customHandler" type="V55\Customer\Api\CustomerRepositoryInterface" method="deleteById99"/>
</topic>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConfigParser
*/
public function parseServiceMethod($serviceMethod)
{
$pattern = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';
$pattern = '/^([a-zA-Z]+[a-zA-Z0-9\\\\]+)::([a-zA-Z0-9]+)$/';
preg_match($pattern, $serviceMethod, $matches);
if (!isset($matches[1]) || !isset($matches[2])) {
throw new LocalizedException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
{
/**
* @deprecated
* @see ConfigParser::SERVICE_METHOD_NAME_PATTERN
* @see ConfigParser::parseServiceMethod
*/
const SERVICE_METHOD_NAME_PATTERN = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';

Expand Down
Loading

0 comments on commit 7647dce

Please sign in to comment.