Skip to content

Commit b33de4e

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-89039
2 parents 1ad527b + 56b9c6c commit b33de4e

File tree

23 files changed

+495
-128
lines changed

23 files changed

+495
-128
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,19 @@ public function processAttributeValue($attribute, $value)
107107
&& in_array($attribute->getFrontendInput(), ['text', 'textarea'])
108108
) {
109109
$result = $value;
110-
} elseif ($this->isTermFilterableAttribute($attribute)) {
110+
} elseif ($this->isTermFilterableAttribute($attribute)
111+
|| ($attribute->getIsSearchable()
112+
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect']))
113+
) {
111114
$result = '';
112115
}
113116

114117
return $result;
115118
}
116119

117120
/**
118-
* Prepare index array as a string glued by separator
121+
* Prepare index array as a string glued by separator.
122+
*
119123
* Support 2 level array gluing
120124
*
121125
* @param array $index

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/price-configurable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ define([
5353
if (isConfigurable) {
5454
this.disable();
5555
this.clear();
56+
} else {
57+
this.enable();
5658
}
5759
}
5860
});

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public function updateSubscription($customerId)
552552
}
553553

554554
/**
555-
* Saving customer subscription status
555+
* Saving customer subscription status.
556556
*
557557
* @param int $customerId
558558
* @param bool $subscribe indicates whether the customer should be subscribed or unsubscribed
@@ -588,7 +588,12 @@ protected function _updateCustomerSubscription($customerId, $subscribe)
588588
if (AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED
589589
== $this->customerAccountManagement->getConfirmationStatus($customerId)
590590
) {
591-
$status = self::STATUS_UNCONFIRMED;
591+
if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) {
592+
// if a customer was already subscribed then keep the subscribed
593+
$status = self::STATUS_SUBSCRIBED;
594+
} else {
595+
$status = self::STATUS_UNCONFIRMED;
596+
}
592597
} elseif ($isConfirmNeed) {
593598
if ($this->getStatus() != self::STATUS_SUBSCRIBED) {
594599
$status = self::STATUS_NOT_ACTIVE;

app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public function testSubscribeNotLoggedIn()
209209
$this->assertEquals(Subscriber::STATUS_NOT_ACTIVE, $this->subscriber->subscribe($email));
210210
}
211211

212+
/**
213+
* Update status with Confirmation Status - required.
214+
*
215+
* @return void
216+
*/
212217
public function testUpdateSubscription()
213218
{
214219
$websiteId = 1;
@@ -225,7 +230,7 @@ public function testUpdateSubscription()
225230
->willReturn(
226231
[
227232
'subscriber_id' => 1,
228-
'subscriber_status' => Subscriber::STATUS_SUBSCRIBED
233+
'subscriber_status' => Subscriber::STATUS_SUBSCRIBED,
229234
]
230235
);
231236
$customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id');
@@ -245,8 +250,9 @@ public function testUpdateSubscription()
245250
->getMock();
246251
$this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel);
247252
$storeModel->expects($this->exactly(2))->method('getWebsiteId')->willReturn($websiteId);
253+
$data = $this->subscriber->updateSubscription($customerId);
248254

249-
$this->assertEquals($this->subscriber, $this->subscriber->updateSubscription($customerId));
255+
$this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $data->getSubscriberStatus());
250256
}
251257

252258
public function testUnsubscribeCustomerById()

