diff --git a/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php b/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php index b28a223ef2dce..6bf9258f98fbe 100644 --- a/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php +++ b/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php @@ -1,4 +1,4 @@ -objectManager = new ObjectManager($this); diff --git a/app/code/Magento/Weee/Test/Unit/Block/Element/Weee/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Block/Element/Weee/TaxTest.php index 7145e56783c32..2b6e582174382 100644 --- a/app/code/Magento/Weee/Test/Unit/Block/Element/Weee/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Block/Element/Weee/TaxTest.php @@ -1,33 +1,44 @@ - '30000.4'], ]; $collectionFactory = $this->createPartialMock( - \Magento\Framework\Data\Form\Element\CollectionFactory::class, + CollectionFactory::class, ['create'] ); - $storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); + $storeManager = $this->createMock(StoreManager::class); - $localeCurrency = $this->createMock(\Magento\Framework\Locale\Currency::class); + $localeCurrency = $this->createMock(Currency::class); $currency = $this->createMock(\Magento\Framework\Currency::class); @@ -43,7 +54,7 @@ public function testGetEscapedValue() 'getCurrency' )->willReturn($currency); - $store = $this->createMock(\Magento\Store\Model\Store::class); + $store = $this->createMock(Store::class); $storeManager->expects( $this->any() @@ -51,10 +62,10 @@ public function testGetEscapedValue() 'getStore' )->willReturn($store); - $factory = $this->createMock(\Magento\Framework\Data\Form\Element\Factory::class); + $factory = $this->createMock(Factory::class); $this->model = $objectManager->getObject( - \Magento\Weee\Block\Element\Weee\Tax::class, + Tax::class, [ 'factoryElement' => $factory, 'factoryCollection' => $collectionFactory, @@ -64,7 +75,7 @@ public function testGetEscapedValue() ); $this->model->setValue($inputValue); - $this->model->setEntityAttribute(new \Magento\Framework\DataObject(['store_id' => 1])); + $this->model->setEntityAttribute(new DataObject(['store_id' => 1])); $return = $this->model->getEscapedValue(); $this->assertEquals( diff --git a/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php b/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php index 8b770ea763cdd..2cf5e5cfb7107 100644 --- a/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php +++ b/app/code/Magento/Weee/Test/Unit/Block/Item/Price/RendererTest.php @@ -1,42 +1,49 @@ -weeeHelper = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeHelper = $this->getMockBuilder(Data::class) ->disableOriginalConstructor() ->setMethods([ 'isEnabled', @@ -48,12 +55,12 @@ protected function setUp() ]) ->getMock(); - $this->priceCurrency = $this->getMockBuilder(\Magento\Directory\Model\PriceCurrency::class) + $this->priceCurrency = $this->getMockBuilder(PriceCurrency::class) ->disableOriginalConstructor() ->setMethods(['format']) ->getMock(); - $this->item = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) + $this->item = $this->getMockBuilder(Item::class) ->disableOriginalConstructor() ->setMethods([ '__wakeup', @@ -80,7 +87,7 @@ protected function setUp() ->will($this->returnValue(self::STORE_ID)); $this->renderer = $objectManager->getObject( - \Magento\Weee\Block\Item\Price\Renderer::class, + Renderer::class, [ 'weeeHelper' => $this->weeeHelper, 'priceCurrency' => $this->priceCurrency, diff --git a/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php b/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php index 7d0f6723976be..30b5844786fa7 100644 --- a/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php @@ -1,17 +1,30 @@ -product = $this->createMock(\Magento\Catalog\Model\Product::class); - $weeeConfig = $this->createMock(\Magento\Weee\Model\Config::class); + $this->product = $this->createMock(Product::class); + $weeeConfig = $this->createMock(Config::class); $weeeConfig->expects($this->any())->method('isEnabled')->will($this->returnValue(true)); $weeeConfig->expects($this->any())->method('getListPriceDisplayType')->will($this->returnValue(1)); - $this->weeeTax = $this->createMock(\Magento\Weee\Model\Tax::class); + $this->weeeTax = $this->createMock(Tax::class); $this->weeeTax->expects($this->any())->method('getWeeeAmount')->will($this->returnValue('11.26')); $this->taxData = $this->createPartialMock( \Magento\Tax\Helper\Data::class, ['getPriceDisplayType', 'priceIncludesTax'] ); - $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); + $this->serializerMock = $this->getMockBuilder(Json::class)->getMock(); $arguments = [ 'weeeConfig' => $weeeConfig, @@ -66,7 +79,7 @@ protected function setUp() 'taxData' => $this->taxData, 'serializer' => $this->serializerMock ]; - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $helper = new ObjectManager($this); $this->helperData = $helper->getObject(\Magento\Weee\Helper\Data::class, $arguments); } @@ -79,11 +92,11 @@ public function testGetAmount() } /** - * @return \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject + * @return Item|MockObject */ private function setupOrderItem() { - $orderItem = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) + $orderItem = $this->getMockBuilder(Item::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); @@ -192,7 +205,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, $fptCode1 = 'fpt' . $prodId1; $fptCode2 = 'fpt' . $prodId2; - $weeeObject1 = new \Magento\Framework\DataObject( + $weeeObject1 = new DataObject( [ 'code' => $fptCode1, 'amount' => '15', @@ -200,7 +213,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, 'tax_amount' => '1' ] ); - $weeeObject2 = new \Magento\Framework\DataObject( + $weeeObject2 = new DataObject( [ 'code' => $fptCode2, 'amount' => '10', @@ -208,7 +221,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, 'tax_amount' => '5' ] ); - $expectedObject1 = new \Magento\Framework\DataObject( + $expectedObject1 = new DataObject( [ 'code' => $fptCode1, 'amount' => $expectedAmount[0], @@ -216,7 +229,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, 'tax_amount' => '1' ] ); - $expectedObject2 = new \Magento\Framework\DataObject( + $expectedObject2 = new DataObject( [ 'code' => $fptCode2, 'amount' => $expectedAmount[1], @@ -236,7 +249,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, ->method('priceIncludesTax') ->willReturn($priceIncludesTax); - $productSimple = $this->createPartialMock(\Magento\Catalog\Model\Product\Type\Simple::class, ['getId']); + $productSimple = $this->createPartialMock(Simple::class, ['getId']); $productSimple->expects($this->at(0)) ->method('getId') ->will($this->returnValue($prodId1)); @@ -244,15 +257,15 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, ->method('getId') ->will($this->returnValue($prodId2)); - $productInstance = $this->createMock(\Magento\Bundle\Model\Product\Type::class); + $productInstance = $this->createMock(Type::class); $productInstance->expects($this->any()) ->method('getSelectionsCollection') ->will($this->returnValue([$productSimple])); - $store=$this->createMock(\Magento\Store\Model\Store::class); - /** @var \Magento\Catalog\Model\Product $product */ + $store=$this->createMock(Store::class); + /** @var Product $product */ $product = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, + Product::class, ['getTypeInstance', 'getStoreId', 'getStore', 'getTypeId'] ); $product->expects($this->any()) @@ -268,7 +281,7 @@ public function testGetWeeeAttributesForBundle($priceDisplay, $priceIncludesTax, ->method('getTypeId') ->will($this->returnValue('bundle')); - $registry=$this->createMock(\Magento\Framework\Registry::class); + $registry=$this->createMock(Registry::class); $registry->expects($this->any()) ->method('registry') ->with('current_product') @@ -431,7 +444,7 @@ public function testGetRecursiveAmountBundle() public function testGetProductWeeeAttributesForDisplay() { - $store = $this->createMock(\Magento\Store\Model\Store::class); + $store = $this->createMock(Store::class); $this->product->expects($this->any()) ->method('getStore') ->will($this->returnValue($store)); @@ -448,7 +461,7 @@ public function testGetTaxDisplayConfig() $arguments = [ 'taxData' => $taxData, ]; - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $helper = new ObjectManager($this); $helperData = $helper->getObject(\Magento\Weee\Helper\Data::class, $arguments); $this->assertEquals($expected, $helperData->getTaxDisplayConfig()); diff --git a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php index 7170969f5953e..804d686a8075a 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php @@ -1,4 +1,4 @@ -objectManager = new ObjectManager($this); } @@ -26,8 +30,8 @@ protected function setUp() public function testGetBackendModelName() { $this->assertEquals( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::getBackendModelName() + Tax::class, + Tax::getBackendModelName() ); } @@ -38,7 +42,7 @@ public function testGetBackendModelName() */ public function testValidate($data, $expected) { - $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Attribute::class) + $attributeMock = $this->getMockBuilder(Attribute::class) ->setMethods(['getName']) ->disableOriginalConstructor() ->getMock(); @@ -47,7 +51,7 @@ public function testValidate($data, $expected) ->method('getName') ->will($this->returnValue('weeeTax')); - $modelMock = $this->getMockBuilder(\Magento\Weee\Model\Attribute\Backend\Weee\Tax::class) + $modelMock = $this->getMockBuilder(Tax::class) ->setMethods(['getAttribute']) ->disableOriginalConstructor() ->getMock(); @@ -57,7 +61,7 @@ public function testValidate($data, $expected) ->will($this->returnValue($attributeMock)); $taxes = [reset($data)]; - $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productMock = $this->getMockBuilder(Product::class) ->setMethods(['getData']) ->disableOriginalConstructor() ->getMock(); @@ -70,7 +74,7 @@ public function testValidate($data, $expected) $modelMock->validate($productMock); $taxes = $data; - $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productMock = $this->getMockBuilder(Product::class) ->setMethods(['getData']) ->disableOriginalConstructor() ->getMock(); @@ -117,7 +121,7 @@ public function testAfterLoad() ->method('loadProductData') ->will($this->returnValue($data)); - $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Attribute::class) + $attributeMock = $this->getMockBuilder(Attribute::class) ->setMethods(['getName']) ->disableOriginalConstructor() ->getMock(); @@ -127,7 +131,7 @@ public function testAfterLoad() ->will($this->returnValue('weeeTax')); $model = $this->objectManager->getObject( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, + Tax::class, [ 'attributeTax' => $attributeTaxMock, '_attribute' => $attributeMock @@ -135,7 +139,7 @@ public function testAfterLoad() ); $model->setAttribute($attributeMock); - $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productMock = $this->getMockBuilder(Product::class) ->setMethods(['setData']) ->disableOriginalConstructor() ->getMock(); @@ -154,7 +158,7 @@ public function testAfterLoad() */ public function testAfterSaveWithRegion($origData, $currentData, $expectedData) { - $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $productMock = $this->getMockBuilder(Product::class) ->setMethods(['getOrigData', 'getData']) ->disableOriginalConstructor() ->getMock(); @@ -182,7 +186,7 @@ public function testAfterSaveWithRegion($origData, $currentData, $expectedData) ->with($productMock, $expectedData) ->will($this->returnValue(null)); - $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Attribute::class) + $attributeMock = $this->getMockBuilder(Attribute::class) ->setMethods(['getName', 'getId']) ->disableOriginalConstructor() ->getMock(); @@ -196,7 +200,7 @@ public function testAfterSaveWithRegion($origData, $currentData, $expectedData) ->will($this->returnValue(1)); $model = $this->objectManager->getObject( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, + Tax::class, [ 'attributeTax' => $attributeTaxMock, '_attribute' => $attributeMock @@ -239,7 +243,7 @@ public function testAfterDelete() ->will($this->returnValue(null)); $model = $this->objectManager->getObject( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, + Tax::class, [ 'attributeTax' => $attributeTaxMock, ] @@ -261,7 +265,7 @@ public function testGetTable() ->will($this->returnValue(null)); $model = $this->objectManager->getObject( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, + Tax::class, [ 'attributeTax' => $attributeTaxMock, ] @@ -288,7 +292,7 @@ public function testGetEntityIdField() : void ->willReturn(null); $model = $this->objectManager->getObject( - \Magento\Weee\Model\Attribute\Backend\Weee\Tax::class, + Tax::class, [ 'attributeTax' => $attributeTaxMock, ] diff --git a/app/code/Magento/Weee/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Weee/Test/Unit/Model/ConfigTest.php index a5663ec35e59c..52ad266c31ea3 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/ConfigTest.php @@ -1,4 +1,4 @@ -getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $scopeConfigMock->expects($this->any()) ->method('getValue') - ->with($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null) + ->with($path, ScopeInterface::SCOPE_STORE, null) ->will($this->returnValue($configValue)); $scopeConfigMock->expects($this->any()) ->method('isSetFlag') - ->with($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null) + ->with($path, ScopeInterface::SCOPE_STORE, null) ->will($this->returnValue($configValue)); - $taxData = $this->createMock(\Magento\Tax\Helper\Data::class); + $taxData = $this->createMock(Data::class); - /** @var \Magento\Weee\Model\Config */ + /** @var Config */ $model = new Config($scopeConfigMock, $taxData); $this->assertEquals($expectedValue, $model->{$method}()); } diff --git a/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/Attribute/Backend/Weee/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/Attribute/Backend/Weee/TaxTest.php index 01de2b8f7934e..b954d648532c2 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/Attribute/Backend/Weee/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/Attribute/Backend/Weee/TaxTest.php @@ -1,38 +1,47 @@ -storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->connectionMock = $this->createMock(AdapterInterface::class); - $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->resourceMock = $this->createMock(ResourceConnection::class); $this->resourceMock->expects($this->once()) ->method('getConnection') ->willReturn($this->connectionMock); @@ -41,10 +50,10 @@ protected function setUp() ->method('getTableName') ->willReturn('table_name'); - $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); + $contextMock = $this->createMock(Context::class); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); - $this->model = new \Magento\Weee\Model\ResourceModel\Attribute\Backend\Weee\Tax( + $this->model = new Tax( $contextMock, $this->storeManagerMock ); @@ -53,7 +62,7 @@ protected function setUp() public function testInsertProductData() { $productId = 100; - $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId']); + $productMock = $this->createPartialMock(Product::class, ['getId']); $productMock->expects($this->once())->method('getId')->willReturn($productId); $this->connectionMock->expects($this->once()) diff --git a/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/TaxTest.php index abb2e3f1e2438..3744fd2876114 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/ResourceModel/TaxTest.php @@ -1,51 +1,61 @@ -objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManager = new ObjectManager($this); - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); - $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class); + $this->selectMock = $this->createMock(Select::class); - $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->connectionMock = $this->createMock(AdapterInterface::class); $this->connectionMock->expects($this->once()) ->method('select') ->willReturn($this->selectMock); - $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->resourceMock = $this->createMock(ResourceConnection::class); $this->resourceMock->expects($this->any()) ->method('getConnection') ->willReturn($this->connectionMock); @@ -54,11 +64,11 @@ protected function setUp() ->method('getTableName') ->willReturn('table_name'); - $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); + $contextMock = $this->createMock(Context::class); $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock); - $this->model = $this->objectManager->getObject( - \Magento\Weee\Model\ResourceModel\Tax::class, + $this->model = $objectManager->getObject( + Tax::class, [ 'context' => $contextMock, ] diff --git a/app/code/Magento/Weee/Test/Unit/Model/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/TaxTest.php index ac90dfade07e2..9377da2ec65b8 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/TaxTest.php @@ -1,115 +1,136 @@ -objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); - $className = \Magento\Framework\Model\Context::class; + $className = Context::class; $this->context = $this->createMock($className); - $className = \Magento\Framework\Registry::class; + $className = Registry::class; $this->registry = $this->createMock($className); - $className = \Magento\Eav\Model\Entity\AttributeFactory::class; + $className = AttributeFactory::class; $this->attributeFactory = $this->createPartialMock($className, ['create']); - $className = \Magento\Store\Model\StoreManagerInterface::class; + $className = StoreManagerInterface::class; $this->storeManager = $this->createMock($className); - $className = \Magento\Tax\Model\CalculationFactory::class; + $className = CalculationFactory::class; $this->calculationFactory = $this->createPartialMock($className, ['create']); - $className = \Magento\Customer\Model\Session::class; + $className = Session::class; $this->customerSession = $this->createPartialMock( $className, ['getCustomerId', 'getDefaultTaxShippingAddress', 'getDefaultTaxBillingAddress', 'getCustomerTaxClassId'] @@ -119,26 +140,26 @@ protected function setUp() $this->customerSession->expects($this->any())->method('getDefaultTaxBillingAddress')->willReturn(null); $this->customerSession->expects($this->any())->method('getCustomerTaxClassId')->willReturn(null); - $className = \Magento\Customer\Api\AccountManagementInterface::class; + $className = AccountManagementInterface::class; $this->accountManagement = $this->createMock($className); - $className = \Magento\Tax\Helper\Data::class; + $className = Data::class; $this->taxData = $this->createMock($className); $className = \Magento\Weee\Model\ResourceModel\Tax::class; $this->resource = $this->createMock($className); - $className = \Magento\Weee\Model\Config::class; + $className = Config::class; $this->weeeConfig = $this->createMock($className); - $className = \Magento\Framework\Pricing\PriceCurrencyInterface::class; + $className = PriceCurrencyInterface::class; $this->priceCurrency = $this->createMock($className); - $className = \Magento\Framework\Data\Collection\AbstractDb::class; + $className = AbstractDb::class; $this->resourceCollection = $this->createMock($className); $this->model = $this->objectManager->getObject( - \Magento\Weee\Model\Tax::class, + Tax::class, [ 'context' => $this->context, 'registry' => $this->registry, @@ -168,15 +189,15 @@ public function testGetProductWeeeAttributes( $websitePassed, string $expectedFptLabel ): void { - $product = $this->createMock(\Magento\Catalog\Model\Product::class); - $website = $this->createMock(\Magento\Store\Model\Website::class); - $store = $this->createMock(\Magento\Store\Model\Store::class); - $group = $this->createMock(\Magento\Store\Model\Group::class); + $product = $this->createMock(Product::class); + $website = $this->createMock(Website::class); + $store = $this->createMock(Store::class); + $group = $this->createMock(Group::class); - $attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); - $calculation = $this->createMock(\Magento\Tax\Model\Calculation::class); + $attribute = $this->createMock(Attribute::class); + $calculation = $this->createMock(Calculation::class); - $obj = new \Magento\Framework\DataObject(['country' => 'US', 'region' => 'TX']); + $obj = new DataObject(['country' => 'US', 'region' => 'TX']); $calculation->expects($this->once()) ->method('getRateRequest') ->willReturn($obj); @@ -270,19 +291,19 @@ public function testGetProductWeeeAttributes( */ public function testGetWeeeAmountExclTax($productTypeId, $productPriceType) { - $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $product = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['getTypeId', 'getPriceType']) ->getMock(); $product->expects($this->any())->method('getTypeId')->willReturn($productTypeId); $product->expects($this->any())->method('getPriceType')->willReturn($productPriceType); - $weeeDataHelper = $this->getMockBuilder(\Magento\Framework\DataObject::class) + $weeeDataHelper = $this->getMockBuilder(DataObject::class) ->disableOriginalConstructor() ->setMethods(['getAmountExclTax']) ->getMock(); $weeeDataHelper->expects($this->at(0))->method('getAmountExclTax')->willReturn(10); $weeeDataHelper->expects($this->at(1))->method('getAmountExclTax')->willReturn(30); - $tax = $this->getMockBuilder(\Magento\Weee\Model\Tax::class) + $tax = $this->getMockBuilder(Tax::class) ->disableOriginalConstructor() ->setMethods(['getProductWeeeAttributes']) ->getMock(); @@ -296,16 +317,16 @@ public function testGetWeeeAmountExclTax($productTypeId, $productPriceType) */ public function testGetWeeeAmountExclTaxForDynamicBundleProduct() { - $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + $product = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['getTypeId', 'getPriceType']) ->getMock(); $product->expects($this->once())->method('getTypeId')->willReturn('bundle'); $product->expects($this->once())->method('getPriceType')->willReturn(0); - $weeeDataHelper = $this->getMockBuilder(\Magento\Framework\DataObject::class) + $weeeDataHelper = $this->getMockBuilder(DataObject::class) ->disableOriginalConstructor() ->getMock(); - $tax = $this->getMockBuilder(\Magento\Weee\Model\Tax::class) + $tax = $this->getMockBuilder(Tax::class) ->disableOriginalConstructor() ->setMethods(['getProductWeeeAttributes']) ->getMock(); diff --git a/app/code/Magento/Weee/Test/Unit/Model/Total/Creditmemo/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Model/Total/Creditmemo/WeeeTest.php index 409dd93cb2050..d0824a662598f 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Total/Creditmemo/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Total/Creditmemo/WeeeTest.php @@ -1,4 +1,4 @@ -weeeData = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeData = $this->getMockBuilder(Data::class) ->setMethods( [ 'getRowWeeeTaxInclTax', @@ -61,22 +71,22 @@ protected function setUp() )->disableOriginalConstructor() ->getMock(); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); $serializer = $this->objectManager->getObject(Json::class); - /** @var \Magento\Sales\Model\Order\Invoice\Total\Tax $model */ + /** @var Tax $model */ $this->model = $this->objectManager->getObject( - \Magento\Weee\Model\Total\Creditmemo\Weee::class, + Weee::class, [ 'weeeData' => $this->weeeData, 'serializer' => $serializer ] ); - $this->order = $this->createPartialMock(\Magento\Sales\Model\Order::class, [ + $this->order = $this->createPartialMock(Order::class, [ '__wakeup' ]); - $this->creditmemo = $this->createPartialMock(\Magento\Sales\Model\Order\Creditmemo::class, [ + $this->creditmemo = $this->createPartialMock(Creditmemo::class, [ 'getAllItems', 'getInvoice', 'roundPrice', @@ -100,7 +110,7 @@ public function testCollect($creditmemoData, $expectedResults) ->will($this->returnValue($creditmemoData['include_in_subtotal'])); //Set up invoice mock - /** @var \Magento\Sales\Model\Order\Invoice\Item[] $creditmemoItems */ + /** @var Item[] $creditmemoItems */ $creditmemoItems = []; foreach ($creditmemoData['items'] as $itemKey => $creditmemoItemData) { $creditmemoItems[$itemKey] = $this->getInvoiceItem($creditmemoItemData); @@ -132,7 +142,7 @@ function ($price, $type) use (&$roundingDelta) { $this->assertEquals( $value, $this->creditmemo->getData($key), - 'Creditmemo data field '.$key.' is incorrect' + 'Creditmemo data field ' . $key . ' is incorrect' ); } //verify invoice item data @@ -146,7 +156,7 @@ function ($price, $type) use (&$roundingDelta) { $this->assertEquals( $value, $creditmemoItem->getData($key), - 'Creditmemo item field '.$key.' is incorrect' + 'Creditmemo item field ' . $key . ' is incorrect' ); } } @@ -485,11 +495,11 @@ public function collectDataProvider() /** * @param $creditmemoItemData array - * @return \Magento\Sales\Model\Order\Creditmemo\Item|\PHPUnit_Framework_MockObject_MockObject + * @return \Magento\Sales\Model\Order\Creditmemo\Item|MockObject */ protected function getInvoiceItem($creditmemoItemData) { - /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject $orderItem */ + /** @var \Magento\Sales\Model\Order\Item|MockObject $orderItem */ $orderItem = $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, [ 'isDummy', '__wakeup' @@ -539,8 +549,8 @@ protected function getInvoiceItem($creditmemoItemData) ->with($orderItem) ->will($this->returnValue($orderItem->getBaseWeeeTaxAmountRefunded())); - /** @var \Magento\Sales\Model\Order\Invoice\Item|\PHPUnit_Framework_MockObject_MockObject $invoiceItem */ - $invoiceItem = $this->createPartialMock(\Magento\Sales\Model\Order\Invoice\Item::class, [ + /** @var Item|MockObject $invoiceItem */ + $invoiceItem = $this->createPartialMock(Item::class, [ 'getOrderItem', 'isLast', '__wakeup' diff --git a/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php index 22d673e0c8b26..8d3b334b5125c 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php @@ -1,4 +1,4 @@ -weeeData = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeData = $this->getMockBuilder(Data::class) ->setMethods( [ 'getRowWeeeTaxInclTax', @@ -52,22 +61,22 @@ protected function setUp() )->disableOriginalConstructor() ->getMock(); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); $serializer = $this->objectManager->getObject(Json::class); - /** @var \Magento\Sales\Model\Order\Invoice\Total\Tax $model */ + /** @var Tax $model */ $this->model = $this->objectManager->getObject( - \Magento\Weee\Model\Total\Invoice\Weee::class, + Weee::class, [ 'weeeData' => $this->weeeData, 'serializer' => $serializer ] ); - $this->order = $this->createPartialMock(\Magento\Sales\Model\Order::class, [ + $this->order = $this->createPartialMock(Order::class, [ '__wakeup' ]); - $this->invoice = $this->createPartialMock(\Magento\Sales\Model\Order\Invoice::class, [ + $this->invoice = $this->createPartialMock(Invoice::class, [ 'getAllItems', 'getOrder', 'roundPrice', @@ -107,7 +116,7 @@ public function testCollect($orderData, $invoiceData, $expectedResults) ->will($this->returnValue($invoiceData['include_in_subtotal'])); //Set up invoice mock - /** @var \Magento\Sales\Model\Order\Invoice\Item[] $invoiceItems */ + /** @var Item[] $invoiceItems */ $invoiceItems = []; foreach ($invoiceData['items'] as $itemKey => $invoiceItemData) { $invoiceItems[$itemKey] = $this->getInvoiceItem($invoiceItemData); @@ -139,7 +148,7 @@ function ($price, $type) use (&$roundingDelta) { //verify invoice data foreach ($expectedResults['invoice_data'] as $key => $value) { - $this->assertEquals($value, $this->invoice->getData($key), 'Invoice data field '.$key.' is incorrect'); + $this->assertEquals($value, $this->invoice->getData($key), 'Invoice data field ' . $key . ' is incorrect'); } //verify invoice item data foreach ($expectedResults['invoice_items'] as $itemKey => $itemData) { @@ -152,7 +161,7 @@ function ($price, $type) use (&$roundingDelta) { $this->assertEquals( $value, $invoiceItem->getData($key), - 'Invoice item field '.$key.' is incorrect' + 'Invoice item field ' . $key . ' is incorrect' ); } } @@ -671,11 +680,11 @@ public function collectDataProvider() /** * @param $invoiceItemData array - * @return \Magento\Sales\Model\Order\Invoice\Item|\PHPUnit_Framework_MockObject_MockObject + * @return Item|MockObject */ protected function getInvoiceItem($invoiceItemData) { - /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject $orderItem */ + /** @var \Magento\Sales\Model\Order\Item|MockObject $orderItem */ $orderItem = $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, [ 'isDummy', '__wakeup' @@ -710,8 +719,8 @@ protected function getInvoiceItem($invoiceItemData) ->with($orderItem) ->will($this->returnValue($orderItem->getBaseWeeeTaxAmountInvoiced())); } - /** @var \Magento\Sales\Model\Order\Invoice\Item|\PHPUnit_Framework_MockObject_MockObject $invoiceItem */ - $invoiceItem = $this->createPartialMock(\Magento\Sales\Model\Order\Invoice\Item::class, [ + /** @var Item|MockObject $invoiceItem */ + $invoiceItem = $this->createPartialMock(Item::class, [ 'getOrderItem', 'isLast', '__wakeup' diff --git a/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTaxTest.php index 51cba29199abb..abb242cc9db6c 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTaxTest.php @@ -1,17 +1,30 @@ -objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); + $this->objectManagerHelper = new ObjectManager($this); + $this->quoteMock = $this->createMock(Quote::class); } /** * Setup tax helper with an array of methodName, returnValue * * @param array $taxConfig - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Helper\Data + * @return MockObject|\Magento\Tax\Helper\Data */ protected function setupTaxHelper($taxConfig) { - $taxHelper = $this->createMock(\Magento\Tax\Helper\Data::class); + $taxHelper = $this->createMock(Data::class); foreach ($taxConfig as $method => $value) { $taxHelper->expects($this->any())->method($method)->will($this->returnValue($value)); @@ -62,7 +74,7 @@ protected function setupTaxHelper($taxConfig) * Setup weee helper with an array of methodName, returnValue * * @param array $weeeConfig - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Weee\Helper\Data + * @return MockObject|\Magento\Weee\Helper\Data */ protected function setupWeeeHelper($weeeConfig) { @@ -79,11 +91,11 @@ protected function setupWeeeHelper($weeeConfig) * Setup an item mock * * @param float $itemQty - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item + * @return MockObject|Item */ protected function setupItemMock($itemQty) { - $itemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [ + $itemMock = $this->createPartialMock(Item::class, [ 'getProduct', 'getQuote', 'getAddress', @@ -91,7 +103,7 @@ protected function setupItemMock($itemQty) '__wakeup', ]); - $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $productMock = $this->createMock(Product::class); $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock)); $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($itemQty)); @@ -101,15 +113,15 @@ protected function setupItemMock($itemQty) /** * Setup address mock * - * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item $itemMock + * @param MockObject|Item $itemMock * @param boolean $isWeeeTaxable * @param array $itemWeeeTaxDetails * @param array $addressData - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ protected function setupTotalMock($itemMock, $isWeeeTaxable, $itemWeeeTaxDetails, $addressData) { - $totalMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Total::class, [ + $totalMock = $this->createPartialMock(Total::class, [ '__wakeup', 'getWeeeCodeToItemMap', 'getExtraTaxableDetails', @@ -125,24 +137,21 @@ protected function setupTotalMock($itemMock, $isWeeeTaxable, $itemWeeeTaxDetails if ($isWeeeTaxable) { $i = 1; $weeeTaxDetails = []; - foreach ($itemWeeeTaxDetails as $itemData) { - $code = 'weee' . $i++ . '-myWeeeCode'; + foreach ($itemWeeeTaxDetails as $data) { + $code = 'weee' . ($i++) . '-myWeeeCode'; $map[$code] = $itemMock; $weeeTaxDetails[] = [ CTC::KEY_TAX_DETAILS_TYPE => 'weee', CTC::KEY_TAX_DETAILS_CODE => $code, - CTC::KEY_TAX_DETAILS_PRICE_EXCL_TAX => $itemData['weee_tax_applied_amount'], - CTC::KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX => $itemData['base_weee_tax_applied_amount'], - CTC::KEY_TAX_DETAILS_PRICE_INCL_TAX => $itemData['weee_tax_applied_amount_incl_tax'], - CTC::KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX => - $itemData['base_weee_tax_applied_amount_incl_tax'], - CTC::KEY_TAX_DETAILS_ROW_TOTAL => $itemData['weee_tax_applied_row_amount'], - CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL => $itemData['base_weee_tax_applied_row_amnt'], - CTC::KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX => - $itemData['weee_tax_applied_row_amount_incl_tax'], - CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX => - $itemData['base_weee_tax_applied_row_amnt_incl_tax'], - ]; + CTC::KEY_TAX_DETAILS_PRICE_EXCL_TAX => $data['weee_tax_applied_amount'], + CTC::KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX => $data['base_weee_tax_applied_amount'], + CTC::KEY_TAX_DETAILS_PRICE_INCL_TAX => $data['weee_tax_applied_amount_incl_tax'], + CTC::KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX => $data['base_weee_tax_applied_amount_incl_tax'], + CTC::KEY_TAX_DETAILS_ROW_TOTAL => $data['weee_tax_applied_row_amount'], + CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL => $data['base_weee_tax_applied_row_amnt'], + CTC::KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX => $data['weee_tax_applied_row_amount_incl_tax'], + CTC::KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX => $data['base_weee_tax_applied_row_amnt_incl_tax'], + ]; } $extraDetails = [ 'weee' => [ @@ -174,15 +183,15 @@ protected function setupTotalMock($itemMock, $isWeeeTaxable, $itemWeeeTaxDetails /** * Setup shipping assignment mock. - * @param \PHPUnit_Framework_MockObject_MockObject $addressMock - * @param \PHPUnit_Framework_MockObject_MockObject $itemMock - * @return \PHPUnit_Framework_MockObject_MockObject + * @param MockObject $addressMock + * @param MockObject $itemMock + * @return MockObject */ protected function setupShippingAssignmentMock($addressMock, $itemMock) { - $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class); + $shippingMock = $this->createMock(ShippingInterface::class); $shippingMock->expects($this->any())->method('getAddress')->willReturn($addressMock); - $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); + $shippingAssignmentMock = $this->createMock(ShippingAssignmentInterface::class); $itemMock = $itemMock ? [$itemMock] : []; $shippingAssignmentMock->expects($this->any())->method('getItems')->willReturn($itemMock); $shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shippingMock); @@ -193,7 +202,7 @@ protected function setupShippingAssignmentMock($addressMock, $itemMock) /** * Verify that correct fields of item has been set * - * @param \PHPUnit_Framework_MockObject_MockObject|null $item + * @param MockObject|null $item * @param array $itemData */ public function verifyItem($item, $itemData) @@ -209,7 +218,7 @@ public function verifyItem($item, $itemData) /** * Verify that correct fields of address has been set * - * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address + * @param MockObject|Address $address * @param array $addressData */ public function verifyTotals($address, $addressData) @@ -224,16 +233,16 @@ public function verifyTotals($address, $addressData) public function testFetch() { - $serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); + $serializerMock = $this->getMockBuilder(Json::class)->getMock(); $weeeTotal = 17; - $totalMock = new \Magento\Quote\Model\Quote\Address\Total( + $totalMock = new Total( [], $serializerMock ); $taxHelper = $this->setupTaxHelper([]); $weeeHelper = $this->setupWeeeHelper(['getTotalAmounts' => $weeeTotal]); $this->weeeCollector = $this->objectManagerHelper->getObject( - \Magento\Weee\Model\Total\Quote\WeeeTax::class, + WeeeTax::class, ['taxData' => $taxHelper, 'weeeData' => $weeeHelper] ); $expectedResult = [ @@ -248,15 +257,15 @@ public function testFetch() public function testFetchWithZeroAmounts() { - $serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); - $totalMock = new \Magento\Quote\Model\Quote\Address\Total( + $serializerMock = $this->getMockBuilder(Json::class)->getMock(); + $totalMock = new Total( [], $serializerMock ); $taxHelper = $this->setupTaxHelper([]); $weeeHelper = $this->setupWeeeHelper(['getTotalAmounts' => null]); $this->weeeCollector = $this->objectManagerHelper->getObject( - \Magento\Weee\Model\Total\Quote\WeeeTax::class, + WeeeTax::class, ['taxData' => $taxHelper, 'weeeData' => $weeeHelper] ); @@ -282,7 +291,7 @@ public function testCollect($taxConfig, $weeeConfig, $itemWeeeTaxDetails, $itemQ $itemMock = null; } $totalMock = $this->setupTotalMock($itemMock, $weeeConfig['isTaxable'], $itemWeeeTaxDetails, $addressData); - $addressMock = $this->createMock(\Magento\Quote\Model\Quote\Address::class); + $addressMock = $this->createMock(Address::class); $shippingAssignmentMock = $this->setupShippingAssignmentMock($addressMock, $itemMock); $taxHelper = $this->setupTaxHelper($taxConfig); @@ -294,7 +303,7 @@ public function testCollect($taxConfig, $weeeConfig, $itemWeeeTaxDetails, $itemQ ]; $this->weeeCollector = $this->objectManagerHelper->getObject( - \Magento\Weee\Model\Total\Quote\WeeeTax::class, + WeeeTax::class, $arguments ); diff --git a/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTest.php index 91cb2b5745bac..9c74ffae26993 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTest.php @@ -1,19 +1,35 @@ -createMock(\Magento\Tax\Helper\Data::class); + $taxHelper = $this->createMock(Data::class); foreach ($taxConfig as $method => $value) { $taxHelper->expects($this->any())->method($method)->will($this->returnValue($value)); @@ -45,7 +61,7 @@ protected function setupTaxHelper($taxConfig) * Setup calculator to return tax rates * * @param array $taxRates - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Model\Calculation + * @return MockObject|Calculation */ protected function setupTaxCalculation($taxRates) { @@ -53,12 +69,12 @@ protected function setupTaxCalculation($taxRates) $customerTaxRate = $taxRates['customer_tax_rate']; $taxCalculation = $this->createPartialMock( - \Magento\Tax\Model\Calculation::class, + Calculation::class, ['getRateOriginRequest', 'getRateRequest', 'getRate'] ); - $rateRequest = new \Magento\Framework\DataObject(); - $defaultRateRequest = new \Magento\Framework\DataObject(); + $rateRequest = new DataObject(); + $defaultRateRequest = new DataObject(); $taxCalculation->expects($this->any())->method('getRateRequest')->will($this->returnValue($rateRequest)); $taxCalculation @@ -78,11 +94,11 @@ protected function setupTaxCalculation($taxRates) * Setup weee helper with an array of methodName, returnValue * * @param array $weeeConfig - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Weee\Helper\Data + * @return MockObject|\Magento\Weee\Helper\Data */ protected function setupWeeeHelper($weeeConfig) { - $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock(); + $this->serializerMock = $this->getMockBuilder(Json::class)->getMock(); $weeeHelper = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) ->setConstructorArgs(['serializer' => $this->serializerMock]) @@ -100,11 +116,11 @@ protected function setupWeeeHelper($weeeConfig) * Setup the basics of an item mock * * @param float $itemTotalQty - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item + * @return MockObject|Item */ protected function setupItemMockBasics($itemTotalQty) { - $itemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [ + $itemMock = $this->createPartialMock(Item::class, [ 'getProduct', 'getQuote', 'getAddress', @@ -116,7 +132,7 @@ protected function setupItemMockBasics($itemTotalQty) '__wakeup', ]); - $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $productMock = $this->createMock(Product::class); $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock)); $itemMock->expects($this->any())->method('getTotalQty')->will($this->returnValue($itemTotalQty)); @@ -127,7 +143,7 @@ protected function setupItemMockBasics($itemTotalQty) * Setup an item mock * * @param float $itemQty - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item + * @return MockObject|Item */ protected function setupItemMock($itemQty) { @@ -146,7 +162,7 @@ protected function setupItemMock($itemQty) * * @param float $parentQty * @param float $itemQty - * @return \PHPUnit_Framework_MockObject_MockObject[]|\Magento\Quote\Model\Quote\Item[] + * @return MockObject[]|Item[] */ protected function setupParentItemWithChildrenMock($parentQty, $itemQty) { @@ -173,22 +189,22 @@ protected function setupParentItemWithChildrenMock($parentQty, $itemQty) /** * Setup address mock * - * @param \PHPUnit_Framework_MockObject_MockObject[]|\Magento\Quote\Model\Quote\Item[] $items - * @return \PHPUnit_Framework_MockObject_MockObject + * @param MockObject[]|Item[] $items + * @return MockObject */ protected function setupAddressMock($items) { - $addressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [ + $addressMock = $this->createPartialMock(Address::class, [ '__wakeup', 'getAllItems', 'getQuote', 'getCustomAttributesCodes' ]); - $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); - $storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $quoteMock = $this->createMock(Quote::class); + $storeMock = $this->createMock(Store::class); $this->priceCurrency = $this->getMockBuilder( - \Magento\Framework\Pricing\PriceCurrencyInterface::class + PriceCurrencyInterface::class )->getMock(); $this->priceCurrency->expects($this->any())->method('round')->willReturnArgument(0); $this->priceCurrency->expects($this->any())->method('convert')->willReturnArgument(0); @@ -203,15 +219,15 @@ protected function setupAddressMock($items) /** * Setup shipping assignment mock. - * @param \PHPUnit_Framework_MockObject_MockObject $addressMock - * @param \PHPUnit_Framework_MockObject_MockObject $itemMock - * @return \PHPUnit_Framework_MockObject_MockObject + * @param MockObject $addressMock + * @param MockObject $itemMock + * @return MockObject */ protected function setupShippingAssignmentMock($addressMock, $itemMock) { - $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class); + $shippingMock = $this->createMock(ShippingInterface::class); $shippingMock->expects($this->any())->method('getAddress')->willReturn($addressMock); - $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); + $shippingAssignmentMock = $this->createMock(ShippingAssignmentInterface::class); $shippingAssignmentMock->expects($this->any())->method('getItems')->willReturn($itemMock); $shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shippingMock); @@ -221,10 +237,10 @@ protected function setupShippingAssignmentMock($addressMock, $itemMock) /** * Verify that correct fields of item has been set * - * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Item $item + * @param MockObject|Item $item * @param $itemData */ - public function verifyItem(\Magento\Quote\Model\Quote\Item $item, $itemData) + public function verifyItem(Item $item, $itemData) { foreach ($itemData as $key => $value) { $this->assertEquals($value, $item->getData($key), 'item ' . $key . ' is incorrect'); @@ -234,7 +250,7 @@ public function verifyItem(\Magento\Quote\Model\Quote\Item $item, $itemData) /** * Verify that correct fields of address has been set * - * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\Quote\Address $address + * @param MockObject|Address $address * @param $addressData */ public function verifyAddress($address, $addressData) @@ -274,13 +290,13 @@ public function testCollect( $itemMock = $this->setupItemMock($itemQty); $items[] = $itemMock; } - $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); - $storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $quoteMock = $this->createMock(Quote::class); + $storeMock = $this->createMock(Store::class); $quoteMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $addressMock = $this->setupAddressMock($items); - $totalMock = new \Magento\Quote\Model\Quote\Address\Total( + $totalMock = new Total( [], - $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock() + $this->getMockBuilder(Json::class)->getMock() ); $shippingAssignmentMock = $this->setupShippingAssignmentMock($addressMock, $items); @@ -335,8 +351,8 @@ public function testCollect( 'priceCurrency' => $this->priceCurrency ]; - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->weeeCollector = $helper->getObject(\Magento\Weee\Model\Total\Quote\Weee::class, $arguments); + $helper = new ObjectManager($this); + $this->weeeCollector = $helper->getObject(Weee::class, $arguments); $this->weeeCollector->collect($quoteMock, $shippingAssignmentMock, $totalMock); @@ -371,7 +387,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -412,7 +428,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -453,7 +469,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -494,7 +510,7 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -537,7 +553,7 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -580,7 +596,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -621,7 +637,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -662,7 +678,7 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -705,7 +721,7 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -748,7 +764,7 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -791,7 +807,7 @@ public function collectDataProvider() 'isTaxable' => true, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, @@ -834,13 +850,13 @@ public function collectDataProvider() 'isTaxable' => false, 'getApplied' => [], 'getProductWeeeAttributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'Recycling Fee', 'amount' => 10, ] ), - new \Magento\Framework\DataObject( + new DataObject( [ 'name' => 'FPT Fee', 'amount' => 5, diff --git a/app/code/Magento/Weee/Test/Unit/Model/WeeeConfigProviderTest.php b/app/code/Magento/Weee/Test/Unit/Model/WeeeConfigProviderTest.php index d42d123f927c0..9d03cd7443b90 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/WeeeConfigProviderTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/WeeeConfigProviderTest.php @@ -1,47 +1,55 @@ -weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class); - $this->weeeConfigMock = $this->createMock(\Magento\Weee\Model\Config::class); - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->weeeHelperMock = $this->createMock(Data::class); + $this->weeeConfigMock = $this->createMock(Config::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->storeMock = $this->createMock(Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock)); - $this->model = new \Magento\Weee\Model\WeeeConfigProvider( + $this->model = new WeeeConfigProvider( $this->weeeHelperMock, $this->storeManagerMock, $this->weeeConfigMock diff --git a/app/code/Magento/Weee/Test/Unit/Observer/AddPaymentWeeeItemTest.php b/app/code/Magento/Weee/Test/Unit/Observer/AddPaymentWeeeItemTest.php index dd0547354cfa4..d33474e05f86a 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/AddPaymentWeeeItemTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/AddPaymentWeeeItemTest.php @@ -17,12 +17,9 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Weee\Helper\Data; use Magento\Weee\Observer\AddPaymentWeeeItem; +use PHPUnit\Framework\MockObject\MockObject as MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -/** - * Class AddPaymentWeeeItemTest - */ class AddPaymentWeeeItemTest extends TestCase { /** @@ -45,7 +42,7 @@ class AddPaymentWeeeItemTest extends TestCase /** * Set Up */ - protected function setUp() + protected function setUp(): void { $this->weeeHelperMock = $this->createMock(Data::class); $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); diff --git a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php index 868d603f34b8c..7397728b30691 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php @@ -1,18 +1,22 @@ -objectManager = new ObjectManager($this); - $this->observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) + $this->observerMock = $this->getMockBuilder(Observer::class) ->disableOriginalConstructor() ->setMethods(['getCustomerAddress']) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) + $this->moduleManagerMock = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->cacheConfigMock = $this->getMockBuilder(\Magento\PageCache\Model\Config::class) + $this->cacheConfigMock = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); - $this->weeeHelperMock = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeHelperMock = $this->getMockBuilder(Data::class) ->disableOriginalConstructor() ->getMock(); @@ -79,7 +83,7 @@ protected function setUp() ->getMock(); $this->session = $this->objectManager->getObject( - \Magento\Weee\Observer\AfterAddressSave::class, + AfterAddressSave::class, [ 'weeeHelper' => $this->weeeHelperMock, 'moduleManager' => $this->moduleManagerMock, @@ -117,8 +121,8 @@ public function testExecute( ->method('isEnabled') ->willReturn($isEnabledWeee); - /* @var \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject $address */ - $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) + /* @var \Magento\Customer\Model\Address|MockObject $address */ + $address = $this->getMockBuilder(Address::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php b/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php index af8c2e70a8ff6..59b3b3fe071f6 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php @@ -1,39 +1,45 @@ -observerMock = $this->getMockBuilder(\Magento\Framework\Event\Observer::class) + $objectManager = new ObjectManager($this); + $this->observerMock = $this->getMockBuilder(Observer::class) ->disableOriginalConstructor() ->setMethods( [ @@ -59,15 +65,15 @@ protected function setUp() ) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) + $this->moduleManagerMock = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->cacheConfigMock = $this->getMockBuilder(\Magento\PageCache\Model\Config::class) + $this->cacheConfigMock = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); - $this->weeeHelperMock = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeHelperMock = $this->getMockBuilder(Data::class) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +83,7 @@ protected function setUp() ->getMock(); $this->session = $objectManager->getObject( - \Magento\Weee\Observer\CustomerLoggedIn::class, + CustomerLoggedIn::class, [ 'weeeHelper' => $this->weeeHelperMock, 'moduleManager' => $this->moduleManagerMock, @@ -105,12 +111,12 @@ public function testExecute() ->method('isEnabled') ->willReturn(true); - $customerMock = $this->getMockBuilder(\Magento\Customer\Model\Data\Customer::class) + $customerMock = $this->getMockBuilder(Customer::class) ->disableOriginalConstructor() ->getMock(); - /* @var \Magento\Customer\Api\Data\AddressInterface|\PHPUnit_Framework_MockObject_MockObject $address */ - $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) + /* @var \Magento\Customer\Api\Data\AddressInterface|MockObject $address */ + $address = $this->getMockBuilder(AddressInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Weee/Test/Unit/Observer/GetPriceConfigurationObserverTest.php b/app/code/Magento/Weee/Test/Unit/Observer/GetPriceConfigurationObserverTest.php index 848f315f0cbd9..927e8d0b07bc7 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/GetPriceConfigurationObserverTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/GetPriceConfigurationObserverTest.php @@ -1,4 +1,4 @@ - $testArray, ] ); - $weeeObject1 = new \Magento\Framework\DataObject( + $weeeObject1 = new DataObject( [ 'code' => 'fpt1', 'amount' => '15.0000', ] ); - $weeeObject2 = new \Magento\Framework\DataObject( + $weeeObject2 = new DataObject( [ 'code' => 'fpt2', 'amount' => '16.0000', ] ); - $weeeHelper=$this->createMock(\Magento\Weee\Helper\Data::class); + $weeeHelper=$this->createMock(Data::class); $weeeHelper->expects($this->any()) ->method('isEnabled') ->will($this->returnValue(true)); - $observerObject=$this->createMock(\Magento\Framework\Event\Observer::class); + $observerObject=$this->createMock(Observer::class); $observerObject->expects($this->any()) ->method('getData') ->with('configObj') ->will($this->returnValue($configObj)); - $productInstance=$this->createMock(\Magento\Catalog\Model\Product\Type\Simple::class); + $productInstance=$this->createMock(Simple::class); $product = $this->createPartialMock( - \Magento\Bundle\Model\Product\Type::class, + Type::class, ['getTypeInstance', 'getTypeId', 'getStoreId'] ); $product->expects($this->any()) @@ -66,7 +74,7 @@ public function testGetPriceConfiguration($hasWeeeAttributes, $testArray, $expec ->method('getStoreId') ->will($this->returnValue(null)); - $registry=$this->createMock(\Magento\Framework\Registry::class); + $registry=$this->createMock(Registry::class); $registry->expects($this->any()) ->method('registry') ->with('current_product') @@ -89,9 +97,9 @@ public function testGetPriceConfiguration($hasWeeeAttributes, $testArray, $expec } $objectManager = new ObjectManager($this); - /** @var \Magento\Weee\Observer\GetPriceConfigurationObserver $weeeObserverObject */ + /** @var GetPriceConfigurationObserver $weeeObserverObject */ $weeeObserverObject = $objectManager->getObject( - \Magento\Weee\Observer\GetPriceConfigurationObserver::class, + GetPriceConfigurationObserver::class, [ 'weeeData' => $weeeHelper, 'registry' => $registry, diff --git a/app/code/Magento/Weee/Test/Unit/Observer/SetWeeeRendererInFormObserverTest.php b/app/code/Magento/Weee/Test/Unit/Observer/SetWeeeRendererInFormObserverTest.php index 188b42cb37906..b9d2098416592 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/SetWeeeRendererInFormObserverTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/SetWeeeRendererInFormObserverTest.php @@ -13,12 +13,9 @@ use Magento\Framework\View\LayoutInterface; use Magento\Weee\Model\Tax; use Magento\Weee\Observer\SetWeeeRendererInFormObserver; +use PHPUnit\Framework\MockObject\MockObject as MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; -/** - * Class AddPaymentWeeeItemTest - */ class SetWeeeRendererInFormObserverTest extends TestCase { /** @@ -41,7 +38,7 @@ class SetWeeeRendererInFormObserverTest extends TestCase /** * Set Up */ - protected function setUp() + protected function setUp(): void { $this->layoutMock = $this->createMock(LayoutInterface::class); $this->taxModelMock = $this->createMock(Tax::class); diff --git a/app/code/Magento/Weee/Test/Unit/Observer/UpdateProductOptionsObserverTest.php b/app/code/Magento/Weee/Test/Unit/Observer/UpdateProductOptionsObserverTest.php index a3fa2ce474e0d..b997cf7c295f0 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/UpdateProductOptionsObserverTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/UpdateProductOptionsObserverTest.php @@ -1,4 +1,4 @@ - $initialArray, ] ); - $weeeObject1 = new \Magento\Framework\DataObject( + $weeeObject1 = new DataObject( [ 'code' => 'fpt1', 'amount' => '15.0000', ] ); - $weeeObject2 = new \Magento\Framework\DataObject( + $weeeObject2 = new DataObject( [ 'code' => 'fpt2', 'amount' => '7.0000', ] ); - $weeeHelper=$this->createMock(\Magento\Weee\Helper\Data::class); + $weeeHelper=$this->createMock(Data::class); $weeeHelper->expects($this->any()) ->method('isEnabled') ->will($this->returnValue($weeeEnabled)); @@ -70,17 +77,17 @@ public function testUpdateProductOptions($initialArray, $weeeEnabled, $weeeDispl ->method('priceIncludesTax') ->will($this->returnValue(true)); - $responseObject=$this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getResponseObject']); + $responseObject=$this->createPartialMock(Observer::class, ['getResponseObject']); $responseObject->expects($this->any()) ->method('getResponseObject') ->will($this->returnValue($configObj)); - $observerObject=$this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getEvent']); + $observerObject=$this->createPartialMock(Observer::class, ['getEvent']); $observerObject->expects($this->any()) ->method('getEvent') ->will($this->returnValue($responseObject)); - $product = $this->createPartialMock(\Magento\Bundle\Model\Product\Type::class, ['getTypeId', 'getStoreId']); + $product = $this->createPartialMock(Type::class, ['getTypeId', 'getStoreId']); $product->expects($this->any()) ->method('getStoreId') ->will($this->returnValue(1)); @@ -88,16 +95,16 @@ public function testUpdateProductOptions($initialArray, $weeeEnabled, $weeeDispl ->method('getTypeId') ->will($this->returnValue('bundle')); - $registry=$this->createMock(\Magento\Framework\Registry::class); + $registry=$this->createMock(Registry::class); $registry->expects($this->any()) ->method('registry') ->with('current_product') ->will($this->returnValue($product)); $objectManager = new ObjectManager($this); - /** @var \Magento\Weee\Observer\UpdateProductOptionsObserver $weeeObserverObject */ + /** @var UpdateProductOptionsObserver $weeeObserverObject */ $weeeObserverObject = $objectManager->getObject( - \Magento\Weee\Observer\UpdateProductOptionsObserver::class, + UpdateProductOptionsObserver::class, [ 'weeeData' => $weeeHelper, 'taxData' => $taxHelper, diff --git a/app/code/Magento/Weee/Test/Unit/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper/ProcessTaxAttributeTest.php b/app/code/Magento/Weee/Test/Unit/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper/ProcessTaxAttributeTest.php index 2c88d3e0f0251..f809418853102 100644 --- a/app/code/Magento/Weee/Test/Unit/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper/ProcessTaxAttributeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper/ProcessTaxAttributeTest.php @@ -61,7 +61,7 @@ class ProcessTaxAttributeTest extends TestCase /** * Prepare environment for test */ - protected function setUp() + protected function setUp(): void { $this->subjectMock = $this->createMock(Helper::class); $this->resultMock = $this->createMock(Product::class); diff --git a/app/code/Magento/Weee/Test/Unit/Plugin/Ui/DataProvider/WeeeSettingsTest.php b/app/code/Magento/Weee/Test/Unit/Plugin/Ui/DataProvider/WeeeSettingsTest.php index 0ac9c55313538..02e6b60616c99 100644 --- a/app/code/Magento/Weee/Test/Unit/Plugin/Ui/DataProvider/WeeeSettingsTest.php +++ b/app/code/Magento/Weee/Test/Unit/Plugin/Ui/DataProvider/WeeeSettingsTest.php @@ -41,7 +41,7 @@ class WeeeSettingsTest extends TestCase /** * Prepare environment for test */ - protected function setUp() + protected function setUp(): void { $this->configMock = $this->createMock(Config::class); $this->subjectMock = $this->createMock(DataProvider::class); diff --git a/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php b/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php index a0d0b6486c7d9..2cf986dd08cc5 100644 --- a/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php +++ b/app/code/Magento/Weee/Test/Unit/Pricing/AdjustmentTest.php @@ -1,4 +1,4 @@ -weeeHelper = $this->createMock(\Magento\Weee\Helper\Data::class); - $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class); $this->priceCurrencyMock->expects($this->any()) ->method('convertAndRound') ->will( @@ -75,9 +78,9 @@ public function testIsIncludedInBasePrice() public function testIsIncludedInDisplayPrice($expectedResult) { $displayTypes = [ - \Magento\Weee\Model\Tax::DISPLAY_INCL, - \Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, - \Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, + Tax::DISPLAY_INCL, + Tax::DISPLAY_INCL_DESCR, + Tax::DISPLAY_EXCL_DESCR_INCL, ]; $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') @@ -103,7 +106,7 @@ public function isIncludedInDisplayPriceDataProvider() */ public function testApplyAdjustment($amount, $amountOld, $expectedResult) { - $object = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $object = $this->getMockForAbstractClass(SaleableInterface::class); $this->weeeHelper->expects($this->any()) ->method('getAmountExclTax') diff --git a/app/code/Magento/Weee/Test/Unit/Pricing/Render/AdjustmentTest.php b/app/code/Magento/Weee/Test/Unit/Pricing/Render/AdjustmentTest.php index 2d18793de209b..251aacd5ff929 100644 --- a/app/code/Magento/Weee/Test/Unit/Pricing/Render/AdjustmentTest.php +++ b/app/code/Magento/Weee/Test/Unit/Pricing/Render/AdjustmentTest.php @@ -1,4 +1,4 @@ -contextMock = $this->createPartialMock( - \Magento\Framework\View\Element\Template\Context::class, + Context::class, ['getStoreConfig', 'getEventManager', 'getScopeConfig'] ); $this->priceCurrencyMock = $this->getMockForAbstractClass( - \Magento\Framework\Pricing\PriceCurrencyInterface::class, + PriceCurrencyInterface::class, [], '', true, @@ -57,23 +68,16 @@ protected function setUp() true, [] ); - $this->weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class); - $eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) + $this->weeeHelperMock = $this->createMock(Data::class); + $eventManagerMock = $this->getMockBuilder(ManagerInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $storeConfigMock = $this->getMockBuilder(\Magento\Store\Model\Store\Config::class) - ->disableOriginalConstructor() - ->getMock(); - - $scopeConfigMock = $this->getMockForAbstractClass(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $this->contextMock->expects($this->any()) ->method('getEventManager') ->will($this->returnValue($eventManagerMock)); - $this->contextMock->expects($this->any()) - ->method('getStoreConfig') - ->will($this->returnValue($storeConfigMock)); $this->contextMock->expects($this->any()) ->method('getScopeConfig') ->will($this->returnValue($scopeConfigMock)); @@ -90,7 +94,7 @@ protected function setUp() */ public function testGetAdjustmentCode() { - $this->assertEquals(\Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE, $this->model->getAdjustmentCode()); + $this->assertEquals(PricingAdjustment::ADJUSTMENT_CODE, $this->model->getAdjustmentCode()); } /** @@ -106,8 +110,8 @@ public function testGetFinalAmount() $displayValue = 10; $expectedValue = "$10.00"; $typeOfDisplay = 1; //Just to set it to not false - /** @var \Magento\Framework\Pricing\Render\Amount $amountRender */ - $amountRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) + /** @var Amount $amountRender */ + $amountRender = $this->getMockBuilder(Amount::class) ->disableOriginalConstructor() ->setMethods(['getSaleableItem', 'getDisplayValue', 'getAmount']) ->getMock(); @@ -115,8 +119,8 @@ public function testGetFinalAmount() ->method('getDisplayValue') ->will($this->returnValue($displayValue)); $this->weeeHelperMock->expects($this->any())->method('typeOfDisplay')->will($this->returnValue($typeOfDisplay)); - /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */ - $baseAmount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) + /** @var Base $baseAmount */ + $baseAmount = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -137,18 +141,18 @@ public function testGetFinalAmount() */ public function testShowInclDescr($typeOfDisplay, $amount, $expectedResult) { - /** @var \Magento\Framework\Pricing\Render\Amount $amountRender */ - $amountRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) + /** @var Amount $amountRender */ + $amountRender = $this->getMockBuilder(Amount::class) ->disableOriginalConstructor() ->setMethods(['getSaleableItem', 'getDisplayValue', 'getAmount']) ->getMock(); - /** @var \Magento\Catalog\Model\Product $saleable */ - $saleable = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + /** @var Product $saleable */ + $saleable = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); - /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */ - $baseAmount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) + /** @var Base $baseAmount */ + $baseAmount = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -187,15 +191,15 @@ public function testShowInclDescr($typeOfDisplay, $amount, $expectedResult) public function showInclDescrDataProvider() { return [ - [\Magento\Weee\Model\Tax::DISPLAY_INCL, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, 1.23, true], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL, 1.23, false], + [Tax::DISPLAY_INCL, 1.23, false], + [Tax::DISPLAY_INCL_DESCR, 1.23, true], + [Tax::DISPLAY_EXCL_DESCR_INCL, 1.23, false], + [Tax::DISPLAY_EXCL, 1.23, false], [4, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL, 0, false], + [Tax::DISPLAY_INCL, 0, false], + [Tax::DISPLAY_INCL_DESCR, 0, false], + [Tax::DISPLAY_EXCL_DESCR_INCL, 0, false], + [Tax::DISPLAY_EXCL, 0, false], [4, 0, false], ]; } @@ -210,18 +214,18 @@ public function showInclDescrDataProvider() */ public function testShowExclDescrIncl($typeOfDisplay, $amount, $expectedResult) { - /** @var \Magento\Framework\Pricing\Render\Amount $amountRender */ - $amountRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) + /** @var Amount $amountRender */ + $amountRender = $this->getMockBuilder(Amount::class) ->disableOriginalConstructor() ->setMethods(['getSaleableItem', 'getDisplayValue', 'getAmount']) ->getMock(); - /** @var \Magento\Catalog\Model\Product $saleable */ - $saleable = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + /** @var Product $saleable */ + $saleable = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); - /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */ - $baseAmount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) + /** @var Base $baseAmount */ + $baseAmount = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -258,15 +262,15 @@ public function testShowExclDescrIncl($typeOfDisplay, $amount, $expectedResult) public function showExclDescrInclDataProvider() { return [ - [\Magento\Weee\Model\Tax::DISPLAY_INCL, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, 1.23, true], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL, 1.23, false], + [Tax::DISPLAY_INCL, 1.23, false], + [Tax::DISPLAY_INCL_DESCR, 1.23, false], + [Tax::DISPLAY_EXCL_DESCR_INCL, 1.23, true], + [Tax::DISPLAY_EXCL, 1.23, false], [4, 1.23, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, 0, false], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL, 0, false], + [Tax::DISPLAY_INCL, 0, false], + [Tax::DISPLAY_INCL_DESCR, 0, false], + [Tax::DISPLAY_EXCL_DESCR_INCL, 0, false], + [Tax::DISPLAY_EXCL, 0, false], [4, 0, false], ]; } @@ -281,18 +285,18 @@ public function showExclDescrInclDataProvider() */ public function testGetWeeeTaxAttributes($typeOfDisplay, $attributes, $expectedResult) { - /** @var \Magento\Framework\Pricing\Render\Amount $amountRender */ - $amountRender = $this->getMockBuilder(\Magento\Framework\Pricing\Render\Amount::class) + /** @var Amount $amountRender */ + $amountRender = $this->getMockBuilder(Amount::class) ->disableOriginalConstructor() ->setMethods(['getSaleableItem', 'getDisplayValue', 'getAmount']) ->getMock(); - /** @var \Magento\Catalog\Model\Product $saleable */ - $saleable = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + /** @var Product $saleable */ + $saleable = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); - /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */ - $baseAmount = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\Base::class) + /** @var Base $baseAmount */ + $baseAmount = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); @@ -326,10 +330,10 @@ public function testGetWeeeTaxAttributes($typeOfDisplay, $attributes, $expectedR public function getWeeeTaxAttributesDataProvider() { return [ - [\Magento\Weee\Model\Tax::DISPLAY_INCL, [1, 2, 3], []], - [\Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR, [1, 2, 3], [1, 2, 3]], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL, [1, 2, 3], [1, 2, 3]], - [\Magento\Weee\Model\Tax::DISPLAY_EXCL, [1, 2, 3], []], + [Tax::DISPLAY_INCL, [1, 2, 3], []], + [Tax::DISPLAY_INCL_DESCR, [1, 2, 3], [1, 2, 3]], + [Tax::DISPLAY_EXCL_DESCR_INCL, [1, 2, 3], [1, 2, 3]], + [Tax::DISPLAY_EXCL, [1, 2, 3], []], [4, [1, 2, 3], []], ]; } @@ -337,7 +341,7 @@ public function getWeeeTaxAttributesDataProvider() /** * Test for method renderWeeeTaxAttribute * - * @param \Magento\Framework\DataObject $attribute + * @param DataObject $attribute * @param string $expectedResult * @dataProvider renderWeeeTaxAttributeAmountDataProvider */ @@ -357,15 +361,15 @@ public function testRenderWeeeTaxAttributeAmount($attribute, $expectedResult) public function renderWeeeTaxAttributeAmountDataProvider() { return [ - [new \Magento\Framework\DataObject(['amount' => 51]), 51], - [new \Magento\Framework\DataObject(['amount' => false]), false], + [new DataObject(['amount' => 51]), 51], + [new DataObject(['amount' => false]), false], ]; } /** * Test for method renderWeeeTaxAttributeName * - * @param \Magento\Framework\DataObject $attribute + * @param DataObject $attribute * @param string $expectedResult * @dataProvider renderWeeeTaxAttributeNameDataProvider */ @@ -385,15 +389,15 @@ public function testRenderWeeeTaxAttributeName($attribute, $expectedResult) public function renderWeeeTaxAttributeNameDataProvider() { return [ - [new \Magento\Framework\DataObject(['name' => 51]), 51], - [new \Magento\Framework\DataObject(['name' => false]), false], + [new DataObject(['name' => 51]), 51], + [new DataObject(['name' => false]), false], ]; } /** * Test for method renderWeeeTaxAttributeWithTax * - * @param \Magento\Framework\DataObject $attribute + * @param DataObject $attribute * @param string $expectedResult * @dataProvider renderWeeeTaxAttributeAmountWithTaxDataProvider */ @@ -413,8 +417,8 @@ public function testRenderWeeeTaxAttributeWithTax($attribute, $expectedResult) public function renderWeeeTaxAttributeAmountWithTaxDataProvider() { return [ - [new \Magento\Framework\DataObject(['amount_excl_tax' => 50, 'tax_amount' => 5]), 55], - [new \Magento\Framework\DataObject(['amount_excl_tax' => false]), false], + [new DataObject(['amount_excl_tax' => 50, 'tax_amount' => 5]), 55], + [new DataObject(['amount_excl_tax' => false]), false], ]; } } diff --git a/app/code/Magento/Weee/Test/Unit/Pricing/Render/TaxAdjustmentTest.php b/app/code/Magento/Weee/Test/Unit/Pricing/Render/TaxAdjustmentTest.php index 02c540fea7073..b247c0617d834 100644 --- a/app/code/Magento/Weee/Test/Unit/Pricing/Render/TaxAdjustmentTest.php +++ b/app/code/Magento/Weee/Test/Unit/Pricing/Render/TaxAdjustmentTest.php @@ -1,4 +1,4 @@ -objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); $this->weeeHelperMock = $this->createPartialMock( - \Magento\Weee\Helper\Data::class, + Data::class, ['typeOfDisplay', 'isTaxable'] ); $this->model = $this->objectManager->getObject( - \Magento\Weee\Pricing\Render\TaxAdjustment::class, + TaxAdjustment::class, [ 'weeeHelper' => $this->weeeHelperMock, ] @@ -62,7 +69,7 @@ public function testGetDefaultExclusions($weeeIsExcluded) $taxCode = $this->model->getAdjustmentCode(); // since Weee's TaxAdjustment is a subclass of Tax's Adjustment $this->assertContains($taxCode, $defaultExclusions); - $weeeCode = \Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE; + $weeeCode = Adjustment::ADJUSTMENT_CODE; if ($weeeIsExcluded) { $this->assertContains($weeeCode, $defaultExclusions); } else { diff --git a/app/code/Magento/Weee/Test/Unit/Pricing/TaxAdjustmentTest.php b/app/code/Magento/Weee/Test/Unit/Pricing/TaxAdjustmentTest.php index 8abccdc181ad3..884706484ffd5 100644 --- a/app/code/Magento/Weee/Test/Unit/Pricing/TaxAdjustmentTest.php +++ b/app/code/Magento/Weee/Test/Unit/Pricing/TaxAdjustmentTest.php @@ -1,4 +1,4 @@ -weeeHelperMock = $this->createMock(\Magento\Weee\Helper\Data::class); + $this->weeeHelperMock = $this->createMock(Data::class); $this->taxHelperMock = $this->createMock(\Magento\Tax\Helper\Data::class); - $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(PriceCurrencyInterface::class); $this->priceCurrencyMock->expects($this->any()) ->method('convertAndRound') ->will( @@ -101,7 +108,7 @@ public function testIsIncludedInDisplayPrice( ->willReturn($taxDisplayExclTax); $displayTypes = [ - \Magento\Weee\Model\Tax::DISPLAY_EXCL, + Tax::DISPLAY_EXCL, ]; $this->weeeHelperMock->expects($this->any()) ->method('typeOfDisplay') @@ -146,13 +153,13 @@ public function isIncludedInDisplayPriceDataProvider() /** * @param float $amount - * @param \Magento\Framework\DataObject[] $weeeAttributes + * @param DataObject[] $weeeAttributes * @param float $expectedResult * @dataProvider applyAdjustmentDataProvider */ public function testApplyAdjustment($amount, $weeeAttributes, $expectedResult) { - $object = $this->getMockForAbstractClass(\Magento\Framework\Pricing\SaleableInterface::class); + $object = $this->getMockForAbstractClass(SaleableInterface::class); $this->weeeHelperMock->expects($this->any()) ->method('getProductWeeeAttributes') @@ -170,12 +177,12 @@ public function applyAdjustmentDataProvider() [ 'amount' => 10, 'weee_attributes' => [ - new \Magento\Framework\DataObject( + new DataObject( [ 'tax_amount' => 5, ] ), - new \Magento\Framework\DataObject( + new DataObject( [ 'tax_amount' => 2.5, ] diff --git a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Manager/WebsiteTest.php b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Manager/WebsiteTest.php index 6671402d49d47..f58e974965959 100644 --- a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Manager/WebsiteTest.php +++ b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Manager/WebsiteTest.php @@ -1,4 +1,4 @@ -objectManager = new ObjectManager($this); $this->locatorMock = $this->getMockBuilder(LocatorInterface::class) diff --git a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WeeeTest.php index 8bd2d24fe160f..f3add900aa9da 100644 --- a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WeeeTest.php @@ -1,44 +1,41 @@ -sourceCountryMock = $this->getMockBuilder(SourceCountry::class) diff --git a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Listing/Collector/WeeeTest.php b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Listing/Collector/WeeeTest.php index 266737089cd21..cf3012dbcc2b7 100644 --- a/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Listing/Collector/WeeeTest.php +++ b/app/code/Magento/Weee/Test/Unit/Ui/DataProvider/Product/Listing/Collector/WeeeTest.php @@ -1,55 +1,61 @@ -weeeHelperMock = $this->getMockBuilder(\Magento\Weee\Helper\Data::class) + $this->weeeHelperMock = $this->getMockBuilder(Data::class) ->disableOriginalConstructor() ->getMock(); - $this->priceCurrencyMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class) + $this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class) ->getMockForAbstractClass(); $this->weeeAdjustmentAttributeFactory = $this->getMockBuilder(WeeeAdjustmentAttributeInterfaceFactory::class) @@ -96,11 +102,11 @@ public function testCollect() $this->weeeAdjustmentAttributeFactory->expects($this->atLeastOnce()) ->method('create') ->willReturn($weeAttribute); - $priceInfo = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) + $priceInfo = $this->getMockBuilder(Base::class) ->disableOriginalConstructor() ->setMethods(['getExtensionAttributes', 'getPrice', 'setExtensionAttributes']) ->getMock(); - $price = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\FinalPrice::class) + $price = $this->getMockBuilder(FinalPrice::class) ->disableOriginalConstructor() ->getMock(); $weeAttribute->expects($this->once())