Skip to content

Commit 6e8c105

Browse files
committed
Merge remote-tracking branch 'origin/2.1-develop' into 2.1-develop-pr56
2 parents 4f6670f + 964f7b0 commit 6e8c105

File tree

11 files changed

+48
-14
lines changed

11 files changed

+48
-14
lines changed

app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ protected function isValidOptionTitle($title, $storeId)
106106
if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $title === null) {
107107
return true;
108108
}
109-
if ($this->isEmpty($title)) {
109+
110+
// checking whether title is null and is empty string
111+
if ($title === null || $title === '') {
110112
return false;
111113
}
112114

app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ protected function _saveValueTitles(AbstractModel $object)
256256
$object->unsetData('title');
257257
}
258258

259-
if ($object->getTitle()) {
259+
/*** Checking whether title is not null ***/
260+
if ($object->getTitle()!= null) {
260261
if ($existInCurrentStore) {
261262
if ($storeId == $object->getStoreId()) {
262263
$where = [

app/code/Magento/Config/Model/ResourceModel/Config.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Config\Model\ResourceModel;
77

8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
810
/**
911
* Core Resource Resource Model
1012
*
@@ -32,7 +34,7 @@ protected function _construct()
3234
* @param int $scopeId
3335
* @return $this
3436
*/
35-
public function saveConfig($path, $value, $scope, $scopeId)
37+
public function saveConfig($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
3638
{
3739
$connection = $this->getConnection();
3840
$select = $connection->select()->from(
@@ -68,7 +70,7 @@ public function saveConfig($path, $value, $scope, $scopeId)
6870
* @param int $scopeId
6971
* @return $this
7072
*/
71-
public function deleteConfig($path, $scope, $scopeId)
73+
public function deleteConfig($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
7274
{
7375
$connection = $this->getConnection();
7476
$connection->delete(

app/code/Magento/Quote/Model/CouponManagement.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function set($cartId, $couponCode)
5555
if (!$quote->getItemsCount()) {
5656
throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId));
5757
}
58+
if (!$quote->getStoreId()) {
59+
throw new NoSuchEntityException(__('Cart isn\'t assigned to correct store'));
60+
}
5861
$quote->getShippingAddress()->setCollectShippingRates(true);
5962

6063
try {

app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected function setUp()
5151
'save',
5252
'getShippingAddress',
5353
'getCouponCode',
54+
'getStoreId',
5455
'__wakeup'
5556
],
5657
[],
@@ -112,6 +113,9 @@ public function testSetWhenCouldNotApplyCoupon()
112113
$cartId = 33;
113114
$couponCode = '153a-ABC';
114115

116+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
117+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
118+
115119
$this->quoteRepositoryMock->expects($this->once())
116120
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
117121
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
@@ -139,6 +143,9 @@ public function testSetWhenCouponCodeIsInvalid()
139143
$cartId = 33;
140144
$couponCode = '153a-ABC';
141145

146+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
147+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
148+
142149
$this->quoteRepositoryMock->expects($this->once())
143150
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
144151
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
@@ -158,6 +165,9 @@ public function testSet()
158165
$cartId = 33;
159166
$couponCode = '153a-ABC';
160167

168+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
169+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
170+
161171
$this->quoteRepositoryMock->expects($this->once())
162172
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
163173
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));

app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public function draw()
127127
'feed' => 35,
128128
];
129129

130-
if ($option['value']) {
130+
// Checking whether option value is not null
131+
if ($option['value']!= null) {
131132
if (isset($option['print_value'])) {
132133
$printValue = $option['print_value'];
133134
} else {

app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function draw()
8989
];
9090

9191
// draw options value
92-
if ($option['value']) {
92+
if ($option['value']!= null) {
9393
$printValue = isset(
9494
$option['print_value']
9595
) ? $option['print_value'] : $this->filterManager->stripTags(

app/code/Magento/Store/Model/Address/Renderer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
*/
1616
class Renderer
1717
{
18+
const DEFAULT_TEMPLATE = "{{var name}}\n" .
19+
"{{var street_line1}}\n" .
20+
"{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
21+
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
22+
"{{var country}}";
23+
1824
/**
1925
* @var EventManager
2026
*/
@@ -25,18 +31,26 @@ class Renderer
2531
*/
2632
protected $filterManager;
2733

34+
/**
35+
* @var string
36+
*/
37+
private $template;
38+
2839
/**
2940
* Constructor
3041
*
3142
* @param EventManager $eventManager
3243
* @param FilterManager $filterManager
44+
* @param string $template
3345
*/
3446
public function __construct(
3547
EventManager $eventManager,
36-
FilterManager $filterManager
48+
FilterManager $filterManager,
49+
$template = self::DEFAULT_TEMPLATE
3750
) {
3851
$this->eventManager = $eventManager;
3952
$this->filterManager = $filterManager;
53+
$this->template = $template;
4054
}
4155

4256
/**
@@ -50,8 +64,7 @@ public function format(DataObject $storeInfo, $type = 'html')
5064
{
5165
$this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
5266
$address = $this->filterManager->template(
53-
"{{var name}}\n{{var street_line1}}\n{{depend street_line2}}{{var street_line2}}\n{{/depend}}"
54-
. "{{var city}}, {{var region}} {{var postcode}},\n{{var country}}",
67+
$this->template,
5568
['variables' => $storeInfo->getData()]
5669
);
5770

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function testAddNegative($optionData)
220220
];
221221

222222
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
223-
if (isset($optionDataPost['title']) && empty($optionDataPost['title'])) {
223+
if ($optionDataPost['title'] === null || $optionDataPost['title'] === '') {
224224
$this->setExpectedException('SoapFault', 'Missed values for option required fields');
225225
} else {
226226
$this->setExpectedException('SoapFault', 'Invalid option');

dev/tests/api-functional/testsuite/Magento/Catalog/Api/_files/product_options_negative.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
return [
88
'empty_required_field' => [
9-
'title' => '',
9+
'title' => null,
1010
'type' => 'field',
1111
'sort_order' => 1,
1212
'is_require' => 1,
@@ -54,7 +54,7 @@
5454
'price' => 10.0,
5555
'price_type' => 'fixed',
5656
'sku' => 'radio option 1 sku',
57-
'title' => '',
57+
'title' => null,
5858
'sort_order' => 1,
5959
],
6060
],

0 commit comments

Comments
 (0)