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:
 - magento-engcom/php-7.2-support#32: Removed `create_function()` function usage (by @joni-jones)
 - magento-engcom/php-7.2-support#34: Made `getAllOptions()` and `toOptionArray()` compatible (by @joni-jones)
  • Loading branch information
magento-engcom-team committed Feb 8, 2018
2 parents 3aa0a16 + cd6e3b9 commit ec39184
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 149 deletions.
Expand Up @@ -42,9 +42,9 @@ public function __construct(
}

/**
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->_options) {
$groups = $this->_groupManagement->getLoggedInGroups();
Expand Down
Expand Up @@ -40,9 +40,9 @@ public function __construct(
}

/**
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->_options) {
$collection = $this->_createStoresCollection();
Expand Down
Expand Up @@ -32,9 +32,9 @@ public function __construct(
}

/**
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->_options) {
$this->_options = $this->_store->getWebsiteValuesForForm();
Expand Down
Expand Up @@ -45,11 +45,9 @@ public function __construct(
}

/**
* Retrieve all options
*
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->_options) {
$this->_options = $this->_createCountriesCollection()->loadByStore(
Expand Down
Expand Up @@ -67,11 +67,9 @@ public function __construct(
}

/**
* Retrieve all options
*
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->options) {
$allowedCountries = [];
Expand Down
Expand Up @@ -33,11 +33,9 @@ public function __construct(
}

/**
* Retrieve all region options
*
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->_options) {
$this->_options = $this->_createRegionsCollection()->load()->toOptionArray();
Expand Down
Expand Up @@ -16,11 +16,10 @@
class Full extends \Magento\Directory\Model\Config\Source\Country implements \Magento\Framework\Option\ArrayInterface
{
/**
* @param bool $isMultiselect
* @return array
* @inheritdoc
*/
public function toOptionArray($isMultiselect = false)
public function toOptionArray($isMultiselect = false, $foregroundCountries = '')
{
return parent::toOptionArray(true);
return parent::toOptionArray(true, $foregroundCountries);
}
}
5 changes: 2 additions & 3 deletions app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
Expand Up @@ -35,10 +35,9 @@ public function __construct(

/**
* Retrieve Full Option values array
*
* @return array
* @inheritdoc
*/
public function getAllOptions()
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if ($this->_options === null) {
$this->_options = $this->_storeCollectionFactory->create()->load()->toOptionArray();
Expand Down
Expand Up @@ -13,12 +13,11 @@ class Country extends \Magento\Directory\Model\Config\Source\Country
protected $_options;

/**
* @param bool $noEmpty
* @return array
* @inheritdoc
*/
public function toOptionArray($noEmpty = false)
public function toOptionArray($noEmpty = false, $foregroundCountries = '')
{
$options = parent::toOptionArray($noEmpty);
$options = parent::toOptionArray($noEmpty, $foregroundCountries);

if (!$noEmpty) {
if ($options) {
Expand Down
Expand Up @@ -5,61 +5,63 @@
*/
namespace Magento\Tax\Test\Unit\Plugin\Checkout\CustomerData;

class CartTest extends \PHPUnit\Framework\TestCase
use Magento\Checkout\CustomerData\Cart as CheckoutCart;
use Magento\Checkout\Helper\Data;
use Magento\Checkout\Model\Session;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Item;
use Magento\Tax\Block\Item\Price\Renderer;
use Magento\Tax\Plugin\Checkout\CustomerData\Cart;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class CartTest extends TestCase
{

/**
* @var \Magento\Checkout\Model\Session
* @var Session|MockObject
*/
protected $checkoutSession;
private $checkoutSession;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var Data|MockObject
*/
protected $checkoutHelper;
private $checkoutHelper;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var Renderer|MockObject
*/
protected $itemPriceRenderer;
private $itemPriceRenderer;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var CheckoutCart|MockObject
*/
protected $checkoutCart;
private $checkoutCart;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @var Quote|MockObject
*/
protected $quote;
private $quote;

/**
* @var \Magento\Tax\Plugin\Checkout\CustomerData\Cart
* @var Cart
*/
protected $cart;
private $cart;

protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class);
$this->checkoutHelper = $this->createMock(\Magento\Checkout\Helper\Data::class);
$this->itemPriceRenderer = $this->createMock(\Magento\Tax\Block\Item\Price\Renderer::class);
$this->checkoutCart = $this->createMock(\Magento\Checkout\CustomerData\Cart::class);
$this->quote = $this->createMock(\Magento\Quote\Model\Quote::class);

$this->checkoutSession->expects(
$this->any()
)->method(
'getQuote'
)->willReturn($this->quote);

$this->cart = $helper->getObject(
\Magento\Tax\Plugin\Checkout\CustomerData\Cart::class,
[
'checkoutSession' => $this->checkoutSession,
'checkoutHelper' => $this->checkoutHelper,
'itemPriceRenderer' => $this->itemPriceRenderer,
]
$this->checkoutSession = $this->createMock(Session::class);
$this->checkoutHelper = $this->createMock(Data::class);
$this->itemPriceRenderer = $this->createMock(Renderer::class);
$this->checkoutCart = $this->createMock(CheckoutCart::class);
$this->quote = $this->createMock(Quote::class);

$this->checkoutSession->method('getQuote')
->willReturn($this->quote);

$this->cart = new Cart(
$this->checkoutSession,
$this->checkoutHelper,
$this->itemPriceRenderer
);
}

Expand All @@ -77,49 +79,34 @@ public function testAfterGetSectionData()
]
];

$this->checkoutHelper->expects(
$this->atLeastOnce()
)->method(
'formatPrice'
)->willReturn('formatted');

$item1 = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
$item2 = $this->createMock(\Magento\Quote\Model\Quote\Item::class);

$item1->expects(
$this->atLeastOnce()
)->method(
'getItemId'
)->willReturn(1);
$item2->expects(
$this->atLeastOnce()
)->method(
'getItemId'
)->willReturn(2);

$this->quote->expects(
$this->any()
)->method(
'getAllVisibleItems'
)->willReturn([
$item1,
$item2,
]);

$this->itemPriceRenderer->expects(
$this->atLeastOnce(1)
)->method(
'toHtml'
)->willReturn(1);
$this->checkoutHelper->method('formatPrice')
->willReturn('formatted');

$item1 = $this->createMock(Item::class);
$item2 = $this->createMock(Item::class);

$item1->method('getItemId')
->willReturn(1);
$item2->method('getItemId')
->willReturn(2);

$this->quote->method('getAllVisibleItems')
->willReturn([
$item1,
$item2,
]);

$this->itemPriceRenderer->method('toHtml')
->willReturn(1);

$result = $this->cart->afterGetSectionData($this->checkoutCart, $input);

$this->assertArrayHasKey('subtotal_incl_tax', $result);
$this->assertArrayHasKey('subtotal_excl_tax', $result);
$this->assertArrayHasKey('items', $result);
$this->assertTrue(is_array($result['items']));
$this->assertEquals(2, count($result['items']));
$this->assertEquals(1, count($result['items'][0]['product_price']));
$this->assertEquals(1, count($result['items'][1]['product_price']));
self::assertArrayHasKey('subtotal_incl_tax', $result);
self::assertArrayHasKey('subtotal_excl_tax', $result);
self::assertArrayHasKey('items', $result);
self::assertTrue(is_array($result['items']));
self::assertEquals(2, count($result['items']));
self::assertEquals(1, $result['items'][0]['product_price']);
self::assertEquals(1, $result['items'][1]['product_price']);
}
}
Expand Up @@ -12,12 +12,7 @@ define([
'use strict';

describe('Magento_Ui/js/form/components/collection', function () {

var obj = new Constr({
provider: 'provName',
name: '',
index: ''
});
var obj;

registry.set('provName', {
/** Stub */
Expand All @@ -30,6 +25,12 @@ define([
set: function () {}
});

obj = new Constr({
provider: 'provName',
name: '',
index: ''
});

describe('"initElement" method', function () {
it('Check for defined ', function () {
expect(obj.hasOwnProperty('initElement')).toBeDefined();
Expand Down
Expand Up @@ -2528,4 +2528,5 @@
['_isAttributeValueEmpty', 'Magento\Catalog\Model\ResourceModel\AbstractResource'],
['var_dump', ''],
['each', ''],
['create_function', ''],
];

0 comments on commit ec39184

Please sign in to comment.