Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 7968f8b

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#16824: [Forwardport] Fixed type hints and docs for Downloadable Samples block (by @ronak2ram) - magento/magento2#16815: [Forwardport] Covered Magento\Checkout\Model\Cart\CollectQuote by Unit Test (by @mage2pratik) - magento/magento2#16756: [forwardport] #16716 fix _utilities.less font-size issue (by @Karlasa) - magento/magento2#16363: [Forwardport] Fix case mismatch call (class/method) (by @lfluvisotto) - magento/magento2#16745: [Forwardport] typo in private method name getUniq[ue]ImageIndex (by @eduard13) - magento/magento2#15895: Handle type errors for objects creation (by @yuriyDne) - magento/magento2#16874: [Forwardport] Remove commented code & remove space (by @ronak2ram) - magento/magento2#16773: Improved code and remove unnecessary space (by @ronak2ram)
2 parents 9e9ec37 + d347270 commit 7968f8b

File tree

47 files changed

+316
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+316
-78
lines changed

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected function setUp()
219219
'_getCustomerGroupById',
220220
'correctExportData'
221221
]);
222-
$this->advancedPricing = $this->getMockbuilder(
222+
$this->advancedPricing = $this->getMockBuilder(
223223
\Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class
224224
)
225225
->setMethods($mockMethods)

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function testRender()
6565
->method('getLabel')
6666
->willReturn('Comment label');
6767
$html = $this->additionalComment->render($this->abstractElementMock);
68-
$this->assertRegexp(
68+
$this->assertRegExp(
6969
"/New comment/",
7070
$html
7171
);
72-
$this->assertRegexp(
72+
$this->assertRegExp(
7373
"/Comment label/",
7474
$html
7575
);

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testRender()
8787
$this->localeResolver->expects($this->once())
8888
->method('getLocale')
8989
->willReturn('en_US');
90-
$this->assertRegexp(
90+
$this->assertRegExp(
9191
"/Eastern Standard Time \(America\/New_York\)/",
9292
$this->collectionTimeLabel->render($this->abstractElementMock)
9393
);

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testRender()
7474
$this->abstractElementMock->expects($this->any())
7575
->method('getComment')
7676
->willReturn('Subscription status: Enabled');
77-
$this->assertRegexp(
77+
$this->assertRegExp(
7878
"/Subscription status: Enabled/",
7979
$this->subscriptionStatusLabel->render($this->abstractElementMock)
8080
);

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testRender()
6565
->method('getHint')
6666
->willReturn('New hint');
6767
$html = $this->vertical->render($this->abstractElementMock);
68-
$this->assertRegexp(
68+
$this->assertRegExp(
6969
"/New comment/",
7070
$html
7171
);

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function getValue($index = null)
2626
{
2727
if ($index) {
2828
if ($data = $this->getData('value', 'orig_' . $index)) {
29-
// date('Y-m-d', strtotime($data));
3029
return $data;
3130
}
3231
return null;

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ public function getGridIdsJson()
277277
}
278278
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
279279
$allIdsCollection = clone $this->getParentBlock()->getCollection();
280-
280+
281281
if ($this->getMassactionIdField()) {
282282
$massActionIdField = $this->getMassactionIdField();
283283
} else {
284284
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
285285
}
286-
286+
287287
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
288288
if (!empty($gridIds)) {
289289
return join(",", $gridIds);

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ public function getGridIdsJson()
274274

275275
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
276276
$allIdsCollection = clone $this->getParentBlock()->getCollection();
277-
277+
278278
if ($this->getMassactionIdField()) {
279279
$massActionIdField = $this->getMassactionIdField();
280280
} else {
281281
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
282282
}
283-
283+
284284
$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
285285

286286
if (!empty($gridIds)) {

app/code/Magento/Braintree/Gateway/Response/CardDetailsHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function handle(array $handlingSubject, array $response)
8585
private function getCreditCardType($type)
8686
{
8787
$replaced = str_replace(' ', '-', strtolower($type));
88-
$mapper = $this->config->getCctypesMapper();
88+
$mapper = $this->config->getCcTypesMapper();
8989

9090
return $mapper[$replaced];
9191
}

app/code/Magento/Braintree/Gateway/Response/VaultDetailsHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function convertDetailsToJSON($details)
157157
private function getCreditCardType($type)
158158
{
159159
$replaced = str_replace(' ', '-', strtolower($type));
160-
$mapper = $this->config->getCctypesMapper();
160+
$mapper = $this->config->getCcTypesMapper();
161161

162162
return $mapper[$replaced];
163163
}

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getConfig()
7070
self::CODE => [
7171
'isActive' => $this->config->isActive($storeId),
7272
'clientToken' => $this->getClientToken(),
73-
'ccTypesMapper' => $this->config->getCctypesMapper(),
73+
'ccTypesMapper' => $this->config->getCcTypesMapper(),
7474
'sdkUrl' => $this->config->getSdkUrl(),
7575
'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig($storeId),
7676
'availableCardTypes' => $this->config->getAvailableCardTypes($storeId),

app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testGetCcTypesMapper($value, $expected)
142142

143143
static::assertEquals(
144144
$expected,
145-
$this->model->getCctypesMapper()
145+
$this->model->getCcTypesMapper()
146146
);
147147
}
148148

app/code/Magento/Catalog/Pricing/Price/ConfiguredRegularPrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function setItem(ItemInterface $item) : ConfiguredRegularPrice
6363

6464
return $this;
6565
}
66-
66+
6767
/**
6868
* Price value of product with configured options.
6969
*
@@ -73,7 +73,7 @@ public function getValue()
7373
{
7474
$basePrice = parent::getValue();
7575

76-
return $this->item
76+
return $this->item && $basePrice !== false
7777
? $basePrice + $this->configuredOptions->getItemOptionsValue($basePrice, $this->item)
7878
: $basePrice;
7979
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function getContext()
5858
$objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
5959
$objectManagerMock->expects($this->any())
6060
->method('get')
61-
->willreturn($productActionMock);
61+
->willReturn($productActionMock);
6262

6363
$eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class)
6464
->setMethods(['dispatch'])

app/code/Magento/Checkout/Setup/Patch/Data/PrepareInitialCheckoutConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public function apply()
817817

818818
$connection->commit();
819819
} catch (\Exception $e) {
820-
$connection->rollback();
820+
$connection->rollBack();
821821
throw $e;
822822
}
823823
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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\Checkout\Test\Unit\Model\Cart;
9+
10+
use Magento\Customer\Api\AddressRepositoryInterface;
11+
use Magento\Customer\Api\CustomerRepositoryInterface;
12+
use Magento\Customer\Api\Data\AddressInterface;
13+
use Magento\Customer\Api\Data\CustomerInterface;
14+
use Magento\Customer\Api\Data\RegionInterface;
15+
use Magento\Checkout\Model\Cart\CollectQuote;
16+
use Magento\Customer\Model\Session as CustomerSession;
17+
use Magento\Quote\Api\CartRepositoryInterface;
18+
use Magento\Quote\Api\Data\EstimateAddressInterface;
19+
use Magento\Quote\Api\Data\EstimateAddressInterfaceFactory;
20+
use Magento\Quote\Api\ShippingMethodManagementInterface;
21+
use Magento\Quote\Model\Quote;
22+
use PHPUnit\Framework\TestCase;
23+
24+
/**
25+
* Class CollectQuoteTest
26+
*/
27+
class CollectQuoteTest extends TestCase
28+
{
29+
/**
30+
* @var CollectQuote
31+
*/
32+
private $model;
33+
34+
/**
35+
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
private $customerSessionMock;
38+
39+
/**
40+
* @var CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
private $customerRepositoryMock;
43+
44+
/**
45+
* @var AddressRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
private $addressRepositoryMock;
48+
49+
/**
50+
* @var EstimateAddressInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
private $estimateAddressFactoryMock;
53+
54+
/**
55+
* @var EstimateAddressInterface|\PHPUnit_Framework_MockObject_MockObject
56+
*/
57+
private $estimateAddressMock;
58+
59+
/**
60+
* @var ShippingMethodManagementInterface|\PHPUnit_Framework_MockObject_MockObject
61+
*/
62+
private $shippingMethodManagerMock;
63+
64+
/**
65+
* @var CartRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
66+
*/
67+
private $quoteRepositoryMock;
68+
69+
/**
70+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
71+
*/
72+
private $quoteMock;
73+
74+
/**
75+
* @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
76+
*/
77+
private $customerMock;
78+
79+
/**
80+
* @var AddressInterface|\PHPUnit_Framework_MockObject_MockObject
81+
*/
82+
private $addressMock;
83+
84+
/**
85+
* Set up
86+
*/
87+
protected function setUp()
88+
{
89+
$this->customerSessionMock = $this->createMock(CustomerSession::class);
90+
$this->customerRepositoryMock = $this->getMockForAbstractClass(
91+
CustomerRepositoryInterface::class,
92+
[],
93+
'',
94+
false,
95+
true,
96+
true,
97+
['getById']
98+
);
99+
$this->addressRepositoryMock = $this->createMock(AddressRepositoryInterface::class);
100+
$this->estimateAddressMock = $this->createMock(EstimateAddressInterface::class);
101+
$this->estimateAddressFactoryMock =
102+
$this->createPartialMock(EstimateAddressInterfaceFactory::class, ['create']);
103+
$this->shippingMethodManagerMock = $this->createMock(ShippingMethodManagementInterface::class);
104+
$this->quoteRepositoryMock = $this->createMock(CartRepositoryInterface::class);
105+
$this->quoteMock = $this->createMock(Quote::class);
106+
$this->customerMock = $this->createMock(CustomerInterface::class);
107+
$this->addressMock = $this->createMock(AddressInterface::class);
108+
109+
$this->model = new CollectQuote(
110+
$this->customerSessionMock,
111+
$this->customerRepositoryMock,
112+
$this->addressRepositoryMock,
113+
$this->estimateAddressFactoryMock,
114+
$this->shippingMethodManagerMock,
115+
$this->quoteRepositoryMock
116+
);
117+
}
118+
119+
/**
120+
* Test collect method
121+
*/
122+
public function testCollect()
123+
{
124+
$customerId = 1;
125+
$defaultAddressId = 999;
126+
$countryId = 'USA';
127+
$regionId = 'CA';
128+
$regionMock = $this->createMock(RegionInterface::class);
129+
130+
$this->customerSessionMock->expects(self::once())
131+
->method('isLoggedIn')
132+
->willReturn(true);
133+
$this->customerSessionMock->expects(self::once())
134+
->method('getCustomerId')
135+
->willReturn($customerId);
136+
$this->customerRepositoryMock->expects(self::once())
137+
->method('getById')
138+
->willReturn($this->customerMock);
139+
$this->customerMock->expects(self::once())
140+
->method('getDefaultShipping')
141+
->willReturn($defaultAddressId);
142+
$this->addressMock->expects(self::once())
143+
->method('getCountryId')
144+
->willReturn($countryId);
145+
$regionMock->expects(self::once())
146+
->method('getRegion')
147+
->willReturn($regionId);
148+
$this->addressMock->expects(self::once())
149+
->method('getRegion')
150+
->willReturn($regionMock);
151+
$this->addressRepositoryMock->expects(self::once())
152+
->method('getById')
153+
->with($defaultAddressId)
154+
->willReturn($this->addressMock);
155+
$this->estimateAddressFactoryMock->expects(self::once())
156+
->method('create')
157+
->willReturn($this->estimateAddressMock);
158+
$this->quoteRepositoryMock->expects(self::once())
159+
->method('save')
160+
->with($this->quoteMock);
161+
162+
$this->model->collect($this->quoteMock);
163+
}
164+
165+
/**
166+
* Test with a not logged in customer
167+
*/
168+
public function testCollectWhenCustomerIsNotLoggedIn()
169+
{
170+
$this->customerSessionMock->expects(self::once())
171+
->method('isLoggedIn')
172+
->willReturn(false);
173+
$this->customerRepositoryMock->expects(self::never())
174+
->method('getById');
175+
176+
$this->model->collect($this->quoteMock);
177+
}
178+
}

app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ public function testGetDataWithVisibleAttributesWithAccountEdit()
12691269
$helper = new ObjectManager($this);
12701270
$context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class)
12711271
->setMethods(['getRequestParam'])
1272-
->getMockforAbstractClass();
1272+
->getMockForAbstractClass();
12731273
$context->expects($this->any())
12741274
->method('getRequestParam')
12751275
->with('request-field-name')

app/code/Magento/Downloadable/Block/Catalog/Product/Samples.php

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

77
namespace Magento\Downloadable\Block\Catalog\Product;
88

9-
use Magento\Downloadable\Model\ResourceModel\Sample;
9+
use Magento\Downloadable\Model\ResourceModel\Sample\Collection as SampleCollection;
10+
use Magento\Downloadable\Api\Data\SampleInterface;
1011

1112
/**
1213
* Downloadable Product Samples part block
@@ -29,15 +30,15 @@ public function hasSamples()
2930
/**
3031
* Get downloadable product samples
3132
*
32-
* @return array
33+
* @return SampleCollection
3334
*/
3435
public function getSamples()
3536
{
3637
return $this->getProduct()->getTypeInstance()->getSamples($this->getProduct());
3738
}
3839

3940
/**
40-
* @param Sample $sample
41+
* @param SampleInterface $sample
4142
* @return string
4243
*/
4344
public function getSampleUrl($sample)

app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected function setUp()
115115
$this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
116116
$this->connectionMock->expects($this->any())
117117
->method('describeTable')
118-
->will($this->returnvalueMap(
118+
->will($this->returnValueMap(
119119
[
120120
[
121121
'some_main_table',

0 commit comments

Comments
 (0)