diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php index e70fc30d7a5..e590e5e213a 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php @@ -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(); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php index f70d0a91f35..85c23c98975 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php @@ -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(); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php index d670ed73db6..43c68f06d5f 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php @@ -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(); diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php index cf7105c1519..37b3b1af0a4 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php @@ -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( diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php index 3f45993a3e1..ce6278b4463 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php @@ -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 = []; diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php index 8e45e4a91ec..2cafdab077d 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php @@ -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(); diff --git a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php index f9b9463b16a..e3c4e17c4bd 100644 --- a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php +++ b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php @@ -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); } } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php index 00450088e86..cee4a06062d 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php @@ -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(); diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php index 19731403ae7..9707f3ae6e3 100644 --- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php +++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php @@ -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) { diff --git a/app/code/Magento/Tax/Test/Unit/Plugin/Checkout/CustomerData/CartTest.php b/app/code/Magento/Tax/Test/Unit/Plugin/Checkout/CustomerData/CartTest.php index effc54b84ac..88dce330b15 100644 --- a/app/code/Magento/Tax/Test/Unit/Plugin/Checkout/CustomerData/CartTest.php +++ b/app/code/Magento/Tax/Test/Unit/Plugin/Checkout/CustomerData/CartTest.php @@ -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 ); } @@ -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']); } }