app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,21 @@ public function getItemRowTotalAfterDiscountHtml($item = null)
278278
$block->setItem($item);
279279
return $block->toHtml();
280280
}
281+
282+
/**
283+
* Return the base total amount minus discount.
284+
*
285+
* @param OrderItem|InvoiceItem|CreditmemoItem $item
286+
* @return float|null
287+
*/
288+
public function getBaseTotalAmount($item)
289+
{
290+
$baseTotalAmount = $item->getBaseRowTotal()
291+
+ $item->getBaseTaxAmount()
292+
+ $item->getBaseDiscountTaxCompensationAmount()
293+
+ $item->getBaseWeeeTaxAppliedAmount()
294+
- $item->getBaseDiscountAmount();
295+
296+
return $baseTotalAmount;
297+
}
281298
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Model\Order\Webapi;
9+
10+
use Magento\Sales\Api\Data\OrderItemInterface;
11+
use Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn;
12+
use Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer;
13+
14+
/**
15+
* Class for changing row total in response.
16+
*/
17+
class ChangeOutputArray
18+
{
19+
/**
20+
* @var DefaultColumn
21+
*/
22+
private $priceRenderer;
23+
24+
/**
25+
* @var DefaultRenderer
26+
*/
27+
private $defaultRenderer;
28+
29+
/**
30+
* @param DefaultColumn $priceRenderer
31+
* @param DefaultRenderer $defaultRenderer
32+
*/
33+
public function __construct(
34+
DefaultColumn $priceRenderer,
35+
DefaultRenderer $defaultRenderer
36+
) {
37+
$this->priceRenderer = $priceRenderer;
38+
$this->defaultRenderer = $defaultRenderer;
39+
}
40+
41+
/**
42+
* Changing row total for webapi order item response.
43+
*
44+
* @param OrderItemInterface $dataObject
45+
* @param array $result
46+
* @return array
47+
*/
48+
public function execute(
49+
OrderItemInterface $dataObject,
50+
array $result
51+
): array {
52+
$result[OrderItemInterface::ROW_TOTAL] = $this->priceRenderer->getTotalAmount($dataObject);
53+
$result[OrderItemInterface::BASE_ROW_TOTAL] = $this->priceRenderer->getBaseTotalAmount($dataObject);
54+
$result[OrderItemInterface::ROW_TOTAL_INCL_TAX] = $this->defaultRenderer->getTotalAmount($dataObject);
55+
$result[OrderItemInterface::BASE_ROW_TOTAL_INCL_TAX] = $this->defaultRenderer->getBaseTotalAmount($dataObject);
56+
57+
return $result;
58+
}
59+
}

app/code/Magento/Sales/Test/Unit/Block/Order/Item/Renderer/DefaultRendererTest.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,7 @@ protected function setUp()
6060
->setMethods(['setItem', 'toHtml'])
6161
->getMock();
6262

63-
$itemMockMethods = [
64-
'__wakeup',
65-
'getRowTotal',
66-
'getTaxAmount',
67-
'getDiscountAmount',
68-
'getDiscountTaxCompensationAmount',
69-
'getWeeeTaxAppliedRowAmount',
70-
];
71-
$this->itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
72-
->disableOriginalConstructor()
73-
->setMethods($itemMockMethods)
74-
->getMock();
63+
$this->itemMock = $this->createMock(\Magento\Sales\Model\Order\Item::class);
7564
}
7665

7766
public function testGetItemPriceHtml()
@@ -161,4 +150,20 @@ public function testGetTotalAmount()
161150

