Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #16824: [Forwardport] Fixed type hints and docs for Downloadable Samples block (by @ronak2ram)
 - #16815: [Forwardport] Covered Magento\Checkout\Model\Cart\CollectQuote by Unit Test (by @mage2pratik)
 - #16756: [forwardport] #16716 fix _utilities.less font-size issue (by @Karlasa)
 - #16363: [Forwardport] Fix case mismatch call (class/method) (by @lfluvisotto)
 - #16745: [Forwardport] typo in private method name getUniq[ue]ImageIndex (by @eduard13)
 - #15895: Handle type errors for objects creation (by @yuriyDne)
 - #16874: [Forwardport] Remove commented code & remove space (by @ronak2ram)
 - #16773: Improved code and remove unnecessary space (by @ronak2ram)
  • Loading branch information
Stanislav Idolov committed Jul 18, 2018
2 parents 9e9ec37 + d347270 commit 7968f8b
Show file tree
Hide file tree
Showing 47 changed files with 316 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected function setUp()
'_getCustomerGroupById',
'correctExportData'
]);
$this->advancedPricing = $this->getMockbuilder(
$this->advancedPricing = $this->getMockBuilder(
\Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class
)
->setMethods($mockMethods)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function testRender()
->method('getLabel')
->willReturn('Comment label');
$html = $this->additionalComment->render($this->abstractElementMock);
$this->assertRegexp(
$this->assertRegExp(
"/New comment/",
$html
);
$this->assertRegexp(
$this->assertRegExp(
"/Comment label/",
$html
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testRender()
$this->localeResolver->expects($this->once())
->method('getLocale')
->willReturn('en_US');
$this->assertRegexp(
$this->assertRegExp(
"/Eastern Standard Time \(America\/New_York\)/",
$this->collectionTimeLabel->render($this->abstractElementMock)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testRender()
$this->abstractElementMock->expects($this->any())
->method('getComment')
->willReturn('Subscription status: Enabled');
$this->assertRegexp(
$this->assertRegExp(
"/Subscription status: Enabled/",
$this->subscriptionStatusLabel->render($this->abstractElementMock)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testRender()
->method('getHint')
->willReturn('New hint');
$html = $this->vertical->render($this->abstractElementMock);
$this->assertRegexp(
$this->assertRegExp(
"/New comment/",
$html
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function getValue($index = null)
{
if ($index) {
if ($data = $this->getData('value', 'orig_' . $index)) {
// date('Y-m-d', strtotime($data));
return $data;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ public function getGridIdsJson()
}
/** @var \Magento\Framework\Data\Collection $allIdsCollection */
$allIdsCollection = clone $this->getParentBlock()->getCollection();

if ($this->getMassactionIdField()) {
$massActionIdField = $this->getMassactionIdField();
} else {
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
}

$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);
if (!empty($gridIds)) {
return join(",", $gridIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ public function getGridIdsJson()

/** @var \Magento\Framework\Data\Collection $allIdsCollection */
$allIdsCollection = clone $this->getParentBlock()->getCollection();

if ($this->getMassactionIdField()) {
$massActionIdField = $this->getMassactionIdField();
} else {
$massActionIdField = $this->getParentBlock()->getMassactionIdField();
}

$gridIds = $allIdsCollection->setPageSize(0)->getColumnValues($massActionIdField);

if (!empty($gridIds)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function handle(array $handlingSubject, array $response)
private function getCreditCardType($type)
{
$replaced = str_replace(' ', '-', strtolower($type));
$mapper = $this->config->getCctypesMapper();
$mapper = $this->config->getCcTypesMapper();

return $mapper[$replaced];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private function convertDetailsToJSON($details)
private function getCreditCardType($type)
{
$replaced = str_replace(' ', '-', strtolower($type));
$mapper = $this->config->getCctypesMapper();
$mapper = $this->config->getCcTypesMapper();

return $mapper[$replaced];
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getConfig()
self::CODE => [
'isActive' => $this->config->isActive($storeId),
'clientToken' => $this->getClientToken(),
'ccTypesMapper' => $this->config->getCctypesMapper(),
'ccTypesMapper' => $this->config->getCcTypesMapper(),
'sdkUrl' => $this->config->getSdkUrl(),
'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig($storeId),
'availableCardTypes' => $this->config->getAvailableCardTypes($storeId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testGetCcTypesMapper($value, $expected)

static::assertEquals(
$expected,
$this->model->getCctypesMapper()
$this->model->getCcTypesMapper()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function setItem(ItemInterface $item) : ConfiguredRegularPrice

return $this;
}

/**
* Price value of product with configured options.
*
Expand All @@ -73,7 +73,7 @@ public function getValue()
{
$basePrice = parent::getValue();

return $this->item
return $this->item && $basePrice !== false
? $basePrice + $this->configuredOptions->getItemOptionsValue($basePrice, $this->item)
: $basePrice;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getContext()
$objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
$objectManagerMock->expects($this->any())
->method('get')
->willreturn($productActionMock);
->willReturn($productActionMock);

$eventManager = $this->getMockBuilder(\Magento\Framework\Event\Manager::class)
->setMethods(['dispatch'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ public function apply()

$connection->commit();
} catch (\Exception $e) {
$connection->rollback();
$connection->rollBack();
throw $e;
}
}
Expand Down
178 changes: 178 additions & 0 deletions app/code/Magento/Checkout/Test/Unit/Model/Cart/CollectQuoteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Checkout\Test\Unit\Model\Cart;

use Magento\Customer\Api\AddressRepositoryInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\RegionInterface;
use Magento\Checkout\Model\Cart\CollectQuote;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\Data\EstimateAddressInterface;
use Magento\Quote\Api\Data\EstimateAddressInterfaceFactory;
use Magento\Quote\Api\ShippingMethodManagementInterface;
use Magento\Quote\Model\Quote;
use PHPUnit\Framework\TestCase;

/**
* Class CollectQuoteTest
*/
class CollectQuoteTest extends TestCase
{
/**
* @var CollectQuote
*/
private $model;

/**
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
*/
private $customerSessionMock;

/**
* @var CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $customerRepositoryMock;

/**
* @var AddressRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $addressRepositoryMock;

/**
* @var EstimateAddressInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $estimateAddressFactoryMock;

/**
* @var EstimateAddressInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $estimateAddressMock;

/**
* @var ShippingMethodManagementInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $shippingMethodManagerMock;

/**
* @var CartRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $quoteRepositoryMock;

/**
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
*/
private $quoteMock;

/**
* @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $customerMock;

/**
* @var AddressInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $addressMock;

/**
* Set up
*/
protected function setUp()
{
$this->customerSessionMock = $this->createMock(CustomerSession::class);
$this->customerRepositoryMock = $this->getMockForAbstractClass(
CustomerRepositoryInterface::class,
[],
'',
false,
true,
true,
['getById']
);
$this->addressRepositoryMock = $this->createMock(AddressRepositoryInterface::class);
$this->estimateAddressMock = $this->createMock(EstimateAddressInterface::class);
$this->estimateAddressFactoryMock =
$this->createPartialMock(EstimateAddressInterfaceFactory::class, ['create']);
$this->shippingMethodManagerMock = $this->createMock(ShippingMethodManagementInterface::class);
$this->quoteRepositoryMock = $this->createMock(CartRepositoryInterface::class);
$this->quoteMock = $this->createMock(Quote::class);
$this->customerMock = $this->createMock(CustomerInterface::class);
$this->addressMock = $this->createMock(AddressInterface::class);

$this->model = new CollectQuote(
$this->customerSessionMock,
$this->customerRepositoryMock,
$this->addressRepositoryMock,
$this->estimateAddressFactoryMock,
$this->shippingMethodManagerMock,
$this->quoteRepositoryMock
);
}

/**
* Test collect method
*/
public function testCollect()
{
$customerId = 1;
$defaultAddressId = 999;
$countryId = 'USA';
$regionId = 'CA';
$regionMock = $this->createMock(RegionInterface::class);

$this->customerSessionMock->expects(self::once())
->method('isLoggedIn')
->willReturn(true);
$this->customerSessionMock->expects(self::once())
->method('getCustomerId')
->willReturn($customerId);
$this->customerRepositoryMock->expects(self::once())
->method('getById')
->willReturn($this->customerMock);
$this->customerMock->expects(self::once())
->method('getDefaultShipping')
->willReturn($defaultAddressId);
$this->addressMock->expects(self::once())
->method('getCountryId')
->willReturn($countryId);
$regionMock->expects(self::once())
->method('getRegion')
->willReturn($regionId);
$this->addressMock->expects(self::once())
->method('getRegion')
->willReturn($regionMock);
$this->addressRepositoryMock->expects(self::once())
->method('getById')
->with($defaultAddressId)
->willReturn($this->addressMock);
$this->estimateAddressFactoryMock->expects(self::once())
->method('create')
->willReturn($this->estimateAddressMock);
$this->quoteRepositoryMock->expects(self::once())
->method('save')
->with($this->quoteMock);

$this->model->collect($this->quoteMock);
}

/**
* Test with a not logged in customer
*/
public function testCollectWhenCustomerIsNotLoggedIn()
{
$this->customerSessionMock->expects(self::once())
->method('isLoggedIn')
->willReturn(false);
$this->customerRepositoryMock->expects(self::never())
->method('getById');

$this->model->collect($this->quoteMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ public function testGetDataWithVisibleAttributesWithAccountEdit()
$helper = new ObjectManager($this);
$context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class)
->setMethods(['getRequestParam'])
->getMockforAbstractClass();
->getMockForAbstractClass();
$context->expects($this->any())
->method('getRequestParam')
->with('request-field-name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Magento\Downloadable\Block\Catalog\Product;

use Magento\Downloadable\Model\ResourceModel\Sample;
use Magento\Downloadable\Model\ResourceModel\Sample\Collection as SampleCollection;
use Magento\Downloadable\Api\Data\SampleInterface;

/**
* Downloadable Product Samples part block
Expand All @@ -29,15 +30,15 @@ public function hasSamples()
/**
* Get downloadable product samples
*
* @return array
* @return SampleCollection
*/
public function getSamples()
{
return $this->getProduct()->getTypeInstance()->getSamples($this->getProduct());
}

/**
* @param Sample $sample
* @param SampleInterface $sample
* @return string
*/
public function getSampleUrl($sample)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function setUp()
$this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
$this->connectionMock->expects($this->any())
->method('describeTable')
->will($this->returnvalueMap(
->will($this->returnValueMap(
[
[
'some_main_table',
Expand Down
Loading

0 comments on commit 7968f8b

Please sign in to comment.