Skip to content

Commit a22f248

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into MC-15922
2 parents fe54707 + 88eba25 commit a22f248

File tree

34 files changed

+339
-144
lines changed

34 files changed

+339
-144
lines changed

app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function setEntity($entity)
264264
$this->_entity = $this->_eavEntityFactory->create()->setType($entity);
265265
} else {
266266
throw new LocalizedException(
267-
__('The "%1" entity supplied is invalid. Verify the entity and try again.', print_r($entity, 1))
267+
__('The entity supplied to collection is invalid. Verify the entity and try again.')
268268
);
269269
}
270270
return $this;
@@ -1061,6 +1061,7 @@ public function importFromArray($arr)
10611061
$this->_items[$entityId]->addData($row);
10621062
}
10631063
}
1064+
$this->_setIsLoaded();
10641065
return $this;
10651066
}
10661067

@@ -1164,7 +1165,6 @@ public function _loadEntities($printQuery = false, $logQuery = false)
11641165
* @param bool $printQuery
11651166
* @param bool $logQuery
11661167
* @return $this
1167-
* @throws LocalizedException
11681168
* @throws \Exception
11691169
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
11701170
* @SuppressWarnings(PHPMD.NPathComplexity)

app/code/Magento/Integration/Model/AdminTokenService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct(
7272
}
7373

7474
/**
75-
* {@inheritdoc}
75+
* @inheritdoc
7676
*/
7777
public function createAdminAccessToken($username, $password)
7878
{
@@ -110,7 +110,7 @@ public function revokeAdminAccessToken($adminId)
110110
{
111111
$tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByAdminId($adminId);
112112
if ($tokenCollection->getSize() == 0) {
113-
throw new LocalizedException(__('This user has no tokens.'));
113+
return true;
114114
}
115115
try {
116116
foreach ($tokenCollection as $token) {

app/code/Magento/Integration/Test/Unit/Model/AdminTokenServiceTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Integration\Model\Oauth\Token;
1010

11+
/**
12+
* Test for Magento\Integration\Model\AdminTokenService class.
13+
*/
1114
class AdminTokenServiceTest extends \PHPUnit\Framework\TestCase
1215
{
1316
/** \Magento\Integration\Model\AdminTokenService */
@@ -99,10 +102,6 @@ public function testRevokeAdminAccessToken()
99102
$this->assertTrue($this->_tokenService->revokeAdminAccessToken($adminId));
100103
}
101104

102-
/**
103-
* @expectedException \Magento\Framework\Exception\LocalizedException
104-
* @expectedExceptionMessage This user has no tokens.
105-
*/
106105
public function testRevokeAdminAccessTokenWithoutAdminId()
107106
{
108107
$this->_tokenModelCollectionMock->expects($this->once())

app/code/Magento/Msrp/Pricing/MsrpPriceCalculator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MsrpPriceCalculator implements MsrpPriceCalculatorInterface
2323
/**
2424
* @param array $msrpPriceCalculators
2525
*/
26-
public function __construct(array $msrpPriceCalculators)
26+
public function __construct(array $msrpPriceCalculators = [])
2727
{
2828
$this->msrpPriceCalculators = $this->getMsrpPriceCalculators($msrpPriceCalculators);
2929
}

app/code/Magento/Review/Block/Adminhtml/Edit/Form.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
namespace Magento\Review\Block\Adminhtml\Edit;
8+
79
/**
810
* Adminhtml Review Edit Form
911
*/
10-
namespace Magento\Review\Block\Adminhtml\Edit;
11-
1212
class Form extends \Magento\Backend\Block\Widget\Form\Generic
1313
{
1414
/**
@@ -84,7 +84,8 @@ protected function _prepareForm()
8484
'review/*/save',
8585
[
8686
'id' => $this->getRequest()->getParam('id'),
87-
'ret' => $this->_coreRegistry->registry('ret')
87+
'ret' => $this->_coreRegistry->registry('ret'),
88+
'productId' => $this->getRequest()->getParam('productId')
8889
]
8990
),
9091
'method' => 'post',

app/code/Magento/Review/Controller/Adminhtml/Product/Save.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public function execute()
7373
} else {
7474
$resultRedirect->setPath('*/*/');
7575
}
76+
$productId = (int)$this->getRequest()->getParam('productId');
77+
if ($productId) {
78+
$resultRedirect->setPath("catalog/product/edit/id/$productId");
79+
}
7680
return $resultRedirect;
7781
}
7882
$resultRedirect->setPath('review/*/');

app/code/Magento/Sales/Model/Order/Payment.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function canCapture()
300300
}
301301

302302
/**
303-
* Check refund availability
303+
* Check refund availability.
304304
*
305305
* @return bool
306306
*/
@@ -310,7 +310,7 @@ public function canRefund()
310310
}
311311

312312
/**
313-
* Check partial refund availability for invoice
313+
* Check partial refund availability for invoice.
314314
*
315315
* @return bool
316316
*/
@@ -320,7 +320,7 @@ public function canRefundPartialPerInvoice()
320320
}
321321

