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

Commit ec39184

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #32: Removed `create_function()` function usage (by @joni-jones) - #34: Made `getAllOptions()` and `toOptionArray()` compatible (by @joni-jones)
2 parents 3aa0a16 + cd6e3b9 commit ec39184

File tree

13 files changed

+150
-149
lines changed

13 files changed

+150
-149
lines changed

app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function __construct(
4242
}
4343

4444
/**
45-
* @return array
45+
* @inheritdoc
4646
*/
47-
public function getAllOptions()
47+
public function getAllOptions($withEmpty = true, $defaultValues = false)
4848
{
4949
if (!$this->_options) {
5050
$groups = $this->_groupManagement->getLoggedInGroups();

app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function __construct(
4040
}
4141

4242
/**
43-
* @return array
43+
* @inheritdoc
4444
*/
45-
public function getAllOptions()
45+
public function getAllOptions($withEmpty = true, $defaultValues = false)
4646
{
4747
if (!$this->_options) {
4848
$collection = $this->_createStoresCollection();

app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function __construct(
3232
}
3333

3434
/**
35-
* @return array
35+
* @inheritdoc
3636
*/
37-
public function getAllOptions()
37+
public function getAllOptions($withEmpty = true, $defaultValues = false)
3838
{
3939
if (!$this->_options) {
4040
$this->_options = $this->_store->getWebsiteValuesForForm();

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ public function __construct(
4545
}
4646

4747
/**
48-
* Retrieve all options
49-
*
50-
* @return array
48+
* @inheritdoc
5149
*/
52-
public function getAllOptions()
50+
public function getAllOptions($withEmpty = true, $defaultValues = false)
5351
{
5452
if (!$this->_options) {
5553
$this->_options = $this->_createCountriesCollection()->loadByStore(

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ public function __construct(
6767
}
6868

6969
/**
70-
* Retrieve all options
71-
*
72-
* @return array
70+
* @inheritdoc
7371
*/
74-
public function getAllOptions()
72+
public function getAllOptions($withEmpty = true, $defaultValues = false)
7573
{
7674
if (!$this->options) {
7775
$allowedCountries = [];

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ public function __construct(
3333
}
3434

3535
/**
36-
* Retrieve all region options
37-
*
38-
* @return array
36+
* @inheritdoc
3937
*/
40-
public function getAllOptions()
38+
public function getAllOptions($withEmpty = true, $defaultValues = false)
4139
{
4240
if (!$this->_options) {
4341
$this->_options = $this->_createRegionsCollection()->load()->toOptionArray();

app/code/Magento/Directory/Model/Config/Source/Country/Full.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
class Full extends \Magento\Directory\Model\Config\Source\Country implements \Magento\Framework\Option\ArrayInterface
1717
{
1818
/**
19-
* @param bool $isMultiselect
20-
* @return array
19+
* @inheritdoc
2120
*/
22-
public function toOptionArray($isMultiselect = false)
21+
public function toOptionArray($isMultiselect = false, $foregroundCountries = '')
2322
{
24-
return parent::toOptionArray(true);
23+
return parent::toOptionArray(true, $foregroundCountries);
2524
}
2625
}

app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ public function __construct(
3535

3636
/**
3737
* Retrieve Full Option values array
38-
*
39-
* @return array
38+
* @inheritdoc
4039
*/
41-
public function getAllOptions()
40+
public function getAllOptions($withEmpty = true, $defaultValues = false)
4241
{
4342
if ($this->_options === null) {
4443
$this->_options = $this->_storeCollectionFactory->create()->load()->toOptionArray();

app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ class Country extends \Magento\Directory\Model\Config\Source\Country
1313
protected $_options;
1414

1515
/**
16-
* @param bool $noEmpty
17-
* @return array
16+
* @inheritdoc
1817
*/
19-
public function toOptionArray($noEmpty = false)
18+
public function toOptionArray($noEmpty = false, $foregroundCountries = '')
2019
{
21-
$options = parent::toOptionArray($noEmpty);
20+
$options = parent::toOptionArray($noEmpty, $foregroundCountries);
2221

2322
if (!$noEmpty) {
2423
if ($options) {

app/code/Magento/Tax/Test/Unit/Plugin/Checkout/CustomerData/CartTest.php

Lines changed: 62 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,63 @@
55
*/
66
namespace Magento\Tax\Test\Unit\Plugin\Checkout\CustomerData;
77

8-
class CartTest extends \PHPUnit\Framework\TestCase
8+
use Magento\Checkout\CustomerData\Cart as CheckoutCart;
9+
use Magento\Checkout\Helper\Data;
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Quote\Model\Quote;
12+
use Magento\Quote\Model\Quote\Item;
13+
use Magento\Tax\Block\Item\Price\Renderer;
14+
use Magento\Tax\Plugin\Checkout\CustomerData\Cart;
15+
use PHPUnit\Framework\TestCase;
16+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
17+
18+
class CartTest extends TestCase
919
{
10-
1120
/**
12-
* @var \Magento\Checkout\Model\Session
21+
* @var Session|MockObject
1322
*/
14-
protected $checkoutSession;
23+
private $checkoutSession;
1524

1625
/**
17-
* @var \PHPUnit_Framework_MockObject_MockObject
26+
* @var Data|MockObject
1827
*/
19-
protected $checkoutHelper;
28+
private $checkoutHelper;
2029

2130
/**
22-
* @var \PHPUnit_Framework_MockObject_MockObject
31+
* @var Renderer|MockObject
2332
*/
24-
protected $itemPriceRenderer;
33+
private $itemPriceRenderer;
2534

2635
/**
27-
* @var \PHPUnit_Framework_MockObject_MockObject
36+
* @var CheckoutCart|MockObject
2837
*/
29-
protected $checkoutCart;
38+
private $checkoutCart;
3039

3140
/**
32-
* @var \PHPUnit_Framework_MockObject_MockObject
41+
* @var Quote|MockObject
3342
*/
34-
protected $quote;
43+
private $quote;
3544

3645
/**
37-
* @var \Magento\Tax\Plugin\Checkout\CustomerData\Cart
46+
* @var Cart
3847
*/
39-
protected $cart;
48+
private $cart;
4049

4150
protected function setUp()
4251
{
43-
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
44-
$this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class);
45-
$this->checkoutHelper = $this->createMock(\Magento\Checkout\Helper\Data::class);
46-
$this->itemPriceRenderer = $this->createMock(\Magento\Tax\Block\Item\Price\Renderer::class);
47-
$this->checkoutCart = $this->createMock(\Magento\Checkout\CustomerData\Cart::class);
48-
$this->quote = $this->createMock(\Magento\Quote\Model\Quote::class);
49-
50-
$this->checkoutSession->expects(
51-
$this->any()
52-
)->method(
53-
'getQuote'
54-
)->willReturn($this->quote);
55-
56-
$this->cart = $helper->getObject(
57-
\Magento\Tax\Plugin\Checkout\CustomerData\Cart::class,
58-
[
59-
'checkoutSession' => $this->checkoutSession,
60-
'checkoutHelper' => $this->checkoutHelper,
61-
'itemPriceRenderer' => $this->itemPriceRenderer,
62-
]
52+
$this->checkoutSession = $this->createMock(Session::class);
53+
$this->checkoutHelper = $this->createMock(Data::class);
54+
$this->itemPriceRenderer = $this->createMock(Renderer::class);
55+
$this->checkoutCart = $this->createMock(CheckoutCart::class);
56+
$this->quote = $this->createMock(Quote::class);
57+
58+
$this->checkoutSession->method('getQuote')
59+
->willReturn($this->quote);
60+
61+
$this->cart = new Cart(
62+
$this->checkoutSession,
63+
$this->checkoutHelper,
64+
$this->itemPriceRenderer
6365
);
6466
}
6567

@@ -77,49 +79,34 @@ public function testAfterGetSectionData()
7779
]
7880
];
7981

80-
$this->checkoutHelper->expects(
81-
$this->atLeastOnce()
82-
)->method(
83-
'formatPrice'
84-
)->willReturn('formatted');
85-
86-
$item1 = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
87-
$item2 = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
88-
89-
$item1->expects(
90-
$this->atLeastOnce()
91-
)->method(
92-
'getItemId'
93-
)->willReturn(1);
94-
$item2->expects(
95-
$this->atLeastOnce()
96-
)->method(
97-
'getItemId'
98-
)->willReturn(2);
99-
100-
$this->quote->expects(
101-
$this->any()
102-
)->method(
103-
'getAllVisibleItems'
104-
)->willReturn([
105-
$item1,
106-
$item2,
107-
]);
108-
109-
$this->itemPriceRenderer->expects(
110-
$this->atLeastOnce(1)
111-
)->method(
112-
'toHtml'
113-
)->willReturn(1);
82+
$this->checkoutHelper->method('formatPrice')
83+
->willReturn('formatted');
84+
85+
$item1 = $this->createMock(Item::class);
86+
$item2 = $this->createMock(Item::class);
87+
88+
$item1->method('getItemId')
89+
->willReturn(1);
90+
$item2->method('getItemId')
91+
->willReturn(2);
92+
93+
$this->quote->method('getAllVisibleItems')
94+
->willReturn([
95+
$item1,
96+
$item2,
97+
]);
98+
99+
$this->itemPriceRenderer->method('toHtml')
100+
->willReturn(1);
114101

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

117-
$this->assertArrayHasKey('subtotal_incl_tax', $result);
118-
$this->assertArrayHasKey('subtotal_excl_tax', $result);
119-
$this->assertArrayHasKey('items', $result);
120-
$this->assertTrue(is_array($result['items']));
121-
$this->assertEquals(2, count($result['items']));
122-
$this->assertEquals(1, count($result['items'][0]['product_price']));
123-
$this->assertEquals(1, count($result['items'][1]['product_price']));
104+
self::assertArrayHasKey('subtotal_incl_tax', $result);
105+
self::assertArrayHasKey('subtotal_excl_tax', $result);
106+
self::assertArrayHasKey('items', $result);
107+
self::assertTrue(is_array($result['items']));
108+
self::assertEquals(2, count($result['items']));
109+
self::assertEquals(1, $result['items'][0]['product_price']);
110+
self::assertEquals(1, $result['items'][1]['product_price']);
124111
}
125112
}

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/collection.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ define([
1212
'use strict';
1313

1414
describe('Magento_Ui/js/form/components/collection', function () {
15-
16-
var obj = new Constr({
17-
provider: 'provName',
18-
name: '',
19-
index: ''
20-
});
15+
var obj;
2116

2217
registry.set('provName', {
2318
/** Stub */
@@ -30,6 +25,12 @@ define([
3025
set: function () {}
3126
});
3227

28+
obj = new Constr({
29+
provider: 'provName',
30+
name: '',
31+
index: ''
32+
});
33+
3334
describe('"initElement" method', function () {
3435
it('Check for defined ', function () {
3536
expect(obj.hasOwnProperty('initElement')).toBeDefined();

dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,4 +2528,5 @@
25282528
['_isAttributeValueEmpty', 'Magento\Catalog\Model\ResourceModel\AbstractResource'],
25292529
['var_dump', ''],
25302530
['each', ''],
2531+
['create_function', ''],
25312532
];

0 commit comments

Comments
 (0)