162151
$this->assertEquals($expectedResult, $this->block->getTotalAmount($this->itemMock));
163152
}
153+
154+
/**
155+
* @return void
156+
*/
157+
public function testGetBaseTotalAmount()
158+
{
159+
$expectedBaseTotalAmount = 10;
160+
161+
$this->itemMock->expects($this->once())->method('getBaseRowTotal')->willReturn(8);
162+
$this->itemMock->expects($this->once())->method('getBaseTaxAmount')->willReturn(1);
163+
$this->itemMock->expects($this->once())->method('getBaseDiscountTaxCompensationAmount')->willReturn(1);
164+
$this->itemMock->expects($this->once())->method('getBaseWeeeTaxAppliedAmount')->willReturn(1);
165+
$this->itemMock->expects($this->once())->method('getBaseDiscountAmount')->willReturn(1);
166+
167+
$this->assertEquals($expectedBaseTotalAmount, $this->block->getBaseTotalAmount($this->itemMock));
168+
}
164169
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Test\Unit\Model\Order\Webapi;
9+
10+
use Magento\Sales\Api\Data\OrderItemInterface;
11+
use Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer;
14+
use Magento\Sales\Model\Order\Webapi\ChangeOutputArray;
15+
16+
/**
17+
* Test for Magento\Sales\Model\Order\Webapi\ChangeOutputArray class.
18+
*/
19+
class ChangeOutputArrayTest extends \PHPUnit\Framework\TestCase
20+
{
21+
/**
22+
* @var DefaultColumn|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $priceRendererMock;
25+
26+
/**
27+
* @var DefaultRenderer|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
private $defaultRendererMock;
30+
31+
/**
32+
* @var ObjectManager
33+
*/
34+
private $objectManager;
35+
36+
/**
37+
* @var ChangeOutputArray
38+
*/
39+
private $model;
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
protected function setUp()
45+
{
46+
$this->objectManager = new ObjectManager($this);
47+
48+
$this->priceRendererMock = $this->createMock(DefaultColumn::class);
49+
$this->defaultRendererMock = $this->createMock(DefaultRenderer::class);
50+
51+
$this->model = $this->objectManager->getObject(
52+
ChangeOutputArray::class,
53+
[
54+
'priceRenderer' => $this->priceRendererMock,
55+
'defaultRenderer' => $this->defaultRendererMock,
56+
]
57+
);
58+
}
59+
60+
/**
61+
* @return void
62+
*/
63+
public function testExecute()
64+
{
65+
$expectedResult = [
66+
OrderItemInterface::ROW_TOTAL => 10,
67+
OrderItemInterface::BASE_ROW_TOTAL => 10,
68+
OrderItemInterface::ROW_TOTAL_INCL_TAX => 11,
69+
OrderItemInterface::BASE_ROW_TOTAL_INCL_TAX => 11,
70+
];
71+
$orderItemInterfaceMock = $this->createMock(OrderItemInterface::class);
72+
73+
$this->priceRendererMock->expects($this->once())
74+
->method('getTotalAmount')
75+
->with($orderItemInterfaceMock)
76+
->willReturn(10);
77+
$this->priceRendererMock->expects($this->once())
78+
->method('getBaseTotalAmount')
79+
->with($orderItemInterfaceMock)
80+
->willReturn(10);
81+
$this->defaultRendererMock->expects($this->once())
82+
->method('getTotalAmount')
83+
->with($orderItemInterfaceMock)
84+
->willReturn(11);
85+
$this->defaultRendererMock->expects($this->once())
86+
->method('getBaseTotalAmount')
87+
->with($orderItemInterfaceMock)
88+
->willReturn(11);
89+
90+
$this->assertEquals($expectedResult, $this->model->execute($orderItemInterfaceMock, []));
91+
}
92+
}

app/code/Magento/Sales/etc/webapi_rest/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@
1515
<type name="Magento\Sales\Api\ShipmentRepositoryInterface">
1616
<plugin name="convert_blob_to_string" type="Magento\Sales\Plugin\ShippingLabelConverter" />
1717
</type>
18+
<type name="Magento\Framework\Reflection\DataObjectProcessor">
19+
<arguments>
20+
<argument name="processors" xsi:type="array">
21+
<item name="\Magento\Sales\Model\Order\Item" xsi:type="object">Magento\Sales\Model\Order\Webapi\ChangeOutputArray\Proxy</item>
22+
</argument>
23+
</arguments>
24+
</type>
1825
</config>

app/code/Magento/Sales/etc/webapi_soap/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@
1515
<type name="Magento\Sales\Api\ShipmentRepositoryInterface">
1616
<plugin name="convert_blob_to_string" type="Magento\Sales\Plugin\ShippingLabelConverter" />
1717
</type>
18+
<type name="Magento\Framework\Reflection\DataObjectProcessor">
19+
<arguments>
20+
<argument name="processors" xsi:type="array">
21+
<item name="\Magento\Sales\Model\Order\Item" xsi:type="object">Magento\Sales\Model\Order\Webapi\ChangeOutputArray\Proxy</item>
22+
</argument>
23+
</arguments>
24+
</type>
1825
</config>

0 commit comments

Comments
 (0)