322322
/**
323-
* Check partial capture availability
323+
* Check partial capture availability.
324324
*
325325
* @return bool
326326
*/
@@ -546,9 +546,7 @@ public function cancelInvoice($invoice)
546546
}
547547

548548
/**
549-
* Create new invoice with maximum qty for invoice for each item
550-
*
551-
* Register this invoice and capture
549+
* Create new invoice with maximum qty for invoice for each item register this invoice and capture
552550
*
553551
* @return Invoice
554552
*/
@@ -686,6 +684,7 @@ public function refund($creditmemo)
686684
$gateway->refund($this, $baseAmountToRefund);
687685

688686
$creditmemo->setTransactionId($this->getLastTransId());
687+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
689688
} catch (\Magento\Framework\Exception\LocalizedException $e) {
690689
if (!$captureTxn) {
691690
throw new \Magento\Framework\Exception\LocalizedException(
@@ -732,10 +731,14 @@ public function refund($creditmemo)
732731
$message = $message = $this->prependMessage($message);
733732
$message = $this->_appendTransactionToMessage($transaction, $message);
734733
$orderState = $this->getOrderStateResolver()->getStateForOrder($this->getOrder());
734+
$statuses = $this->getOrder()->getConfig()->getStateStatuses($orderState, false);
735+
$status = in_array($this->getOrder()->getStatus(), $statuses, true)
736+
? $this->getOrder()->getStatus()
737+
: $this->getOrder()->getConfig()->getStateDefaultStatus($orderState);
735738
$this->getOrder()
736739
->addStatusHistoryComment(
737740
$message,
738-
$this->getOrder()->getConfig()->getStateDefaultStatus($orderState)
741+
$status
739742
)->setIsCustomerNotified($creditmemo->getOrder()->getCustomerNoteNotify());
740743
$this->_eventManager->dispatch(
741744
'sales_order_payment_refund',
@@ -1203,7 +1206,7 @@ public function addTransaction($type, $salesDocument = null, $failSafe = false)
12031206
}
12041207

12051208
/**
1206-
* Add message to the specified transaction.
1209+
* Add transaction comments to order.
12071210
*
12081211
* @param Transaction|null $transaction
12091212
* @param string $message

app/code/Magento/Sales/Model/RefundOrder.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Model;
78

89
use Magento\Framework\App\ResourceConnection;
@@ -151,10 +152,13 @@ public function execute(
151152
$creditmemo->setState(\Magento\Sales\Model\Order\Creditmemo::STATE_REFUNDED);
152153
$order->setCustomerNoteNotify($notify);
153154
$order = $this->refundAdapter->refund($creditmemo, $order);
154-
$order->setState(
155-
$this->orderStateResolver->getStateForOrder($order, [])
156-
);
157-
$order->setStatus($this->config->getStateDefaultStatus($order->getState()));
155+
$orderState = $this->orderStateResolver->getStateForOrder($order, []);
156+
$order->setState($orderState);
157+
$statuses = $this->config->getStateStatuses($orderState, false);
158+
$status = in_array($order->getStatus(), $statuses, true)
159+
? $order->getStatus()
160+
: $this->config->getStateDefaultStatus($orderState);
161+
$order->setStatus($status);
158162

159163
$order = $this->orderRepository->save($order);
160164
$creditmemo = $this->creditmemoRepository->save($creditmemo);

app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Test\Unit\Model\Order;
78

89
use Magento\Framework\Model\Context;
@@ -1526,7 +1527,7 @@ public function testRefund()
15261527
$this->orderStateResolver->expects($this->once())->method('getStateForOrder')
15271528
->with($this->order)
15281529
->willReturn(Order::STATE_CLOSED);
1529-
$this->mockGetDefaultStatus(Order::STATE_CLOSED, $status);
1530+
$this->mockGetDefaultStatus(Order::STATE_CLOSED, $status, ['first, second']);
15301531
$this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message);
15311532

15321533
static::assertSame($this->payment, $this->payment->refund($this->creditMemoMock));

app/code/Magento/Sales/Test/Unit/Model/RefundOrderTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sales\Test\Unit\Model;
78

89
use Magento\Framework\App\ResourceConnection;
@@ -245,9 +246,9 @@ public function testOrderCreditmemo($orderId, $notify, $appendComment)
245246
->method('setState')
246247
->with(Order::STATE_CLOSED)
247248
->willReturnSelf();
248-
$this->orderMock->expects($this->once())
249-
->method('getState')
250-
->willReturn(Order::STATE_CLOSED);
249+
$this->configMock->expects($this->once())
250+
->method('getStateStatuses')
251+
->willReturn(['first, second']);
251252
$this->configMock->expects($this->once())
252253
->method('getStateDefaultStatus')
253254
->with(Order::STATE_CLOSED)

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<column name="order_increment_id">
9393
<settings>
9494
<filter>text</filter>
95-
<label translate="true">Order</label>
95+
<label translate="true">Order #</label>
9696
</settings>
9797
</column>
9898
<column name="order_created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<column name="order_increment_id">
101101
<settings>
102102
<filter>text</filter>
103-
<label translate="true">Order</label>
103+
<label translate="true">Order #</label>
104104
</settings>
105105
</column>
106106
<column name="order_created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<column name="order_increment_id">
106106
<settings>
107107
<filter>text</filter>
108-
<label translate="true">Order</label>
108+
<label translate="true">Order #</label>
109109
</settings>
110110
</column>
111111
<column name="order_created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<column name="order_increment_id">
107107
<settings>
108108
<filter>textRange</filter>
109-
<label translate="true">Order</label>
109+
<label translate="true">Order #</label>
110110
</settings>
111111
</column>
112112
<column name="order_created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,8 @@ protected function _updatePathUseRewrites($url)
716716
if ($this->_isCustomEntryPoint()) {
717717
$indexFileName = 'index.php';
718718
} else {
719-
$indexFileName = basename($_SERVER['SCRIPT_FILENAME']);
719+
$scriptFilename = $this->_request->getServer('SCRIPT_FILENAME');
720+
$indexFileName = basename($scriptFilename);
720721
}
721722
$url .= $indexFileName . '/';
722723
}

app/code/Magento/Store/Test/Unit/Model/StoreTest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testGetWebsite()
160160
/** @var \Magento\Store\Model\Store $model */
161161
$model = $this->objectManagerHelper->getObject(
162162
\Magento\Store\Model\Store::class,
163-
['websiteRepository' => $websiteRepository,]
163+
['websiteRepository' => $websiteRepository]
164164
);
165165
$model->setWebsiteId($websiteId);
166166

@@ -181,7 +181,7 @@ public function testGetWebsiteIfWebsiteIsNotExist()
181181
/** @var \Magento\Store\Model\Store $model */
182182
$model = $this->objectManagerHelper->getObject(
183183
\Magento\Store\Model\Store::class,
184-
['websiteRepository' => $websiteRepository,]
184+
['websiteRepository' => $websiteRepository]
185185
);
186186
$model->setWebsiteId(null);
187187

@@ -207,7 +207,7 @@ public function testGetGroup()
207207
/** @var \Magento\Store\Model\Store $model */
208208
$model = $this->objectManagerHelper->getObject(
209209
\Magento\Store\Model\Store::class,
210-
['groupRepository' => $groupRepository,]
210+
['groupRepository' => $groupRepository]
211211
);
212212
$model->setGroupId($groupId);
213213

@@ -228,7 +228,7 @@ public function testGetGroupIfGroupIsNotExist()
228228
/** @var \Magento\Store\Model\Store $model */
229229
$model = $this->objectManagerHelper->getObject(
230230
\Magento\Store\Model\Store::class,
231-
['groupRepository' => $groupRepository,]
231+
['groupRepository' => $groupRepository]
232232
);
233233
$model->setGroupId(null);
234234

@@ -377,30 +377,31 @@ public function testGetBaseUrlEntryPoint()
377377
$configMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
378378
$configMock->expects($this->atLeastOnce())
379379
->method('getValue')
380-
->will($this->returnCallback(
381-
function ($path, $scope, $scopeCode) use ($expectedPath) {
382-
return $expectedPath == $path ? 'http://domain.com/' . $path . '/' : null;
383-
}
384-
));
380+
->willReturnCallback(function ($path, $scope, $scopeCode) use ($expectedPath) {
381+
return $expectedPath == $path ? 'http://domain.com/' . $path . '/' : null;
382+
});
383+
$this->requestMock->expects($this->once())
384+
->method('getServer')
385+
->with('SCRIPT_FILENAME')
386+
->willReturn('test_script.php');
387+
385388
/** @var \Magento\Store\Model\Store $model */
386389
$model = $this->objectManagerHelper->getObject(
387390
\Magento\Store\Model\Store::class,
388391
[
389392
'config' => $configMock,
390393
'isCustomEntryPoint' => false,
394+
'request' => $this->requestMock
391395
]
392396
);
393397
$model->setCode('scopeCode');
394398

395399
$this->setUrlModifier($model);
396400

397-
$server = $_SERVER;
398-
$_SERVER['SCRIPT_FILENAME'] = 'test_script.php';
399401
$this->assertEquals(
400402
$expectedBaseUrl,
401403
$model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false)
402404
);
403-
$_SERVER = $server;
404405
}
405406

406407
/**
@@ -592,7 +593,7 @@ public function testGetAllowedCurrencies()
592593
/** @var \Magento\Store\Model\Store $model */
593594
$model = $this->objectManagerHelper->getObject(
594595
\Magento\Store\Model\Store::class,
595-
['config' => $configMock, 'currencyInstalled' => $currencyPath,]
596+
['config' => $configMock, 'currencyInstalled' => $currencyPath]
596597
);
597598

598599
$this->assertEquals($expectedResult, $model->getAllowedCurrencies());

0 commit comments

Comments
 (0)