From a2ea67f4728478067f3323d8b641c3416729d944 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Mon, 1 Sep 2014 01:33:18 -0700 Subject: [PATCH] 0.1.0-alpha93 * Price template refactoring * Refactored order item templates in the Sales, Bundle and Downloadable modules * Eliminated the unused PHTML templates and removed the direct dependencies on the TaxHelper module in the Catalog module * Service layer implementation: * Created service layer for Order creation * Created service layer for Invoice * Created service layer for Credit Memo * Created service layer for Shipment * Introduce the Search library: * Created adapter interfaces for the Search library * Created response structure * Created parsing of XML declaration and creation of library objects (Queries, Filters, Aggregations) * Refactored Framework\Stdlib\Cookie to use CookieManager * Added the ability to prevent the backend cookie from going to the storefront * Fixed bugs: * Fixed an issue where taxes were not added in some orders * Fixed an issue were the Add New Address button did not work if the default address was already set * Fixed a Google Chrome and Internet Explorer specific issue when a JavaScript error made it impossible to register during checkout downloadable product * Fixed an issue when the credit card iframe (PayPal or 3D secure) was absent on the Order Review step during Onepage Checkout * Fixed an issue with the Tax Rate, Customer Tax Class and Product Tax Class multiselects on the Tax Rule Information page * Fixed JavaScript issues which prevented saving a newsletter template. * Modified the Button component behavior * Fixed an issue where it was impossible for a guest customer to register during Onepage checkout when the Require Customer To Be Logged In To Checkout option was set to Yes * Fixed an issue where the Calendar icons were not displayed on the storefront * Fixed an AJAX loader issue in the Admin panel * Fixed an issue where it was impossible to upload images for variations of a configurable product on product form * Fixed an issue where clicking on a row in the Search Terms Report Grid leads to 404 page * Fixed an issue where configurable products fixture creates out of stock products * Fixed an issue where Magento crashed when invalid cookie domain was set * Fixed an issue where the Change checkbox label overlapped the text message for a recurring profile attribute on the attribute mass update page * Fixed an issue where integrity test determined normal dependencies as redundant * Fixed an issue where Catalog\Service\V1\Product\Attribute\ReadService::search returned an error * Fixed an issue where Magento\Catalog\Service\V1\Category\Attribute\ReadService::options returned empty results * GitHub requests: * [#160] (https://github.com/magento/bugathon_march_2013/issues/160) -- Wrong default value for memory_limit in .htaccess.sample * [#480] (https://github.com/magento/magento2/pull/480) -- Provide instructions on adding memcache support for Magento 2 * [#612] (https://github.com/magento/magento2/issues/612) -- Category Layered Navigation : Selection of disabled entity * [#626] (https://github.com/magento/magento2/issues/626) -- Unable to install under IIS / FastCGI --- .htaccess.sample | 2 +- CHANGELOG.md | 45 +- .../Magento/AdminNotification/composer.json | 12 +- app/code/Magento/Authorization/composer.json | 6 +- .../Authorizenet/Model/Directpost/Session.php | 15 +- app/code/Magento/Authorizenet/composer.json | 20 +- app/code/Magento/Backend/AdminConfig.php | 111 ++ .../Magento/Backend/Model/Auth/Session.php | 50 +- .../Backend/Model/Config/Backend/Domain.php | 50 + app/code/Magento/Backend/Model/Session.php | 17 +- .../Magento/Backend/Model/Session/Quote.php | 15 +- app/code/Magento/Backend/Model/Url.php | 16 +- app/code/Magento/Backend/composer.json | 46 +- app/code/Magento/Backend/etc/adminhtml/di.xml | 5 +- .../Magento/Backend/etc/adminhtml/system.xml | 1 + .../Backend/view/adminhtml/layout/default.xml | 5 + app/code/Magento/Backup/composer.json | 14 +- .../Block/Sales/Order/Items/Renderer.php | 13 + .../V1/Data/Product/Option/TypeConverter.php | 4 +- .../V1/Product/Link/Data/ProductLink.php | 2 + .../Product/Link/Data/ProductLinkBuilder.php | 1 + app/code/Magento/Bundle/composer.json | 33 +- app/code/Magento/Bundle/etc/module.xml | 1 - .../creditmemo/create/items/renderer.phtml | 196 +--- .../creditmemo/view/items/renderer.phtml | 193 +-- .../sales/invoice/create/items/renderer.phtml | 196 +--- .../sales/invoice/view/items/renderer.phtml | 196 +--- .../sales/order/view/items/renderer.phtml | 195 +-- .../order/items/creditmemo/default.phtml | 76 +- .../email/order/items/invoice/default.phtml | 76 +- .../email/order/items/order/default.phtml | 76 +- .../order/creditmemo/items/renderer.phtml | 142 +-- .../sales/order/invoice/items/renderer.phtml | 172 +-- .../sales/order/items/renderer.phtml | 172 +-- app/code/Magento/Captcha/composer.json | 14 +- .../Product/Edit/Action/Attribute.php | 8 +- .../Edit/Action/Attribute/Tab/Attributes.php | 5 +- .../Catalog/Block/Product/View/Options.php | 2 +- app/code/Magento/Catalog/Model/Layer.php | 12 +- .../Catalog/Model/Layer/Filter/Category.php | 27 +- .../Model/Product/ProductList/Toolbar.php | 22 +- .../V1/Category/Attribute/ReadService.php | 2 +- .../Catalog/Service/V1/Data/Category.php | 3 + .../Service/V1/Data/CategoryBuilder.php | 3 + .../Catalog/Service/V1/Data/Eav/Attribute.php | 3 + .../Service/V1/Data/Eav/AttributeBuilder.php | 3 + .../Service/V1/Data/Eav/AttributeGroup.php | 4 +- .../V1/Data/Eav/AttributeGroupBuilder.php | 3 + .../Service/V1/Data/Eav/AttributeMetadata.php | 2 + .../V1/Data/Eav/AttributeMetadataBuilder.php | 31 + .../Service/V1/Data/Eav/AttributeSet.php | 2 + .../V1/Data/Eav/AttributeSet/Attribute.php | 3 + .../Eav/AttributeSet/AttributeBuilder.php | 3 + .../V1/Data/Eav/AttributeSetBuilder.php | 2 + .../Data/Eav/Category/AttributeMetadata.php | 3 + .../Eav/Category/AttributeMetadataBuilder.php | 3 + .../Service/V1/Data/Eav/Category/Tree.php | 3 + .../V1/Data/Eav/Category/TreeBuilder.php | 3 + .../Catalog/Service/V1/Data/Eav/Option.php | 2 + .../Service/V1/Data/Eav/Option/Label.php | 2 + .../V1/Data/Eav/Option/LabelBuilder.php | 2 + .../Service/V1/Data/Eav/OptionBuilder.php | 2 + .../Eav/Product/Attribute/FrontendLabel.php | 2 + .../Attribute/FrontendLabelBuilder.php | 2 + .../V1/Data/Eav/Product/Attribute/Type.php | 2 + .../Eav/Product/Attribute/TypeBuilder.php | 2 + .../Service/V1/Data/Eav/ValidationRule.php | 3 + .../V1/Data/Eav/ValidationRuleBuilder.php | 3 + .../Catalog/Service/V1/Data/Product.php | 3 +- .../Data/Product/Attribute/SearchResults.php | 2 + .../Attribute/SearchResultsBuilder.php | 1 + .../Service/V1/Data/Product/GroupPrice.php | 3 + .../V1/Data/Product/GroupPriceBuilder.php | 9 +- .../Service/V1/Data/Product/SearchResults.php | 2 + .../V1/Data/Product/SearchResultsBuilder.php | 1 + .../Service/V1/Data/Product/TierPrice.php | 3 + .../V1/Data/Product/TierPriceBuilder.php | 9 +- .../Service/V1/Data/ProductBuilder.php | 5 +- .../Catalog/Service/V1/Data/ProductMapper.php | 6 +- .../Catalog/Service/V1/Data/ProductType.php | 3 + .../Service/V1/Data/ProductTypeBuilder.php | 3 + .../Catalog/Service/V1/MetadataService.php | 8 +- .../Attribute/Media/Data/GalleryEntry.php | 3 + .../Media/Data/GalleryEntryBuilder.php | 3 + .../Media/Data/GalleryEntryContent.php | 3 + .../Media/Data/GalleryEntryContentBuilder.php | 3 + .../Attribute/Media/Data/MediaImage.php | 2 + .../Media/Data/MediaImageBuilder.php | 2 + .../V1/Product/CustomOptions/Data/Option.php | 3 + .../CustomOptions/Data/Option/Metadata.php | 3 + .../Data/Option/Metadata/Reader/File.php | 3 + .../Data/Option/Metadata/Reader/Text.php | 3 + .../Data/Option/MetadataBuilder.php | 3 + .../CustomOptions/Data/OptionBuilder.php | 3 + .../Product/CustomOptions/Data/OptionType.php | 3 + .../CustomOptions/Data/OptionTypeBuilder.php | 3 + .../V1/Product/Link/Data/LinkAttribute.php | 2 + .../Link/Data/LinkAttributeBuilder.php | 1 + .../Service/V1/Product/Link/Data/LinkType.php | 2 + .../V1/Product/Link/Data/LinkTypeBuilder.php | 1 + .../V1/Product/Link/Data/ProductLink.php | 2 + .../ProductEntity/ConverterPool.php | 3 + .../Product/Link/Data/ProductLinkBuilder.php | 1 + .../Service/V1/Product/MetadataService.php | 14 +- .../Service/V1/Product/TierPriceService.php | 16 +- app/code/Magento/Catalog/composer.json | 48 +- .../catalog/product/attribute/form.phtml | 2 +- .../product/edit/action/attribute.phtml | 6 +- .../product/edit/action/inventory.phtml | 486 +++++--- .../product/edit/action/websites.phtml | 114 +- .../product/price/configured_price.phtml | 5 +- .../Model/Import/Product.php | 5 +- .../Magento/CatalogImportExport/composer.json | 20 +- .../CatalogInventory/Model/Stock/Item.php | 3 + .../Service/V1/Data/LowStockCriteria.php | 2 + .../V1/Data/LowStockCriteriaBuilder.php | 2 + .../Service/V1/Data/LowStockResult.php | 2 + .../Service/V1/Data/LowStockResultBuilder.php | 2 + .../Service/V1/Data/StockItem.php | 2 + .../Service/V1/Data/StockItemDetails.php | 2 + .../V1/Data/StockItemDetailsBuilder.php | 2 + .../Service/V1/Data/StockStatus.php | 2 + .../Magento/CatalogInventory/composer.json | 20 +- app/code/Magento/CatalogRule/composer.json | 18 +- app/code/Magento/CatalogSearch/composer.json | 22 +- .../Magento/CatalogUrlRewrite/composer.json | 12 +- app/code/Magento/Centinel/composer.json | 14 +- .../templates/authentication/complete.phtml | 4 +- .../templates/authentication/start.phtml | 2 - app/code/Magento/Checkout/Model/Session.php | 15 +- app/code/Magento/Checkout/composer.json | 32 +- .../frontend/templates/onepage/login.phtml | 4 +- .../frontend/web/js/opc-checkout-method.js | 7 +- .../Magento/CheckoutAgreements/composer.json | 10 +- .../Adminhtml/Wysiwyg/Images/Content.php | 20 +- app/code/Magento/Cms/composer.json | 20 +- app/code/Magento/CmsUrlRewrite/composer.json | 8 +- .../ConfigurableImportExport/composer.json | 14 +- .../Model/Attribute/LockValidator.php | 1 - .../Service/V1/Data/Option.php | 3 + .../Service/V1/Data/Option/Value.php | 4 +- .../Service/V1/Data/Option/ValueBuilder.php | 3 + .../Service/V1/Data/Option/ValueConverter.php | 3 + .../Service/V1/Data/OptionBuilder.php | 3 + .../Magento/ConfigurableProduct/composer.json | 32 +- app/code/Magento/Contact/composer.json | 12 +- .../Core/Model/File/Storage/Response.php | 12 +- app/code/Magento/Core/composer.json | 16 +- app/code/Magento/Core/etc/di.xml | 1 + app/code/Magento/Cron/composer.json | 8 +- app/code/Magento/CurrencySymbol/composer.json | 14 +- app/code/Magento/Customer/Model/Session.php | 15 +- app/code/Magento/Customer/composer.json | 40 +- .../Customer/view/frontend/web/address.js | 4 +- .../CustomerImportExport/composer.json | 18 +- app/code/Magento/DesignEditor/composer.json | 16 +- app/code/Magento/Dhl/composer.json | 22 +- app/code/Magento/Directory/composer.json | 10 +- .../Sales/Items/Column/Downloadable/Name.php | 6 +- .../Service/V1/Data/FileContent.php | 3 + .../Service/V1/Data/FileContentBuilder.php | 3 + .../Data/DownloadableLinkContent.php | 3 + .../Data/DownloadableLinkContentBuilder.php | 3 + .../Data/DownloadableLinkInfo.php | 3 + .../Data/DownloadableLinkInfoBuilder.php | 3 + .../Data/DownloadableResourceInfo.php | 3 + .../Data/DownloadableSampleInfo.php | 3 + .../Data/DownloadableSampleInfoBuilder.php | 3 + .../Data/DownloadableSampleContent.php | 3 + .../Data/DownloadableSampleContentBuilder.php | 3 + app/code/Magento/Downloadable/composer.json | 33 +- app/code/Magento/Downloadable/etc/module.xml | 1 - .../create/items/renderer/downloadable.phtml | 87 +- .../view/items/renderer/downloadable.phtml | 87 +- .../create/items/renderer/downloadable.phtml | 87 +- .../view/items/renderer/downloadable.phtml | 87 +- .../view/items/renderer/downloadable.phtml | 94 +- .../order/items/creditmemo/downloadable.phtml | 76 +- .../order/items/invoice/downloadable.phtml | 76 +- .../order/items/order/downloadable.phtml | 76 +- .../items/renderer/downloadable.phtml | 170 +-- .../invoice/items/renderer/downloadable.phtml | 172 +-- .../order/items/renderer/downloadable.phtml | 173 +-- .../Resource/Entity/Attribute/Collection.php | 12 + app/code/Magento/Eav/composer.json | 12 +- .../Email/Block/Adminhtml/Template/Edit.php | 27 +- app/code/Magento/Email/composer.json | 14 +- .../adminhtml/templates/template/edit.phtml | 32 + app/code/Magento/Fedex/composer.json | 18 +- app/code/Magento/GiftMessage/composer.json | 22 +- app/code/Magento/GoogleAdwords/composer.json | 8 +- .../Magento/GoogleAnalytics/composer.json | 8 +- .../Magento/GoogleOptimizer/composer.json | 14 +- app/code/Magento/GoogleShopping/composer.json | 22 +- .../Magento/GroupedImportExport/composer.json | 14 +- app/code/Magento/GroupedProduct/composer.json | 26 +- app/code/Magento/ImportExport/composer.json | 14 +- app/code/Magento/Index/composer.json | 8 +- app/code/Magento/Indexer/composer.json | 8 +- app/code/Magento/Install/composer.json | 14 +- app/code/Magento/Integration/composer.json | 18 +- .../Magento/LayeredNavigation/composer.json | 8 +- .../catalog_category_view_type_layered.xml | 5 + app/code/Magento/Log/composer.json | 16 +- app/code/Magento/Multishipping/composer.json | 22 +- .../Block/Adminhtml/Template/Edit.php | 36 +- app/code/Magento/Newsletter/composer.json | 24 +- .../adminhtml/templates/template/edit.phtml | 29 + .../Magento/OfflinePayments/composer.json | 6 +- .../Magento/OfflineShipping/composer.json | 20 +- app/code/Magento/Ogone/composer.json | 12 +- .../Model/App/FrontController/MessageBox.php | 44 +- app/code/Magento/PageCache/composer.json | 8 +- .../PayPalRecurringPayment/composer.json | 16 +- app/code/Magento/Payment/composer.json | 14 +- app/code/Magento/Paypal/composer.json | 30 +- .../view/frontend/templates/hss/form.phtml | 9 +- .../frontend/templates/hss/redirect.phtml | 2 - .../templates/payflowadvanced/form.phtml | 9 +- .../templates/payflowadvanced/redirect.phtml | 4 +- .../frontend/templates/payflowlink/form.phtml | 9 +- .../templates/payflowlink/redirect.phtml | 4 +- .../Persistent/Model/Observer/Session.php | 26 +- app/code/Magento/Persistent/Model/Session.php | 77 +- app/code/Magento/Persistent/composer.json | 16 +- app/code/Magento/ProductAlert/composer.json | 12 +- .../Magento/RecurringPayment/composer.json | 24 +- app/code/Magento/Reports/composer.json | 36 +- .../layout/reports_index_search_block.xml | 2 +- app/code/Magento/RequireJs/composer.json | 6 +- .../Magento/Review/Model/Rating/Entity.php | 1 + .../Magento/Review/Model/Rating/Option.php | 1 + .../Review/Model/Rating/Option/Vote.php | 1 + .../Magento/Review/Model/Review/Status.php | 1 + .../Magento/Review/Model/Review/Summary.php | 2 + app/code/Magento/Review/composer.json | 22 +- app/code/Magento/Rss/Model/Rss.php | 4 + app/code/Magento/Rss/composer.json | 22 +- app/code/Magento/Rule/composer.json | 12 +- .../Block/Adminhtml/Items/AbstractItems.php | 51 - .../Adminhtml/Items/Column/DefaultColumn.php | 47 +- .../Adminhtml/Order/Create/Items/Grid.php | 39 + .../View/Items/Renderer/DefaultRenderer.php | 2 +- .../Block/Order/Email/Items/DefaultItems.php | 17 + .../Order/Email/Items/Order/DefaultOrder.php | 15 + .../Order/Item/Renderer/DefaultRenderer.php | 69 ++ .../Creditmemo/AbstractCreditmemo/Email.php | 40 +- .../Invoice/AbstractInvoice/Email.php | 26 +- .../Adminhtml/Order/Creditmemo/AddComment.php | 6 +- .../Adminhtml/Order/Creditmemo/Cancel.php | 17 +- .../Adminhtml/Order/Creditmemo/NewAction.php | 7 +- .../Order/Creditmemo/PrintAction.php | 6 +- .../Adminhtml/Order/Creditmemo/Save.php | 8 +- .../Adminhtml/Order/Creditmemo/UpdateQty.php | 6 +- .../Adminhtml/Order/Creditmemo/View.php | 6 +- .../Adminhtml/Order/Creditmemo/Void.php | 17 +- .../Adminhtml/Order/CreditmemoLoader.php | 48 +- .../Controller/Adminhtml/Order/Email.php | 26 +- .../Adminhtml/Order/Invoice/AddComment.php | 6 +- .../Adminhtml/Order/Invoice/Cancel.php | 6 +- .../Adminhtml/Order/Invoice/Capture.php | 6 +- .../Adminhtml/Order/Invoice/NewAction.php | 6 +- .../Adminhtml/Order/Invoice/PrintAction.php | 6 +- .../Adminhtml/Order/Invoice/Save.php | 5 +- .../Adminhtml/Order/Invoice/UpdateQty.php | 9 +- .../Adminhtml/Order/Invoice/View.php | 6 +- .../Adminhtml/Order/Invoice/Void.php | 6 +- .../Adminhtml/Order/InvoiceLoader.php | 84 +- app/code/Magento/Sales/Helper/Guest.php | 60 +- .../{Notifier.php => AbstractNotifier.php} | 28 +- app/code/Magento/Sales/Model/Order.php | 23 +- .../Magento/Sales/Model/Order/Builder.php | 407 +++++++ .../Magento/Sales/Model/Order/Creditmemo.php | 24 +- .../Order/Creditmemo/Comment/Validator.php | 63 + .../Sales/Model/Order/CreditmemoNotifier.php | 66 ++ .../Magento/Sales/Model/Order/Customer.php | 259 ++++ .../Sales/Model/Order/Customer/Builder.php | 278 +++++ .../Magento/Sales/Model/Order/Invoice.php | 20 +- .../Model/Order/Invoice/Comment/Validator.php | 63 + .../Sales/Model/Order/InvoiceNotifier.php | 66 ++ .../Magento/Sales/Model/Order/Shipment.php | 18 +- .../Order/Shipment/Comment/Validator.php | 63 + .../Model/Order/Shipment/Track/Validator.php | 65 + .../Magento/Sales/Model/OrderConverter.php | 171 +++ .../Magento/Sales/Model/OrderNotifier.php | 66 ++ .../Resource/Order/Creditmemo/Comment.php | 47 + .../Model/Resource/Order/Invoice/Comment.php | 47 + .../Model/Resource/Order/Shipment/Comment.php | 47 + .../Model/Resource/Order/Shipment/Track.php | 47 + .../Order/Status/History/Collection.php | 8 +- .../V1/Action/CreditmemoAddComment.php | 62 + .../Service/V1/Action/CreditmemoCancel.php | 57 + .../V1/Action/CreditmemoCommentsList.php | 104 ++ .../Service/V1/Action/CreditmemoCreate.php | 77 ++ .../Service/V1/Action/CreditmemoEmail.php | 67 ++ .../Sales/Service/V1/Action/CreditmemoGet.php | 67 ++ .../Service/V1/Action/CreditmemoList.php | 84 ++ .../Service/V1/Action/InvoiceAddComment.php | 62 + .../Service/V1/Action/InvoiceCapture.php | 57 + .../Service/V1/Action/InvoiceCommentsList.php | 104 ++ .../Sales/Service/V1/Action/InvoiceCreate.php | 75 ++ .../Sales/Service/V1/Action/InvoiceEmail.php | 67 ++ .../Sales/Service/V1/Action/InvoiceGet.php | 67 ++ .../Sales/Service/V1/Action/InvoiceList.php | 83 ++ .../InvoiceVoid.php} | 28 +- .../V1/{ => Action}/OrderAddressUpdate.php | 7 +- .../Service/V1/{ => Action}/OrderCancel.php | 5 +- .../V1/{ => Action}/OrderCommentsList.php | 4 +- .../Sales/Service/V1/Action/OrderCreate.php | 71 ++ .../OrderEmail.php} | 12 +- .../Service/V1/{ => Action}/OrderGet.php | 7 +- .../V1/{ => Action}/OrderGetStatus.php | 4 +- .../Service/V1/{ => Action}/OrderHold.php | 4 +- .../Service/V1/{ => Action}/OrderList.php | 10 +- .../V1/{ => Action}/OrderStatusHistoryAdd.php | 4 +- .../Service/V1/{ => Action}/OrderUnHold.php | 4 +- .../Service/V1/Action/ShipmentAddComment.php | 62 + .../Service/V1/Action/ShipmentAddTrack.php | 62 + .../V1/Action/ShipmentCommentsList.php | 104 ++ .../Service/V1/Action/ShipmentCreate.php | 78 ++ .../Sales/Service/V1/Action/ShipmentEmail.php | 67 ++ .../Sales/Service/V1/Action/ShipmentGet.php | 67 ++ .../Service/V1/Action/ShipmentLabelGet.php | 57 + .../Sales/Service/V1/Action/ShipmentList.php | 83 ++ .../Service/V1/Action/ShipmentRemoveTrack.php | 61 + .../Sales/Service/V1/CreditmemoRead.php | 93 ++ .../Service/V1/CreditmemoReadInterface.php | 48 + .../Sales/Service/V1/CreditmemoWrite.php | 114 ++ .../Service/V1/CreditmemoWriteInterface.php | 57 + .../Sales/Service/V1/Data/Creditmemo.php | 202 +--- .../Service/V1/Data/CreditmemoComment.php | 122 -- .../Service/V1/Data/CreditmemoConverter.php | 69 ++ .../Service/V1/Data/CreditmemoMapper.php | 78 ++ .../Magento/Sales/Service/V1/Data/Invoice.php | 15 +- .../Service/V1/Data/InvoiceConverter.php | 63 + .../Sales/Service/V1/Data/InvoiceItem.php | 95 -- .../Sales/Service/V1/Data/InvoiceMapper.php | 76 ++ .../Sales/Service/V1/Data/OrderAddress.php | 103 -- .../Sales/Service/V1/Data/OrderMapper.php | 4 +- .../Sales/Service/V1/Data/OrderPayment.php | 215 ---- .../Sales/Service/V1/Data/Shipment.php | 81 +- .../Service/V1/Data/ShipmentConverter.php | 66 ++ .../Sales/Service/V1/Data/ShipmentItem.php | 48 - .../Sales/Service/V1/Data/ShipmentMapper.php | 89 ++ .../Sales/Service/V1/Data/ShipmentTrack.php | 43 - .../Magento/Sales/Service/V1/InvoiceRead.php | 98 ++ ...Interface.php => InvoiceReadInterface.php} | 25 +- .../Magento/Sales/Service/V1/InvoiceWrite.php | 132 +++ .../Service/V1/InvoiceWriteInterface.php | 63 + .../Magento/Sales/Service/V1/OrderRead.php | 112 ++ ...stInterface.php => OrderReadInterface.php} | 31 +- .../Magento/Sales/Service/V1/OrderWrite.php | 173 +++ .../Sales/Service/V1/OrderWriteInterface.php | 79 ++ .../Magento/Sales/Service/V1/ShipmentRead.php | 112 ++ .../Service/V1/ShipmentReadInterface.php | 55 + .../Sales/Service/V1/ShipmentWrite.php | 133 +++ .../Service/V1/ShipmentWriteInterface.php | 64 + app/code/Magento/Sales/composer.json | 42 +- app/code/Magento/Sales/etc/di.xml | 18 +- app/code/Magento/Sales/etc/module.xml | 2 +- app/code/Magento/Sales/etc/webapi.xml | 190 ++- .../layout/sales_creditmemo_item_price.xml | 32 + .../layout/sales_invoice_item_price.xml | 32 + .../layout/sales_order_create_index.xml | 1 + .../layout/sales_order_create_item_price.xml | 30 + .../sales_order_create_load_block_data.xml | 1 + .../sales_order_create_load_block_items.xml | 1 + .../layout/sales_order_creditmemo_new.xml | 1 + .../sales_order_creditmemo_updateqty.xml | 1 + .../layout/sales_order_creditmemo_view.xml | 1 + .../layout/sales_order_invoice_new.xml | 1 + .../layout/sales_order_invoice_updateqty.xml | 1 + .../layout/sales_order_invoice_view.xml | 1 + .../layout/sales_order_item_price.xml | 32 + .../adminhtml/layout/sales_order_view.xml | 1 + .../adminhtml/templates/items/price/row.phtml | 33 + .../templates/items/price/total.phtml | 31 + .../templates/items/price/unit.phtml | 32 + .../templates/order/create/items/grid.phtml | 230 +--- .../order/create/items/price/row.phtml | 33 + .../order/create/items/price/total.phtml | 32 + .../order/create/items/price/unit.phtml | 32 + .../create/items/renderer/default.phtml | 195 +-- .../view/items/renderer/default.phtml | 196 +--- .../create/items/renderer/default.phtml | 188 +-- .../invoice/view/items/renderer/default.phtml | 192 +-- .../order/view/items/renderer/default.phtml | 195 +-- .../layout/sales_email_item_price.xml | 30 + .../sales_email_order_creditmemo_items.xml | 1 + .../sales_email_order_invoice_items.xml | 1 + .../layout/sales_email_order_items.xml | 1 + .../layout/sales_guest_creditmemo.xml | 1 + .../frontend/layout/sales_guest_invoice.xml | 1 + .../frontend/layout/sales_guest_print.xml | 1 + .../layout/sales_guest_printcreditmemo.xml | 1 + .../layout/sales_guest_printinvoice.xml | 1 + .../view/frontend/layout/sales_guest_view.xml | 1 + .../layout/sales_order_creditmemo.xml | 1 + .../frontend/layout/sales_order_invoice.xml | 1 + .../layout/sales_order_item_price.xml | 30 + .../frontend/layout/sales_order_print.xml | 1 + .../layout/sales_order_printcreditmemo.xml | 1 + .../layout/sales_order_printinvoice.xml | 1 + .../view/frontend/layout/sales_order_view.xml | 1 + .../email/items/creditmemo/default.phtml | 75 +- .../email/items/invoice/default.phtml | 75 +- .../templates/email/items/order/default.phtml | 77 +- .../templates/email/items/price/row.phtml | 34 + .../frontend/templates/items/price/row.phtml | 32 + .../items/price/total_after_discount.phtml | 29 + .../frontend/templates/items/price/unit.phtml | 32 + .../creditmemo/items/renderer/default.phtml | 167 +-- .../invoice/items/renderer/default.phtml | 168 +-- .../order/items/renderer/default.phtml | 164 +-- app/code/Magento/SalesRule/composer.json | 34 +- .../Magento/Sendfriend/Controller/Product.php | 30 +- .../Magento/Sendfriend/Model/Sendfriend.php | 115 +- app/code/Magento/Sendfriend/composer.json | 14 +- .../Adminhtml/Order/Shipment/AddComment.php | 10 +- .../Adminhtml/Order/Shipment/AddTrack.php | 6 +- .../Adminhtml/Order/Shipment/CreateLabel.php | 15 +- .../Adminhtml/Order/Shipment/Email.php | 40 +- .../Order/Shipment/GetShippingItemsGrid.php | 6 +- .../Adminhtml/Order/Shipment/NewAction.php | 6 +- .../Adminhtml/Order/Shipment/PrintLabel.php | 8 +- .../Adminhtml/Order/Shipment/PrintPackage.php | 7 +- .../Adminhtml/Order/Shipment/RemoveTrack.php | 15 +- .../Adminhtml/Order/Shipment/Save.php | 19 +- .../Adminhtml/Order/Shipment/View.php | 7 +- .../Adminhtml/Order/ShipmentLoader.php | 45 +- .../Shipping/Model/ShipmentNotifier.php | 66 ++ .../Model/Shipping/LabelGenerator.php | 30 +- app/code/Magento/Shipping/composer.json | 26 +- app/code/Magento/Sitemap/composer.json | 16 +- .../Store/App/Action/Plugin/Context.php | 12 +- .../Magento/Store/Model/StorageFactory.php | 31 +- app/code/Magento/Store/Model/Store.php | 29 +- app/code/Magento/Store/composer.json | 10 +- app/code/Magento/Store/etc/di.xml | 1 + .../Block/Adminhtml/Items/Price/Renderer.php | 176 +++ .../Magento/Tax/Block/Item/Price/Renderer.php | 183 ++- .../Tax/Model/Resource/Calculation.php | 56 +- app/code/Magento/Tax/composer.json | 30 +- .../layout/sales_creditmemo_item_price.xml | 32 + .../layout/sales_invoice_item_price.xml | 32 + .../layout/sales_order_create_item_price.xml | 42 + .../layout/sales_order_item_price.xml | 32 + .../adminhtml/templates/items/price/row.phtml | 48 + .../templates/items/price/total.phtml | 31 + .../templates/items/price/unit.phtml | 51 + .../order/create/items/price/row.phtml | 44 + .../order/create/items/price/total.phtml | 46 + .../order/create/items/price/unit.phtml | 45 + .../layout/sales_email_item_price.xml | 34 + .../layout/sales_order_item_price.xml | 38 + .../templates/email/items/price/row.phtml | 47 + .../frontend/templates/item/price/row.phtml | 4 +- .../item/price/total_after_discount.phtml | 29 + .../frontend/templates/item/price/unit.phtml | 6 +- app/code/Magento/Theme/composer.json | 16 +- .../Theme/view/adminhtml/web/js/bootstrap.js | 2 +- app/code/Magento/Translation/composer.json | 10 +- app/code/Magento/Ups/composer.json | 18 +- app/code/Magento/UrlRedirect/composer.json | 16 +- .../Magento/UrlRewrite/Model/UrlRewrite.php | 137 +-- app/code/Magento/UrlRewrite/composer.json | 10 +- app/code/Magento/UrlRewrite/etc/module.xml | 4 +- app/code/Magento/User/composer.json | 16 +- app/code/Magento/Usps/composer.json | 18 +- .../Magento/Webapi/Controller/Request.php | 20 + .../Webapi/Controller/Rest/Request.php | 4 +- .../Config/ClassReflector/TypeProcessor.php | 6 +- app/code/Magento/Webapi/composer.json | 16 +- .../Block/Adminhtml/Items/Price/Renderer.php | 202 ++++ .../Weee/Block/Item/Price/Renderer.php | 239 +++- app/code/Magento/Weee/Helper/Data.php | 3 +- app/code/Magento/Weee/composer.json | 24 +- .../layout/sales_creditmemo_item_price.xml | 32 + .../layout/sales_invoice_item_price.xml | 32 + .../layout/sales_order_create_item_price.xml | 42 + .../layout/sales_order_item_price.xml | 32 + .../adminhtml/templates/items/price/row.phtml | 85 ++ .../templates/items/price/total.phtml | 31 + .../templates/items/price/unit.phtml | 86 ++ .../order/create/items/price/row.phtml | 78 ++ .../order/create/items/price/total.phtml | 82 ++ .../order/create/items/price/unit.phtml | 79 ++ ...kout_cart_sidebar_item_price_renderers.xml | 6 +- .../layout/checkout_item_price_renderers.xml | 36 +- .../layout/sales_email_item_price.xml | 34 + .../layout/sales_order_item_price.xml | 38 + .../templates/email/items/price/row.phtml | 79 ++ .../item/price/total_after_discount.phtml | 29 + app/code/Magento/Widget/composer.json | 16 +- .../Wishlist/Item/Column/Actions.php} | 17 +- .../Customer/Wishlist/Item/Column/Edit.php | 34 + .../Customer/Wishlist/Item/Column/Info.php | 34 + app/code/Magento/Wishlist/Block/Rss.php | 3 +- app/code/Magento/Wishlist/Helper/Data.php | 2 +- app/code/Magento/Wishlist/composer.json | 32 +- .../frontend/layout/wishlist_index_index.xml | 35 +- .../item/column/{info.phtml => actions.phtml} | 14 +- .../frontend/templates/item/column/cart.phtml | 28 +- .../templates/item/column/comment.phtml | 30 + .../frontend/templates/item/column/edit.phtml | 34 + .../templates/item/column/image.phtml | 2 +- .../frontend/templates/item/column/name.phtml | 33 + .../templates/item/column/price.phtml | 30 + .../view/frontend/templates/item/list.phtml | 41 +- .../frontend/templates/options_list.phtml | 2 +- .../view/frontend/templates/view.phtml | 2 +- .../web/css/source/module.less | 132 +++ .../adminhtml/Magento/backend/composer.json | 4 +- .../adminhtml/Magento/backend/theme.xml | 2 +- .../Magento/backend/web/css/admin.less | 115 +- .../Magento_Bundle/web/css/source/module.less | 6 +- .../web/css/source/listings.less | 240 ++++ .../web/css/source/module.less | 237 +--- .../web/css/source/module.less | 35 +- .../web/css/source/module.less | 214 ++++ .../frontend/Magento/blank/composer.json | 4 +- .../frontend/Magento/blank/etc/view.xml | 4 +- app/design/frontend/Magento/blank/theme.xml | 2 +- .../blank/web/css/source/abstract.less | 96 +- .../Magento/blank/web/css/source/layout.less | 4 +- .../frontend/Magento/plushe/composer.json | 6 +- app/design/frontend/Magento/plushe/theme.xml | 2 +- app/design/install/Magento/basic/theme.xml | 2 +- app/etc/di.xml | 1 + app/i18n/magento/de_de/composer.json | 4 +- app/i18n/magento/en_us/composer.json | 4 +- app/i18n/magento/es_es/composer.json | 4 +- app/i18n/magento/fr_fr/composer.json | 4 +- app/i18n/magento/nl_nl/composer.json | 4 +- app/i18n/magento/pt_br/composer.json | 4 +- app/i18n/magento/zh_cn/composer.json | 4 +- composer.json | 2 +- .../Magento/TestFramework/Application.php | 3 + .../{Cookie.php => CookieManager.php} | 20 +- .../ObjectManager/Configurator.php | 7 +- .../TestFramework/ObjectManagerFactory.php | 3 + .../testsuite/Magento/Test/RequestTest.php | 5 +- .../testsuite/Magento/Test/ResponseTest.php | 5 +- .../Test/TestCase/ControllerAbstractTest.php | 10 +- .../Model/Config/Backend/DomainTest.php | 78 ++ .../Model/Product/ProductList/ToolbarTest.php | 76 ++ .../Model/Import/ProductTest.php | 1 + .../Search/Request/Config/ConverterTest.php | 2 +- .../Framework/Search/Request/MapperTest.php | 44 +- .../Search/_files/search_request.xml | 30 +- .../Search/_files/search_request_config.php | 69 +- .../Magento/Framework/Session/ConfigTest.php | 14 +- .../Persistent/Model/Observer/SessionTest.php | 25 +- .../Magento/Persistent/Model/SessionTest.php | 120 ++ .../Magento/Sales/_files/creditmemo.php | 1 + .../Sales/_files/creditmemo_for_get.php | 56 + .../_files/creditmemo_for_get_rollback.php | 7 +- .../Sales/_files/creditmemo_rollback.php | 25 + .../Sales/_files/creditmemo_with_list.php | 31 +- .../_files/creditmemo_with_list_rollback.php | 25 + .../Magento/Sales/_files/default_rollback.php | 45 + .../Magento/Sales/_files/invoice.php | 1 + .../Magento/Sales/_files/invoice_rollback.php | 25 + .../testsuite/Magento/Sales/_files/order.php | 6 + .../Magento/Sales/_files/order_rollback.php | 25 + .../Magento/Sales/_files/shipment.php | 43 + .../Sales/_files/shipment_rollback.php | 24 + .../Magento/Store/Model/StoreTest.php | 131 ++- .../UrlRewrite/Model/UrlRewriteTest.php | 198 +++- .../Magento/TestFramework/Utility/Classes.php | 2 +- .../Magento/TestFramework/Utility/Files.php | 2 +- .../Magento/Test/Integrity/DependencyTest.php | 50 +- .../Magento/Framework/Search/ConfigTest.php | 1 + .../Search/_files/invalid_partial.xml | 2 + .../Magento/Framework/Search/_files/valid.xml | 3 + .../Test/Legacy/_files/obsolete_classes.php | 1 + .../Test/Legacy/_files/obsolete_methods.php | 10 +- .../Php/_files/phpcpd/blacklist/common.txt | 3 +- .../Matcher/MethodInvokedAtIndexTest.php | 2 - .../Magento/Backend/AdminConfigTest.php | 91 ++ .../App/Response/Http/FileFactoryTest.php | 12 +- .../Backend/Model/Auth/SessionTest.php | 66 +- .../Model/Config/Backend/DomainTest.php | 121 ++ .../Pricing/Adjustment/CalculatorTest.php | 217 ++-- .../Bundle/Pricing/Price/GroupPriceTest.php | 35 +- .../Product/Action/Attribute/SaveTest.php | 2 +- .../Magento/Catalog/Model/LayerTest.php | 342 ++++++ .../Model/Product/ProductList/ToolbarTest.php | 58 +- .../Category/ProductLinks/ReadServiceTest.php | 28 +- .../Service/V1/Category/WriteServiceTest.php | 5 +- .../Service/V1/Data/Category/MapperTest.php | 20 +- .../Service/V1/Data/ProductMapperTest.php | 49 +- .../Service/V1/MetadataServiceTest.php | 183 ++- .../V1/Product/GroupPriceServiceTest.php | 133 ++- .../V1/Product/MetadataServiceTest.php | 162 +++ .../V1/Product/TierPriceServiceTest.php | 207 +++- .../Catalog/Service/V1/ProductServiceTest.php | 228 +++- .../CatalogInventory/Model/Stock/ItemTest.php | 17 +- .../Service/V1/StockItemServiceTest.php | 54 +- .../Magento/Checkout/Helper/CartTest.php | 51 +- .../Checkout/Helper/ExpressRedirectTest.php | 2 +- .../Checkout/Model/Type/OnepageTest.php | 2 +- .../Model/Attribute/LockValidatorTest.php | 145 +++ .../Group/AttributeMapper/PluginTest.php | 130 ++ .../Service/V1/Data/OptionConverterTest.php | 32 +- .../V1/Product/Link/WriteServiceTest.php | 37 + .../V1/Product/Option/WriteServiceTest.php | 141 ++- .../Core/Controller/Request/HttpTest.php | 106 -- .../Core/Controller/Response/HttpTest.php | 76 -- .../Controller/Account/CreateTest.php | 10 +- .../Controller/Account/LoginPostTest.php | 24 +- .../Adminhtml/Index/NewsletterTest.php | 9 +- .../Adminhtml/Index/ResetPasswordTest.php | 2 +- .../Magento/Customer/Helper/DataTest.php | 6 +- .../Customer/Model/Metadata/Form/FileTest.php | 14 +- .../Controller/Varien/Router/StandardTest.php | 23 +- .../V1/Data/FileContentValidatorTest.php | 36 +- .../Resource/Attribute/CollectionTest.php | 4 +- .../Framework/App/Action/ActionTest.php | 3 +- .../Framework/App/Action/ForwardTest.php | 63 +- .../Magento/Framework/App/HttpTest.php | 9 +- .../Framework/App/PageCache/FormKeyTest.php | 19 +- .../Framework/App/PageCache/KernelTest.php | 2 +- .../Framework/App/PageCache/VersionTest.php | 62 +- .../Framework/App/Request/HttpTest.php | 215 +++- .../App/Response/Http/FileFactoryTest.php | 4 +- .../Framework/App/Response/HttpTest.php | 210 +++- .../Framework/HTTP/AuthenticationTest.php | 16 +- .../Generator/_files/SampleRepository.txt | 11 +- .../Framework/Search/AdapterFactoryTest.php | 97 ++ .../Framework/Search/AggregationTest.php | 82 ++ .../Magento/Framework/Search/DocumentTest.php | 82 ++ .../Framework/Search/QueryResponseTest.php | 95 ++ .../Framework/Search/Request/MapperTest.php | 1045 +++++++++++++++++ .../Framework/Search/RequestFactoryTest.php | 37 +- .../Framework/Search/SearchEngineTest.php | 80 ++ .../Magento/Framework/Session/ConfigTest.php | 115 +- .../Framework/Session/SessionManagerTest.php | 26 +- .../Cookie/PublicCookieMetadataTest.php | 4 +- .../testsuite/Magento/Framework/UrlTest.php | 95 +- .../App/FrontController/MessageBoxTest.php | 111 +- .../Magento/Persistent/Model/SessionTest.php | 188 ++- .../Controller/Adminhtml/Product/PostTest.php | 3 +- .../testsuite/Magento/Rss/Model/RssTest.php | 55 + .../Items/Column/DefaultColumnTest.php | 82 ++ .../Adminhtml/Order/Create/Items/GridTest.php | 121 +- .../Order/Email/Items/DefaultItemsTest.php | 104 ++ .../Email/Items/Order/DefaultOrderTest.php | 104 ++ .../Item/Renderer/DefaultRendererTest.php | 182 +++ .../AbstractCreditmemo/EmailTest.php | 247 ++++ .../Order/Creditmemo/AddCommentTest.php | 254 ++++ .../Adminhtml/Order/Creditmemo/CancelTest.php | 262 +++++ .../Order/Creditmemo/NewActionTest.php | 281 +++++ .../Order/Creditmemo/PrintActionTest.php | 209 ++++ .../Order/Creditmemo/UpdateQtyTest.php | 263 +++++ .../Adminhtml/Order/Creditmemo/ViewTest.php | 253 ++++ .../Adminhtml/Order/Creditmemo/VoidTest.php | 271 +++++ .../Adminhtml/Order/CreditmemoLoaderTest.php | 274 +++++ .../Controller/Adminhtml/Order/EmailTest.php | 260 ++++ .../Order/Invoice/AddCommentTest.php | 257 ++++ .../Adminhtml/Order/Invoice/CancelTest.php | 327 ++++++ .../Adminhtml/Order/Invoice/CaptureTest.php | 327 ++++++ .../Adminhtml/Order/Invoice/NewActionTest.php | 254 ++++ .../Order/Invoice/PrintActionTest.php | 149 +++ .../Adminhtml/Order/Invoice/UpdateQtyTest.php | 247 ++++ .../Adminhtml/Order/Invoice/ViewTest.php | 227 ++++ .../Adminhtml/Order/Invoice/VoidTest.php | 331 ++++++ .../Adminhtml/Order/InvoiceLoaderTest.php | 212 ++++ .../Magento/Sales/Helper/GuestTest.php | 46 +- .../Model/Order/Address/ValidatorTest.php | 4 + .../Magento/Sales/Model/Order/ConfigTest.php | 2 - .../Creditmemo/Comment/ValidatorTest.php | 113 ++ .../Model/Order/CreditmemoNotifierTest.php | 165 +++ .../Sales/Model/Order/CreditmemoTest.php | 144 +++ .../Model/Order/Customer/BuilderTest.php | 184 +++ .../Sales/Model/Order/CustomerTest.php | 265 +++++ .../Order/Invoice/Comment/ValidatorTest.php | 113 ++ .../Sales/Model/Order/InvoiceNotifierTest.php | 165 +++ .../Magento/Sales/Model/Order/InvoiceTest.php | 87 +- .../Order/Shipment/Comment/ValidatorTest.php | 113 ++ .../Order/Shipment/Track/ValidatorTest.php | 123 ++ .../Sales/Model/OrderConverterTest.php | 486 ++++++++ ...NotifierTest.php => OrderNotifierTest.php} | 10 +- .../Magento/Sales/Model/OrderTest.php | 21 +- .../Model/Resource/Order/AddressTest.php | 4 +- .../Resource/Order/Creditmemo/CommentTest.php | 138 +++ .../Resource/Order/Invoice/CommentTest.php | 138 +++ .../Resource/Order/Shipment/CommentTest.php | 138 +++ .../Resource/Order/Shipment/TrackTest.php | 138 +++ .../Order/Status/History/CollectionTest.php | 159 +++ .../V1/Action/CreditmemoAddCommentTest.php | 93 ++ .../V1/Action/CreditmemoCancelTest.php | 84 ++ .../V1/Action/CreditmemoCommentsListTest.php | 197 ++++ .../V1/Action/CreditmemoCreateTest.php | 143 +++ .../Service/V1/Action/CreditmemoEmailTest.php | 94 ++ .../Service/V1/Action/CreditmemoGetTest.php | 113 ++ .../Service/V1/Action/CreditmemoListTest.php | 154 +++ .../V1/Action/InvoiceAddCommentTest.php | 93 ++ .../Service/V1/Action/InvoiceCaptureTest.php | 84 ++ .../V1/Action/InvoiceCommentsListTest.php | 197 ++++ .../Service/V1/Action/InvoiceCreateTest.php | 120 ++ .../Service/V1/Action/InvoiceEmailTest.php | 92 ++ .../Service/V1/Action/InvoiceGetTest.php | 110 ++ .../Service/V1/Action/InvoiceListTest.php | 150 +++ .../Service/V1/Action/InvoiceVoidTest.php | 84 ++ .../{ => Action}/OrderAddressUpdateTest.php | 2 +- .../V1/{ => Action}/OrderCancelTest.php | 8 +- .../V1/{ => Action}/OrderCommentsListTest.php | 14 +- .../OrderEmailTest.php} | 11 +- .../V1/{ => Action}/OrderGetStatusTest.php | 6 +- .../Service/V1/{ => Action}/OrderGetTest.php | 10 +- .../Service/V1/{ => Action}/OrderHoldTest.php | 10 +- .../Service/V1/{ => Action}/OrderListTest.php | 12 +- .../OrderStatusHistoryAddTest.php | 4 +- .../V1/{ => Action}/OrderUnHoldTest.php | 8 +- .../V1/Action/ShipmentAddCommentTest.php | 93 ++ .../V1/Action/ShipmentAddTrackTest.php | 93 ++ .../V1/Action/ShipmentCommentsListTest.php | 197 ++++ .../Service/V1/Action/ShipmentCreateTest.php | 130 ++ .../Service/V1/Action/ShipmentEmailTest.php | 64 + .../Service/V1/Action/ShipmentGetTest.php | 117 ++ .../V1/Action/ShipmentLabelGetTest.php | 81 ++ .../Service/V1/Action/ShipmentListTest.php | 150 +++ .../V1/Action/ShipmentRemoveTrackTest.php | 83 ++ .../Sales/Service/V1/CreditmemoReadTest.php | 121 ++ .../Sales/Service/V1/CreditmemoWriteTest.php | 148 +++ .../Service/V1/Data/CreditmemoCommentTest.php | 123 -- .../V1/Data/CreditmemoConverterTest.php | 80 ++ .../Service/V1/Data/CreditmemoMapperTest.php | 127 ++ .../Sales/Service/V1/Data/CreditmemoTest.php | 16 + .../Service/V1/Data/InvoiceConverterTest.php | 121 ++ .../Service/V1/Data/InvoiceMapperTest.php | 127 ++ .../Sales/Service/V1/Data/InvoiceTest.php | 18 +- .../Service/V1/Data/ShipmentConverterTest.php | 90 ++ .../Service/V1/Data/ShipmentMapperTest.php | 167 +++ .../Sales/Service/V1/InvoiceReadTest.php | 121 ++ .../Sales/Service/V1/InvoiceWriteTest.php | 172 +++ .../Sales/Service/V1/OrderReadTest.php | 146 +++ .../Sales/Service/V1/OrderWriteTest.php | 224 ++++ .../Sales/Service/V1/ShipmentReadTest.php | 146 +++ .../Sales/Service/V1/ShipmentWriteTest.php | 174 +++ .../Sendfriend/Model/SendfriendTest.php | 98 ++ .../Order/Shipment/AddCommentTest.php | 331 ++++++ .../Adminhtml/Order/Shipment/AddTrackTest.php | 262 +++++ .../Order/Shipment/CreateLabelTest.php | 257 ++++ .../Adminhtml/Order/Shipment/EmailTest.php | 266 +++++ .../Shipment/GetShippingItemsGridTest.php | 175 +++ .../Order/Shipment/NewActionTest.php | 293 +++++ .../Order/Shipment/PrintLabelTest.php | 386 ++++++ .../Order/Shipment/PrintPackageTest.php | 243 ++++ .../Order/Shipment/RemoveTrackTest.php | 325 +++++ .../Adminhtml/Order/Shipment/SaveTest.php | 317 +++++ .../Adminhtml/Order/Shipment/ViewTest.php | 300 +++++ .../Adminhtml/Order/ShipmentLoaderTest.php | 211 ++++ .../Shipping/Model/ShipmentNotifierTest.php | 165 +++ .../Magento/Shipping/Model/ShipmentTest.php | 130 ++ .../Store/App/Action/Plugin/ContextTest.php | 36 +- .../App/Request/PathInfoProcessorTest.php | 3 +- .../Store/App/Response/RedirectTest.php | 3 +- .../Magento/Store/Helper/CookieTest.php | 4 +- .../Store/Model/StorageFactoryTest.php | 126 +- .../Magento/Store/Model/StoreTest.php | 71 +- .../Adminhtml/Items/Price/RendererTest.php | 149 +++ .../Tax/Block/Item/Price/RendererTest.php | 384 +++++- .../Tax/Model/Resource/CalculationTest.php | 111 ++ .../UrlRewrite/Model/UrlRewriteTest.php | 103 ++ .../Magento/Webapi/Controller/RequestTest.php | 68 ++ .../Webapi/Controller/Rest/RequestTest.php | 9 +- .../Webapi/Controller/Rest/RouterTest.php | 32 +- .../Webapi/Controller/Soap/RequestTest.php | 12 +- .../ClassReflector/TypeProcessorTest.php | 3 +- .../Weee/Block/Item/Price/RendererTest.php | 396 ++++++- .../Magento/_files/session_set_name_mock.php | 17 +- .../Magento/Framework/App/Console/Request.php | 11 + .../Framework/App/PageCache/FormKey.php | 14 +- .../Framework/App/PageCache/Version.php | 29 +- .../Magento/Framework/App/Request/Http.php | 20 + .../Framework/App/RequestInterface.php | 9 + .../Magento/Framework/App/Response/Http.php | 53 +- .../Magento/Framework/AppInterface.php | 2 +- .../Data/Form/Element/Editablemultiselect.php | 41 +- .../Code/Generator/Repository.php | 19 +- .../Magento/Framework/Pricing/Render.php | 1 + .../Search/Adapter/Mysql/Adapter.php | 77 ++ .../Adapter/Mysql/AggregationFactory.php | 67 ++ .../Search/Adapter/Mysql/DocumentFactory.php | 67 ++ .../Framework/Search/Adapter/Mysql/Mapper.php | 22 +- .../Search/Adapter/Mysql/ResponseFactory.php | 91 ++ .../Framework/Search/AdapterFactory.php | 91 ++ .../Framework/Search/AdapterInterface.php | 18 +- .../Magento/Framework/Search/Aggregation.php | 75 ++ .../Magento/Framework/Search/Bucket.php | 73 ++ .../Magento/Framework/Search/Document.php | 97 ++ .../Framework/Search/DocumentField.php | 50 +- .../Framework/Search/QueryResponse.php | 82 ++ .../Magento/Framework/Search/Request.php | 19 +- .../Search/Request/Aggregation/Metric.php | 32 +- .../Search/Request/BucketInterface.php | 4 +- .../Search/Request/Config/Converter.php | 28 +- .../Framework/Search/Request/Dimension.php | 59 + .../Framework/Search/Request/Mapper.php | 190 ++- .../Framework/Search/RequestFactory.php | 16 +- .../Framework/Search/RequestInterface.php | 7 +- .../Magento/Framework/Search/SearchEngine.php | 16 +- .../Magento/Framework/Search/etc/requests.xsd | 16 + .../Magento/Framework/Session/Config.php | 51 +- .../Session/Config/ConfigInterface.php | 8 - .../Magento/Framework/Session/Generic.php | 15 +- .../Framework/Session/SessionManager.php | 70 +- .../Magento/Framework/Stdlib/Cookie.php | 104 -- .../Stdlib/Cookie/CookieMetadataFactory.php | 2 +- .../Stdlib/Cookie/PhpCookieManager.php | 8 +- .../Stdlib/Cookie/PublicCookieMetadata.php | 10 + .../Framework/View/Element/Html/Date.php | 6 - lib/internal/Magento/Framework/composer.json | 2 +- lib/web/app-config.js | 2 +- lib/web/css/source/lib/popups.less | 2 +- .../jquery/fileUploader/jquery.fileupload.js | 3 +- lib/web/mage/backend/button.js | 57 +- lib/web/mage/backend/validation.js | 3 +- lib/web/mage/loader_old.js | 2 +- lib/web/mage/mage.js | 7 - lib/web/mage/requirejs/resolver.js | 130 ++ pub/errors/404.php | 11 +- pub/errors/503.php | 11 +- pub/errors/noCache.php | 10 +- pub/errors/processor.php | 2 +- .../errors/processorFactory.php | 24 +- pub/errors/report.php | 12 +- 829 files changed, 37808 insertions(+), 9866 deletions(-) create mode 100644 app/code/Magento/Backend/AdminConfig.php create mode 100644 app/code/Magento/Backend/Model/Config/Backend/Domain.php rename app/code/Magento/Sales/Model/{Notifier.php => AbstractNotifier.php} (78%) create mode 100644 app/code/Magento/Sales/Model/Order/Builder.php create mode 100644 app/code/Magento/Sales/Model/Order/Creditmemo/Comment/Validator.php create mode 100644 app/code/Magento/Sales/Model/Order/CreditmemoNotifier.php create mode 100644 app/code/Magento/Sales/Model/Order/Customer.php create mode 100644 app/code/Magento/Sales/Model/Order/Customer/Builder.php create mode 100644 app/code/Magento/Sales/Model/Order/Invoice/Comment/Validator.php create mode 100644 app/code/Magento/Sales/Model/Order/InvoiceNotifier.php create mode 100644 app/code/Magento/Sales/Model/Order/Shipment/Comment/Validator.php create mode 100644 app/code/Magento/Sales/Model/Order/Shipment/Track/Validator.php create mode 100644 app/code/Magento/Sales/Model/OrderConverter.php create mode 100644 app/code/Magento/Sales/Model/OrderNotifier.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoAddComment.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoCancel.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoCommentsList.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoCreate.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoEmail.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoGet.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/CreditmemoList.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceAddComment.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceCapture.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceCommentsList.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceCreate.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceEmail.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceGet.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/InvoiceList.php rename app/code/Magento/Sales/Service/V1/{OrderUnHoldInterface.php => Action/InvoiceVoid.php} (65%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderAddressUpdate.php (91%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderCancel.php (92%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderCommentsList.php (97%) create mode 100644 app/code/Magento/Sales/Service/V1/Action/OrderCreate.php rename app/code/Magento/Sales/Service/V1/{OrderNotifyUser.php => Action/OrderEmail.php} (86%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderGet.php (90%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderGetStatus.php (94%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderHold.php (94%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderList.php (90%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderStatusHistoryAdd.php (95%) rename app/code/Magento/Sales/Service/V1/{ => Action}/OrderUnHold.php (94%) create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentAddComment.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentAddTrack.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentCommentsList.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentCreate.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentEmail.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentGet.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentLabelGet.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentList.php create mode 100644 app/code/Magento/Sales/Service/V1/Action/ShipmentRemoveTrack.php create mode 100644 app/code/Magento/Sales/Service/V1/CreditmemoRead.php create mode 100644 app/code/Magento/Sales/Service/V1/CreditmemoReadInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/CreditmemoWrite.php create mode 100644 app/code/Magento/Sales/Service/V1/CreditmemoWriteInterface.php delete mode 100644 app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/CreditmemoConverter.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/CreditmemoMapper.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/InvoiceConverter.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/InvoiceMapper.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/ShipmentConverter.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/ShipmentMapper.php create mode 100644 app/code/Magento/Sales/Service/V1/InvoiceRead.php rename app/code/Magento/Sales/Service/V1/{OrderGetInterface.php => InvoiceReadInterface.php} (66%) create mode 100644 app/code/Magento/Sales/Service/V1/InvoiceWrite.php create mode 100644 app/code/Magento/Sales/Service/V1/InvoiceWriteInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderRead.php rename app/code/Magento/Sales/Service/V1/{OrderCommentsListInterface.php => OrderReadInterface.php} (60%) create mode 100644 app/code/Magento/Sales/Service/V1/OrderWrite.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderWriteInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/ShipmentRead.php create mode 100644 app/code/Magento/Sales/Service/V1/ShipmentReadInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/ShipmentWrite.php create mode 100644 app/code/Magento/Sales/Service/V1/ShipmentWriteInterface.php create mode 100644 app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_item_price.xml create mode 100644 app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_item_price.xml create mode 100644 app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_item_price.xml create mode 100644 app/code/Magento/Sales/view/adminhtml/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/items/price/row.phtml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/items/price/total.phtml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/items/price/unit.phtml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/row.phtml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/total.phtml create mode 100644 app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/unit.phtml create mode 100644 app/code/Magento/Sales/view/frontend/layout/sales_email_item_price.xml create mode 100644 app/code/Magento/Sales/view/frontend/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Sales/view/frontend/templates/email/items/price/row.phtml create mode 100644 app/code/Magento/Sales/view/frontend/templates/items/price/row.phtml create mode 100644 app/code/Magento/Sales/view/frontend/templates/items/price/total_after_discount.phtml create mode 100644 app/code/Magento/Sales/view/frontend/templates/items/price/unit.phtml create mode 100644 app/code/Magento/Shipping/Model/ShipmentNotifier.php create mode 100644 app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php create mode 100644 app/code/Magento/Tax/view/adminhtml/layout/sales_creditmemo_item_price.xml create mode 100644 app/code/Magento/Tax/view/adminhtml/layout/sales_invoice_item_price.xml create mode 100644 app/code/Magento/Tax/view/adminhtml/layout/sales_order_create_item_price.xml create mode 100644 app/code/Magento/Tax/view/adminhtml/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/items/price/row.phtml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/items/price/total.phtml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/items/price/unit.phtml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/row.phtml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml create mode 100644 app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/unit.phtml create mode 100644 app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml create mode 100644 app/code/Magento/Tax/view/frontend/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Tax/view/frontend/templates/email/items/price/row.phtml create mode 100644 app/code/Magento/Tax/view/frontend/templates/item/price/total_after_discount.phtml create mode 100644 app/code/Magento/Weee/Block/Adminhtml/Items/Price/Renderer.php create mode 100644 app/code/Magento/Weee/view/adminhtml/layout/sales_creditmemo_item_price.xml create mode 100644 app/code/Magento/Weee/view/adminhtml/layout/sales_invoice_item_price.xml create mode 100644 app/code/Magento/Weee/view/adminhtml/layout/sales_order_create_item_price.xml create mode 100644 app/code/Magento/Weee/view/adminhtml/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/items/price/row.phtml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/items/price/total.phtml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/items/price/unit.phtml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/row.phtml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml create mode 100644 app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/unit.phtml create mode 100644 app/code/Magento/Weee/view/frontend/layout/sales_email_item_price.xml create mode 100644 app/code/Magento/Weee/view/frontend/layout/sales_order_item_price.xml create mode 100644 app/code/Magento/Weee/view/frontend/templates/email/items/price/row.phtml create mode 100644 app/code/Magento/Weee/view/frontend/templates/item/price/total_after_discount.phtml rename app/code/Magento/{Sales/Service/V1/OrderCancelInterface.php => Wishlist/Block/Customer/Wishlist/Item/Column/Actions.php} (75%) create mode 100644 app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Edit.php create mode 100644 app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Info.php rename app/code/Magento/Wishlist/view/frontend/templates/item/column/{info.phtml => actions.phtml} (62%) create mode 100644 app/code/Magento/Wishlist/view/frontend/templates/item/column/comment.phtml create mode 100644 app/code/Magento/Wishlist/view/frontend/templates/item/column/edit.phtml create mode 100644 app/code/Magento/Wishlist/view/frontend/templates/item/column/name.phtml create mode 100644 app/code/Magento/Wishlist/view/frontend/templates/item/column/price.phtml create mode 100644 app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/listings.less rename dev/tests/integration/framework/Magento/TestFramework/{Cookie.php => CookieManager.php} (66%) create mode 100644 dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Model/SessionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get.php rename lib/internal/Magento/Framework/Search/Response.php => dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get_rollback.php (89%) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_rollback.php rename app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php => dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list.php (58%) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/default_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/invoice_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/order_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/shipment.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/shipment_rollback.php create mode 100644 dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/MetadataServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Attribute/LockValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Core/Controller/Request/HttpTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/AdapterFactoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/AggregationTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Request/MapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/SearchEngineTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rss/Model/RssTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumnTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/DefaultItemsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoaderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintActionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/ViewTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Creditmemo/Comment/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoNotifierTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Customer/BuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/CustomerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Invoice/Comment/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceNotifierTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Comment/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Track/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/OrderConverterTest.php rename dev/tests/unit/testsuite/Magento/Sales/Model/{NotifierTest.php => OrderNotifierTest.php} (95%) create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/History/CollectionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoAddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCancelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCommentsListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCreateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoEmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoGetTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceAddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCaptureTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCommentsListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCreateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceEmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceGetTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceVoidTest.php rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderAddressUpdateTest.php (98%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderCancelTest.php (93%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderCommentsListTest.php (97%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{OrderNotifyUserTest.php => Action/OrderEmailTest.php} (84%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderGetStatusTest.php (92%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderGetTest.php (95%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderHoldTest.php (93%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderListTest.php (96%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderStatusHistoryAddTest.php (96%) rename dev/tests/unit/testsuite/Magento/Sales/Service/V1/{ => Action}/OrderUnHoldTest.php (93%) create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddTrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCommentsListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCreateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentEmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentGetTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentLabelGetTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentRemoveTrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoReadTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoWriteTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoMapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceMapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentMapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceReadTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceWriteTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderReadTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderWriteTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentReadTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentWriteTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/EmailTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackageTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/ViewTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoaderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentNotifierTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Tax/Block/Adminhtml/Items/Price/RendererTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php create mode 100644 dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Webapi/Controller/RequestTest.php rename app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php => dev/tests/unit/testsuite/Magento/_files/session_set_name_mock.php (79%) create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php rename app/code/Magento/Sales/Service/V1/OrderListInterface.php => lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php (69%) create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php create mode 100644 lib/internal/Magento/Framework/Search/AdapterFactory.php rename app/code/Magento/Sales/Service/V1/OrderHoldInterface.php => lib/internal/Magento/Framework/Search/AdapterInterface.php (77%) create mode 100644 lib/internal/Magento/Framework/Search/Aggregation.php create mode 100644 lib/internal/Magento/Framework/Search/Bucket.php create mode 100644 lib/internal/Magento/Framework/Search/Document.php rename dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php => lib/internal/Magento/Framework/Search/DocumentField.php (57%) create mode 100644 lib/internal/Magento/Framework/Search/QueryResponse.php rename app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php => lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php (73%) create mode 100644 lib/internal/Magento/Framework/Search/Request/Dimension.php delete mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie.php create mode 100644 lib/web/mage/requirejs/resolver.js rename app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php => pub/errors/processorFactory.php (64%) diff --git a/.htaccess.sample b/.htaccess.sample index ed07a267d1f..47944ce3105 100644 --- a/.htaccess.sample +++ b/.htaccess.sample @@ -31,7 +31,7 @@ ############################################ ## adjust memory limit - php_value memory_limit 128M + php_value memory_limit 256M php_value max_execution_time 18000 ############################################ diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c3e686cc2..cd6fbcb839b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,44 @@ +0.1.0-alpha93 +============= + * Price template refactoring + * Refactored order item templates in the Sales, Bundle and Downloadable modules + * Eliminated the unused PHTML templates and removed the direct dependencies on the TaxHelper module in the Catalog module + * Service layer implementation: + * Created service layer for Order creation + * Created service layer for Invoice + * Created service layer for Credit Memo + * Created service layer for Shipment + * Introduce the Search library: + * Created adapter interfaces for the Search library + * Created response structure + * Created parsing of XML declaration and creation of library objects (Queries, Filters, Aggregations) + * Refactored Framework\Stdlib\Cookie to use CookieManager + * Added the ability to prevent the backend cookie from going to the storefront + * Fixed bugs: + * Fixed an issue where taxes were not added in some orders + * Fixed an issue were the Add New Address button did not work if the default address was already set + * Fixed a Google Chrome and Internet Explorer specific issue when a JavaScript error made it impossible to register during checkout downloadable product + * Fixed an issue when the credit card iframe (PayPal or 3D secure) was absent on the Order Review step during Onepage Checkout + * Fixed an issue with the Tax Rate, Customer Tax Class and Product Tax Class multiselects on the Tax Rule Information page + * Fixed JavaScript issues which prevented saving a newsletter template. + * Modified the Button component behavior + * Fixed an issue where it was impossible for a guest customer to register during Onepage checkout when the Require Customer To Be Logged In To Checkout option was set to Yes + * Fixed an issue where the Calendar icons were not displayed on the storefront + * Fixed an AJAX loader issue in the Admin panel + * Fixed an issue where it was impossible to upload images for variations of a configurable product on product form + * Fixed an issue where clicking on a row in the Search Terms Report Grid leads to 404 page + * Fixed an issue where configurable products fixture creates out of stock products + * Fixed an issue where Magento crashed when invalid cookie domain was set + * Fixed an issue where the Change checkbox label overlapped the text message for a recurring profile attribute on the attribute mass update page + * Fixed an issue where integrity test determined normal dependencies as redundant + * Fixed an issue where Catalog\Service\V1\Product\Attribute\ReadService::search returned an error + * Fixed an issue where Magento\Catalog\Service\V1\Category\Attribute\ReadService::options returned empty results + * GitHub requests: + * [#160] (https://github.com/magento/bugathon_march_2013/issues/160) -- Wrong default value for memory_limit in .htaccess.sample + * [#480] (https://github.com/magento/magento2/pull/480) -- Provide instructions on adding memcache support for Magento 2 + * [#612] (https://github.com/magento/magento2/issues/612) -- Category Layered Navigation : Selection of disabled entity + * [#626] (https://github.com/magento/magento2/issues/626) -- Unable to install under IIS / FastCGI + 0.1.0-alpha92 ============= * Implemented API services: @@ -10,7 +51,7 @@ * Framework Improvements: * Ability to drop/regenerate access for native mobile apps * Ability to support extensible service data objects - * No Code Duplication in Root Templates (MAGETWO-26278) + * No Code Duplication in Root Templates * Fixed bugs: * Persistance session application. Loggin out the customer * Placing the order with two terms and conditions @@ -20,7 +61,7 @@ * Validation for country_id/region_id and percentage_rate during Tax Rate creation * Declaration of getSortOrders in Magento\Framework\Service\V1\Data\SearchCriteria * Order cancellation for online payment methods - * Order online processing for Authorize.net Direct Post + * Order online processing for Authorize.net Direct Post * Backend grids while search * Adding of downlodable sample block on product page * Variations on duplicated configurable product diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 43db83e7a6c..0ad3d3ae0fe 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 7d69a310753..90884f26fed 100644 --- a/app/code/Magento/Authorization/composer.json +++ b/app/code/Magento/Authorization/composer.json @@ -3,12 +3,12 @@ "description": "Authorization module provides access to Magento ACL functionality.", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Session.php b/app/code/Magento/Authorizenet/Model/Directpost/Session.php index f52da08f852..06709106c96 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Session.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Session.php @@ -35,6 +35,8 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param string|null $sessionName * @internal param array $data */ @@ -45,9 +47,20 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, $sessionName = null ) { - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start($sessionName); } diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 3afe9a4cc5a..dfc68dcc5c4 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-centinel": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-centinel": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/AdminConfig.php b/app/code/Magento/Backend/AdminConfig.php new file mode 100644 index 00000000000..01c29802308 --- /dev/null +++ b/app/code/Magento/Backend/AdminConfig.php @@ -0,0 +1,111 @@ +<?php +/** + * Backend Session configuration object + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Backend; + +use Magento\Backend\App\Area\FrontNameResolver; +use Magento\Framework\Session\Config; + +/** + * Magento Backend session configuration + * + * @method Config setSaveHandler() + */ +class AdminConfig extends Config +{ + /** + * @var FrontNameResolver $frontNameResolver + */ + protected $frontNameResolver; + + /** + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Framework\Stdlib\String $stringHelper + * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\App\Filesystem $filesystem + * @param string $scopeType + * @param FrontNameResolver $frontNameResolver + * @param string $saveMethod + * @param null|string $savePath + * @param null|string $cacheLimiter + * @param string $lifetimePath + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ + public function __construct( + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\Stdlib\String $stringHelper, + \Magento\Framework\App\RequestInterface $request, + \Magento\Framework\App\State $appState, + \Magento\Framework\App\Filesystem $filesystem, + $scopeType, + FrontNameResolver $frontNameResolver, + $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, + $savePath = null, + $cacheLimiter = null, + $lifetimePath = self::XML_PATH_COOKIE_LIFETIME + ) { + parent::__construct( + $scopeConfig, + $stringHelper, + $request, + $appState, + $filesystem, + $scopeType, + $saveMethod, + $savePath, + $cacheLimiter, + $lifetimePath + ); + + $this->frontNameResolver = $frontNameResolver; + + $baseUrl = $this->_httpRequest->getBaseUrl(); + $adminPath = $this->extractAdminPath($baseUrl); + $this->setCookiePath($adminPath); + } + + /** + * Determine the admin path + * + * @param string $baseUrl + * @return string + * @throws \InvalidArgumentException + */ + private function extractAdminPath($baseUrl) + { + if (!is_string($baseUrl)) { + throw new \InvalidArgumentException('Cookie path is not a string.'); + } + + $adminPath = $this->frontNameResolver->getFrontName(); + + if (!substr($baseUrl, -1) || ('/' != substr($baseUrl, -1))) { + $baseUrl = $baseUrl . '/'; + } + + return $baseUrl . $adminPath; + } +} diff --git a/app/code/Magento/Backend/Model/Auth/Session.php b/app/code/Magento/Backend/Model/Auth/Session.php index 42b75dd1e62..b30534c6f72 100644 --- a/app/code/Magento/Backend/Model/Auth/Session.php +++ b/app/code/Magento/Backend/Model/Auth/Session.php @@ -23,6 +23,9 @@ */ namespace Magento\Backend\Model\Auth; +use \Magento\Framework\Stdlib\CookieManager; +use \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; + /** * Backend Auth session model * @@ -44,7 +47,7 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage const XML_PATH_SESSION_LIFETIME = 'admin/security/session_lifetime'; /** - * Whether it is the first page after successfull login + * Whether it is the first page after successful login * * @var boolean */ @@ -67,11 +70,6 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage */ protected $_config; - /** - * @var \Magento\Framework\Stdlib\Cookie - */ - protected $_cookie; - /** * @param \Magento\Framework\App\Request\Http $request * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -79,10 +77,11 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param CookieManager $cookieManager + * @param CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\Acl\Builder $aclBuilder * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\App\ConfigInterface $config - * @param \Magento\Framework\Stdlib\Cookie $cookie */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -91,16 +90,25 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, + CookieManager $cookieManager, + CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\Acl\Builder $aclBuilder, \Magento\Backend\Model\UrlInterface $backendUrl, - \Magento\Backend\App\ConfigInterface $config, - \Magento\Framework\Stdlib\Cookie $cookie + \Magento\Backend\App\ConfigInterface $config ) { $this->_config = $config; $this->_aclBuilder = $aclBuilder; $this->_backendUrl = $backendUrl; - $this->_cookie = $cookie; - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start(); } @@ -187,22 +195,20 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage $currentTime = time(); $this->setUpdatedAt($currentTime); - $cookieValue = $this->_cookie->get($this->getName()); + $cookieValue = $this->cookieManager->getCookie($this->getName()); if ($cookieValue) { - $this->_cookie->set( - $this->getName(), - $cookieValue, - $lifetime, - $this->sessionConfig->getCookiePath(), - $this->sessionConfig->getCookieDomain(), - $this->sessionConfig->getCookieSecure(), - $this->sessionConfig->getCookieHttpOnly() - ); + $cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration($lifetime) + ->setPath($this->sessionConfig->getCookiePath()) + ->setDomain($this->sessionConfig->getCookieDomain()) + ->setSecure($this->sessionConfig->getCookieSecure()) + ->setHttpOnly($this->sessionConfig->getCookieHttpOnly()); + $this->cookieManager->setPublicCookie($this->getName(), $cookieValue, $cookieMetadata); } } /** - * Check if it is the first page after successfull login + * Check if it is the first page after successful login * * @return bool */ diff --git a/app/code/Magento/Backend/Model/Config/Backend/Domain.php b/app/code/Magento/Backend/Model/Config/Backend/Domain.php new file mode 100644 index 00000000000..ccc46d9ba9a --- /dev/null +++ b/app/code/Magento/Backend/Model/Config/Backend/Domain.php @@ -0,0 +1,50 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Backend\Model\Config\Backend; + +/** + * Backend model for domain config value + */ +class Domain extends \Magento\Framework\App\Config\Value +{ + /** + * Validate a domain name value + * + * @return void + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave() + { + $value = $this->getValue(); + + $validator = new \Zend\Validator\Hostname(\Zend\Validator\Hostname::ALLOW_ALL); + + // Empty value is treated valid and will be handled when read the value out + if (!empty($value) && !$validator->isValid($value)) { + throw new \Magento\Framework\Model\Exception( + 'Invalid domain name: ' . join('; ', $validator->getMessages()) + ); + } + } +} diff --git a/app/code/Magento/Backend/Model/Session.php b/app/code/Magento/Backend/Model/Session.php index 94769838c32..d36bb06c32d 100644 --- a/app/code/Magento/Backend/Model/Session.php +++ b/app/code/Magento/Backend/Model/Session.php @@ -34,6 +34,8 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -41,9 +43,20 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, - \Magento\Framework\Session\StorageInterface $storage + \Magento\Framework\Session\StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start('adminhtml'); } diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index d7acbf2752f..68d49ce4dbd 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -95,6 +95,8 @@ class Quote extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService * @param \Magento\Sales\Model\OrderFactory $orderFactory @@ -108,6 +110,8 @@ class Quote extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService, \Magento\Sales\Model\OrderFactory $orderFactory, @@ -119,7 +123,16 @@ class Quote extends \Magento\Framework\Session\SessionManager $this->_orderFactory = $orderFactory; $this->_storeManager = $storeManager; $this->_scopeConfig = $scopeConfig; - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start(); if ($this->_storeManager->hasSingleStore()) { $this->setStoreId($this->_storeManager->getStore(true)->getId()); diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index ca5f3dff77f..88d13211ba8 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -129,7 +129,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\Data\Form\FormKey $formKey, - array $data = array() + array $data = [] ) { $this->_encryptor = $encryptor; parent::__construct( @@ -207,11 +207,11 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn $controllerName = $this->_getControllerName(self::DEFAULT_CONTROLLER_NAME); $actionName = $this->_getActionName(self::DEFAULT_ACTION_NAME); if ($cacheSecretKey) { - $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"); + $secret = [self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"]; } else { - $secret = array( + $secret = [ self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($routeName, $controllerName, $actionName) - ); + ]; } if (is_array($routeParams)) { $routeParams = array_merge($secret, $routeParams); @@ -300,7 +300,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn */ public function renewSecretUrls() { - $this->_cache->clean(array(\Magento\Backend\Block\Menu::CACHE_TAGS)); + $this->_cache->clean([\Magento\Backend\Block\Menu::CACHE_TAGS]); } /** @@ -416,10 +416,10 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn { if (!$this->_scope) { $this->_scope = $this->_storeFactory->create( - array( + [ 'url' => $this, - 'data' => array('code' => 'admin', 'force_disable_rewrites' => true, 'disable_store_in_url' => true) - ) + 'data' => ['code' => 'admin', 'force_disable_rewrites' => false, 'disable_store_in_url' => true] + ] ); } return $this->_scope; diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index d09b2f14a6f..b294e2b0dd6 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,32 +3,32 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/module-sendfriend": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/module-reports": "0.1.0-alpha92", - "magento/module-catalog-search": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-user": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-backup": "0.1.0-alpha92", - "magento/module-email": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-url-rewrite": "0.1.0-alpha92", - "magento/module-translation": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/module-sendfriend": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-weee": "0.1.0-alpha93", + "magento/module-reports": "0.1.0-alpha93", + "magento/module-catalog-search": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-user": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-backup": "0.1.0-alpha93", + "magento/module-email": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-url-rewrite": "0.1.0-alpha93", + "magento/module-translation": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 781422eebdd..09512c7ec5a 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -36,7 +36,8 @@ <preference for="Magento\Framework\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" /> <preference for="Magento\Framework\App\View" type="Magento\Backend\Model\View" /> <preference for="Magento\Framework\Model\ActionValidator\RemoveAction" type="Magento\Framework\Model\ActionValidator\RemoveAction\Allowed" /> - <type name="Magento\Backend\App\Action\Context"> + <preference for="Magento\Framework\Session\Config\ConfigInterface" type="Magento\Backend\AdminConfig" /> + <type name="Magento\Backend\App\Action\Context"> <arguments> <argument name="helper" xsi:type="object">Magento\Backend\Helper\Data</argument> </arguments> @@ -97,7 +98,7 @@ <argument name="locale" xsi:type="object">Magento\Backend\Model\Locale\Resolver\Proxy</argument> </arguments> </type> - <type name="Magento\Core\Model\Session\Config"> + <type name="Magento\Backend\AdminConfig"> <arguments> <argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument> </arguments> diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index cc52c30d4f0..5314894c083 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -595,6 +595,7 @@ </field> <field id="cookie_domain" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Cookie Domain</label> + <backend_model>Magento\Backend\Model\Config\Backend\Domain</backend_model> </field> <field id="cookie_httponly" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Use HTTP Only</label> diff --git a/app/code/Magento/Backend/view/adminhtml/layout/default.xml b/app/code/Magento/Backend/view/adminhtml/layout/default.xml index cbe4ae2e7bb..cc535e0a52c 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/default.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/default.xml @@ -159,6 +159,11 @@ <argument name="file" xsi:type="string">requirejs/require.js</argument> </arguments> </block> + <block class="Magento\Theme\Block\Html\Head\Script" name="mage-requirejs-resolver"> + <arguments> + <argument name="file" xsi:type="string">mage/requirejs/resolver.js</argument> + </arguments> + </block> <block class="Magento\Theme\Block\Html\Head\Script" name="app-config" after="jquery"> <arguments> <argument name="file" xsi:type="string">app-config.js</argument> diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 36a9cad902e..74bcb2589ac 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/module-index": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/module-index": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php index ac0fb075fd5..2a542e6d53c 100644 --- a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php @@ -185,4 +185,17 @@ class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer } return false; } + + /** + * Get the html for item price + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item + * @return string + */ + public function getItemPrice($item) + { + $block = $this->getLayout()->getBlock('item_price'); + $block->setItem($item); + return $block->toHtml(); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php index b64fecdbd27..220b87e2340 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php @@ -24,7 +24,9 @@ namespace Magento\Bundle\Service\V1\Data\Product\Option; - +/** + * @codeCoverageIgnore + */ class TypeConverter { /** diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php index 9568d0b1e30..ab265ef5159 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php @@ -26,6 +26,8 @@ namespace Magento\Bundle\Service\V1\Product\Link\Data; /** * Bundle ProductLink Service Data Object + * + * @codeCoverageIgnore */ class ProductLink extends \Magento\Framework\Service\Data\Eav\AbstractObject { diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php index d646232c2da..9c26d51c295 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php @@ -30,6 +30,7 @@ use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; * Builder for the ProductLink Service Data Object * * @method ProductLink create() + * @codeCoverageIgnore */ class ProductLinkBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectBuilder { diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 0427ebbc87b..8b8afe8452b 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,26 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-catalog-rule": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/module-gift-message": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", - "magento/module-webapi": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-catalog-rule": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-gift-message": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", + "magento/module-webapi": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/etc/module.xml b/app/code/Magento/Bundle/etc/module.xml index d91076fb651..3af545dbed1 100644 --- a/app/code/Magento/Bundle/etc/module.xml +++ b/app/code/Magento/Bundle/etc/module.xml @@ -40,7 +40,6 @@ <module name="Magento_Customer"/> <module name="Magento_CatalogRule"/> <module name="Magento_Eav"/> - <module name="Magento_Weee"/> <module name="Magento_GiftMessage"/> <module name="Magento_Theme"/> <module name="Magento_Webapi"/> diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/create/items/renderer.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/create/items/renderer.phtml index dd71a1ff87c..a6d3871b318 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/create/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/create/items/renderer.phtml @@ -26,6 +26,7 @@ /** * @see \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ +/** @var $this \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> @@ -74,100 +75,7 @@ <?php endif; ?> <td class="col-price"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> <?php else: ?> <?php endif; ?> @@ -245,100 +153,7 @@ </td> <td class="col-subtotal"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - </span> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> <?php else: ?> <?php endif; ?> @@ -359,10 +174,7 @@ </td> <td class="col-total last"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/view/items/renderer.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/view/items/renderer.phtml index 08bfb2833ec..fd2ace92881 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/view/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/sales/creditmemo/view/items/renderer.phtml @@ -26,6 +26,7 @@ /** * @see \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ +/** @var $this \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> @@ -72,100 +73,7 @@ <?php endif; ?> <td class="col-price"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> <?php else: ?> <?php endif; ?> @@ -179,97 +87,7 @@ </td> <td class="col-subtotal"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - </span> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> <?php else: ?> <?php endif; ?> @@ -290,10 +108,7 @@ </td> <td class="col-total last"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml index e2cb0a835e6..01159d1009f 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/create/items/renderer.phtml @@ -26,6 +26,7 @@ /** * @see \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ +/** @var $this \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> @@ -75,100 +76,7 @@ <?php endif; ?> <td class="col-price"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> <?php else: ?> <?php endif; ?> @@ -235,100 +143,7 @@ </td> <td class="col-subtotal"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - </span> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> <?php else: ?> <?php endif; ?> @@ -349,10 +164,7 @@ </td> <td class="col-total last"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/view/items/renderer.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/view/items/renderer.phtml index 1e424aa4ca2..bfac0a12212 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/view/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/sales/invoice/view/items/renderer.phtml @@ -26,6 +26,7 @@ /** * @see \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ +/** @var $this \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> @@ -73,100 +74,7 @@ <?php endif; ?> <td class="col-price"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> <?php else: ?> <?php endif; ?> @@ -180,100 +88,7 @@ </td> <td class="col-subtotal"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - </span> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> <?php else: ?> <?php endif; ?> @@ -294,10 +109,7 @@ </td> <td class="col-total last"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getBaseWeeeTaxAppliedRowAmnt(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/sales/order/view/items/renderer.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/sales/order/view/items/renderer.phtml index 0524cf9c580..5f09f440506 100644 --- a/app/code/Magento/Bundle/view/adminhtml/templates/sales/order/view/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/adminhtml/templates/sales/order/view/items/renderer.phtml @@ -26,6 +26,7 @@ /** * @see \Magento\Bundle\Block\Adminhtml\Sales\Order\View\Items\Renderer */ +/** @var $this \Magento\Bundle\Block\Adminhtml\Sales\Order\View\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> @@ -93,100 +94,7 @@ </td> <td class="col-price"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> <?php else: ?> <?php endif; ?> @@ -242,99 +150,7 @@ </td> <td class="col-subtotal"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> <?php else: ?> <?php endif; ?> @@ -362,10 +178,7 @@ </td> <td class="col-total last"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->displayPrices( - max(0, $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt()), - max(0, $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount()) - ); ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/creditmemo/default.phtml b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/creditmemo/default.phtml index d1ec525d1d1..68a1033c49c 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/creditmemo/default.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/creditmemo/default.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?> <?php $parentItem = $this->getItem() ?> <?php $_order = $this->getItem()->getOrder(); ?> @@ -65,80 +66,7 @@ </td> <td align="right" valign="top" style="padding:3px 9px"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/invoice/default.phtml b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/invoice/default.phtml index 11df4cccb14..db254fc363a 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/invoice/default.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/invoice/default.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?> <?php $parentItem = $this->getItem() ?> <?php $items = $this->getChilds($parentItem) ?> @@ -66,80 +67,7 @@ </td> <td align="right" valign="top" style="padding:3px 9px"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/order/default.phtml b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/order/default.phtml index 0643e61ecd7..01d0eb97def 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/email/order/items/order/default.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/email/order/items/order/default.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?> <?php $_item = $this->getItem() ?> <?php $_order=$this->getOrder() ?> @@ -66,80 +67,7 @@ </td> <td align="right" valign="top" style="padding:3px 9px"> <?php if (!$_item->getParentItem()): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml index f59849e66d5..528866f9e92 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?> <?php $parentItem = $this->getItem() ?> <?php $items = $this->getChilds($parentItem) ?> @@ -59,91 +60,7 @@ <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->escapeHtml($_item->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart tax info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl + $this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml($_item); ?> <?php else: ?> <?php endif; ?> @@ -157,58 +74,7 @@ </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <?php echo $this->getOrder()->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php endif; ?> - </span> - <?php else: ?> - - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal() + $this->getItem()->getWeeeTaxAppliedRowAmount() + $this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal() + $this->getItem()->getWeeeTaxAppliedRowAmount() + $this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml($_item); ?> <?php else: ?> <?php endif; ?> @@ -222,7 +88,7 @@ </td> <td class="col rowtotal" data-th="<?php echo $this->escapeHtml(__('Row Total')); ?>"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php echo $this->getOrder()->formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> + <?php echo $this->getItemRowTotalAfterDiscountHtml($_item); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml index 20b29c9f317..8ce1ef4cb7c 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?> <?php $parentItem = $this->getItem() ?> <?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> @@ -58,92 +59,7 @@ <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->escapeHtml($_item->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml($_item); ?> <?php else: ?> <?php endif; ?> @@ -157,89 +73,7 @@ </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> <?php if ($this->canShowPriceInfo($_item)): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $tax['title']; ?>: <?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml($_item); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml index b1908e1964b..c7d8dc29e27 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml @@ -59,89 +59,7 @@ <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($_item->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> <?php if (!$_item->getParentItem()): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> <?php else: ?> <?php endif; ?> @@ -194,93 +112,7 @@ </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> <?php if (!$_item->getParentItem()): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" - id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> <?php else: ?> <?php endif; ?> diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index 53f5e302ccd..62a1c56b511 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php index 7600fbd7bda..d859d594af3 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php @@ -61,7 +61,7 @@ class Attribute extends \Magento\Backend\Block\Widget */ protected function _prepareLayout() { - $this->addChild( + $this->getToolbar()->addChild( 'back_button', 'Magento\Backend\Block\Widget\Button', array( @@ -74,7 +74,7 @@ class Attribute extends \Magento\Backend\Block\Widget ) ); - $this->addChild( + $this->getToolbar()->addChild( 'reset_button', 'Magento\Backend\Block\Widget\Button', array( @@ -84,12 +84,12 @@ class Attribute extends \Magento\Backend\Block\Widget ) ); - $this->addChild( + $this->getToolbar()->addChild( 'save_button', 'Magento\Backend\Block\Widget\Button', array( 'label' => __('Save'), - 'class' => 'save', + 'class' => 'save primary', 'data_attribute' => array( 'mage-init' => array('button' => array('event' => 'save', 'target' => '#attributes-edit-form')) ) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php index 05d7aed24b6..1ca7ec7c484 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php @@ -147,11 +147,12 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form implements $nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : ''; $elementId = $element->getId(); $dataAttribute = "data-disable='{$elementId}'"; + $dataCheckboxName = "toggle_"."{$elementId}"; $checkboxLabel = __('Change'); $html = <<<HTML <span class="attribute-change-checkbox"> - <label> - <input type="checkbox" $nameAttributeHtml onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute /> + <input type="checkbox" id="$dataCheckboxName" name="$dataCheckboxName" class="checkbox" $nameAttributeHtml onclick="toogleFieldEditMode(this, '{$elementId}')" $dataAttribute /> + <label class="label" for="$dataCheckboxName"> {$checkboxLabel} </label> </span> diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php index 982273aa7fc..75424c2e5db 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options.php @@ -179,7 +179,7 @@ class Options extends \Magento\Framework\View\Element\Template $data['oldPrice'] = $this->_coreData->currency($option->getPrice(false), false, false); $data['priceValue'] = $option->getPrice(false); $data['type'] = $option->getPriceType(); - $data['exclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price']); + $data['exclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], false); $data['inclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], true); return $data; } diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php index 2b104f58388..31badd1789b 100644 --- a/app/code/Magento/Catalog/Model/Layer.php +++ b/app/code/Magento/Catalog/Model/Layer.php @@ -173,6 +173,8 @@ class Layer extends \Magento\Framework\Object public function prepareProductCollection($collection) { $this->collectionFilter->filter($collection, $this->getCurrentCategory()); + + return $this; } /** @@ -274,14 +276,4 @@ class Layer extends \Magento\Framework\Object return $state; } - - /** - * Get attribute sets identifiers of current product set - * - * @return array - */ - protected function _getSetIds() - { - return $this->getProductCollection()->getSetIds(); - } } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php index fb04bd21c91..8765e28ce4a 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php @@ -151,7 +151,16 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ protected function _isValidCategory($category) { - return $category->getId(); + if ($category->getId()) { + while ($category->getLevel() != 0) { + if (!$category->getIsActive()) { + return false; + } + $category = $category->getParentCategory(); + } + return true; + } + return false; } /** @@ -194,13 +203,15 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter $this->getLayer()->getProductCollection()->addCountToCategories($categories); $data = array(); - foreach ($categories as $category) { - if ($category->getIsActive() && $category->getProductCount()) { - $data[] = array( - 'label' => $this->_escaper->escapeHtml($category->getName()), - 'value' => $category->getId(), - 'count' => $category->getProductCount() - ); + if ($category->getIsActive()) { + foreach ($categories as $category) { + if ($category->getIsActive() && $category->getProductCount()) { + $data[] = array( + 'label' => $this->_escaper->escapeHtml($category->getName()), + 'value' => $category->getId(), + 'count' => $category->getProductCount() + ); + } } } return $data; diff --git a/app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php index 8d9719afa16..09d0aa5e756 100644 --- a/app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php +++ b/app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php @@ -23,6 +23,8 @@ */ namespace Magento\Catalog\Model\Product\ProductList; +use Magento\Framework\Stdlib\CookieManager; + /** * Class Toolbar */ @@ -54,11 +56,11 @@ class Toolbar const LIMIT_COOKIE_NAME = 'product_list_limit'; /** - * Cookie + * Cookie manager * - * @var \Magento\Framework\Stdlib\Cookie + * @var CookieManager */ - protected $cookie; + protected $cookieManager; /** * Request @@ -68,14 +70,14 @@ class Toolbar protected $request; /** - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param CookieManager $cookieManager * @param \Magento\Framework\App\Request\Http $request */ public function __construct( - \Magento\Framework\Stdlib\Cookie $cookie, + CookieManager $cookieManager, \Magento\Framework\App\Request\Http $request ) { - $this->cookie = $cookie; + $this->cookieManager = $cookieManager; $this->request = $request; } @@ -86,7 +88,7 @@ class Toolbar */ public function getOrder() { - return $this->cookie->get(self::ORDER_COOKIE_NAME); + return $this->cookieManager->getCookie(self::ORDER_COOKIE_NAME); } /** @@ -96,7 +98,7 @@ class Toolbar */ public function getDirection() { - return $this->cookie->get(self::DIRECTION_COOKIE_NAME); + return $this->cookieManager->getCookie(self::DIRECTION_COOKIE_NAME); } /** @@ -106,7 +108,7 @@ class Toolbar */ public function getMode() { - return $this->cookie->get(self::MODE_COOKIE_NAME); + return $this->cookieManager->getCookie(self::MODE_COOKIE_NAME); } /** @@ -116,7 +118,7 @@ class Toolbar */ public function getLimit() { - return $this->cookie->get(self::LIMIT_COOKIE_NAME); + return $this->cookieManager->getCookie(self::LIMIT_COOKIE_NAME); } /** * Return current page from request diff --git a/app/code/Magento/Catalog/Service/V1/Category/Attribute/ReadService.php b/app/code/Magento/Catalog/Service/V1/Category/Attribute/ReadService.php index 203b0929fa7..d87dd83d78b 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/Attribute/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/Attribute/ReadService.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Category\Attribute; use Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory; -use Magento\Catalog\Service\V1\Product\MetadataServiceInterface; +use Magento\Catalog\Service\V1\Category\MetadataServiceInterface; /** * Class ReadService diff --git a/app/code/Magento/Catalog/Service/V1/Data/Category.php b/app/code/Magento/Catalog/Service/V1/Data/Category.php index ffc879eb60b..23bfb991365 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Category.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category.php @@ -25,6 +25,9 @@ namespace Magento\Catalog\Service\V1\Data; use \Magento\Framework\Service\Data\Eav\AbstractObject; +/** + * @codeCoverageIgnore + */ class Category extends AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php index 392999218e1..0837be16b1d 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data; use Magento\Framework\Service\Data\Eav\AbstractObjectBuilder; use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; +/** + * @codeCoverageIgnore + */ class CategoryBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Attribute.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Attribute.php index 924bd369d2a..c2c85ecde79 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Attribute.php @@ -25,6 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav; use Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class Attribute extends AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeBuilder.php index 9729c8b1464..035195e6705 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeBuilder.php @@ -25,6 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class AttributeBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroup.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroup.php index 6c171121b09..9b53a749fef 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroup.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroup.php @@ -25,7 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav; - +/** + * @codeCoverageIgnore + */ class AttributeGroup extends \Magento\Framework\Service\Data\AbstractObject { /**#@+ diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroupBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroupBuilder.php index 84b2a10e703..956d1e147f7 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroupBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeGroupBuilder.php @@ -24,6 +24,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav; +/** + * @codeCoverageIgnore + */ class AttributeGroupBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadata.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadata.php index b9767902868..1c68f0ce64c 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadata.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadata.php @@ -28,6 +28,8 @@ use Magento\Framework\Service\Data\Eav\MetadataObjectInterface; /** * Class AttributeMetadata + * + * @codeCoverageIgnore */ class AttributeMetadata extends AbstractObject implements MetadataObjectInterface { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php index c369b3b9fca..ee31ce5d88a 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php @@ -78,6 +78,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param int $attributeId * @return $this + * @codeCoverageIgnore */ public function setAttributeId($attributeId) { @@ -89,6 +90,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $attributeCode * @return $this + * @codeCoverageIgnore */ public function setAttributeCode($attributeCode) { @@ -100,6 +102,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isSystem * @return $this + * @codeCoverageIgnore */ public function setSystem($isSystem) { @@ -111,6 +114,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $frontendInput * @return $this + * @codeCoverageIgnore */ public function setFrontendInput($frontendInput) { @@ -122,6 +126,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param \Magento\Catalog\Service\V1\Data\Eav\ValidationRule[] $validationRules * @return $this + * @codeCoverageIgnore */ public function setValidationRules($validationRules) { @@ -133,6 +138,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param \Magento\Catalog\Service\V1\Data\Eav\Option[] $options * @return $this + * @codeCoverageIgnore */ public function setOptions($options) { @@ -144,6 +150,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $visible * @return $this + * @codeCoverageIgnore */ public function setVisible($visible) { @@ -155,6 +162,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $required * @return $this + * @codeCoverageIgnore */ public function setRequired($required) { @@ -166,6 +174,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isUserDefined * @return $this + * @codeCoverageIgnore */ public function setUserDefined($isUserDefined) { @@ -177,6 +186,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param \Magento\Catalog\Service\V1\Data\Eav\Product\Attribute\FrontendLabel[] $frontendLabel * @return $this + * @codeCoverageIgnore */ public function setFrontendLabel($frontendLabel) { @@ -188,6 +198,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $note * @return $this + * @codeCoverageIgnore */ public function setNote($note) { @@ -197,6 +208,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut /** * @param string $backendType * @return AttributeMetadataBuilder + * @codeCoverageIgnore */ public function setBackendType($backendType) { @@ -208,6 +220,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $value * @return $this + * @codeCoverageIgnore */ public function setBackendModel($value) { @@ -219,6 +232,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $value * @return $this + * @codeCoverageIgnore */ public function setSourceModel($value) { @@ -230,6 +244,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $value * @return $this + * @codeCoverageIgnore */ public function setDefaultValue($value) { @@ -241,6 +256,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isUnique * @return $this + * @codeCoverageIgnore */ public function setUnique($isUnique) { @@ -291,6 +307,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isConfigurable * @return $this + * @codeCoverageIgnore */ public function setConfigurable($isConfigurable) { @@ -302,6 +319,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isSearchable * @return $this + * @codeCoverageIgnore */ public function setSearchable($isSearchable) { @@ -313,6 +331,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isVisibleInAdvancedSearch * @return $this + * @codeCoverageIgnore */ public function setVisibleInAdvancedSearch($isVisibleInAdvancedSearch) { @@ -324,6 +343,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isComparable * @return $this + * @codeCoverageIgnore */ public function setComparable($isComparable) { @@ -335,6 +355,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isUsedForPromoRules * @return $this + * @codeCoverageIgnore */ public function setUsedForPromoRules($isUsedForPromoRules) { @@ -346,6 +367,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isVisibleOnFront * @return $this + * @codeCoverageIgnore */ public function setVisibleOnFront($isVisibleOnFront) { @@ -357,6 +379,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $usedInProductListing * @return $this + * @codeCoverageIgnore */ public function setUsedInProductListing($usedInProductListing) { @@ -368,6 +391,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $scope * @return $this + * @codeCoverageIgnore */ public function setScope($scope) { @@ -379,6 +403,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $usedForSortBy * @return $this + * @codeCoverageIgnore */ public function setUsedForSortBy($usedForSortBy) { @@ -390,6 +415,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isFilterable * @return $this + * @codeCoverageIgnore */ public function setFilterable($isFilterable) { @@ -401,6 +427,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isFilterableInSearch * @return $this + * @codeCoverageIgnore */ public function setFilterableInSearch($isFilterableInSearch) { @@ -412,6 +439,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param int $position * @return $this + * @codeCoverageIgnore */ public function setPosition($position) { @@ -423,6 +451,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isWysiwygEnabled * @return $this + * @codeCoverageIgnore */ public function setWysiwygEnabled($isWysiwygEnabled) { @@ -434,6 +463,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param bool $isHtmlAllowedOnFront * @return $this + * @codeCoverageIgnore */ public function setHtmlAllowedOnFront($isHtmlAllowedOnFront) { @@ -445,6 +475,7 @@ class AttributeMetadataBuilder extends AbstractObjectBuilder implements Attribut * * @param string $frontendClass * @return $this + * @codeCoverageIgnore */ public function setFrontendClass($frontendClass) { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet.php index 5252a88c30c..0f44e145698 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav; /** * Contains basic attribute set data + * + * @codeCoverageIgnore */ class AttributeSet extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/Attribute.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/Attribute.php index 09162ff9969..ca5f0d4bb45 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/Attribute.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/Attribute.php @@ -23,6 +23,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav\AttributeSet; +/** + * @codeCoverageIgnore + */ class Attribute extends \Magento\Framework\Service\Data\AbstractObject { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/AttributeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/AttributeBuilder.php index e7d5faf8f02..1c6ed7765e0 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/AttributeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSet/AttributeBuilder.php @@ -23,6 +23,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav\AttributeSet; +/** + * @codeCoverageIgnore + */ class AttributeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSetBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSetBuilder.php index cf90d2ce147..a0bbf1041c2 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSetBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeSetBuilder.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav; /** * Builder for AttributeSet + * + * @codeCoverageIgnore */ class AttributeSetBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadata.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadata.php index 055c6efc5a9..e5f30774eea 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadata.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadata.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Category; use \Magento\Framework\Service\Data\Eav\AbstractObject; use Magento\Framework\Service\Data\Eav\MetadataObjectInterface; +/** + * @codeCoverageIgnore + */ class AttributeMetadata extends AbstractObject implements MetadataObjectInterface { const ATTRIBUTE_ID = 'attribute_id'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadataBuilder.php index d6824b2cdb2..25d3aecb6f7 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/AttributeMetadataBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Category; use Magento\Framework\Service\Data\AbstractObjectBuilder; use Magento\Framework\Service\Data\AttributeMetadataBuilderInterface; +/** + * @codeCoverageIgnore + */ class AttributeMetadataBuilder extends AbstractObjectBuilder implements AttributeMetadataBuilderInterface { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php index 087b9798c7f..e7b565601f2 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php @@ -23,6 +23,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav\Category; +/** + * @codeCoverageIgnore + */ class Tree extends \Magento\Framework\Service\Data\AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php index f46ca55aadd..7df8edcb3aa 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php @@ -25,6 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Category; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class TreeBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option.php index 19cbe278dcd..ecaee1ffe46 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option.php @@ -27,6 +27,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav; /** * Class Option + * + * @codeCoverageIgnore */ class Option extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/Label.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/Label.php index 44b449ff673..7243e8ff445 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/Label.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/Label.php @@ -27,6 +27,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Option; /** * Class Store Scope Label + * + * @codeCoverageIgnore */ class Label extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/LabelBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/LabelBuilder.php index 67b10003e1c..d4a738f43f8 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/LabelBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Option/LabelBuilder.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Option; /** * Class LabelBuilder + * + * @codeCoverageIgnore */ class LabelBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/OptionBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/OptionBuilder.php index cd7d935cf10..ebfdb17e5ed 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/OptionBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/OptionBuilder.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Data\Eav; /** * Class OptionBuilder + * + * @codeCoverageIgnore */ class OptionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabel.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabel.php index 35fe1447671..800c49c322d 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabel.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabel.php @@ -25,7 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Product\Attribute; /** * Class FrontendLabel + * * @package Magento\Catalog\Service\V1\Data\Eav\Product\Attribute + * @codeCoverageIgnore */ class FrontendLabel extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabelBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabelBuilder.php index d5760cdc196..4ab427b19ae 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabelBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/FrontendLabelBuilder.php @@ -25,7 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Product\Attribute; /** * Class FrontendLabelBuilder + * * @package Magento\Catalog\Service\V1\Data\Eav\Product\Attribute + * @codeCoverageIgnore */ class FrontendLabelBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/Type.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/Type.php index dbc20c98100..56ee3e0a772 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/Type.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/Type.php @@ -25,7 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Product\Attribute; /** * Class Type + * * @package Magento\Catalog\Service\V1\Data\Eav\Product\Attribute + * @codeCoverageIgnore */ class Type extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/TypeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/TypeBuilder.php index b10dbb881c6..ac73f8b2bdc 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/TypeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Product/Attribute/TypeBuilder.php @@ -25,7 +25,9 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Product\Attribute; /** * Class TypeBuilder + * * @package Magento\Catalog\Service\V1\Data\Eav\Product\Attribute + * @codeCoverageIgnore */ class TypeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRule.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRule.php index 58d5c41db20..b8bffbe65aa 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRule.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRule.php @@ -23,6 +23,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav; +/** + * @codeCoverageIgnore + */ class ValidationRule extends \Magento\Framework\Service\Data\AbstractObject { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRuleBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRuleBuilder.php index b4b92a48073..3e8e2e8bbbf 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRuleBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/ValidationRuleBuilder.php @@ -23,6 +23,9 @@ */ namespace Magento\Catalog\Service\V1\Data\Eav; +/** + * @codeCoverageIgnore + */ class ValidationRuleBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product.php b/app/code/Magento/Catalog/Service/V1/Data/Product.php index a7787e91123..a145c34a19a 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product.php @@ -24,8 +24,7 @@ namespace Magento\Catalog\Service\V1\Data; /** - * Class Product - * @package Magento\Catalog\Service\V1\Data + * @codeCoverageIgnore */ class Product extends \Magento\Framework\Service\Data\Eav\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResults.php b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResults.php index 79f94909345..bf20f550096 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResults.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResults.php @@ -26,6 +26,8 @@ namespace Magento\Catalog\Service\V1\Data\Product\Attribute; /** * SearchResults Service Data Object used for the search service requests + * + * @codeCoverageIgnore */ class SearchResults extends \Magento\Framework\Service\V1\Data\SearchResults { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php index bca9e55cac6..2b415cd9fc7 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php @@ -33,6 +33,7 @@ use Magento\Catalog\Service\V1\Data\Eav\AttributeBuilder; * Builder for the SearchResults Service Data Object * * @method \Magento\Catalog\Service\V1\Data\Product\Attribute\SearchResults create() + * @codeCoverageIgnore */ class SearchResultsBuilder extends \Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPrice.php b/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPrice.php index 83e8212c9e9..688280cc154 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPrice.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPrice.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class GroupPrice extends AbstractObject { const CUSTOMER_GROUP_ID = 'customer_group_id'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPriceBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPriceBuilder.php index 3210e1dc84f..f67be6d393a 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPriceBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/GroupPriceBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class GroupPriceBuilder extends AbstractObjectBuilder { /** @@ -36,8 +39,7 @@ class GroupPriceBuilder extends AbstractObjectBuilder */ public function setCustomerGroupId($customerGroupId) { - $this->_set(GroupPrice::CUSTOMER_GROUP_ID, $customerGroupId); - return $this; + return $this->_set(GroupPrice::CUSTOMER_GROUP_ID, $customerGroupId); } /** @@ -48,7 +50,6 @@ class GroupPriceBuilder extends AbstractObjectBuilder */ public function setValue($value) { - $this->_set(GroupPrice::VALUE, $value); - return $this; + return $this->_set(GroupPrice::VALUE, $value); } } diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResults.php b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResults.php index 6061fbe257b..82d953376fa 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResults.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResults.php @@ -26,6 +26,8 @@ namespace Magento\Catalog\Service\V1\Data\Product; /** * SearchResults Service Data Object used for the search service requests + * + * @codeCoverageIgnore */ class SearchResults extends \Magento\Framework\Service\V1\Data\SearchResults { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php index 0e6fff2558a..ff3d295ff11 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php @@ -33,6 +33,7 @@ use Magento\Catalog\Service\V1\Data\ProductBuilder; * Builder for the SearchResults Service Data Object * * @method \Magento\Catalog\Service\V1\Data\Product\SearchResults create() + * @codeCoverageIgnore */ class SearchResultsBuilder extends AbstractSearchResultsBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/TierPrice.php b/app/code/Magento/Catalog/Service/V1/Data/Product/TierPrice.php index 75e554ed306..ec368ff4fc4 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/TierPrice.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/TierPrice.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class TierPrice extends AbstractObject { const QTY = 'qty'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/TierPriceBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/TierPriceBuilder.php index 4903056618b..2f30002783f 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/TierPriceBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/TierPriceBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class TierPriceBuilder extends AbstractObjectBuilder { /** @@ -36,8 +39,7 @@ class TierPriceBuilder extends AbstractObjectBuilder */ public function setQty($qty) { - $this->_set(TierPrice::QTY, $qty); - return $this; + return $this->_set(TierPrice::QTY, $qty); } /** @@ -48,7 +50,6 @@ class TierPriceBuilder extends AbstractObjectBuilder */ public function setValue($value) { - $this->_set(TierPrice::VALUE, $value); - return $this; + return $this->_set(TierPrice::VALUE, $value); } } diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php index a4a024726d0..29a1dab4cff 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Data; use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; +/** + * @codeCoverageIgnore + */ class ProductBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectBuilder { /** @@ -109,7 +112,6 @@ class ProductBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectB /** * Set created time - * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * @param string|null $value @@ -125,7 +127,6 @@ class ProductBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectB /** * Set updated time - * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * @param string|null $value diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php index c3f71253c3c..a9839d8a83c 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php @@ -23,7 +23,7 @@ */ namespace Magento\Catalog\Service\V1\Data; -use \Magento\Framework\Service\EavDataObjectConverter; +use Magento\Framework\Service\EavDataObjectConverter; class ProductMapper { @@ -56,14 +56,14 @@ class ProductMapper \Magento\Catalog\Model\Product $productModel = null ) { /** @var \Magento\Catalog\Model\Product $productModel */ - $productModel = $productModel ?: $this->productFactory->create(); + $productModel = $productModel ? : $this->productFactory->create(); $productModel->addData(EavDataObjectConverter::toFlatArray($product)); if (!is_numeric($productModel->getAttributeSetId())) { $productModel->setAttributeSetId($productModel->getDefaultAttributeSetId()); } if (!$productModel->hasTypeId()) { $productModel->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); - } else if (!isset($this->productTypes->getTypes()[$productModel->getTypeId()])) { + } elseif (!isset($this->productTypes->getTypes()[$productModel->getTypeId()])) { throw new \RuntimeException('Illegal product type'); } return $productModel; diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductType.php b/app/code/Magento/Catalog/Service/V1/Data/ProductType.php index b7a4a49e5ec..3e4db01284a 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductType.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductType.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class ProductType extends AbstractObject { const NAME = 'name'; diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductTypeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/ProductTypeBuilder.php index df36d34454c..f55af769962 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductTypeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductTypeBuilder.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Data; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class ProductTypeBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/MetadataService.php b/app/code/Magento/Catalog/Service/V1/MetadataService.php index e98cace4823..6e0429f3ea6 100644 --- a/app/code/Magento/Catalog/Service/V1/MetadataService.php +++ b/app/code/Magento/Catalog/Service/V1/MetadataService.php @@ -118,7 +118,7 @@ class MetadataService implements MetadataServiceInterface { /** @var AbstractAttribute $attribute */ $attribute = $this->eavConfig->getAttribute($entityType, $attributeCode); - if ($attribute) { + if ($attribute->getId()) { $attributeMetadata = $this->createMetadataAttribute($attribute); return $attributeMetadata; } else { @@ -146,7 +146,7 @@ class MetadataService implements MetadataServiceInterface $attributeCollection->join( ['eav_entity_attribute' => $attributeCollection->getTable('eav_entity_attribute')], 'main_table.attribute_id = eav_entity_attribute.attribute_id', - ['attribute_set_id'] + [] ); $attributeCollection->join( array('additional_table' => $attributeCollection->getTable('catalog_eav_attribute')), @@ -164,8 +164,12 @@ class MetadataService implements MetadataServiceInterface ($sortOrder->getDirection() == SearchCriteria::SORT_ASC) ? 'ASC' : 'DESC' ); } + $totalCount = $attributeCollection->getSize(); + // Group attributes by id to prevent duplicates with different attribute sets + $attributeCollection->addAttributeGrouping(); + $attributeCollection->setCurPage($searchCriteria->getCurrentPage()); $attributeCollection->setPageSize($searchCriteria->getPageSize()); diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntry.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntry.php index 489990c5926..c64c07cfb2b 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntry.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntry.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class GalleryEntry extends AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryBuilder.php index b613592fe07..cc8a291c378 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryBuilder.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class GalleryEntryBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContent.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContent.php index 87777694aa1..06f27e701a3 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContent.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContent.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class GalleryEntryContent extends AbstractObject { const DATA = 'data'; diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContentBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContentBuilder.php index 16ee223a7ac..d27987f242c 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContentBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/GalleryEntryContentBuilder.php @@ -27,6 +27,9 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class GalleryEntryContentBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImage.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImage.php index 6b4769a693e..518344871cd 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImage.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImage.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; /** * Contains media_image attribute info + * + * @codeCoverageIgnore */ class MediaImage extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImageBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImageBuilder.php index 3689228c473..a259169ac6a 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImageBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/Data/MediaImageBuilder.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Service\V1\Product\Attribute\Media\Data; /** * Builder for media_image + * + * @codeCoverageIgnore */ class MediaImageBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option.php index bac5ba32df2..7824a5f6c16 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data; +/** + * @codeCoverageIgnore + */ class Option extends \Magento\Framework\Service\Data\AbstractObject { const OPTION_ID = 'option_id'; diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata.php index 9c9a653ea78..d14864dd2a6 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option; +/** + * @codeCoverageIgnore + */ class Metadata extends \Magento\Framework\Service\Data\Eav\AbstractObject { const PRICE = 'price'; diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/File.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/File.php index e7f36b3b92f..c22eccce678 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/File.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/File.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ use \Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata; +/** + * @codeCoverageIgnore + */ class File extends DefaultReader { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/Text.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/Text.php index 00264921875..515abff9bb6 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/Text.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/Metadata/Reader/Text.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ use \Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata; +/** + * @codeCoverageIgnore + */ class Text extends DefaultReader { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php index c696ab11613..0099bd21055 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php @@ -26,6 +26,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option; use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; +/** + * @codeCoverageIgnore + */ class MetadataBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionBuilder.php index c56dddae572..917c0e9c47a 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionBuilder.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data; +/** + * @codeCoverageIgnore + */ class OptionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionType.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionType.php index e55da5970ac..52120dd9723 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionType.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionType.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data; +/** + * @codeCoverageIgnore + */ class OptionType extends \Magento\Framework\Service\Data\AbstractObject { const LABEL = 'label'; diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionTypeBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionTypeBuilder.php index ea08d6857c9..f8929bbcb8a 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionTypeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/OptionTypeBuilder.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data; +/** + * @codeCoverageIgnore + */ class OptionTypeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttribute.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttribute.php index 3531cbdadfb..d27e016a477 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttribute.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttribute.php @@ -26,6 +26,8 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; /** * LinkAttribute Service Data Object + * + * @codeCoverageIgnore */ class LinkAttribute extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttributeBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttributeBuilder.php index 24da159e9b5..e4c1ef236e9 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttributeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkAttributeBuilder.php @@ -28,6 +28,7 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; * Builder for the LinkAttribute Service Data Object * * @method LinkAttribute create() + * @codeCoverageIgnore */ class LinkAttributeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkType.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkType.php index 94269b81014..ead7b37d939 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkType.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkType.php @@ -26,6 +26,8 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; /** * LinkType Service Data Object + * + * @codeCoverageIgnore */ class LinkType extends \Magento\Framework\Service\Data\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkTypeBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkTypeBuilder.php index 3abf3bfb8d2..efabf545772 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkTypeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/LinkTypeBuilder.php @@ -28,6 +28,7 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; * Builder for the LinkType Service Data Object * * @method LinkType create() + * @codeCoverageIgnore */ class LinkTypeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink.php index f809e6c5e1a..210589037ce 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink.php @@ -26,6 +26,8 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; /** * ProductLink Service Data Object + * + * @codeCoverageIgnore */ class ProductLink extends \Magento\Framework\Service\Data\Eav\AbstractObject { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink/ProductEntity/ConverterPool.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink/ProductEntity/ConverterPool.php index d464e11d103..cfd9e9d166b 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink/ProductEntity/ConverterPool.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLink/ProductEntity/ConverterPool.php @@ -24,6 +24,9 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data\ProductLink\ProductEntity; +/** + * @codeCoverageIgnore + */ class ConverterPool { /** diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php index 0e6fb868f39..237f37a68d5 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php @@ -30,6 +30,7 @@ use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; * Builder for the ProductLink Service Data Object * * @method ProductLink create() + * @codeCoverageIgnore */ class ProductLinkBuilder extends \Magento\Framework\Service\Data\Eav\AbstractObjectBuilder { diff --git a/app/code/Magento/Catalog/Service/V1/Product/MetadataService.php b/app/code/Magento/Catalog/Service/V1/Product/MetadataService.php index 9df4a08a1b0..4f6760add2e 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/MetadataService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/MetadataService.php @@ -90,12 +90,14 @@ class MetadataService implements MetadataServiceInterface public function getProductAttributesMetadata($attributeSetId = self::DEFAULT_ATTRIBUTE_SET_ID) { /** @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $searchCriteria */ - $this->searchCriteriaBuilder->addFilter([ - $this->filterBuilder - ->setField('attribute_set_id') - ->setValue($attributeSetId) - ->create() - ]); + $this->searchCriteriaBuilder->addFilter( + [ + $this->filterBuilder + ->setField('attribute_set_id') + ->setValue($attributeSetId) + ->create() + ] + ); return $this->metadataService->getAllAttributeMetadata( MetadataServiceInterface::ENTITY_TYPE, diff --git a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php index c45a24f22a6..e50690efc28 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -26,9 +25,9 @@ namespace Magento\Catalog\Service\V1\Product; use Magento\Catalog\Model\ProductFactory; use Magento\Catalog\Model\ProductRepository; -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\CouldNotSaveException; use Magento\Catalog\Service\V1\Data\Product; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; class TierPriceService implements TierPriceServiceInterface { @@ -88,7 +87,6 @@ class TierPriceService implements TierPriceServiceInterface /** * {@inheritdoc} - * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -180,10 +178,12 @@ class TierPriceService implements TierPriceServiceInterface if ((is_numeric($customerGroupId) && intval($price['cust_group']) === intval($customerGroupId)) || ($customerGroupId === 'all' && $price['all_groups']) ) { - $this->priceBuilder->populateWithArray(array( - Product\TierPrice::VALUE => $price[$priceKey], - Product\TierPrice::QTY => $price['price_qty'] - )); + $this->priceBuilder->populateWithArray( + array( + Product\TierPrice::VALUE => $price[$priceKey], + Product\TierPrice::QTY => $price['price_qty'] + ) + ); $prices[] = $this->priceBuilder->create(); } } diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index c07830f16b7..1a172db36af 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-index": "0.1.0-alpha92", - "magento/module-indexer": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-log": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-bundle": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-catalog-rule": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-catalog-search": "0.1.0-alpha92", - "magento/module-product-alert": "0.1.0-alpha92", - "magento/module-url-rewrite": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-index": "0.1.0-alpha93", + "magento/module-indexer": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-log": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-bundle": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-catalog-rule": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-catalog-search": "0.1.0-alpha93", + "magento/module-product-alert": "0.1.0-alpha93", + "magento/module-url-rewrite": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml index a5384dcb686..308ca624099 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/form.phtml @@ -29,7 +29,7 @@ ?> <?php echo $this->getFormInitScripts() ?> <form id="edit_form" action="<?php echo $this->escapeHtml($this->getSaveUrl()) ?>" method="post"> - <input name="form_key" type="hidden" value="<?php echo $this->escapeHtml($this->getFormKey()) ?>" /> + <input name="form_key" type="hidden" value="<?php echo $this->escapeHtml($this->getFormKey()) ?>" /> <?php echo $this->getChildHtml('form') ?> </form> <div class="page-actions" <?php echo $this->getUiId('content-header') ?>> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/attribute.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/attribute.phtml index 613071e6244..f2a35f1688f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/attribute.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/attribute.phtml @@ -22,11 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> -<div class="page-actions"> - <?php echo $this->getBackButtonHtml() ?> - <?php echo $this->getCancelButtonHtml() ?> - <?php echo $this->getSaveButtonHtml() ?> -</div> + <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="attributes-edit-form" class="attributes-edit-form" enctype="multipart/form-data"> <?php echo $this->getBlockHtml('formkey')?> </form> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml index 4a9d9e33cdc..a771fe1d058 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml @@ -23,24 +23,29 @@ */ ?> <script type="text/javascript"> - function toggleValueElementsWithCheckbox(checkbox) { - var td = $(checkbox).up('.field'); - var checkboxes = td.getElementsBySelector('input[type="checkbox"]'); - var inputs = td.getElementsBySelector('input[type!="checkbox"]', 'select', 'textarea'); - if (checkboxes.size()>1) { - inputs.each(function(input){ - input.disabled = (!checkbox.checked || checkboxes[0].checked); - checkboxes[0].disabled = !checkbox.checked; - }); - } else { - inputs.each(function(input){ - input.disabled = !checkbox.checked; - }); - } - } + require(['jquery'], function($){ + $('[data-role=toggle-editability-all]').change(function(e) { + var toggler = $(this); + var field = toggler.parents('.field'); + var someEditable = $('input[type!="checkbox"], select, textarea', field); + var someEditableCheckboxes = $('input[type="checkbox"]', field).not(toggler); + if(someEditableCheckboxes.length){ + someEditable.prop('disabled', !toggler.prop('checked') || someEditableCheckboxes.prop('checked')); + someEditableCheckboxes.prop('disabled', !toggler.prop('checked')); + } else { + someEditable.prop('disabled', !toggler.prop('checked')); + } + }); + $('[data-role=toggle-editability]').change(function(e) { + var useConfigSettings = $(this); + var field = useConfigSettings.parents('.field'); + var someEditable = $('input[type!="checkbox"], select, textarea', field); + someEditable.prop('disabled', useConfigSettings.prop('checked')); + }); + }); </script> -<div class="fieldset-wrapper form-inline"> +<div class="fieldset-wrapper form-inline advanced-inventory-edit"> <div class="fieldset-wrapper-title"> <strong class="title"> <span><?php echo __('Advanced Inventory') ?></span> @@ -48,203 +53,322 @@ </div> <div class="fieldset-wrapper-content"> <fieldset class="fieldset" id="table_cataloginventory"> - <div class="field"> - <label class="label" for="inventory_manage_stock"> - <span><?php echo __('Manage Stock') ?></span> - </label> - <div class="control"> - <select id="inventory_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[manage_stock]" class="select" disabled="disabled"> - <option value="1"><?php echo __('Yes') ?></option> - <option value="0"<?php if ($this->getConfigFieldValue('manage_stock') == 0): ?> selected="selected"<?php endif; ?>><?php echo __('No') ?></option> - </select> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input name="<?php echo $this->getFieldSuffix() ?>[use_config_manage_stock]" type="checkbox" id="inventory_use_config_manage_stock" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_manage_stock_checkbox'));" value="1" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_manage_stock" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_manage_stock_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_manage_stock_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_manage_stock"> + <span><?php echo __('Manage Stock') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <select id="inventory_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[manage_stock]" + class="select" disabled="disabled"> + <option value="1"><?php echo __('Yes') ?></option> + <option + value="0"<?php if ($this->getConfigFieldValue('manage_stock') == 0): ?> selected="selected"<?php endif; ?>><?php echo __('No') ?></option> + </select> + </div> + <div class="field choice"> + <input name="<?php echo $this->getFieldSuffix() ?>[use_config_manage_stock]" type="checkbox" + id="inventory_use_config_manage_stock" data-role="toggle-editability" value="1" + checked="checked" disabled="disabled"/> + <label for="inventory_use_config_manage_stock" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_manage_stock_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_manage_stock_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field required"> - <label class="label" for="inventory_qty"> - <span><?php echo __('Qty') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text required-entry validate-number" id="inventory_qty" name="<?php echo $this->getFieldSuffix() ?>[qty]" value="<?php echo $this->getDefaultConfigValue('qty')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_qty_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_qty_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field required"> + <label class="label" for="inventory_qty"> + <span><?php echo __('Qty') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text required-entry validate-number" id="inventory_qty" + name="<?php echo $this->getFieldSuffix() ?>[qty]" + value="<?php echo $this->getDefaultConfigValue('qty') * 1 ?>" disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_qty_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_qty_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_min_qty"> - <span><?php echo __('Minimum Qty for Item\'s Status to be Out of Stock') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text validate-number" id="inventory_min_qty" name="<?php echo $this->getFieldSuffix() ?>[min_qty]" value="<?php echo $this->getDefaultConfigValue('min_qty')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_min_qty" name="<?php echo $this->getFieldSuffix() ?>[use_config_min_qty]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_min_qty_checkbox'));" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_min_qty" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_min_qty_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_min_qty_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field with-addon"> + <label class="label" for="inventory_min_qty"> + <span><?php echo __('Minimum Qty for Item\'s Status to be Out of Stock') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text validate-number" id="inventory_min_qty" + name="<?php echo $this->getFieldSuffix() ?>[min_qty]" + value="<?php echo $this->getDefaultConfigValue('min_qty') * 1 ?>" disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_min_qty" + name="<?php echo $this->getFieldSuffix() ?>[use_config_min_qty]" value="1" + data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_min_qty" class="label"> + <span><?php echo __('Use Config Settings') ?></span> + </label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_min_qty_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_min_qty_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_min_sale_qty"> - <span><?php echo __('Minimum Qty Allowed in Shopping Cart') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text validate-number" id="inventory_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[min_sale_qty]" value="<?php echo $this->getDefaultConfigValue('min_sale_qty')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[use_config_min_sale_qty]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_min_sale_qty_checkbox'));" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_min_sale_qty" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_min_sale_qty_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_min_sale_qty_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_min_sale_qty"> + <span><?php echo __('Minimum Qty Allowed in Shopping Cart') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text validate-number" id="inventory_min_sale_qty" + name="<?php echo $this->getFieldSuffix() ?>[min_sale_qty]" + value="<?php echo $this->getDefaultConfigValue('min_sale_qty') * 1 ?>" + disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_min_sale_qty" + name="<?php echo $this->getFieldSuffix() ?>[use_config_min_sale_qty]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_min_sale_qty" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_min_sale_qty_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_min_sale_qty_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_max_sale_qty"> - <span><?php echo __('Maximum Qty Allowed in Shopping Cart') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text validate-number" id="inventory_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[max_sale_qty]" value="<?php echo $this->getDefaultConfigValue('max_sale_qty')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[use_config_max_sale_qty]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_max_sale_checkbox'));" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_max_sale_qty" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_max_sale_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_max_sale_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_max_sale_qty"> + <span><?php echo __('Maximum Qty Allowed in Shopping Cart') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text validate-number" id="inventory_max_sale_qty" + name="<?php echo $this->getFieldSuffix() ?>[max_sale_qty]" + value="<?php echo $this->getDefaultConfigValue('max_sale_qty') * 1 ?>" + disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_max_sale_qty" + name="<?php echo $this->getFieldSuffix() ?>[use_config_max_sale_qty]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_max_sale_qty" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_max_sale_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_max_sale_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_is_qty_decimal"> - <span><?php echo __('Qty Uses Decimals') ?></span> - </label> - <div class="control"> - <select id="inventory_is_qty_decimal" name="<?php echo $this->getFieldSuffix() ?>[is_qty_decimal]" class="select" disabled="disabled"> - <option value="0"><?php echo __('No') ?></option> - <option value="1"<?php if ($this->getDefaultConfigValue('is_qty_decimal')==1): ?> selected="selected"<?php endif; ?>><?php echo __('Yes') ?></option> - </select> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_is_qty_decimal_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_is_qty_decimal_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_is_qty_decimal"> + <span><?php echo __('Qty Uses Decimals') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <select id="inventory_is_qty_decimal" + name="<?php echo $this->getFieldSuffix() ?>[is_qty_decimal]" class="select" + disabled="disabled"> + <option value="0"><?php echo __('No') ?></option> + <option + value="1"<?php if ($this->getDefaultConfigValue('is_qty_decimal') == 1): ?> selected="selected"<?php endif; ?>><?php echo __('Yes') ?></option> + </select> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_is_qty_decimal_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_is_qty_decimal_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_backorders"> - <span><?php echo __('Backorders') ?></span> - </label> - <div class="control"> - <select id="inventory_backorders" name="<?php echo $this->getFieldSuffix() ?>[backorders]" class="select" disabled="disabled"> - <?php foreach ($this->getBackordersOption() as $option): ?> - <?php $_selected = ($option['value'] == $this->getDefaultConfigValue('backorders')) ? ' selected="selected"' : '' ?> - <option value="<?php echo $option['value'] ?>"<?php echo $_selected ?>><?php echo $option['label'] ?></option> - <?php endforeach; ?> - </select> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_backorders" name="<?php echo $this->getFieldSuffix() ?>[use_config_backorders]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_backorders_checkbox'));" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_backorders" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_backorders_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_backorders_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_backorders"> + <span><?php echo __('Backorders') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <select id="inventory_backorders" name="<?php echo $this->getFieldSuffix() ?>[backorders]" + class="select" disabled="disabled"> + <?php foreach ($this->getBackordersOption() as $option): ?> + <?php $_selected = ($option['value'] == $this->getDefaultConfigValue('backorders')) ? ' selected="selected"' : '' ?> + <option + value="<?php echo $option['value'] ?>"<?php echo $_selected ?>><?php echo $option['label'] ?></option> + <?php endforeach; ?> + </select> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_backorders" + name="<?php echo $this->getFieldSuffix() ?>[use_config_backorders]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_backorders" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_backorders_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_backorders_checkbox" class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> + </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_notify_stock_qty"> - <span><?php echo __('Notify for Quantity Below') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text validate-number" id="inventory_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[notify_stock_qty]" value="<?php echo $this->getDefaultConfigValue('notify_stock_qty')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[use_config_notify_stock_qty]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, $('inventory_notify_stock_qty_checkbox'));" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_notify_stock_qty" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_notify_stock_qty_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_notify_stock_qty_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_notify_stock_qty"> + <span><?php echo __('Notify for Quantity Below') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text validate-number" id="inventory_notify_stock_qty" + name="<?php echo $this->getFieldSuffix() ?>[notify_stock_qty]" + value="<?php echo $this->getDefaultConfigValue('notify_stock_qty') * 1 ?>" + disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_notify_stock_qty" + name="<?php echo $this->getFieldSuffix() ?>[use_config_notify_stock_qty]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_notify_stock_qty" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_notify_stock_qty_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_notify_stock_qty_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_enable_qty_increments"> - <span><?php echo __('Enable Qty Increments') ?></span> - </label> - <div class="control"> - <select id="inventory_enable_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[enable_qty_increments]" class="select" disabled="disabled"> - <option value="1"><?php echo __('Yes') ?></option> - <option value="0"<?php if ($this->getDefaultConfigValue('enable_qty_increments') == 0): ?> selected="selected"<?php endif; ?>><?php echo __('No') ?></option> - </select> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_enable_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[use_config_enable_qty_increments]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, [$('inventory_enable_qty_increments_checkbox')]);" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_enable_qty_increments" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_enable_qty_increments_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_enable_qty_increments_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_enable_qty_increments"> + <span><?php echo __('Enable Qty Increments') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <select id="inventory_enable_qty_increments" + name="<?php echo $this->getFieldSuffix() ?>[enable_qty_increments]" class="select" + disabled="disabled"> + <option value="1"><?php echo __('Yes') ?></option> + <option + value="0"<?php if ($this->getDefaultConfigValue('enable_qty_increments') == 0): ?> selected="selected"<?php endif; ?>><?php echo __('No') ?></option> + </select> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_enable_qty_increments" + name="<?php echo $this->getFieldSuffix() ?>[use_config_enable_qty_increments]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_enable_qty_increments" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_enable_qty_increments_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_enable_qty_increments_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_qty_increments"> - <span><?php echo __('Qty Increments') ?></span> - </label> - <div class="control"> - <input type="text" class="input-text validate-number" id="inventory_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[qty_increments]" value="<?php echo $this->getDefaultConfigValue('qty_increments')*1 ?>" disabled="disabled" /> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <input type="checkbox" id="inventory_use_config_qty_increments" name="<?php echo $this->getFieldSuffix() ?>[use_config_qty_increments]" value="1" onclick="toggleValueElements(this, this.parentNode.parentNode, [$('inventory_qty_increments_checkbox')]);" checked="checked" disabled="disabled" /> - <label for="inventory_use_config_qty_increments" class="normal"><?php echo __('Use Config Settings') ?></label> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_qty_increments_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_qty_increments_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_qty_increments"> + <span><?php echo __('Qty Increments') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <input type="text" class="input-text validate-number" id="inventory_qty_increments" + name="<?php echo $this->getFieldSuffix() ?>[qty_increments]" + value="<?php echo $this->getDefaultConfigValue('qty_increments') * 1 ?>" + disabled="disabled"/> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_use_config_qty_increments" + name="<?php echo $this->getFieldSuffix() ?>[use_config_qty_increments]" value="1" data-role="toggle-editability" checked="checked" disabled="disabled"/> + <label for="inventory_use_config_qty_increments" + class="label"><span><?php echo __('Use Config Settings') ?></span></label> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_qty_increments_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_qty_increments_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> - <div class="field"> - <label class="label" for="inventory_stock_availability"> - <span><?php echo __('Stock Availability') ?></span> - </label> - <div class="control"> - <select id="inventory_stock_availability" name="<?php echo $this->getFieldSuffix() ?>[is_in_stock]" class="select" disabled="disabled"> - <option value="1"><?php echo __('In Stock') ?></option> - <option value="0"<?php if ($this->getDefaultConfigValue('is_in_stock')==0): ?> selected<?php endif; ?>><?php echo __('Out of Stock') ?></option> - </select> - </div> - <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"> - <span class="attribute-change-checkbox"> - <input type="checkbox" id="inventory_stock_availability_checkbox" onclick="toggleValueElementsWithCheckbox(this)" /> - <label for="inventory_stock_availability_checkbox" class="normal"><?php echo __('Change') ?></label> - </span> + <div class="field"> + <label class="label" for="inventory_stock_availability"> + <span><?php echo __('Stock Availability') ?></span> + </label> + + <div class="control"> + <div class="fields-group-2"> + <div class="field"> + <select id="inventory_stock_availability" + name="<?php echo $this->getFieldSuffix() ?>[is_in_stock]" class="select" + disabled="disabled"> + <option value="1"><?php echo __('In Stock') ?></option> + <option + value="0"<?php if ($this->getDefaultConfigValue('is_in_stock') == 0): ?> selected<?php endif; ?>><?php echo __('Out of Stock') ?></option> + </select> + </div> + <div class="field choice"> + <input type="checkbox" id="inventory_stock_availability_checkbox" data-role="toggle-editability-all"/> + <label for="inventory_stock_availability_checkbox" + class="label"><span><?php echo __('Change') ?></span></label> + </div> </div> </div> + <div class="field-service" value-scope="<?php echo __('[GLOBAL]') ?>"></div> + </div> </fieldset> </div> </div> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/websites.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/websites.phtml index 38f0a80033e..ad5804a32c7 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/websites.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/websites.phtml @@ -24,72 +24,72 @@ ?> <div class="fieldset-wrapper" id="add-products-to-website-wrapper"> - <div class="fieldset-wrapper-title"> - <strong class="title"> + <fieldset class="fieldset" id="grop_fields"> + <legend class="legend"> <span><?php echo __('Add Product To Websites') ?></span> - </strong> - </div> - <div class="fieldset-wrapper-content" id="add-products-to-website-content"> - <fieldset class="fieldset" id="grop_fields"> - <?php foreach ($this->getWebsiteCollection() as $_website): ?> - <div class="website-name"> - <input name="add_website_ids[]" value="<?php echo $_website->getId() ?>" <?php if($this->getWebsitesReadonly()): ?>disabled="disabled"<?php endif;?> class="checkbox website-checkbox" id="add_product_website_<?php echo $_website->getId() ?>" type="checkbox" /> - <strong><label for="add_product_website_<?php echo $_website->getId() ?>"><?php echo $this->escapeHtml($_website->getName()) ?></label></strong> - </div> - <div class="webiste-groups" id="add_product_website_<?php echo $_website->getId() ?>_data"> - <?php foreach ($this->getGroupCollection($_website) as $_group): ?> - <h4><?php echo $this->escapeHtml($_group->getName()) ?></h4> - <div class="group-stores"> - <table class="data-table"> + </legend> + <br> + <div class="store-scope"> + <div class="store-tree" id="add-products-to-website-content"> + <?php foreach ($this->getWebsiteCollection() as $_website): ?> + <div class="website-name"> + <input name="add_website_ids[]" value="<?php echo $_website->getId() ?>" <?php if($this->getWebsitesReadonly()): ?>disabled="disabled"<?php endif;?> class="checkbox website-checkbox" id="add_product_website_<?php echo $_website->getId() ?>" type="checkbox" /> + <label for="add_product_website_<?php echo $_website->getId() ?>"><?php echo $this->escapeHtml($_website->getName()) ?></label> + </div> + <dl class="webiste-groups" id="add_product_website_<?php echo $_website->getId() ?>_data"> + <?php foreach ($this->getGroupCollection($_website) as $_group): ?> + <dt><?php echo $this->escapeHtml($_group->getName()) ?></dt> + <dd class="group-stores"> + <ul> <?php foreach ($this->getStoreCollection($_group) as $_store): ?> - <tr> - <td><?php echo $this->escapeHtml($_store->getName()) ?></td> - <td> </td> - </tr> + <li> + <?php echo $this->escapeHtml($_store->getName()) ?> + </li> <?php endforeach; ?> - </table> - </div> - <?php endforeach; ?> - </div> - <?php endforeach; ?> - </fieldset> - </div> + </ul> + </dd> + <?php endforeach; ?> + </dl> + <?php endforeach; ?> + </div> + </div> + </fieldset> </div> <div class="fieldset-wrapper" id="remove-products-to-website-wrapper"> - <div class="fieldset-wrapper-title"> - <strong class="title"> + <fieldset class="fieldset" id="grop_fields"> + <legend class="legend"> <span><?php echo __('Remove Product From Websites') ?></span> - </strong> - </div> - <div class="fieldset-wrapper-content" id="remove-products-to-website-content"> - <fieldset class="fieldset" id="grop_fields"> - <div class="message info"> - <div><?php echo __("Items that you do not want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></div> - </div> - <?php foreach ($this->getWebsiteCollection() as $_website): ?> - <div class="website-name"> - <input name="remove_website_ids[]" value="<?php echo $_website->getId() ?>" <?php if($this->getWebsitesReadonly()): ?>disabled="disabled"<?php endif;?> class="checkbox website-checkbox" id="remove_product_website_<?php echo $_website->getId() ?>" type="checkbox"/> - <strong><label for="remove_product_website_<?php echo $_website->getId() ?>"><?php echo $this->escapeHtml($_website->getName()) ?></label></strong> - </div> - <div class="webiste-groups" id="remove_product_website_<?php echo $_website->getId() ?>_data"> - <?php foreach ($this->getGroupCollection($_website) as $_group): ?> - <h4><?php echo $this->escapeHtml($_group->getName()) ?></h4> - <div class="group-stores"> - <table class="data-table"> + </legend> + <br> + <div class="message info"> + <div><?php echo __("Items that you do not want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></div> + </div> + <div class="store-scope"> + <div class="store-tree" id="remove-products-to-website-content"> + <?php foreach ($this->getWebsiteCollection() as $_website): ?> + <div class="website-name"> + <input name="remove_website_ids[]" value="<?php echo $_website->getId() ?>" <?php if($this->getWebsitesReadonly()): ?>disabled="disabled"<?php endif;?> class="checkbox website-checkbox" id="remove_product_website_<?php echo $_website->getId() ?>" type="checkbox" /> + <label for="remove_product_website_<?php echo $_website->getId() ?>"><?php echo $this->escapeHtml($_website->getName()) ?></label> + </div> + <dl class="webiste-groups" id="remove_product_website_<?php echo $_website->getId() ?>_data"> + <?php foreach ($this->getGroupCollection($_website) as $_group): ?> + <dt><?php echo $this->escapeHtml($_group->getName()) ?></dt> + <dd class="group-stores"> + <ul> <?php foreach ($this->getStoreCollection($_group) as $_store): ?> - <tr> - <td><?php echo $this->escapeHtml($_store->getName()) ?></td> - <td> </td> - </tr> + <li> + <?php echo $this->escapeHtml($_store->getName()) ?> + </li> <?php endforeach; ?> - </table> - </div> - <?php endforeach; ?> - </div> - <?php endforeach; ?> - </fieldset> - </div> + </ul> + </dd> + <?php endforeach; ?> + </dl> + <?php endforeach; ?> + </div> + </div> + </fieldset> </div> <script type="text/javascript"> diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml index 56937eac033..9eb83124fe9 100644 --- a/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/configured_price.phtml @@ -26,10 +26,13 @@ /** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $this */ /** @var \Magento\Catalog\Pricing\Price\ConfiguredPrice $configuredPrice */ $configuredPrice = $this->getPrice(); +$priceLabel = ($this->getPriceLabel() !== null) + ? $this->getPriceLabel() + : __('Price as configured:'); ?> <p class="price-as-configured"> <?php echo $this->renderAmount($configuredPrice->getAmount(), [ - 'display_label' => __('Price as configured:'), + 'display_label' => $priceLabel, 'price_id' => $this->getPriceId('product-price-'), 'include_container' => false ]); ?> diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index b5203bb1b31..2bc539809f5 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -311,7 +311,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity 'use_config_enable_qty_inc' => 1, 'qty_increments' => 0, 'use_config_qty_increments' => 1, - 'is_in_stock' => 0, + 'is_in_stock' => 1, 'low_stock_date' => null, 'stock_status_changed_auto' => 0, 'is_decimal_divided' => 0 @@ -1786,9 +1786,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $row ); - $row = $this->stockItemService->processIsInStock($row); - if ($this->stockItemService->isQty($this->_newSku[$rowData[self::COL_SKU]]['type_id'])) { + $row = $this->stockItemService->processIsInStock($row); if ($this->stockItemService->verifyNotification($row['product_id'])) { $row['low_stock_date'] = $this->_localeDate->date( null, diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index a34245cd89a..7d42c81ef9f 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-import-export": "0.1.0-alpha92", - "magento/module-indexer": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-import-export": "0.1.0-alpha93", + "magento/module-indexer": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 0f0560ec06a..14b744233ac 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -903,6 +903,9 @@ class Item extends \Magento\Framework\Model\AbstractModel $isQty = $this->stockItemService->isQty($typeId); if ($isQty) { + if (!$this->getId()) { + $this->processIsInStock(); + } if ($this->getManageStock() && !$this->verifyStock()) { $this->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true); } diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteria.php b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteria.php index 9749bd1d058..d4eadf3b175 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteria.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteria.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObject; /** * Low stock criteria data object + * + * @codeCoverageIgnore */ class LowStockCriteria extends AbstractObject { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteriaBuilder.php b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteriaBuilder.php index bd8e901e44b..881696e5479 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteriaBuilder.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockCriteriaBuilder.php @@ -25,6 +25,8 @@ namespace Magento\CatalogInventory\Service\V1\Data; /** * Low stock criteria builder + * + * @codeCoverageIgnore */ class LowStockCriteriaBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResult.php b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResult.php index 9da2be72982..0da79133f8a 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResult.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResult.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObject; /** * Low stock search result data object + * + * @codeCoverageIgnore */ class LowStockResult extends AbstractObject { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResultBuilder.php b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResultBuilder.php index 1f4e01a9207..06b44cd0063 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResultBuilder.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/LowStockResultBuilder.php @@ -25,6 +25,8 @@ namespace Magento\CatalogInventory\Service\V1\Data; /** * Low stock search result builder object + * + * @codeCoverageIgnore */ class LowStockResultBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItem.php b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItem.php index daaa7399804..c1c8475dbe7 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItem.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItem.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObject; /** * Stock item data object + * + * @codeCoverageIgnore */ class StockItem extends AbstractObject { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php index d6fa3ad65e9..9850bb09269 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObject; /** * Stock item details data object + * + * @codeCoverageIgnore */ class StockItemDetails extends AbstractObject { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetailsBuilder.php b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetailsBuilder.php index 7ee9ae24a29..3031efe101b 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetailsBuilder.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetailsBuilder.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObjectBuilder; /** * Stock item details data builder + * + * @codeCoverageIgnore */ class StockItemDetailsBuilder extends AbstractObjectBuilder { diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/StockStatus.php b/app/code/Magento/CatalogInventory/Service/V1/Data/StockStatus.php index 62d942b34a6..97d83297818 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/StockStatus.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/StockStatus.php @@ -27,6 +27,8 @@ use Magento\Framework\Service\Data\AbstractObject; /** * Stock status data object + * + * @codeCoverageIgnore */ class StockStatus extends AbstractObject { diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 3dca3ff3f96..260782670d9 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-indexer": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-indexer": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index b2d53a4a92a..c553599dace 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-rule": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-index": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-rule": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-index": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 2da508b5d13..e9e65d38a74 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-indexer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-indexer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 62b37171d84..6b6f6212343 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-url-redirect": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92" + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-url-redirect": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index 12621985669..5812e3e21b6 100644 --- a/app/code/Magento/Centinel/composer.json +++ b/app/code/Magento/Centinel/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml b/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml index 8d9835501c5..d41533f6780 100644 --- a/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml +++ b/app/code/Magento/Centinel/view/frontend/templates/authentication/complete.phtml @@ -25,12 +25,10 @@ <?php if ($this->getIsProcessed()):?> <?php if ($this->getIsSuccess()):?> <script type="text/javascript"> -require(['jquery'], function(jQuery){ parent.jQuery('[data-container="body"]').trigger("paymentAuthentication", {state: "success"}); -}); -</script> + </script> <?php else:?> <h4><?php echo __('Verification Failed');?></h4> <p><?php echo __('The card has failed verification with the issuer bank.')?> <strong><?php echo __('Order cannot be placed.')?></strong></p> diff --git a/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml b/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml index 8a32507a9f0..b52250e4444 100644 --- a/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml +++ b/app/code/Magento/Centinel/view/frontend/templates/authentication/start.phtml @@ -30,12 +30,10 @@ </fieldset> </form> <script type="text/javascript"> -require(['jquery'], function(jQuery){ window.onload = function () { parent.jQuery('[data-container="body"]').trigger("paymentAuthentication", {state: "start"}); document.getElementById('validation-form').submit(); } -}); </script> diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index 8816bc11a37..e217ec2ef69 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -99,6 +99,8 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Sales\Model\QuoteFactory $quoteFactory @@ -114,6 +116,8 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Sales\Model\QuoteFactory $quoteFactory, @@ -128,7 +132,16 @@ class Session extends \Magento\Framework\Session\SessionManager $this->_remoteAddress = $remoteAddress; $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start($sessionName); } diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index eb48bc0d8e9..d16752337e5 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-gift-message": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-page-cache": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-gift-message": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-page-cache": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/login.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/login.phtml index 5d50197db26..20c2fce40ce 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/login.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/login.phtml @@ -114,10 +114,10 @@ <?php if ($this->isAllowedGuestCheckout()): ?> <button data-role="opc-continue" id="onepage-guest-register-button" type="button" class="action continue primary" data-checkout='{"isGuestCheckoutAllowed":true}'><span><?php echo __('Continue') ?></span></button> <?php elseif ($this->helper('Magento\Checkout\Helper\Data')->isCustomerMustBeLogged()): ?> - <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" /> + <input type="checkbox" name="checkout_method" id="login:register" value="register" checked="checked" style="display: none"/> <button data-role="opc-continue" id="onepage-guest-register-button" type="button" class="action register primary" data-checkout='{"isGuestCheckoutAllowed":false, "registrationUrl":"<?php echo $this->helper('Magento\Customer\Helper\Data')->getRegisterUrl();?>"}'><span><?php echo __('Register') ?></span></button> <?php else: ?> - <input type="hidden" name="checkout_method" data-role="checkout-method-register" id="login:register" value="register" checked="checked" /> + <input type="checkbox" name="checkout_method" data-role="checkout-method-register" id="login:register" value="register" checked="checked" style="display: none"/> <button data-role="opc-continue" id="onepage-guest-register-button" type="button" class="action register primary" data-checkout='{"isGuestCheckoutAllowed":true}'><span><?php echo __('Register') ?></span></button> <?php endif; ?> </div> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js index 5b5dfcf568b..e1ab03bfff2 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js @@ -172,7 +172,7 @@ define([ var json = elem.data('checkout'), checkout = this.options.checkout, guestChecked = $( checkout.loginGuestSelector ).is( ':checked' ), - loginRegister = $( checkout.loginRegisterSelector )[0], + registerChecked = $( checkout.loginRegisterSelector ).is( ':checked' ), method = 'register', action = 'show'; @@ -181,7 +181,7 @@ define([ if (json.isGuestCheckoutAllowed) { - if( !guestChecked && !(loginRegister && loginRegister.checked) ){ + if( !guestChecked && !registerChecked ){ alert( $.mage.__('Please choose to register or to checkout as a guest.') ); return false; @@ -200,6 +200,9 @@ define([ this.element.find( checkout.registerCustomerPasswordSelector )[action](); } + else if( json.registrationUrl ){ + window.location = json.registrationUrl; + } this.element.trigger('login'); }, diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 988fcdf04ab..98a24e9fabc 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php index 6798fb562ef..cd98b4615eb 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php @@ -62,22 +62,34 @@ class Content extends \Magento\Backend\Block\Widget\Container $this->buttonList->remove('edit'); $this->buttonList->add( 'new_folder', - array('class' => 'save', 'label' => __('Create Folder...'), 'type' => 'button') + array('class' => 'save', 'label' => __('Create Folder...'), 'type' => 'button'), + 0, + 0, + 'header' ); $this->buttonList->add( 'delete_folder', - array('class' => 'delete no-display', 'label' => __('Delete Folder'), 'type' => 'button') + array('class' => 'delete no-display', 'label' => __('Delete Folder'), 'type' => 'button'), + 0, + 0, + 'header' ); $this->buttonList->add( 'delete_files', - array('class' => 'delete no-display', 'label' => __('Delete File'), 'type' => 'button') + array('class' => 'delete no-display', 'label' => __('Delete File'), 'type' => 'button'), + 0, + 0, + 'header' ); $this->buttonList->add( 'insert_files', - array('class' => 'save no-display primary', 'label' => __('Insert File'), 'type' => 'button') + array('class' => 'save no-display primary', 'label' => __('Insert File'), 'type' => 'button'), + 0, + 0, + 'header' ); } diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index b5f0105614a..625b46255ce 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-email": "0.1.0-alpha92", - "magento/module-install": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-email": "0.1.0-alpha93", + "magento/module-install": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 063c9c841c1..79c62328fd4 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-url-redirect": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92" + "magento/module-store": "0.1.0-alpha93", + "magento/module-url-redirect": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index 08c3e7ac715..a49b43a2c92 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-catalog-import-export": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-import-export": "0.1.0-alpha92", - "magento/module-configurable-product": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92" + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-catalog-import-export": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-import-export": "0.1.0-alpha93", + "magento/module-configurable-product": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php b/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php index e0a0e059ecf..918d24ab6e5 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php +++ b/app/code/Magento/ConfigurableProduct/Model/Attribute/LockValidator.php @@ -46,7 +46,6 @@ class LockValidator implements LockValidatorInterface * @param \Magento\Framework\Model\AbstractModel $object * @param null $attributeSet * @throws \Magento\Framework\Model\Exception - * * @return void */ public function validate(\Magento\Framework\Model\AbstractModel $object, $attributeSet = null) diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php index 0a723a8b6f2..ea950836097 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php @@ -23,6 +23,9 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; +/** + * @codeCoverageIgnore + */ class Option extends \Magento\Framework\Service\Data\AbstractObject { /**#@+ diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php index 0ecd1e14924..6eecac37264 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php @@ -21,9 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\ConfigurableProduct\Service\V1\Data\Option; +/** + * @codeCoverageIgnore + */ class Value extends \Magento\Framework\Service\Data\AbstractObject { const INDEX = 'index'; diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php index f113fde85bf..ddbb23c6bed 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php @@ -25,6 +25,9 @@ namespace Magento\ConfigurableProduct\Service\V1\Data\Option; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class ValueBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php index 202c6f19b1f..568372a22eb 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php @@ -23,6 +23,9 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data\Option; +/** + * @codeCoverageIgnore + */ class ValueConverter { /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php index e720f3e8213..a973df03023 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php @@ -23,6 +23,9 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; +/** + * @codeCoverageIgnore + */ class OptionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index b11cab300cb..7895fb7c631 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-catalog-rule": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", - "magento/module-webapi": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-catalog-rule": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-weee": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", + "magento/module-webapi": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index f81900d3c2d..a1ab8a43709 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/Model/File/Storage/Response.php b/app/code/Magento/Core/Model/File/Storage/Response.php index 07fe7927406..34a9bde1a22 100644 --- a/app/code/Magento/Core/Model/File/Storage/Response.php +++ b/app/code/Magento/Core/Model/File/Storage/Response.php @@ -23,6 +23,8 @@ */ namespace Magento\Core\Model\File\Storage; +use Magento\Framework\Stdlib\CookieManager; +use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\App\Response\Http; class Response extends Http implements \Magento\Framework\App\Response\FileInterface @@ -42,16 +44,18 @@ class Response extends Http implements \Magento\Framework\App\Response\FileInter /** * Constructor * - * @param \Magento\Framework\Stdlib\Cookie $cookie - * @param \Magento\Framework\App\Http\Context $context + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory + * @param \Magento\Framework\App\Http\Context $context * @param \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter */ public function __construct( - \Magento\Framework\Stdlib\Cookie $cookie, + CookieManager $cookieManager, + CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\App\Http\Context $context, \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter ) { - parent::__construct($cookie, $context); + parent::__construct($cookieManager, $cookieMetadataFactory, $context); $this->_transferAdapter = $transferAdapter; } diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 80b3c122eff..6d823c678f0 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-page-cache": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-page-cache": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index ea46458a942..9004dd991a1 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -81,6 +81,7 @@ <preference for="Magento\Framework\App\Config\Resource\ConfigInterface" type="Magento\Core\Model\Resource\Config" /> <preference for="Magento\Framework\App\DesignInterface" type="Magento\Core\Model\Design" /> <preference for="Magento\Framework\Pricing\Amount\AmountInterface" type="Magento\Framework\Pricing\Amount\Base" /> + <preference for="Magento\Framework\Stdlib\CookieManager" type="Magento\Framework\Stdlib\Cookie\PhpCookieManager" /> <type name="Magento\Framework\App\DefaultPath\DefaultPath"> <arguments> <argument name="parts" xsi:type="array"> diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index 03e0ba31079..3b9ce9020d6 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 35f434b91f0..3e16764643f 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-page-cache": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-page-cache": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 1a160afe616..793aab1e8d6 100755 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -113,6 +113,8 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler * @param \Magento\Framework\Session\ValidatorInterface $validator * @param \Magento\Framework\Session\StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param Share $configShare * @param \Magento\Core\Helper\Url $coreUrl * @param \Magento\Customer\Helper\Data $customerData @@ -133,6 +135,8 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\SaveHandlerInterface $saveHandler, \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, Config\Share $configShare, \Magento\Core\Helper\Url $coreUrl, \Magento\Customer\Helper\Data $customerData, @@ -156,7 +160,16 @@ class Session extends \Magento\Framework\Session\SessionManager $this->_customerAccountService = $customerAccountService; $this->_eventManager = $eventManager; $this->_httpContext = $httpContext; - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start($sessionName); $this->_converter = $converter; $this->_eventManager->dispatch('customer_session_init', array('customer_session' => $this)); diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index a81627d618f..f00584bb653 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,29 +3,29 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-newsletter": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-index": "0.1.0-alpha92", - "magento/module-log": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-review": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-page-cache": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", - "magento/module-authorization": "0.1.0-alpha92", - "magento/module-integration": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-newsletter": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-index": "0.1.0-alpha93", + "magento/module-log": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-review": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-page-cache": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", + "magento/module-authorization": "0.1.0-alpha93", + "magento/module-integration": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/view/frontend/web/address.js b/app/code/Magento/Customer/view/frontend/web/address.js index c584a11c567..20c24279610 100644 --- a/app/code/Magento/Customer/view/frontend/web/address.js +++ b/app/code/Magento/Customer/view/frontend/web/address.js @@ -43,8 +43,8 @@ define([ * @private */ _create: function() { - $(this.options.addAddress).on('click', $.proxy(this._addAddress, this)); - $(this.options.deleteAddress).on('click', $.proxy(this._deleteAddress, this)); + $(document).on('click', this.options.addAddress, $.proxy(this._addAddress, this)); + $(document).on('click', this.options.deleteAddress, $.proxy(this._deleteAddress, this)); }, /** diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index 1ea7f97d0e0..0bf7781f8ba 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-import-export": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-import-export": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index c58852a9115..0069c2479c6 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-url-rewrite": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-url-rewrite": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index f467f32fa98..84c59de268a 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index 3cc0d57ac7e..793154d4285 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php index df9214d4cb7..12a54705574 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php @@ -47,6 +47,8 @@ class Name extends \Magento\Sales\Block\Adminhtml\Items\Column\Name /** * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService + * @param \Magento\Framework\Registry $registry * @param \Magento\Catalog\Model\Product\OptionFactory $optionFactory * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory @@ -54,6 +56,8 @@ class Name extends \Magento\Sales\Block\Adminhtml\Items\Column\Name */ public function __construct( \Magento\Backend\Block\Template\Context $context, + \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, + \Magento\Framework\Registry $registry, \Magento\Catalog\Model\Product\OptionFactory $optionFactory, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, @@ -61,7 +65,7 @@ class Name extends \Magento\Sales\Block\Adminhtml\Items\Column\Name ) { $this->_purchasedFactory = $purchasedFactory; $this->_itemsFactory = $itemsFactory; - parent::__construct($context, $optionFactory, $data); + parent::__construct($context, $stockItemService, $registry, $optionFactory, $data); } /** diff --git a/app/code/Magento/Downloadable/Service/V1/Data/FileContent.php b/app/code/Magento/Downloadable/Service/V1/Data/FileContent.php index 8b6c6a80df2..53dc0cbfd4d 100644 --- a/app/code/Magento/Downloadable/Service/V1/Data/FileContent.php +++ b/app/code/Magento/Downloadable/Service/V1/Data/FileContent.php @@ -25,6 +25,9 @@ namespace Magento\Downloadable\Service\V1\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class FileContent extends AbstractObject { const DATA = 'data'; diff --git a/app/code/Magento/Downloadable/Service/V1/Data/FileContentBuilder.php b/app/code/Magento/Downloadable/Service/V1/Data/FileContentBuilder.php index b0c443c3da9..e87a624c8ea 100644 --- a/app/code/Magento/Downloadable/Service/V1/Data/FileContentBuilder.php +++ b/app/code/Magento/Downloadable/Service/V1/Data/FileContentBuilder.php @@ -25,6 +25,9 @@ namespace Magento\Downloadable\Service\V1\Data; use \Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class FileContentBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContent.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContent.php index 72de1163db1..59be97dde36 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContent.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContent.php @@ -26,6 +26,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class DownloadableLinkContent extends AbstractObject { const TITLE = 'title'; diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContentBuilder.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContentBuilder.php index f344be1800e..176381b6ce3 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContentBuilder.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkContentBuilder.php @@ -28,6 +28,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use \Magento\Framework\Service\Data\AbstractObjectBuilder; use \Magento\Downloadable\Service\V1\Data\FileContent; +/** + * @codeCoverageIgnore + */ class DownloadableLinkContentBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfo.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfo.php index 0e841b08e7f..31a23891191 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfo.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfo.php @@ -26,6 +26,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class DownloadableLinkInfo extends AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfoBuilder.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfoBuilder.php index 28853bfc59b..838c482be9e 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfoBuilder.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableLinkInfoBuilder.php @@ -27,6 +27,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class DownloadableLinkInfoBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableResourceInfo.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableResourceInfo.php index 29959bea145..c08524b581f 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableResourceInfo.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableResourceInfo.php @@ -26,6 +26,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class DownloadableResourceInfo extends AbstractObject { const FILE = 'file'; diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfo.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfo.php index 532d15fbf06..daab802e77a 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfo.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfo.php @@ -26,6 +26,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class DownloadableSampleInfo extends AbstractObject { const ID = 'id'; diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfoBuilder.php b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfoBuilder.php index 7540f4b11e7..0a7535f7ceb 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfoBuilder.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableLink/Data/DownloadableSampleInfoBuilder.php @@ -27,6 +27,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableLink\Data; use Magento\Framework\Service\Data\AbstractObjectBuilder; +/** + * @codeCoverageIgnore + */ class DownloadableSampleInfoBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContent.php b/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContent.php index 349d35f84f7..62beae8ebad 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContent.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContent.php @@ -26,6 +26,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableSample\Data; use \Magento\Framework\Service\Data\AbstractObject; +/** + * @codeCoverageIgnore + */ class DownloadableSampleContent extends AbstractObject { const TITLE = 'title'; diff --git a/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContentBuilder.php b/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContentBuilder.php index 11b7b09c342..6d794cba30a 100644 --- a/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContentBuilder.php +++ b/app/code/Magento/Downloadable/Service/V1/DownloadableSample/Data/DownloadableSampleContentBuilder.php @@ -28,6 +28,9 @@ namespace Magento\Downloadable\Service\V1\DownloadableSample\Data; use \Magento\Framework\Service\Data\AbstractObjectBuilder; use \Magento\Downloadable\Service\V1\Data\FileContent; +/** + * @codeCoverageIgnore + */ class DownloadableSampleContentBuilder extends AbstractObjectBuilder { /** diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 63a02f5615a..80d15ba2798 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,26 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-gift-message": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-gift-message": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/etc/module.xml b/app/code/Magento/Downloadable/etc/module.xml index d17b2b48cbd..9a0a14069bc 100644 --- a/app/code/Magento/Downloadable/etc/module.xml +++ b/app/code/Magento/Downloadable/etc/module.xml @@ -40,7 +40,6 @@ <module name="Magento_Sales"/> <module name="Magento_Checkout"/> <module name="Magento_Directory"/> - <module name="Magento_Weee"/> <module name="Magento_Wishlist"/> <module name="Magento_GiftMessage"/> <module name="Magento_CatalogInventory"/> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml index 4c5a8eb774f..94908c13403 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/create/items/renderer/downloadable.phtml @@ -22,50 +22,13 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer $this */?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item); ?> <tr class="border"> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('price') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displayPriceInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price')?> </td> <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <?php if ($this->canParentReturnToStock($_item)) : ?> @@ -83,53 +46,11 @@ <?php endif; ?> </td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('row_total') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> - <?php endif; ?> - <?php endif; ?> - </span> + <?php echo $this->getColumnHtml($_item, 'subtotal')?> </td> <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total')?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml index 60813107eaf..21e394e3e56 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/creditmemo/view/items/renderer/downloadable.phtml @@ -22,100 +22,21 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item) ?> <tr class="border"> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('price') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displayPriceInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price')?> </td> <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('row_total') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal')?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount(), - $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total')?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml index 174e5fb089e..6092b89ef95 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/create/items/renderer/downloadable.phtml @@ -22,50 +22,13 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item)?> <tr class="border"> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('price') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displayPriceInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price')?> </td> <td class="col-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <td class="col-qty-invoice"> @@ -76,53 +39,11 @@ <?php endif; ?> </td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('row_total') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal')?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedRowAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total')?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml index 21b2455efec..21e394e3e56 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/invoice/view/items/renderer/downloadable.phtml @@ -22,100 +22,21 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item) ?> <tr class="border"> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'downloadable') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('price') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displayPriceInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price')?> </td> <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('row_total') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal')?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseTaxAmount()-$_item->getBaseDiscountAmount()+$_item->getWeeeTaxAppliedAmount(), - $_item->getRowTotal()+$_item->getTaxAmount()-$_item->getDiscountAmount()+$_item->getWeeeTaxAppliedAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total')?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml index 69c673990ee..0ccf9b73fd3 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/sales/order/view/items/renderer/downloadable.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item) ?> <tr<?php if ($this->canDisplayGiftmessage()): ?> class="border"<?php endif; ?>> @@ -39,103 +40,16 @@ <td class="col-status"><?php echo $_item->getStatus() ?></td> <td class="col-price-original"><?php echo $this->displayPriceAttribute('original_price') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('price') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item)+$_item->getWeeeTaxAppliedAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displayPriceInclTax($_item); ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price')?> </td> <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displayPriceAttribute('row_total') ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="price-incl-tax"> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(0, 'sales')): // including ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): // incl. + weee ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - <br /> - <small> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr">+ <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($_item->getWeeeTaxAppliedRowAmount() && $this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): // excl. + weee + final ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)); ?> - <br /> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Core\Helper\Data')->currency($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <span class="nobr"> - <?php echo __('Total'); ?>: - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item)+$_item->getWeeeTaxAppliedRowAmount()); ?> - </span> - <?php else: // excl. ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> - <?php endif; ?> -<!-- - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php echo $this->displaySubtotalInclTax($_item); ?> ---> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal')?> </td> <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-tax-percent"><?php echo $this->displayTaxPercent($_item) ?></td> <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() - $_item->getBaseDiscountAmount() + $_item->getBaseTaxAmount(), - $_item->getRowTotal() - $_item->getDiscountAmount() + $_item->getTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - ); ?> + <?php echo $this->getColumnHtml($_item, 'total')?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/creditmemo/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/creditmemo/downloadable.phtml index 7e792ac8b3e..6695308baea 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/creditmemo/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/creditmemo/downloadable.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable */ ?> <?php $_item = $this->getItem() ?> <?php $_order = $this->getItem()->getOrder(); ?> <tr> @@ -48,79 +49,6 @@ <td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getQty()*1 ?></td> <td align="right" valign="top" style="padding:3px 9px"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/invoice/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/invoice/downloadable.phtml index 555b22615ce..7fbdd15e1b3 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/invoice/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/invoice/downloadable.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable */ ?> <?php $_item = $this->getItem() ?> <?php $_order = $this->getItem()->getOrder(); ?> <tr> @@ -51,79 +52,6 @@ <td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getQty()*1 ?></td> <td align="right" valign="top" style="padding:3px 9px"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/order/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/order/downloadable.phtml index f7b994580e8..331e37c8a8e 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/order/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/email/order/items/order/downloadable.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Downloadable\Block\Sales\Order\Email\Items\Order\Downloadable */ ?> <?php $_item = $this->getItem() ?> <?php $_order = $this->getItem()->getOrder() ?> <tr> @@ -57,79 +58,6 @@ <td align="left" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="padding:3px 9px"><?php echo $_item->getQtyOrdered()*1 ?></td> <td align="right" valign="top" style="padding:3px 9px"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/creditmemo/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/creditmemo/items/renderer/downloadable.phtml index ee4566eed5f..c097c3515f0 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/creditmemo/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/creditmemo/items/renderer/downloadable.phtml @@ -76,178 +76,14 @@ </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart tax info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty')); ?>"><?php echo $_item->getQty()*1 ?></td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> <td class="col discount" data-th="<?php echo $this->escapeHtml(__('Discount Amount')); ?>"><?php echo $_order->formatPrice(-$_item->getDiscountAmount()) ?></td> <td class="cot total" data-th="<?php echo $this->escapeHtml(__('Row Total')); ?>"> - <?php echo $_order->formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> + <?php echo $this->getItemRowTotalAfterDiscountHtml(); ?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/invoice/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/invoice/items/renderer/downloadable.phtml index ca56ccf7ff2..509f1f54c69 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/invoice/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/invoice/items/renderer/downloadable.phtml @@ -75,180 +75,12 @@ </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty Invoiced')); ?>"> <span class="qty summary" data-th="<?php echo $this->escapeHtml(__('Qty Invoiced')); ?>"><?php echo $_item->getQty()*1 ?></span> </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" - id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> </tr> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml index a532caf8952..5fd5789eba4 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/sales/order/items/renderer/downloadable.phtml @@ -80,92 +80,7 @@ </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty')); ?>"> <ul class="items-qty"> @@ -196,91 +111,7 @@ </ul> </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" - id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" - style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> <?php /* <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php index 213206ac7ff..f20de6c7445 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php @@ -423,4 +423,16 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac return $this; } + + + /** + * @inheritdoc + */ + public function getSelectCountSql() + { + $countSelect = parent::getSelectCountSql(); + $countSelect->reset(\Zend_Db_Select::COLUMNS); + $countSelect->columns('COUNT(DISTINCT main_table.attribute_id)'); + return $countSelect; + } } diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 459cdf68a02..73f4007a2d0 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php index 50d06bb8848..ea48ddc9498 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php @@ -167,7 +167,9 @@ class Edit extends \Magento\Backend\Block\Widget implements \Magento\Backend\Blo 'delete', array( 'label' => __('Delete Template'), - 'onclick' => 'templateControl.deleteTemplate();', + 'data_attribute' => array( + 'role' => 'template-delete' + ), 'class' => 'delete' ) ); @@ -177,7 +179,9 @@ class Edit extends \Magento\Backend\Block\Widget implements \Magento\Backend\Blo 'to_plain', array( 'label' => __('Convert to Plain Text'), - 'onclick' => 'templateControl.stripTags();', + 'data_attribute' => array( + 'role' => 'template-strip' + ), 'id' => 'convert_button' ) ); @@ -185,7 +189,9 @@ class Edit extends \Magento\Backend\Block\Widget implements \Magento\Backend\Blo 'to_html', array( 'label' => __('Return Html Version'), - 'onclick' => 'templateControl.unStripTags();', + 'data_attribute' => array( + 'role' => 'template-unstrip' + ), 'id' => 'convert_button_back', 'style' => 'display:none' ) @@ -193,13 +199,20 @@ class Edit extends \Magento\Backend\Block\Widget implements \Magento\Backend\Blo } $this->buttonList->add( 'preview', - array('label' => __('Preview Template'), 'onclick' => 'templateControl.preview();') + array( + 'label' => __('Preview Template'), + 'data_attribute' => array( + 'role' => 'template-preview' + ) + ) ); $this->buttonList->add( 'save', array( 'label' => __('Save Template'), - 'onclick' => 'templateControl.save();', + 'data_attribute' => array( + 'role' => 'template-save' + ), 'class' => 'save primary save-template' ) ); @@ -207,7 +220,9 @@ class Edit extends \Magento\Backend\Block\Widget implements \Magento\Backend\Blo 'load', array( 'label' => __('Load Template'), - 'onclick' => 'templateControl.load();', + 'data_attribute' => array( + 'role' => 'template-load' + ), 'type' => 'button', 'class' => 'save' ), diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index 6b336196b86..874ec744873 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml index 86b743a2884..538a74d73bb 100644 --- a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml @@ -82,13 +82,45 @@ require([ unconvertedText: '', typeChange: false, variables: null, + + events: { + 'click [data-role=template-save]' : 'save', + 'click [data-role=template-preview]' : 'preview', + 'click [data-role=template-unstrip]' : 'unStripTags', + 'click [data-role=template-strip]' : 'stripTags', + 'click [data-role=template-delete]': 'deleteTemplate', + 'click [data-role=template-load]': 'load' + }, + init: function () { if ($('convert_button_back')) { $('convert_button_back').hide(); } + + this.bindEvents(); + this.renderPaths(<?php echo $this->getUsedDefaultForPaths(); ?>, 'used_default_for'); this.renderPaths(<?php echo $this->getUsedCurrentlyForPaths(); ?>, 'used_currently_for'); }, + + bindEvents: function(){ + var events = this.events, + eventName, + selector, + callback, + key; + + for( key in events ){ + callback = this[events[key]]; + key = key.split(' '); + + eventName = key[0]; + selector = key.slice(1).join(' '); + + jQuery(selector).on(eventName, jQuery.proxy(callback, this) ); + } + }, + stripTags: function () { if(!window.confirm("<?php echo __('Are you sure that you want to strip tags?') ?>")) { return false; diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index e9f108b6514..b59a2948386 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index ab8bdee8ed8..ea4f89a561a 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-multishipping": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-multishipping": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 1e1186e2435..0871683c6b6 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 44b90179e9d..8c052d78a6d 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index c0c161cee8d..19b24193042 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-google-analytics": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-google-analytics": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 301d9f7aad9..0653fc8490f 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index b9e3799d1ed..d10e42271fb 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-import-export": "0.1.0-alpha92", - "magento/module-catalog-import-export": "0.1.0-alpha92", - "magento/module-grouped-product": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92" + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-import-export": "0.1.0-alpha93", + "magento/module-catalog-import-export": "0.1.0-alpha93", + "magento/module-grouped-product": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 5f48a5be84d..194defc21f1 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 8ae46fed5df..07ceb549aa5 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-indexer": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-indexer": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 25fe7c7e83b..fd2dd650972 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index e9d675725f1..a25790d2fa3 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-page-cache": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-page-cache": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index 65f882ad0d8..a697de6070f 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-user": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-user": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index cd5f7fd93b8..c247cc387e4 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-user": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", - "magento/module-authorization": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-user": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", + "magento/module-authorization": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index 370f1216505..e768accf760 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml b/app/code/Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml index 09986a45093..1a9c3455d71 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml +++ b/app/code/Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml @@ -24,6 +24,11 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="root"> + <action method="addBodyClass"> + <argument name="class" xsi:type="string">page-with-filter</argument> + </action> + </referenceBlock> <referenceContainer name="sidebar.main"> <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="layer/view.phtml"> <block class="Magento\LayeredNavigation\Block\Navigation\State\Category" name="catalog.navigation.state" as="state" /> diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index bac2d75fc99..4aee7ac3097 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 07ae882a256..e57b6e2b48b 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-weee": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php index c9e2984a713..656be4d4600 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php @@ -109,7 +109,9 @@ class Edit extends \Magento\Backend\Block\Widget 'Magento\Backend\Block\Widget\Button', array( 'label' => __('Convert to Plain Text'), - 'onclick' => 'templateControl.stripTags();', + 'data_attribute' => array( + 'role' => 'template-strip' + ), 'id' => 'convert_button', 'class' => 'convert' ) @@ -120,7 +122,9 @@ class Edit extends \Magento\Backend\Block\Widget 'Magento\Backend\Block\Widget\Button', array( 'label' => __('Return HTML Version'), - 'onclick' => 'templateControl.unStripTags();', + 'data_attribute' => array( + 'role' => 'template-unstrip' + ), 'id' => 'convert_button_back', 'style' => 'display:none', 'class' => 'return' @@ -131,7 +135,13 @@ class Edit extends \Magento\Backend\Block\Widget $this->getToolbar()->addChild( 'preview_button', 'Magento\Backend\Block\Widget\Button', - array('label' => __('Preview Template'), 'onclick' => 'templateControl.preview();', 'class' => 'preview') + array( + 'label' => __('Preview Template'), + 'data_attribute' => array( + 'role' => 'template-preview' + ), + 'class' => 'preview' + ) ); if ($this->getEditMode()) { @@ -140,7 +150,9 @@ class Edit extends \Magento\Backend\Block\Widget 'Magento\Backend\Block\Widget\Button', array( 'label' => __('Delete Template'), - 'onclick' => 'templateControl.deleteTemplate();', + 'data_attribute' => array( + 'role' => 'template-delete' + ), 'class' => 'delete' ) ); @@ -148,14 +160,26 @@ class Edit extends \Magento\Backend\Block\Widget $this->getToolbar()->addChild( 'save_as_button', 'Magento\Backend\Block\Widget\Button', - array('label' => __('Save As'), 'onclick' => 'templateControl.saveAs();', 'class' => 'save-as') + array( + 'label' => __('Save As'), + 'data_attribute' => array( + 'role' => 'template-save-as' + ), + 'class' => 'save-as' + ) ); } $this->getToolbar()->addChild( 'save_button', 'Magento\Backend\Block\Widget\Button', - array('label' => __('Save Template'), 'onclick' => 'templateControl.save();', 'class' => 'save primary') + array( + 'label' => __('Save Template'), + 'data_attribute' => array( + 'role' => 'template-save' + ), + 'class' => 'save primary' + ) ); return parent::_prepareLayout(); diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 535b99bcab6..751c49b0248 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-email": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-email": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml index ed7b8e85023..72d9a4ef274 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml @@ -53,10 +53,39 @@ require(['jquery', 'mage/mage', 'prototype'], function(jQuery){ templateName: false, id: 'text', + events: { + 'click [data-role=template-save]' : 'save', + 'click [data-role=template-save-as]': 'saveAs', + 'click [data-role=template-preview]' : 'preview', + 'click [data-role=template-unstrip]' : 'unStripTags', + 'click [data-role=template-strip]' : 'stripTags', + 'click [data-role=template-delete]': 'deleteTemplate' + }, + init: function () { if ($('convert_button_back')) { $('convert_button_back').hide(); } + + this.bindEvents(); + }, + + bindEvents: function(){ + var events = this.events, + eventName, + selector, + callback, + key; + + for( key in events ){ + callback = this[events[key]]; + key = key.split(' '); + + eventName = key[0]; + selector = key.slice(1).join(' '); + + jQuery(selector).on(eventName, jQuery.proxy(callback, this) ); + } }, stripTags: function () { diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 4f1c6e19bac..04fa82d9ca2 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-payment": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-payment": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 4b6560c1bd0..26f52b3d904 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-sales-rule": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-sales-rule": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index 463423ba7b6..033ce6c9be6 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php index 881f462a4c7..3234af5463d 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php @@ -23,6 +23,11 @@ */ namespace Magento\PageCache\Model\App\FrontController; +use Magento\Framework\App\FrontController; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; +use Magento\Framework\Stdlib\CookieManager; + class MessageBox { /** @@ -36,11 +41,18 @@ class MessageBox const COOKIE_PERIOD = 315360000; /** - * Cookie + * Cookie manager * - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $cookie; + protected $cookieManager; + + /** + * Cookie metadata factory + * + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactory; /** * Request @@ -50,28 +62,35 @@ class MessageBox protected $request; /** + * Scope config + * * @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $config; /** + * Message manager + * * @var \Magento\Framework\Message\Manager */ protected $messageManager; /** - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param CookieManager $cookieManager + * @param CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\App\Request\Http $request * @param \Magento\PageCache\Model\Config $config * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Framework\Stdlib\Cookie $cookie, + CookieManager $cookieManager, + CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\App\Request\Http $request, \Magento\PageCache\Model\Config $config, \Magento\Framework\Message\ManagerInterface $messageManager ) { - $this->cookie = $cookie; + $this->cookieManager = $cookieManager; + $this->cookieMetadataFactory = $cookieMetadataFactory; $this->request = $request; $this->config = $config; $this->messageManager = $messageManager; @@ -80,16 +99,19 @@ class MessageBox /** * Set Cookie for msg box when it displays first * - * @param \Magento\Framework\App\FrontController $subject - * @param \Magento\Framework\App\ResponseInterface $response + * @param FrontController $subject + * @param ResponseInterface $response * - * @return \Magento\Framework\App\ResponseInterface + * @return ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDispatch(\Magento\Framework\App\FrontController $subject, \Magento\Framework\App\ResponseInterface $response) + public function afterDispatch(FrontController $subject, ResponseInterface $response) { if ($this->request->isPost() && $this->messageManager->hasMessages()) { - $this->cookie->set(self::COOKIE_NAME, 1, self::COOKIE_PERIOD, '/'); + $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration(self::COOKIE_PERIOD) + ->setPath('/'); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, 1, $publicCookieMetadata); } return $response; } diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index a6be326a2cd..cb4980b68fa 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index 2d75a75ce3e..a4c82d9947b 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-paypal": "0.1.0-alpha92", - "magento/module-recurring-payment": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-paypal": "0.1.0-alpha93", + "magento/module-recurring-payment": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index e40a3b93c06..01c5d7e638a 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-centinel": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-centinel": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index 0a1ff267fcb..beee8266d6e 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-centinel": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-centinel": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/view/frontend/templates/hss/form.phtml b/app/code/Magento/Paypal/view/frontend/templates/hss/form.phtml index 40fedef5ad3..a10b664c7b4 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/hss/form.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/hss/form.phtml @@ -28,8 +28,6 @@ ?> <html> <head> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery.js') ?>"></script> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery-migrate.js') ?>"></script> </head> <body> <form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>"> @@ -38,12 +36,7 @@ <input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>"/> </form> <script type="text/javascript"> -require(['jquery'], function(jQuery){ - - // this is NOT tested. - jQuery('#token_form').submit(); - -}); + document.getElementById('token_form').submit(); </script> </body> </html> diff --git a/app/code/Magento/Paypal/view/frontend/templates/hss/redirect.phtml b/app/code/Magento/Paypal/view/frontend/templates/hss/redirect.phtml index a2a237f4d73..c2cb67cb061 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/hss/redirect.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/hss/redirect.phtml @@ -33,7 +33,6 @@ </head> <body> <script type="text/javascript"> -require(['jquery'], function(jQuery){ // this code is NOT tested! if (window.top == window.self) { @@ -59,7 +58,6 @@ require(['jquery'], function(jQuery){ window.top.location = "<?php echo $this->getUrl('checkout/cart') ?>"; <?php endif; ?> -}); </script> </body> </html> \ No newline at end of file diff --git a/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/form.phtml b/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/form.phtml index aaa771f271d..6746afe0600 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/form.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/form.phtml @@ -28,8 +28,6 @@ ?> <html> <head> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery.js') ?>"></script> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery-migrate.js') ?>"></script> </head> <body> <form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>"> @@ -38,12 +36,7 @@ <input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>"/> </form> <script type="text/javascript"> -require(['jquery'], function(jQuery){ - - // this is NOT tested. - jQuery('#token_form').submit(); - -}); + document.getElementById('token_form').submit(); </script> </body> </html> diff --git a/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/redirect.phtml b/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/redirect.phtml index a35d1c1ccd5..7bcfa8d862c 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/redirect.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/payflowadvanced/redirect.phtml @@ -33,8 +33,7 @@ </head> <body> <script type="text/javascript"> -require(['jquery'], function(jQuery){ -var $ = jQuery; + if (window.top == window.self) { window.location = "<?php echo $this->getUrl('checkout/cart') ?>"; @@ -65,7 +64,6 @@ var $ = jQuery; window.top.location = "<?php echo $this->getUrl('checkout/cart') ?>"; <?php endif; ?> -}); </script> </body> </html> diff --git a/app/code/Magento/Paypal/view/frontend/templates/payflowlink/form.phtml b/app/code/Magento/Paypal/view/frontend/templates/payflowlink/form.phtml index 40fedef5ad3..a10b664c7b4 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/payflowlink/form.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/payflowlink/form.phtml @@ -28,8 +28,6 @@ ?> <html> <head> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery.js') ?>"></script> - <script type="text/javascript" src="<?php echo $this->getViewFileUrl('jquery/jquery-migrate.js') ?>"></script> </head> <body> <form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>"> @@ -38,12 +36,7 @@ <input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>"/> </form> <script type="text/javascript"> -require(['jquery'], function(jQuery){ - - // this is NOT tested. - jQuery('#token_form').submit(); - -}); + document.getElementById('token_form').submit(); </script> </body> </html> diff --git a/app/code/Magento/Paypal/view/frontend/templates/payflowlink/redirect.phtml b/app/code/Magento/Paypal/view/frontend/templates/payflowlink/redirect.phtml index 830e80cd3f2..a0f1a27a6b6 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/payflowlink/redirect.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/payflowlink/redirect.phtml @@ -31,8 +31,7 @@ </head> <body> <script type="text/javascript"> -require(['jquery'], function(jQuery){ -var $ = jQuery; + if (window.top == window.self) { window.location = "<?php echo $this->getUrl('checkout/cart') ?>"; @@ -63,7 +62,6 @@ var $ = jQuery; window.top.location = "<?php echo $this->getUrl('checkout/cart') ?>"; <?php endif; ?> -}); </script> </body> </html> diff --git a/app/code/Magento/Persistent/Model/Observer/Session.php b/app/code/Magento/Persistent/Model/Observer/Session.php index c7b106106b1..6b6b7cea563 100644 --- a/app/code/Magento/Persistent/Model/Observer/Session.php +++ b/app/code/Magento/Persistent/Model/Observer/Session.php @@ -51,13 +51,6 @@ class Session */ protected $_sessionFactory; - /** - * Cookie model - * - * @var \Magento\Framework\Stdlib\Cookie - */ - protected $_cookie; - /** * Customer session * @@ -73,13 +66,12 @@ class Session protected $_checkoutSession; /** - * Construct + * Constructor * * @param \Magento\Persistent\Helper\Data $persistentData * @param \Magento\Persistent\Helper\Session $persistentSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Framework\Stdlib\Cookie $cookie * @param \Magento\Persistent\Model\SessionFactory $sessionFactory */ public function __construct( @@ -87,14 +79,12 @@ class Session \Magento\Persistent\Helper\Session $persistentSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, - \Magento\Framework\Stdlib\Cookie $cookie, \Magento\Persistent\Model\SessionFactory $sessionFactory ) { $this->_persistentData = $persistentData; $this->_persistentSession = $persistentSession; $this->_checkoutSession = $checkoutSession; $this->_customerSession = $customerSession; - $this->_cookie = $cookie; $this->_sessionFactory = $sessionFactory; } @@ -138,9 +128,7 @@ class Session // Set new cookie if ($sessionModel->getId()) { - $this->_cookie->set( - \Magento\Persistent\Model\Session::COOKIE_NAME, - $sessionModel->getKey(), + $sessionModel->setPersistentCookie( $persistentLifeTime, $this->_customerSession->getCookiePath() ); @@ -239,11 +227,11 @@ class Session $request = $observer->getEvent()->getRequest(); if ($this->_customerSession->isLoggedIn() || $request->getFullActionName() == 'customer_account_logout') { - $this->_cookie->renew( - \Magento\Persistent\Model\Session::COOKIE_NAME, - $this->_persistentData->getLifeTime(), - $this->_customerSession->getCookiePath() - ); + $this->_sessionFactory->create() + ->renewPersistentCookie( + $this->_persistentData->getLifeTime(), + $this->_customerSession->getCookiePath() + ); } } } diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index f15c485f457..c4dd6a31ae3 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -27,6 +27,7 @@ namespace Magento\Persistent\Model; * Persistent Session Model * * @method int getCustomerId() + * @method Session setCustomerId() */ class Session extends \Magento\Framework\Model\AbstractModel { @@ -88,11 +89,18 @@ class Session extends \Magento\Framework\Model\AbstractModel protected $_storeManager; /** - * Cookie model + * Cookie manager * - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $_cookie; + protected $_cookieManager; + + /** + * Cookie metadata factory + * + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $_cookieMetadataFactory; /** * @var \Magento\Framework\Math\Random @@ -105,14 +113,15 @@ class Session extends \Magento\Framework\Model\AbstractModel protected $sessionConfig; /** - * Construct + * Constructor * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Persistent\Helper\Data $persistentData - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig @@ -126,7 +135,8 @@ class Session extends \Magento\Framework\Model\AbstractModel \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, \Magento\Core\Helper\Data $coreData, \Magento\Persistent\Helper\Data $persistentData, - \Magento\Framework\Stdlib\Cookie $cookie, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, @@ -137,7 +147,8 @@ class Session extends \Magento\Framework\Model\AbstractModel $this->_coreData = $coreData; $this->_persistentData = $persistentData; $this->_coreConfig = $coreConfig; - $this->_cookie = $cookie; + $this->_cookieManager = $cookieManager; + $this->_cookieMetadataFactory = $cookieMetadataFactory; $this->_storeManager = $storeManager; $this->sessionConfig = $sessionConfig; $this->mathRandom = $mathRandom; @@ -243,7 +254,7 @@ class Session extends \Magento\Framework\Model\AbstractModel public function loadByCookieKey($key = null) { if (null === $key) { - $key = $this->_cookie->get(self::COOKIE_NAME); + $key = $this->_cookieManager->getCookie(self::COOKIE_NAME); } if ($key) { $this->load($key, 'key'); @@ -286,7 +297,55 @@ class Session extends \Magento\Framework\Model\AbstractModel */ public function removePersistentCookie() { - $this->_cookie->set(self::COOKIE_NAME, null, null, $this->sessionConfig->getCookiePath()); + $cookieMetadata = $this->_cookieMetadataFactory->createCookieMetadata() + ->setPath($this->sessionConfig->getCookiePath()); + $this->_cookieManager->deleteCookie(self::COOKIE_NAME, $cookieMetadata); + return $this; + } + + /** + * Set persistent cookie + * + * @param int $duration Time in seconds. + * @param string $path + * @return $this + */ + public function setPersistentCookie($duration, $path) + { + $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration($duration) + ->setPath($path); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $this->getKey(), + $publicCookieMetadata + ); + return $this; + } + + /** + * Postpone cookie expiration time if cookie value defined + * + * @param int $duration Time in seconds. + * @param string $path + * @return $this + */ + public function renewPersistentCookie($duration, $path) + { + if ($duration === null) { + return $this; + } + $value = $this->_cookieManager->getCookie(self::COOKIE_NAME); + if (null !== $value) { + $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration($duration) + ->setPath($path); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $value, + $publicCookieMetadata + ); + } return $this; } diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index ec1ad898b03..a9935773703 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 21b61ae09ab..ffd6c9def72 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index 7949775d23c..2b864043d07 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index b6e5b2575c3..efce6ded2f4 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-log": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-review": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-downloadable": "0.1.0-alpha92", - "magento/module-sales-rule": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-log": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-review": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-downloadable": "0.1.0-alpha93", + "magento/module-sales-rule": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/view/adminhtml/layout/reports_index_search_block.xml b/app/code/Magento/Reports/view/adminhtml/layout/reports_index_search_block.xml index 0efe089b005..ee855a368bb 100644 --- a/app/code/Magento/Reports/view/adminhtml/layout/reports_index_search_block.xml +++ b/app/code/Magento/Reports/view/adminhtml/layout/reports_index_search_block.xml @@ -49,7 +49,7 @@ <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.report.search.grid.columnSet"> <arguments> <argument name="rowUrl" xsi:type="array"> - <item name="path" xsi:type="string">adminhtml/catalog_search/edit</item> + <item name="path" xsi:type="string">catalog/search/edit</item> <item name="extraParamsTemplate" xsi:type="array"> <item name="id" xsi:type="string">getId</item> </item> diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index d058fc990d0..8c0a8013326 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/Model/Rating/Entity.php b/app/code/Magento/Review/Model/Rating/Entity.php index 5f57192fd08..33944275a05 100644 --- a/app/code/Magento/Review/Model/Rating/Entity.php +++ b/app/code/Magento/Review/Model/Rating/Entity.php @@ -32,6 +32,7 @@ namespace Magento\Review\Model\Rating; * @method \Magento\Review\Model\Rating\Entity setEntityCode(string $value) * * @author Magento Core Team <core@magentocommerce.com> + * @codeCoverageIgnore */ class Entity extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Review/Model/Rating/Option.php b/app/code/Magento/Review/Model/Rating/Option.php index f6c47ce7cc4..43ee4bd61f6 100644 --- a/app/code/Magento/Review/Model/Rating/Option.php +++ b/app/code/Magento/Review/Model/Rating/Option.php @@ -38,6 +38,7 @@ namespace Magento\Review\Model\Rating; * @method \Magento\Review\Model\Rating\Option setPosition(int $value) * * @author Magento Core Team <core@magentocommerce.com> + * @codeCoverageIgnore */ class Option extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Review/Model/Rating/Option/Vote.php b/app/code/Magento/Review/Model/Rating/Option/Vote.php index 8d50f6e3152..d9204841467 100644 --- a/app/code/Magento/Review/Model/Rating/Option/Vote.php +++ b/app/code/Magento/Review/Model/Rating/Option/Vote.php @@ -27,6 +27,7 @@ namespace Magento\Review\Model\Rating\Option; * Rating vote model * * @author Magento Core Team <core@magentocommerce.com> + * @codeCoverageIgnore */ class Vote extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Review/Model/Review/Status.php b/app/code/Magento/Review/Model/Review/Status.php index f9d10085ff9..74dc48cea5d 100644 --- a/app/code/Magento/Review/Model/Review/Status.php +++ b/app/code/Magento/Review/Model/Review/Status.php @@ -26,6 +26,7 @@ * Review status * * @author Magento Core Team <core@magentocommerce.com> + * @codeCoverageIgnore */ namespace Magento\Review\Model\Review; diff --git a/app/code/Magento/Review/Model/Review/Summary.php b/app/code/Magento/Review/Model/Review/Summary.php index 47231db812c..9167d24dd45 100644 --- a/app/code/Magento/Review/Model/Review/Summary.php +++ b/app/code/Magento/Review/Model/Review/Summary.php @@ -25,6 +25,8 @@ namespace Magento\Review\Model\Review; /** * Review summary + * + * @codeCoverageIgnore */ class Summary extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 1d71cde7563..0eddb6270e0 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-newsletter": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-newsletter": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/Model/Rss.php b/app/code/Magento/Rss/Model/Rss.php index 2d6c95a2872..ddeba3753ea 100644 --- a/app/code/Magento/Rss/Model/Rss.php +++ b/app/code/Magento/Rss/Model/Rss.php @@ -38,6 +38,7 @@ class Rss /** * @param array $data * @return $this + * @codeCoverageIgnore */ public function _addHeader($data = array()) { @@ -48,6 +49,7 @@ class Rss /** * @param array $entries * @return $this + * @codeCoverageIgnore */ public function _addEntries($entries) { @@ -58,6 +60,7 @@ class Rss /** * @param array $entry * @return $this + * @codeCoverageIgnore */ public function _addEntry($entry) { @@ -67,6 +70,7 @@ class Rss /** * @return array + * @codeCoverageIgnore */ public function getFeedArray() { diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 305d0577313..a63e637cc1c 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-sales-rule": "0.1.0-alpha92", - "magento/module-review": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-gift-message": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-sales-rule": "0.1.0-alpha93", + "magento/module-review": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-gift-message": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 6ba8eb24d11..8221d57bad5 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php b/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php index ec740624191..eac8657379e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Items/AbstractItems.php @@ -322,57 +322,6 @@ class AbstractItems extends \Magento\Backend\Block\Template return $res; } - /** - * Retrieve include tax html formatted content - * - * @param \Magento\Framework\Object $item - * @return string - */ - public function displayPriceInclTax(\Magento\Framework\Object $item) - { - $qty = $item->getQtyOrdered() ? $item->getQtyOrdered() : ($item->getQty() ? $item->getQty() : 1); - - $baseTax = $item->getTaxBeforeDiscount() - ? $item->getTaxBeforeDiscount() - : ($item->getTaxAmount() ? $item->getTaxAmount() : 0); - - $tax = $item->getBaseTaxBeforeDiscount() - ? $item->getBaseTaxBeforeDiscount() - : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0); - - $basePriceTax = 0; - $priceTax = 0; - - if (floatval($qty)) { - $basePriceTax = $item->getBasePrice() + $baseTax / $qty; - $priceTax = $item->getPrice() + $tax / $qty; - } - - return $this->displayPrices( - $this->getOrder()->getStore()->roundPrice($basePriceTax), - $this->getOrder()->getStore()->roundPrice($priceTax) - ); - } - - /** - * Retrieve subtotal price include tax html formated content - * - * @param \Magento\Framework\Object $item - * @return string - */ - public function displaySubtotalInclTax($item) - { - $baseTax = $item->getTaxBeforeDiscount() - ? $item->getTaxBeforeDiscount() - : ($item->getTaxAmount() ? $item->getTaxAmount() : 0); - - $tax = $item->getBaseTaxBeforeDiscount() - ? $item->getBaseTaxBeforeDiscount() - : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0); - - return $this->displayPrices($item->getBaseRowTotal() + $baseTax, $item->getRowTotal() + $tax); - } - /** * Retrieve tax calculation html content * diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php index 1a60e24dbd4..bddeee82ee0 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php @@ -24,13 +24,16 @@ namespace Magento\Sales\Block\Adminhtml\Items\Column; use Magento\Sales\Model\Order\Item; +use Magento\Sales\Model\Quote\Item\AbstractItem as QuoteItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem; /** * Adminhtml sales order column renderer * * @author Magento Core Team <core@magentocommerce.com> */ -class DefaultColumn extends \Magento\Backend\Block\Template +class DefaultColumn extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems { /** * Option factory @@ -41,29 +44,34 @@ class DefaultColumn extends \Magento\Backend\Block\Template /** * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService + * @param \Magento\Framework\Registry $registry * @param \Magento\Catalog\Model\Product\OptionFactory $optionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, + \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, + \Magento\Framework\Registry $registry, \Magento\Catalog\Model\Product\OptionFactory $optionFactory, array $data = array() ) { $this->_optionFactory = $optionFactory; - parent::__construct($context, $data); + parent::__construct($context, $stockItemService, $registry, $data); } /** * Get item * - * @return Item + * @return Item|QuoteItem */ public function getItem() { - if ($this->_getData('item') instanceof Item) { - return $this->_getData('item'); + $item = $this->_getData('item'); + if ($item instanceof Item || $item instanceof QuoteItem) { + return $item; } else { - return $this->_getData('item')->getOrderItem(); + return $item->getOrderItem(); } } @@ -119,4 +127,31 @@ class DefaultColumn extends \Magento\Backend\Block\Template { return $this->getItem()->getSku(); } + + + /** + * Calculate total amount for the item + * + * @param QuoteItem|Item|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + $totalAmount = $item->getRowTotal() - $item->getDiscountAmount(); + + return $totalAmount; + } + + /** + * Calculate base total amount for the item + * + * @param QuoteItem|Item|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getBaseTotalAmount($item) + { + $baseTotalAmount = $item->getBaseRowTotal() - $item->getBaseDiscountAmount(); + + return $baseTotalAmount; + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php index 10431e2c48b..2e206390994 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php @@ -576,4 +576,43 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { return $this->_wishlistFactory->create()->getCollection()->filterByCustomerId($this->getCustomerId()); } + + /** + * Get the item unit price html + * + * @param Item $item + * @return string + */ + public function getItemUnitPriceHtml(Item $item) + { + $block = $this->getLayout()->getBlock('item_unit_price'); + $block->setItem($item); + return $block->toHtml(); + } + + /** + * Get the item row total html + * + * @param Item $item + * @return string + */ + public function getItemRowTotalHtml(Item $item) + { + $block = $this->getLayout()->getBlock('item_row_total'); + $block->setItem($item); + return $block->toHtml(); + } + + /** + * Return html for row total with discount + * + * @param Item $item + * @return string + */ + public function getItemRowTotalWithDiscountHtml(Item $item) + { + $block = $this->getLayout()->getBlock('item_row_total_with_discount'); + $block->setItem($item); + return $block->toHtml(); + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items/Renderer/DefaultRenderer.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items/Renderer/DefaultRenderer.php index a8fa90a493a..0301d957ab0 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items/Renderer/DefaultRenderer.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Items/Renderer/DefaultRenderer.php @@ -28,7 +28,7 @@ use Magento\Sales\Model\Order\Item; /** * Adminhtml sales order item renderer */ -class DefaultRenderer extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems +class DefaultRenderer extends \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer { /** * Message helper diff --git a/app/code/Magento/Sales/Block/Order/Email/Items/DefaultItems.php b/app/code/Magento/Sales/Block/Order/Email/Items/DefaultItems.php index f7ac98fdd1c..a29a690496a 100644 --- a/app/code/Magento/Sales/Block/Order/Email/Items/DefaultItems.php +++ b/app/code/Magento/Sales/Block/Order/Email/Items/DefaultItems.php @@ -23,6 +23,10 @@ */ namespace Magento\Sales\Block\Order\Email\Items; +use Magento\Sales\Model\Order\Item as OrderItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem; + /** * Sales Order Email items default renderer * @@ -103,4 +107,17 @@ class DefaultItems extends \Magento\Framework\View\Element\Template { return $this->getLayout()->getBlock('additional.product.info'); } + + /** + * Get the html for item price + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item + * @return string + */ + public function getItemPrice($item) + { + $block = $this->getLayout()->getBlock('item_price'); + $block->setItem($item); + return $block->toHtml(); + } } diff --git a/app/code/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrder.php b/app/code/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrder.php index 461203e44ed..9747894391a 100644 --- a/app/code/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrder.php +++ b/app/code/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrder.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Block\Order\Email\Items\Order; +use Magento\Sales\Model\Order\Item as OrderItem; + /** * Sales Order Email items default renderer * @@ -103,4 +105,17 @@ class DefaultOrder extends \Magento\Framework\View\Element\Template { return $this->getLayout()->getBlock('additional.product.info'); } + + /** + * Get the html for item price + * + * @param OrderItem $item + * @return string + */ + public function getItemPrice(OrderItem $item) + { + $block = $this->getLayout()->getBlock('item_price'); + $block->setItem($item); + return $block->toHtml(); + } } diff --git a/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php b/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php index d750593534c..308b7d15744 100644 --- a/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php +++ b/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php @@ -23,6 +23,10 @@ */ namespace Magento\Sales\Block\Order\Item\Renderer; +use Magento\Sales\Model\Order\Item as OrderItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\CreditMemo\Item as CreditMemoItem; + /** * Order item render block */ @@ -220,4 +224,69 @@ class DefaultRenderer extends \Magento\Framework\View\Element\Template { return $this->escapeHtml($this->string->splitInjection($sku)); } + + /** + * Return item unit price html + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item child item in case of bundle product + * @return string + */ + public function getItemPriceHtml($item = null) + { + $block = $this->getLayout()->getBlock('item_unit_price'); + if (!$item) { + $item = $this->getItem(); + } + $block->setItem($item); + return $block->toHtml(); + } + + /** + * Return item row total html + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item child item in case of bundle product + * @return string + */ + public function getItemRowTotalHtml($item = null) + { + $block = $this->getLayout()->getBlock('item_row_total'); + if (!$item) { + $item = $this->getItem(); + } + $block->setItem($item); + return $block->toHtml(); + } + + /** + * Return the total amount minus discount + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + $totalAmount = $item->getRowTotal() + + $item->getTaxAmount() + + $item->getHiddenTaxAmount() + + $item->getWeeeTaxAppliedRowAmount() + - $item->getDiscountAmount(); + + return $totalAmount; + } + + /** + * Return HTML for item total after discount + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item child item in case of bundle product + * @return string + */ + public function getItemRowTotalAfterDiscountHtml($item = null) + { + $block = $this->getLayout()->getBlock('item_row_total_after_discount'); + if (!$item) { + $item = $this->getItem(); + } + $block->setItem($item); + return $block->toHtml(); + } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php index 9de7ad34c38..3d7ee57a947 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php @@ -24,8 +24,11 @@ */ namespace Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo; -use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; - +/** + * Class Email + * + * @package Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo + */ class Email extends \Magento\Backend\App\Action { /** @@ -44,28 +47,17 @@ class Email extends \Magento\Backend\App\Action public function execute() { $creditmemoId = $this->getRequest()->getParam('creditmemo_id'); - if ($creditmemoId) { - $creditmemo = $this->_objectManager->create('Magento\Sales\Model\Order\Creditmemo')->load($creditmemoId); - if ($creditmemo) { - /** @var CreditmemoSender $creditmemoSender */ - $creditmemoSender = $this->_objectManager - ->create('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender'); - $creditmemoSender->send($creditmemo); - - $historyItem = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Status\History\Collection' - )->getUnnotifiedForInstance( - $creditmemo, - \Magento\Sales\Model\Order\Creditmemo::HISTORY_ENTITY_NAME - ); - if ($historyItem) { - $historyItem->setIsCustomerNotified(1); - $historyItem->save(); - } - - $this->messageManager->addSuccess(__('We sent the message.')); - $this->_redirect('sales/order_creditmemo/view', array('creditmemo_id' => $creditmemoId)); - } + if (!$creditmemoId) { + return; } + $creditmemo = $this->_objectManager->create('Magento\Sales\Model\Order\Creditmemo')->load($creditmemoId); + if (!$creditmemo) { + return; + } + $this->_objectManager->create('Magento\Sales\Model\Order\CreditmemoNotifier') + ->notify($creditmemo); + + $this->messageManager->addSuccess(__('We sent the message.')); + $this->_redirect('sales/order_creditmemo/view', ['creditmemo_id' => $creditmemoId]); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php index 207cbeefdb1..1eb233b34c0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php @@ -24,12 +24,17 @@ */ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; -use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; - +/** + * Class Email + * + * @package Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice + */ abstract class Email extends \Magento\Backend\App\Action { /** - * {@inheritdoc} + * Check if email sending is allowed for the current user + * + * @return bool */ protected function _isAllowed() { @@ -52,20 +57,9 @@ abstract class Email extends \Magento\Backend\App\Action return; } - /** @var InvoiceSender $invoiceSender */ - $invoiceSender = $this->_objectManager->create('Magento\Sales\Model\Order\Email\Sender\InvoiceSender'); - $invoiceSender->send($invoice); + $this->_objectManager->create('Magento\Sales\Model\InvoiceNotifier') + ->notify($invoice); - $historyItem = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Status\History\Collection' - )->getUnnotifiedForInstance( - $invoice, - \Magento\Sales\Model\Order\Invoice::HISTORY_ENTITY_NAME - ); - if ($historyItem) { - $historyItem->setIsCustomerNotified(1); - $historyItem->save(); - } $this->messageManager->addSuccess(__('We sent the message.')); $this->_redirect( 'sales/invoice/view', diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php index 02c9c6ea161..d380e480664 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php @@ -76,7 +76,11 @@ class AddComment extends \Magento\Backend\App\Action throw new \Magento\Framework\Model\Exception(__('The Comment Text field cannot be empty.')); } $this->_title->add(__('Credit Memos')); - $creditmemo = $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); $comment = $creditmemo->addComment( $data['comment'], isset($data['is_customer_notified']), diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php index e81ca9f0e18..21fd38224ff 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Cancel.php @@ -60,17 +60,18 @@ class Cancel extends \Magento\Backend\App\Action */ public function execute() { - $creditmemo = $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { try { $creditmemo->cancel(); - $transactionSave = $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' - )->addObject( - $creditmemo - )->addObject( - $creditmemo->getOrder() - ); + $transactionSave = $this->_objectManager->create('Magento\Framework\DB\Transaction'); + $transactionSave->addObject($creditmemo); + $transactionSave->addObject($creditmemo->getOrder()); + if ($creditmemo->getInvoice()) { $transactionSave->addObject($creditmemo->getInvoice()); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php index 4bb35add576..f29c26a1aa0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php @@ -61,7 +61,12 @@ class NewAction extends \Magento\Backend\App\Action public function execute() { $this->_title->add(__('Credit Memos')); - if ($creditmemo = $this->creditmemoLoader->load($this->_request)) { + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); + if ($creditmemo) { if ($creditmemo->getInvoice()) { $this->_title->add(__("New Memo for #%1", $creditmemo->getInvoice()->getIncrementId())); } else { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintAction.php index 519ae1c3179..a4aacacb859 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintAction.php @@ -56,7 +56,11 @@ class PrintAction extends \Magento\Sales\Controller\Adminhtml\Creditmemo\Abstrac public function execute() { $this->_title->add(__('Credit Memos')); - $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $this->creditmemoLoader->load(); parent::execute(); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php index 11021c94b9f..0492b84993d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php @@ -76,9 +76,13 @@ class Save extends \Magento\Backend\App\Action $this->_getSession()->setCommentText($data['comment_text']); } try { - $creditmemo = $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { - if ($creditmemo->getGrandTotal() <= 0 && !$creditmemo->getAllowZeroGrandTotal()) { + if (!$creditmemo->isValidGrandTotal()) { throw new \Magento\Framework\Model\Exception(__('Credit memo\'s total must be positive.')); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php index 204301727b9..3724ec6ccc7 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php @@ -61,7 +61,11 @@ class UpdateQty extends \Magento\Backend\App\Action public function execute() { try { - $creditmemo = $this->creditmemoLoader->load($this->_request, true); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $this->creditmemoLoader->load(); $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('order_items')->toHtml(); } catch (\Magento\Framework\Model\Exception $e) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php index 5ee636fb6b3..252ed679849 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php @@ -60,7 +60,11 @@ class View extends \Magento\Backend\App\Action */ public function execute() { - $creditmemo = $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { if ($creditmemo->getInvoice()) { $this->_title->add(__("View Memo for #%1", $creditmemo->getInvoice()->getIncrementId())); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php index 4865b62e506..12954cb6d65 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Void.php @@ -60,17 +60,18 @@ class Void extends \Magento\Backend\App\Action */ public function execute() { - $creditmemo = $this->creditmemoLoader->load($this->_request); + $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id')); + $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo')); + $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id')); + $creditmemo = $this->creditmemoLoader->load(); if ($creditmemo) { try { $creditmemo->void(); - $transactionSave = $this->_objectManager->create( - 'Magento\Framework\DB\Transaction' - )->addObject( - $creditmemo - )->addObject( - $creditmemo->getOrder() - ); + $transactionSave = $this->_objectManager->create('Magento\Framework\DB\Transaction'); + $transactionSave->addObject($creditmemo); + $transactionSave->addObject($creditmemo->getOrder()); + if ($creditmemo->getInvoice()) { $transactionSave->addObject($creditmemo->getInvoice()); } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php index cef61ceaedc..c7a91190377 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php @@ -24,9 +24,22 @@ */ namespace Magento\Sales\Controller\Adminhtml\Order; -use Magento\Framework\App\RequestInterface; +use Magento\Framework\Object; -class CreditmemoLoader +/** + * Class CreditmemoLoader + * + * @package Magento\Sales\Controller\Adminhtml\Order + * @method CreditmemoLoader setCreditmemoId + * @method CreditmemoLoader setCreditmemo + * @method CreditmemoLoader setInvoiceId + * @method CreditmemoLoader setOrderId + * @method int getCreditmemoId + * @method string getCreditmemo + * @method int getInvoiceId + * @method int getOrderId + */ +class CreditmemoLoader extends Object { /** * @var \Magento\Sales\Model\Order\CreditmemoFactory @@ -83,6 +96,7 @@ class CreditmemoLoader * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Framework\Registry $registry * @param \Magento\CatalogInventory\Helper\Data $inventoryHelper + * @param array $data */ public function __construct( \Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory, @@ -93,7 +107,8 @@ class CreditmemoLoader \Magento\Backend\Model\Session $backendSession, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Registry $registry, - \Magento\CatalogInventory\Helper\Data $inventoryHelper + \Magento\CatalogInventory\Helper\Data $inventoryHelper, + array $data = [] ) { $this->creditmemoFactory = $creditmemoFactory; $this->orderFactory = $orderFactory; @@ -104,17 +119,17 @@ class CreditmemoLoader $this->messageManager = $messageManager; $this->registry = $registry; $this->inventoryHelper = $inventoryHelper; + parent::__construct($data); } /** * Get requested items qtys and return to stock flags * - * @param RequestInterface $request * @return array */ - protected function _getItemData(RequestInterface $request) + protected function _getItemData() { - $data = $request->getParam('creditmemo'); + $data = $this->getCreditmemo(); if (!$data) { $data = $this->backendSession->getFormData(true); } @@ -153,13 +168,12 @@ class CreditmemoLoader } /** - * @param RequestInterface $request * @param \Magento\Sales\Model\Order $order * @return $this|bool */ - protected function _initInvoice(RequestInterface $request, $order) + protected function _initInvoice($order) { - $invoiceId = $request->getParam('invoice_id'); + $invoiceId = $this->getInvoiceId(); if ($invoiceId) { $invoice = $this->invoiceFactory->create()->load( $invoiceId @@ -176,27 +190,25 @@ class CreditmemoLoader /** * Initialize creditmemo model instance * - * @param RequestInterface $request - * @param bool $update * @return \Magento\Sales\Model\Order\Creditmemo|false */ - public function load(RequestInterface $request, $update = false) + public function load() { $creditmemo = false; - $creditmemoId = $request->getParam('creditmemo_id'); - $orderId = $request->getParam('order_id'); + $creditmemoId = $this->getCreditmemoId(); + $orderId = $this->getOrderId(); if ($creditmemoId) { $creditmemo = $this->creditmemoFactory->create()->load($creditmemoId); } elseif ($orderId) { - $data = $request->getParam('creditmemo'); + $data = $this->getCreditmemo(); $order = $this->orderFactory->create()->load($orderId); - $invoice = $this->_initInvoice($request, $order); + $invoice = $this->_initInvoice($order); if (!$this->_canCreditmemo($order)) { return false; } - $savedData = $this->_getItemData($request); + $savedData = $this->_getItemData(); $qtys = array(); $backToStock = array(); @@ -239,7 +251,7 @@ class CreditmemoLoader $this->eventManager->dispatch( 'adminhtml_sales_order_creditmemo_register_before', - array('creditmemo' => $creditmemo, 'request' => $request) + array('creditmemo' => $creditmemo, 'input' => $this->getCreditmemo()) ); $this->registry->register('current_creditmemo', $creditmemo); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php index b5492f4f114..44052695522 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -26,6 +25,11 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use \Magento\Backend\App\Action; +/** + * Class Email + * + * @package Magento\Sales\Controller\Adminhtml\Order + */ class Email extends \Magento\Sales\Controller\Adminhtml\Order { /** @@ -38,22 +42,8 @@ class Email extends \Magento\Sales\Controller\Adminhtml\Order $order = $this->_initOrder(); if ($order) { try { - /** @var \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender */ - $orderSender = $this->_objectManager->create( - 'Magento\Sales\Model\Order\Email\Sender\OrderSender' - ); - $orderSender->send($order); - - $historyItem = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Status\History\Collection' - )->getUnnotifiedForInstance( - $order, - \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME - ); - if ($historyItem) { - $historyItem->setIsCustomerNotified(1); - $historyItem->save(); - } + $this->_objectManager->create('Magento\Sales\Model\OrderNotifier') + ->notify($order); $this->messageManager->addSuccess(__('You sent the order email.')); } catch (\Magento\Framework\Model\Exception $e) { $this->messageManager->addError($e->getMessage()); @@ -61,7 +51,7 @@ class Email extends \Magento\Sales\Controller\Adminhtml\Order $this->messageManager->addError(__('We couldn\'t send the email order.')); $this->_objectManager->get('Magento\Framework\Logger')->logException($e); } + $this->_redirect('sales/order/view', array('order_id' => $order->getId())); } - $this->_redirect('sales/order/view', array('order_id' => $order->getId())); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php index 1f715e8a264..957bea3765d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php @@ -78,8 +78,12 @@ class AddComment extends \Magento\Backend\App\Action throw new Exception(__('The Comment Text field cannot be empty.')); } $this->_title->add(__('Invoices')); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; /** @var Invoice $invoice */ - $invoice = $this->invoiceLoader->load($this->_request); + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); $invoice->addComment( $data['comment'], isset($data['is_customer_notified']), diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php index 5e165a80a6d..d1962c1953b 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Cancel.php @@ -61,7 +61,11 @@ class Cancel extends \Magento\Backend\App\Action */ public function execute() { - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { try { $invoice->cancel(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php index 55b222ed897..35c19ec7457 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Capture.php @@ -61,7 +61,11 @@ class Capture extends \Magento\Backend\App\Action */ public function execute() { - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { try { $invoice->capture(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php index 32aebbaae6e..d869868dc50 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php @@ -61,7 +61,11 @@ class NewAction extends \Magento\Backend\App\Action public function execute() { $this->_title->add(__('Invoices')); - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { $this->_title->add(__('New Invoice')); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintAction.php index e1648c406af..6bf4d9aa4f5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintAction.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintAction.php @@ -55,7 +55,11 @@ class PrintAction extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractIn */ public function execute() { - $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); parent::execute(); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php index ac057bc6bea..84b30cdef76 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php @@ -123,8 +123,11 @@ class Save extends \Magento\Backend\App\Action } try { + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; /** @var Invoice $invoice */ - $invoice = $this->invoiceLoader->load($this->_request); + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { if (!empty($data['capture_case'])) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php index 00a2a80336c..82918229cd5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php @@ -63,10 +63,13 @@ class UpdateQty extends \Magento\Backend\App\Action { try { $this->_title->add(__('Invoices')); - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceItems = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceItems); // Save invoice comment text in current invoice object in order to display it in corresponding view - $invoiceRawData = $this->getRequest()->getParam('invoice'); - $invoiceRawCommentText = $invoiceRawData['comment_text']; + $invoiceRawCommentText = $invoiceData['comment_text']; $invoice->setCommentText($invoiceRawCommentText); $this->_view->loadLayout(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php index 866560925d7..e406cbb5db8 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php @@ -53,7 +53,11 @@ class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\V public function execute() { $this->_title->add(__('Invoices')); - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { $this->_title->add(sprintf("#%s", $invoice->getIncrementId())); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php index 6b1e153ea88..ec85acf1191 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Void.php @@ -61,7 +61,11 @@ class Void extends \Magento\Backend\App\Action */ public function execute() { - $invoice = $this->invoiceLoader->load($this->_request); + $orderId = $this->getRequest()->getParam('order_id'); + $invoiceId = $this->getRequest()->getParam('invoice_id'); + $invoiceData = $this->getRequest()->getParam('invoice', []); + $invoiceData = isset($invoiceData['items']) ? $invoiceData['items'] : []; + $invoice = $this->invoiceLoader->load($orderId, $invoiceId, $invoiceData); if ($invoice) { try { $invoice->void(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoader.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoader.php index c9e0f00dce5..c6f60699b0a 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoader.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoader.php @@ -43,6 +43,21 @@ class InvoiceLoader */ protected $registry; + /** + * @var int + */ + protected $orderId; + + /** + * @var int + */ + protected $invoiceId; + + /** + * @var array + */ + protected $invoiceItems; + /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Registry $registry @@ -59,17 +74,67 @@ class InvoiceLoader } /** - * Load invoice + * Set corresponding order Id + * + * @param int $orderId + * @return $this + */ + public function setOrderId($orderId) + { + $this->orderId = $orderId; + return $this; + } + + /** + * Set corresponding invoice Id + * + * @param int $invoiceId + * @return $this + */ + public function setInvoiceId($invoiceId) + { + $this->invoiceId = $invoiceId; + return $this; + } + + /** + * Linear array of order items for invoice: + * [ + * orderItemId => qtyInvoicedItems + * ] + * + * @param array $invoiceItems + * @return $this + */ + public function setInvoiceItems($invoiceItems) + { + $this->invoiceItems = $invoiceItems; + return $this; + } + + /** + * Create invoice * - * @param RequestInterface $request - * @return bool + * @return bool|\Magento\Sales\Model\Order\Invoice * @throws \Exception */ - public function load(RequestInterface $request) + public function create() + { + return $this->load($this->orderId, $this->invoiceId, $this->invoiceItems); + } + + /** + * Load invoice + * @deprecated + * @param int $orderId + * @param null|int $invoiceId + * @param array $invoiceItems + * @return \Magento\Sales\Model\Order\Invoice | bool + * @throws \Exception + */ + public function load($orderId, $invoiceId = null, array $invoiceItems = []) { $invoice = false; - $invoiceId = $request->getParam('invoice_id'); - $orderId = $request->getParam('order_id'); if ($invoiceId) { $invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId); if (!$invoice->getId()) { @@ -92,17 +157,12 @@ class InvoiceLoader $this->messageManager->addError(__('The order does not allow an invoice to be created.')); return false; } - $savedQtys = array(); - $data = $request->getParam('invoice'); - if (isset($data['items'])) { - $savedQtys = $data['items']; - } $invoice = $this->_objectManager->create( 'Magento\Sales\Model\Service\Order', array('order' => $order) )->prepareInvoice( - $savedQtys + $invoiceItems ); if (!$invoice->getTotalQty()) { throw new \Exception(__('Cannot create an invoice without products.')); diff --git a/app/code/Magento/Sales/Helper/Guest.php b/app/code/Magento/Sales/Helper/Guest.php index cc06a929fd0..36d410d9466 100644 --- a/app/code/Magento/Sales/Helper/Guest.php +++ b/app/code/Magento/Sales/Helper/Guest.php @@ -36,18 +36,23 @@ class Guest extends \Magento\Core\Helper\Data * * @var \Magento\Framework\Registry */ - protected $_coreRegistry; + protected $coreRegistry; /** * @var \Magento\Customer\Model\Session */ - protected $_customerSession; - + protected $customerSession; + /** - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $_coreCookie; + protected $cookieManager; + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactory; + /** * @var \Magento\Framework\Message\ManagerInterface */ @@ -56,7 +61,7 @@ class Guest extends \Magento\Core\Helper\Data /** * @var \Magento\Sales\Model\OrderFactory */ - protected $_orderFactory; + protected $orderFactory; /** * Cookie key for guest view @@ -81,11 +86,14 @@ class Guest extends \Magento\Core\Helper\Data * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Framework\Stdlib\Cookie $coreCookie + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\App\ViewInterface $view * @param bool $dbCompatibleMode + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( App\Helper\Context $context, @@ -95,17 +103,19 @@ class Guest extends \Magento\Core\Helper\Data \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Registry $coreRegistry, \Magento\Customer\Model\Session $customerSession, - \Magento\Framework\Stdlib\Cookie $coreCookie, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\App\ViewInterface $view, $dbCompatibleMode = true ) { - $this->_coreRegistry = $coreRegistry; - $this->_customerSession = $customerSession; - $this->_coreCookie = $coreCookie; + $this->coreRegistry = $coreRegistry; + $this->customerSession = $customerSession; + $this->cookieManager = $cookieManager; + $this->cookieMetadataFactory = $cookieMetadataFactory; $this->messageManager = $messageManager; - $this->_orderFactory = $orderFactory; + $this->orderFactory = $orderFactory; $this->_view = $view; parent::__construct( $context, @@ -123,10 +133,13 @@ class Guest extends \Magento\Core\Helper\Data * @param App\RequestInterface $request * @param App\ResponseInterface $response * @return bool + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function loadValidOrder(App\RequestInterface $request, App\ResponseInterface $response) { - if ($this->_customerSession->isLoggedIn()) { + if ($this->customerSession->isLoggedIn()) { $response->setRedirect($this->_urlBuilder->getUrl('sales/order/history')); return false; } @@ -135,9 +148,10 @@ class Guest extends \Magento\Core\Helper\Data $errors = false; /** @var $order \Magento\Sales\Model\Order */ - $order = $this->_orderFactory->create(); + $order = $this->orderFactory->create(); - if (empty($post) && !$this->_coreCookie->get(self::COOKIE_NAME)) { + $fromCookie = $this->cookieManager->getCookie(self::COOKIE_NAME); + if (empty($post) && !$fromCookie) { $response->setRedirect($this->_urlBuilder->getUrl('sales/guest/form')); return false; } elseif (!empty($post) && isset($post['oar_order_id']) && isset($post['oar_type'])) { @@ -172,10 +186,12 @@ class Guest extends \Magento\Core\Helper\Data if (!$errors) { $toCookie = base64_encode($order->getProtectCode() . ':' . $incrementId); - $this->_coreCookie->set(self::COOKIE_NAME, $toCookie, self::COOKIE_LIFETIME, self::COOKIE_PATH); + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); + $metadata->setPath(self::COOKIE_PATH); + $metadata->setDuration(self::COOKIE_LIFETIME); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $toCookie, $metadata); } - } elseif ($this->_coreCookie->get(self::COOKIE_NAME)) { - $fromCookie = $this->_coreCookie->get(self::COOKIE_NAME); + } elseif ($fromCookie) { $cookieData = explode(':', base64_decode($fromCookie)); $protectCode = isset($cookieData[0]) ? $cookieData[0] : null; $incrementId = isset($cookieData[1]) ? $cookieData[1] : null; @@ -184,14 +200,18 @@ class Guest extends \Magento\Core\Helper\Data if (!empty($protectCode) && !empty($incrementId)) { $order->loadByIncrementId($incrementId); if ($order->getProtectCode() == $protectCode) { - $this->_coreCookie->renew(self::COOKIE_NAME, self::COOKIE_LIFETIME, self::COOKIE_PATH); + // renew cookie + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); + $metadata->setPath(self::COOKIE_PATH); + $metadata->setDuration(self::COOKIE_LIFETIME); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $fromCookie, $metadata); $errors = false; } } } if (!$errors && $order->getId()) { - $this->_coreRegistry->register('current_order', $order); + $this->coreRegistry->register('current_order', $order); return true; } diff --git a/app/code/Magento/Sales/Model/Notifier.php b/app/code/Magento/Sales/Model/AbstractNotifier.php similarity index 78% rename from app/code/Magento/Sales/Model/Notifier.php rename to app/code/Magento/Sales/Model/AbstractNotifier.php index bbe3ebfa38a..4e2e164d64a 100644 --- a/app/code/Magento/Sales/Model/Notifier.php +++ b/app/code/Magento/Sales/Model/AbstractNotifier.php @@ -25,7 +25,7 @@ namespace Magento\Sales\Model; use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; -use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Sales\Model\Order\Email\Sender; use Magento\Framework\Logger; use Magento\Framework\Mail\Exception; @@ -33,7 +33,7 @@ use Magento\Framework\Mail\Exception; * Class Notifier * @package Magento\Sales\Model */ -class Notifier extends \Magento\Framework\Model\AbstractModel +abstract class AbstractNotifier extends \Magento\Framework\Model\AbstractModel { /** * @var CollectionFactory @@ -46,43 +46,41 @@ class Notifier extends \Magento\Framework\Model\AbstractModel protected $logger; /** - * @var OrderSender + * @var Sender */ - protected $orderSender; + protected $sender; /** * @param CollectionFactory $historyCollectionFactory * @param Logger $logger - * @param OrderSender $orderSender + * @param Sender $sender */ public function __construct( CollectionFactory $historyCollectionFactory, Logger $logger, - OrderSender $orderSender + Sender $sender ) { $this->historyCollectionFactory = $historyCollectionFactory; $this->logger = $logger; - $this->orderSender = $orderSender; + $this->sender = $sender; } /** * Notify user * - * @param Order $order + * @param AbstractModel $model * @return bool * @throws \Magento\Framework\Mail\Exception */ - public function notify(\Magento\Sales\Model\Order $order) + public function notify(\Magento\Sales\Model\AbstractModel $model) { try { - $this->orderSender->send($order); - if (!$order->getEmailSent()) { + $this->sender->send($model); + if (!$model->getEmailSent()) { return false; } - $historyItem = $this->historyCollectionFactory->create()->getUnnotifiedForInstance( - $order, - \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME - ); + $historyItem = $this->historyCollectionFactory->create() + ->getUnnotifiedForInstance($model); if ($historyItem) { $historyItem->setIsCustomerNotified(1); $historyItem->save(); diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 83f670f3236..a275ec26e8b 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -367,13 +367,6 @@ class Order extends \Magento\Sales\Model\AbstractModel const REPORT_DATE_TYPE_UPDATED = 'updated'; - /* - * Identifier for history item - * - * @var string - */ - const HISTORY_ENTITY_NAME = 'order'; - /** * @var string */ @@ -458,7 +451,7 @@ class Order extends \Magento\Sales\Model\AbstractModel * * @var string */ - protected $_historyEntityName = self::HISTORY_ENTITY_NAME; + protected $entityType = 'order'; /** * @var \Magento\Store\Model\StoreManagerInterface @@ -1290,7 +1283,7 @@ class Order extends \Magento\Sales\Model\AbstractModel )->setComment( $comment )->setEntityName( - $this->_historyEntityName + $this->entityType ); $this->addStatusHistory($history); return $history; @@ -1304,10 +1297,20 @@ class Order extends \Magento\Sales\Model\AbstractModel */ public function setHistoryEntityName($entityName) { - $this->_historyEntityName = $entityName; + $this->entityType = $entityName; return $this; } + /** + * Return order entity type + * + * @return string + */ + public function getEntityType() + { + return $this->entityType; + } + /** * Place order * diff --git a/app/code/Magento/Sales/Model/Order/Builder.php b/app/code/Magento/Sales/Model/Order/Builder.php new file mode 100644 index 00000000000..e77fd10b1fc --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Builder.php @@ -0,0 +1,407 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Order\Payment; +use Magento\Sales\Model\Order\Customer; +use Magento\Sales\Model\Order\Address; +use Magento\Sales\Model\OrderFactory; +use Magento\Sales\Model\Quote; +use Magento\Catalog\Model\Product; + +class Builder +{ + /** + * @var Address + */ + protected $billingAddress; + + /** + * @var Address + */ + protected $shippingAddress; + + /** + * @var Item[] + */ + protected $items; + + /** + * @var Payment[] + */ + protected $payments; + + /** + * @var int + */ + protected $quoteId; + + /** + * @var array + */ + protected $appliedRuleIds; + + /** + * @var int + */ + protected $isVirtual; + + /** + * @var string + */ + protected $remoteIp; + + /** + * @var string + */ + protected $baseSubtotal; + + /** + * @var string + */ + protected $subtotal; + + /** + * @var string + */ + protected $baseGrandTotal; + + /** + * @var string + */ + protected $grandTotal; + + /** + * @var string + */ + protected $baseCurrencyCode; + + /** + * @var string + */ + protected $globalCurrencyCode; + + /** + * @var string + */ + protected $storeCurrencyCode; + + /** + * @var int + */ + protected $storeId; + + /** + * @var string + */ + protected $storeToBaseRate; + + /** + * @var string + */ + protected $baseToGlobalRate; + + /** + * @var string + */ + protected $couponCode; + + /** + * @var \Magento\Sales\Model\Order\Customer + */ + protected $customer; + + /** + * @var OrderFactory + */ + protected $orderFactory; + + /** + * @param OrderFactory $orderFactory + */ + public function __construct(OrderFactory $orderFactory) + { + $this->orderFactory = $orderFactory; + } + + /** + * @param Customer $customer + * @return $this + */ + public function setCustomer(Customer $customer) + { + $this->customer = $customer; + return $this; + } + + /** + * @param Address $address + * @return $this + */ + public function setShippingAddress(Address $address) + { + $this->shippingAddress = $address; + return $this; + } + + /** + * @param Address $address + * @return $this + */ + public function setBillingAddress(Address $address) + { + $this->billingAddress = $address; + return $this; + } + + /** + * @param int $quoteId + * @return $this + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + return $this; + } + + /** + * @param array $appliedRuleIds + * @return $this + */ + public function setAppliedRuleIds($appliedRuleIds) + { + $this->appliedRuleIds = $appliedRuleIds; + return $this; + } + + /** + * @param int $isVirtual + * @return $this + */ + public function setIsVirtual($isVirtual) + { + $this->isVirtual = $isVirtual; + return $this; + } + + /** + * @param string $remoteIp + * @return $this + */ + public function setRemoteIp($remoteIp) + { + $this->remoteIp = $remoteIp; + return $this; + } + + /** + * @param string $baseSubtotal + * @return $this + */ + public function setBaseSubtotal($baseSubtotal) + { + $this->baseSubtotal = $baseSubtotal; + return $this; + } + + /** + * @param string $subtotal + * @return $this + */ + public function setSubtotal($subtotal) + { + $this->subtotal = $subtotal; + return $this; + } + + /** + * @param string $baseGrandTotal + * @return $this + */ + public function setBaseGrandTotal($baseGrandTotal) + { + $this->baseGrandTotal = $baseGrandTotal; + return $this; + } + + /** + * @param string $grandTotal + * @return $this + */ + public function setGrandTotal($grandTotal) + { + $this->grandTotal = $grandTotal; + return $this; + } + + /** + * @param string $baseCurrencyCode + * @return $this + */ + public function setBaseCurrencyCode($baseCurrencyCode) + { + $this->baseCurrencyCode = $baseCurrencyCode; + return $this; + } + + /** + * @param string $globalCurrencyCode + * @return $this + */ + public function setGlobalCurrencyCode($globalCurrencyCode) + { + $this->globalCurrencyCode = $globalCurrencyCode; + return $this; + } + + /** + * @param string $storeCurrencyCode + * @return $this + */ + public function setStoreCurrencyCode($storeCurrencyCode) + { + $this->storeCurrencyCode = $storeCurrencyCode; + return $this; + } + + /** + * @param int $storeId + * @return $this + */ + public function setStoreId($storeId) + { + $this->storeId = $storeId; + return $this; + } + + /** + * @param string $storeToBaseRate + * @return $this + */ + public function setStoreToBaseRate($storeToBaseRate) + { + $this->storeToBaseRate = $storeToBaseRate; + return $this; + } + + /** + * @param string $baseToGlobalRate + * @return $this + */ + public function setBaseToGlobalRate($baseToGlobalRate) + { + $this->baseToGlobalRate = $baseToGlobalRate; + return $this; + } + + /** + * @param string $couponCode + * @return $this + */ + public function setCouponCode($couponCode) + { + $this->couponCode = $couponCode; + return $this; + } + + /** + * @param Item[] $items + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * @param Payment[] $payments + * @return $this + */ + public function setPayments($payments) + { + $this->payments = $payments; + return $this; + } + + /** + * @return \Magento\Sales\Model\Order + * @throws \Exception + */ + public function create() + { + /**@var $order \Magento\Sales\Model\Order */ + $order = $this->orderFactory->create([ + 'data' => [ + 'quote_id' => $this->quoteId, + 'applied_rule_ids' => $this->appliedRuleIds, + 'is_virtual' => $this->isVirtual, + 'remote_ip' => $this->remoteIp, + 'base_subtotal' => $this->baseSubtotal, + 'subtotal' => $this->subtotal, + 'base_grand_total' => $this->baseGrandTotal, + 'grand_total' => $this->grandTotal, + 'base_currency_code' => $this->baseCurrencyCode, + 'global_currency_code' => $this->globalCurrencyCode, + 'store_currency_code' => $this->storeCurrencyCode, + 'store_id' => $this->storeId, + 'store_to_base_rate' => $this->storeToBaseRate, + 'base_to_global_rate' => $this->baseToGlobalRate, + 'coupon_code' => $this->couponCode, + 'customer_dob' => $this->customer->getDob(), + 'customer_email' => $this->customer->getEmail(), + 'customer_firstname' => $this->customer->getFirstName(), + 'customer_gender' => $this->customer->getGender(), + 'customer_group_id' => $this->customer->getGroupId(), + 'customer_id' => $this->customer->getId(), + 'customer_is_guest' => $this->customer->getIsGuest(), + 'customer_lastname' => $this->customer->getLastName(), + 'customer_middlename' => $this->customer->getMiddleName(), + 'customer_note' => $this->customer->getNote(), + 'customer_note_notify' => $this->customer->getNoteNotify(), + 'customer_prefix' => $this->customer->getPrefix(), + 'customer_suffix' => $this->customer->getSuffix(), + 'customer_taxvat' => $this->customer->getTaxvat() + ] + ]); + $order->setBillingAddress($this->billingAddress) + ->setShippingAddress($this->shippingAddress); + foreach ($this->items as $item) { + if ($item instanceof Item) { + $order->addItem($item); + } else { + throw new \InvalidArgumentException('Cannot add item, instance of wrong type is given'); + } + } + foreach ($this->payments as $payment) { + if ($payment instanceof Payment) { + $order->addPayment($payment); + } else { + throw new \InvalidArgumentException('Cannot add payment, instance of wrong type is given'); + } + } + return $order; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 98a0c17d3be..2a380d120e2 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -134,8 +134,10 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel /* * Identifier for order history item + * + * @var string */ - const HISTORY_ENTITY_NAME = 'creditmemo'; + protected $entityType = 'creditmemo'; /** * @var array @@ -304,7 +306,17 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel if (!$this->_order instanceof \Magento\Sales\Model\Order) { $this->_order = $this->_orderFactory->create()->load($this->getOrderId()); } - return $this->_order->setHistoryEntityName(self::HISTORY_ENTITY_NAME); + return $this->_order->setHistoryEntityName($this->entityType); + } + + /** + * Return order entity type + * + * @return string + */ + public function getEntityType() + { + return $this->entityType; } /** @@ -852,4 +864,12 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel { return $this->getResourceCollection()->getFiltered($filter); } + + /** + * @return bool + */ + public function isValidGrandTotal() + { + return !($this->getGrandTotal() <= 0 && !$this->getAllowZeroGrandTotal()); + } } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment/Validator.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment/Validator.php new file mode 100644 index 00000000000..37f8f78c1af --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment/Validator.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Creditmemo\Comment; + +use Magento\Sales\Model\Order\Creditmemo\Comment; + +/** + * Class Validator + */ +class Validator +{ + /** + * Required field + * + * @var array + */ + protected $required = [ + 'parent_id' =>'Parent Creditmemo Id', + 'comment' => 'Comment' + ]; + + /** + * Validate data + * + * @param \Magento\Sales\Model\Order\Creditmemo\Comment $comment + * @return array + */ + public function validate(Comment $comment) + { + $errors = []; + $commentData = $comment->getData(); + foreach ($this->required as $code => $label) { + if (!$comment->hasData($code)) { + $errors[$code] = sprintf('%s is a required field', $label); + } elseif (empty($commentData[$code])) { + $errors[$code] = sprintf('%s can not be empty', $label); + } + } + + return $errors; + } +} diff --git a/app/code/Magento/Sales/Model/Order/CreditmemoNotifier.php b/app/code/Magento/Sales/Model/Order/CreditmemoNotifier.php new file mode 100644 index 00000000000..7399a9c0130 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/CreditmemoNotifier.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; +use Magento\Framework\Logger; + +/** + * Class CreditmemoNotifier + * @package Magento\Sales\Model + */ +class CreditmemoNotifier extends \Magento\Sales\Model\AbstractNotifier +{ + /** + * @var CollectionFactory + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var CreditmemoSender + */ + protected $sender; + + /** + * @param CollectionFactory $historyCollectionFactory + * @param Logger $logger + * @param CreditmemoSender $sender + */ + public function __construct( + CollectionFactory $historyCollectionFactory, + Logger $logger, + CreditmemoSender $sender + ) { + $this->historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->sender = $sender; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Customer.php b/app/code/Magento/Sales/Model/Order/Customer.php new file mode 100644 index 00000000000..485439fda1d --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Customer.php @@ -0,0 +1,259 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + + +class Customer +{ + /** + * @var string + */ + protected $customerDob; + + /** + * @var string + */ + protected $customerEmail; + + /** + * @var string + */ + protected $customerFirstName; + + /** + * @var string + */ + protected $customerGender; + + /** + * @var string + */ + protected $customerGroupId; + + /** + * @var int + */ + protected $customerId; + + /** + * @var int + */ + protected $customerIsGuest; + + /** + * @var string + */ + protected $customerLastName; + + /** + * @var string + */ + protected $customerMiddleName; + + /** + * @var string + */ + protected $customerNote; + + /** + * @var string + */ + protected $customerNoteNotify; + + /** + * @var string + */ + protected $customerPrefix; + + /** + * @var string + */ + protected $customerSuffix; + + /** + * @var string + */ + protected $customerTaxvat; + + /** + * @param string $customerDob + * @param string $customerEmail + * @param string $customerFirstName + * @param string $customerGender + * @param string $customerGroupId + * @param int $customerId + * @param int $customerIsGuest + * @param string $customerLastName + * @param string $customerMiddleName + * @param string $customerNote + * @param string $customerNoteNotify + * @param string $customerPrefix + * @param string $customerSuffix + * @param string $customerTaxvat + */ + public function __construct( + $customerDob, + $customerEmail, + $customerFirstName, + $customerGender, + $customerGroupId, + $customerId, + $customerIsGuest, + $customerLastName, + $customerMiddleName, + $customerNote, + $customerNoteNotify, + $customerPrefix, + $customerSuffix, + $customerTaxvat + ) { + $this->customerDob = $customerDob; + $this->customerEmail = $customerEmail; + $this->customerFirstName = $customerFirstName; + $this->customerGender = $customerGender; + $this->customerGroupId = $customerGroupId; + $this->customerId = $customerId; + $this->customerIsGuest = $customerIsGuest; + $this->customerLastName = $customerLastName; + $this->customerMiddleName = $customerMiddleName; + $this->customerNote = $customerNote; + $this->customerNoteNotify = $customerNoteNotify; + $this->customerPrefix = $customerPrefix; + $this->customerSuffix = $customerSuffix; + $this->customerTaxvat = $customerTaxvat; + } + + /** + * @return string + */ + public function getDob() + { + return $this->customerDob; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->customerEmail; + } + + /** + * @return string + */ + public function getFirstName() + { + return $this->customerFirstName; + } + + /** + * @return string + */ + public function getGender() + { + return $this->customerGender; + } + + /** + * @return string + */ + public function getGroupId() + { + return $this->customerGroupId; + } + + /** + * @return string + */ + public function getId() + { + return $this->customerId; + } + + /** + * @return string + */ + public function getIsGuest() + { + return $this->customerIsGuest; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->customerLastName; + } + + /** + * @return string + */ + public function getMiddleName() + { + return $this->customerMiddleName; + } + + /** + * @return string + */ + public function getNote() + { + return $this->customerNote; + } + + /** + * @return string + */ + public function getNoteNotify() + { + return $this->customerNoteNotify; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->customerPrefix; + } + + /** + * @return string + */ + public function getSuffix() + { + return $this->customerSuffix; + } + + /** + * @return string + */ + public function getTaxvat() + { + return $this->customerTaxvat; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Customer/Builder.php b/app/code/Magento/Sales/Model/Order/Customer/Builder.php new file mode 100644 index 00000000000..ce30c109879 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Customer/Builder.php @@ -0,0 +1,278 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order\Customer; + +/** + * Class Builder + */ +class Builder +{ + /** + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * @var string + */ + protected $customerDob; + + /** + * @var string + */ + protected $customerEmail; + + /** + * @var string + */ + protected $customerFirstName; + + /** + * @var string + */ + protected $customerGender; + + /** + * @var int + */ + protected $customerGroupId; + + /** + * @var int + */ + protected $customerId; + + /** + * @var int + */ + protected $customerIsGuest; + + /** + * @var string + */ + protected $customerLastName; + + /** + * @var string + */ + protected $customerMiddleName; + + /** + * @var string + */ + protected $customerNote; + + /** + * @var int + */ + protected $customerNoteNotify; + + /** + * @var string + */ + protected $customerPrefix; + + /** + * @var string + */ + protected $customerSuffix; + + /** + * @var string + */ + protected $customerTaxvat; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager + ) { + $this->objectManager = $objectManager; + } + + /** + * @param string $customerDob + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setDob($customerDob) + { + $this->customerDob = $customerDob; + return $this; + } + + /** + * @param string $customerEmail + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setEmail($customerEmail) + { + $this->customerEmail = $customerEmail; + return $this; + } + + /** + * @param string $customerFirstName + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setFirstName($customerFirstName) + { + $this->customerFirstName = $customerFirstName; + return $this; + } + + /** + * @param string $customerGender + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setGender($customerGender) + { + $this->customerGender = $customerGender; + return $this; + } + + /** + * @param int $customerGroupId + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setGroupId($customerGroupId) + { + $this->customerGroupId = $customerGroupId; + return $this; + } + + /** + * @param int $customerId + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setId($customerId) + { + $this->customerId = $customerId; + return $this; + } + + /** + * @param int $customerIsGuest + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setIsGuest($customerIsGuest) + { + $this->customerIsGuest = $customerIsGuest; + return $this; + } + + /** + * @param string $customerLastName + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setLastName($customerLastName) + { + $this->customerLastName = $customerLastName; + return $this; + } + + /** + * @param string $customerMiddleName + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setMiddleName($customerMiddleName) + { + $this->customerMiddleName = $customerMiddleName; + return $this; + } + + /** + * @param string $customerNote + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setNote($customerNote) + { + $this->customerNote = $customerNote; + return $this; + } + + /** + * @param int $customerNoteNotify + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setNoteNotify($customerNoteNotify) + { + $this->customerNoteNotify = $customerNoteNotify; + return $this; + } + + /** + * @param string $customerPrefix + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setPrefix($customerPrefix) + { + $this->customerPrefix = $customerPrefix; + return $this; + } + + /** + * @param string $customerSuffix + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setSuffix($customerSuffix) + { + $this->customerSuffix = $customerSuffix; + return $this; + } + + /** + * @param string $customerTaxvat + * @return \Magento\Sales\Model\Order\Customer\Builder + */ + public function setTaxvat($customerTaxvat) + { + $this->customerTaxvat = $customerTaxvat; + return $this; + } + + /** + * @return \Magento\Sales\Model\Order\Customer + */ + public function create() + { + return $this->objectManager->create('Magento\Sales\Model\Order\Customer', [ + 'customerDob' => $this->customerDob, + 'customerEmail' => $this->customerEmail, + 'customerFirstName' => $this->customerFirstName, + 'customerGender' => $this->customerGender, + 'customerGroupId' => $this->customerGroupId, + 'customerId' => $this->customerId, + 'customerIsGuest' => $this->customerIsGuest, + 'customerLastName' => $this->customerLastName, + 'customerMiddleName' => $this->customerMiddleName, + 'customerNote' => $this->customerNote, + 'customerNoteNotify' => $this->customerNoteNotify, + 'customerPrefix' => $this->customerPrefix, + 'customerSuffix' => $this->customerSuffix, + 'customerTaxvat' => $this->customerTaxvat + ]); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index f337c613041..e84ae0574a9 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -130,10 +130,12 @@ class Invoice extends \Magento\Sales\Model\AbstractModel const REPORT_DATE_TYPE_INVOICE_CREATED = 'invoice_created'; - /* - * Identifier for order history item + /** + * Identifier for history item + * + * @var string */ - const HISTORY_ENTITY_NAME = 'invoice'; + protected $entityType = 'invoice'; /** * @var array @@ -331,7 +333,17 @@ class Invoice extends \Magento\Sales\Model\AbstractModel if (!$this->_order instanceof \Magento\Sales\Model\Order) { $this->_order = $this->_orderFactory->create()->load($this->getOrderId()); } - return $this->_order->setHistoryEntityName(self::HISTORY_ENTITY_NAME); + return $this->_order->setHistoryEntityName($this->entityType); + } + + /** + * Return order history item identifier + * + * @return string + */ + public function getEntityType() + { + return $this->entityType; } /** diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment/Validator.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment/Validator.php new file mode 100644 index 00000000000..a3f7b59b53e --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment/Validator.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Invoice\Comment; + +use Magento\Sales\Model\Order\Invoice\Comment; + +/** + * Class Validator + */ +class Validator +{ + /** + * Required field + * + * @var array + */ + protected $required = [ + 'parent_id' =>'Parent Invoice Id', + 'comment' => 'Comment' + ]; + + /** + * Validate data + * + * @param \Magento\Sales\Model\Order\Invoice\Comment $comment + * @return array + */ + public function validate(Comment $comment) + { + $errors = []; + $commentData = $comment->getData(); + foreach ($this->required as $code => $label) { + if (!$comment->hasData($code)) { + $errors[$code] = sprintf('%s is a required field', $label); + } elseif (empty($commentData[$code])) { + $errors[$code] = sprintf('%s can not be empty', $label); + } + } + + return $errors; + } +} diff --git a/app/code/Magento/Sales/Model/Order/InvoiceNotifier.php b/app/code/Magento/Sales/Model/Order/InvoiceNotifier.php new file mode 100644 index 00000000000..a5d31ef06db --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/InvoiceNotifier.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; +use Magento\Framework\Logger; + +/** + * Class InvoiceNotifier + * @package Magento\Sales\Model + */ +class InvoiceNotifier extends \Magento\Sales\Model\AbstractNotifier +{ + /** + * @var CollectionFactory + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var InvoiceSender + */ + protected $sender; + + /** + * @param CollectionFactory $historyCollectionFactory + * @param Logger $logger + * @param InvoiceSender $sender + */ + public function __construct( + CollectionFactory $historyCollectionFactory, + Logger $logger, + InvoiceSender $sender + ) { + $this->historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->sender = $sender; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index a4f64eed4dd..b8e7584cf7b 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -62,9 +62,11 @@ class Shipment extends \Magento\Sales\Model\AbstractModel const REPORT_DATE_TYPE_SHIPMENT_CREATED = 'shipment_created'; /** - * Identifier for order history item + * Order entity type + * + * @var string */ - const HISTORY_ENTITY_NAME = 'shipment'; + protected $entityType = 'shipment'; /** * Store address @@ -232,7 +234,17 @@ class Shipment extends \Magento\Sales\Model\AbstractModel if (!$this->_order instanceof \Magento\Sales\Model\Order) { $this->_order = $this->_orderFactory->create()->load($this->getOrderId()); } - return $this->_order->setHistoryEntityName(self::HISTORY_ENTITY_NAME); + return $this->_order->setHistoryEntityName($this->entityType); + } + + /** + * Return order history item identifier + * + * @return string + */ + public function getEntityType() + { + return $this->entityType; } /** diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment/Validator.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment/Validator.php new file mode 100644 index 00000000000..4ecf0305d1d --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment/Validator.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Shipment\Comment; + +use Magento\Sales\Model\Order\Shipment\Comment; + +/** + * Class Validator + */ +class Validator +{ + /** + * Required field + * + * @var array + */ + protected $required = [ + 'parent_id' =>'Parent Shipment Id', + 'comment' => 'Comment' + ]; + + /** + * Validate data + * + * @param \Magento\Sales\Model\Order\Shipment\Comment $comment + * @return array + */ + public function validate(Comment $comment) + { + $errors = []; + $commentData = $comment->getData(); + foreach ($this->required as $code => $label) { + if (!$comment->hasData($code)) { + $errors[$code] = sprintf('%s is a required field', $label); + } elseif (empty($commentData[$code])) { + $errors[$code] = sprintf('%s can not be empty', $label); + } + } + + return $errors; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track/Validator.php b/app/code/Magento/Sales/Model/Order/Shipment/Track/Validator.php new file mode 100644 index 00000000000..234c16b7951 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track/Validator.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Shipment\Track; + +use Magento\Sales\Model\Order\Shipment\Track; + +/** + * Class Validator + */ +class Validator +{ + /** + * Required field + * + * @var array + */ + protected $required = [ + 'parent_id' => 'Parent Track Id', + 'order_id' => 'Order Id', + 'track_number' => 'Number', + 'carrier_code' => 'Carrier Code' + ]; + + /** + * Validate data + * + * @param \Magento\Sales\Model\Order\Shipment\Track $track + * @return array + */ + public function validate(Track $track) + { + $errors = []; + $commentData = $track->getData(); + foreach ($this->required as $code => $label) { + if (!$track->hasData($code)) { + $errors[$code] = sprintf('%s is a required field', $label); + } elseif (empty($commentData[$code])) { + $errors[$code] = sprintf('%s can not be empty', $label); + } + } + + return $errors; + } +} diff --git a/app/code/Magento/Sales/Model/OrderConverter.php b/app/code/Magento/Sales/Model/OrderConverter.php new file mode 100644 index 00000000000..83ab755637a --- /dev/null +++ b/app/code/Magento/Sales/Model/OrderConverter.php @@ -0,0 +1,171 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model; + +use Magento\Sales\Model\Order\Builder as OrderBuilder; +use Magento\Sales\Model\Order\ItemConverter; +use Magento\Sales\Model\Order\PaymentConverter; +use Magento\Sales\Model\Order\AddressConverter; +use Magento\Sales\Model\Order\Customer\Builder as CustomerBuilder; +use Magento\Sales\Service\V1\Data\Order as OrderData; + +/** + * Converter class for \Magento\Sales\Model\Order + */ +class OrderConverter +{ + /** + * @var OrderBuilder + */ + protected $orderBuilder; + + /** + * @var ItemConverter + */ + protected $itemConverter; + + /** + * @var PaymentConverter + */ + protected $paymentConverter; + + /** + * @var AddressConverter + */ + protected $addressConverter; + + /** + * @var CustomerBuilder + */ + protected $customerBuilder; + + /** + * @param OrderBuilder $orderBuilder + * @param ItemConverter $itemConverter + * @param PaymentConverter $paymentConverter + * @param AddressConverter $addressConverter + * @param CustomerBuilder $customerBuilder + */ + public function __construct( + OrderBuilder $orderBuilder, + ItemConverter $itemConverter, + PaymentConverter $paymentConverter, + AddressConverter $addressConverter, + CustomerBuilder $customerBuilder + ) { + $this->orderBuilder = $orderBuilder; + $this->itemConverter = $itemConverter; + $this->paymentConverter = $paymentConverter; + $this->addressConverter = $addressConverter; + $this->customerBuilder = $customerBuilder; + } + + /** + * Get Order Customer + * + * @param OrderData $dataObject + * @return Order\Customer + */ + protected function getCustomer(OrderData $dataObject) + { + $this->customerBuilder->setDob($dataObject->getCustomerDob()) + ->setEmail($dataObject->getCustomerEmail()) + ->setFirstName($dataObject->getCustomerFirstname()) + ->setGender($dataObject->getCustomerGender()) + ->setGroupId($dataObject->getCustomerGroupId()) + ->setId($dataObject->getCustomerId()) + ->setIsGuest($dataObject->getCustomerIsGuest()) + ->setLastName($dataObject->getCustomerLastname()) + ->setMiddleName($dataObject->getCustomerMiddlename()) + ->setNote($dataObject->getCustomerNote()) + ->setNoteNotify($dataObject->getCustomerNoteNotify()) + ->setPrefix($dataObject->getCustomerPrefix()) + ->setSuffix($dataObject->getCustomerSuffix()) + ->setTaxvat($dataObject->getCustomerTaxvat()); + return $this->customerBuilder->create(); + } + + /** + * Get Order Items + * + * @param OrderData $dataObject + * @return array + */ + protected function getItems(OrderData $dataObject) + { + $items = []; + foreach ($dataObject->getItems() as $item) { + $items[] = $this->itemConverter->getModel($item); + } + return $items; + } + + /** + * Get Order Payments + * + * @param OrderData $dataObject + * @return array + */ + protected function getPayments(OrderData $dataObject) + { + $payments = []; + foreach ($dataObject->getPayments() as $payment) { + $payments[] = $this->paymentConverter->getModel($payment); + } + return $payments; + } + + /** + * Get Order Model + * + * @param OrderData $dataObject + * @return Order + * @throws \Exception + */ + public function getModel(OrderData $dataObject) + { + $this->orderBuilder->setCustomer($this->getCustomer($dataObject)) + ->setQuoteId($dataObject->getQuoteId()) + ->setAppliedRuleIds($dataObject->getAppliedRuleIds()) + ->setIsVirtual($dataObject->getIsVirtual()) + ->setRemoteIp($dataObject->getRemoteIp()) + ->setBaseSubtotal($dataObject->getBaseSubtotal()) + ->setSubtotal($dataObject->getSubtotal()) + ->setBaseGrandTotal($dataObject->getBaseGrandTotal()) + ->setGrandTotal($dataObject->getGrandTotal()) + ->setBaseCurrencyCode($dataObject->getBaseCurrencyCode()) + ->setGlobalCurrencyCode($dataObject->getGlobalCurrencyCode()) + ->setStoreCurrencyCode($dataObject->getStoreCurrencyCode()) + ->setStoreId($dataObject->getStoreId()) + ->setStoreToBaseRate($dataObject->getStoreToBaseRate()) + ->setBaseToGlobalRate($dataObject->getBaseToGlobalRate()) + ->setCouponCode($dataObject->getCouponCode()) + ->setBillingAddress($this->addressConverter->getModel($dataObject->getBillingAddress())) + ->setShippingAddress($this->addressConverter->getModel($dataObject->getShippingAddress())) + ->setPayments($this->getPayments($dataObject)) + ->setItems($this->getItems($dataObject)); + return $this->orderBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Model/OrderNotifier.php b/app/code/Magento/Sales/Model/OrderNotifier.php new file mode 100644 index 00000000000..12d967a2fdd --- /dev/null +++ b/app/code/Magento/Sales/Model/OrderNotifier.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Framework\Logger; + +/** + * Class OrderNotifier + * @package Magento\Sales\Model + */ +class OrderNotifier extends \Magento\Sales\Model\AbstractNotifier +{ + /** + * @var CollectionFactory + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var OrderSender + */ + protected $sender; + + /** + * @param CollectionFactory $historyCollectionFactory + * @param Logger $logger + * @param OrderSender $sender + */ + public function __construct( + CollectionFactory $historyCollectionFactory, + Logger $logger, + OrderSender $sender + ) { + $this->historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->sender = $sender; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php index 4cef48a914e..4ef922839f1 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php @@ -37,6 +37,33 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder */ protected $_eventPrefix = 'sales_order_creditmemo_comment_resource'; + /** + * Validator + * + * @var \Magento\Sales\Model\Order\Creditmemo\Comment\Validator + */ + protected $validator; + + /** + * Constructor + * + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, + \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Model initialization * @@ -46,4 +73,24 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder { $this->_init('sales_flat_creditmemo_comment', 'entity_id'); } + + /** + * Performs validation before save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $errors = $this->validator->validate($object); + if (!empty($errors)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save comment") . ":\n" . implode("\n", $errors) + ); + } + + return $this; + } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php index 41b2c7fcdab..9dca32d432a 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php @@ -37,6 +37,33 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder */ protected $_eventPrefix = 'sales_order_invoice_comment_resource'; + /** + * Validator + * + * @var \Magento\Sales\Model\Order\Invoice\Comment\Validator + */ + protected $validator; + + /** + * Constructor + * + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, + \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Model initialization * @@ -46,4 +73,24 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder { $this->_init('sales_flat_invoice_comment', 'entity_id'); } + + /** + * Performs validation before save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $errors = $this->validator->validate($object); + if (!empty($errors)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save comment") . ":\n" . implode("\n", $errors) + ); + } + + return $this; + } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php index 41bfbba1cd3..709d47bd2ec 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php @@ -37,6 +37,33 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder */ protected $_eventPrefix = 'sales_order_shipment_comment_resource'; + /** + * Validator + * + * @var \Magento\Sales\Model\Order\Shipment\Comment\Validator + */ + protected $validator; + + /** + * Constructor + * + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, + \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Model initialization * @@ -46,4 +73,24 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder { $this->_init('sales_flat_shipment_comment', 'entity_id'); } + + /** + * Performs validation before save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $errors = $this->validator->validate($object); + if (!empty($errors)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save comment") . ":\n" . implode("\n", $errors) + ); + } + + return $this; + } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php index 8654094f8c9..73718f9e165 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php @@ -37,6 +37,33 @@ class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder */ protected $_eventPrefix = 'sales_order_shipment_track_resource'; + /** + * Validator + * + * @var \Magento\Sales\Model\Order\Shipment\Track\Validator + */ + protected $validator; + + /** + * Constructor + * + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, + \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Model initialization * @@ -46,4 +73,24 @@ class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder { $this->_init('sales_flat_shipment_track', 'entity_id'); } + + /** + * Performs validation before save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $errors = $this->validator->validate($object); + if (!empty($errors)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save track") . ":\n" . implode("\n", $errors) + ); + } + + return $this; + } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History/Collection.php index dbdde6815c3..c8eb2d9f9f8 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History/Collection.php @@ -63,11 +63,9 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection\Abstract * \Magento\Sales\Model\Order\Creditmemo, \Magento\Sales\Model\Order\Invoice, \Magento\Sales\Model\Order\Shipment * * @param AbstractModel $instance - * @param string $historyEntityName - * * @return \Magento\Sales\Model\Order\Status\History|null */ - public function getUnnotifiedForInstance($instance, $historyEntityName = Order::HISTORY_ENTITY_NAME) + public function getUnnotifiedForInstance($instance) { if (!$instance instanceof Order) { $instance = $instance->getOrder(); @@ -79,14 +77,14 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection\Abstract 'desc' )->addFieldToFilter( 'entity_name', - $historyEntityName + $instance->getEntityType() )->addFieldToFilter( 'is_customer_notified', 0 )->setPageSize( 1 ); - foreach ($this as $historyItem) { + foreach ($this->getItems() as $historyItem) { return $historyItem; } return null; diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoAddComment.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoAddComment.php new file mode 100644 index 00000000000..0c5f6058463 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoAddComment.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\Comment; +use Magento\Sales\Model\Order\Creditmemo\CommentConverter; + +/** + * Class CreditmemoAddComment + */ +class CreditmemoAddComment +{ + /** + * @var \Magento\Sales\Model\Order\Creditmemo\CommentConverter + */ + protected $commentConverter; + + /** + * @param \Magento\Sales\Model\Order\Creditmemo\CommentConverter $commentConverter + */ + public function __construct(CommentConverter $commentConverter) + { + $this->commentConverter = $commentConverter; + } + + /** + * Invoke creditmemo add comment service + * + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function invoke(Comment $comment) + { + /** @var \Magento\Sales\Model\Order\Creditmemo\Comment $commentModel */ + $commentModel = $this->commentConverter->getModel($comment); + $commentModel->save(); + + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoCancel.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCancel.php new file mode 100644 index 00000000000..d5773c60318 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCancel.php @@ -0,0 +1,57 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\CreditmemoRepository; + +/** + * Class CreditmemoCancel + */ +class CreditmemoCancel +{ + /** + * @var CreditmemoRepository + */ + protected $creditmemoRepository; + + /** + * @param CreditmemoRepository $creditmemoRepository + */ + public function __construct(CreditmemoRepository $creditmemoRepository) + { + $this->creditmemoRepository = $creditmemoRepository; + } + + /** + * Invoke CreditmemoCancel service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->creditmemoRepository->get($id)->cancel(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoCommentsList.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCommentsList.php new file mode 100644 index 00000000000..bbb755e832f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCommentsList.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\CommentMapper; +use Magento\Framework\Service\V1\Data\FilterBuilder; +use Magento\Sales\Model\Order\Creditmemo\CommentRepository; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder; + +/** + * Class CreditmemoCommentsList + */ +class CreditmemoCommentsList +{ + /** + * @var \Magento\Sales\Model\Order\Creditmemo\CommentRepository + */ + protected $commentRepository; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper + */ + protected $commentMapper; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder + */ + protected $criteriaBuilder; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder + */ + protected $filterBuilder; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param \Magento\Sales\Model\Order\Creditmemo\CommentRepository $commentRepository + * @param \Magento\Sales\Service\V1\Data\CommentMapper $commentMapper + * @param \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $criteriaBuilder + * @param \Magento\Framework\Service\V1\Data\FilterBuilder $filterBuilder + * @param \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + CommentRepository $commentRepository, + CommentMapper $commentMapper, + SearchCriteriaBuilder $criteriaBuilder, + FilterBuilder $filterBuilder, + CommentSearchResultsBuilder $searchResultsBuilder + ) { + $this->commentRepository = $commentRepository; + $this->commentMapper = $commentMapper; + $this->criteriaBuilder = $criteriaBuilder; + $this->filterBuilder = $filterBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke CreditmemoCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function invoke($id) + { + $this->criteriaBuilder->addFilter( + ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + ); + $criteria = $this->criteriaBuilder->create(); + $comments = []; + foreach ($this->commentRepository->find($criteria) as $comment) { + $comments[] = $this->commentMapper->extractDto($comment); + } + return $this->searchResultsBuilder->setItems($comments) + ->setSearchCriteria($criteria) + ->setTotalCount(count($comments)) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoCreate.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCreate.php new file mode 100644 index 00000000000..4134d0a4dfc --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoCreate.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\CreditmemoConverter; + +/** + * Class CreditmemoCreate + */ +class CreditmemoCreate +{ + /** + * @var CreditmemoConverter + */ + protected $invoiceConverter; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @param CreditmemoConverter $creditmemoConverter + * @param \Magento\Framework\Logger $logger + */ + public function __construct(CreditmemoConverter $creditmemoConverter, \Magento\Framework\Logger $logger) + { + $this->creditmemoConverter = $creditmemoConverter; + $this->logger = $logger; + } + + /** + * @param \Magento\Sales\Service\V1\Data\Creditmemo $creditmemoDataObject + * @throws \Exception + * @return bool + */ + public function invoke(\Magento\Sales\Service\V1\Data\Creditmemo $creditmemoDataObject) + { + try { + /** @var \Magento\Sales\Model\Order\Creditmemo $creditmemo */ + $creditmemo = $this->creditmemoConverter->getModel($creditmemoDataObject); + if (!$creditmemo) { + return false; + } + if (!$creditmemo->isValidGrandTotal()) { + return false; + } + $creditmemo->register(); + $creditmemo->save(); + return true; + } catch (\Exception $e) { + $this->logger->logException($e); + throw new \Exception(__('An error has occurred during creating Creditmemo')); + } + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoEmail.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoEmail.php new file mode 100644 index 00000000000..721845ba3ed --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoEmail.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\CreditmemoRepository; + +/** + * Class CreditmemoEmail + */ +class CreditmemoEmail +{ + /** + * @var CreditmemoRepository + */ + protected $creditmemoRepository; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoNotifier + */ + protected $creditmemoNotifier; + + /** + * @param CreditmemoRepository $creditmemoRepository + * @param \Magento\Sales\Model\Order\CreditmemoNotifier $notifier + */ + public function __construct( + CreditmemoRepository $creditmemoRepository, + \Magento\Sales\Model\Order\CreditmemoNotifier $notifier + ) { + $this->creditmemoRepository = $creditmemoRepository; + $this->creditmemoNotifier = $notifier; + } + + /** + * Invoke notifyUser service + * + * @param int $id + * @return bool + */ + public function invoke($id) + { + /** @var \Magento\Sales\Model\Order\Creditmemo $creditmemo */ + $creditmemo = $this->creditmemoRepository->get($id); + return $this->creditmemoNotifier->notify($creditmemo); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoGet.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoGet.php new file mode 100644 index 00000000000..8234ff4e8b7 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoGet.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\CreditmemoRepository; +use Magento\Sales\Service\V1\Data\CreditmemoMapper; + +/** + * Class CreditmemoGet + */ +class CreditmemoGet +{ + /** + * @var \Magento\Sales\Model\Order\CreditmemoRepository + */ + protected $creditmemoRepository; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoMapper + */ + protected $creditmemoMapper; + + /** + * @param \Magento\Sales\Model\Order\CreditmemoRepository $creditmemoRepository + * @param \Magento\Sales\Service\V1\Data\CreditmemoMapper $creditmemoMapper + */ + public function __construct( + CreditmemoRepository $creditmemoRepository, + CreditmemoMapper $creditmemoMapper + ) { + $this->creditmemoRepository = $creditmemoRepository; + $this->creditmemoMapper = $creditmemoMapper; + } + + /** + * Invoke creditmemo get service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Creditmemo + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return $this->creditmemoMapper->extractDto($this->creditmemoRepository->get($id)); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/CreditmemoList.php b/app/code/Magento/Sales/Service/V1/Action/CreditmemoList.php new file mode 100644 index 00000000000..3b38db63556 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/CreditmemoList.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\CreditmemoMapper; +use Magento\Sales\Model\Order\CreditmemoRepository; +use Magento\Framework\Service\V1\Data\SearchCriteria; +use Magento\Sales\Service\V1\Data\CreditmemoSearchResultsBuilder; + +/** + * Class CreditmemoList + */ +class CreditmemoList +{ + /** + * @var CreditmemoMapper + */ + protected $creditmemoMapper; + + /** + * @var CreditmemoRepository + */ + protected $creditmemoRepository; + + /** + * @var CreditmemoSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param CreditmemoRepository $creditmemoRepository + * @param CreditmemoMapper $creditmemoMapper + * @param CreditmemoSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + CreditmemoRepository $creditmemoRepository, + CreditmemoMapper $creditmemoMapper, + CreditmemoSearchResultsBuilder $searchResultsBuilder + ) { + $this->creditmemoRepository = $creditmemoRepository; + $this->creditmemoMapper = $creditmemoMapper; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke CreditmemoList service + * + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria) + { + $creditmemos = []; + foreach ($this->creditmemoRepository->find($searchCriteria) as $creditmemo) { + $creditmemos[] = $this->creditmemoMapper->extractDto($creditmemo); + } + + return $this->searchResultsBuilder->setItems($creditmemos) + ->setTotalCount(count($creditmemos)) + ->setSearchCriteria($searchCriteria) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceAddComment.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceAddComment.php new file mode 100644 index 00000000000..ddec6d28522 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceAddComment.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\Comment; +use Magento\Sales\Model\Order\Invoice\CommentConverter; + +/** + * Class InvoiceAddComment + */ +class InvoiceAddComment +{ + /** + * @var \Magento\Sales\Model\Order\Invoice\CommentConverter + */ + protected $commentConverter; + + /** + * @param \Magento\Sales\Model\Order\Invoice\CommentConverter $commentConverter + */ + public function __construct(CommentConverter $commentConverter) + { + $this->commentConverter = $commentConverter; + } + + /** + * Invoke invoice add comment service + * + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function invoke(Comment $comment) + { + /** @var \Magento\Sales\Model\Order\Invoice\Comment $commentModel */ + $commentModel = $this->commentConverter->getModel($comment); + $commentModel->save(); + + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceCapture.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceCapture.php new file mode 100644 index 00000000000..a45b21e3bcb --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceCapture.php @@ -0,0 +1,57 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\InvoiceRepository; + +/** + * Class InvoiceCapture + */ +class InvoiceCapture +{ + /** + * @var InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @param InvoiceRepository $invoiceRepository + */ + public function __construct(InvoiceRepository $invoiceRepository) + { + $this->invoiceRepository = $invoiceRepository; + } + + /** + * Invoke InvoiceCapture service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->invoiceRepository->get($id)->capture(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceCommentsList.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceCommentsList.php new file mode 100644 index 00000000000..f5d8730ab96 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceCommentsList.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\CommentMapper; +use Magento\Framework\Service\V1\Data\FilterBuilder; +use Magento\Sales\Model\Order\Invoice\CommentRepository; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder; + +/** + * Class InvoiceCommentsList + */ +class InvoiceCommentsList +{ + /** + * @var \Magento\Sales\Model\Order\Invoice\CommentRepository + */ + protected $commentRepository; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper + */ + protected $commentMapper; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder + */ + protected $criteriaBuilder; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder + */ + protected $filterBuilder; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param \Magento\Sales\Model\Order\Invoice\CommentRepository $commentRepository + * @param \Magento\Sales\Service\V1\Data\CommentMapper $commentMapper + * @param \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $criteriaBuilder + * @param \Magento\Framework\Service\V1\Data\FilterBuilder $filterBuilder + * @param \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + CommentRepository $commentRepository, + CommentMapper $commentMapper, + SearchCriteriaBuilder $criteriaBuilder, + FilterBuilder $filterBuilder, + CommentSearchResultsBuilder $searchResultsBuilder + ) { + $this->commentRepository = $commentRepository; + $this->commentMapper = $commentMapper; + $this->criteriaBuilder = $criteriaBuilder; + $this->filterBuilder = $filterBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke InvoiceCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function invoke($id) + { + $this->criteriaBuilder->addFilter( + ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + ); + $criteria = $this->criteriaBuilder->create(); + $comments = []; + foreach ($this->commentRepository->find($criteria) as $comment) { + $comments[] = $this->commentMapper->extractDto($comment); + } + return $this->searchResultsBuilder->setItems($comments) + ->setSearchCriteria($criteria) + ->setTotalCount(count($comments)) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceCreate.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceCreate.php new file mode 100644 index 00000000000..ec76de3a21f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceCreate.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\InvoiceConverter; + +/** + * Class InvoiceCreate + * @package Magento\Sales\Service\V1 + */ +class InvoiceCreate +{ + /** + * @var InvoiceConverter + */ + protected $invoiceConverter; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @param InvoiceConverter $invoiceConverter + * @param \Magento\Framework\Logger $logger + */ + public function __construct(InvoiceConverter $invoiceConverter, \Magento\Framework\Logger $logger) + { + $this->invoiceConverter = $invoiceConverter; + $this->logger = $logger; + } + + /** + * @param \Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject + * @return bool + * @throws \Exception + */ + public function invoke(\Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject) + { + try { + /** @var \Magento\Sales\Model\Order\Invoice $invoice */ + $invoice = $this->invoiceConverter->getModel($invoiceDataObject); + if (!$invoice) { + return false; + } + $invoice->register(); + $invoice->save(); + return true; + } catch (\Exception $e) { + $this->logger->logException($e); + throw new \Exception(__('An error has occurred during creating Invoice')); + } + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceEmail.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceEmail.php new file mode 100644 index 00000000000..b15792d8b8a --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceEmail.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\InvoiceRepository; + +/** + * Class InvoiceEmail + */ +class InvoiceEmail +{ + /** + * @var InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @var \Magento\Sales\Model\InvoiceNotifier + */ + protected $invoiceNotifier; + + /** + * @param InvoiceRepository $invoiceRepository + * @param \Magento\Sales\Model\Order\InvoiceNotifier $notifier + */ + public function __construct( + InvoiceRepository $invoiceRepository, + \Magento\Sales\Model\Order\InvoiceNotifier $notifier + ) { + $this->invoiceRepository = $invoiceRepository; + $this->invoiceNotifier = $notifier; + } + + /** + * Invoke notifyUser service + * + * @param int $id + * @return bool + */ + public function invoke($id) + { + /** @var \Magento\Sales\Model\Order\Invoice $invoice */ + $invoice = $this->invoiceRepository->get($id); + return $this->invoiceNotifier->notify($invoice); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceGet.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceGet.php new file mode 100644 index 00000000000..621d3f56c5f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceGet.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\InvoiceRepository; +use Magento\Sales\Service\V1\Data\InvoiceMapper; + +/** + * Class InvoiceGet + */ +class InvoiceGet +{ + /** + * @var InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @var InvoiceMapper + */ + protected $invoiceMapper; + + /** + * @param InvoiceRepository $invoiceRepository + * @param InvoiceMapper $invoiceMapper + */ + public function __construct( + InvoiceRepository $invoiceRepository, + InvoiceMapper $invoiceMapper + ) { + $this->invoiceRepository = $invoiceRepository; + $this->invoiceMapper = $invoiceMapper; + } + + /** + * Invoke getInvoice service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Invoice + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return $this->invoiceMapper->extractDto($this->invoiceRepository->get($id)); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/InvoiceList.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceList.php new file mode 100644 index 00000000000..8632bc4d1c9 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceList.php @@ -0,0 +1,83 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\InvoiceRepository; +use Magento\Sales\Service\V1\Data\InvoiceMapper; +use Magento\Sales\Service\V1\Data\InvoiceSearchResultsBuilder; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class InvoiceList + */ +class InvoiceList +{ + /** + * @var InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @var InvoiceMapper + */ + protected $invoiceMapper; + + /** + * @var InvoiceSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param InvoiceRepository $invoiceRepository + * @param InvoiceMapper $invoiceMapper + * @param InvoiceSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + InvoiceRepository $invoiceRepository, + InvoiceMapper $invoiceMapper, + InvoiceSearchResultsBuilder $searchResultsBuilder + ) { + $this->invoiceRepository = $invoiceRepository; + $this->invoiceMapper = $invoiceMapper; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke InvoiceList service + * + * @param SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria) + { + $invoices = []; + foreach ($this->invoiceRepository->find($searchCriteria) as $invoice) { + $invoices[] = $this->invoiceMapper->extractDto($invoice); + } + return $this->searchResultsBuilder->setItems($invoices) + ->setTotalCount(count($invoices)) + ->setSearchCriteria($searchCriteria) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php b/app/code/Magento/Sales/Service/V1/Action/InvoiceVoid.php similarity index 65% rename from app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php rename to app/code/Magento/Sales/Service/V1/Action/InvoiceVoid.php index 720df5f28b4..0346a46c5ba 100644 --- a/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php +++ b/app/code/Magento/Sales/Service/V1/Action/InvoiceVoid.php @@ -21,19 +21,37 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\InvoiceRepository; /** - * Interface OrderUnHoldInterface + * Class InvoiceVoid */ -interface OrderUnHoldInterface +class InvoiceVoid { /** - * Invoke orderUnHold service + * @var InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @param InvoiceRepository $invoiceRepository + */ + public function __construct(InvoiceRepository $invoiceRepository) + { + $this->invoiceRepository = $invoiceRepository; + } + + /** + * Invoke InvoiceVoid service * * @param int $id * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function invoke($id); + public function invoke($id) + { + return (bool)$this->invoiceRepository->get($id)->void(); + } } diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php b/app/code/Magento/Sales/Service/V1/Action/OrderAddressUpdate.php similarity index 91% rename from app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php rename to app/code/Magento/Sales/Service/V1/Action/OrderAddressUpdate.php index 0ee239faf42..b9300b7231d 100644 --- a/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderAddressUpdate.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\Order\AddressConverter; use Magento\Sales\Service\V1\Data\OrderAddress; @@ -29,7 +29,7 @@ use Magento\Sales\Service\V1\Data\OrderAddress; /** * Class OrderAddressUpdate */ -class OrderAddressUpdate implements OrderAddressUpdateInterface +class OrderAddressUpdate { /** * @var AddressConverter @@ -54,6 +54,7 @@ class OrderAddressUpdate implements OrderAddressUpdateInterface public function invoke(OrderAddress $orderAddress) { $orderAddressModel = $this->addressConverter->getModel($orderAddress); - return (bool)$orderAddressModel->save(); + $orderAddressModel->save(); + return true; } } diff --git a/app/code/Magento/Sales/Service/V1/OrderCancel.php b/app/code/Magento/Sales/Service/V1/Action/OrderCancel.php similarity index 92% rename from app/code/Magento/Sales/Service/V1/OrderCancel.php rename to app/code/Magento/Sales/Service/V1/Action/OrderCancel.php index a1fd9a36bd6..1ae1ea2f109 100644 --- a/app/code/Magento/Sales/Service/V1/OrderCancel.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderCancel.php @@ -21,15 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; -use Magento\Sales\Service\V1\Data\OrderMapper; /** * Class OrderCancel */ -class OrderCancel implements OrderCancelInterface +class OrderCancel { /** * @var OrderRepository diff --git a/app/code/Magento/Sales/Service/V1/OrderCommentsList.php b/app/code/Magento/Sales/Service/V1/Action/OrderCommentsList.php similarity index 97% rename from app/code/Magento/Sales/Service/V1/OrderCommentsList.php rename to app/code/Magento/Sales/Service/V1/Action/OrderCommentsList.php index 4d202befae6..7fec849be43 100644 --- a/app/code/Magento/Sales/Service/V1/OrderCommentsList.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderCommentsList.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\Order\Status\HistoryRepository; use Magento\Sales\Service\V1\Data\OrderStatusHistoryMapper; @@ -32,7 +32,7 @@ use Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResultsBuilder; /** * Class OrderCommentsList */ -class OrderCommentsList implements OrderCommentsListInterface +class OrderCommentsList { /** * @var HistoryRepository diff --git a/app/code/Magento/Sales/Service/V1/Action/OrderCreate.php b/app/code/Magento/Sales/Service/V1/Action/OrderCreate.php new file mode 100644 index 00000000000..680876b4e3c --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/OrderCreate.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Action; + +/** + * Class OrderCreate + */ +class OrderCreate +{ + /** + * @var \Magento\Sales\Model\OrderConverter + */ + protected $orderConverter; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @param \Magento\Sales\Model\OrderConverter $orderConverter + * @param \Magento\Framework\Logger $logger + */ + public function __construct( + \Magento\Sales\Model\OrderConverter $orderConverter, + \Magento\Framework\Logger $logger + ) { + $this->orderConverter = $orderConverter; + $this->logger = $logger; + } + + /** + * Create order + * + * @param \Magento\Sales\Service\V1\Data\Order $orderDataObject + * @return bool + * @throws \Exception + */ + public function invoke(\Magento\Sales\Service\V1\Data\Order $orderDataObject) + { + try { + $order = $this->orderConverter->getModel($orderDataObject); + return (bool)$order->save(); + } catch (\Exception $e) { + $this->logger->logException($e); + throw new \Exception(__('An error has occurred during order creation')); + } + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderNotifyUser.php b/app/code/Magento/Sales/Service/V1/Action/OrderEmail.php similarity index 86% rename from app/code/Magento/Sales/Service/V1/OrderNotifyUser.php rename to app/code/Magento/Sales/Service/V1/Action/OrderEmail.php index 433a3c359a6..94cf4b5b3a7 100644 --- a/app/code/Magento/Sales/Service/V1/OrderNotifyUser.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderEmail.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; /** - * Class OrderNotifyUser + * Class OrderEmail */ -class OrderNotifyUser implements OrderNotifyUserInterface +class OrderEmail { /** * @var OrderRepository @@ -36,17 +36,17 @@ class OrderNotifyUser implements OrderNotifyUserInterface protected $orderRepository; /** - * @var \Magento\Sales\Model\Notifier + * @var \Magento\Sales\Model\OrderNotifier */ protected $notifier; /** * @param OrderRepository $orderRepository - * @param \Magento\Sales\Model\Notifier $notifier + * @param \Magento\Sales\Model\OrderNotifier $notifier */ public function __construct( OrderRepository $orderRepository, - \Magento\Sales\Model\Notifier $notifier + \Magento\Sales\Model\OrderNotifier $notifier ) { $this->orderRepository = $orderRepository; $this->notifier = $notifier; diff --git a/app/code/Magento/Sales/Service/V1/OrderGet.php b/app/code/Magento/Sales/Service/V1/Action/OrderGet.php similarity index 90% rename from app/code/Magento/Sales/Service/V1/OrderGet.php rename to app/code/Magento/Sales/Service/V1/Action/OrderGet.php index 0fe552bd9d4..19d133bff9d 100644 --- a/app/code/Magento/Sales/Service/V1/OrderGet.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderGet.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; use Magento\Sales\Service\V1\Data\OrderMapper; @@ -29,7 +29,7 @@ use Magento\Sales\Service\V1\Data\OrderMapper; /** * Class OrderGet */ -class OrderGet implements OrderGetInterface +class OrderGet { /** * @var OrderRepository @@ -62,7 +62,6 @@ class OrderGet implements OrderGetInterface */ public function invoke($id) { - $order = $this->orderRepository->get($id); - return $this->orderMapper->extractDto($order); + return $this->orderMapper->extractDto($this->orderRepository->get($id)); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderGetStatus.php b/app/code/Magento/Sales/Service/V1/Action/OrderGetStatus.php similarity index 94% rename from app/code/Magento/Sales/Service/V1/OrderGetStatus.php rename to app/code/Magento/Sales/Service/V1/Action/OrderGetStatus.php index cc7b678f8ff..36b44b70cd3 100644 --- a/app/code/Magento/Sales/Service/V1/OrderGetStatus.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderGetStatus.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; /** * Class OrderGetStatus */ -class OrderGetStatus implements OrderGetStatusInterface +class OrderGetStatus { /** * Order repository diff --git a/app/code/Magento/Sales/Service/V1/OrderHold.php b/app/code/Magento/Sales/Service/V1/Action/OrderHold.php similarity index 94% rename from app/code/Magento/Sales/Service/V1/OrderHold.php rename to app/code/Magento/Sales/Service/V1/Action/OrderHold.php index 0f3500d71a6..81bb0b44ff4 100644 --- a/app/code/Magento/Sales/Service/V1/OrderHold.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderHold.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; /** * Class OrderHold */ -class OrderHold implements OrderHoldInterface +class OrderHold { /** * @var OrderRepository diff --git a/app/code/Magento/Sales/Service/V1/OrderList.php b/app/code/Magento/Sales/Service/V1/Action/OrderList.php similarity index 90% rename from app/code/Magento/Sales/Service/V1/OrderList.php rename to app/code/Magento/Sales/Service/V1/Action/OrderList.php index a8afa33b3df..65b92272eff 100644 --- a/app/code/Magento/Sales/Service/V1/OrderList.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderList.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; use Magento\Sales\Service\V1\Data\OrderMapper; @@ -31,7 +31,7 @@ use Magento\Framework\Service\V1\Data\SearchCriteria; /** * Class OrderList */ -class OrderList implements OrderListInterface +class OrderList { /** * @var OrderRepository @@ -66,8 +66,8 @@ class OrderList implements OrderListInterface /** * Invoke OrderList service * - * @param SearchCriteria $searchCriteria - * @return \Magento\Framework\Service\V1\Data\SearchResults + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Sales\Service\V1\Data\OrderSearchResults */ public function invoke(SearchCriteria $searchCriteria) { @@ -76,7 +76,7 @@ class OrderList implements OrderListInterface $orders[] = $this->orderMapper->extractDto($order); } return $this->searchResultsBuilder->setItems($orders) - ->setTotalCount(count($order)) + ->setTotalCount(count($orders)) ->setSearchCriteria($searchCriteria) ->create(); } diff --git a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php b/app/code/Magento/Sales/Service/V1/Action/OrderStatusHistoryAdd.php similarity index 95% rename from app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php rename to app/code/Magento/Sales/Service/V1/Action/OrderStatusHistoryAdd.php index 95188ae734f..ba388d2e2fc 100644 --- a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderStatusHistoryAdd.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; use Magento\Sales\Model\Order\Status\HistoryConverter; @@ -31,7 +31,7 @@ use Magento\Sales\Service\V1\Data\OrderStatusHistory; * Class OrderStatusHistoryAdd * @package Magento\Sales\Service\V1 */ -class OrderStatusHistoryAdd implements OrderStatusHistoryAddInterface +class OrderStatusHistoryAdd { /** * @var OrderRepository diff --git a/app/code/Magento/Sales/Service/V1/OrderUnHold.php b/app/code/Magento/Sales/Service/V1/Action/OrderUnHold.php similarity index 94% rename from app/code/Magento/Sales/Service/V1/OrderUnHold.php rename to app/code/Magento/Sales/Service/V1/Action/OrderUnHold.php index d25ace68310..f6156cba1e3 100644 --- a/app/code/Magento/Sales/Service/V1/OrderUnHold.php +++ b/app/code/Magento/Sales/Service/V1/Action/OrderUnHold.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; /** * Class OrderUnHold */ -class OrderUnHold implements OrderUnHoldInterface +class OrderUnHold { /** * @var OrderRepository diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentAddComment.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentAddComment.php new file mode 100644 index 00000000000..74382e60b15 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentAddComment.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\Comment; +use Magento\Sales\Model\Order\Shipment\CommentConverter; + +/** + * Class ShipmentAddComment + */ +class ShipmentAddComment +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\CommentConverter + */ + protected $commentConverter; + + /** + * @param \Magento\Sales\Model\Order\Shipment\CommentConverter $commentConverter + */ + public function __construct(CommentConverter $commentConverter) + { + $this->commentConverter = $commentConverter; + } + + /** + * Invoke shipment add comment service + * + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function invoke(Comment $comment) + { + /** @var \Magento\Sales\Model\Order\Shipment\Comment $commentModel */ + $commentModel = $this->commentConverter->getModel($comment); + $commentModel->save(); + + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentAddTrack.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentAddTrack.php new file mode 100644 index 00000000000..0b3f51d8873 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentAddTrack.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\ShipmentTrack; +use Magento\Sales\Model\Order\Shipment\TrackConverter; + +/** + * Class ShipmentAddTrack + */ +class ShipmentAddTrack +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\TrackConverter + */ + protected $trackConverter; + + /** + * @param \Magento\Sales\Model\Order\Shipment\TrackConverter $trackConverter + */ + public function __construct(TrackConverter $trackConverter) + { + $this->trackConverter = $trackConverter; + } + + /** + * Invoke shipment add track service + * + * @param \Magento\Sales\Service\V1\Data\ShipmentTrack $track + * @return bool + * @throws \Exception + */ + public function invoke(ShipmentTrack $track) + { + /** @var \Magento\Sales\Model\Order\Shipment\Track $trackModel */ + $trackModel = $this->trackConverter->getModel($track); + $trackModel->save(); + + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentCommentsList.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentCommentsList.php new file mode 100644 index 00000000000..85e8a150860 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentCommentsList.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\CommentMapper; +use Magento\Framework\Service\V1\Data\FilterBuilder; +use Magento\Sales\Model\Order\Shipment\CommentRepository; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder; + +/** + * Class ShipmentCommentsList + */ +class ShipmentCommentsList +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\CommentRepository + */ + protected $commentRepository; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper + */ + protected $commentMapper; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder + */ + protected $criteriaBuilder; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder + */ + protected $filterBuilder; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param \Magento\Sales\Model\Order\Shipment\CommentRepository $commentRepository + * @param \Magento\Sales\Service\V1\Data\CommentMapper $commentMapper + * @param \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $criteriaBuilder + * @param \Magento\Framework\Service\V1\Data\FilterBuilder $filterBuilder + * @param \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + CommentRepository $commentRepository, + CommentMapper $commentMapper, + SearchCriteriaBuilder $criteriaBuilder, + FilterBuilder $filterBuilder, + CommentSearchResultsBuilder $searchResultsBuilder + ) { + $this->commentRepository = $commentRepository; + $this->commentMapper = $commentMapper; + $this->criteriaBuilder = $criteriaBuilder; + $this->filterBuilder = $filterBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke ShipmentCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function invoke($id) + { + $this->criteriaBuilder->addFilter( + ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + ); + $criteria = $this->criteriaBuilder->create(); + $comments = []; + foreach ($this->commentRepository->find($criteria) as $comment) { + $comments[] = $this->commentMapper->extractDto($comment); + } + return $this->searchResultsBuilder->setItems($comments) + ->setSearchCriteria($criteria) + ->setTotalCount(count($comments)) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentCreate.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentCreate.php new file mode 100644 index 00000000000..bc06acca0e2 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentCreate.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Service\V1\Data\ShipmentConverter; + +/** + * Class ShipmentCreate + * + */ +class ShipmentCreate +{ + /** + * @var ShipmentConverter + */ + protected $shipmentConverter; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @param ShipmentConverter $shipmentConverter + * @param \Magento\Framework\Logger $logger + */ + public function __construct(ShipmentConverter $shipmentConverter, \Magento\Framework\Logger $logger) + { + $this->shipmentConverter = $shipmentConverter; + $this->logger = $logger; + } + + /** + * Invoke CreateShipment service + * + * @param \Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject + * @return bool + * @throws \Exception + */ + public function invoke(\Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject) + { + try { + /** @var \Magento\Sales\Model\Order\Shipment $shipment */ + $shipment = $this->shipmentConverter->getModel($shipmentDataObject); + if (!$shipment) { + return false; + } + $shipment->getOrder()->setIsInProcess(true); + $shipment->register(); + $shipment->save(); + return true; + } catch (\Exception $e) { + $this->logger->logException($e); + throw new \Exception(__('An error has occurred during creating Shipment')); + } + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentEmail.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentEmail.php new file mode 100644 index 00000000000..91871224fa2 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentEmail.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\ShipmentRepository; + +/** + * Class ShipmentEmail + */ +class ShipmentEmail +{ + /** + * @var ShipmentRepository + */ + protected $shipmentRepository; + + /** + * @var \Magento\Shipping\Model\ShipmentNotifier + */ + protected $notifier; + + /** + * @param ShipmentRepository $shipmentRepository + * @param \Magento\Shipping\Model\ShipmentNotifier $notifier + */ + public function __construct( + ShipmentRepository $shipmentRepository, + \Magento\Shipping\Model\ShipmentNotifier $notifier + ) { + $this->shipmentRepository = $shipmentRepository; + $this->notifier = $notifier; + } + + /** + * Invoke notifyUser service + * + * @param int $id + * @return bool + */ + public function invoke($id) + { + /** @var \Magento\Sales\Model\Order\Shipment $shipment */ + $shipment = $this->shipmentRepository->get($id); + return $this->notifier->notify($shipment); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentGet.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentGet.php new file mode 100644 index 00000000000..624a4da1cd8 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentGet.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\ShipmentRepository; +use Magento\Sales\Service\V1\Data\ShipmentMapper; + +/** + * Class ShipmentGet + */ +class ShipmentGet +{ + /** + * @var ShipmentRepository + */ + protected $shipmentRepository; + + /** + * @var ShipmentMapper + */ + protected $shipmentMapper; + + /** + * @param ShipmentRepository $shipmentRepository + * @param ShipmentMapper $shipmentMapper + */ + public function __construct( + ShipmentRepository $shipmentRepository, + ShipmentMapper $shipmentMapper + ) { + $this->shipmentRepository = $shipmentRepository; + $this->shipmentMapper = $shipmentMapper; + } + + /** + * Invoke getShipment service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Shipment + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return $this->shipmentMapper->extractDto($this->shipmentRepository->get($id)); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentLabelGet.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentLabelGet.php new file mode 100644 index 00000000000..89cd5503adf --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentLabelGet.php @@ -0,0 +1,57 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\ShipmentRepository; + +/** + * Class ShipmentLabelGet + */ +class ShipmentLabelGet +{ + /** + * @var ShipmentRepository + */ + protected $shipmentRepository; + + /** + * @param ShipmentRepository $shipmentRepository + */ + public function __construct(ShipmentRepository $shipmentRepository) + { + $this->shipmentRepository = $shipmentRepository; + } + + /** + * Invoke ShipmentLabelGet service + * + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (string)$this->shipmentRepository->get($id)->getShippingLabel(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentList.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentList.php new file mode 100644 index 00000000000..766b66457f9 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentList.php @@ -0,0 +1,83 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\ShipmentRepository; +use Magento\Sales\Service\V1\Data\ShipmentMapper; +use Magento\Sales\Service\V1\Data\ShipmentSearchResultsBuilder; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class ShipmentList + */ +class ShipmentList +{ + /** + * @var ShipmentRepository + */ + protected $shipmentRepository; + + /** + * @var ShipmentMapper + */ + protected $shipmentMapper; + + /** + * @var ShipmentSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param ShipmentRepository $shipmentRepository + * @param ShipmentMapper $shipmentMapper + * @param ShipmentSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + ShipmentRepository $shipmentRepository, + ShipmentMapper $shipmentMapper, + ShipmentSearchResultsBuilder $searchResultsBuilder + ) { + $this->shipmentRepository = $shipmentRepository; + $this->shipmentMapper = $shipmentMapper; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke ShipmentList service + * + * @param SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria) + { + $shipments = []; + foreach ($this->shipmentRepository->find($searchCriteria) as $shipment) { + $shipments[] = $this->shipmentMapper->extractDto($shipment); + } + return $this->searchResultsBuilder->setItems($shipments) + ->setTotalCount(count($shipments)) + ->setSearchCriteria($searchCriteria) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Action/ShipmentRemoveTrack.php b/app/code/Magento/Sales/Service/V1/Action/ShipmentRemoveTrack.php new file mode 100644 index 00000000000..c40d72b64e7 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Action/ShipmentRemoveTrack.php @@ -0,0 +1,61 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +use Magento\Sales\Model\Order\Shipment\TrackRepository; + +/** + * Class ShipmentRemoveTrack + */ +class ShipmentRemoveTrack +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\TrackRepository + */ + protected $trackRepository; + + /** + * @param \Magento\Sales\Model\Order\Shipment\TrackRepository $trackRepository + */ + public function __construct(TrackRepository $trackRepository) + { + $this->trackRepository = $trackRepository; + } + + /** + * Invoke shipment remove track + * + * @param int $id + * @return bool + * @throws \Exception + */ + public function invoke($id) + { + /** @var \Magento\Sales\Model\Order\Shipment\Track $trackModel */ + $trackModel = $this->trackRepository->get($id); + $trackModel->delete(); + + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/CreditmemoRead.php b/app/code/Magento/Sales/Service/V1/CreditmemoRead.php new file mode 100644 index 00000000000..84e6634a203 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/CreditmemoRead.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\CreditmemoGet; +use Magento\Sales\Service\V1\Action\CreditmemoList; +use Magento\Sales\Service\V1\Action\CreditmemoCommentsList; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class CreditmemoRead + */ +class CreditmemoRead implements CreditmemoReadInterface +{ + /** + * @var CreditmemoGet + */ + protected $creditmemoGet; + + /** + * @var CreditmemoList + */ + protected $creditmemoList; + + /** + * @var CreditmemoCommentsList + */ + protected $creditmemoCommentsList; + + /** + * @param CreditmemoGet $creditmemoGet + * @param CreditmemoList $creditmemoList + * @param CreditmemoCommentsList $creditmemoCommentsList + */ + public function __construct( + CreditmemoGet $creditmemoGet, + CreditmemoList $creditmemoList, + CreditmemoCommentsList $creditmemoCommentsList + ) { + $this->creditmemoGet = $creditmemoGet; + $this->creditmemoList = $creditmemoList; + $this->creditmemoCommentsList = $creditmemoCommentsList; + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Creditmemo + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id) + { + return $this->creditmemoGet->invoke($id); + } + + /** + * @param SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria) + { + return $this->creditmemoList->invoke($searchCriteria); + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id) + { + return $this->creditmemoCommentsList->invoke($id); + } +} diff --git a/app/code/Magento/Sales/Service/V1/CreditmemoReadInterface.php b/app/code/Magento/Sales/Service/V1/CreditmemoReadInterface.php new file mode 100644 index 00000000000..8f59c3beb08 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/CreditmemoReadInterface.php @@ -0,0 +1,48 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Framework\Service\V1\Data\SearchCriteria; + +interface CreditmemoReadInterface +{ + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Creditmemo + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id); + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria); + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id); +} diff --git a/app/code/Magento/Sales/Service/V1/CreditmemoWrite.php b/app/code/Magento/Sales/Service/V1/CreditmemoWrite.php new file mode 100644 index 00000000000..9d02d532b93 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/CreditmemoWrite.php @@ -0,0 +1,114 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\CreditmemoAddComment; +use Magento\Sales\Service\V1\Action\CreditmemoCancel; +use Magento\Sales\Service\V1\Action\CreditmemoEmail; +use Magento\Sales\Service\V1\Action\CreditmemoCreate; +use Magento\Sales\Service\V1\Data\Comment; +use Magento\Sales\Service\V1\Data\Creditmemo; + +/** + * Class CreditmemoWrite + */ +class CreditmemoWrite implements CreditmemoWriteInterface +{ + /** + * @var CreditmemoAddComment + */ + protected $creditmemoAddComment; + + /** + * @var CreditmemoCancel + */ + protected $creditmemoCancel; + + /** + * @var CreditmemoEmail + */ + protected $creditmemoEmail; + + /** + * @var CreditmemoCreate + */ + protected $creditmemoCreate; + + /** + * @param CreditmemoAddComment $creditmemoAddComment + * @param CreditmemoCancel $creditmemoCancel + * @param CreditmemoEmail $creditmemoEmail + * @param CreditmemoCreate $creditmemoCreate + */ + public function __construct( + CreditmemoAddComment $creditmemoAddComment, + CreditmemoCancel $creditmemoCancel, + CreditmemoEmail $creditmemoEmail, + CreditmemoCreate $creditmemoCreate + ) { + $this->creditmemoAddComment = $creditmemoAddComment; + $this->creditmemoCancel = $creditmemoCancel; + $this->creditmemoEmail = $creditmemoEmail; + $this->creditmemoCreate = $creditmemoCreate; + } + + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment) + { + return $this->creditmemoAddComment->invoke($comment); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function cancel($id) + { + return $this->creditmemoCancel->invoke($id); + } + + /** + * @param int $id + * @return bool + */ + public function email($id) + { + return $this->creditmemoEmail->invoke($id); + } + + /** + * @param \Magento\Sales\Service\V1\Data\Creditmemo $creditmemoDataObject + * @throws \Exception + * @return bool + */ + public function create(Creditmemo $creditmemoDataObject) + { + return $this->creditmemoCreate->invoke($creditmemoDataObject); + } +} diff --git a/app/code/Magento/Sales/Service/V1/CreditmemoWriteInterface.php b/app/code/Magento/Sales/Service/V1/CreditmemoWriteInterface.php new file mode 100644 index 00000000000..def6ef9c772 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/CreditmemoWriteInterface.php @@ -0,0 +1,57 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Data\Comment; +use Magento\Sales\Service\V1\Data\Creditmemo; + +interface CreditmemoWriteInterface +{ + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function cancel($id); + + /** + * @param int $id + * @return bool + */ + public function email($id); + + /** + * @param \Magento\Sales\Service\V1\Data\Creditmemo $creditmemoDataObject + * @throws \Exception + * @return bool + */ + public function create(Creditmemo $creditmemoDataObject); +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php index d43bacf41c2..63670339b81 100644 --- a/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php +++ b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php @@ -30,245 +30,55 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class Creditmemo extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const STORE_ID = 'store_id'; - - /** - * float - */ const ADJUSTMENT_POSITIVE = 'adjustment_positive'; - - /** - * float - */ const BASE_SHIPPING_TAX_AMOUNT = 'base_shipping_tax_amount'; - - /** - * float - */ const STORE_TO_ORDER_RATE = 'store_to_order_rate'; - - /** - * float - */ const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'; - - /** - * float - */ const BASE_TO_ORDER_RATE = 'base_to_order_rate'; - - /** - * float - */ const GRAND_TOTAL = 'grand_total'; - - /** - * float - */ const BASE_ADJUSTMENT_NEGATIVE = 'base_adjustment_negative'; - - /** - * float - */ const BASE_SUBTOTAL_INCL_TAX = 'base_subtotal_incl_tax'; - - /** - * float - */ const SHIPPING_AMOUNT = 'shipping_amount'; - - /** - * float - */ const SUBTOTAL_INCL_TAX = 'subtotal_incl_tax'; - - /** - * float - */ const ADJUSTMENT_NEGATIVE = 'adjustment_negative'; - - /** - * float - */ const BASE_SHIPPING_AMOUNT = 'base_shipping_amount'; - - /** - * float - */ const STORE_TO_BASE_RATE = 'store_to_base_rate'; - - /** - * float - */ const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'; - - /** - * float - */ const BASE_ADJUSTMENT = 'base_adjustment'; - - /** - * float - */ const BASE_SUBTOTAL = 'base_subtotal'; - - /** - * float - */ const DISCOUNT_AMOUNT = 'discount_amount'; - - /** - * float - */ const SUBTOTAL = 'subtotal'; - - /** - * float - */ const ADJUSTMENT = 'adjustment'; - - /** - * float - */ const BASE_GRAND_TOTAL = 'base_grand_total'; - - /** - * float - */ const BASE_ADJUSTMENT_POSITIVE = 'base_adjustment_positive'; - - /** - * float - */ const BASE_TAX_AMOUNT = 'base_tax_amount'; - - /** - * float - */ const SHIPPING_TAX_AMOUNT = 'shipping_tax_amount'; - - /** - * float - */ const TAX_AMOUNT = 'tax_amount'; - - /** - * int - */ const ORDER_ID = 'order_id'; - - /** - * int - */ const EMAIL_SENT = 'email_sent'; - - /** - * int - */ const CREDITMEMO_STATUS = 'creditmemo_status'; - - /** - * int - */ const STATE = 'state'; - - /** - * int - */ const SHIPPING_ADDRESS_ID = 'shipping_address_id'; - - /** - * int - */ const BILLING_ADDRESS_ID = 'billing_address_id'; - - /** - * int - */ const INVOICE_ID = 'invoice_id'; - - /** - * string - */ const STORE_CURRENCY_CODE = 'store_currency_code'; - - /** - * string - */ const ORDER_CURRENCY_CODE = 'order_currency_code'; - - /** - * string - */ const BASE_CURRENCY_CODE = 'base_currency_code'; - - /** - * string - */ const GLOBAL_CURRENCY_CODE = 'global_currency_code'; - - /** - * string - */ const TRANSACTION_ID = 'transaction_id'; - - /** - * string - */ const INCREMENT_ID = 'increment_id'; - - /** - * string - */ const CREATED_AT = 'created_at'; - - /** - * string - */ const UPDATED_AT = 'updated_at'; - - /** - * float - */ const HIDDEN_TAX_AMOUNT = 'hidden_tax_amount'; - - /** - * float - */ const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; - - /** - * float - */ const SHIPPING_HIDDEN_TAX_AMOUNT = 'shipping_hidden_tax_amount'; - - /** - * float - */ const BASE_SHIPPING_HIDDEN_TAX_AMNT = 'base_shipping_hidden_tax_amnt'; - - /** - * float - */ const SHIPPING_INCL_TAX = 'shipping_incl_tax'; - - /** - * float - */ const BASE_SHIPPING_INCL_TAX = 'base_shipping_incl_tax'; - - /** - * string - */ const DISCOUNT_DESCRIPTION = 'discount_description'; + const ITEMS = 'items'; /** * Returns adjustment @@ -750,4 +560,14 @@ class Creditmemo extends DataObject { return $this->_get(self::UPDATED_AT); } + + /** + * Return creditmemo items + * + * @return \Magento\Sales\Service\V1\Data\CreditmemoItem[] + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } } diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php deleted file mode 100644 index 26e097b26e1..00000000000 --- a/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Service\V1\Data; - -use Magento\Framework\Service\Data\AbstractObject as DataObject; - -/** - * Class CreditmemoComment - */ -class CreditmemoComment extends DataObject -{ - /** - * int - */ - const ENTITY_ID = 'entity_id'; - - /** - * int - */ - const PARENT_ID = 'parent_id'; - - /** - * int - */ - const IS_CUSTOMER_NOTIFIED = 'is_customer_notified'; - - /** - * int - */ - const IS_VISIBLE_ON_FRONT = 'is_visible_on_front'; - - /** - * string - */ - const COMMENT = 'comment'; - - /** - * string - */ - const CREATED_AT = 'created_at'; - - /** - * Returns comment - * - * @return string - */ - public function getComment() - { - return $this->_get(self::COMMENT); - } - - /** - * Returns created_at - * - * @return string - */ - public function getCreatedAt() - { - return $this->_get(self::CREATED_AT); - } - - /** - * Returns entity_id - * - * @return int - */ - public function getEntityId() - { - return $this->_get(self::ENTITY_ID); - } - - /** - * Returns is_customer_notified - * - * @return int - */ - public function getIsCustomerNotified() - { - return $this->_get(self::IS_CUSTOMER_NOTIFIED); - } - - /** - * Returns is_visible_on_front - * - * @return int - */ - public function getIsVisibleOnFront() - { - return $this->_get(self::IS_VISIBLE_ON_FRONT); - } - - /** - * Returns parent_id - * - * @return int - */ - public function getParentId() - { - return $this->_get(self::PARENT_ID); - } -} diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoConverter.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoConverter.php new file mode 100644 index 00000000000..9dd0022e83f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoConverter.php @@ -0,0 +1,69 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class CreditmemoConverter + * + * @package Magento\Sales\Service\V1\Data + */ +class CreditmemoConverter +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader + */ + protected $creditmemoLoader; + + /** + * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + */ + public function __construct(\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader) + { + $this->creditmemoLoader = $creditmemoLoader; + } + + /** + * @param Creditmemo $dataObject + * @return bool|\Magento\Sales\Model\Order\Creditmemo + */ + public function getModel(Creditmemo $dataObject) + { + $this->creditmemoLoader->setOrderId($dataObject->getOrderId()); + $this->creditmemoLoader->setCreditmemoId($dataObject->getEntityId()); + + $items = []; + foreach ($dataObject->getItems() as $item) { + $items[$item->getOrderItemId()] = ['qty' => $item->getQty()]; + } + $creditmemo = [ + 'items' => $items, + 'shipping_amount' => $dataObject->getShippingAmount(), + 'adjustment_positive' => $dataObject->getAdjustmentPositive(), + 'adjustment_negative' => $dataObject->getAdjustmentNegative(), + ]; + $this->creditmemoLoader->setCreditmemo($creditmemo); + $this->creditmemoLoader->setInvoiceId($dataObject->getInvoiceId()); + return $this->creditmemoLoader->load(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoMapper.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoMapper.php new file mode 100644 index 00000000000..3d2e6a01bec --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoMapper.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class CreditmemoMapper + */ +class CreditmemoMapper +{ + /** + * @var CreditmemoBuilder + */ + protected $creditmemoBuilder; + + /** + * @var CreditmemoItemMapper + */ + protected $creditmemoItemMapper; + + /** + * @param CreditmemoBuilder $creditmemoBuilder + * @param CreditmemoItemMapper $creditmemoItemMapper + */ + public function __construct(CreditmemoBuilder $creditmemoBuilder, CreditmemoItemMapper $creditmemoItemMapper) + { + $this->creditmemoBuilder = $creditmemoBuilder; + $this->creditmemoItemMapper = $creditmemoItemMapper; + } + + /** + * Returns array of items + * + * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo + * @return \Magento\Sales\Service\V1\Data\CreditmemoItem[] + */ + protected function getItems(\Magento\Sales\Model\Order\Creditmemo $creditmemo) + { + $items = []; + foreach ($creditmemo->getAllItems() as $item) { + $items[] = $this->creditmemoItemMapper->extractDto($item); + } + + return $items; + } + + /** + * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo + * @return \Magento\Framework\Service\Data\AbstractObject + */ + public function extractDto(\Magento\Sales\Model\Order\Creditmemo $creditmemo) + { + $this->creditmemoBuilder->populateWithArray($creditmemo->getData()); + $this->creditmemoBuilder->setItems($this->getItems($creditmemo)); + + return $this->creditmemoBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Invoice.php b/app/code/Magento/Sales/Service/V1/Data/Invoice.php index 08ed2599cf0..49dfcbad0f2 100644 --- a/app/code/Magento/Sales/Service/V1/Data/Invoice.php +++ b/app/code/Magento/Sales/Service/V1/Data/Invoice.php @@ -75,7 +75,6 @@ class Invoice extends DataObject const BASE_TOTAL_REFUNDED = 'base_total_refunded'; const DISCOUNT_DESCRIPTION = 'discount_description'; const ITEMS = 'items'; - const COMMENTS = 'comments'; /** * Returns base_currency_code @@ -520,20 +519,10 @@ class Invoice extends DataObject /** * Returns invoice items * - * @return InvoiceItem[] + * @return \Magento\Sales\Service\V1\Data\InvoiceItem[] */ public function getItems() { - return $this->_get(self::ITEMS); - } - - /** - * Return invoice comments - * - * @return Comment[] - */ - public function getComments() - { - return $this->_get(self::COMMENTS); + return (array)$this->_get(self::ITEMS); } } diff --git a/app/code/Magento/Sales/Service/V1/Data/InvoiceConverter.php b/app/code/Magento/Sales/Service/V1/Data/InvoiceConverter.php new file mode 100644 index 00000000000..3aebad91e48 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/InvoiceConverter.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class InvoiceConverter + * @package Magento\Sales\Service\V1\Data + */ +class InvoiceConverter +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader + */ + protected $invoiceLoader; + + /** + * @param \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + */ + public function __construct(\Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader) + { + $this->invoiceLoader = $invoiceLoader; + } + + /** + * @param Invoice $dataObject + * @return \Magento\Sales\Model\Order\Invoice + * @throws \Exception + */ + public function getModel(Invoice $dataObject) + { + $items = []; + /** @var InvoiceItem $item */ + foreach ($dataObject->getItems() as $item) { + $items[$item->getOrderItemId()] = $item->getQty(); + } + return $this->invoiceLoader + ->setOrderId($dataObject->getOrderId()) + ->setInvoiceId($dataObject->getEntityId()) + ->setInvoiceItems($items) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php index dd3865fe5b9..1fb57135c85 100644 --- a/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php +++ b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php @@ -30,124 +30,29 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class InvoiceItem extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const PARENT_ID = 'parent_id'; - - /** - * float - */ const BASE_PRICE = 'base_price'; - - /** - * float - */ const TAX_AMOUNT = 'tax_amount'; - - /** - * float - */ const BASE_ROW_TOTAL = 'base_row_total'; - - /** - * float - */ const DISCOUNT_AMOUNT = 'discount_amount'; - - /** - * float - */ const ROW_TOTAL = 'row_total'; - - /** - * float - */ const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'; - - /** - * float - */ const PRICE_INCL_TAX = 'price_incl_tax'; - - /** - * float - */ const BASE_TAX_AMOUNT = 'base_tax_amount'; - - /** - * float - */ const BASE_PRICE_INCL_TAX = 'base_price_incl_tax'; - - /** - * float - */ const QTY = 'qty'; - - /** - * float - */ const BASE_COST = 'base_cost'; - - /** - * float - */ const PRICE = 'price'; - - /** - * float - */ const BASE_ROW_TOTAL_INCL_TAX = 'base_row_total_incl_tax'; - - /** - * float - */ const ROW_TOTAL_INCL_TAX = 'row_total_incl_tax'; - - /** - * int - */ const PRODUCT_ID = 'product_id'; - - /** - * int - */ const ORDER_ITEM_ID = 'order_item_id'; - - /** - * string - */ const ADDITIONAL_DATA = 'additional_data'; - - /** - * string - */ const DESCRIPTION = 'description'; - - /** - * string - */ const SKU = 'sku'; - - /** - * string - */ const NAME = 'name'; - - /** - * float - */ const HIDDEN_TAX_AMOUNT = 'hidden_tax_amount'; - - /** - * float - */ const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; /** diff --git a/app/code/Magento/Sales/Service/V1/Data/InvoiceMapper.php b/app/code/Magento/Sales/Service/V1/Data/InvoiceMapper.php new file mode 100644 index 00000000000..d59189f0d9e --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/InvoiceMapper.php @@ -0,0 +1,76 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class InvoiceMapper + */ +class InvoiceMapper +{ + /** + * @var InvoiceBuilder + */ + protected $invoiceBuilder; + + /** + * @var InvoiceItemMapper + */ + protected $invoiceItemMapper; + + /** + * @param InvoiceBuilder $invoiceBuilder + * @param InvoiceItemMapper $invoiceItemMapper + */ + public function __construct(InvoiceBuilder $invoiceBuilder, InvoiceItemMapper $invoiceItemMapper) + { + $this->invoiceBuilder = $invoiceBuilder; + $this->invoiceItemMapper = $invoiceItemMapper; + } + + /** + * Returns array of items + * + * @param \Magento\Sales\Model\Order\Invoice $object + * @return InvoiceItem[] + */ + protected function getItems(\Magento\Sales\Model\Order\Invoice $object) + { + $items = []; + foreach ($object->getAllItems() as $item) { + $items[] = $this->invoiceItemMapper->extractDto($item); + } + return $items; + } + + /** + * @param \Magento\Sales\Model\Order\Invoice $object + * @return \Magento\Framework\Service\Data\AbstractObject + */ + public function extractDto(\Magento\Sales\Model\Order\Invoice $object) + { + $this->invoiceBuilder->populateWithArray($object->getData()); + $this->invoiceBuilder->setItems($this->getItems($object)); + return $this->invoiceBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php index 34d413993fd..5d956b53c5d 100644 --- a/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php +++ b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php @@ -30,134 +30,31 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class OrderAddress extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const PARENT_ID = 'parent_id'; - - /** - * int - */ const CUSTOMER_ADDRESS_ID = 'customer_address_id'; - - /** - * int - */ const QUOTE_ADDRESS_ID = 'quote_address_id'; - - /** - * int - */ const REGION_ID = 'region_id'; - - /** - * int - */ const CUSTOMER_ID = 'customer_id'; - - /** - * string - */ const FAX = 'fax'; - - /** - * string - */ const REGION = 'region'; - - /** - * string - */ const POSTCODE = 'postcode'; - - /** - * string - */ const LASTNAME = 'lastname'; - - /** - * string - */ const STREET = 'street'; - - /** - * string - */ const CITY = 'city'; - - /** - * string - */ const EMAIL = 'email'; - - /** - * string - */ const TELEPHONE = 'telephone'; - - /** - * string - */ const COUNTRY_ID = 'country_id'; - - /** - * string - */ const FIRSTNAME = 'firstname'; - - /** - * string - */ const ADDRESS_TYPE = 'address_type'; - - /** - * string - */ const PREFIX = 'prefix'; - - /** - * string - */ const MIDDLENAME = 'middlename'; - - /** - * string - */ const SUFFIX = 'suffix'; - - /** - * string - */ const COMPANY = 'company'; - - /** - * string - */ const VAT_ID = 'vat_id'; - - /** - * int - */ const VAT_IS_VALID = 'vat_is_valid'; - - /** - * string - */ const VAT_REQUEST_ID = 'vat_request_id'; - - /** - * string - */ const VAT_REQUEST_DATE = 'vat_request_date'; - - /** - * int - */ const VAT_REQUEST_SUCCESS = 'vat_request_success'; /** diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php index 38a6e49d4f3..0ce3f48ed22 100644 --- a/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php +++ b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php @@ -23,8 +23,6 @@ */ namespace Magento\Sales\Service\V1\Data; -//use Magento\Sales\Model\Order; - /** * Class OrderMapper */ @@ -130,7 +128,7 @@ class OrderMapper /** * @param \Magento\Sales\Model\Order $object - * @return \Magento\Framework\Service\Data\AbstractObject + * @return \Magento\Sales\Service\V1\Data\Order */ public function extractDto(\Magento\Sales\Model\Order $object) { diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php index a076f2ab30e..f57b67e9fec 100644 --- a/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php +++ b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php @@ -30,274 +30,59 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class OrderPayment extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const PARENT_ID = 'parent_id'; - - /** - * float - */ const BASE_SHIPPING_CAPTURED = 'base_shipping_captured'; - - /** - * float - */ const SHIPPING_CAPTURED = 'shipping_captured'; - - /** - * float - */ const AMOUNT_REFUNDED = 'amount_refunded'; - - /** - * float - */ const BASE_AMOUNT_PAID = 'base_amount_paid'; - - /** - * float - */ const AMOUNT_CANCELED = 'amount_canceled'; - - /** - * float - */ const BASE_AMOUNT_AUTHORIZED = 'base_amount_authorized'; - - /** - * float - */ const BASE_AMOUNT_PAID_ONLINE = 'base_amount_paid_online'; - - /** - * float - */ const BASE_AMOUNT_REFUNDED_ONLINE = 'base_amount_refunded_online'; - - /** - * float - */ const BASE_SHIPPING_AMOUNT = 'base_shipping_amount'; - - /** - * float - */ const SHIPPING_AMOUNT = 'shipping_amount'; - - /** - * float - */ const AMOUNT_PAID = 'amount_paid'; - - /** - * float - */ const AMOUNT_AUTHORIZED = 'amount_authorized'; - - /** - * float - */ const BASE_AMOUNT_ORDERED = 'base_amount_ordered'; - - /** - * float - */ const BASE_SHIPPING_REFUNDED = 'base_shipping_refunded'; - - /** - * float - */ const SHIPPING_REFUNDED = 'shipping_refunded'; - - /** - * float - */ const BASE_AMOUNT_REFUNDED = 'base_amount_refunded'; - - /** - * float - */ const AMOUNT_ORDERED = 'amount_ordered'; - - /** - * float - */ const BASE_AMOUNT_CANCELED = 'base_amount_canceled'; - - /** - * int - */ const QUOTE_PAYMENT_ID = 'quote_payment_id'; - - /** - * string - */ const ADDITIONAL_DATA = 'additional_data'; - - /** - * string - */ const CC_EXP_MONTH = 'cc_exp_month'; - - /** - * string - */ const CC_SS_START_YEAR = 'cc_ss_start_year'; - - /** - * string - */ const ECHECK_BANK_NAME = 'echeck_bank_name'; - - /** - * string - */ const METHOD = 'method'; - - /** - * string - */ const CC_DEBUG_REQUEST_BODY = 'cc_debug_request_body'; - - /** - * string - */ const CC_SECURE_VERIFY = 'cc_secure_verify'; - - /** - * string - */ const PROTECTION_ELIGIBILITY = 'protection_eligibility'; - - /** - * string - */ const CC_APPROVAL = 'cc_approval'; - - /** - * string - */ const CC_LAST4 = 'cc_last4'; - - /** - * string - */ const CC_STATUS_DESCRIPTION = 'cc_status_description'; - - /** - * string - */ const ECHECK_TYPE = 'echeck_type'; - - /** - * string - */ const CC_DEBUG_RESPONSE_SERIALIZED = 'cc_debug_response_serialized'; - - /** - * string - */ const CC_SS_START_MONTH = 'cc_ss_start_month'; - - /** - * string - */ const ECHECK_ACCOUNT_TYPE = 'echeck_account_type'; - - /** - * string - */ const LAST_TRANS_ID = 'last_trans_id'; - - /** - * string - */ const CC_CID_STATUS = 'cc_cid_status'; - - /** - * string - */ const CC_OWNER = 'cc_owner'; - - /** - * string - */ const CC_TYPE = 'cc_type'; - - /** - * string - */ const PO_NUMBER = 'po_number'; - - /** - * string - */ const CC_EXP_YEAR = 'cc_exp_year'; - - /** - * string - */ const CC_STATUS = 'cc_status'; - - /** - * string - */ const ECHECK_ROUTING_NUMBER = 'echeck_routing_number'; - - /** - * string - */ const ACCOUNT_STATUS = 'account_status'; - - /** - * string - */ const ANET_TRANS_METHOD = 'anet_trans_method'; - - /** - * string - */ const CC_DEBUG_RESPONSE_BODY = 'cc_debug_response_body'; - - /** - * string - */ const CC_SS_ISSUE = 'cc_ss_issue'; - - /** - * string - */ const ECHECK_ACCOUNT_NAME = 'echeck_account_name'; - - /** - * string - */ const CC_AVS_STATUS = 'cc_avs_status'; - - /** - * string - */ const CC_NUMBER_ENC = 'cc_number_enc'; - - /** - * string - */ const CC_TRANS_ID = 'cc_trans_id'; - - /** - * string - */ const ADDRESS_STATUS = 'address_status'; - - /** - * string - */ const ADDITIONAL_INFORMATION = 'additional_information'; /** diff --git a/app/code/Magento/Sales/Service/V1/Data/Shipment.php b/app/code/Magento/Sales/Service/V1/Data/Shipment.php index 814b6472c93..568850d4ac8 100644 --- a/app/code/Magento/Sales/Service/V1/Data/Shipment.php +++ b/app/code/Magento/Sales/Service/V1/Data/Shipment.php @@ -30,80 +30,23 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class Shipment extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const STORE_ID = 'store_id'; - - /** - * float - */ const TOTAL_WEIGHT = 'total_weight'; - - /** - * float - */ const TOTAL_QTY = 'total_qty'; - - /** - * int - */ const EMAIL_SENT = 'email_sent'; - - /** - * int - */ const ORDER_ID = 'order_id'; - - /** - * int - */ const CUSTOMER_ID = 'customer_id'; - - /** - * int - */ const SHIPPING_ADDRESS_ID = 'shipping_address_id'; - - /** - * int - */ const BILLING_ADDRESS_ID = 'billing_address_id'; - - /** - * int - */ const SHIPMENT_STATUS = 'shipment_status'; - - /** - * string - */ const INCREMENT_ID = 'increment_id'; - - /** - * string - */ const CREATED_AT = 'created_at'; - - /** - * string - */ const UPDATED_AT = 'updated_at'; - - /** - * string - */ const PACKAGES = 'packages'; - - /** - * mediumblob - */ const SHIPPING_LABEL = 'shipping_label'; + const ITEMS = 'items'; + const TRACKS = 'tracks'; /** * Returns billing_address_id @@ -254,4 +197,24 @@ class Shipment extends DataObject { return $this->_get(self::UPDATED_AT); } + + /** + * Returns items + * + * @return \Magento\Sales\Service\V1\Data\ShipmentItem[] + */ + public function getItems() + { + return (array)$this->_get(self::ITEMS); + } + + /** + * Returns tracks + * + * @return \Magento\Sales\Service\V1\Data\ShipmentTrack[] + */ + public function getTracks() + { + return (array)$this->_get(self::TRACKS); + } } diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentConverter.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentConverter.php new file mode 100644 index 00000000000..71b302938be --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentConverter.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Data; + +/** + * Class ShipmentConverter + * + * @package Magento\Sales\Service\V1\Data + */ +class ShipmentConverter +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader + */ + protected $shipmentLoader; + + /** + * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader + */ + public function __construct(\Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader) + { + $this->shipmentLoader = $shipmentLoader; + } + + /** + * @param Shipment $dataObject + * @return \Magento\Sales\Model\Order\Shipment + * @throws \Exception + */ + public function getModel(Shipment $dataObject) + { + $this->shipmentLoader->setOrderId($dataObject->getOrderId()); + $this->shipmentLoader->setShipmentId($dataObject->getEntityId()); + + $items = []; + foreach ($dataObject->getItems() as $item) { + $items[$item->getOrderItemId()] = $item->getQty(); + } + $shipmentItems = ['items' => $items]; + $this->shipmentLoader->setShipment($shipmentItems); + $this->shipmentLoader->setTracking($dataObject->getTracks()); + return $this->shipmentLoader->load(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php index 4c5eb9f556a..34d4f97f21f 100644 --- a/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php @@ -30,65 +30,17 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; */ class ShipmentItem extends DataObject { - - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const PARENT_ID = 'parent_id'; - - /** - * float - */ const ROW_TOTAL = 'row_total'; - - /** - * float - */ const PRICE = 'price'; - - /** - * float - */ const WEIGHT = 'weight'; - - /** - * float - */ const QTY = 'qty'; - - /** - * int - */ const PRODUCT_ID = 'product_id'; - - /** - * int - */ const ORDER_ITEM_ID = 'order_item_id'; - - /** - * string - */ const ADDITIONAL_DATA = 'additional_data'; - - /** - * string - */ const DESCRIPTION = 'description'; - - /** - * string - */ const NAME = 'name'; - - /** - * string - */ const SKU = 'sku'; /** diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentMapper.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentMapper.php new file mode 100644 index 00000000000..0739c5aafa3 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentMapper.php @@ -0,0 +1,89 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Data; + +/** + * Class ShipmentMapper + */ +class ShipmentMapper +{ + /** + * @param ShipmentBuilder $shipmentBuilder + * @param ShipmentItemMapper $shipmentItemMapper + * @param ShipmentTrackMapper $shipmentTrackMapper + */ + public function __construct( + ShipmentBuilder $shipmentBuilder, + ShipmentItemMapper $shipmentItemMapper, + ShipmentTrackMapper $shipmentTrackMapper + ) { + $this->shipmentBuilder = $shipmentBuilder; + $this->shipmentItemMapper = $shipmentItemMapper; + $this->shipmentTrackMapper = $shipmentTrackMapper; + } + + /** + * Returns array of items + * + * @param \Magento\Sales\Model\Order\Shipment $object + * @return ShipmentItem[] + */ + protected function getItems(\Magento\Sales\Model\Order\Shipment $object) + { + $items = []; + foreach ($object->getItemsCollection() as $item) { + $items[] = $this->shipmentItemMapper->extractDto($item); + } + return $items; + } + + /** + * Returns array of tracks + * + * @param \Magento\Sales\Model\Order\Shipment $object + * @return ShipmentTrack[] + */ + protected function getTracks(\Magento\Sales\Model\Order\Shipment $object) + { + $items = []; + foreach ($object->getTracksCollection() as $item) { + $items[] = $this->shipmentTrackMapper->extractDto($item); + } + return $items; + } + + /** + * @param \Magento\Sales\Model\Order\Shipment $object + * @return \Magento\Sales\Service\V1\Data\Shipment + */ + public function extractDto(\Magento\Sales\Model\Order\Shipment $object) + { + $this->shipmentBuilder->populateWithArray($object->getData()); + $this->shipmentBuilder->setItems($this->getItems($object)); + $this->shipmentBuilder->setTracks($this->getTracks($object)); + $this->shipmentBuilder->setPackages(serialize($object->getPackages())); + return $this->shipmentBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php index 5038db1869f..aeb63bcb0fd 100644 --- a/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php @@ -31,59 +31,16 @@ use Magento\Framework\Service\Data\AbstractObject as DataObject; class ShipmentTrack extends DataObject { - /** - * int - */ const ENTITY_ID = 'entity_id'; - - /** - * int - */ const PARENT_ID = 'parent_id'; - - /** - * float - */ const WEIGHT = 'weight'; - - /** - * float - */ const QTY = 'qty'; - - /** - * int - */ const ORDER_ID = 'order_id'; - - /** - * string - */ const TRACK_NUMBER = 'track_number'; - - /** - * string - */ const DESCRIPTION = 'description'; - - /** - * string - */ const TITLE = 'title'; - - /** - * string - */ const CARRIER_CODE = 'carrier_code'; - - /** - * string - */ const CREATED_AT = 'created_at'; - - /** - * string - */ const UPDATED_AT = 'updated_at'; /** diff --git a/app/code/Magento/Sales/Service/V1/InvoiceRead.php b/app/code/Magento/Sales/Service/V1/InvoiceRead.php new file mode 100644 index 00000000000..a890060aa7f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/InvoiceRead.php @@ -0,0 +1,98 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\InvoiceGet; +use Magento\Sales\Service\V1\Action\InvoiceList; +use Magento\Sales\Service\V1\Action\InvoiceCommentsList; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class InvoiceRead + */ +class InvoiceRead implements InvoiceReadInterface +{ + /** + * @var InvoiceGet + */ + protected $invoiceGet; + + /** + * @var InvoiceList + */ + protected $invoiceList; + + /** + * @var InvoiceCommentsList + */ + protected $invoiceCommentsList; + + /** + * @var InvoiceGetStatus + */ + protected $invoiceGetStatus; + + /** + * @param InvoiceGet $invoiceGet + * @param InvoiceList $invoiceList + * @param InvoiceCommentsList $invoiceCommentsList + */ + public function __construct( + InvoiceGet $invoiceGet, + InvoiceList $invoiceList, + InvoiceCommentsList $invoiceCommentsList + ) { + $this->invoiceGet = $invoiceGet; + $this->invoiceList = $invoiceList; + $this->invoiceCommentsList = $invoiceCommentsList; + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Invoice + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id) + { + return $this->invoiceGet->invoke($id); + } + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria) + { + return $this->invoiceList->invoke($searchCriteria); + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id) + { + return $this->invoiceCommentsList->invoke($id); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderGetInterface.php b/app/code/Magento/Sales/Service/V1/InvoiceReadInterface.php similarity index 66% rename from app/code/Magento/Sales/Service/V1/OrderGetInterface.php rename to app/code/Magento/Sales/Service/V1/InvoiceReadInterface.php index edc166d4782..b566d1be23c 100644 --- a/app/code/Magento/Sales/Service/V1/OrderGetInterface.php +++ b/app/code/Magento/Sales/Service/V1/InvoiceReadInterface.php @@ -23,17 +23,26 @@ */ namespace Magento\Sales\Service\V1; -/** - * Interface OrderGetInterface - */ -interface OrderGetInterface +use Magento\Framework\Service\V1\Data\SearchCriteria; + +interface InvoiceReadInterface { /** - * Invoke getOrder service - * * @param int $id - * @return \Magento\Sales\Service\V1\Data\Order + * @return \Magento\Sales\Service\V1\Data\Invoice * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function invoke($id); + public function get($id); + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria); + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id); } diff --git a/app/code/Magento/Sales/Service/V1/InvoiceWrite.php b/app/code/Magento/Sales/Service/V1/InvoiceWrite.php new file mode 100644 index 00000000000..4bd1c81a1da --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/InvoiceWrite.php @@ -0,0 +1,132 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\InvoiceAddComment; +use Magento\Sales\Service\V1\Action\InvoiceVoid; +use Magento\Sales\Service\V1\Action\InvoiceEmail; +use Magento\Sales\Service\V1\Action\InvoiceCapture; +use Magento\Sales\Service\V1\Action\InvoiceCreate; +use Magento\Sales\Service\V1\Data\Comment; + +/** + * Class InvoiceWrite + */ +class InvoiceWrite implements InvoiceWriteInterface +{ + /** + * @var InvoiceAddComment + */ + protected $invoiceAddComment; + + /** + * @var InvoiceVoid + */ + protected $invoiceVoid; + + /** + * @var InvoiceEmail + */ + protected $invoiceEmail; + + /** + * @var InvoiceCapture + */ + protected $invoiceCapture; + + /** + * @var InvoiceCreate + */ + protected $invoiceCreate; + + /** + * @param InvoiceAddComment $invoiceAddComment + * @param InvoiceVoid $invoiceVoid + * @param InvoiceEmail $invoiceEmail + * @param InvoiceCapture $invoiceCapture + * @param InvoiceCreate $invoiceCreate + */ + public function __construct( + InvoiceAddComment $invoiceAddComment, + InvoiceVoid $invoiceVoid, + InvoiceEmail $invoiceEmail, + InvoiceCapture $invoiceCapture, + InvoiceCreate $invoiceCreate + ) { + $this->invoiceAddComment = $invoiceAddComment; + $this->invoiceVoid = $invoiceVoid; + $this->invoiceEmail = $invoiceEmail; + $this->invoiceCapture = $invoiceCapture; + $this->invoiceCreate = $invoiceCreate; + } + + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment) + { + return $this->invoiceAddComment->invoke($comment); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function void($id) + { + return $this->invoiceVoid->invoke($id); + } + + /** + * @param int $id + * @return bool + */ + public function email($id) + { + return $this->invoiceEmail->invoke($id); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function capture($id) + { + return $this->invoiceCapture->invoke($id); + } + + /** + * @param \Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject + * @return bool + * @throws \Exception + */ + public function create(\Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject) + { + return $this->invoiceCreate->invoke($invoiceDataObject); + } +} diff --git a/app/code/Magento/Sales/Service/V1/InvoiceWriteInterface.php b/app/code/Magento/Sales/Service/V1/InvoiceWriteInterface.php new file mode 100644 index 00000000000..c0783c9add6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/InvoiceWriteInterface.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Data\Comment; + +interface InvoiceWriteInterface +{ + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function void($id); + + /** + * @param int $id + * @return bool + */ + public function email($id); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function capture($id); + + /** + * @param \Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject + * @return bool + * @throws \Exception + */ + public function create(\Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderRead.php b/app/code/Magento/Sales/Service/V1/OrderRead.php new file mode 100644 index 00000000000..dc3a72c3d29 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderRead.php @@ -0,0 +1,112 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\OrderGet; +use Magento\Sales\Service\V1\Action\OrderList; +use Magento\Sales\Service\V1\Action\OrderCommentsList; +use Magento\Sales\Service\V1\Action\OrderGetStatus; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class OrderRead + */ +class OrderRead implements OrderReadInterface +{ + /** + * @var OrderGet + */ + protected $orderGet; + + /** + * @var OrderList + */ + protected $orderList; + + /** + * @var OrderCommentsList + */ + protected $orderCommentsList; + + /** + * @var OrderGetStatus + */ + protected $orderGetStatus; + + /** + * @param OrderGet $orderGet + * @param OrderList $orderList + * @param OrderCommentsList $orderCommentsList + * @param OrderGetStatus $orderGetStatus + */ + public function __construct( + OrderGet $orderGet, + OrderList $orderList, + OrderCommentsList $orderCommentsList, + OrderGetStatus $orderGetStatus + ) { + $this->orderGet = $orderGet; + $this->orderList = $orderList; + $this->orderCommentsList = $orderCommentsList; + $this->orderGetStatus = $orderGetStatus; + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Order + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id) + { + return $this->orderGet->invoke($id); + } + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Sales\Service\V1\Data\OrderSearchResults + */ + public function search(SearchCriteria $searchCriteria) + { + return $this->orderList->invoke($searchCriteria); + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResults + */ + public function commentsList($id) + { + return $this->orderCommentsList->invoke($id); + } + + /** + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getStatus($id) + { + return $this->orderGetStatus->invoke($id); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php b/app/code/Magento/Sales/Service/V1/OrderReadInterface.php similarity index 60% rename from app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php rename to app/code/Magento/Sales/Service/V1/OrderReadInterface.php index 64de1d90067..4862680cfee 100644 --- a/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php +++ b/app/code/Magento/Sales/Service/V1/OrderReadInterface.php @@ -23,16 +23,33 @@ */ namespace Magento\Sales\Service\V1; -/** - * Interface OrderCommentsListInterface - */ -interface OrderCommentsListInterface +use Magento\Framework\Service\V1\Data\SearchCriteria; + +interface OrderReadInterface { /** - * Invoke OrderCommentsList service - * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Order + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id); + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Sales\Service\V1\Data\OrderSearchResults + */ + public function search(SearchCriteria $searchCriteria); + + /** * @param int $id * @return \Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResults */ - public function invoke($id); + public function commentsList($id); + + /** + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getStatus($id); } diff --git a/app/code/Magento/Sales/Service/V1/OrderWrite.php b/app/code/Magento/Sales/Service/V1/OrderWrite.php new file mode 100644 index 00000000000..23ccae33c23 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderWrite.php @@ -0,0 +1,173 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\OrderAddressUpdate; +use Magento\Sales\Service\V1\Action\OrderCancel; +use Magento\Sales\Service\V1\Action\OrderEmail; +use Magento\Sales\Service\V1\Action\OrderHold; +use Magento\Sales\Service\V1\Action\OrderUnHold; +use Magento\Sales\Service\V1\Action\OrderStatusHistoryAdd; +use Magento\Sales\Service\V1\Action\OrderCreate; +use Magento\Sales\Service\V1\Data\Order; +use Magento\Sales\Service\V1\Data\OrderAddress; +use Magento\Sales\Service\V1\Data\OrderStatusHistory; + +/** + * Class OrderWrite + */ +class OrderWrite implements OrderWriteInterface +{ + /** + * @var OrderAddressUpdate + */ + protected $orderAddressUpdate; + + /** + * @var OrderCancel + */ + protected $orderCancel; + + /** + * @var OrderEmail + */ + protected $orderEmail; + + /** + * @var OrderHold + */ + protected $orderHold; + + /** + * @var OrderUnHold + */ + protected $orderUnHold; + + /** + * @var OrderStatusHistoryAdd + */ + protected $orderStatusHistoryAdd; + + /** + * @var OrderCreate + */ + protected $orderCreate; + + /** + * @param OrderAddressUpdate $orderAddressUpdate + * @param OrderCancel $orderCancel + * @param OrderEmail $orderEmail + * @param OrderHold $orderHold + * @param OrderUnHold $orderUnHold + * @param OrderStatusHistoryAdd $orderStatusHistoryAdd + * @param OrderCreate $orderCreate + */ + public function __construct( + OrderAddressUpdate $orderAddressUpdate, + OrderCancel $orderCancel, + OrderEmail $orderEmail, + OrderHold $orderHold, + OrderUnHold $orderUnHold, + OrderStatusHistoryAdd $orderStatusHistoryAdd, + OrderCreate $orderCreate + ) { + $this->orderAddressUpdate = $orderAddressUpdate; + $this->orderCancel = $orderCancel; + $this->orderEmail = $orderEmail; + $this->orderHold = $orderHold; + $this->orderUnHold = $orderUnHold; + $this->orderStatusHistoryAdd = $orderStatusHistoryAdd; + $this->orderCreate = $orderCreate; + } + + /** + * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress + * @return bool + */ + public function addressUpdate(OrderAddress $orderAddress) + { + return $this->orderAddressUpdate->invoke($orderAddress); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function cancel($id) + { + return $this->orderCancel->invoke($id); + } + + /** + * @param int $id + * @return bool + */ + public function email($id) + { + return $this->orderEmail->invoke($id); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function hold($id) + { + return $this->orderHold->invoke($id); + } + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function unHold($id) + { + return $this->orderUnHold->invoke($id); + } + + /** + * @param int $id + * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory + * @return bool + */ + public function statusHistoryAdd($id, OrderStatusHistory $statusHistory) + { + return $this->orderStatusHistoryAdd->invoke($id, $statusHistory); + } + + /** + * Create an order + * + * @param Order $orderDataObject + * @return bool + * @throws \Exception + */ + public function create(Order $orderDataObject) + { + return $this->orderCreate->invoke($orderDataObject); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderWriteInterface.php b/app/code/Magento/Sales/Service/V1/OrderWriteInterface.php new file mode 100644 index 00000000000..69b3c8c8398 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderWriteInterface.php @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Data\OrderAddress; +use Magento\Sales\Service\V1\Data\OrderStatusHistory; + +interface OrderWriteInterface +{ + /** + * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress + * @return bool + */ + public function addressUpdate(OrderAddress $orderAddress); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function cancel($id); + + /** + * @param int $id + * @return bool + */ + public function email($id); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function hold($id); + + /** + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function unHold($id); + + /** + * @param int $id + * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory + * @return bool + */ + public function statusHistoryAdd($id, OrderStatusHistory $statusHistory); + + /** + * Create an order + * + * @param \Magento\Sales\Service\V1\Data\Order $orderDataObject + * @return bool + * @throws \Exception + */ + public function create(\Magento\Sales\Service\V1\Data\Order $orderDataObject); +} diff --git a/app/code/Magento/Sales/Service/V1/ShipmentRead.php b/app/code/Magento/Sales/Service/V1/ShipmentRead.php new file mode 100644 index 00000000000..333cc714834 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/ShipmentRead.php @@ -0,0 +1,112 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\ShipmentGet; +use Magento\Sales\Service\V1\Action\ShipmentList; +use Magento\Sales\Service\V1\Action\ShipmentCommentsList; +use Magento\Sales\Service\V1\Action\ShipmentLabelGet; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class ShipmentRead + */ +class ShipmentRead implements ShipmentReadInterface +{ + /** + * @var ShipmentGet + */ + protected $shipmentGet; + + /** + * @var ShipmentList + */ + protected $shipmentList; + + /** + * @var ShipmentCommentsList + */ + protected $shipmentCommentsList; + + /** + * @var ShipmentLabelGet + */ + protected $shipmentLabelGet; + + /** + * @param ShipmentGet $shipmentGet + * @param ShipmentList $shipmentList + * @param ShipmentCommentsList $shipmentCommentsList + * @param ShipmentLabelGet $shipmentLabelGet + */ + public function __construct( + ShipmentGet $shipmentGet, + ShipmentList $shipmentList, + ShipmentCommentsList $shipmentCommentsList, + ShipmentLabelGet $shipmentLabelGet + ) { + $this->shipmentGet = $shipmentGet; + $this->shipmentList = $shipmentList; + $this->shipmentCommentsList = $shipmentCommentsList; + $this->shipmentLabelGet = $shipmentLabelGet; + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Shipment + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id) + { + return $this->shipmentGet->invoke($id); + } + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria) + { + return $this->shipmentList->invoke($searchCriteria); + } + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id) + { + return $this->shipmentCommentsList->invoke($id); + } + + /** + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getLabel($id) + { + return $this->shipmentLabelGet->invoke($id); + } +} diff --git a/app/code/Magento/Sales/Service/V1/ShipmentReadInterface.php b/app/code/Magento/Sales/Service/V1/ShipmentReadInterface.php new file mode 100644 index 00000000000..c4da5bab4cf --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/ShipmentReadInterface.php @@ -0,0 +1,55 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Framework\Service\V1\Data\SearchCriteria; + +interface ShipmentReadInterface +{ + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Shipment + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id); + + /** + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function search(SearchCriteria $searchCriteria); + + /** + * @param int $id + * @return \Magento\Sales\Service\V1\Data\CommentSearchResults + */ + public function commentsList($id); + + /** + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getLabel($id); +} diff --git a/app/code/Magento/Sales/Service/V1/ShipmentWrite.php b/app/code/Magento/Sales/Service/V1/ShipmentWrite.php new file mode 100644 index 00000000000..4366adb945d --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/ShipmentWrite.php @@ -0,0 +1,133 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Action\ShipmentAddTrack; +use Magento\Sales\Service\V1\Action\ShipmentRemoveTrack; +use Magento\Sales\Service\V1\Action\ShipmentEmail; +use Magento\Sales\Service\V1\Action\ShipmentAddComment; +use Magento\Sales\Service\V1\Action\ShipmentCreate; +use Magento\Sales\Service\V1\Data\ShipmentTrack; +use Magento\Sales\Service\V1\Data\Comment; + +/** + * Class ShipmentWrite + */ +class ShipmentWrite implements ShipmentWriteInterface +{ + /** + * @var ShipmentAddTrack + */ + protected $shipmentAddTrack; + + /** + * @var ShipmentRemoveTrack + */ + protected $shipmentRemoveTrack; + + /** + * @var ShipmentEmail + */ + protected $shipmentEmail; + + /** + * @var ShipmentAddComment + */ + protected $shipmentAddComment; + + /** + * @var ShipmentCreate + */ + protected $shipmentCreate; + + /** + * @param ShipmentAddTrack $shipmentAddTrack + * @param ShipmentRemoveTrack $shipmentRemoveTrack + * @param ShipmentEmail $shipmentEmail + * @param ShipmentAddComment $shipmentAddComment + * @param ShipmentCreate $shipmentCreate + */ + public function __construct( + ShipmentAddTrack $shipmentAddTrack, + ShipmentRemoveTrack $shipmentRemoveTrack, + ShipmentEmail $shipmentEmail, + ShipmentAddComment $shipmentAddComment, + ShipmentCreate $shipmentCreate + ) { + $this->shipmentAddTrack = $shipmentAddTrack; + $this->shipmentRemoveTrack = $shipmentRemoveTrack; + $this->shipmentEmail = $shipmentEmail; + $this->shipmentAddComment = $shipmentAddComment; + $this->shipmentCreate = $shipmentCreate; + } + + /** + * @param \Magento\Sales\Service\V1\Data\ShipmentTrack $track + * @return bool + * @throws \Exception + */ + public function addTrack(ShipmentTrack $track) + { + return $this->shipmentAddTrack->invoke($track); + } + + /** + * @param int $id + * @return bool + * @throws \Exception + */ + public function removeTrack($id) + { + return $this->shipmentRemoveTrack->invoke($id); + } + + /** + * @param int $id + * @return bool + */ + public function email($id) + { + return $this->shipmentEmail->invoke($id); + } + + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment) + { + return $this->shipmentAddComment->invoke($comment); + } + + /** + * @param \Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject + * @return bool + * @throws \Exception + */ + public function create(\Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject) + { + return $this->shipmentCreate->invoke($shipmentDataObject); + } +} diff --git a/app/code/Magento/Sales/Service/V1/ShipmentWriteInterface.php b/app/code/Magento/Sales/Service/V1/ShipmentWriteInterface.php new file mode 100644 index 00000000000..967ec348ffc --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/ShipmentWriteInterface.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +use Magento\Sales\Service\V1\Data\ShipmentTrack; +use Magento\Sales\Service\V1\Data\Comment; + +interface ShipmentWriteInterface +{ + /** + * @param \Magento\Sales\Service\V1\Data\ShipmentTrack $track + * @return bool + * @throws \Exception + */ + public function addTrack(ShipmentTrack $track); + + /** + * @param int $id + * @return bool + * @throws \Exception + */ + public function removeTrack($id); + + /** + * @param int $id + * @return bool + */ + public function email($id); + + /** + * @param \Magento\Sales\Service\V1\Data\Comment $comment + * @return bool + * @throws \Exception + */ + public function addComment(Comment $comment); + + /** + * @param \Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject + * @return bool + * @throws \Exception + */ + public function create(\Magento\Sales\Service\V1\Data\Shipment $shipmentDataObject); +} diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index 3ee49b89cbf..1fe0ee1dc1c 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,30 +3,30 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-sales-rule": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-gift-message": "0.1.0-alpha92", - "magento/module-reports": "0.1.0-alpha92", - "magento/module-weee": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-wishlist": "0.1.0-alpha92", - "magento/module-email": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-sales-rule": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-gift-message": "0.1.0-alpha93", + "magento/module-reports": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-wishlist": "0.1.0-alpha93", + "magento/module-email": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 991b5f78ecf..00410f1ef12 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -24,16 +24,14 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Sales\Service\V1\OrderGetInterface" type="Magento\Sales\Service\V1\OrderGet"/> - <preference for="Magento\Sales\Service\V1\OrderCancelInterface" type="Magento\Sales\Service\V1\OrderCancel"/> - <preference for="Magento\Sales\Service\V1\OrderListInterface" type="Magento\Sales\Service\V1\OrderList"/> - <preference for="Magento\Sales\Service\V1\OrderGetStatusInterface" type="Magento\Sales\Service\V1\OrderGetStatus"/> - <preference for="Magento\Sales\Service\V1\OrderHoldInterface" type="Magento\Sales\Service\V1\OrderHold"/> - <preference for="Magento\Sales\Service\V1\OrderUnHoldInterface" type="Magento\Sales\Service\V1\OrderUnHold"/> - <preference for="Magento\Sales\Service\V1\OrderNotifyUserInterface" type="Magento\Sales\Service\V1\OrderNotifyUser"/> - <preference for="Magento\Sales\Service\V1\OrderStatusHistoryAddInterface" type="Magento\Sales\Service\V1\OrderStatusHistoryAdd"/> - <preference for="Magento\Sales\Service\V1\OrderCommentsListInterface" type="Magento\Sales\Service\V1\OrderCommentsList"/> - <preference for="Magento\Sales\Service\V1\OrderAddressUpdateInterface" type="Magento\Sales\Service\V1\OrderAddressUpdate"/> + <preference for="Magento\Sales\Service\V1\OrderReadInterface" type="Magento\Sales\Service\V1\OrderRead"/> + <preference for="Magento\Sales\Service\V1\OrderWriteInterface" type="Magento\Sales\Service\V1\OrderWrite"/> + <preference for="Magento\Sales\Service\V1\InvoiceReadInterface" type="Magento\Sales\Service\V1\InvoiceRead"/> + <preference for="Magento\Sales\Service\V1\InvoiceWriteInterface" type="Magento\Sales\Service\V1\InvoiceWrite"/> + <preference for="Magento\Sales\Service\V1\CreditmemoReadInterface" type="Magento\Sales\Service\V1\CreditmemoRead"/> + <preference for="Magento\Sales\Service\V1\CreditmemoWriteInterface" type="Magento\Sales\Service\V1\CreditmemoWrite"/> + <preference for="Magento\Sales\Service\V1\ShipmentReadInterface" type="Magento\Sales\Service\V1\ShipmentRead"/> + <preference for="Magento\Sales\Service\V1\ShipmentWriteInterface" type="Magento\Sales\Service\V1\ShipmentWrite"/> <type name="Magento\Sales\Model\Resource\Report" shared="false"/> <type name="Magento\Sales\Model\Order\Pdf\Config\Reader"> <arguments> diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index 0045564ebfc..60586c7d3b5 100644 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -47,10 +47,10 @@ <module name="Magento_Tax"/> <module name="Magento_GiftMessage"/> <module name="Magento_Reports"/> - <module name="Magento_Weee"/> <module name="Magento_CatalogInventory"/> <module name="Magento_Wishlist"/> <module name="Magento_Email"/> + <module name="Magento_Shipping"/> </depends> </module> </config> diff --git a/app/code/Magento/Sales/etc/webapi.xml b/app/code/Magento/Sales/etc/webapi.xml index fa435cb99b5..a0f4bafce81 100644 --- a/app/code/Magento/Sales/etc/webapi.xml +++ b/app/code/Magento/Sales/etc/webapi.xml @@ -25,62 +25,212 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/orders/:id" method="GET"> - <service class="Magento\Sales\Service\V1\OrderGetInterface" method="invoke"/> + <route url="/V1/order/:id" method="GET"> + <service class="Magento\Sales\Service\V1\OrderReadInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/cancellation" method="POST"> - <service class="Magento\Sales\Service\V1\OrderCancelInterface" method="invoke"/> + <route url="/V1/orders" method="PUT"> + <service class="Magento\Sales\Service\V1\OrderReadInterface" method="search"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders" method="GET"> - <service class="Magento\Sales\Service\V1\OrderListInterface" method="invoke"/> + <route url="/V1/order/:id/status" method="GET"> + <service class="Magento\Sales\Service\V1\OrderReadInterface" method="getStatus"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/status" method="GET"> - <service class="Magento\Sales\Service\V1\OrderGetStatusInterface" method="invoke"/> + <route url="/V1/order/:id/cancel" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="cancel"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/emails" method="POST"> - <service class="Magento\Sales\Service\V1\OrderNotifyUserInterface" method="invoke"/> + <route url="/V1/order/:id/email" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="email"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/hold" method="POST"> - <service class="Magento\Sales\Service\V1\OrderHoldInterface" method="invoke"/> + <route url="/V1/order/:id/hold" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="hold"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/unhold" method="POST"> - <service class="Magento\Sales\Service\V1\OrderUnHoldInterface" method="invoke"/> + <route url="/V1/order/:id/unhold" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="unHold"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/comment" method="POST"> - <service class="Magento\Sales\Service\V1\OrderStatusHistoryAddInterface" method="invoke"/> + <route url="/V1/order/:id/comment" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="statusHistoryAdd"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id/comments" method="GET"> - <service class="Magento\Sales\Service\V1\OrderCommentsListInterface" method="invoke"/> + <route url="/V1/order/:id/comments" method="GET"> + <service class="Magento\Sales\Service\V1\OrderReadInterface" method="commentsList"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/orders/:id" method="PUT"> - <service class="Magento\Sales\Service\V1\OrderAddressUpdateInterface" method="invoke"/> + <route url="/V1/order/:id" method="PUT"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="addressUpdate"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/:id" method="GET"> + <service class="Magento\Sales\Service\V1\InvoiceReadInterface" method="get"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoices" method="PUT"> + <service class="Magento\Sales\Service\V1\InvoiceReadInterface" method="search"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/:id/comments" method="GET"> + <service class="Magento\Sales\Service\V1\InvoiceReadInterface" method="commentsList"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/:id/email" method="POST"> + <service class="Magento\Sales\Service\V1\InvoiceWriteInterface" method="email"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/:id/void" method="POST"> + <service class="Magento\Sales\Service\V1\InvoiceWriteInterface" method="void"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/:id/capture" method="POST"> + <service class="Magento\Sales\Service\V1\InvoiceWriteInterface" method="capture"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/comment" method="POST"> + <service class="Magento\Sales\Service\V1\InvoiceWriteInterface" method="addComment"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/invoice/" method="POST"> + <service class="Magento\Sales\Service\V1\InvoiceWriteInterface" method="create"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo/:id/comments" method="GET"> + <service class="Magento\Sales\Service\V1\CreditmemoReadInterface" method="commentsList"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemos" method="PUT"> + <service class="Magento\Sales\Service\V1\CreditmemoReadInterface" method="search"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo/:id" method="GET"> + <service class="Magento\Sales\Service\V1\CreditmemoReadInterface" method="get"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo/:id" method="PUT"> + <service class="Magento\Sales\Service\V1\CreditmemoWriteInterface" method="cancel"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo/:id/email" method="POST"> + <service class="Magento\Sales\Service\V1\CreditmemoWriteInterface" method="email"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo/comment" method="POST"> + <service class="Magento\Sales\Service\V1\CreditmemoWriteInterface" method="addComment"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/creditmemo" method="POST"> + <service class="Magento\Sales\Service\V1\CreditmemoWriteInterface" method="create"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/:id" method="GET"> + <service class="Magento\Sales\Service\V1\ShipmentReadInterface" method="get"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipments" method="PUT"> + <service class="Magento\Sales\Service\V1\ShipmentReadInterface" method="search"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/:id/comments" method="GET"> + <service class="Magento\Sales\Service\V1\ShipmentReadInterface" method="commentsList"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/comment" method="POST"> + <service class="Magento\Sales\Service\V1\ShipmentWriteInterface" method="addComment"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/:id/email" method="POST"> + <service class="Magento\Sales\Service\V1\ShipmentWriteInterface" method="email"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/track" method="POST"> + <service class="Magento\Sales\Service\V1\ShipmentWriteInterface" method="addTrack"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/track/:id" method="DELETE"> + <service class="Magento\Sales\Service\V1\ShipmentWriteInterface" method="removeTrack"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/" method="POST"> + <service class="Magento\Sales\Service\V1\ShipmentWriteInterface" method="create"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/shipment/:id/label" method="GET"> + <service class="Magento\Sales\Service\V1\ShipmentReadInterface" method="getLabel"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/order/" method="POST"> + <service class="Magento\Sales\Service\V1\OrderWriteInterface" method="create"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_item_price.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_item_price.xml new file mode 100644 index 00000000000..f123922450f --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_creditmemo_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="creditmemo_items"> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_item_price.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_item_price.xml new file mode 100644 index 00000000000..cfb6efa58b2 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_invoice_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="invoice_items"> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml index 269e8ff39a8..c1b114f7706 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_index.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_create_customer_block"/> + <update handle="sales_order_create_item_price"/> <referenceBlock name="page-title"> <action method="setTitleId"> <argument translate="true" name="id" xsi:type="string">order-header</argument> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_item_price.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_item_price.xml new file mode 100644 index 00000000000..3d424396f09 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_item_price.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" name="item_unit_price" template="order/create/items/price/unit.phtml"/> + <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" name="item_row_total" template="order/create/items/price/row.phtml"/> + <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" name="item_row_total_with_discount" template="order/create/items/price/total.phtml"/> +</page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml index 415af2d5feb..a1f6934d5e6 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_data.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_create_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Create\Data" template="order/create/data.phtml" name="data"> <block class="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar" template="order/create/sidebar.phtml" name="sidebar"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_items.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_items.xml index 1f61366e304..bdd1f9a524c 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_items.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_create_load_block_items.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_create_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items" template="order/create/items.phtml" name="items"> <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" template="order/create/items/grid.phtml" name="items_grid"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml index b62eddc80a2..3d65741190e 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create" name="sales_creditmemo_create"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Form" name="form" template="order/creditmemo/create/form.phtml"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml index 94b3359c567..30a90f8e8ca 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_item_price"/> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items" name="order_items" template="order/creditmemo/create/items.phtml"> <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/creditmemo/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml index f6eaf4b79f8..c9b7484363c 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_creditmemo_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\View" name="sales_creditmemo_view"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Form" name="form" template="order/creditmemo/view/form.phtml"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml index dca3b3ec0e1..16e79c7da62 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create" name="sales_invoice_create"> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Form" name="form" template="order/invoice/create/form.phtml"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml index ef2a8eb5420..b09ec778cf5 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_order_item_price"/> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Items" name="order_items" template="order/invoice/create/items.phtml"> <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/invoice/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml index 363bb8c0470..ffd58e6da95 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml @@ -24,6 +24,7 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <update handle="sales_invoice_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\View" name="sales_invoice_view"> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\View\Form" name="form" template="order/invoice/view/form.phtml"> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_item_price.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..d313fd7d0c9 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="order_items"> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml index 6b67d7a6f00..cde71209712 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml @@ -38,6 +38,7 @@ <update handle="sales_order_shipment_grid_block"/> <update handle="sales_order_transactions_grid_block"/> <update handle="sales_order_creditmemo_grid_block"/> + <update handle="sales_order_item_price"/> <referenceContainer name="left"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tabs" name="sales_order_tabs"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Info" name="order_tab_info" template="order/view/tab/info.phtml"> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/price/row.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/price/row.phtml new file mode 100644 index 00000000000..bcf5435d382 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/price/row.phtml @@ -0,0 +1,33 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $this */ + +$_item = $this->getItem(); +?> + +<div class="price-excl-tax"> + <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> +</div> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/price/total.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/price/total.phtml new file mode 100644 index 00000000000..ed7c20dd271 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/price/total.phtml @@ -0,0 +1,31 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $this */ + +$_item = $this->getItem(); +?> + +<?php echo $this->displayPrices($this->getBaseTotalAmount($_item), $this->getTotalAmount($_item)) ?> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/price/unit.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/price/unit.phtml new file mode 100644 index 00000000000..7fe062c688d --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/price/unit.phtml @@ -0,0 +1,32 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $this */ + +$_item = $this->getItem(); +?> +<div class="price-excl-tax"> +<?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> +</div> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml index 1552de2111e..14910fda331 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml @@ -22,8 +22,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/** @var $_weeeHelper \Magento\Weee\Helper\Data */ -$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); ?> <?php /** @@ -110,80 +108,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); </td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->formatPrice($_item->getCalculationPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice($_incl+$_weeeHelper->getWeeeTaxInclTax($_item)); ?> - <?php else: ?> - <?php echo $this->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->formatPrice($_incl+$_weeeHelper->getWeeeTaxInclTax($_item)); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemUnitPriceHtml($_item); ?> <?php $_isCustomPrice = $this->usedCustomPriceForItem($_item) ?> <?php if($_tier = $this->getTierHtml($_item)): ?> @@ -202,80 +127,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); </td> <td class="col-qty"><input name="item[<?php echo $_item->getId() ?>][qty]" class="input-text item-qty" value="<?php echo $_item->getQty()*1 ?>" maxlength="12" /></td> <td class="col-subtotal col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?> - <?php else: ?> - <?php echo $this->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - + <?php echo $this->getItemRowTotalHtml($_item); ?> </td> <td class="col-discount col-price"> <?php echo $this->formatPrice(-$_item->getDiscountAmount()) ?><br /> @@ -283,83 +135,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); <label for="item_use_discount_<?php echo $_item->getId() ?>" class="normal"><?php echo __('Apply') ?></label> </td> <td class="col-price col-row-subtotal"> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php $_rowTotalWithoutDiscount = $_item->getRowTotal() - $_item->getDiscountAmount(); ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice(max(0, $_rowTotalWithoutDiscount+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition())); ?> - <?php else: ?> - <?php echo $this->formatPrice(max(0, $_rowTotalWithoutDiscount)) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax($this->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices($this->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $_item->getPriceInclTax() * $_item->getQty() - $_item->getDiscountAmount(); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales')): ?> - <?php echo $this->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?> - <?php else: ?> - <?php echo $this->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales')): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - + <?php echo $this->getItemRowTotalWithDiscountHtml($_item); ?> </td> <td class="col-actions last"> <select name="item[<?php echo $_item->getId() ?>][action]" style="width:100px;"> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/row.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/row.phtml new file mode 100644 index 00000000000..4d16747f82b --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/row.phtml @@ -0,0 +1,33 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $this */ + +$_item = $this->getItem(); +?> + +<div class="price-excl-tax"> + <?php echo $this->formatPrice($_item->getRowTotal()) ?> +</div> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/total.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/total.phtml new file mode 100644 index 00000000000..f4701e720c2 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/total.phtml @@ -0,0 +1,32 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $this */ + +$_item = $this->getItem(); +?> + +<?php $_rowTotalWithoutDiscount = $_item->getRowTotal() - $_item->getDiscountAmount(); ?> +<?php echo $this->formatPrice(max(0, $_rowTotalWithoutDiscount)) ?> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/unit.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/unit.phtml new file mode 100644 index 00000000000..60e370cad57 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/price/unit.phtml @@ -0,0 +1,32 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $this */ + +$_item = $this->getItem(); +?> +<div class="price-excl-tax"> +<?php echo $this->formatPrice($_item->getCalculationPrice()) ?> +</div> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items/renderer/default.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items/renderer/default.phtml index 97ced2df7bf..979e1948ab7 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items/renderer/default.phtml @@ -22,105 +22,13 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item); ?> <tr> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'name') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> </td> <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <?php if ($this->canParentReturnToStock($_item)) : ?> @@ -138,106 +46,11 @@ <?php endif; ?> </td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> </td> <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), - $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/view/items/renderer/default.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/view/items/renderer/default.phtml index 80248c2f19c..b58a4d0e007 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/view/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/view/items/renderer/default.phtml @@ -22,210 +22,22 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $_item->setStoreId($_item->getCreditMemo()->getStoreId()) ?> <?php $this->setPriceDataObject($_item) ?> <tr> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'name') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - + <?php echo $this->getColumnHtml($_item, 'price'); ?> </td> <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), - $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/create/items/renderer/default.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/create/items/renderer/default.phtml index 658f396e069..8931ffc81a7 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/create/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/create/items/renderer/default.phtml @@ -22,103 +22,12 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item)?> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'name') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> </td> <td class="col-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <td class="col-qty-invoice"> @@ -129,100 +38,11 @@ <?php endif; ?> </td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?> - <?php endforeach; ?> - </small> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), - $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> </td> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/view/items/renderer/default.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/view/items/renderer/default.phtml index 7553d6f22c0..1f6665e4d15 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/view/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/invoice/view/items/renderer/default.phtml @@ -22,206 +22,22 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $_item->setStoreId($_item->getInvoice()->getStoreId()) ?> <?php $this->setPriceDataObject($_item) ?> <tr> <td class="col-product"><?php echo $this->getColumnHtml($_item, 'name') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales')): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedAmount(), $_incl+$_item->getWeeeTaxAppliedAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> </td> <td class="col-qty"><?php echo $_item->getQty()*1 ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <br /> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_item->getBaseWeeeTaxAppliedRowAmnt(), $_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> </td> <td class="col-tax"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-discount"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), - $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() - ) ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/view/items/renderer/default.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/view/items/renderer/default.phtml index b4a52fb282b..3b1738f84a4 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/view/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/view/items/renderer/default.phtml @@ -21,10 +21,8 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ - -/** @var $_weeeHelper \Magento\Weee\Helper\Data */ -$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); ?> +<?php /** @var $this \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $this->setPriceDataObject($_item) ?> <tr> @@ -40,202 +38,17 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); <td class="col-status"><?php echo $_item->getStatus() ?></td> <td class="col-price-original"><?php echo $this->displayPriceAttribute('original_price') ?></td> <td class="col-price"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <div class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(), - $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </div> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <div class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_weeeHelper->getBaseWeeeTaxInclTax($_item), $_incl+$_weeeHelper->getWeeeTaxInclTax($_item)); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_weeeHelper->getBaseWeeeTaxInclTax($_item), $_incl+$_weeeHelper->getWeeeTaxInclTax($_item)); ?></span> - <?php endif; ?> - <?php endif; ?> - </div> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'price'); ?> </td> <td class="col-ordered-qty"><?php echo $this->getColumnHtml($_item, 'qty') ?></td> <td class="col-subtotal"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <div class="price-excl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - <?php else: ?> - <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> - <?php - echo $this->displayPrices( - $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmnt()+$_item->getBaseWeeeTaxRowDisposition(), - $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition() - ); - ?> - </span> - <?php endif; ?> - <?php endif; ?> - </div> - <?php endif; ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <div class="price-incl-tax"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> - <span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales', $_item->getStoreId())): ?> - <?php echo $this->displayPrices($_baseIncl+$_weeeHelper->getBaseRowWeeeTaxInclTax($_item), $_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?> - <?php else: ?> - <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales', $_item->getStoreId())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales', $_item->getStoreId())): ?> - <br /><span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl+$_weeeHelper->getBaseRowWeeeTaxInclTax($_item), $_incl+$_weeeHelper->getRowWeeeTaxInclTax($_item)); ?></span> - <?php endif; ?> - <?php endif; ?> - </div> - <?php endif; ?> + <?php echo $this->getColumnHtml($_item, 'subtotal'); ?> </td> <td class="col-tax-amount"><?php echo $this->displayPriceAttribute('tax_amount') ?></td> <td class="col-tax-percent"><?php echo $this->displayTaxPercent($_item) ?></td> <td class="col-discont"><?php echo $this->displayPriceAttribute('discount_amount') ?></td> <td class="col-total last"> - <?php echo $this->displayPrices( - $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmnt() - $_item->getBaseDiscountAmount(), - $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount() - ); ?> + <?php echo $this->getColumnHtml($_item, 'total'); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_item_price.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_item_price.xml new file mode 100644 index 00000000000..e4393bdedcb --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_item_price.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="items"> + <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" name="item_price" template="email/items/price/row.phtml"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml index 8381d7f455e..5fa9abb1f69 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd" label="Email Creditmemo Items List" design_abstraction="custom"> <update handle="sales_email_order_creditmemo_renderers" /> + <update handle="sales_email_item_price" /> <block class="Magento\Sales\Block\Order\Email\Creditmemo\Items" name="items" template="email/creditmemo/items.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.creditmemo.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml" cacheable="false"> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml index 63401ce4e6d..f3f3358669e 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd" label="Email Invoice Items List" design_abstraction="custom"> <update handle="sales_email_order_invoice_renderers" /> + <update handle="sales_email_item_price" /> <block class="Magento\Sales\Block\Order\Email\Invoice\Items" name="items" template="email/invoice/items.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.invoice.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml" cacheable="false"> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml index c1c1f8ce53c..7b04f192cbb 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd" label="Email Order Items List" design_abstraction="custom"> <update handle="sales_email_order_renderers" /> + <update handle="sales_email_item_price" /> <block class="Magento\Sales\Block\Order\Email\Items" name="items" template="email/items.phtml" cacheable="false"> <block class="Magento\Framework\View\Element\RendererList" name="sales.email.order.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml index d93dfc482ba..36ab59e11d2 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml @@ -25,6 +25,7 @@ --> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_creditmemo_renderers" /> + <update handle="sales_order_item_price" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info"> <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml index 878019f482e..c845e7382d4 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml @@ -25,6 +25,7 @@ --> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_invoice_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info"> <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml index 145d7594337..f077a8e1d63 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintShipment" name="sales.order.print" template="order/print.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.renderers" as="renderer.list" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml index bdf4a55bf57..fb8835c15f0 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_creditmemo_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Creditmemo" name="sales.order.print.creditmemo" template="order/print/creditmemo.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.creditmemo.renderers" as="renderer.list"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml index e85e2125e27..2344eb29be2 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_invoice_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="sales.order.print.invoice" template="order/print/invoice.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.invoice.renderers" as="renderer.list" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml index 822d7f48a35..11efb475646 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml @@ -25,6 +25,7 @@ --> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_item_renderers"/> + <update handle="sales_order_item_price"/> <referenceContainer name="page.main.title"> <container name="order.actions.container" htmlTag="div" htmlClass="actions-toolbar order-actions-toolbar"> <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml index d9156d16f3a..0b89a18b9db 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml @@ -26,6 +26,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_creditmemo_renderers" /> <update handle="customer_account"/> + <update handle="sales_order_item_price"/> <referenceContainer name="page.main.title"> <block class="Magento\Sales\Block\Order\Info" name="order.status" template="order/order_status.phtml" /> <block class="Magento\Sales\Block\Order\Info" name="order.date" template="order/order_date.phtml" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml index e10f531f7bc..50ba2bf8de0 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml @@ -26,6 +26,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="customer_account"/> <update handle="sales_order_invoice_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="page.main.title"> <block class="Magento\Sales\Block\Order\Info" name="order.status" template="order/order_status.phtml" /> <block class="Magento\Sales\Block\Order\Info" name="order.date" template="order/order_date.phtml" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_item_price.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..b3a3d1ce78e --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_price.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="item_unit_price" template="items/price/unit.phtml"/> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="item_row_total" template="items/price/row.phtml"/> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="item_row_total_after_discount" template="items/price/total_after_discount.phtml"/> +</page> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml index 8bf5e903d19..ee9cab54d5b 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintShipment" name="sales.order.print" template="order/print.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.renderers" as="renderer.list" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml index 210ff8f7bb4..9c33b757320 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_creditmemo_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Creditmemo" name="sales.order.print.creditmemo" template="order/print/creditmemo.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.creditmemo.renderers" as="renderer.list"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml index 99b5554448b..5e4834b8d78 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml @@ -25,6 +25,7 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="sales_order_print_invoice_renderers" /> + <update handle="sales_order_item_price"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="sales.order.print.invoice" template="order/print/invoice.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.invoice.renderers" as="renderer.list" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml index d327227a921..22fe53c376d 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml @@ -26,6 +26,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <update handle="customer_account"/> <update handle="sales_order_item_renderers"/> + <update handle="sales_order_item_price"/> <referenceContainer name="page.main.title"> <block class="Magento\Sales\Block\Order\Info" name="order.status" template="order/order_status.phtml" /> <block class="Magento\Sales\Block\Order\Info" name="order.date" template="order/order_date.phtml" /> diff --git a/app/code/Magento/Sales/view/frontend/templates/email/items/creditmemo/default.phtml b/app/code/Magento/Sales/view/frontend/templates/email/items/creditmemo/default.phtml index e2209100409..394dd89c4a6 100644 --- a/app/code/Magento/Sales/view/frontend/templates/email/items/creditmemo/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/email/items/creditmemo/default.phtml @@ -44,79 +44,6 @@ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getQty()*1 ?></td> <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml b/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml index e2209100409..394dd89c4a6 100644 --- a/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml @@ -44,79 +44,6 @@ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getQty()*1 ?></td> <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/frontend/templates/email/items/order/default.phtml b/app/code/Magento/Sales/view/frontend/templates/email/items/order/default.phtml index 1c7db4f5e58..27a84e0b1a0 100644 --- a/app/code/Magento/Sales/view/frontend/templates/email/items/order/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/email/items/order/default.phtml @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/** @var $this \Magento\Sales\Block\Order\Email\Items_Order_Default */ +/** @var $this \Magento\Sales\Block\Order\Email\Items\DefaultItems */ /** @var $_item \Magento\Sales\Model\Order\Item */ $_item = $this->getItem(); @@ -50,80 +50,7 @@ $_order = $_item->getOrder(); <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $this->escapeHtml($this->getSku($_item)) ?></td> <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $_item->getQtyOrdered()*1 ?></td> <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <span class="label"><?php echo __('Excl. Tax'); ?>:</span> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <br /> - <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> - - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax($_order->getStore()) || $this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices($_order->getStore())): ?> - <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> - <?php endif; ?> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'email', $_order->getStore())): ?> - <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <br /> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'email', $_order->getStore())): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'email', $_order->getStore())): ?> - <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span> - <?php endif; ?> - <?php endif; ?> - <?php endif; ?> + <?php echo $this->getItemPrice($_item); ?> </td> </tr> <?php if ($_item->getGiftMessageId() && $_giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessage($_item->getGiftMessageId())): ?> diff --git a/app/code/Magento/Sales/view/frontend/templates/email/items/price/row.phtml b/app/code/Magento/Sales/view/frontend/templates/email/items/price/row.phtml new file mode 100644 index 00000000000..bb18a4c7a42 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/templates/email/items/price/row.phtml @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Sales\Block\Order\Email\Items\DefaultItems $this */ + +$_item = $this->getItem(); + +/** @var \Magento\Sales\Model\Order $_order */ +$_order = $_item->getOrder(); +?> + +<?php echo $_order->formatPrice($_item->getRowTotal()) ?> diff --git a/app/code/Magento/Sales/view/frontend/templates/items/price/row.phtml b/app/code/Magento/Sales/view/frontend/templates/items/price/row.phtml new file mode 100644 index 00000000000..7768e182d3a --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/templates/items/price/row.phtml @@ -0,0 +1,32 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** @var \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer $this */ +$_item = $this->getItem(); +?> +<span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> + <span class="cart-price"> + <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> + </span> +</span> diff --git a/app/code/Magento/Sales/view/frontend/templates/items/price/total_after_discount.phtml b/app/code/Magento/Sales/view/frontend/templates/items/price/total_after_discount.phtml new file mode 100644 index 00000000000..4532b9f1f31 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/templates/items/price/total_after_discount.phtml @@ -0,0 +1,29 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** @var \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer $this */ +$_item = $this->getItem(); +?> +<?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> +<?php echo $_order->formatPrice($this->getTotalAmount($_item))?> \ No newline at end of file diff --git a/app/code/Magento/Sales/view/frontend/templates/items/price/unit.phtml b/app/code/Magento/Sales/view/frontend/templates/items/price/unit.phtml new file mode 100644 index 00000000000..3ee30e95401 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/templates/items/price/unit.phtml @@ -0,0 +1,32 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** @var \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer $this */ +$_item = $this->getItem(); +?> +<span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> + <span class="cart-price"> + <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> + </span> +</span> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml index 2728e71d8e5..3ac897b4790 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> <tr id="order-item-row-<?php echo $_item->getId() ?>"> @@ -75,174 +76,14 @@ </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}' - <span class="weee" data-th="<?php echo __('Total incl. tax'); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty')); ?>"><?php echo $_item->getQty()*1 ?></td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $tax['title']; ?>: <?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> <td class="col discount" data-th="<?php echo $this->escapeHtml(__('Discount Amount')); ?>"><?php echo $_order->formatPrice(-$_item->getDiscountAmount()) ?></td> <td class="cot total" data-th="<?php echo $this->escapeHtml(__('Row Total')); ?>"> - <?php echo $_order->formatPrice($_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()+$_item->getWeeeTaxAppliedRowAmount()) ?> + <?php echo $this->getItemRowTotalAfterDiscountHtml(); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml index d303068af26..49e3618ecbf 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> +<?php /** @var $this \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer */ ?> <?php $_item = $this->getItem() ?> <?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> <tr id="order-item-row-<?php echo $_item->getId() ?>"> @@ -66,175 +67,12 @@ </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}' - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}' - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty Invoiced')); ?>"> <span class="qty summary"><?php echo $_item->getQty()*1 ?></span> </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - </small> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$this->getItem()->getWeeeTaxAppliedRowAmount()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><<?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> </tr> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml index f4e97fb4766..92beeaf1a06 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml @@ -22,9 +22,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ +/** @var $this \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer */ $_item = $this->getItem(); -/** @var $_weeeHelper \Magento\Weee\Helper\Data */ -$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); ?> <tr id="order-item-row-<?php echo $_item->getId() ?>"> <td class="col name" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"> @@ -71,87 +70,8 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); </td> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->prepareSku($this->getSku()) ?></td> <td class="col price" data-th="<?php echo $this->escapeHtml(__('Price')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$_weeeHelper->getWeeeTaxInclTax($this->getItem())); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxDisposition()) ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="unit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}' - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$_weeeHelper->getWeeeTaxInclTax($this->getItem())); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['amount']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $this->getItem()->getId(); ?>"}' - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getPrice()+$this->getItem()->getWeeeTaxAppliedAmount()+$this->getItem()->getWeeeTaxDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemPriceHtml(); ?> </td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty')); ?>"> <ul class="items-qty"> @@ -182,85 +102,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); </ul> </td> <td class="col subtotal" data-th="<?php echo $this->escapeHtml(__('Subtotal')); ?>"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> - <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($this->getItem()); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($this->getItem())); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($_incl-$this->getItem()->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount_incl_tax']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total incl. tax')); ?>"><?php echo $this->getOrder()->formatPrice($_incl+$_weeeHelper->getRowWeeeTaxInclTax($this->getItem())); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> - - <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> - <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <?php else: ?> - <span class="cart-price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(0, 1, 4), 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem())): ?> - <span class="cart-tax-info" id="esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>" style="display: none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(1, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(4, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($this->getItem()) as $tax): ?> - <span class="weee" data-th="<?php echo $tax['title']; ?>"><?php echo $this->getOrder()->formatPrice($tax['row_amount']); ?></span> - <?php endforeach; ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(2, 'sales') && (float)$this->getItem()->getWeeeTaxAppliedAmount()): ?> - <span class="cart-tax-total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $this->getItem()->getId(); ?>"}'> - <span class="weee" data-th="<?php echo $this->escapeHtml(__('Total')); ?>"><?php echo $this->getOrder()->formatPrice($this->getItem()->getRowTotal()+$this->getItem()->getWeeeTaxAppliedRowAmount()+$this->getItem()->getWeeeTaxRowDisposition()); ?></span> - </span> - <?php endif; ?> - <?php endif; ?> - </span> - <?php endif; ?> + <?php echo $this->getItemRowTotalHtml(); ?> </td> <?php /* if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 2d689887bea..3e354350531 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-rule": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-reports": "0.1.0-alpha92", - "magento/module-catalog-rule": "0.1.0-alpha92", - "magento/module-widget": "0.1.0-alpha92", - "magento/module-cron": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-rule": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-reports": "0.1.0-alpha93", + "magento/module-catalog-rule": "0.1.0-alpha93", + "magento/module-widget": "0.1.0-alpha93", + "magento/module-cron": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/Controller/Product.php b/app/code/Magento/Sendfriend/Controller/Product.php index 5d0018629e6..87092329b30 100644 --- a/app/code/Magento/Sendfriend/Controller/Product.php +++ b/app/code/Magento/Sendfriend/Controller/Product.php @@ -45,18 +45,26 @@ class Product extends \Magento\Framework\App\Action\Action */ protected $_formKeyValidator; + /** + * @var \Magento\Sendfriend\Model\Sendfriend + */ + protected $sendFriend; + /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator + * @param \Magento\Sendfriend\Model\Sendfriend $sendFriend */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Core\App\Action\FormKeyValidator $formKeyValidator + \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, + \Magento\Sendfriend\Model\Sendfriend $sendFriend ) { $this->_coreRegistry = $coreRegistry; $this->_formKeyValidator = $formKeyValidator; + $this->sendFriend = $sendFriend; parent::__construct($context); } @@ -127,23 +135,7 @@ class Product extends \Magento\Framework\App\Action\Action */ protected function _initSendToFriendModel() { - /** @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress */ - $remoteAddress = $this->_objectManager->get('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress'); - - /** @var \Magento\Framework\Stdlib\Cookie $cookie */ - $cookie = $this->_objectManager->get('Magento\Framework\Stdlib\Cookie'); - - /** @var \Magento\Store\Model\StoreManagerInterface $store */ - $store = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); - - /** @var \Magento\Sendfriend\Model\Sendfriend $model */ - $model = $this->_objectManager->create('Magento\Sendfriend\Model\Sendfriend'); - $model->setRemoteAddr($remoteAddress->getRemoteAddress(true)); - $model->setCookie($cookie); - $model->setWebsiteId($store->getStore()->getWebsiteId()); - - $this->_coreRegistry->register('send_to_friend_model', $model); - - return $model; + $this->sendFriend->register(); + return $this->sendFriend; } } diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php index dfa8addb324..42eb89a6d69 100644 --- a/app/code/Magento/Sendfriend/Model/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php @@ -115,6 +115,16 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel */ protected $inlineTranslation; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManager; + + /** + * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress + */ + protected $remoteAddress; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -123,6 +133,8 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel * @param \Magento\Catalog\Helper\Image $catalogImage * @param \Magento\Sendfriend\Helper\Data $sendfriendData * @param \Magento\Framework\Escaper $escaper + * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -136,16 +148,21 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel \Magento\Catalog\Helper\Image $catalogImage, \Magento\Sendfriend\Helper\Data $sendfriendData, \Magento\Framework\Escaper $escaper, + \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, + \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + $this->_storeManager = $storeManager; $this->_transportBuilder = $transportBuilder; $this->_catalogImage = $catalogImage; $this->_sendfriendData = $sendfriendData; $this->_escaper = $escaper; + $this->remoteAddress = $remoteAddress; + $this->cookieManager = $cookieManager; $this->inlineTranslation = $inlineTranslation; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -265,76 +282,6 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel return $errors; } - /** - * Set cookie instance - * - * @param \Magento\Framework\Stdlib\Cookie $cookie - * @return $this - */ - public function setCookie($cookie) - { - return $this->setData('_cookie', $cookie); - } - - /** - * Retrieve Cookie instance - * - * @throws \Magento\Framework\Model\Exception - * @return \Magento\Framework\Stdlib\Cookie - */ - public function getCookie() - { - $cookie = $this->_getData('_cookie'); - if (!$cookie instanceof \Magento\Framework\Stdlib\Cookie) { - throw new \Magento\Framework\Model\Exception(__('Please define a correct Cookie instance.')); - } - return $cookie; - } - - /** - * Set Visitor Remote Address - * - * @param int $ipAddr the IP address on Long Format - * @return $this - */ - public function setRemoteAddr($ipAddr) - { - $this->setData('_remote_addr', $ipAddr); - return $this; - } - - /** - * Retrieve Visitor Remote Address - * - * @return int - */ - public function getRemoteAddr() - { - return $this->_getData('_remote_addr'); - } - - /** - * Set Website Id - * - * @param int $id - website id - * @return $this - */ - public function setWebsiteId($id) - { - $this->setData('_website_id', $id); - return $this; - } - - /** - * Retrieve Website Id - * - * @return int - */ - public function getWebsiteId() - { - return $this->_getData('_website_id'); - } - /** * Set Recipients * @@ -372,7 +319,10 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel $emails = array_keys($emails); } - return $this->setData('_recipients', new \Magento\Framework\Object(array('emails' => $emails, 'names' => $names))); + return $this->setData( + '_recipients', + new \Magento\Framework\Object(array('emails' => $emails, 'names' => $names)) + ); } /** @@ -533,14 +483,14 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel */ protected function _sentCountByCookies($increment = false) { - $cookie = $this->_sendfriendData->getCookieName(); + $cookieName = $this->_sendfriendData->getCookieName(); $time = time(); $newTimes = array(); - if (isset($this->_lastCookieValue[$cookie])) { - $oldTimes = $this->_lastCookieValue[$cookie]; + if (isset($this->_lastCookieValue[$cookieName])) { + $oldTimes = $this->_lastCookieValue[$cookieName]; } else { - $oldTimes = $this->getCookie()->get($cookie); + $oldTimes = $this->cookieManager->getCookie($cookieName); } if ($oldTimes) { @@ -556,8 +506,8 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel if ($increment) { $newTimes[] = $time; $newValue = implode(',', $newTimes); - $this->getCookie()->set($cookie, $newValue); - $this->_lastCookieValue[$cookie] = $newValue; + $this->cookieManager->setPublicCookie($cookieName, $newValue); + $this->_lastCookieValue[$cookieName] = $newValue; } return count($newTimes); @@ -573,16 +523,21 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel { $time = time(); $period = $this->_sendfriendData->getPeriod(); - $websiteId = $this->getWebsiteId(); + $websiteId = $this->_storeManager->getStore()->getWebsiteId(); if ($increment) { // delete expired logs $this->_getResource()->deleteLogsBefore($time - $period); // add new item - $this->_getResource()->addSendItem($this->getRemoteAddr(), $time, $websiteId); + $this->_getResource()->addSendItem($this->remoteAddress->getRemoteAddress(true), $time, $websiteId); } - return $this->_getResource()->getSendCount($this, $this->getRemoteAddr(), time() - $period, $websiteId); + return $this->_getResource()->getSendCount( + $this, + $this->remoteAddress->getRemoteAddress(true), + time() - $period, + $websiteId + ); } /** diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index 1bfb4e8f4be..7c13ee863d2 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php index 6807412a6a5..93d4e3f6f37 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php @@ -76,7 +76,11 @@ class AddComment extends \Magento\Backend\App\Action throw new \Magento\Framework\Model\Exception(__("The comment text field cannot be empty.")); } $this->_title->add(__('Shipments')); - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); $shipment->addComment( $data['comment'], isset($data['is_customer_notified']), @@ -89,9 +93,9 @@ class AddComment extends \Magento\Backend\App\Action $this->_view->loadLayout(false); $response = $this->_view->getLayout()->getBlock('shipment_comments')->toHtml(); } catch (\Magento\Framework\Model\Exception $e) { - $response = array('error' => true, 'message' => $e->getMessage()); + $response = ['error' => true, 'message' => $e->getMessage()]; } catch (\Exception $e) { - $response = array('error' => true, 'message' => __('Cannot add new comment.')); + $response = ['error' => true, 'message' => __('Cannot add new comment.')]; } if (is_array($response)) { $response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrack.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrack.php index deef6bb7878..6e2302f194b 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrack.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrack.php @@ -72,7 +72,11 @@ class AddTrack extends \Magento\Backend\App\Action throw new \Magento\Framework\Model\Exception(__('Please enter a tracking number.')); } $this->_title->add(__('Shipments')); - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { $track = $this->_objectManager->create( 'Magento\Sales\Model\Order\Shipment\Track' diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabel.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabel.php index 11903806c8a..69542e1f484 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabel.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabel.php @@ -70,12 +70,15 @@ class CreateLabel extends \Magento\Backend\App\Action { $response = new \Magento\Framework\Object(); try { - $shipment = $this->shipmentLoader->load($this->_request); - if ($this->labelGenerator->create($shipment, $this->_request)) { - $shipment->save(); - $this->messageManager->addSuccess(__('You created the shipping label.')); - $response->setOk(true); - } + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); + $this->labelGenerator->create($shipment, $this->_request); + $shipment->save(); + $this->messageManager->addSuccess(__('You created the shipping label.')); + $response->setOk(true); } catch (\Magento\Framework\Model\Exception $e) { $response->setError(true); $response->setMessage($e->getMessage()); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php index 62af1f58827..2636b965d65 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php @@ -25,8 +25,12 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use \Magento\Backend\App\Action; -use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; +/** + * Class Email + * + * @package Magento\Shipping\Controller\Adminhtml\Order\Shipment + */ class Email extends \Magento\Backend\App\Action { /** @@ -34,27 +38,21 @@ class Email extends \Magento\Backend\App\Action */ protected $shipmentLoader; - /** - * @var ShipmentSender - */ - protected $shipmentSender; - /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader - * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, - \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, - ShipmentSender $shipmentSender + \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader ) { $this->shipmentLoader = $shipmentLoader; - $this->shipmentSender = $shipmentSender; parent::__construct($context); } /** + * Check if email sending is allowed for the current user + * * @return bool */ protected function _isAllowed() @@ -70,21 +68,15 @@ class Email extends \Magento\Backend\App\Action public function execute() { try { - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { - $this->shipmentSender->send($shipment, true); + $this->_objectManager->create('Magento\Shipping\Model\ShipmentNotifier') + ->notify($shipment); $shipment->save(); - - $historyItem = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Status\History\Collection' - )->getUnnotifiedForInstance( - $shipment, - \Magento\Sales\Model\Order\Shipment::HISTORY_ENTITY_NAME - ); - if ($historyItem) { - $historyItem->setIsCustomerNotified(1); - $historyItem->save(); - } $this->messageManager->addSuccess(__('You sent the shipment.')); } } catch (\Magento\Framework\Model\Exception $e) { @@ -92,6 +84,6 @@ class Email extends \Magento\Backend\App\Action } catch (\Exception $e) { $this->messageManager->addError(__('Cannot send shipment information.')); } - $this->_redirect('*/*/view', array('shipment_id' => $this->getRequest()->getParam('shipment_id'))); + $this->_redirect('*/*/view', ['shipment_id' => $this->getRequest()->getParam('shipment_id')]); } } diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGrid.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGrid.php index bd4a7838abd..ce1460e6f76 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGrid.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGrid.php @@ -61,7 +61,11 @@ class GetShippingItemsGrid extends \Magento\Backend\App\Action */ public function execute() { - $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $this->shipmentLoader->load(); return $this->getResponse()->setBody( $this->_view->getLayout()->createBlock( 'Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid' diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php index 03698fe75c8..295ee0caba3 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php @@ -61,7 +61,11 @@ class NewAction extends \Magento\Backend\App\Action public function execute() { $this->_title->add(__('Shipments')); - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { $this->_title->add(__('New Shipment')); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabel.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabel.php index 898bcb43465..f0ca7adc66b 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabel.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabel.php @@ -78,7 +78,11 @@ class PrintLabel extends \Magento\Backend\App\Action public function execute() { try { - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); $labelContent = $shipment->getShippingLabel(); if ($labelContent) { $pdfContent = null; @@ -114,7 +118,7 @@ class PrintLabel extends \Magento\Backend\App\Action } $this->_redirect( 'adminhtml/order_shipment/view', - array('shipment_id' => $this->getRequest()->getParam('shipment_id')) + ['shipment_id' => $this->getRequest()->getParam('shipment_id')] ); } } diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackage.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackage.php index 6a34fe5d3c8..149ecef4d19 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackage.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackage.php @@ -69,9 +69,14 @@ class PrintPackage extends \Magento\Backend\App\Action */ public function execute() { - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { + /** @var \Zend_Pdf $pdf */ $pdf = $this->_objectManager->create('Magento\Shipping\Model\Order\Pdf\Packaging')->getPdf($shipment); return $this->_fileFactory->create( 'packingslip' . $this->_objectManager->get( diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrack.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrack.php index aed7bc1b25f..b1bb79217e0 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrack.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrack.php @@ -61,27 +61,32 @@ class RemoveTrack extends \Magento\Backend\App\Action public function execute() { $trackId = $this->getRequest()->getParam('track_id'); + /** @var \Magento\Sales\Model\Order\Shipment\Track $track */ $track = $this->_objectManager->create('Magento\Sales\Model\Order\Shipment\Track')->load($trackId); if ($track->getId()) { try { $this->_title->add(__('Shipments')); - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { $track->delete(); $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('shipment_tracking')->toHtml(); } else { - $response = array( + $response = [ 'error' => true, 'message' => __('Cannot initialize shipment for delete tracking number.') - ); + ]; } } catch (\Exception $e) { - $response = array('error' => true, 'message' => __('Cannot delete tracking number.')); + $response = ['error' => true, 'message' => __('Cannot delete tracking number.')]; } } else { - $response = array('error' => true, 'message' => __('Cannot load track with retrieving identifier.')); + $response = ['error' => true, 'message' => __('Cannot load track with retrieving identifier.')]; } if (is_array($response)) { $response = $this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($response); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php index 8bdd3ed7fca..7ac03cb4414 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php @@ -79,9 +79,10 @@ class Save extends \Magento\Backend\App\Action protected function _saveShipment($shipment) { $shipment->getOrder()->setIsInProcess(true); - $transactionSave = $this->_objectManager->create( + $transaction = $this->_objectManager->create( 'Magento\Framework\DB\Transaction' - )->addObject( + ); + $transaction->addObject( $shipment )->addObject( $shipment->getOrder() @@ -98,13 +99,18 @@ class Save extends \Magento\Backend\App\Action */ public function execute() { - $data = $this->getRequest()->getPost('shipment'); + $data = $this->getRequest()->getParam('shipment'); + if (!empty($data['comment_text'])) { $this->_objectManager->get('Magento\Backend\Model\Session')->setCommentText($data['comment_text']); } try { - $shipment = $this->shipmentLoader->load($this->_request); + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($data); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if (!$shipment) { $this->_forward('noroute'); return; @@ -131,7 +137,8 @@ class Save extends \Magento\Backend\App\Action $responseAjax = new \Magento\Framework\Object(); $isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label']; - if ($isNeedCreateLabel && $this->labelGenerator->create($shipment, $this->_request)) { + if ($isNeedCreateLabel) { + $this->labelGenerator->create($shipment, $this->_request); $responseAjax->setOk(true); } @@ -167,7 +174,7 @@ class Save extends \Magento\Backend\App\Action if ($isNeedCreateLabel) { $this->getResponse()->representJson($responseAjax->toJson()); } else { - $this->_redirect('sales/order/view', array('order_id' => $shipment->getOrderId())); + $this->_redirect('sales/order/view', ['order_id' => $shipment->getOrderId()]); } } } diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php index 50c03f4d561..808d5859834 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php @@ -61,7 +61,12 @@ class View extends \Magento\Backend\App\Action public function execute() { $this->_title->add(__('Shipments')); - $shipment = $this->shipmentLoader->load($this->_request); + + $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id')); + $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id')); + $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment')); + $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking')); + $shipment = $this->shipmentLoader->load(); if ($shipment) { $this->_title->add("#" . $shipment->getIncrementId()); $this->_view->loadLayout(); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php index 6cc1afeda48..f5228c91d29 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php @@ -24,9 +24,22 @@ */ namespace Magento\Shipping\Controller\Adminhtml\Order; -use Magento\Framework\App\RequestInterface; +use Magento\Framework\Object; -class ShipmentLoader +/** + * Class ShipmentLoader + * + * @package Magento\Shipping\Controller\Adminhtml\Order + * @method ShipmentLoader setOrderId + * @method ShipmentLoader setShipmentId + * @method ShipmentLoader setShipment + * @method ShipmentLoader setTracking + * @method int getOrderId + * @method int getShipmentId + * @method array getShipment + * @method array getTracking + */ +class ShipmentLoader extends Object { /** * @var \Magento\Framework\Message\ManagerInterface @@ -65,6 +78,7 @@ class ShipmentLoader * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Service\OrderFactory $orderServiceFactory * @param \Magento\Sales\Model\Order\Shipment\TrackFactory $trackFactory + * @param array $data */ public function __construct( \Magento\Framework\Message\ManagerInterface $messageManager, @@ -72,7 +86,8 @@ class ShipmentLoader \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Service\OrderFactory $orderServiceFactory, - \Magento\Sales\Model\Order\Shipment\TrackFactory $trackFactory + \Magento\Sales\Model\Order\Shipment\TrackFactory $trackFactory, + array $data = [] ) { $this->messageManager = $messageManager; $this->registry = $registry; @@ -80,21 +95,21 @@ class ShipmentLoader $this->orderFactory = $orderFactory; $this->orderServiceFactory = $orderServiceFactory; $this->trackFactory = $trackFactory; + parent::__construct($data); } /** * Initialize shipment items QTY * - * @param RequestInterface $request * @return array */ - protected function _getItemQtys(RequestInterface $request) + protected function getItemQtys() { - $data = $request->getParam('shipment'); + $data = $this->getShipment(); if (isset($data['items'])) { $qtys = $data['items']; } else { - $qtys = array(); + $qtys = []; } return $qtys; } @@ -102,15 +117,14 @@ class ShipmentLoader /** * Initialize shipment model instance * - * @param RequestInterface $request * @return bool|\Magento\Sales\Model\Order\Shipment * @throws \Magento\Framework\Model\Exception */ - public function load(RequestInterface $request) + public function load() { $shipment = false; - $shipmentId = $request->getParam('shipment_id'); - $orderId = $request->getParam('order_id'); + $orderId = $this->getOrderId(); + $shipmentId = $this->getShipmentId(); if ($shipmentId) { $shipment = $this->shipmentFactory->create()->load($shipmentId); } elseif ($orderId) { @@ -137,12 +151,11 @@ class ShipmentLoader $this->messageManager->addError(__('Cannot do shipment for the order.')); return false; } - $savedQtys = $this->_getItemQtys($request); - $shipment = $this->orderServiceFactory->create(array('order' => $order))->prepareShipment($savedQtys); - $tracks = $request->getPost('tracking'); - if ($tracks) { - foreach ($tracks as $data) { + $savedQtys = $this->getItemQtys(); + $shipment = $this->orderServiceFactory->create(['order' => $order])->prepareShipment($savedQtys); + if ($this->getTracking()) { + foreach ((array)$this->getTracking() as $data) { if (empty($data['number'])) { throw new \Magento\Framework\Model\Exception(__('Please enter a tracking number.')); } diff --git a/app/code/Magento/Shipping/Model/ShipmentNotifier.php b/app/code/Magento/Shipping/Model/ShipmentNotifier.php new file mode 100644 index 00000000000..d0a4f2dcd71 --- /dev/null +++ b/app/code/Magento/Shipping/Model/ShipmentNotifier.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Model; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Sales\Model\Order\Email\Sender\ShipmentSender; +use Magento\Framework\Logger; + +/** + * Class ShipmentNotifier + * @package Magento\Shipping\Model + */ +class ShipmentNotifier extends \Magento\Sales\Model\AbstractNotifier +{ + /** + * @var CollectionFactory + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var ShipmentSender + */ + protected $sender; + + /** + * @param CollectionFactory $historyCollectionFactory + * @param Logger $logger + * @param ShipmentSender $sender + */ + public function __construct( + CollectionFactory $historyCollectionFactory, + Logger $logger, + ShipmentSender $sender + ) { + $this->historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->sender = $sender; + } +} diff --git a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php index 235d590812b..a723d6df8cc 100644 --- a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php +++ b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php @@ -77,31 +77,26 @@ class LabelGenerator /** * @param \Magento\Sales\Model\Order\Shipment $shipment * @param RequestInterface $request - * @return bool + * @return void * @throws \Magento\Framework\Model\Exception */ public function create(\Magento\Sales\Model\Order\Shipment $shipment, RequestInterface $request) { - if (!$shipment) { - return false; - } $order = $shipment->getOrder(); $carrier = $this->_carrierFactory->create($order->getShippingMethod(true)->getCarrierCode()); if (!$carrier->isShippingLabelsAvailable()) { - return false; + throw new \Magento\Framework\Model\Exception(__('Shipping labels is not available.')); } $shipment->setPackages($request->getParam('packages')); - $response = $this->labelFactory->create()->requestToShipment( - $shipment - ); + $response = $this->labelFactory->create()->requestToShipment($shipment); if ($response->hasErrors()) { throw new \Magento\Framework\Model\Exception($response->getErrors()); } if (!$response->hasInfo()) { - return false; + throw new \Magento\Framework\Model\Exception(__('Response info is not exist.')); } - $labelsContent = array(); - $trackingNumbers = array(); + $labelsContent = []; + $trackingNumbers = []; $info = $response->getInfo(); foreach ($info as $inf) { if (!empty($inf['tracking_number']) && !empty($inf['label_content'])) { @@ -117,20 +112,15 @@ class LabelGenerator \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $shipment->getStoreId() ); - if ($trackingNumbers) { + if (!empty($trackingNumbers)) { foreach ($trackingNumbers as $trackingNumber) { $track = $this->trackFactory->create() - ->setNumber( - $trackingNumber - )->setCarrierCode( - $carrierCode - )->setTitle( - $carrierTitle - ); + ->setNumber($trackingNumber) + ->setCarrierCode($carrierCode) + ->setTitle($carrierTitle); $shipment->addTrack($track); } } - return true; } /** diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 7fe4c019590..6ee64a8e25f 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-contact": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-payment": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-contact": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-payment": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 89b13529810..6d3346dfb91 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/App/Action/Plugin/Context.php b/app/code/Magento/Store/App/Action/Plugin/Context.php index 62cc392af2a..89e343a1209 100644 --- a/app/code/Magento/Store/App/Action/Plugin/Context.php +++ b/app/code/Magento/Store/App/Action/Plugin/Context.php @@ -49,22 +49,30 @@ class Context */ protected $storeManager; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManager; + /** * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Request\Http $httpRequest * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager */ public function __construct( \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Request\Http $httpRequest, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\Stdlib\CookieManager $cookieManager ) { $this->session = $session; $this->httpContext = $httpContext; $this->httpRequest = $httpRequest; $this->storeManager = $storeManager; + $this->cookieManager = $cookieManager; } /** @@ -88,7 +96,7 @@ class Context \Magento\Core\Helper\Data::CONTEXT_STORE, $this->httpRequest->getParam( '___store', - $this->httpRequest->getCookie(\Magento\Store\Model\Store::COOKIE_NAME) + $this->cookieManager->getCookie(\Magento\Store\Model\Store::COOKIE_NAME) ), $this->storeManager->getWebsite()->getDefaultStore()->getCode() ); diff --git a/app/code/Magento/Store/Model/StorageFactory.php b/app/code/Magento/Store/Model/StorageFactory.php index 1bb360c2278..711d0e8f7d4 100644 --- a/app/code/Magento/Store/Model/StorageFactory.php +++ b/app/code/Magento/Store/Model/StorageFactory.php @@ -79,9 +79,9 @@ class StorageFactory protected $_writerModel; /** - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $_cookie; + protected $_cookieManager; /** * @var \Magento\Framework\App\Http\Context @@ -93,16 +93,21 @@ class StorageFactory */ protected $request; + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactory; /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Session\SidResolverInterface $sidResolver * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param string $defaultStorageClassName * @param string $installedStorageClassName * @param string $writerModel @@ -113,10 +118,11 @@ class StorageFactory \Magento\Framework\Logger $logger, \Magento\Framework\Session\SidResolverInterface $sidResolver, \Magento\Framework\App\State $appState, - \Magento\Framework\Stdlib\Cookie $cookie, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\RequestInterface $request, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, + \Magento\Framework\Stdlib\CookieManager $cookieManager, $defaultStorageClassName = 'Magento\Store\Model\Storage\DefaultStorage', $installedStorageClassName = 'Magento\Store\Model\Storage\Db', $writerModel = '' @@ -129,8 +135,9 @@ class StorageFactory $this->_appState = $appState; $this->_sidResolver = $sidResolver; $this->_writerModel = $writerModel; - $this->_cookie = $cookie; $this->_httpContext = $httpContext; + $this->cookieMetadataFactory = $cookieMetadataFactory; + $this->_cookieManager = $cookieManager; $this->_scopeConfig = $scopeConfig; $this->request = $request; } @@ -287,12 +294,10 @@ class StorageFactory */ protected function _checkCookieStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeType) { - if (!$this->_cookie->get()) { - return; + $storeCode = $this->_cookieManager->getCookie(Store::COOKIE_NAME); + if (isset($storeCode)) { + $this->setCurrentStore($storage, $storeCode, $scopeType); } - - $storeCode = $this->_cookie->get(Store::COOKIE_NAME); - $this->setCurrentStore($storage, $storeCode, $scopeType); } /** @@ -314,9 +319,11 @@ class StorageFactory if ($storage->getStore()->getCode() == $storeCode) { $store = $storage->getStore($storeCode); if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) { - $this->_cookie->set(Store::COOKIE_NAME, null); + $this->_cookieManager->deleteCookie(Store::COOKIE_NAME); } else { - $this->_cookie->set(Store::COOKIE_NAME, $storage->getStore()->getCode(), true); + $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setDurationOneYear(); + $this->_cookieManager->setPublicCookie(Store::COOKIE_NAME, $storage->getStore()->getCode(), $publicCookieMetadata); $this->_httpContext->setValue( Store::ENTITY, $storage->getStore()->getCode(), diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 3e52c98e2ea..dc85ed2177b 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -301,11 +301,14 @@ class Store extends AbstractModel implements protected $_currencyInstalled; /** - * Cookie model - * - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $_cookieMetadataFactory; + + /** + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $_cookie; + protected $_cookieManager; /** * @var \Magento\Framework\App\Http\Context @@ -330,7 +333,8 @@ class Store extends AbstractModel implements * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config * @param StoreManagerInterface $storeManager * @param \Magento\Framework\Session\SidResolverInterface $sidResolver - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager, * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory @@ -352,7 +356,8 @@ class Store extends AbstractModel implements \Magento\Framework\App\Config\ReinitableConfigInterface $config, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Session\SidResolverInterface $sidResolver, - \Magento\Framework\Stdlib\Cookie $cookie, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, + \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Directory\Model\CurrencyFactory $currencyFactory, @@ -371,7 +376,8 @@ class Store extends AbstractModel implements $this->filesystem = $filesystem; $this->_storeManager = $storeManager; $this->_sidResolver = $sidResolver; - $this->_cookie = $cookie; + $this->_cookieMetadataFactory = $cookieMetadataFactory; + $this->_cookieManager = $cookieManager; $this->_httpContext = $httpContext; $this->_session = $session; $this->currencyFactory = $currencyFactory; @@ -403,7 +409,6 @@ class Store extends AbstractModel implements $this->_config = \Magento\Framework\App\ObjectManager::getInstance()->get( 'Magento\Framework\App\Config\ReinitableConfigInterface' ); - $this->_cookie = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\Stdlib\Cookie'); } /** @@ -849,10 +854,14 @@ class Store extends AbstractModel implements if (in_array($code, $this->getAvailableCurrencyCodes())) { $this->_getSession()->setCurrencyCode($code); $path = $this->_getSession()->getCookiePath(); + + $sensitiveCookieMetadata = $this->_cookieMetadataFactory->createSensitiveCookieMetadata() + ->setPath($path); + if ($code == $this->getDefaultCurrency()->getCurrencyCode()) { - $this->_cookie->set(self::COOKIE_CURRENCY, null, null, $path); + $this->_cookieManager->deleteCookie(self::COOKIE_CURRENCY, $sensitiveCookieMetadata); } else { - $this->_cookie->set(self::COOKIE_CURRENCY, $code, null, $path); + $this->_cookieManager->setSensitiveCookie(self::COOKIE_CURRENCY, $code, $sensitiveCookieMetadata); } $this->_httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_CURRENCY, diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index 1ec619f7eeb..f1a95f07547 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-index": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-core": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-index": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index a5cbe17abdf..ca80cd75581 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -65,6 +65,7 @@ </type> <preference for="Magento\Framework\App\Config\Scope\ReaderPoolInterface" type="Magento\Store\Model\Config\Reader\ReaderPool"/> <preference for="Magento\Framework\App\ScopeResolverInterface" type="Magento\Store\Model\Resolver\Store" /> + <preference for="Magento\Framework\Stdlib\CookieManager" type="Magento\Framework\Stdlib\Cookie\PhpCookieManager" /> <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> </type> diff --git a/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php b/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php new file mode 100644 index 00000000000..7022e44abc3 --- /dev/null +++ b/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php @@ -0,0 +1,176 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Tax\Block\Adminhtml\Items\Price; + +use Magento\Tax\Helper\Data as TaxHelper; +use Magento\Tax\Block\Item\Price\Renderer as ItemPriceRenderer; +use Magento\Sales\Model\Order\Item; +use Magento\Sales\Model\Quote\Item\AbstractItem as QuoteItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem; + +/** + * Sales Order items price column renderer + */ +class Renderer extends \Magento\Backend\Block\Template +{ + /** + * @var \Magento\Tax\Helper\Data + */ + protected $taxHelper; + + /** + * @var \Magento\Tax\Block\Item\Price\Renderer + */ + protected $itemPriceRenderer; + + /** + * @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn + */ + protected $defaultColumnRenderer; + + /** + * @var Item|QuoteItem|InvoiceItem|CreditmemoItem + */ + protected $item; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer + * @param TaxHelper $taxHelper + * @param ItemPriceRenderer $itemPriceRenderer + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer, + TaxHelper $taxHelper, + ItemPriceRenderer $itemPriceRenderer, + array $data = array() + ) { + $this->defaultColumnRenderer = $defaultColumnRenderer; + $this->itemPriceRenderer = $itemPriceRenderer; + $this->itemPriceRenderer->setZone('sales'); + parent::__construct($context, $data); + } + + /** + * Set item + * + * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item + * @return $this + */ + public function setItem($item) + { + $this->itemPriceRenderer->setItem($item); + $this->defaultColumnRenderer->setItem($item); + $this->item = $item; + return $this; + } + + /** + * Return order item or quote item + * + * @return Item|QuoteItem + */ + public function getItem() + { + return $this->item; + } + + /** + * Return whether display setting is to display price including tax + * + * @return bool + */ + public function displayPriceInclTax() + { + return $this->itemPriceRenderer->displayPriceInclTax(); + } + + /** + * Return whether display setting is to display price excluding tax + * + * @return bool + */ + public function displayPriceExclTax() + { + return $this->itemPriceRenderer->displayPriceExclTax(); + } + + /** + * Return whether display setting is to display both price including tax and price excluding tax + * + * @return bool + */ + public function displayBothPrices() + { + return $this->itemPriceRenderer->displayBothPrices(); + } + + /** + * Calculate total amount for the item + * + * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + return $this->itemPriceRenderer->getTotalAmount($item); + } + + /** + * Calculate base total amount for the item + * + * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getBaseTotalAmount($item) + { + return $this->itemPriceRenderer->getBaseTotalAmount($item); + } + + /** + * Retrieve formated price, use different formatter depending on type of item + * + * @param float $price + * @return string + */ + public function formatPrice($price) + { + return $this->itemPriceRenderer->formatPrice($price); + } + + /** + * Return html that contains both base price and display price + * + * @param float $basePrice + * @param float $displayPrice + * @return string + */ + public function displayPrices($basePrice, $displayPrice) + { + return $this->defaultColumnRenderer->displayPrices($basePrice, $displayPrice); + } +} diff --git a/app/code/Magento/Tax/Block/Item/Price/Renderer.php b/app/code/Magento/Tax/Block/Item/Price/Renderer.php index 278de31027f..1fb40e7d982 100644 --- a/app/code/Magento/Tax/Block/Item/Price/Renderer.php +++ b/app/code/Magento/Tax/Block/Item/Price/Renderer.php @@ -25,19 +25,42 @@ namespace Magento\Tax\Block\Item\Price; use Magento\Tax\Helper\Data as TaxHelper; use Magento\Framework\View\Element\Template\Context; +use Magento\Framework\Object as MagentoObject; +use Magento\Sales\Model\Quote\Item\AbstractItem as QuoteItem; +use Magento\Sales\Model\Order\Item as OrderItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\CreditMemo\Item as CreditMemoItem; +use Magento\Framework\Pricing\Render as PricingRender; /** * Item price render block * * @author Magento Core Team <core@magentocommerce.com> */ -class Renderer extends \Magento\Checkout\Block\Item\Price\Renderer +class Renderer extends \Magento\Framework\View\Element\Template { /** * @var \Magento\Tax\Helper\Data */ protected $taxHelper; + /** + * @var QuoteItem|OrderItem|InvoiceItem|CreditMemoItem + */ + protected $item; + + /** + * @var string|int|null + */ + protected $storeId = null; + + /** + * Set the display area, e.g., cart, sales, etc. + * + * @var string + */ + protected $zone = null; + /** * Constructor * @@ -45,12 +68,70 @@ class Renderer extends \Magento\Checkout\Block\Item\Price\Renderer * @param TaxHelper $taxHelper * @param array $data */ - public function __construct(Context $context, TaxHelper $taxHelper, array $data = array()) - { + public function __construct( + Context $context, + TaxHelper $taxHelper, + array $data = array() + ) { $this->taxHelper = $taxHelper; + if (isset($data['zone'])) { + $this->zone = $data['zone']; + } parent::__construct($context, $data); } + /** + * Set item for render + * + * @param QuoteItem|OrderItem|InvoiceItem|CreditMemoItem $item + * @return $this + */ + public function setItem($item) + { + $this->item = $item; + $this->storeId = $item->getStoreId(); + return $this; + } + + /** + * Get display zone + * + * @return string|null + */ + public function getZone() + { + return $this->zone; + } + + /** + * Set display zone + * + * @param string $zone + * @return $this + */ + public function setZone($zone) + { + $this->zone = $zone; + return $this; + } + + /** + * @return int|null|string + */ + public function getStoreId() + { + return $this->storeId; + } + /** + * Get quote or order item + * + * @return CreditMemoItem|InvoiceItem|OrderItem|QuoteItem + */ + public function getItem() + { + return $this->item; + } + /** * Return whether display setting is to display price including tax * @@ -58,7 +139,15 @@ class Renderer extends \Magento\Checkout\Block\Item\Price\Renderer */ public function displayPriceInclTax() { - return $this->taxHelper->displayCartPriceInclTax(); + switch ($this->zone) { + case PricingRender::ZONE_CART: + return $this->taxHelper->displayCartPriceInclTax($this->storeId); + case PricingRender::ZONE_EMAIL: + case PricingRender::ZONE_SALES: + return $this->taxHelper->displaySalesPriceInclTax($this->storeId); + default: + return $this->taxHelper->displayCartPriceInclTax($this->storeId); + } } /** @@ -68,7 +157,15 @@ class Renderer extends \Magento\Checkout\Block\Item\Price\Renderer */ public function displayPriceExclTax() { - return $this->taxHelper->displayCartPriceExclTax(); + switch ($this->zone) { + case PricingRender::ZONE_CART: + return $this->taxHelper->displayCartPriceExclTax($this->storeId); + case PricingRender::ZONE_EMAIL: + case PricingRender::ZONE_SALES: + return $this->taxHelper->displaySalesPriceExclTax($this->storeId); + default: + return $this->taxHelper->displayCartPriceExclTax($this->storeId); + } } /** @@ -78,6 +175,80 @@ class Renderer extends \Magento\Checkout\Block\Item\Price\Renderer */ public function displayBothPrices() { - return $this->taxHelper->displayCartBothPrices(); + switch ($this->zone) { + case PricingRender::ZONE_CART: + return $this->taxHelper->displayCartBothPrices($this->storeId); + case PricingRender::ZONE_EMAIL: + case PricingRender::ZONE_SALES: + return $this->taxHelper->displaySalesBothPrices($this->storeId); + default: + return $this->taxHelper->displayCartBothPrices($this->storeId); + } + } + + /** + * Format price + * + * @param float $price + * @return string + */ + public function formatPrice($price) + { + $item = $this->getItem(); + if ($item instanceof QuoteItem) { + return $item->getStore()->formatPrice($price); + } elseif ($item instanceof OrderItem) { + return $item->getOrder()->formatPrice($price); + } else { + return $item->getOrderItem()->getOrder()->formatPrice($price); + } + } + + /** + * Get item price in display currency or order currency depending + * on item type + * + * @return float + */ + public function getItemDisplayPriceExclTax() + { + $item = $this->getItem(); + if ($item instanceof QuoteItem) { + return $item->getCalculationPrice(); + } else { + return $item->getPrice(); + } + } + + /** + * Return the total amount minus discount + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + $totalAmount = $item->getRowTotal() + - $item->getDiscountAmount() + + $item->getTaxAmount() + + $item->getHiddenTaxAmount(); + + return $totalAmount; + } + + /** + * Return the total amount minus discount + * + * @param OrderItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getBaseTotalAmount($item) + { + $totalAmount = $item->getBaseRowTotal() + - $item->getBaseDiscountAmount() + + $item->getBaseTaxAmount() + + $item->getBaseHiddenTaxAmount(); + + return $totalAmount; } } diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php index 46f270187ae..73ea7a4fc0a 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation.php @@ -30,6 +30,11 @@ namespace Magento\Tax\Model\Resource; class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb { + /** + * Store ISO 3166-1 alpha-2 USA country code + */ + const USA_COUNTRY_CODE = 'US'; + /** * Rates cache * @@ -187,14 +192,15 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb } $row['rates'][] = $oneRate; + $ruleId = null; if (isset($rates[$i + 1]['tax_calculation_rule_id'])) { - $rule = $rate['tax_calculation_rule_id']; + $ruleId = $rate['tax_calculation_rule_id']; } $priority = $rate['priority']; $ids[] = $rate['code']; if (isset($rates[$i + 1]['tax_calculation_rule_id'])) { - while (isset($rates[$i + 1]) && $rates[$i + 1]['tax_calculation_rule_id'] == $rule) { + while (isset($rates[$i + 1]) && $rates[$i + 1]['tax_calculation_rule_id'] == $ruleId) { $i++; } } @@ -214,7 +220,7 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb $row['percent'] = $this->_collectPercent($totalPercent, $currentRate); $totalPercent += $row['percent']; } - $row['id'] = implode($ids); + $row['id'] = implode('', $ids); $result[] = $row; $row = array(); $ids = array(); @@ -242,22 +248,28 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb * Create search templates for postcode * * @param string $postcode + * @param string|null $exactPostcode * @return string[] */ - protected function _createSearchPostCodeTemplates($postcode) + protected function _createSearchPostCodeTemplates($postcode, $exactPostcode = null) { + // as needed, reduce the postcode to the correct length $len = $this->_taxData->getPostCodeSubStringLength(); - $strlen = strlen($postcode); - if ($strlen > $len) { - $postcode = substr($postcode, 0, $len); - $strlen = $len; + $postcode = substr($postcode, 0, $len); + + // begin creating the search template array + $strArr = [$postcode, $postcode . '*']; + + // if supplied, use the exact postcode as the basis for the search templates + if ($exactPostcode) { + $postcode = substr($exactPostcode, 0, $len); + $strArr[] = $postcode; } - $strArr = array((string)$postcode, $postcode . '*'); - if ($strlen > 1) { - for ($i = 1; $i < $strlen; $i++) { - $strArr[] = sprintf('%s*', substr($postcode, 0, -$i)); - } + // finish building out the search template array + $strlen = strlen($postcode); + for ($i = 1; $i < $strlen; $i++) { + $strArr[] = sprintf('%s*', substr($postcode, 0, -$i)); } return $strArr; @@ -347,10 +359,18 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb array(0, (int)$regionId) ); $postcodeIsNumeric = is_numeric($postcode); - $postcodeIsRange = is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches); - if ($postcodeIsRange) { - $zipFrom = $matches[1]; - $zipTo = $matches[2]; + $postcodeIsRange = false; + $originalPostcode = null; + if (is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches)) { + if ($countryId == self::USA_COUNTRY_CODE && is_numeric($matches[2]) && strlen($matches[2]) == 4) { + $postcodeIsNumeric = true; + $originalPostcode = $postcode; + $postcode = $matches[1]; + } else { + $postcodeIsRange = true; + $zipFrom = $matches[1]; + $zipTo = $matches[2]; + } } if ($postcodeIsNumeric || $postcodeIsRange) { @@ -362,7 +382,7 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb if ($postcode != '*' || $postcodeIsRange) { $select->where( "rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', ?)", - $postcodeIsRange ? $postcode : $this->_createSearchPostCodeTemplates($postcode) + $postcodeIsRange ? $postcode : $this->_createSearchPostCodeTemplates($postcode, $originalPostcode) ); if ($postcodeIsNumeric) { $selectClone->where('? BETWEEN rate.zip_from AND rate.zip_to', $postcode); diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index e7870a63e7a..12c89937e41 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-reports": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-configurable-product": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-reports": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-configurable-product": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/view/adminhtml/layout/sales_creditmemo_item_price.xml b/app/code/Magento/Tax/view/adminhtml/layout/sales_creditmemo_item_price.xml new file mode 100644 index 00000000000..00ceda94217 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/layout/sales_creditmemo_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="creditmemo_items"> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/sales_invoice_item_price.xml b/app/code/Magento/Tax/view/adminhtml/layout/sales_invoice_item_price.xml new file mode 100644 index 00000000000..d3176f17fad --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/layout/sales_invoice_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="invoice_items"> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/sales_order_create_item_price.xml b/app/code/Magento/Tax/view/adminhtml/layout/sales_order_create_item_price.xml new file mode 100644 index 00000000000..e6bcd4e4990 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/layout/sales_order_create_item_price.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_unit_price" template="order/create/items/price/unit.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_row_total" template="order/create/items/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_row_total_with_discount" template="order/create/items/price/total.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/sales_order_item_price.xml b/app/code/Magento/Tax/view/adminhtml/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..bf0e841e1e3 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/layout/sales_order_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="order_items"> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Tax\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/items/price/row.phtml b/app/code/Magento/Tax/view/adminhtml/templates/items/price/row.phtml new file mode 100644 index 00000000000..7f803660814 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/items/price/row.phtml @@ -0,0 +1,48 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayBothPrices() || $this->displayPriceExclTax()): ?> + <div class="price-excl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?> + </div> +<?php endif; ?> +<?php if ($this->displayBothPrices() || $this->displayPriceInclTax()): ?> + <div class="price-incl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> + <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBaseSubtotalInclTax($_item); ?> + <?php echo $this->displayPrices($_baseIncl, $_incl) ?> + </div> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/items/price/total.phtml b/app/code/Magento/Tax/view/adminhtml/templates/items/price/total.phtml new file mode 100644 index 00000000000..3a0d0193ba0 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/items/price/total.phtml @@ -0,0 +1,31 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php echo $this->displayPrices($this->getBaseTotalAmount($_item), $this->getTotalAmount($_item)) ?> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/items/price/unit.phtml b/app/code/Magento/Tax/view/adminhtml/templates/items/price/unit.phtml new file mode 100644 index 00000000000..4deec41ead9 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/items/price/unit.phtml @@ -0,0 +1,51 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceExclTax()): ?> + <div class="price-excl-tax"> + <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + + <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?> + </div> +<?php endif; ?> +<?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices() || $this->helper('Magento\Tax\Helper\Data')->displaySalesPriceInclTax()): ?> + <div class="price-incl-tax"> + <?php if ($this->helper('Magento\Tax\Helper\Data')->displaySalesBothPrices()): ?> + <span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> + <?php $_baseIncl = $this->helper('Magento\Checkout\Helper\Data')->getBasePriceInclTax($_item); ?> + + <?php echo $this->displayPrices($_baseIncl, $_incl) ?> + + </div> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/row.phtml b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/row.phtml new file mode 100644 index 00000000000..18969a7209d --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/row.phtml @@ -0,0 +1,44 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices($this->getStore())): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($_item->getRowTotal()) ?> +<?php endif; ?> + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> + <?php echo $this->formatPrice($_incl) ?> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml new file mode 100644 index 00000000000..f3850e61eed --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml @@ -0,0 +1,46 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php $_rowTotalWithoutDiscount = $_item->getRowTotal() - $_item->getDiscountAmount(); ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice(max(0, $_rowTotalWithoutDiscount)) ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices($this->getStore())): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $_item->getPriceInclTax() * $_item->getQty() - $_item->getDiscountAmount(); ?> + <?php echo $this->formatPrice($_incl) ?> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/unit.phtml b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/unit.phtml new file mode 100644 index 00000000000..cdfa5685d63 --- /dev/null +++ b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/unit.phtml @@ -0,0 +1,45 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($_item->getCalculationPrice()) ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> + <?php echo $this->formatPrice($_incl) ?> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml b/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml new file mode 100644 index 00000000000..8e860e82905 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="items"> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_price" template="email/items/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">email</argument> + </arguments> + </block> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/frontend/layout/sales_order_item_price.xml b/app/code/Magento/Tax/view/frontend/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..e4560a2c2c3 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/layout/sales_order_item_price.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_unit_price" template="item/price/unit.phtml"> + <arguments> + <argument name="zone" xsi:type="string">sales</argument> + </arguments> + </block> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_row_total" template="item/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">sales</argument> + </arguments> + </block> + <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_row_total_after_discount" template="item/price/total_after_discount.phtml"/> +</page> diff --git a/app/code/Magento/Tax/view/frontend/templates/email/items/price/row.phtml b/app/code/Magento/Tax/view/frontend/templates/email/items/price/row.phtml new file mode 100644 index 00000000000..d5346fa7254 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/templates/email/items/price/row.phtml @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Tax\Block\Item\Price\Renderer $this */ + +$_item = $this->getItem(); +/** @var \Magento\Sales\Model\Order $_order */ +$_order = $_item->getOrder(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $_order->formatPrice($_item->getRowTotal()) ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> + <?php echo $_order->formatPrice($_incl) ?> +<?php endif; ?> diff --git a/app/code/Magento/Tax/view/frontend/templates/item/price/row.phtml b/app/code/Magento/Tax/view/frontend/templates/item/price/row.phtml index 59506d4369b..5a8143977d0 100644 --- a/app/code/Magento/Tax/view/frontend/templates/item/price/row.phtml +++ b/app/code/Magento/Tax/view/frontend/templates/item/price/row.phtml @@ -29,7 +29,7 @@ $_item = $this->getItem(); <?php if (($this->displayPriceInclTax() || $this->displayBothPrices()) && !$_item->getNoSubtotal()): ?> <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax'));?>"> <span class="cart price"> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotalInclTax()) ?> + <?php echo $this->formatPrice($_item->getRowTotalInclTax()) ?> </span> </span> <?php endif; ?> @@ -37,7 +37,7 @@ $_item = $this->getItem(); <?php if (($this->displayPriceExclTax() || $this->displayBothPrices()) && !$_item->getNoSubtotal()): ?> <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax'));?>"> <span class="cart price"> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()) ?> + <?php echo $this->formatPrice($_item->getRowTotal()) ?> </span> </span> <?php endif; ?> diff --git a/app/code/Magento/Tax/view/frontend/templates/item/price/total_after_discount.phtml b/app/code/Magento/Tax/view/frontend/templates/item/price/total_after_discount.phtml new file mode 100644 index 00000000000..d51574e8f28 --- /dev/null +++ b/app/code/Magento/Tax/view/frontend/templates/item/price/total_after_discount.phtml @@ -0,0 +1,29 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** @var \Magento\Tax\Block\Item\Price\Renderer $this */ +$_item = $this->getItem(); +?> +<?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> +<?php echo $_order->formatPrice($this->getTotalAmount($_item))?> \ No newline at end of file diff --git a/app/code/Magento/Tax/view/frontend/templates/item/price/unit.phtml b/app/code/Magento/Tax/view/frontend/templates/item/price/unit.phtml index 0e55d449a60..59ed24ece87 100644 --- a/app/code/Magento/Tax/view/frontend/templates/item/price/unit.phtml +++ b/app/code/Magento/Tax/view/frontend/templates/item/price/unit.phtml @@ -29,9 +29,9 @@ $_item = $this->getItem(); <?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> <span class="incl tax" data-th="<?php echo $this->escapeHtml(__('Incl. Tax')); ?>"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> + <?php $_incl = $_item->getPriceInclTax(); ?> <span class="cart price"> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl) ?> + <?php echo $this->formatPrice($_incl) ?> </span> </span> <?php endif; ?> @@ -39,7 +39,7 @@ $_item = $this->getItem(); <?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> <span class="excl tax" data-th="<?php echo $this->escapeHtml(__('Excl. Tax')); ?>"> <span class="cart price"> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()) ?> + <?php echo $this->formatPrice($this->getItemDisplayPriceExclTax()) ?> </span> </span> <?php endif; ?> diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 52a8f435b0d..ad63426c75a 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-translation": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-translation": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/view/adminhtml/web/js/bootstrap.js b/app/code/Magento/Theme/view/adminhtml/web/js/bootstrap.js index 82ba24f40ed..13a4e1c35af 100644 --- a/app/code/Magento/Theme/view/adminhtml/web/js/bootstrap.js +++ b/app/code/Magento/Theme/view/adminhtml/web/js/bootstrap.js @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ require([ - "jquery/file-uploader", + "jquery/fileUploader/jquery.fileupload-ui", "mage/adminhtml/browser", "Magento_Theme/js/form", "Magento_Theme/js/sortable" diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 7b89e76b425..e6dba2e8d78 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-core": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 7e1cdf0adfd..f2939aace84 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/composer.json b/app/code/Magento/UrlRedirect/composer.json index 01da2de0e8e..6d0e67acab6 100644 --- a/app/code/Magento/UrlRedirect/composer.json +++ b/app/code/Magento/UrlRedirect/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-install": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92" + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-install": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php index e9ca1cfcbc7..6334646455d 100644 --- a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php @@ -61,6 +61,11 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel */ const TYPE_CUSTOM = 3; + /** + * Field name for loading path + */ + const PATH_FIELD = 'id_path'; + /** * Cache tag for clear cache in after save and after delete * @@ -76,9 +81,14 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $_cookieMetadataFactory; + + /** + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $_cookie; + protected $_cookieManager; /** * @var \Magento\Store\Model\StoreManagerInterface @@ -94,7 +104,8 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager, * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -105,7 +116,8 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\Stdlib\Cookie $cookie, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, + \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -114,7 +126,8 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel ) { $this->_scopeConfig = $scopeConfig; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_cookie = $cookie; + $this->_cookieManager = $cookieManager; + $this->_cookieMetadataFactory = $cookieMetadataFactory; $this->_storeManager = $storeManager; $this->_httpContext = $httpContext; } @@ -171,39 +184,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel */ public function loadByIdPath($path) { - $this->setId(null)->load($path, 'id_path'); - return $this; - } - - /** - * @param mixed $tags - * @return $this - */ - public function loadByTags($tags) - { - $this->setId(null); - - $loadTags = is_array($tags) ? $tags : explode(',', $tags); - - $search = $this->getResourceCollection(); - foreach ($loadTags as $key => $tag) { - if (!is_numeric($key)) { - $tag = $key . '=' . $tag; - } - $search->addTagsFilter($tag); - } - if (!is_null($this->getStoreId())) { - $search->addStoreFilter($this->getStoreId()); - } - - $search->setPageSize(1)->load(); - - if ($search->getSize() > 0) { - foreach ($search as $rewrite) { - $this->setData($rewrite->getData()); - } - } - + $this->setId(null)->load($path, self::PATH_FIELD); return $this; } @@ -218,56 +199,6 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel return array_search($key, $optArr) !== false; } - /** - * @param mixed $tags - * @return $this - */ - public function addTag($tags) - { - $curTags = $this->getTags(); - - $addTags = is_array($tags) ? $tags : explode(',', $tags); - - foreach ($addTags as $key => $tag) { - if (!is_numeric($key)) { - $tag = $key . '=' . $tag; - } - if (!in_array($tag, $curTags)) { - $curTags[] = $tag; - } - } - - $this->setTags($curTags); - - return $this; - } - - /** - * @param mixed $tags - * @return $this - */ - public function removeTag($tags) - { - $curTags = $this->getTags(); - - $removeTags = is_array($tags) ? $tags : explode(',', $tags); - - foreach ($removeTags as $key => $tag) { - if (!is_numeric($key)) { - $tag = $key . '=' . $tag; - } - - $tagKey = array_search($tag, $curTags); - if ($tagKey) { - unset($curTags[$tagKey]); - } - } - - $this->setTags(',', $curTags); - - return $this; - } - /** * Perform custom url rewrites * @@ -308,6 +239,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel $this->loadByRequestPath($requestCases); + $targetUrl = $request->getBaseUrl(); /** * Try to find rewrite by request path at first, if no luck - try to find by id_path */ @@ -325,8 +257,14 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel $currentStore = $this->_storeManager->getStore(); $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); - $this->_cookie->set(\Magento\Store\Model\Store::COOKIE_NAME, $currentStore->getCode(), true); - $targetUrl = $request->getBaseUrl() . '/' . $this->getRequestPath(); + $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDurationOneYear(); + $this->_cookieManager->setPublicCookie( + \Magento\Store\Model\Store::COOKIE_NAME, + $currentStore->getCode(), + $cookieMetadata + ); + $targetUrl .= '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); } @@ -341,10 +279,18 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); - $this->_cookie->set(\Magento\Store\Model\Store::COOKIE_NAME, $destinationStoreCode, true); + + $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDurationOneYear(); + $this->_cookieManager->setPublicCookie( + \Magento\Store\Model\Store::COOKIE_NAME, + $destinationStoreCode, + $cookieMetadata + ); + $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { - $targetUrl = $request->getBaseUrl() . '/' . $this->getTargetPath(); + $targetUrl .= '/' . $this->getTargetPath(); } $isRedirectOption = $this->hasOption('R'); $isStoreInUrl = $this->_scopeConfig->getValue( @@ -353,21 +299,24 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel ); if ($isRedirectOption || $isPermanentRedirectOption) { if ($isStoreInUrl && ($storeCode = $this->_storeManager->getStore()->getCode())) { - $targetUrl = $request->getBaseUrl() . '/' . $storeCode . '/' . $this->getTargetPath(); + $targetUrl .= '/' . $storeCode . '/' . $this->getTargetPath(); } $this->_sendRedirectHeaders($targetUrl, $isPermanentRedirectOption); } if ($isStoreInUrl && ($storeCode = $this->_storeManager->getStore()->getCode())) { - $targetUrl = $request->getBaseUrl() . '/' . $storeCode . '/' . $this->getTargetPath(); + $targetUrl .= '/' . $storeCode . '/' . $this->getTargetPath(); } $queryString = $this->_getQueryString(); if ($queryString) { + + $targetUrl .= '?' . $queryString; } + $request->setRequestUri($targetUrl); $request->setPathInfo($this->getTargetPath()); diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 673c7244868..5c70fd9304b 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRewrite/etc/module.xml b/app/code/Magento/UrlRewrite/etc/module.xml index 61de1204f9f..cfc1b944e80 100644 --- a/app/code/Magento/UrlRewrite/etc/module.xml +++ b/app/code/Magento/UrlRewrite/etc/module.xml @@ -26,9 +26,9 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_UrlRewrite" schema_version="1.0.0.0" active="true"> <depends> - <module name="Magento_Catalog" /> - <module name="Magento_Core" /> <module name="Magento_Store" /> + <module name="Magento_Core" /> + <module name="Magento_Catalog" /> </depends> </module> </config> diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index 38febed7db2..b9e6dfec78e 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-authorization": "0.1.0-alpha92", - "magento/module-store": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-integration": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-authorization": "0.1.0-alpha93", + "magento/module-store": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-integration": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index 68f8e2d4340..bfeb6ca5f14 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-shipping": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-shipping": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/Controller/Request.php b/app/code/Magento/Webapi/Controller/Request.php index 56e8a01f2c3..0a53badc0c1 100644 --- a/app/code/Magento/Webapi/Controller/Request.php +++ b/app/code/Magento/Webapi/Controller/Request.php @@ -30,16 +30,23 @@ class Request extends \Zend_Controller_Request_Http implements \Magento\Framewor /** @var int */ protected $_consumerId = 0; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $_cookieManager; + /** * Modify pathInfo: strip down the front name and query parameters. * * @param \Magento\Framework\App\AreaList $areaList * @param \Magento\Framework\Config\ScopeInterface $configScope + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param null|string|\Zend_Uri $uri */ public function __construct( \Magento\Framework\App\AreaList $areaList, \Magento\Framework\Config\ScopeInterface $configScope, + \Magento\Framework\Stdlib\CookieManager $cookieManager, $uri = null ) { parent::__construct($uri); @@ -49,5 +56,18 @@ class Request extends \Zend_Controller_Request_Http implements \Magento\Framewor $this->_pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $this->_pathInfo); /** Remove GET parameters from path */ $this->_pathInfo = preg_replace('#\?.*#', '', $this->_pathInfo); + $this->_cookieManager = $cookieManager; + } + + /** + * Retrieve a value from a cookie. + * + * @param string|null $name + * @param string|null $default The default value to return if no value could be found for the given $name. + * @return string|null + */ + public function getCookie($name = null, $default = null) + { + return $this->_cookieManager->getCookie($name, $default); } } diff --git a/app/code/Magento/Webapi/Controller/Rest/Request.php b/app/code/Magento/Webapi/Controller/Rest/Request.php index cc9dc28f537..ffa2c62e932 100644 --- a/app/code/Magento/Webapi/Controller/Rest/Request.php +++ b/app/code/Magento/Webapi/Controller/Rest/Request.php @@ -52,16 +52,18 @@ class Request extends \Magento\Webapi\Controller\Request * * @param \Magento\Framework\App\AreaList $areaList * @param \Magento\Framework\Config\ScopeInterface $configScope + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory $deserializerFactory * @param null|string $uri */ public function __construct( \Magento\Framework\App\AreaList $areaList, \Magento\Framework\Config\ScopeInterface $configScope, + \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory $deserializerFactory, $uri = null ) { - parent::__construct($areaList, $configScope, $uri); + parent::__construct($areaList, $configScope, $cookieManager, $uri); $this->_deserializerFactory = $deserializerFactory; } diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php index 46ec6fa7a86..d88613edaa3 100644 --- a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php +++ b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php @@ -438,6 +438,8 @@ class TypeProcessor * @param string $type Convert given value to the this simple type * @return int|string|float|int[]|string[]|float[] Return the value which is converted to type * @throws \Magento\Webapi\Exception + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function processSimpleAndAnyType($value, $type) { @@ -445,12 +447,12 @@ class TypeProcessor if ($this->isArrayType($type) && is_array($value)) { $arrayItemType = $this->getArrayItemType($type); foreach (array_keys($value) as $key) { - if (!settype($value[$key], $arrayItemType)) { + if ($value !== null && !settype($value[$key], $arrayItemType)) { throw new \Magento\Webapi\Exception(sprintf($invalidTypeMsg, $value, $type)); } } } elseif (!$this->isArrayType($type) && !is_array($value)) { - if ($type !== self::ANY_TYPE && !settype($value, $type)) { + if ($value !== null && $type !== self::ANY_TYPE && !settype($value, $type)) { throw new \Magento\Webapi\Exception(sprintf($invalidTypeMsg, $value, $type)); } } else { diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 49b014ad840..e24e855b52e 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-authorization": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-integration": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-user": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-authorization": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-integration": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-user": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Weee/Block/Adminhtml/Items/Price/Renderer.php b/app/code/Magento/Weee/Block/Adminhtml/Items/Price/Renderer.php new file mode 100644 index 00000000000..690eaccd8d2 --- /dev/null +++ b/app/code/Magento/Weee/Block/Adminhtml/Items/Price/Renderer.php @@ -0,0 +1,202 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Weee\Block\Adminhtml\Items\Price; + +use Magento\Weee\Block\Item\Price\Renderer as ItemPriceRenderer; +use Magento\Sales\Model\Order\Item; +use Magento\Sales\Model\Quote\Item\AbstractItem as QuoteItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem; + +/** + * Sales Order items price column renderer + */ +class Renderer extends \Magento\Tax\Block\Adminhtml\Items\Price\Renderer +{ + /** + * @var \Magento\Weee\Block\Item\Price\Renderer + */ + protected $itemPriceRenderer; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer + * @param \Magento\Tax\Helper\Data $taxHelper + * @param ItemPriceRenderer $itemPriceRenderer + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer, + \Magento\Tax\Helper\Data $taxHelper, + ItemPriceRenderer $itemPriceRenderer, + array $data = array() + ) { + parent::__construct( + $context, + $defaultColumnRenderer, + $taxHelper, + $itemPriceRenderer, + $data + ); + } + + /** + * Whether to display weee details together with price + * + * @return bool + */ + public function displayPriceWithWeeeDetails() + { + return $this->itemPriceRenderer->displayPriceWithWeeeDetails(); + } + + /** + * Whether to display final price that include Weee amounts + * + * @return bool + */ + public function displayFinalPrice() + { + return $this->itemPriceRenderer->displayFinalPrice(); + } + + /** + * Return HTML for unit price excl tax + * + * @return string + */ + public function getUnitPriceExclTaxHtml() + { + $baseUnitPriceExclTax = $this->itemPriceRenderer->getBaseUnitDisplayPriceExclTax(); + $unitPriceExclTax = $this->itemPriceRenderer->getUnitDisplayPriceExclTax(); + return $this->displayPrices($baseUnitPriceExclTax, $unitPriceExclTax); + } + + /** + * Return HTML for row price excl tax + * + * @return string + */ + public function getRowPriceExclTaxHtml() + { + $baseRowPriceExclTax = $this->itemPriceRenderer->getBaseRowDisplayPriceExclTax(); + $rowPriceExclTax = $this->itemPriceRenderer->getRowDisplayPriceExclTax(); + return $this->displayPrices($baseRowPriceExclTax, $rowPriceExclTax); + } + + /** + * Return HTML for unit price incl tax + * + * @return string + */ + public function getUnitPriceInclTaxHtml() + { + $baseUnitPriceInclTax = $this->itemPriceRenderer->getBaseUnitDisplayPriceInclTax(); + $unitPriceInclTax = $this->itemPriceRenderer->getUnitDisplayPriceInclTax(); + return $this->displayPrices($baseUnitPriceInclTax, $unitPriceInclTax); + } + + /** + * Return HTML for row price incl tax + * + * @return string + */ + public function getRowPriceInclTaxHtml() + { + $baseRowPriceInclTax = $this->itemPriceRenderer->getBaseRowDisplayPriceInclTax(); + $rowPriceInclTax = $this->itemPriceRenderer->getRowDisplayPriceInclTax(); + return $this->displayPrices($baseRowPriceInclTax, $rowPriceInclTax); + } + + /** + * Return HTML for final unit price excl tax + * + * @return string + */ + public function getFinalUnitPriceExclTaxHtml() + { + $baseUnitPriceExclTax = $this->itemPriceRenderer->getBaseFinalUnitDisplayPriceExclTax(); + $unitPriceExclTax = $this->itemPriceRenderer->getFinalUnitDisplayPriceExclTax(); + return $this->displayPrices($baseUnitPriceExclTax, $unitPriceExclTax); + } + + /** + * Return HTML for final row price excl tax + * + * @return string + */ + public function getFinalRowPriceExclTaxHtml() + { + $baseRowPriceExclTax = $this->itemPriceRenderer->getBaseFinalRowDisplayPriceExclTax(); + $rowPriceExclTax = $this->itemPriceRenderer->getFinalRowDisplayPriceExclTax(); + return $this->displayPrices($baseRowPriceExclTax, $rowPriceExclTax); + } + + /** + * Return HTML for final unit price incl tax + * + * @return string + */ + public function getFinalUnitPriceInclTaxHtml() + { + $baseUnitPriceInclTax = $this->itemPriceRenderer->getBaseFinalUnitDisplayPriceInclTax(); + $unitPriceInclTax = $this->itemPriceRenderer->getFinalUnitDisplayPriceInclTax(); + return $this->displayPrices($baseUnitPriceInclTax, $unitPriceInclTax); + } + + /** + * Return HTML for final row price incl tax + * + * @return string + */ + public function getFinalRowPriceInclTaxHtml() + { + $baseRowPriceInclTax = $this->itemPriceRenderer->getBaseFinalRowDisplayPriceInclTax(); + $rowPriceInclTax = $this->itemPriceRenderer->getFinalRowDisplayPriceInclTax(); + return $this->displayPrices($baseRowPriceInclTax, $rowPriceInclTax); + } + + /** + * Calculate total amount for the item + * + * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + return $this->itemPriceRenderer->getTotalAmount($item); + } + + /** + * Calculate base total amount for the item + * + * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item + * @return mixed + */ + public function getBaseTotalAmount($item) + { + return $this->itemPriceRenderer->getBaseTotalAmount($item); + } +} diff --git a/app/code/Magento/Weee/Block/Item/Price/Renderer.php b/app/code/Magento/Weee/Block/Item/Price/Renderer.php index b9731673b32..31e241ea502 100644 --- a/app/code/Magento/Weee/Block/Item/Price/Renderer.php +++ b/app/code/Magento/Weee/Block/Item/Price/Renderer.php @@ -24,7 +24,9 @@ namespace Magento\Weee\Block\Item\Price; use Magento\Weee\Model\Tax as WeeeDisplayConfig; -use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Sales\Model\Order\Item as OrderItem; +use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; +use Magento\Sales\Model\Order\CreditMemo\Item as CreditMemoItem; /** * Item price render block @@ -38,27 +40,19 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer */ protected $weeeHelper; - /** - * @var \Magento\Framework\Pricing\PriceCurrencyInterface - */ - protected $priceCurrency; - /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Tax\Helper\Data $taxHelper * @param \Magento\Weee\Helper\Data $weeeHelper - * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Helper\Data $taxHelper, \Magento\Weee\Helper\Data $weeeHelper, - PriceCurrencyInterface $priceCurrency, array $data = array() ) { $this->weeeHelper = $weeeHelper; - $this->priceCurrency = $priceCurrency; parent::__construct($context, $taxHelper, $data); $this->_isScopePrivate = true; } @@ -74,7 +68,12 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return false; } - if (!$this->weeeHelper->typeOfDisplay([WeeeDisplayConfig::DISPLAY_INCL_DESCR], 'sales')) { + $displayWeeeDetails = $this->weeeHelper->typeOfDisplay( + [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL], + $this->getZone(), + $this->getStoreId() + ); + if (!$displayWeeeDetails) { return false; } @@ -85,6 +84,21 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return true; } + /** + * Return the flag whether to include weee in the price + * + * @return bool|int + */ + public function getIncludeWeeeFlag() + { + $includeWeee = $this->weeeHelper->typeOfDisplay( + [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], + $this->getZone(), + $this->getStoreId() + ); + return $includeWeee; + } + /** * Get display price for unit price including tax. The Weee amount will be added to unit price including tax * depending on Weee display setting @@ -99,14 +113,34 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $priceInclTax; } - if ($this->weeeHelper - ->typeOfDisplay([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales')) { + if ($this->getIncludeWeeeFlag()) { return $priceInclTax + $this->weeeHelper->getWeeeTaxInclTax($this->getItem()); } return $priceInclTax; } + /** + * Get base price for unit price including tax. The Weee amount will be added to unit price including tax + * depending on Weee display setting + * + * @return float + */ + public function getBaseUnitDisplayPriceInclTax() + { + $basePriceInclTax = $this->getItem()->getBasePriceInclTax(); + + if (!$this->weeeHelper->isEnabled()) { + return $basePriceInclTax; + } + + if ($this->getIncludeWeeeFlag()) { + return $basePriceInclTax + $this->weeeHelper->getBaseWeeeTaxInclTax($this->getItem()); + } + + return $basePriceInclTax; + } + /** * Get display price for row total including tax. The Weee amount will be added to row total including tax * depending on Weee display setting @@ -121,14 +155,34 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $rowTotalInclTax; } - if ($this->weeeHelper-> - typeOfDisplay([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales')) { + if ($this->getIncludeWeeeFlag()) { return $rowTotalInclTax + $this->weeeHelper->getRowWeeeTaxInclTax($this->getItem()); } return $rowTotalInclTax; } + /** + * Get base price for row total including tax. The Weee amount will be added to row total including tax + * depending on Weee display setting + * + * @return float + */ + public function getBaseRowDisplayPriceInclTax() + { + $baseRowTotalInclTax = $this->getItem()->getBaseRowTotalInclTax(); + + if (!$this->weeeHelper->isEnabled()) { + return $baseRowTotalInclTax; + } + + if ($this->getIncludeWeeeFlag()) { + return $baseRowTotalInclTax + $this->weeeHelper->getBaseRowWeeeTaxInclTax($this->getItem()); + } + + return $baseRowTotalInclTax; + } + /** * Get display price for unit price excluding tax. The Weee amount will be added to unit price * depending on Weee display setting @@ -137,20 +191,40 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer */ public function getUnitDisplayPriceExclTax() { - $priceExclTax = $this->getItem()->getCalculationPrice(); + $priceExclTax = $this->getItemDisplayPriceExclTax(); if (!$this->weeeHelper->isEnabled()) { return $priceExclTax; } - if ($this->weeeHelper - ->typeOfDisplay([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales')) { + if ($this->getIncludeWeeeFlag()) { return $priceExclTax + $this->getItem()->getWeeeTaxAppliedAmount(); } return $priceExclTax; } + /** + * Get base price for unit price excluding tax. The Weee amount will be added to unit price + * depending on Weee display setting + * + * @return float + */ + public function getBaseUnitDisplayPriceExclTax() + { + $basePriceExclTax = $this->getItem()->getBasePrice(); + + if (!$this->weeeHelper->isEnabled()) { + return $basePriceExclTax; + } + + if ($this->getIncludeWeeeFlag()) { + return $basePriceExclTax + $this->getItem()->getBaseWeeeTaxAppliedAmount(); + } + + return $basePriceExclTax; + } + /** * Get display price for row total excluding tax. The Weee amount will be added to row total * depending on Weee display setting @@ -165,14 +239,34 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $rowTotalExclTax; } - if ($this->weeeHelper - ->typeOfDisplay([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales')) { + if ($this->getIncludeWeeeFlag()) { return $rowTotalExclTax + $this->getItem()->getWeeeTaxAppliedRowAmount(); } return $rowTotalExclTax; } + /** + * Get base price for row total excluding tax. The Weee amount will be added to row total + * depending on Weee display setting + * + * @return float + */ + public function getBaseRowDisplayPriceExclTax() + { + $baseRowTotalExclTax = $this->getItem()->getBaseRowTotal(); + + if (!$this->weeeHelper->isEnabled()) { + return $baseRowTotalExclTax; + } + + if ($this->getIncludeWeeeFlag()) { + return $baseRowTotalExclTax + $this->getItem()->getBaseWeeeTaxAppliedRowAmnt(); + } + + return $baseRowTotalExclTax; + } + /** * Get final unit display price including tax, this will add Weee amount to unit price include tax * @@ -189,6 +283,22 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $priceInclTax + $this->weeeHelper->getWeeeTaxInclTax($this->getItem()); } + /** + * Get base final unit display price including tax, this will add Weee amount to unit price include tax + * + * @return float + */ + public function getBaseFinalUnitDisplayPriceInclTax() + { + $basePriceInclTax = $this->getItem()->getBasePriceInclTax(); + + if (!$this->weeeHelper->isEnabled()) { + return $basePriceInclTax; + } + + return $basePriceInclTax + $this->weeeHelper->getBaseWeeeTaxInclTax($this->getItem()); + } + /** * Get final row display price including tax, this will add weee amount to rowTotalInclTax * @@ -205,6 +315,22 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $rowTotalInclTax + $this->weeeHelper->getRowWeeeTaxInclTax($this->getItem()); } + /** + * Get base final row display price including tax, this will add weee amount to rowTotalInclTax + * + * @return float + */ + public function getBaseFinalRowDisplayPriceInclTax() + { + $baseRowTotalInclTax = $this->getItem()->getBaseRowTotalInclTax(); + + if (!$this->weeeHelper->isEnabled()) { + return $baseRowTotalInclTax; + } + + return $baseRowTotalInclTax + $this->weeeHelper->getBaseRowWeeeTaxInclTax($this->getItem()); + } + /** * Get final unit display price excluding tax * @@ -212,7 +338,7 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer */ public function getFinalUnitDisplayPriceExclTax() { - $priceExclTax = $this->getItem()->getCalculationPrice(); + $priceExclTax = $this->getItemDisplayPriceExclTax(); if (!$this->weeeHelper->isEnabled()) { return $priceExclTax; @@ -221,6 +347,22 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $priceExclTax + $this->getItem()->getWeeeTaxAppliedAmount(); } + /** + * Get base final unit display price excluding tax + * + * @return float + */ + public function getBaseFinalUnitDisplayPriceExclTax() + { + $basePriceExclTax = $this->getItem()->getBasePrice(); + + if (!$this->weeeHelper->isEnabled()) { + return $basePriceExclTax; + } + + return $basePriceExclTax + $this->getItem()->getBaseWeeeTaxAppliedAmount(); + } + /** * Get final row display price excluding tax, this will add Weee amount to rowTotal * @@ -237,6 +379,22 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer return $rowTotalExclTax + $this->getItem()->getWeeeTaxAppliedRowAmount(); } + /** + * Get base final row display price excluding tax, this will add Weee amount to rowTotal + * + * @return float + */ + public function getBaseFinalRowDisplayPriceExclTax() + { + $baseRowTotalExclTax = $this->getItem()->getBaseRowTotal(); + + if (!$this->weeeHelper->isEnabled()) { + return $baseRowTotalExclTax; + } + + return $baseRowTotalExclTax + $this->getItem()->getBaseWeeeTaxAppliedRowAmnt(); + } + /** * Whether to display final price that include Weee amounts * @@ -244,7 +402,13 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer */ public function displayFinalPrice() { - if (!$this->weeeHelper->typeOfDisplay(WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, 'sales')) { + $flag = $this->weeeHelper->typeOfDisplay( + WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + $this->getZone(), + $this->getStoreId() + ); + + if (!$flag) { return false; } @@ -255,13 +419,36 @@ class Renderer extends \Magento\Tax\Block\Item\Price\Renderer } /** - * Format price + * Return the total amount minus discount + * + * @param OrderItem|InvoiceItem|CreditMemoItem $item + * @return mixed + */ + public function getTotalAmount($item) + { + $totalAmount = $item->getRowTotal() + - $item->getDiscountAmount() + + $item->getTaxAmount() + + $item->getHiddenTaxAmount() + + $this->weeeHelper->getRowWeeeTaxInclTax($item); + + return $totalAmount; + } + + /** + * Return the total amount minus discount * - * @param float $price - * @return string + * @param OrderItem|InvoiceItem|CreditMemoItem $item + * @return mixed */ - public function formatPrice($price) + public function getBaseTotalAmount($item) { - return $this->priceCurrency->format($price); + $totalAmount = $item->getBaseRowTotal() + - $item->getBaseDiscountAmount() + + $item->getBaseTaxAmount() + + $item->getBaseHiddenTaxAmount() + + $this->weeeHelper->getBaseRowWeeeTaxInclTax($item); + + return $totalAmount; } } diff --git a/app/code/Magento/Weee/Helper/Data.php b/app/code/Magento/Weee/Helper/Data.php index da26c0d20dc..0de6a7aa9ea 100644 --- a/app/code/Magento/Weee/Helper/Data.php +++ b/app/code/Magento/Weee/Helper/Data.php @@ -221,7 +221,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * * @param int|int[]|null $compareTo * @param string $zone - * @param Store $store + * @param Store|int|string $store * @return bool|int */ public function typeOfDisplay( @@ -240,6 +240,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $type = $this->getListPriceDisplayType($store); break; case \Magento\Framework\Pricing\Render::ZONE_SALES: + case \Magento\Framework\Pricing\Render::ZONE_CART: $type = $this->getSalesPriceDisplayType($store); break; case \Magento\Framework\Pricing\Render::ZONE_EMAIL: diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index b1fee54436b..c56c0412be1 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-tax": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-directory": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-eav": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-bundle": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-tax": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-directory": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-eav": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-bundle": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_creditmemo_item_price.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_creditmemo_item_price.xml new file mode 100644 index 00000000000..60e34e325d0 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_creditmemo_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="creditmemo_items"> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_invoice_item_price.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_invoice_item_price.xml new file mode 100644 index 00000000000..12aaf4b4e51 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_invoice_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="invoice_items"> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_create_item_price.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_create_item_price.xml new file mode 100644 index 00000000000..b5fd4edb48f --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_create_item_price.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_unit_price" template="order/create/items/price/unit.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_row_total" template="order/create/items/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_row_total_with_discount" template="order/create/items/price/total.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> +</page> diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_item_price.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..d2f4cbbfc3e --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_item_price.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="order_items"> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_price" template="items/price/unit.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_subtotal" template="items/price/row.phtml" group="column"/> + <block class="Magento\Weee\Block\Adminhtml\Items\Price\Renderer" name="column_total" template="items/price/total.phtml" group="column"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/items/price/row.phtml b/app/code/Magento/Weee/view/adminhtml/templates/items/price/row.phtml new file mode 100644 index 00000000000..5269b64f3f8 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/items/price/row.phtml @@ -0,0 +1,85 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Adminhtml\Items\Price\Renderer $this */ + +/** @var $_weeeHelper \Magento\Weee\Helper\Data */ +$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); + +$_item = $this->getItem(); +?> + +<?php if ($this->displayBothPrices() || $this->displayPriceExclTax()): ?> + <div class="price-excl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + + <?php echo $this->getRowPriceExclTaxHtml() ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->getFinalRowPriceExclTaxHtml(); ?> + </span> + <?php endif; ?> + <?php endif; ?> + </div> +<?php endif; ?> +<?php if ($this->displayBothPrices() || $this->displayPriceInclTax()): ?> + <div class="price-incl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->getRowPriceInclTaxHtml(); ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->getFinalRowPriceInclTaxHtml(); ?> + </span> + <?php endif; ?> + <?php endif; ?> + </div> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/items/price/total.phtml b/app/code/Magento/Weee/view/adminhtml/templates/items/price/total.phtml new file mode 100644 index 00000000000..2be9c6b6fc3 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/items/price/total.phtml @@ -0,0 +1,31 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Adminhtml\Items\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php echo $this->displayPrices($this->getBaseTotalAmount($_item), $this->getTotalAmount($_item)) ?> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/items/price/unit.phtml b/app/code/Magento/Weee/view/adminhtml/templates/items/price/unit.phtml new file mode 100644 index 00000000000..dee7a501be3 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/items/price/unit.phtml @@ -0,0 +1,86 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Adminhtml\Items\Price\Renderer $this */ + +/** @var $_weeeHelper \Magento\Weee\Helper\Data */ +$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); + +$_item = $this->getItem(); +?> + +<?php if ($this->displayBothPrices() || $this->displayPriceExclTax()): ?> + <div class="price-excl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + + <?php echo $this->getUnitPriceExclTaxHtml() ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->getFinalUnitPriceExclTaxHtml(); ?> + </span> + <?php endif; ?> + <?php endif; ?> + </div> +<?php endif; ?> +<?php if ($this->displayBothPrices() || $this->displayPriceInclTax()): ?> + <div class="price-incl-tax"> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->getUnitPriceInclTaxHtml(); ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->getFinalUnitPriceInclTaxHtml(); ?> + </span> + <?php endif; ?> + <?php endif; ?> + </div> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/row.phtml b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/row.phtml new file mode 100644 index 00000000000..fad1500e97f --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/row.phtml @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var $this \Magento\Weee\Block\Item\Price\Renderer */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($this->getRowDisplayPriceExclTax()); ?> + + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalRowDisplayPriceExclTax()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($this->getRowDisplayPriceInclTax()); ?> + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalRowDisplayPriceInclTax()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml new file mode 100644 index 00000000000..0b7d5b97636 --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Item\Price\Renderer $this */ + +$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php $_rowTotalWithoutDiscount = $this->getRowDisplayPriceExclTax() - $_item->getDiscountAmount(); ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice(max(0, $_rowTotalWithoutDiscount)) ?> + + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalRowDisplayPriceExclTax() - $_item->getDiscountAmount()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php $_incl = $this->getRowDisplayPriceInclTax() - $_item->getDiscountAmount(); ?> + <?php echo $this->formatPrice(max(0, $_incl)) ?> + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalRowDisplayPriceInclTax() - $_item->getDiscountAmount()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/unit.phtml b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/unit.phtml new file mode 100644 index 00000000000..cc14f6c97eb --- /dev/null +++ b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/unit.phtml @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Item\Price\Renderer $this */ + +$_item = $this->getItem(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($this->getUnitDisplayPriceExclTax()); ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalUnitDisplayPriceExclTax()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $this->formatPrice($this->getUnitDisplayPriceInclTax()); ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->formatPrice($tax['amount_incl_tax'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> + <?php echo $this->formatPrice($this->getFinalUnitDisplayPriceInclTax()); ?> + </span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml b/app/code/Magento/Weee/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml index d35990e8485..18b588de584 100644 --- a/app/code/Magento/Weee/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml +++ b/app/code/Magento/Weee/view/frontend/layout/checkout_cart_sidebar_item_price_renderers.xml @@ -25,6 +25,10 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceBlock name="minicart"> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.cart.item.price.sidebar" template="Magento_Weee::checkout/cart/item/price/sidebar.phtml"/> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.cart.item.price.sidebar" template="checkout/cart/item/price/sidebar.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> </referenceBlock> </page> diff --git a/app/code/Magento/Weee/view/frontend/layout/checkout_item_price_renderers.xml b/app/code/Magento/Weee/view/frontend/layout/checkout_item_price_renderers.xml index aa5efb0e7e0..015f0599240 100644 --- a/app/code/Magento/Weee/view/frontend/layout/checkout_item_price_renderers.xml +++ b/app/code/Magento/Weee/view/frontend/layout/checkout_item_price_renderers.xml @@ -24,11 +24,35 @@ */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.item.price.unit" template="Magento_Weee::item/price/unit.phtml"/> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.item.price.row" template="Magento_Weee::item/price/row.phtml"/> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.excl" template="checkout/onepage/review/item/price/unit_excl_tax.phtml"/> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.incl" template="checkout/onepage/review/item/price/unit_incl_tax.phtml"/> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.excl" template="checkout/onepage/review/item/price/row_excl_tax.phtml"/> - <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.incl" template="checkout/onepage/review/item/price/row_incl_tax.phtml"/> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.excl" template="checkout/onepage/review/item/price/unit_excl_tax.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.incl" template="checkout/onepage/review/item/price/unit_incl_tax.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.excl" template="checkout/onepage/review/item/price/row_excl_tax.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.incl" template="checkout/onepage/review/item/price/row_incl_tax.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.item.price.unit" template="item/price/unit.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="checkout.item.price.row" template="item/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">cart</argument> + </arguments> + </block> </page> diff --git a/app/code/Magento/Weee/view/frontend/layout/sales_email_item_price.xml b/app/code/Magento/Weee/view/frontend/layout/sales_email_item_price.xml new file mode 100644 index 00000000000..8e66e4a7566 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/layout/sales_email_item_price.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="items"> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_price" template="email/items/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">email</argument> + </arguments> + </block> + </referenceBlock> +</page> diff --git a/app/code/Magento/Weee/view/frontend/layout/sales_order_item_price.xml b/app/code/Magento/Weee/view/frontend/layout/sales_order_item_price.xml new file mode 100644 index 00000000000..d8886b438ac --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/layout/sales_order_item_price.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_unit_price" template="item/price/unit.phtml"> + <arguments> + <argument name="zone" xsi:type="string">sales</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_row_total" template="item/price/row.phtml"> + <arguments> + <argument name="zone" xsi:type="string">sales</argument> + </arguments> + </block> + <block class="Magento\Weee\Block\Item\Price\Renderer" name="item_row_total_after_discount" template="item/price/total_after_discount.phtml"/> +</page> diff --git a/app/code/Magento/Weee/view/frontend/templates/email/items/price/row.phtml b/app/code/Magento/Weee/view/frontend/templates/email/items/price/row.phtml new file mode 100644 index 00000000000..5e8aba669ea --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/templates/email/items/price/row.phtml @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php +/** @var \Magento\Weee\Block\Item\Price\Renderer $this */ + +/** @var $_weeeHelper \Magento\Weee\Helper\Data */ +$_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); + +$_item = $this->getItem(); +/** @var \Magento\Sales\Model\Order $_order */ +$_order = $_item->getOrder(); +?> + +<?php if ($this->displayPriceExclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <span class="label"><?php echo __('Excl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $_order->formatPrice($this->getRowDisplayPriceExclTax()); ?> + + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <br /> + <span class="nobr"><?php echo __('Total'); ?>:<br /> <?php echo $_order->formatPrice($this->getFinalRowDisplayPriceExclTax()); ?></span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> + + +<?php if ($this->displayPriceInclTax() || $this->displayBothPrices()): ?> + <?php if ($this->displayBothPrices()): ?> + <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> + <?php endif; ?> + <?php echo $_order->formatPrice($this->getRowDisplayPriceInclTax()); ?> + <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> + <br /> + <?php if ($this->displayPriceWithWeeeDetails()): ?> + <small> + <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> + <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br /> + <?php endforeach; ?> + </small> + <?php endif; ?> + + <?php if ($this->displayFinalPrice()): ?> + <span class="nobr"><?php echo __('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($this->getFinalRowDisplayPriceInclTax()); ?></span> + <?php endif; ?> + <?php endif; ?> +<?php endif; ?> diff --git a/app/code/Magento/Weee/view/frontend/templates/item/price/total_after_discount.phtml b/app/code/Magento/Weee/view/frontend/templates/item/price/total_after_discount.phtml new file mode 100644 index 00000000000..137470ca099 --- /dev/null +++ b/app/code/Magento/Weee/view/frontend/templates/item/price/total_after_discount.phtml @@ -0,0 +1,29 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** @var \Magento\Weee\Block\Item\Price\Renderer $this */ +$_item = $this->getItem(); +?> +<?php $_order = $this->getItem()->getOrderItem()->getOrder() ?> +<?php echo $_order->formatPrice($this->getTotalAmount($_item))?> \ No newline at end of file diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index ebd458e2e26..ecd48386ca5 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-cms": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-cms": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Actions.php similarity index 75% rename from app/code/Magento/Sales/Service/V1/OrderCancelInterface.php rename to app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Actions.php index 6fcdae3e147..5c19595bb0e 100644 --- a/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Actions.php @@ -21,19 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; /** - * Interface OrderCancelInterface + * Wishlist for item column in customer wishlist + * + * @author Magento Core Team <core@magentocommerce.com> */ -interface OrderCancelInterface +namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column; + +class Actions extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column { - /** - * Invoke getOrder service - * - * @param int $id - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException - */ - public function invoke($id); } diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Edit.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Edit.php new file mode 100644 index 00000000000..0b57ce0a7ec --- /dev/null +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Edit.php @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Edit item in customer wishlist table + * + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column; + +class Edit extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column +{ +} diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Info.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Info.php new file mode 100644 index 00000000000..833992b6b5b --- /dev/null +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Info.php @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Wishlist block customer item cart column + * + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column; + +class Info extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column +{ +} diff --git a/app/code/Magento/Wishlist/Block/Rss.php b/app/code/Magento/Wishlist/Block/Rss.php index e07b25c14f6..5b6ecaa490c 100644 --- a/app/code/Magento/Wishlist/Block/Rss.php +++ b/app/code/Magento/Wishlist/Block/Rss.php @@ -98,7 +98,8 @@ class Rss extends \Magento\Wishlist\Block\AbstractBlock { if (is_null($this->_wishlist)) { $this->_wishlist = parent::_getWishlist(); - if ($this->_wishlist->getCustomerId() != $this->_getHelper()->getCustomer()->getId()) { + $currentCustomerId = $this->_getHelper()->getCustomer()->getId(); + if (!$this->_wishlist->getVisibility() && ($this->_wishlist->getCustomerId() != $currentCustomerId)) { $this->_wishlist->unsetData(); } } diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index eb8a6bad771..9e3b36d7ac7 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -513,7 +513,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function defaultCommentString() { - return __('Please enter your comments.'); + return __('Comment'); } /** diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 3158f34b60c..d1471bf4a8a 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha92", - "magento/module-customer": "0.1.0-alpha92", - "magento/module-catalog": "0.1.0-alpha92", - "magento/module-core": "0.1.0-alpha92", - "magento/module-checkout": "0.1.0-alpha92", - "magento/module-theme": "0.1.0-alpha92", - "magento/module-catalog-inventory": "0.1.0-alpha92", - "magento/module-rss": "0.1.0-alpha92", - "magento/module-backend": "0.1.0-alpha92", - "magento/module-bundle": "0.1.0-alpha92", - "magento/module-sales": "0.1.0-alpha92", - "magento/module-grouped-product": "0.1.0-alpha92", - "magento/module-configurable-product": "0.1.0-alpha92", - "magento/module-downloadable": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/module-store": "0.1.0-alpha93", + "magento/module-customer": "0.1.0-alpha93", + "magento/module-catalog": "0.1.0-alpha93", + "magento/module-core": "0.1.0-alpha93", + "magento/module-checkout": "0.1.0-alpha93", + "magento/module-theme": "0.1.0-alpha93", + "magento/module-catalog-inventory": "0.1.0-alpha93", + "magento/module-rss": "0.1.0-alpha93", + "magento/module-backend": "0.1.0-alpha93", + "magento/module-bundle": "0.1.0-alpha93", + "magento/module-sales": "0.1.0-alpha93", + "magento/module-grouped-product": "0.1.0-alpha93", + "magento/module-configurable-product": "0.1.0-alpha93", + "magento/module-downloadable": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml index 8eea8ecf041..755f9aeeac8 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml @@ -31,41 +31,38 @@ <referenceContainer name="content"> <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml" cacheable="false"> <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml" cacheable="false"> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" before="-" template="item/column/image.phtml" cacheable="false"> - <arguments> - <argument name="col_class" xsi:type="string">photo</argument> - </arguments> - </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.info" template="item/column/info.phtml" cacheable="false"> - <arguments> - <argument name="col_class" xsi:type="string">item</argument> - <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument> - </arguments> - </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml" cacheable="false"> - <arguments> - <argument name="col_class" xsi:type="string">actions</argument> - <argument name="title" translate="true" xsi:type="string">Add to Cart</argument> - </arguments> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml" cacheable="false" /> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false" /> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.price" template="item/column/price.phtml" cacheable="false"> <block class="Magento\Catalog\Pricing\Render" name="product.price.render.wishlist"> <arguments> <argument name="price_render" xsi:type="string">product.price.render.default</argument> <argument name="price_type_code" xsi:type="string">configured_price</argument> + <argument name="price_label" xsi:type="boolean">false</argument> <argument name="zone" xsi:type="string">item_list</argument> </arguments> </block> <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Options" name="customer.wishlist.item.options" cacheable="false"/> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false"> + <arguments> + <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument> + </arguments> + </block> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml" cacheable="false"> <arguments> - <argument name="col_class" xsi:type="string">remove</argument> + <argument name="title" translate="true" xsi:type="string">Add to Cart</argument> </arguments> </block> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.actions" template="item/column/actions.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Edit" name="customer.wishlist.item.edit" template="item/column/edit.phtml" before="-" cacheable="false" /> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml" cacheable="false"/> + </block> </block> <container name="customer.wishlist.buttons" as="control_buttons" label="Wishlist Control Buttons"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml" cacheable="false"/> <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.share" template="button/share.phtml" cacheable="false"/> <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.toCart" template="button/tocart.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml" cacheable="false"/> </container> </block> </referenceContainer> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/info.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/actions.phtml similarity index 62% rename from app/code/Magento/Wishlist/view/frontend/templates/item/column/info.phtml rename to app/code/Magento/Wishlist/view/frontend/templates/item/column/actions.phtml index 32289cb494b..9281ed0105a 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/column/info.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/actions.phtml @@ -23,21 +23,11 @@ */ /* @var \Magento\Wishlist\Model\Item $item */ -$item = $this->getItem(); -$product = $item->getProduct(); ?> -<strong class="product name"> - <a href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>"> - <?php echo $this->escapeHtml($product->getName()) ?> - </a> -</strong> -<div class="product description"> - <?php echo $this->escapeHtml($this->stripTags($product->getShortDescription()));?> -</div> -<textarea placeholder="<?php echo $this->helper('Magento\Wishlist\Helper\Data')->defaultCommentString() ?>" name="description[<?php echo $item->getWishlistItemId() ?>]" rows="3" cols="5" title="<?php echo __('Comment') ?>"><?php echo($this->escapeHtml($item->getDescription())) ?></textarea> + <?php $children = $this->getChildNames(); ?> <?php if ($children): ?> - <div class="product manage"> + <div class="product-item-actions"> <?php foreach($children as $childName):?> <?php echo $this->getLayout()->renderElement($childName, false);?> <?php endforeach;?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml index 85299fdcd36..cd2d7de3692 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/cart.phtml @@ -31,15 +31,24 @@ $product = $item->getProduct(); <?php echo $this->getLayout()->renderElement($childName, false); ?> <?php endforeach;?> <div class="box-tocart"> + <fieldset class="fieldset"> <?php if ($item->canHaveQty() && $product->isVisibleInSiteVisibility()): ?> - <input type="number" data-role="qty" class="input-text qty" data-validate="{required:true,'validate-greater-than-zero':true}" + <div class="field qty"> + <label class="label" for="qty[<?php echo $item->getId() ?>]"><span><?php echo __('Qty') ?></span></label> + <div class="control"> + <input type="number" data-role="qty" id="qty[<?php echo $item->getId() ?>]" class="input-text qty" data-validate="{required:true,'validate-greater-than-zero':true}" name="qty[<?php echo $item->getId() ?>]" value="<?php echo $this->getAddToCartQty($item) * 1 ?>"> - + </div> + </div> <?php endif; ?> <?php if ($product->isSaleable()): ?> - <button type="button" data-role="tocart" title="<?php echo __('Add to Cart') ?>" data-item-id="<?php echo $item->getId()?>" class="action tocart primary"> - <span><?php echo __('Add to Cart') ?></span> - </button> + <div class="product-item-actions"> + <div class="actions-primary"> + <button type="button" data-role="tocart" title="<?php echo __('Add to Cart') ?>" data-item-id="<?php echo $item->getId()?>" class="action tocart primary"> + <span><?php echo __('Add to Cart') ?></span> + </button> + </div> + </div> <?php else: ?> <?php if ($product->getIsSalable()): ?> <p class="available stock" title="<?php echo __('Availability') ?>"> @@ -51,12 +60,5 @@ $product = $item->getProduct(); </p> <?php endif; ?> <?php endif; ?> + </fieldset> </div> - -<?php if ($product->isVisibleInSiteVisibility()): ?> - <p> - <a class="action edit" href="<?php echo $this->getItemConfigureUrl($item) ?>"> - <span><?php echo __('Edit') ?></span> - </a> - </p> -<?php endif ?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/comment.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/comment.phtml new file mode 100644 index 00000000000..4e793ba41d3 --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/comment.phtml @@ -0,0 +1,30 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* @var \Magento\Wishlist\Model\Item $item */ + +$item = $this->getItem(); +?> + +<textarea placeholder="<?php echo $this->helper('Magento\Wishlist\Helper\Data')->defaultCommentString() ?>" name="description[<?php echo $item->getWishlistItemId() ?>]" title="<?php echo __('Comment') ?>" class="product-item-comment"><?php echo($this->escapeHtml($item->getDescription())) ?></textarea> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/edit.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/edit.phtml new file mode 100644 index 00000000000..513577a5a64 --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/edit.phtml @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* @var \Magento\Wishlist\Model\Item $item */ +$item = $this->getItem(); +$product = $item->getProduct(); +?> + +<?php if ($product->isVisibleInSiteVisibility()): ?> + <a class="action edit" href="<?php echo $this->getItemConfigureUrl($item) ?>"> + <span><?php echo __('Edit') ?></span> + </a> +<?php endif ?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml index f01abe193f3..4470e63b269 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml @@ -27,6 +27,6 @@ $item = $this->getItem(); $product = $item->getProduct(); $imageBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Image'); ?> -<a class="product photo" href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>"> +<a class="product-item-photo" href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>"> <?php echo $imageBlock->init($product, 'wishlist_thumbnail')->toHtml() ?> </a> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/name.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/name.phtml new file mode 100644 index 00000000000..721cae2a9e3 --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/name.phtml @@ -0,0 +1,33 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* @var \Magento\Wishlist\Model\Item $item */ +$item = $this->getItem(); +$product = $item->getProduct(); +?> +<strong class="product-item-name"> + <a href="<?php echo $this->getProductUrl($item) ?>" title="<?php echo $this->escapeHtml($product->getName()) ?>" class="product-item-link"> + <?php echo $this->escapeHtml($product->getName()) ?> + </a> +</strong> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/price.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/price.phtml new file mode 100644 index 00000000000..42ffe94668a --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/price.phtml @@ -0,0 +1,30 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* @var \Magento\Wishlist\Model\Item $item */ +?> + +<?php foreach ($this->getChildNames() as $childName): ?> + <?php echo $this->getLayout()->renderElement($childName, false); ?> +<?php endforeach;?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml index da4421f4f50..91c76686427 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/item/list.phtml @@ -26,33 +26,26 @@ /** @var \Magento\Wishlist\Block\Customer\Wishlist\Items $this */ $columns = $this->getColumns(); ?> -<div class="wishlist table-wrapper"> - <table class="table data wishlist" id="wishlist-table"> - <caption class="table caption"><?php echo __('Wish List') ?></caption> - <thead> - <tr> + +<div class="products-grid wishlist"> + <?php $iterator = 1; ?> + <?php if (count($this->getItems())): ?> + <ol class="product-items"> + <?php foreach ($this->getItems() as $item): ?> + <?php echo ($iterator++==1) ? '<li class="product-item" id="item_<?php echo $item->getId();?>">' : '</li><li class="product-item" id="item_<?php echo $item->getId();?>">' ?> + <div class="product-item-info"> <?php foreach ($columns as $column): ?> - <th class="col <?php echo $column->getColClass(); ?>"><?php echo $column->getTitle();?></th> + <?php $column->setItem($item); echo $column->toHtml($item);?> <?php endforeach; ?> - </tr> - </thead> - <tbody> - <?php if (count($this->getItems())): ?> - <?php foreach ($this->getItems() as $item): ?> - <tr id="item_<?php echo $item->getId();?>"> - <?php foreach ($columns as $column): ?> - <td class="col <?php echo $column->getColClass(); ?>"> - <?php $column->setItem($item); echo $column->toHtml($item);?> - </td> - <?php endforeach; ?> - </tr> - <?php endforeach ?> - <?php else: ?> - <td colspan="<?php echo count($columns);?>" class="col empty"><?php echo __('This Wish List has no Items');?></td> - <?php endif; ?> - </tbody> - </table> + </div> + <?php echo ($iterator==count($this->getItems())+1) ? '</li>' : '' ?> + <?php endforeach; ?> + </ol> + <?php else: ?> + <div class="message info empty"><span><?php echo __('This Wish List has no Items');?></span></div> + <?php endif; ?> </div> + <?php foreach ($columns as $column): ?> <?php echo $column->getAdditionalHtml();?> <?php endforeach; ?> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/options_list.phtml b/app/code/Magento/Wishlist/view/frontend/templates/options_list.phtml index ef9406f32ce..cf61fe92d82 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/options_list.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/options_list.phtml @@ -26,7 +26,7 @@ <?php $options = $this->getOptionList(); ?> <?php if ($options): ?> -<div class="tooltip wrapper"> +<div class="tooltip wrapper product-item-tooltip"> <span class="action details tooltip toggle"><?php echo __('View Details') ?></span> <div class="tooltip content"> <strong class="subtitle"><?php echo __('Options Details'); ?></strong> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml index 9b18af283ce..29dda8ffdfa 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml @@ -30,7 +30,7 @@ <span><?php echo __('RSS Feed') ?></span> </a> <?php endif; ?> - <form class="form wishlist items" id="wishlist-view-form" + <form class="form-wishlist-items" id="wishlist-view-form" data-mage-init='{"wishlist":{ "dataAttribute":"item-id", "nameFormat":"qty[{0}]", diff --git a/app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/module.less b/app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/module.less index f107b302f13..979408ffd95 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Catalog/web/css/source/module.less @@ -36,3 +36,135 @@ } } +// +// Product Massaction page +//-------------------------------------- + +// Attributes +.attributes-edit-form { + .field { + &:not(.field-weight) { + .addon { + display: block; + position: relative; + input[type="text"] { + border-width: 1px; + } + .addafter { + display: block; + border: 0; + height: auto; + width: auto; + } + input:focus ~ .addafter { + box-shadow: none; + } + } + } + } + + .with-addon .textarea { + margin: 0; + } + + .attribute-change-checkbox { + display: block; + margin-top: 5px; + .label { + float: none; + padding: 0; + width: auto; + } + .checkbox { + margin-right: 5px; + width: auto; + } + } + + .field-price, + .field-special_price, + .field-gift_wrapping_price, + .field-msrp, + .field-gift_wrapping_price { + .addon > input { + padding-left: 23px; + } + .addafter { + > strong { + left: 5px; + position: absolute; + top: 3px; + } + } + } + + .field.type-price, + .field-price, + .field-special_price, + .field-msrp, + .field-weight { + input:focus + label { + box-shadow: none; + } + } + + .field-special_from_date, + .field-special_to_date, + .field-news_from_date, + .field-news_to_date, + .field-custom_design_from, + .field-custom_design_to { + > .control .input-text { + border-width: 1px; + width: 130px; + } + } + + .field-weight { + .fields-group-2 { + .control { + padding-right: 27px; + .addafter + .addafter { + border-width: 1px 1px 1px 0; + border-style: solid; + height: 28px; + right: 0; + position: absolute; + top: 0; + } + .addafter strong { + line-height: 28px; + } + > input:focus + .addafter + .addafter { + box-shadow: 0 0 8px rgba(82, 168, 236, 0.6); + } + } + } + } + + .field-gift_message_available, + .field-gift_wrapping_available { + .addon { + > input[type="checkbox"] { + width: auto; + margin-right: 5px; + } + } + } + + .fieldset > .addafter { + display: none; + } + +} + +// Inventory +.advanced-inventory-edit { + .field.choice { + display: block; + margin: 3px 0 0; + .label { + padding-top: 1px; + } + } +} diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 9309de8d7a4..80cf9ae3a72 100644 --- a/app/design/adminhtml/Magento/backend/composer.json +++ b/app/design/adminhtml/Magento/backend/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index 9956b848f47..ba642ec99a1 100644 --- a/app/design/adminhtml/Magento/backend/theme.xml +++ b/app/design/adminhtml/Magento/backend/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento 2 backend</title> - <version>0.1.0-alpha92</version> + <version>0.1.0-alpha93</version> </theme> diff --git a/app/design/adminhtml/Magento/backend/web/css/admin.less b/app/design/adminhtml/Magento/backend/web/css/admin.less index 6333aaf2fa2..7fc011493c8 100644 --- a/app/design/adminhtml/Magento/backend/web/css/admin.less +++ b/app/design/adminhtml/Magento/backend/web/css/admin.less @@ -1338,7 +1338,8 @@ input.mage-error ~ .addafter { .field.type-price input ~ label.addafter strong, .field-price input ~ label.addafter strong, .field-special_price input ~ label.addafter strong, -.field-msrp input ~ label.addafter strong { +.field-msrp input ~ label.addafter strong, +.field-gift_wrapping_price input ~ label.addafter strong { margin-left: 2px; margin-right: -2px; } @@ -3021,115 +3022,9 @@ tr.dynamic-grid input.input-text { } } -/* - Product Massaction page - TODO: css code below should be removed after element.html refactoring --------------------------------------- */ -.attributes-edit-form .attribute-change-checkbox { - white-space: nowrap; - display: block; -} - -.attributes-edit-form .attribute-change-checkbox > label > input { - width: auto; -} - -.attributes-edit-form .field:last-child, -.attributes-edit-form .field-name, -.attributes-edit-form .field.type-price, -.attributes-edit-form .field-price, -.attributes-edit-form .field-special_price, -.attributes-edit-form .field-meta_title, -.attributes-edit-form .field-visibility, -.attributes-edit-form .field-custom_design, -.attributes-edit-form .field-page_layout, -.attributes-edit-form .field-options_container, -.attributes-edit-form .field-country_of_manufacture, -.attributes-edit-form .field-msrp_display_actual_price_type, -.attributes-edit-form .field-tax_class_id, -.attributes-edit-form .field-is_returnable, -.attributes-edit-form .field-msrp, -.attributes-edit-form .field-gift_wrapping_price { - margin-bottom: 50px; -} - -.attributes-edit-form .field .control { - position: relative; -} - -.attributes-edit-form .field-name .attribute-change-checkbox, -.attributes-edit-form .field-meta_title .attribute-change-checkbox, -.attributes-edit-form .field-gift_wrapping_price .attribute-change-checkbox, -.attributes-edit-form .field .control select + .addafter { - position: absolute; - left: 0; - top: 35px; -} - -.attributes-edit-form .field.type-price .attribute-change-checkbox, -.attributes-edit-form .field-price .attribute-change-checkbox, -.attributes-edit-form .field-special_price .attribute-change-checkbox, -.attributes-edit-form .field-msrp .attribute-change-checkbox { - position: absolute; - top: 35px; -} - -.attributes-edit-form .field-special_from_date > .control .input-text, -.attributes-edit-form .field-special_to_date > .control .input-text, -.attributes-edit-form .field-news_from_date > .control .input-text, -.attributes-edit-form .field-news_to_date > .control .input-text, -.attributes-edit-form .field-custom_design_from > .control .input-text, -.attributes-edit-form .field-custom_design_to > .control .input-text { - border-width: 1px; - border-radius: 4px; - width: 130px; -} - -.attributes-edit-form .field-special_from_date .attribute-change-checkbox, -.attributes-edit-form .field-special_to_date .attribute-change-checkbox, -.attributes-edit-form .field-news_from_date .attribute-change-checkbox, -.attributes-edit-form .field-news_to_date .attribute-change-checkbox, -.attributes-edit-form .field-custom_design_from .attribute-change-checkbox, -.attributes-edit-form .field-custom_design_to .attribute-change-checkbox { - margin-top: 5px; -} - -.attributes-edit-form .field-weight .fields-group-2 .control { - width: 160px; -} - -.attributes-edit-form .field-weight .fields-group-2 .control > input { - width: 130px; - float: left; -} - -.attributes-edit-form .field-weight .fields-group-2 .control > input + .addafter { - position: absolute; - top: 35px; -} - -.attributes-edit-form .field-weight .fields-group-2 .control .addafter strong { - line-height: 26px; -} - -.attributes-edit-form .field .control select { - border-radius: 4px; -} - -.attributes-edit-form .field-gift_message_available .addon > .select, -.attributes-edit-form .field-gift_wrapping_available .addon > .select { - margin-bottom: 25px; -} - -.attributes-edit-form .field-gift_message_available .addon > input[type="checkbox"], -.attributes-edit-form .field-gift_wrapping_available .addon > input[type="checkbox"] { - width: auto; - margin-right: 5px; -} - -/* - Widgets --------------------------------------- */ +// +// Widgets +//-------------------------------------- .widget-layout-updates .fieldset-wrapper, .widget-layout-updates .data-table { margin: 0 0 18px; diff --git a/app/design/frontend/Magento/blank/Magento_Bundle/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Bundle/web/css/source/module.less index 4b7645a1abb..60a53b11596 100644 --- a/app/design/frontend/Magento/blank/Magento_Bundle/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Bundle/web/css/source/module.less @@ -130,9 +130,9 @@ .product-options-wrapper, .product-options-bottom, .block-bundle-summary { - .page-layout-2column-left &, - .page-layout-2column-right &, - .page-layout-3column & { + .page-layout-2columns-left &, + .page-layout-2columns-right &, + .page-layout-3columns & { width: 48%; } } diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/listings.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/listings.less new file mode 100644 index 00000000000..f5074295d65 --- /dev/null +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/listings.less @@ -0,0 +1,240 @@ +// /** +// // * Magento +// * +// * NOTICE OF LICENSE +// * +// * This source file is subject to the Academic Free License (AFL 3.0) +// * that is bundled with this package in the file LICENSE_AFL.txt. +// * It is also available through the world-wide-web at this URL: +// * http://opensource.org/licenses/afl-3.0.php +// * If you did not receive a copy of the license and are unable to +// * obtain it through the world-wide-web, please send an email +// * to license@magentocommerce.com so we can send you a copy immediately. +// * +// * DISCLAIMER +// * +// * Do not edit or add to this file if you wish to upgrade Magento to newer +// * versions in the future. If you wish to customize Magento for your +// * needs please refer to http://www.magentocommerce.com for more information. +// * +// * @category design +// * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) +// * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +// */ + +@product-name-text-decoration: none; +@product-name-text-decoration-hover: @link-text-decoration-hover; + +.product-name() { + font-weight: @font-weight-base; + > a { + .link( + @_link-color: @text-color, + @_link-text-decoration: @product-name-text-decoration, + @_link-color-visited: @text-color, + @_link-text-decoration-visited: @product-name-text-decoration, + @_link-color-hover: @text-color, + @_link-text-decoration-hover: @product-name-text-decoration-hover, + @_link-color-active: @text-color, + @_link-text-decoration-active: @product-name-text-decoration-hover + ); + } +} + +// Product Lists +.products { + margin: @indent-l-base 0; +} +.product { + &-items { + &:extend(.reset-list all); + margin-left: -20px; + } + &-item { + vertical-align: top; + .products-grid & { + width: 100%/2; + display: inline-block; + } + .box-sizing(); + padding-left: 20px; + + &-name { + .product-name(); + display: block; + margin: @indent-xs-base 0; + -ms-word-break: break-all; + word-break: break-all; + + // Non standard for webkit + word-break: break-word; + + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + } + + &-info { + width: 150px; + max-width: 100%; + .page-products & { + width: 200px; + } + } + + &-actions { + display: none; + .actions-secondary { + > .action { + &:extend(.abstract-actions-addto-gridlist all); + &:before { + margin: 0; + } + span { + &:extend(.visually-hidden all); + } + } + } + } + &-description { + margin: @indent-m-base 0; + } + .product-reviews-summary { + .rating-summary { + margin: 0 4px 0 0; + } + .reviews-actions { + margin-top: 5px; + text-transform: lowercase; + font-size: @font-size-s; + } + } + + .price-box { + margin: @indent-s-base 0 @indent-m-base; + .price { + font-weight: bold; + } + .price-label { + font-size: @font-size-s; + color: @text-color-muted; + } + + } + .special-price, + .old-price { + display: inline; + } + .old-price { + color: @text-color-muted; + .price { + font-weight: normal; + } + } + .tocompare { + .icon-font-symbol( + @icon-compare-empty + ); + } + .tocart { + white-space: nowrap; + } + } +} + +.products-list .product { + &-item { + display: table; + width: 100%; + + &-info { + display: table-row; + } + &-photo { + width: 1%; + padding: 0 @indent-l-base @indent-l-base 0; + vertical-align: top; + display: table-cell; + } + &-details { + vertical-align: top; + display: table-cell; + } + } +} + +.responsive-smaller (@break) when (@break = @screen-s) { + .products-list .product { + &-item { + table-layout: fixed; + &-photo { + padding: 0 @indent-s-base @indent-s-base 0; + width: 30%; + } + } + } +} + +.responsive(@break) when (@break = @screen-s) { + .product { + &-item { + .products-grid & { + margin-bottom: @indent-l-base; + } + &-info { + } + + &-actions { + display: block; + .products-grid & { + margin: @indent-s-base 0; + } + .actions-primary + .actions-secondary { + display: table-cell; + width: 50%; + padding-left: 5px; + white-space: nowrap; + > * { + white-space: normal; + } + > .action { + } + } + .actions-primary { display: table-cell; } + } + } + } +} + +.responsive(@break) when (@break = @screen-s) { + .products-grid .product-item { width: 100%/3 } + .layout-1 .products-grid .product-item { width: 100%/3 } + .layout-3 .products-grid .product-item { width: 100%/3 } + .page-products .products-grid .product-item { width: 100%/3 } + .page-products.layout-1 .products-grid .product-item { width: 100%/3 } + .page-products.layout-3 .products-grid .product-item { width: 100%/3 } +} +.responsive(@break) when (@break = @screen-m) { + .page-products .products-grid .product-item{ width: 100%/3 } + .page-products.layout-1 .products-grid .product-item { width: 100%/4 } + .page-products.layout-3 .products-grid .product-item { width: 100%/2 } +} +.responsive(@break) when (@break = @screen-l) { + .products-grid .product-item { width: 100%/5 } + .layout-1 .products-grid .product-item { width: 100%/6 } + .layout-3 .products-grid .product-item { width: 100%/4 } + .page-products .products-grid .product-items { margin: 0; } + .page-products .products-grid .product-item { + width: 100%/4; + width: 200px; + //margin: 0; + margin-left: calc(~"(100% - 4 * 200px) / 3"); + padding: 0; + &:nth-child(4n+1) { + margin-left: 0; + } + } + .page-products.layout-1 .products-grid .product-item { width: 100%/5 } + .page-products.layout-3 .products-grid .product-item { width: 100%/4 } +} diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module.less index 9069515b799..145a9a0314d 100644 --- a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/module.less @@ -48,34 +48,9 @@ @toolbar-mode-icon-font-size: 26px; +@import "listings.less"; @import "toolbar.less"; -.product-item-grid(@_layout-class, @_product-items) when not (@_layout-class = false) and not (@_product-items = '') { - .@{_layout-class} & { - .css(width, 100% / @_product-items); - } -} - -.product-item-grid(@_layout-class, @_product-items) when (@_layout-class = false) and not (@_product-items = '') { - .css(width, 100% / @_product-items); -} - -.product-name() { - font-weight: @font-weight-base; - > a { - .link( - @_link-color: @text-color, - @_link-text-decoration: @product-name-text-decoration, - @_link-color-visited: @text-color, - @_link-text-decoration-visited: @product-name-text-decoration, - @_link-color-hover: @text-color, - @_link-text-decoration-hover: @product-name-text-decoration-hover, - @_link-color-active: @text-color, - @_link-text-decoration-active: @product-name-text-decoration-hover - ); - } -} - // // Category view //-------------------------------------- @@ -106,40 +81,6 @@ } } -// -// Category page layout -//-------------------------------------- -.products.grid .item.product { - .product-item-grid(@_layout-class: false, @product-grid-items-per-row-layout-default); -} - -.responsive(@break) when (@break = @screen-s) { - .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-screen-s); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-screen-s); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-screen-s); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-screen-s); - } -} - -.responsive(@break) when (@break = @screen-m) { - .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-screen-m); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-screen-m); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-screen-m); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-screen-m); - } -} - -.responsive(@break) when (@break = @screen-l) { - .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-screen-l); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-screen-l); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-screen-l); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-screen-l); - } -} - // // Product grid and list item //-------------------------------------- @@ -169,106 +110,6 @@ } } -.products { - &.list.items { - &:extend(.reset-list all); - .item.product { - &:extend(.add-box-sizing all); - position: relative; - vertical-align: top; - } - .img.container { - max-width: 100%; - > .image { - max-width: 100%; - height: auto; - } - } - .name { - .product-name(); - display: block; - } - .price-box { - margin-top: 17px; - .price { - font-weight: @font-weight-bold; - } - } - .description { - padding-top: @indent-l-base; - color: @text-color-intense; - } - .actions { - > .secondary { - display: none; - vertical-align: top; - } - > .primary, - > .secondary { - margin: @indent-s-base 0 0 0; - } - .stock.unavailable { - margin: 7px 5px 0 0; - } - } - .action { - &.tocompare { - &:extend(.abstract-actions-addto-gridlist all); - } - &.tocompare { - .icon-font-symbol( - @icon-compare-empty - ); - } - } - } - &.wrapper.list { - .products.list.items { - .product-item { - display: block; - margin-bottom: @indent-l-base; - &-photo { - display: block; - } - &-details { - text-align: center; - } - &-name { - font-size: @font-size-l; - margin-bottom: @indent-base; - } - .actions { - > .actions-primary { - + .actions-secondary { - margin-top: @indent-s-base; - } - } - } - } - } - } - &.wrapper.grid { - .products.list.items { - .product-item { - display: inline-block; - padding: @product-grid-items-padding; - margin: @product-grid-items-margin; - } - .product-image-container { - margin-bottom: @indent-base; - } - .actions { - > .actions-primary { - display: inline-block; - + .actions-secondary { - margin-top: @indent-s-base; - } - } - } - } - } -} - // // Product view //-------------------------------------- @@ -502,82 +343,6 @@ .product-add-form { &:extend(.revert-field-type-desktop all); } - .products { - &.toolbar { - display: table; - width: 100%; - .settings, - .pager, - .pages { - display: table-cell; - vertical-align: middle; - } - .settings { - text-align: left; - } - .pager { - text-align: right; - } - .modes, - .sorter, - .limiter { - display: inline; - } - .sorter { - } - .limiter { - .text { - display: inline; - } - } - } - } - - .products { - &.list.items { - .actions { - > .secondary { - display: inline-block; - } - } - } - &.wrapper.list { - .products.list.items { - .item.product { - margin-bottom: 2 * @indent-xl-base; - > .product { - display: table; - width: 100%; - table-layout: fixed; - } - .product.photo { - display: table-cell; - vertical-align: top; - width: 30%; - padding-right: 1.75 * @indent-base; - } - .price-box { - width: 30%; - margin-right: 2%; - float: left; - } - .details { - display: table-cell; - vertical-align: top; - text-align: left; - } - .description { - clear: both; - } - .actions { - > .primary { - display: inline-block; - } - } - } - } - } - } } // diff --git a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/module.less index f96d322cf8c..5ec79a6c7a0 100644 --- a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/module.less @@ -130,7 +130,9 @@ } .sidebar .block-account-nav { .css(background, @sidebar-background); - margin: 0 0 40px; + } + .sidebar-additional { + margin-top: 40px; } .block-account-nav { .title { @@ -233,6 +235,9 @@ //-------------------------------------- .responsive-smaller(@break) when (@break = @screen-m) { .account { + .page.messages { + margin-bottom: 40px; + } .data.table { &:extend(.table-vertical-mobile all); .col.actions { @@ -255,34 +260,10 @@ margin-right: -@layout-width-xs-indent; margin-top: -(@indent-base + 1); .title { - .icon-font( - @_icon-font-content: @icon-down, - @_icon-font-size: 30px, - @_icon-font-position: after - ); - border-top: @border-width-base solid @border-color-base; - border-bottom: @border-width-base solid @border-color-base; - cursor: pointer; - display: block; - font-weight: @font-weight-semibold; - margin-bottom: 0; - overflow: hidden; - padding: 7px 20px; - position: relative; - &:after { - position: absolute; - right: 0; - top: -5px; - } + &:extend(.abstract-toggling-title-mobile all); strong { margin: 0; } - &.active { - .icon-font-symbol( - @_icon-font-content: @icon-prev, - @_icon-font-position: after - ); - } } .content { display: none; @@ -342,7 +323,7 @@ } // My account - .account.page-layout-2column-left { + .account.page-layout-2columns-left { .sidebar-main, .sidebar-additional { width: 22.3%; diff --git a/app/design/frontend/Magento/blank/Magento_Wishlist/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Wishlist/web/css/source/module.less index b8b4b04e3b2..472caa4ef5d 100644 --- a/app/design/frontend/Magento/blank/Magento_Wishlist/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Wishlist/web/css/source/module.less @@ -138,3 +138,217 @@ } } } + +.products-grid.wishlist { + .product { + &-item { + &-info { + } + &-photo { + margin-bottom: @indent-s-base; + display: inline-block; + } + &-name { + margin-top: 0; + } + .price-box { + margin: 0; + } + &-tooltip { + } + &-comment { + display: block; + margin: @indent-s-base 0; + height: 42px; + } + &-actions { + > * { + margin-right: 15px; + &:last-child { + margin-right: 0; + } + } + } + .box-tocart { + input.qty { + height: 32px; + &:extend(.abstract-input-qty all); + } + } + } + } +} +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .products-grid.wishlist { + margin-right: -@indent-s-base; + margin-bottom: @indent-l-base; + .product { + &-item { + padding: @indent-base @indent-s-base @indent-base @indent-base; + position: relative; + border-bottom: 1px solid @color-secondary; + &:first-child { + border-top: 1px solid @color-secondary; + } + &-info { + } + &-photo { + margin-right: @indent-base; + float: left; + } + &-name { + .font-size(16); + } + &-tooltip { + } + &-comment { + } + &-actions { + display: block; + .action { + margin-right: 15px; + &:last-child { + margin-right: 0; + } + &.edit { + float: left; + } + &.delete { + float: right; + } + &.edit, + &.delete { + margin-top: 7px; + } + } + } + &-name, + &-description, + .price-box, + &-tooltip { + margin-left: 95px; + } + .box-tocart { + float: left; + margin-right: @indent-base; + .stock { + margin-top: 7px; + } + } + .giftregisty-dropdown, + .field.qty { + display: none; + } + } + &-image-container { + max-width: 80px; + } + } + } +} +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { + .products-grid.wishlist { + .product { + &-item { + &-info { + } + &-photo { + } + &-name { + } + &-tooltip { + display: inline-block; + } + &-comment { + } + &-actions { + margin: @indent-s-base 0 0; + } + .fieldset { + .field.qty, + .product-item-actions { + } + .field.qty { + padding-right: @indent-s-base; + margin-bottom: @indent-s-base; + } + } + .box-tocart { + .actions-primary { + margin: 0; + } + .stock { + margin: @indent-base 0 0; + } + } + } + } + } +} + +// +// Grid view for wishlist +//-------------------------------------- +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .wishlist-index-index { + .product { + &-item { + width: 100%; + &-info { + width: auto; + } + } + } + } + +} + +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { + .wishlist-index-index { + .product { + &-item { + &-info { + width: 200px; + } + } + } + } +} + +.responsive(@break) when (@break = @screen-s) { + //.wishlist-index-index .products-grid .product-item { width: 100%/3 } +} +.responsive(@break) when (@break = @screen-m) { + //.wishlist-index-index .products-grid .product-item { width: 100%/3 } +} +.responsive(@break) when (@break = @screen-l) { + .wishlist-index-index .products-grid .product-items { margin: 0; } + .wishlist-index-index .products-grid .product-item { + width: 100%/4; + width: 200px; + //margin: 0; + margin-left: calc(~"(100% - 4 * 200px) / 3"); + padding: 0; + &:nth-child(4n+1) { + margin-left: 0; + } + } + .products-grid.wishlist { + .product { + &-item { + } + } + } +} diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index e7005b4400b..5ce04c2e04c 100644 --- a/app/design/frontend/Magento/blank/composer.json +++ b/app/design/frontend/Magento/blank/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/etc/view.xml b/app/design/frontend/Magento/blank/etc/view.xml index 64f596f5538..687d5e3514b 100644 --- a/app/design/frontend/Magento/blank/etc/view.xml +++ b/app/design/frontend/Magento/blank/etc/view.xml @@ -150,9 +150,9 @@ <var name="customer_shared_wishlist:height">113</var> <var name="wishlist_thumbnail:type">small_image</var> - <var name="wishlist_thumbnail:width">113</var> + <var name="wishlist_thumbnail:width">200</var> <var name="wishlist_thumbnail:ratio">1</var> - <var name="wishlist_thumbnail:height">113</var> + <var name="wishlist_thumbnail:height">200</var> <var name="wishlist_sidebar_block:type">thumbnail</var> <var name="wishlist_sidebar_block:width">50</var> diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index 53d9e5ba7fd..da4da4de597 100644 --- a/app/design/frontend/Magento/blank/theme.xml +++ b/app/design/frontend/Magento/blank/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Blank</title> - <version>0.1.0-alpha92</version> + <version>0.1.0-alpha93</version> <media> <preview_image>media/preview.jpg</preview_image> </media> diff --git a/app/design/frontend/Magento/blank/web/css/source/abstract.less b/app/design/frontend/Magento/blank/web/css/source/abstract.less index 3aebfd5c2dd..4fb54beb6d1 100644 --- a/app/design/frontend/Magento/blank/web/css/source/abstract.less +++ b/app/design/frontend/Magento/blank/web/css/source/abstract.less @@ -114,12 +114,13 @@ // // Simple Dropdown //-------------------------------------- -.dropdown-simple { - line-height: normal; - .dropdown(); - ul.items.dropdown { - min-width: 155px; - } +.abstract-dropdown-simple { + .dropdown( + @_dropdown-list-item-padding: 5px 5px 5px 23px, + @_dropdown-list-min-width: 200px, + @_icon-font-margin: 0 0 0 5px, + @_icon-font-vertical-align: middle + ); } // @@ -499,3 +500,86 @@ ); } } + +// +// Add colon +//-------------------------------------- +.abstract-colon { + &:after { + content: ": "; + } +} + +// +// Icon - create add +//-------------------------------------- +.abstract-icon-add { + .icon-font( + @_icon-font-content: @icon-expand, + @_icon-font-size: 10px, + @_icon-font-line-height: 10px, + @_icon-font-vertical-align: middle + ); +} +.responsive-smaller(@break) when (@break = @screen-m) { + .abstract-icon-add-mobile { + .icon-font( + @_icon-font-content: @icon-expand, + @_icon-font-size: 10px, + @_icon-font-line-height: 10px, + @_icon-font-vertical-align: middle, + @_icon-font-margin: 0 5px 0 0, + @_icon-font-display: block + ); + } +} + +// +// Dropdown items - create new +//-------------------------------------- +.abstract-dropdown-items-new { + .items .item:last-child { + &:hover { + background: @dropdown-list-item-hover; + } + } + .action.new { + &:extend(.abstract-icon-add all); + &:before { + margin-left: -17px; + margin-right: 5px; + } + } +} + +// +// Abstract toggle title block +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .abstract-toggling-title-mobile { + border-top: @border-width-base solid @border-color-base; + border-bottom: @border-width-base solid @border-color-base; + cursor: pointer; + margin-bottom: 0; + padding: 10px 40px 10px 20px; + position: relative; + .icon-font( + @_icon-font-content: @icon-down, + @_icon-font-size: 28px, + @_icon-font-text-hide: false, + @_icon-font-position: after, + @_icon-font-display: block + ); + &:after { + position: absolute; + right: 10px; + top: 0; + } + &.active { + .icon-font-symbol( + @_icon-font-content: @icon-up, + @_icon-font-position: after + ); + } + } +} diff --git a/app/design/frontend/Magento/blank/web/css/source/layout.less b/app/design/frontend/Magento/blank/web/css/source/layout.less index 915763854a1..4c00f8bc03a 100644 --- a/app/design/frontend/Magento/blank/web/css/source/layout.less +++ b/app/design/frontend/Magento/blank/web/css/source/layout.less @@ -95,7 +95,7 @@ &:extend(.add-box-sizing-desktop all); } - .page-layout-2column-right .sidebar-main { + .page-layout-2columns-right .sidebar-main { padding-right: 0; padding-left: @layout-column-main-sidebar-offset; } @@ -107,7 +107,7 @@ &:extend(.add-box-sizing-desktop all); } - .page-layout-2column-left { + .page-layout-2columns-left { .sidebar-additional { padding-right: @layout-column-additional-sidebar-offset; padding-left: 0; diff --git a/app/design/frontend/Magento/plushe/composer.json b/app/design/frontend/Magento/plushe/composer.json index c8b3ce1d3d2..3f3da8e404f 100644 --- a/app/design/frontend/Magento/plushe/composer.json +++ b/app/design/frontend/Magento/plushe/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/theme-frontend-blank": "0.1.0-alpha92", - "magento/framework": "0.1.0-alpha92", + "magento/theme-frontend-blank": "0.1.0-alpha93", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index c0b39a9f376..62a89bd64e8 100644 --- a/app/design/frontend/Magento/plushe/theme.xml +++ b/app/design/frontend/Magento/plushe/theme.xml @@ -24,7 +24,7 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Plushe</title> - <version>0.1.0-alpha92</version> + <version>0.1.0-alpha93</version> <parent>Magento/blank</parent> <media> <preview_image>media/preview.jpg</preview_image> diff --git a/app/design/install/Magento/basic/theme.xml b/app/design/install/Magento/basic/theme.xml index 42cb97ca000..925ab98d785 100644 --- a/app/design/install/Magento/basic/theme.xml +++ b/app/design/install/Magento/basic/theme.xml @@ -24,5 +24,5 @@ --> <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Config/etc/theme.xsd"> <title>Magento Basic</title> - <version>0.1.0-alpha92</version> + <version>0.1.0-alpha93</version> </theme> diff --git a/app/etc/di.xml b/app/etc/di.xml index c6ef9807ad5..e3fcfb233e7 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -79,6 +79,7 @@ <preference for="Magento\Framework\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> <preference for="Magento\Framework\Session\Config\ConfigInterface" type="Magento\Framework\Session\Config" /> <preference for="Magento\Framework\Session\SidResolverInterface" type="Magento\Framework\Session\SidResolver\Proxy" /> + <preference for="Magento\Framework\Stdlib\CookieManager" type="Magento\Framework\Stdlib\Cookie\PhpCookieManager" /> <preference for="Magento\Framework\TranslateInterface" type="Magento\Framework\Translate" /> <preference for="Magento\Framework\Config\ScopeListInterface" type="interceptionConfigScope" /> <preference for="Magento\Framework\View\Design\Theme\Label\ListInterface" type="Magento\Core\Model\Resource\Theme\Collection" /> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index cfafe951a37..4f6de92be49 100644 --- a/app/i18n/magento/de_de/composer.json +++ b/app/i18n/magento/de_de/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-de_de", "description": "German (Germany) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/en_us/composer.json b/app/i18n/magento/en_us/composer.json index c1de5ebb5de..c6fe319270c 100644 --- a/app/i18n/magento/en_us/composer.json +++ b/app/i18n/magento/en_us/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-en_us", "description": "English (United States) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/es_es/composer.json b/app/i18n/magento/es_es/composer.json index 35110dd92ad..c70aaa9dd2d 100644 --- a/app/i18n/magento/es_es/composer.json +++ b/app/i18n/magento/es_es/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-es_es", "description": "Spanish (Spain) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/fr_fr/composer.json b/app/i18n/magento/fr_fr/composer.json index e4ac4b9d6c8..54022c5d888 100644 --- a/app/i18n/magento/fr_fr/composer.json +++ b/app/i18n/magento/fr_fr/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-fr_fr", "description": "French (France) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/nl_nl/composer.json b/app/i18n/magento/nl_nl/composer.json index b04200d1f4a..fdda8fce7dd 100644 --- a/app/i18n/magento/nl_nl/composer.json +++ b/app/i18n/magento/nl_nl/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-nl_nl", "description": "Dutch (Netherlands) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/pt_br/composer.json b/app/i18n/magento/pt_br/composer.json index b8e98a3a222..8ee23683dd9 100644 --- a/app/i18n/magento/pt_br/composer.json +++ b/app/i18n/magento/pt_br/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-pt_br", "description": "Portuguese (Brazil) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/app/i18n/magento/zh_cn/composer.json b/app/i18n/magento/zh_cn/composer.json index 033e6ee477e..d87bc5280f9 100644 --- a/app/i18n/magento/zh_cn/composer.json +++ b/app/i18n/magento/zh_cn/composer.json @@ -1,9 +1,9 @@ { "name": "magento/language-zh_cn", "description": "Chinese (China) language", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { - "magento/framework": "0.1.0-alpha92", + "magento/framework": "0.1.0-alpha93", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index b1284d44e36..4eb3f4103a3 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/project-community-edition", "description": "Magento project (Community Edition)", "type": "project", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { "php": "~5.4.11|~5.5.0" }, diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 4a4e97a721f..fc8a5f50ecb 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -251,6 +251,9 @@ class Application ); $this->loadArea(\Magento\TestFramework\Application::DEFAULT_APP_AREA); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( + $objectManager->get('Magento\Framework\ObjectManager\DynamicConfigInterface')->getConfiguration() + ); \Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\Framework\Phrase\RendererInterface')); /** @var \Magento\Framework\App\Filesystem\DirectoryList\Verification $verification */ diff --git a/dev/tests/integration/framework/Magento/TestFramework/Cookie.php b/dev/tests/integration/framework/Magento/TestFramework/CookieManager.php similarity index 66% rename from dev/tests/integration/framework/Magento/TestFramework/Cookie.php rename to dev/tests/integration/framework/Magento/TestFramework/CookieManager.php index 40f807ae777..1a94a516684 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Cookie.php +++ b/dev/tests/integration/framework/Magento/TestFramework/CookieManager.php @@ -23,29 +23,23 @@ */ /** - * Replacement for the native cookie model that doesn't send cookie headers in testing environment + * Replacement for PhpCookieManager model that doesn't send cookie headers in testing environment */ namespace Magento\TestFramework; -class Cookie extends \Magento\Framework\Stdlib\Cookie +class CookieManager extends \Magento\Framework\Stdlib\Cookie\PhpCookieManager { /** * Dummy function, which sets value directly to $_COOKIE super-global array instead of calling setcookie() * - * @param string $name The cookie name - * @param string $value The cookie value - * @param int $period Lifetime period - * @param string $path - * @param string $domain - * @param bool|int|string $secure - * @param bool|string $httponly - * @return \Magento\TestFramework\Cookie - * + * @param string $name + * @param string $value + * @param array $metadataArray + * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function set($name, $value, $period = 0, $path = '', $domain = '', $secure = '', $httponly = '') + protected function setCookie($name, $value, array $metadataArray) { $_COOKIE[$name] = $value; - return $this; } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php index 7614c1939aa..7e651f27d33 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Configurator.php @@ -32,6 +32,11 @@ class Configurator implements \Magento\Framework\ObjectManager\DynamicConfigInte */ public function getConfiguration() { - return array('preferences' => array('Magento\Framework\Stdlib\Cookie' => 'Magento\TestFramework\Cookie')); + return [ + 'preferences' => [ + 'Magento\Framework\Stdlib\Cookie' => 'Magento\TestFramework\Cookie', + 'Magento\Framework\Stdlib\CookieManager' => 'Magento\TestFramework\CookieManager', + ] + ]; } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index 318fd9f7419..e0ae647b2ac 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -135,6 +135,9 @@ class ObjectManagerFactory extends \Magento\Framework\App\ObjectManagerFactory $this->_primaryConfigData['preferences'] = array_replace( $this->_primaryConfigData['preferences'], [ + 'Magento\Framework\Stdlib\CookieManager' => 'Magento\TestFramework\CookieManager', + 'Magento\Framework\ObjectManager\DynamicConfigInterface' => + '\Magento\TestFramework\ObjectManager\Configurator', 'Magento\Framework\Stdlib\Cookie' => 'Magento\TestFramework\Cookie', 'Magento\Framework\App\RequestInterface' => 'Magento\TestFramework\Request', 'Magento\Framework\App\Request\Http' => 'Magento\TestFramework\Request', diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php index 9284547bfc2..b4fb5187b5e 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/RequestTest.php @@ -33,8 +33,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = new \Magento\TestFramework\Request( - $this->getMock('Magento\Framework\App\Route\ConfigInterface', array(), array(), '', false), - $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', array(), array(), '', false) + $this->getMock('Magento\Framework\App\Route\ConfigInterface', [], [], '', false), + $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', [], [], '', false), + $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false) ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php index 4d42a3ad4b9..5d820c4edab 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php @@ -28,8 +28,9 @@ class ResponseTest extends \PHPUnit_Framework_TestCase public function testCanSendHeaders() { $response = new \Magento\TestFramework\Response( - $this->getMock('\Magento\Framework\Stdlib\Cookie', array(), array(), '', false), - $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false) + $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false), + $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', [], [], '', false), + $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false) ); $this->assertTrue($response->canSendHeaders()); $this->assertTrue($response->canSendHeaders(false)); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index 2f46e552b18..a554a38b2e8 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -37,12 +37,14 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon { $this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', array(), array(), '', false); $request = new \Magento\TestFramework\Request( - $this->getMock('\Magento\Framework\App\Route\ConfigInterface', array(), array(), '', false), - $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', array(), array(), '', false) + $this->getMock('Magento\Framework\App\Route\ConfigInterface', [], [], '', false), + $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface', [], [], '', false), + $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false) ); $response = new \Magento\TestFramework\Response( - $this->getMock('\Magento\Framework\Stdlib\Cookie', array(), array(), '', false), - $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false) + $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false), + $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', [], [], '', false), + $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false) ); $this->_objectManager = $this->getMock( diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php new file mode 100644 index 00000000000..fec92ee622f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Backend\Model\Config\Backend; +use Magento\Framework\Model\Exception; + +/** + * Test \Magento\Backend\Model\Config\Backend\Domain + * + * @magentoAppArea adminhtml + */ +class DomainTest extends \PHPUnit_Framework_TestCase +{ + /** + * @param string $value + * @param string $exceptionMessage + * @magentoDbIsolation enabled + * @dataProvider beforeSaveDataProvider + */ + public function testBeforeSave($value, $exceptionMessage = null) + { + /** @var $domain \Magento\Backend\Model\Config\Backend\Domain */ + $domain = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Backend\Model\Config\Backend\Domain' + ); + $domain->setValue($value); + try { + $domain->save(); + if ($exceptionMessage ) { + $this->fail('Failed to throw exception'); + } else { + $this->assertNotNull($domain->getId()); + } + } catch (Exception $e) { + $this->assertContains('Invalid domain name: ', $e->getMessage()); + $this->assertContains($exceptionMessage, $e->getMessage()); + $this->assertNull($domain->getId()); + } + } + + /** + * @return array + */ + public function beforeSaveDataProvider() + { + return [ + 'not string' => [['array'], 'Invalid type given. String expected'], + 'invalid hostname' => [ + 'http://', + 'The input does not match the expected structure for a DNS hostname; ' + . 'The input does not appear to be a valid URI hostname; ' + . 'The input does not appear to be a valid local network name' + ], + 'valid hostname' => ['hostname.com'], + 'empty string' => [''], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php new file mode 100644 index 00000000000..957498e0921 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php @@ -0,0 +1,76 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Catalog\Model\Product\ProductList; + +/** + * Test \Magento\Catalog\Model\Product\ProductList\Toolbar + */ +class ToolbarTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Product\ProductList\Toolbar + */ + protected $toolbar; + + protected function setUp() + { + $this->toolbar = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Catalog\Model\Product\ProductList\Toolbar' + ); + $_COOKIE = []; + } + + public function tearDown() + { + $_COOKIE = []; + } + + public function testGetOrder() + { + $this->assertNull($this->toolbar->getOrder()); + $_COOKIE[Toolbar::ORDER_COOKIE_NAME] = 'orderCookie'; + $this->assertEquals('orderCookie', $this->toolbar->getOrder()); + } + + public function testGetDirection() + { + $this->assertNull($this->toolbar->getDirection()); + $_COOKIE[Toolbar::DIRECTION_COOKIE_NAME] = 'directionCookie'; + $this->assertEquals('directionCookie', $this->toolbar->getDirection()); + } + + public function testGetMode() + { + $this->assertNull($this->toolbar->getMode()); + $_COOKIE[Toolbar::MODE_COOKIE_NAME] = 'modeCookie'; + $this->assertEquals('modeCookie', $this->toolbar->getMode()); + } + + public function testGetLimit() + { + $this->assertNull($this->toolbar->getLimit()); + $_COOKIE[Toolbar::LIMIT_COOKIE_NAME] = 'limitCookie'; + $this->assertEquals('limitCookie', $this->toolbar->getLimit()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 5d2b8f92591..5e4747d7632 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -176,6 +176,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $stockItemAfterImport->loadByProduct($productId); $this->assertEquals($stockItmBeforeImport->getQty(), $stockItemAfterImport->getQty()); + $this->assertEquals(1, $stockItemAfterImport->getIsInStock()); unset($stockItemAfterImport); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php index d4f1d813597..cbea9989331 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php @@ -42,4 +42,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $expected = include __DIR__ . '/../../_files/search_request_config.php'; $this->assertEquals($expected, $result); } -} \ No newline at end of file +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php index 6a0e2c08cfb..eb75216b091 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php @@ -25,21 +25,55 @@ namespace Magento\Framework\Search\Request; class MapperTest extends \PHPUnit_Framework_TestCase { - public function testGet() + /** + * @var \Magento\Framework\Search\Request\Mapper + */ + protected $mapper; + + public function setUp() { $config = include __DIR__ . '/../_files/search_request_config.php'; $request = reset($config); - $mapper = $this->object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $this->mapper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create( - '\Magento\Framework\Search\Request\Mapper', + 'Magento\Framework\Search\Request\Mapper', [ 'queries' => $request['queries'], + 'rootQueryName' => 'suggested_search_container', 'filters' => $request['filters'], + 'aggregation' => $request['aggregation'], ] ); + } + + public function testGet() + { $this->assertInstanceOf( '\Magento\Framework\Search\Request\QueryInterface', - $mapper->get('suggested_search_container') + $this->mapper->getRootQuery() ); } -} \ No newline at end of file + + public function testGetBuckets() + { + $buckets = $this->mapper->getBuckets(); + $this->assertEquals(2, count($buckets)); + + $this->assertInstanceOf('\Magento\Framework\Search\Request\Aggregation\TermBucket', $buckets[0]); + $this->assertEquals('category_bucket', $buckets[0]->getName()); + $this->assertEquals('category', $buckets[0]->getField()); + $this->assertEquals(\Magento\Framework\Search\Request\BucketInterface::TYPE_TERM, $buckets[0]->getType()); + $metrics = $buckets[0]->getMetrics(); + $this->assertInstanceOf('\Magento\Framework\Search\Request\Aggregation\Metric', $metrics[0]); + + $this->assertInstanceOf('\Magento\Framework\Search\Request\Aggregation\RangeBucket', $buckets[1]); + $this->assertEquals('price_bucket', $buckets[1]->getName()); + $this->assertEquals('price', $buckets[1]->getField()); + $this->assertEquals(\Magento\Framework\Search\Request\BucketInterface::TYPE_RANGE, $buckets[1]->getType()); + $metrics = $buckets[1]->getMetrics(); + $ranges = $buckets[1]->getRanges(); + $this->assertInstanceOf('\Magento\Framework\Search\Request\Aggregation\Metric', $metrics[0]); + $this->assertInstanceOf('\Magento\Framework\Search\Request\Aggregation\Range', $ranges[0]); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml index e98914a49b9..c5b97e2e6e6 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml @@ -25,16 +25,15 @@ --> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <request query="suggested_search_container" index="product"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> <queries> <query xsi:type="boolQuery" name="suggested_search_container" boost="2"> <queryReference clause="must" ref="fulltext_search_query" /> <queryReference clause="should" ref="fulltext_search_query2" /> </query> - <query xsi:type="filteredQuery" name="fulltext_search_query1"> - <queryReference ref="fulltext_search_query" /> - </query> - <query xsi:type="matchQuery" name="fulltext_search_query" boost="5"> <match field="title" value="$request.title" boost="2" /> <match field="description" value="%request.description%" /> @@ -52,6 +51,29 @@ <filter xsi:type="rangeFilter" field="promoted_boost" name="price_name" from="10" to="100" /> <filter xsi:type="termFilter" name="price_name1" field="price_name" value="$name" /> </filters> + <aggregation> + <bucket xsi:type="termBucket" name="category_bucket" field="category"> + <metrics> + <metric type="sum" /> + <metric type="count" /> + <metric type="min" /> + <metric type="max" /> + </metrics> + </bucket> + <bucket xsi:type="rangeBucket" name="price_bucket" field="price"> + <metrics> + <metric type="sum" /> + <metric type="count" /> + <metric type="min" /> + <metric type="max" /> + </metrics> + <ranges> + <range from="" to="50" /> + <range from="50" to="100" /> + <range from="100" to=""/> + </ranges> + </bucket> + </aggregation> <from>10</from> <size>10</size> </request> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php index c63f48f3df7..84066fed20a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php @@ -23,6 +23,12 @@ */ return [ "suggested_search_container" => [ + "dimensions" => [ + "scope" => [ + "name" => "scope", + "value" => "default" + ] + ], "queries" => [ "suggested_search_container" => [ "name" => "suggested_search_container", @@ -39,15 +45,6 @@ return [ ], "type" => "boolQuery" ], - "fulltext_search_query1" => [ - "name" => "fulltext_search_query1", - "queryReference" => [ - [ - "ref" => "fulltext_search_query" - ] - ], - "type" => "filteredQuery" - ], "fulltext_search_query" => [ "name" => "fulltext_search_query", "boost" => "5", @@ -103,6 +100,60 @@ return [ "type" => "termFilter" ] ], + "aggregation" => [ + "category_bucket" => [ + "name" => "category_bucket", + "field" => "category", + "metric" => [ + [ + "type" => "sum", + ], + [ + "type" => "count", + ], + [ + "type" => "min", + ], + [ + "type" => "max", + ] + ], + "type" => "termBucket", + ], + "price_bucket" => [ + "name" => "price_bucket", + "field" => "price", + "metric" => [ + [ + "type" => "sum", + ], + [ + "type" => "count", + ], + [ + "type" => "min", + ], + [ + "type" => "max", + ] + ], + "range" => [ + [ + "from" => "", + "to" => "50", + ], + [ + "from" => "50", + "to" => "100", + ], + [ + "from" => "100", + "to" => "", + ], + ], + "type" => "rangeBucket", + ] + ], "from" => "10", "size" => "10", "query" => "suggested_search_container", diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php index c0477d2dddf..af90e50f940 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php @@ -46,7 +46,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** @var $sessionManager \Magento\Framework\Session\SessionManager */ $sessionManager = $this->_objectManager->get('Magento\Framework\Session\SessionManager'); if ($sessionManager->isSessionExists()) { - $sessionManager->destroy(); + $sessionManager->writeClose(); } $this->_model = $this->_objectManager->create( 'Magento\Framework\Session\Config', @@ -81,7 +81,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals('localhost', $this->_model->getCookieDomain()); $this->assertEquals(false, $this->_model->getCookieSecure()); $this->assertEquals(true, $this->_model->getCookieHttpOnly()); - $this->assertEquals($this->_model->getOption('save_path'), ini_get('session.save_path')); + $this->assertEquals($this->_model->getSavePath(), $this->_model->getOption('save_path')); } /** @@ -91,4 +91,14 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('files', $this->_model->getSaveHandler()); } + + /** + * Unable to add integration tests for testGetLifetimePathNonDefault + * + * Error: Cannot modify header information - headers already sent + */ + public function testGetLifetimePathNonDefault() + { + + } } diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/SessionTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/SessionTest.php index ad653d0a789..a8cc0ccb3bd 100644 --- a/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/SessionTest.php +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/Observer/SessionTest.php @@ -43,11 +43,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase */ protected $_persistentSession; - /** - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_cookieMock; - /** * @var \Magento\Customer\Model\Session */ @@ -57,15 +52,13 @@ class SessionTest extends \PHPUnit_Framework_TestCase { $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_persistentSession = $this->_objectManager->get('Magento\Persistent\Helper\Session'); - $this->_cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array('set'), array(), '', false); $this->_customerSession = $this->_objectManager->get('Magento\Customer\Model\Session'); $this->_model = $this->_objectManager->create( 'Magento\Persistent\Model\Observer\Session', - array( + [ 'persistentSession' => $this->_persistentSession, - 'cookie' => $this->_cookieMock, 'customerSession' => $this->_customerSession - ) + ] ); } @@ -75,10 +68,10 @@ class SessionTest extends \PHPUnit_Framework_TestCase public function testSynchronizePersistentOnLogin() { $event = new \Magento\Framework\Event(); - $observer = new \Magento\Framework\Event\Observer(array('event' => $event)); + $observer = new \Magento\Framework\Event\Observer(['event' => $event]); /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService */ - $customerAccountService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $customerAccountService = $this->_objectManager->create( 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' ); @@ -86,16 +79,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase $customer = $customerAccountService->getCustomer(1); $event->setData('customer', $customer); $this->_persistentSession->setRememberMeChecked(true); - $this->_cookieMock->expects( - $this->once() - )->method( - 'set' - )->with( - \Magento\Persistent\Model\Session::COOKIE_NAME, - $this->anything(), - $this->anything(), - $this->_customerSession->getCookiePath() - ); $this->_model->synchronizePersistentOnLogin($observer); // check that persistent session has been stored for Customer diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/SessionTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/SessionTest.php new file mode 100644 index 00000000000..0446fcf542e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/SessionTest.php @@ -0,0 +1,120 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Persistent\Model; + +class SessionTest extends \PHPUnit_Framework_TestCase +{ + /** + * Session model + * + * @var \Magento\Persistent\Model\Session + */ + protected $session; + + /** + * Object manager + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * The existing cookies + * + * @var array + */ + protected $existingCookies; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->session = $this->objectManager->create( + 'Magento\Persistent\Model\Session' + ); + $this->existingCookies = $_COOKIE; + } + + public function tearDown() + { + $_COOKIE = $this->existingCookies; + } + + public function testSetPersistentCookie() + { + $this->assertArrayNotHasKey(Session::COOKIE_NAME, $_COOKIE); + $key = 'sessionKey'; + $this->session->setKey($key); + $this->session->setPersistentCookie(1000, '/'); + $this->assertEquals($key, $_COOKIE[Session::COOKIE_NAME]); + } + + public function testRemovePersistendCookie() + { + $_COOKIE[Session::COOKIE_NAME] = 'cookieValue'; + $this->session->removePersistentCookie(); + $this->assertArrayNotHasKey(Session::COOKIE_NAME, $_COOKIE); + } + + /** + * @param int $duration + * @param string $cookieValue + * @dataProvider renewPersistentCookieDataProvider + */ + public function testRenewPersistentCookie($duration, $cookieValue = 'cookieValue') + { + $_COOKIE[Session::COOKIE_NAME] = $cookieValue; + $this->session->renewPersistentCookie($duration, '/'); + $this->assertEquals($cookieValue, $_COOKIE[Session::COOKIE_NAME]); + } + + public function renewPersistentCookieDataProvider() + { + return [ + 'no duration' => [null], + 'no cookie' => [1000, null], + 'all' => [1000], + ]; + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testLoadByCookieKey() + { + /** @var \Magento\Persistent\Model\Session $preSession */ + $preSession = $this->objectManager->get('Magento\Persistent\Model\SessionFactory') + ->create() + ->loadByCookieKey(); + $this->assertNull($preSession->getCustomerId()); + + $this->session->setCustomerId(1)->save(); + $this->session->setPersistentCookie(1000, '/'); + + /** @var \Magento\Persistent\Model\Session $postSession */ + $postSession = $this->objectManager->get('Magento\Persistent\Model\SessionFactory') + ->create() + ->loadByCookieKey(); + $this->assertEquals(1, $postSession->getCustomerId()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo.php index 0915824d889..458d62ca206 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo.php @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +require 'default_rollback.php'; require __DIR__ . '/order.php'; /** @var \Magento\Sales\Model\Order $order */ diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get.php new file mode 100644 index 00000000000..749da06554b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require 'default_rollback.php'; +require __DIR__ . '/order.php'; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->loadByIncrementId('100000001'); + +/** @var Magento\Sales\Model\Service\Order $service */ +$service = $objectManager->get('Magento\Sales\Model\Service\Order'); +$creditmemo = $service->prepareCreditmemo($order->getData()); +$creditmemo->setOrder($order); +$creditmemo->setState(Magento\Sales\Model\Order\Creditmemo::STATE_OPEN); +$creditmemo->setIncrementId('100000001'); +$creditmemo->save(); + +/** @var \Magento\Sales\Model\Order\Item $orderItem */ +$orderItem = $objectManager->get('\Magento\Sales\Model\Order\Item'); +$orderItem->setName('Test item') + ->setQtyRefunded(1) + ->setQtyInvoiced(10) + ->setId(1) + ->setOriginalPrice(20); + +/** @var \Magento\Sales\Model\Order\Creditmemo\Item $creditItem */ +$creditItem = $objectManager->get('Magento\Sales\Model\Order\Creditmemo\Item'); +$creditItem->setCreditmemo($creditmemo) + ->setOrderItem($orderItem) + ->setName('Creditmemo item') + ->setQty(1) + ->setPrice(20) + ->save(); diff --git a/lib/internal/Magento/Framework/Search/Response.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get_rollback.php similarity index 89% rename from lib/internal/Magento/Framework/Search/Response.php rename to dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get_rollback.php index d9bd14fbb4d..a0fd0a5186d 100644 --- a/lib/internal/Magento/Framework/Search/Response.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_for_get_rollback.php @@ -1,7 +1,5 @@ <?php /** - * Search Response - * * Magento * * NOTICE OF LICENSE @@ -23,8 +21,5 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Search; -class Response implements ResponseInterface -{ -} +require 'default_rollback.php'; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_rollback.php new file mode 100644 index 00000000000..a0fd0a5186d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require 'default_rollback.php'; \ No newline at end of file diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list.php similarity index 58% rename from app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php rename to dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list.php index 16237cbe85e..bd7fa9f96b7 100644 --- a/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list.php @@ -21,20 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; -/** - * Interface OrderAddressUpdate - * @package Magento\Sales\Service\V1 - */ -interface OrderAddressUpdateInterface -{ - /** - * Invoke orderAddressUpdate service - * - * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress - * @return bool - * @throws void - */ - public function invoke(\Magento\Sales\Service\V1\Data\OrderAddress $orderAddress); -} +require 'default_rollback.php'; +require __DIR__ . '/order.php'; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->loadByIncrementId('100000001'); + +/** @var Magento\Sales\Model\Service\Order $service */ +$service = $objectManager->get('Magento\Sales\Model\Service\Order'); +$creditmemo = $service->prepareCreditmemo($order->getData()); +$creditmemo->setOrder($order); +$creditmemo->setState(Magento\Sales\Model\Order\Creditmemo::STATE_OPEN); +$creditmemo->setIncrementId('100000001'); +$creditmemo->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list_rollback.php new file mode 100644 index 00000000000..a0fd0a5186d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/creditmemo_with_list_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require 'default_rollback.php'; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/default_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/default_rollback.php new file mode 100644 index 00000000000..a306b89d5f2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/default_rollback.php @@ -0,0 +1,45 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +use Magento\TestFramework\Helper\Bootstrap; + +/** @var \Magento\Framework\Registry $registry */ +$registry = Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var $order \Magento\Sales\Model\Order */ +$orderCollection = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Resource\Order\Collection'); +foreach ($orderCollection as $order) { + $order->delete(); +} + +/** @var $product \Magento\Catalog\Model\Product */ +$productCollection = Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Resource\Product\Collection'); +foreach ($productCollection as $product) { + $product->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php index cd374a766b4..72c2371407f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice.php @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +require 'default_rollback.php'; require 'order.php'; /** @var \Magento\Sales\Model\Order $order */ diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_rollback.php new file mode 100644 index 00000000000..a0fd0a5186d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require 'default_rollback.php'; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php index 35528f93314..2f0c89bd1ac 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php @@ -21,6 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +require 'default_rollback.php'; require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; /** @var \Magento\Catalog\Model\Product $product */ @@ -40,6 +41,9 @@ $payment->setMethod('checkmo'); /** @var \Magento\Sales\Model\Order\Item $orderItem */ $orderItem = $objectManager->create('Magento\Sales\Model\Order\Item'); $orderItem->setProductId($product->getId())->setQtyOrdered(2); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); /** @var \Magento\Sales\Model\Order $order */ $order = $objectManager->create('Magento\Sales\Model\Order'); @@ -51,6 +55,8 @@ $order->setIncrementId( 100 )->setBaseSubtotal( 100 +)->setBaseGrandTotal( + 100 )->setCustomerIsGuest( true )->setCustomerEmail( diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_rollback.php new file mode 100644 index 00000000000..a0fd0a5186d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require 'default_rollback.php'; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/shipment.php b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment.php new file mode 100644 index 00000000000..5d9303944bc --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment.php @@ -0,0 +1,43 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +require 'default_rollback.php'; +require __DIR__ . '/../../../Magento/Sales/_files/order.php'; + +$payment = $order->getPayment(); +$paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Payment\Helper\Data') + ->getInfoBlock($payment); +$payment->setBlockMock($paymentInfoBlock); + +/** @var \Magento\Sales\Model\Order\Shipment $shipment */ +$shipment = $objectManager->create('Magento\Sales\Model\Order\Shipment'); +$shipment->setOrder($order); + +$shipmentItem = $objectManager->create('Magento\Sales\Model\Order\Shipment\Item'); +$shipmentItem->setOrderItem($orderItem); +$shipment->addItem($shipmentItem); +$shipment->setPackages([['1'], ['2']]); +$shipment->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW); + +$shipment->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_rollback.php new file mode 100644 index 00000000000..a2107bf8657 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_rollback.php @@ -0,0 +1,24 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +require 'default_rollback.php'; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php index cff8fecfced..cc861ac6958 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php @@ -46,7 +46,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function _getStoreModel() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_modelParams = array( + $this->_modelParams = [ 'context' => $objectManager->get('Magento\Framework\Model\Context'), 'registry' => $objectManager->get('Magento\Framework\Registry'), 'resource' => $objectManager->get('Magento\Store\Model\Resource\Store'), @@ -59,14 +59,15 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'config' => $objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface'), 'storeManager' => $objectManager->get('Magento\Store\Model\StoreManager'), 'sidResolver' => $objectManager->get('Magento\Framework\Session\SidResolverInterface'), - 'cookie' => $objectManager->get('Magento\Framework\Stdlib\Cookie'), + 'cookieMetadataFactory' => $objectManager->get('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory'), + 'cookieManager' => $objectManager->get('Magento\Framework\Stdlib\CookieManager'), 'httpContext' => $objectManager->get('Magento\Framework\App\Http\Context'), 'session' => $objectManager->get('Magento\Framework\Session\SessionManagerInterface'), 'currencyFactory' => $objectManager->get('Magento\Directory\Model\CurrencyFactory'), 'currencyInstalled' => 'system/currency/installed', - ); + ]; - return $this->getMock('Magento\Store\Model\Store', array('getUrl'), $this->_modelParams); + return $this->getMock('Magento\Store\Model\Store', ['getUrl'], $this->_modelParams); } protected function tearDown() @@ -88,7 +89,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function loadDataProvider() { - return array(array(1, 1), array('default', 1), array('nostore', null)); + return [[1, 1], ['default', 1], ['nostore', null]]; } public function testSetGetWebsite() @@ -151,28 +152,28 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlDataProvider() { - return array( - array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/') - ); + return [ + [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'], + [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'], + [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'], + [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'], + [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'], + [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'], + [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'], + [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'], + [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'] + ]; } /** @@ -181,11 +182,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlInPub() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - array( - \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array( - \Magento\Framework\App\Filesystem::PUB_DIR => array('uri' => '') - ) - ) + [ + \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => [ + \Magento\Framework\App\Filesystem::PUB_DIR => ['uri' => ''] + ] + ] ); $this->_model = $this->_getStoreModel(); $this->_model->load('default'); @@ -245,31 +246,31 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlForCustomEntryPointDataProvider() { - return array( - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'), - array( + return [ + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'], + [ \Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/' - ), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'), - array( + ], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'], + [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'], + [ \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/' - ), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'), - array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/') - ); + ], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'], + [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'] + ]; } public function testGetDefaultCurrency() @@ -313,17 +314,19 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testCRUD() { $this->_model->setData( - array( + [ 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ) + ] ); $crud = new \Magento\TestFramework\Entity( - $this->_model, array('name' => 'new name'), 'Magento\Store\Model\Store' + $this->_model, + ['name' => 'new name'], + 'Magento\Store\Model\Store' ); $crud->testCrud(); } @@ -339,14 +342,14 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testSaveValidation($badStoreData) { - $normalStoreData = array( + $normalStoreData = [ 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ); + ]; $data = array_merge($normalStoreData, $badStoreData); $this->_model->setData($data); $this->_model->save(); @@ -357,11 +360,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public static function saveValidationDataProvider() { - return array( - 'empty store name' => array(array('name' => '')), - 'empty store code' => array(array('code' => '')), - 'invalid store code' => array(array('code' => '^_^')) - ); + return [ + 'empty store name' => [['name' => '']], + 'empty store code' => [['code' => '']], + 'invalid store code' => [['code' => '^_^']] + ]; } /** @@ -371,13 +374,13 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $configMock = $this->getMock('Magento\Framework\App\Config\ReinitableConfigInterface'); - $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false, false); + $appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false, false); $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue($isInstalled)); $params = $this->_modelParams; $params['context'] = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Framework\Model\Context', - array('appState' => $appStateMock) + ['appState' => $appStateMock] ); $configMock->expects( @@ -401,12 +404,12 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function isUseStoreInUrlDataProvider() { - return array( - array(true, true, null, true), - array(false, true, null, false), - array(true, false, null, false), - array(true, true, true, false), - array(true, true, false, true) - ); + return [ + [true, true, null, true], + [false, true, null, false], + [true, false, null, false], + [true, true, true, false], + [true, true, false, true] + ]; } } diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php index f7fa42e3fb3..1eb55815619 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php @@ -22,25 +22,38 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\UrlRewrite\Model; +use \Magento\TestFramework\Helper\Bootstrap; class UrlRewriteTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\UrlRewrite\Model\UrlRewrite */ - protected $_model; + protected $model; + + /** + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; protected function setUp() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->objectManager = Bootstrap::getObjectManager(); + + $this->model = $this->objectManager->create( 'Magento\UrlRewrite\Model\UrlRewrite' ); } + /** + * @magentoDbIsolation enabled + * + * @throws \Exception + */ public function testLoadByRequestPath() { - $this->_model->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->model->setStoreId( + $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( @@ -54,33 +67,37 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase )->save(); try { - $read = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $read = $this->objectManager->create( 'Magento\UrlRewrite\Model\UrlRewrite' ); $read->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByRequestPath( 'fancy/url.html' ); - $this->assertEquals($this->_model->getStoreId(), $read->getStoreId()); - $this->assertEquals($this->_model->getRequestPath(), $read->getRequestPath()); - $this->assertEquals($this->_model->getTargetPath(), $read->getTargetPath()); - $this->assertEquals($this->_model->getIsSystem(), $read->getIsSystem()); - $this->assertEquals($this->_model->getOptions(), $read->getOptions()); - $this->_model->delete(); + $this->assertEquals($this->model->getStoreId(), $read->getStoreId()); + $this->assertEquals($this->model->getRequestPath(), $read->getRequestPath()); + $this->assertEquals($this->model->getTargetPath(), $read->getTargetPath()); + $this->assertEquals($this->model->getIsSystem(), $read->getIsSystem()); + $this->assertEquals($this->model->getOptions(), $read->getOptions()); + $this->model->delete(); } catch (\Exception $e) { - $this->_model->delete(); + $this->model->delete(); throw $e; } } + /** + * @magentoDbIsolation enabled + * @throws \Exception + */ public function testLoadByIdPath() { - $this->_model->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->model->setStoreId( + $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( @@ -96,45 +113,53 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase )->save(); try { - $read = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $read = $this->objectManager->create( 'Magento\UrlRewrite\Model\UrlRewrite' ); $read->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByIdPath( 'product/1' ); - $this->assertEquals($this->_model->getStoreId(), $read->getStoreId()); - $this->assertEquals($this->_model->getRequestPath(), $read->getRequestPath()); - $this->assertEquals($this->_model->getTargetPath(), $read->getTargetPath()); - $this->assertEquals($this->_model->getIdPath(), $read->getIdPath()); - $this->assertEquals($this->_model->getIsSystem(), $read->getIsSystem()); - $this->assertEquals($this->_model->getOptions(), $read->getOptions()); - $this->_model->delete(); + $this->assertEquals($this->model->getStoreId(), $read->getStoreId()); + $this->assertEquals($this->model->getRequestPath(), $read->getRequestPath()); + $this->assertEquals($this->model->getTargetPath(), $read->getTargetPath()); + $this->assertEquals($this->model->getIdPath(), $read->getIdPath()); + $this->assertEquals($this->model->getIsSystem(), $read->getIsSystem()); + $this->assertEquals($this->model->getOptions(), $read->getOptions()); + $this->model->delete(); } catch (\Exception $e) { - $this->_model->delete(); + $this->model->delete(); throw $e; } } + /** + * @magentoDbIsolation enabled + */ public function testHasOption() { - $this->_model->setOptions('RP'); - $this->assertTrue($this->_model->hasOption('RP')); + $this->model->setOptions('RP'); + $this->assertTrue($this->model->hasOption('RP')); } + /** + * + * @magentoDbIsolation enabled + * @throws \Exception + */ public function testRewrite() { - $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $request = $this->objectManager->create( 'Magento\Framework\App\RequestInterface' )->setPathInfo( 'fancy/url.html' ); $_SERVER['QUERY_STRING'] = 'foo=bar&___fooo=bar'; - $this->_model->setRequestPath( + $this->model->setRequestPath( 'fancy/url.html' )->setTargetPath( 'another/fancy/url.html' @@ -143,51 +168,136 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase )->save(); try { - $this->assertTrue($this->_model->rewrite($request)); + $this->assertTrue($this->model->rewrite($request)); $this->assertEquals('/another/fancy/url.html?foo=bar', $request->getRequestUri()); $this->assertEquals('another/fancy/url.html', $request->getPathInfo()); - $this->_model->delete(); + $this->model->delete(); } catch (\Exception $e) { - $this->_model->delete(); + $this->model->delete(); throw $e; } } + /** + * @magentoDbIsolation enabled + */ + public function testRewriteSetCookie() + { + $_SERVER['QUERY_STRING'] = 'foo=bar'; + + $context = $this->objectManager->create( + '\Magento\Framework\Model\Context' + ); + $registry = $this->objectManager->create( + '\Magento\Framework\Registry' + ); + $scopeConfig = $this->objectManager->create( + '\Magento\Framework\App\Config\ScopeConfigInterface' + ); + $cookieMetadataFactory = $this->objectManager->create( + '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + ); + $cookieManager = $this->objectManager->create( + '\Magento\Framework\Stdlib\CookieManager' + ); + $storeManager = $this->objectManager->create( + '\Magento\Store\Model\StoreManagerInterface' + ); + $httpContext = $this->objectManager->create( + '\Magento\Framework\App\Http\Context' + ); + + $constructorArgs = [ + 'context' => $context, + 'registry' => $registry, + 'scopeConfig' => $scopeConfig, + 'cookieMetadataFactory' => $cookieMetadataFactory, + 'cookieManager' => $cookieManager, + 'storeManager' => $storeManager, + 'httpContext' => $httpContext, + ]; + + //SUT must be mocked out for this test to prevent headers from being sent, + //causing errors. + + /** @var \PHPUnit_Framework_MockObject_MockObject /\Magento\UrlRewrite\Model\UrlRewrite $modelMock */ + $modelMock = $this->getMock('\Magento\UrlRewrite\Model\UrlRewrite', + ['_sendRedirectHeaders'], + $constructorArgs + ); + + $modelMock->setRequestPath('http://fancy/url.html') + ->setTargetPath('http://another/fancy/url.html') + ->setIsSystem(1) + ->setOptions('R') + ->save(); + + $modelMock->expects($this->exactly(2)) + ->method('_sendRedirectHeaders'); + + $request = $this->objectManager + ->create('Magento\Framework\App\RequestInterface') + ->setPathInfo('http://fancy/url.html'); + + $this->assertTrue($modelMock->rewrite($request)); + $this->assertEquals('admin', $_COOKIE[\Magento\Store\Model\Store::COOKIE_NAME]); + + $modelMock->delete(); + + } + + /** + * @magentoDbIsolation enabled + */ public function testRewriteNonExistingRecord() { - $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $request = $this->objectManager ->create('Magento\Framework\App\RequestInterface'); - $this->assertFalse($this->_model->rewrite($request)); + $this->assertFalse($this->model->rewrite($request)); } + /** + * @magentoDbIsolation enabled + */ public function testRewriteWrongStore() { - $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $request = $this->objectManager ->create('Magento\Framework\App\RequestInterface'); $_GET['___from_store'] = uniqid('store'); - $this->assertFalse($this->_model->rewrite($request)); + $this->assertFalse($this->model->rewrite($request)); } + /** + * @magentoDbIsolation enabled + */ public function testRewriteNonExistingRecordCorrectStore() { - $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $request = $this->objectManager ->create('Magento\Framework\App\RequestInterface'); - $_GET['___from_store'] = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $_GET['___from_store'] = $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getCode(); - $this->assertFalse($this->_model->rewrite($request)); + $this->assertFalse($this->model->rewrite($request)); } + /** + * @magentoDbIsolation enabled + */ public function testGetStoreId() { - $this->_model->setStoreId(10); - $this->assertEquals(10, $this->_model->getStoreId()); + $this->model->setStoreId(10); + $this->assertEquals(10, $this->model->getStoreId()); } + /** + * @magentoDbIsolation enabled + * + * @throws \Exception + */ public function testCRUD() { - $this->_model->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->model->setStoreId( + $this->objectManager->get( 'Magento\Store\Model\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( @@ -199,7 +309,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase )->setOptions( 'RP' ); - $crud = new \Magento\TestFramework\Entity($this->_model, array('request_path' => 'fancy/url2.html')); + $crud = new \Magento\TestFramework\Entity($this->model, ['request_path' => 'fancy/url2.html']); $crud->testCrud(); } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php index 5aabe6c1bab..97b0c15c578 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php @@ -177,7 +177,7 @@ class Classes */ public static function collectLayoutClasses(\SimpleXMLElement $xml) { - $classes = self::getXmlAttributeValues($xml, '/layout//block[@type]', 'type'); + $classes = self::getXmlAttributeValues($xml, '/layout//block[@class]', 'class'); $classes = array_merge( $classes, self::getXmlNodeValues( diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php index 7d0990be944..5b0c61349f7 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php @@ -904,7 +904,7 @@ class Files * of file names * Note that realpath() automatically changes directory separator to the OS-native */ - if (realpath($fullPath) == str_replace(array('/', '\\'), '/', $fullPath)) { + if (realpath($fullPath) == str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $fullPath)) { $fileContent = file_get_contents($fullPath); if (strpos( $fileContent, diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php index df58487d10f..eb1fc3a0acc 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php @@ -500,7 +500,7 @@ class DependencyTest extends \PHPUnit_Framework_TestCase foreach ($files as $file) { if (preg_match('/(?<namespace>[A-Z][a-z]+)[_\/\\\\](?<module>[A-Z][a-zA-Z]+)/', $file, $matches)) { $module = $matches['namespace'] . '\\' . $matches['module']; - self::$_listRoutesXml[$module] = $file; + self::$_listRoutesXml[$module][] = $file; } } } @@ -517,28 +517,44 @@ class DependencyTest extends \PHPUnit_Framework_TestCase foreach ($files as $file) { if (preg_match($pattern, $file, $matches)) { $module = $matches['namespace'] . '\\' . $matches['module']; - if (isset(self::$_listRoutesXml[$module])) { - // Read module's routes.xml file - $config = simplexml_load_file(self::$_listRoutesXml[$module]); - $nodes = $config->xpath("/config/router/*"); - foreach ($nodes as $node) { - $id = (string)$node['id']; - if ($id != 'adminhtml' && '' == (string)$node['frontName']) { - // Exclude overridden routers - continue; - } - if (!isset(self::$_mapRouters[$id])) { - self::$_mapRouters[$id] = array(); - } - if (!in_array($module, self::$_mapRouters[$id])) { - self::$_mapRouters[$id][] = $module; - } + if (!empty(self::$_listRoutesXml[$module])) { + foreach (self::$_listRoutesXml[$module] as $configFile) { + self::updateRoutersMap($module, $configFile); + } } } } } + /** + * Update routers map for the module basing on the routing config file + * + * @param string $module + * @param string $configFile + * + * @return void + */ + private static function updateRoutersMap($module, $configFile) + { + // Read module's routes.xml file + $config = simplexml_load_file($configFile); + $nodes = $config->xpath("/config/router/*"); + foreach ($nodes as $node) { + $id = (string)$node['id']; + if ($id != 'adminhtml' && '' == (string)$node['frontName']) { + // Exclude overridden routers + continue; + } + if (!isset(self::$_mapRouters[$id])) { + self::$_mapRouters[$id] = array(); + } + if (!in_array($module, self::$_mapRouters[$id])) { + self::$_mapRouters[$id][] = $module; + } + } + } + /** * Prepare map of layout blocks */ diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php index df0577ac49d..b85b880e4f1 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php @@ -104,6 +104,7 @@ Element 'queryReference': No match found for key-sequence ['fulltext_search_quer explode( "\n", " +Element 'dimensions': Missing child element(s). Expected is ( dimension ) Element 'queryReference': The attribute 'ref' is required but missing. Element 'filterReference': The attribute 'ref' is required but missing. Element 'filter': The attribute 'field' is required but missing. diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml index 6dffe42beca..82b5fb547aa 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml @@ -25,6 +25,8 @@ --> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <request query="sugested_search_container" index="product"> + <dimensions> + </dimensions> <queries> <query xsi:type="boolQuery" name="sugested_search_container" boost="2"> <queryReference clause="not" ref="fulltext_search_query" /> diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml index 090a3c76b9a..5f42427c890 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml @@ -25,6 +25,9 @@ --> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <request query="sugegsted_search_container_1" index="product_1"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> <queries> <query xsi:type="boolQuery" name="sugegsted_search_container_1" boost="2"> <queryReference clause="must" ref="fulltext_search_query" /> diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 8944cce44cf..b1591e13986 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -2736,4 +2736,5 @@ return array( ['Magento\CatalogSearch\Model\Fulltext\Observer'], ['Magento\CatalogSearch\Model\Resource\Indexer\Fulltext'], ['\Magento\Theme\Helper\Layout'], + ['Magento\Framework\Stdlib\Cookie', 'Magento\Framework\Stdlib\CookieManager'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index e0e27396680..74d5668b058 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -36,7 +36,12 @@ return array( array('_afterSetConfig', 'Magento\Eav\Model\Entity\AbstractEntity'), array('_aggregateByOrderCreatedAt', 'Magento\SalesRule\Model\Resource\Report\Rule'), array('_amountByCookies', 'Magento\Sendfriend\Model\Sendfriend'), - array('_amountByIp', 'Magento\Sendfriend\Model\Sendfriend'), + array('setCookie', 'Magento\Sendfriend\Model\Sendfriend'), + array('getCookie', 'Magento\Sendfriend\Model\Sendfriend'), + array('setRemoteAddr', 'Magento\Sendfriend\Model\Sendfriend'), + array('getRemoteAddr', 'Magento\Sendfriend\Model\Sendfriend'), + array('setWebsiteId', 'Magento\Sendfriend\Model\Sendfriend'), + array('getWebsiteId', 'Magento\Sendfriend\Model\Sendfriend'), array('_applyClassRewrites', 'Magento\Core\Model\Config'), array('_applyCustomDesignSettings'), array('_applyCustomizationFiles', 'Magento\Core\Model\Theme'), @@ -1907,4 +1912,7 @@ return array( 'updateCategoryIndex', 'Magento\CatalogSearch\Model\Resource\Fulltext', ], + ['removeTag', '\Magento\UrlRewrite\Model\UrlRewrite'], + ['addTag', '\Magento\UrlRewrite\Model\UrlRewrite'], + ['loadByTags', '\Magento\UrlRewrite\Model\UrlRewrite'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index 5838cc49d92..81e78ef60f1 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -124,4 +124,5 @@ Magento/Shipping/Model Magento/Catalog/Service/V1/Category Magento/UrlRedirect/Model setup -Magento/Sales/Service/V1/Data \ No newline at end of file +Magento/Sales/Service/V1 +Magento/Shipping/Controller/Adminhtml/Order/Shipment \ No newline at end of file diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php index ca2e1d5bcb8..acf291e0cbf 100644 --- a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php +++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php @@ -23,8 +23,6 @@ */ namespace Magento\TestFramework\Matcher; -use Magento\TestFramework\Matcher\MethodInvokedAtIndex; - class MethodInvokedAtIndexTest extends \PHPUnit_Framework_TestCase { public function testMatches() diff --git a/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php new file mode 100644 index 00000000000..a0dbec84e05 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Test class for \Magento\Backend\AdminConfig + */ +namespace Magento\Backend; + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + +class AdminConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\App\RequestInterface + */ + private $requestMock; + + /** + * @var \Magento\Framework\App\State + */ + private $appState; + + + protected function setUp() + { + $this->requestMock = $this->getMock( + '\Magento\Framework\App\Request\Http', + ['getBasePath', 'isSecure', 'getHttpHost'], + [], + '', + false, + false + ); + $this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/')); + $this->requestMock->expects( + $this->atLeastOnce() + )->method( + 'getHttpHost' + )->will( + $this->returnValue('init.host') + ); + $this->appState = $this->getMock('\Magento\Framework\App\State', + ['isInstalled'], [], '', false, false); + $this->appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true)); + } + + public function testSetCookiePathNonDefault() + { + $mockFrontNameResolver = $this->getMockBuilder('\Magento\Backend\App\Area\FrontNameResolver') + ->disableOriginalConstructor() + ->getMock(); + + $mockFrontNameResolver + ->method('getFrontName') + ->will($this->returnValue('backend')); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $adminConfig = $objectManager->getObject( + 'Magento\Backend\AdminConfig', + [ + 'request' => $this->requestMock, + 'appState' => $this->appState, + 'frontNameResolver' => $mockFrontNameResolver, + ] + ); + + $this->assertEquals('/backend', $adminConfig->getCookiePath()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Backend/App/Response/Http/FileFactoryTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/Response/Http/FileFactoryTest.php index 98a7db27308..aa92d624b93 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/App/Response/Http/FileFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/App/Response/Http/FileFactoryTest.php @@ -55,8 +55,8 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_responseMock = $this->getMock( 'Magento\Framework\App\Response\Http', - array('setRedirect'), - array(), + ['setRedirect', '__wakeup'], + [], '', false ); @@ -74,16 +74,16 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_backendUrl = $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false); - $this->_authMock = $this->getMock('Magento\Backend\Model\Auth', array(), array(), '', false); + $this->_backendUrl = $this->getMock('Magento\Backend\Model\Url', [], [], '', false); + $this->_authMock = $this->getMock('Magento\Backend\Model\Auth', [], [], '', false); $this->_model = $helper->getObject( 'Magento\Backend\App\Response\Http\FileFactory', - array( + [ 'response' => $this->_responseMock, 'auth' => $this->_authMock, 'backendUrl' => $this->_backendUrl, 'session' => $this->_sessionMock - ) + ] ); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Auth/SessionTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Auth/SessionTest.php index e195b110566..76d49939148 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Auth/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Auth/SessionTest.php @@ -26,7 +26,7 @@ namespace Magento\Backend\Model\Auth; use Magento\TestFramework\Helper\ObjectManager; /** - * Class SessionTest + * Class SessionTest tests Magento\Backend\Model\Auth\Session */ class SessionTest extends \PHPUnit_Framework_TestCase { @@ -41,9 +41,14 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected $sessionConfig; /** - * @var \Magento\Framework\Stdlib\Cookie | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\CookieManager | \PHPUnit_Framework_MockObject_MockObject */ - protected $cookie; + protected $cookieManager; + + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieMetadataFactory; /** * @var \Magento\Framework\Session\Storage | \PHPUnit_Framework_MockObject_MockObject @@ -57,8 +62,22 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->cookieMetadataFactory = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + ['createPublicCookieMetadata'], + [], + '', + false + ); + $this->config = $this->getMock('Magento\Backend\App\Config', ['getValue'], [], '', false); - $this->cookie = $this->getMock('Magento\Framework\Stdlib\Cookie', ['get', 'set'], [], '', false); + $this->cookieManager = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PhpCookieManager', + ['getCookie', 'setPublicCookie'], + [], + '', + false + ); $this->storage = $this->getMock('Magento\Framework\Session\Storage', ['getUser'], [], '', false); $this->sessionConfig = $this->getMock( 'Magento\Framework\Session\Config', @@ -73,7 +92,8 @@ class SessionTest extends \PHPUnit_Framework_TestCase [ 'config' => $this->config, 'sessionConfig' => $this->sessionConfig, - 'cookie' => $this->cookie, + 'cookieManager' => $this->cookieManager, + 'cookieMetadataFactory' => $this->cookieMetadataFactory, 'storage' => $this->storage ] ); @@ -118,13 +138,39 @@ class SessionTest extends \PHPUnit_Framework_TestCase $secure = true; $httpOnly = true; - $this->cookie->expects($this->once()) - ->method('get') + $cookieMetadata = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); + $cookieMetadata->expects($this->once()) + ->method('setDuration') + ->with($lifetime) + ->will($this->returnSelf()); + $cookieMetadata->expects($this->once()) + ->method('setPath') + ->with($path) + ->will($this->returnSelf()); + $cookieMetadata->expects($this->once()) + ->method('setDomain') + ->with($domain) + ->will($this->returnSelf()); + $cookieMetadata->expects($this->once()) + ->method('setSecure') + ->with($secure) + ->will($this->returnSelf()); + $cookieMetadata->expects($this->once()) + ->method('setHttpOnly') + ->with($httpOnly) + ->will($this->returnSelf()); + + $this->cookieMetadataFactory->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadata)); + + $this->cookieManager->expects($this->once()) + ->method('getCookie') ->with($name) ->will($this->returnValue($cookie)); - $this->cookie->expects($this->once()) - ->method('set') - ->with($name, $cookie, $lifetime, $path, $domain, $secure, $httpOnly); + $this->cookieManager->expects($this->once()) + ->method('setPublicCookie') + ->with($name, $cookie, $cookieMetadata); $this->config->expects($this->once()) ->method('getValue') diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php new file mode 100644 index 00000000000..ea89dbef4eb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/DomainTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Backend\Model\Config\Backend; + +use Magento\Framework\Model\Exception; + +/** + * Test \Magento\Backend\Model\Config\Backend\Domain + */ +class DomainTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Framework\Model\Resource\AbstractResource | \PHPUnit_Framework_MockObject_MockObject */ + protected $resourceMock; + + /** @var \Magento\Backend\Model\Config\Backend\Domain */ + protected $domain; + + protected function setUp() + { + $eventDispatcherMock = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); + $contextMock->expects( + $this->any() + )->method( + 'getEventDispatcher' + )->will( + $this->returnValue($eventDispatcherMock) + ); + + $this->resourceMock = $this->getMock( + 'Magento\Framework\Model\Resource\AbstractResource', + [ + '_construct', + '_getReadAdapter', + '_getWriteAdapter', + 'getIdFieldName', + 'beginTransaction', + 'save', + 'commit', + 'addCommitCallback', + 'rollBack', + ], + [], + '', + false + ); + + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->domain = $helper->getObject( + 'Magento\Backend\Model\Config\Backend\Domain', + [ + 'context' => $contextMock, + 'resource' => $this->resourceMock, + ] + ); + } + + /** + * @covers \Magento\Backend\Model\Config\Backend\Domain::_beforeSave + * @dataProvider beforeSaveDataProvider + * + * @param string $value + * @param string $exceptionMessage + */ + public function testBeforeSave($value, $exceptionMessage = null) + { + $this->resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); + $this->resourceMock->expects($this->any())->method('commit')->will($this->returnSelf()); + $this->resourceMock->expects($this->any())->method('rollBack')->will($this->returnSelf()); + + $this->domain->setValue($value); + try { + $this->domain->save(); + if ($exceptionMessage ) { + $this->fail('Failed to throw exception'); + } + } catch (Exception $e) { + $this->assertContains('Invalid domain name: ', $e->getMessage()); + $this->assertContains($exceptionMessage, $e->getMessage()); + } + } + + /** + * @return array + */ + public function beforeSaveDataProvider() + { + return [ + 'not string' => [['array'], 'Invalid type given. String expected'], + 'invalid hostname' => [ + 'http://', + 'The input does not match the expected structure for a DNS hostname; ' + . 'The input does not appear to be a valid URI hostname; ' + . 'The input does not appear to be a valid local network name' + ], + 'valid hostname' => ['hostname.com'], + 'empty string' => [''], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php index fa08eec1a86..f7cb2446164 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Adjustment/CalculatorTest.php @@ -23,8 +23,9 @@ */ namespace Magento\Bundle\Pricing\Adjustment; -use Magento\Bundle\Pricing\Price; use Magento\Bundle\Model\Product\Price as ProductPrice; +use Magento\Bundle\Pricing\Price; +use Magento\TestFramework\Helper\ObjectManager; /** * Test for \Magento\Bundle\Pricing\Adjustment\Calculator @@ -78,12 +79,16 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); $priceInfo = $this->getMock('Magento\Framework\Pricing\PriceInfo\Base', [], [], '', false); - $priceInfo->expects($this->any())->method('getPrice')->will($this->returnCallback(function ($type) { - if (!isset($this->priceMocks[$type])) { - throw new \PHPUnit_Framework_ExpectationFailedException('Unexpected type of price model'); - } - return $this->priceMocks[$type]; - })); + $priceInfo->expects($this->any())->method('getPrice')->will( + $this->returnCallback( + function ($type) { + if (!isset($this->priceMocks[$type])) { + throw new \PHPUnit_Framework_ExpectationFailedException('Unexpected type of price model'); + } + return $this->priceMocks[$type]; + } + ) + ); $this->saleableItem->expects($this->any())->method('getPriceInfo')->will($this->returnValue($priceInfo)); $store = $this->getMockBuilder('Magento\Store\Model\Store') @@ -99,35 +104,35 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $factoryCallback = $this->returnCallback(function () { - list(, $selectionMock) = func_get_args(); - $bundlePrice = $this->getMockBuilder('Magento\Bundle\Pricing\Price\BundleSelectionPrice') - ->setMethods(['getAmount']) - ->disableOriginalConstructor() - ->getMock(); - $bundlePrice->expects($this->any())->method('getAmount') - ->will($this->returnValue($selectionMock->getAmountMock())); - return $bundlePrice; - }); + $factoryCallback = $this->returnCallback( + function () { + list(, $selectionMock) = func_get_args(); + $bundlePrice = $this->getMockBuilder('Magento\Bundle\Pricing\Price\BundleSelectionPrice') + ->setMethods(['getAmount']) + ->disableOriginalConstructor() + ->getMock(); + $bundlePrice->expects($this->any())->method('getAmount') + ->will($this->returnValue($selectionMock->getAmountMock())); + return $bundlePrice; + } + ); $this->selectionFactory->expects($this->any())->method('create')->will($factoryCallback); $this->taxData = $this->getMockBuilder('Magento\Tax\Helper\Data') ->disableOriginalConstructor() ->getMock(); - $this->model = new Calculator( - $this->baseCalculator, - $this->amountFactory, - $this->selectionFactory, - $this->taxData + $this->model = (new ObjectManager($this))->getObject( + 'Magento\Bundle\Pricing\Adjustment\Calculator', + [ + 'calculator' => $this->baseCalculator, + 'amountFactory' => $this->amountFactory, + 'bundleSelectionFactory' => $this->selectionFactory, + 'taxHelper' => $this->taxData + ] ); } - protected function tearDown() - { - $this->priceMocks = []; - } - public function testEmptySelectionPriceList() { $option = $this->getMock('Magento\Bundle\Model\Option', ['getSelections', '__wakeup'], [], '', false); @@ -155,9 +160,11 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $this->priceMocks[Price\BundleOptionPrice::PRICE_CODE] = $price; // Price type of saleable items - $this->saleableItem->expects($this->any())->method('getPriceType')->will($this->returnValue( - ProductPrice::PRICE_TYPE_DYNAMIC - )); + $this->saleableItem->expects($this->any())->method('getPriceType')->will( + $this->returnValue( + ProductPrice::PRICE_TYPE_DYNAMIC + ) + ); $this->amountFactory->expects($this->atLeastOnce())->method('create') ->with($expectedResult['fullAmount'], $expectedResult['adjustments']); @@ -168,6 +175,28 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase } } + /** + * @return array + */ + public function dataProviderForGetterAmount() + { + return [ + // first case with minimal amount + 'case with getting minimal amount' => $this->getCaseWithMinAmount(), + // second case with maximum amount + 'case with getting maximum amount' => $this->getCaseWithMaxAmount(), + // third case without saleable items + 'case without saleable items' => $this->getCaseWithoutSaleableItems(), + // fourth case without require options + 'case without required options' => $this->getCaseMinAmountWithoutRequiredOptions(), + ]; + } + + protected function tearDown() + { + $this->priceMocks = []; + } + /** * Create amount mock * @@ -227,26 +256,6 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase return $selection; } - /** - * @return array - */ - public function dataProviderForGetterAmount() - { - return [ - // first case with minimal amount - 'case with getting minimal amount' => $this->getCaseWithMinAmount(), - - // second case with maximum amount - 'case with getting maximum amount' => $this->getCaseWithMaxAmount(), - - // third case without saleable items - 'case without saleable items' => $this->getCaseWithoutSaleableItems(), - - // fourth case without require options - 'case without required options' => $this->getCaseMinAmountWithoutRequiredOptions(), - ]; - } - /** * Array for data provider dataProviderForGetterAmount for case 'case with getting minimal amount' * @@ -264,30 +273,30 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => false, 'data' => [ - 'title' => 'test option 1', + 'title' => 'test option 1', 'default_title' => 'test option 1', - 'type' => 'select', - 'option_id' => '1', - 'position' => '0', - 'required' => '1', + 'type' => 'select', + 'option_id' => '1', + 'position' => '0', + 'required' => '1', ], 'selections' => [ - 'first product selection' => [ - 'data' => ['price' => 70.], + 'first product selection' => [ + 'data' => ['price' => 70.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8, 'weee' => 10], 'amount' => 18 ] ], 'second product selection' => [ - 'data' => ['price' => 80.], + 'data' => ['price' => 80.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 18], 'amount' => 28 ] ], - 'third product selection with the lowest price' => [ - 'data' => ['price' => 50.], + 'third product selection with the lowest price' => [ + 'data' => ['price' => 50.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8, 'weee' => 10], 'amount' => 8 @@ -298,7 +307,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ], 'expectedResult' => [ 'isMinAmount' => true, - 'fullAmount' => 790., + 'fullAmount' => 790., 'adjustments' => ['tax' => 110, 'weee' => 10] ] ]; @@ -321,23 +330,23 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => false, 'data' => [ - 'title' => 'test option 1', + 'title' => 'test option 1', 'default_title' => 'test option 1', - 'type' => 'select', - 'option_id' => '1', - 'position' => '0', - 'required' => '1', + 'type' => 'select', + 'option_id' => '1', + 'position' => '0', + 'required' => '1', ], 'selections' => [ - 'first product selection' => [ - 'data' => ['price' => 50.], + 'first product selection' => [ + 'data' => ['price' => 50.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8, 'weee' => 10], 'amount' => 8 ] ], 'second product selection' => [ - 'data' => ['price' => 80.], + 'data' => ['price' => 80.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 18], 'amount' => 8 @@ -349,30 +358,30 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => true, 'data' => [ - 'title' => 'test option 2', + 'title' => 'test option 2', 'default_title' => 'test option 2', - 'type' => 'select', - 'option_id' => '2', - 'position' => '1', - 'required' => '1', + 'type' => 'select', + 'option_id' => '2', + 'position' => '1', + 'required' => '1', ], 'selections' => [ - 'first product selection' => [ - 'data' => ['price' => 20.], + 'first product selection' => [ + 'data' => ['price' => 20.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8], 'amount' => 8 ] ], 'second product selection' => [ - 'data' => ['price' => 110.], + 'data' => ['price' => 110.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 28], 'amount' => 28 ] ], 'third product selection' => [ - 'data' => ['price' => 50.], + 'data' => ['price' => 50.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 18], 'amount' => 18 @@ -383,7 +392,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ], 'expectedResult' => [ 'isMinAmount' => false, - 'fullAmount' => 844., + 'fullAmount' => 844., 'adjustments' => ['tax' => 164, 'weee' => 10] ] ]; @@ -406,19 +415,19 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => false, 'data' => [ - 'title' => 'test option 1', + 'title' => 'test option 1', 'default_title' => 'test option 1', - 'type' => 'select', - 'option_id' => '1', - 'position' => '0', - 'required' => '1', + 'type' => 'select', + 'option_id' => '1', + 'position' => '0', + 'required' => '1', ], 'selections' => [] ], ], 'expectedResult' => [ 'isMinAmount' => true, - 'fullAmount' => 782., + 'fullAmount' => 782., 'adjustments' => ['tax' => 102] ] ]; @@ -441,23 +450,23 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => false, 'data' => [ - 'title' => 'test option 1', + 'title' => 'test option 1', 'default_title' => 'test option 1', - 'type' => 'select', - 'option_id' => '1', - 'position' => '0', - 'required' => '0', + 'type' => 'select', + 'option_id' => '1', + 'position' => '0', + 'required' => '0', ], 'selections' => [ - 'first product selection' => [ - 'data' => ['price' => 20.], + 'first product selection' => [ + 'data' => ['price' => 20.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8], 'amount' => 8 ] ], - 'second product selection' => [ - 'data' => ['price' => 30.], + 'second product selection' => [ + 'data' => ['price' => 30.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 10], 'amount' => 12 @@ -469,23 +478,23 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase [ 'isMultiSelection' => false, 'data' => [ - 'title' => 'test option 2', + 'title' => 'test option 2', 'default_title' => 'test option 2', - 'type' => 'select', - 'option_id' => '2', - 'position' => '1', - 'required' => '0', + 'type' => 'select', + 'option_id' => '2', + 'position' => '1', + 'required' => '0', ], 'selections' => [ - 'first product selection' => [ - 'data' => ['price' => 25.], + 'first product selection' => [ + 'data' => ['price' => 25.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 8], 'amount' => 9 ] ], - 'second product selection' => [ - 'data' => ['price' => 35.], + 'second product selection' => [ + 'data' => ['price' => 35.], 'amount' => [ 'adjustmentsAmounts' => ['tax' => 10], 'amount' => 10 @@ -496,7 +505,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase ], 'expectedResult' => [ 'isMinAmount' => true, - 'fullAmount' => 8., + 'fullAmount' => 8., 'adjustments' => ['tax' => 8] ] ]; diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/GroupPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/GroupPriceTest.php index 6039a1bf000..bc50c043796 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/GroupPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Pricing/Price/GroupPriceTest.php @@ -74,6 +74,7 @@ class GroupPriceTest extends \PHPUnit_Framework_TestCase * @var \Magento\Catalog\Pricing\Price\RegularPrice|\PHPUnit_Framework_MockObject_MockObject */ protected $regularPrice; + /** * Set up test case */ @@ -189,15 +190,37 @@ class GroupPriceTest extends \PHPUnit_Framework_TestCase $this->equalTo('group_price'), $this->equalTo(null) ) - ->will($this->returnValue( - [ + ->will( + $this->returnValue( [ - 'cust_group' => 3, - 'website_price' => 80 + [ + 'cust_group' => 3, + 'website_price' => 80 + ] ] - ] - )); + ) + ); + $this->assertEquals(20, $this->groupPrice->getValue()); $this->assertEquals(20, $this->groupPrice->getValue()); } + + public function testGetValueNotGroupPrice() + { + $this->productMock->expects($this->once()) + ->method('getCustomerGroupId') + ->will($this->returnValue(null)); + $this->customerSessionMock->expects($this->once()) + ->method('getCustomerGroupId') + ->will($this->returnValue(3)); + $this->productMock->expects($this->once()) + ->method('getResource') + ->will($this->returnValue($this->productResourceMock)); + $this->productResourceMock->expects($this->once()) + ->method('getAttribute') + ->with($this->equalTo('group_price')) + ->will($this->returnValue(null)); + + $this->assertFalse($this->groupPrice->getValue()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php index c144c696fd8..5e884ad8181 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php @@ -132,7 +132,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase { $this->request = $this->getMock( 'Magento\Framework\App\RequestInterface', - ['getParam', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName'], + ['getParam', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getCookie'], [], '', false diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php new file mode 100644 index 00000000000..5c75256055c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php @@ -0,0 +1,342 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Catalog\Model; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class LayerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Layer + */ + private $model; + + /** + * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject + */ + private $category; + + /** + * @var \Magento\Catalog\Model\CategoryFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $categoryFactory; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + private $registry; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $storeManager; + + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + private $store; + + /** + * @var \Magento\Catalog\Model\Layer\ContextInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $context; + + /** + * @var \Magento\Catalog\Model\Layer\Category\StateKey|\PHPUnit_Framework_MockObject_MockObject + */ + private $stateKeyGenerator; + + /** + * @var \Magento\Catalog\Model\Layer\StateFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $stateFactory; + + /** + * @var \Magento\Catalog\Model\Layer\State|\PHPUnit_Framework_MockObject_MockObject + */ + private $state; + + /** + * @var \Magento\Catalog\Model\Layer\Category\CollectionFilter|\PHPUnit_Framework_MockObject_MockObject + */ + private $collectionFilter; + + /** + * @var \Magento\Catalog\Model\Resource\Product\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $collection; + + /** + * @var \Magento\Catalog\Model\Layer\ItemCollectionProviderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $collectionProvider; + + /** + * @var \Magento\Catalog\Model\Layer\Filter\Item|\PHPUnit_Framework_MockObject_MockObject + */ + private $filter; + + /** + * @var \Magento\Catalog\Model\Layer\Filter\AbstractFilter|\PHPUnit_Framework_MockObject_MockObject + */ + private $abstractFilter; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->category = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->setMethods(['load', 'getId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->categoryFactory = $this->getMockBuilder('Magento\Catalog\Model\CategoryFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->categoryFactory->expects($this->any())->method('create') + ->will($this->returnValue($this->category)); + + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->setMethods(['registry']) + ->disableOriginalConstructor() + ->getMock(); + + $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + ->setMethods(['getRootCategoryId', 'getFilters', '__wakeup']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + ->setMethods(['getStore']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->storeManager->expects($this->any())->method('getStore') + ->will($this->returnValue($this->store)); + + $this->stateKeyGenerator = $this->getMockBuilder('Magento\Catalog\Model\Layer\Category\StateKey') + ->setMethods(['toString']) + ->disableOriginalConstructor() + ->getMock(); + + $this->collectionFilter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Category\CollectionFilter') + ->setMethods(['filter']) + ->disableOriginalConstructor() + ->getMock(); + + $this->collectionProvider = $this->getMockBuilder('Magento\Catalog\Model\Layer\ItemCollectionProviderInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->filter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Filter\Item') + ->setMethods(['getFilter', 'getValueString']) + ->disableOriginalConstructor() + ->getMock(); + + $this->abstractFilter = $this->getMockBuilder('Magento\Catalog\Model\Layer\Filter\AbstractFilter') + ->setMethods(['getRequestVar']) + ->disableOriginalConstructor() + ->getMock(); + + $this->context = $this->getMockBuilder('Magento\Catalog\Model\Layer\ContextInterface') + ->setMethods(['getStateKey', 'getCollectionFilter']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->context->expects($this->any())->method('getStateKey') + ->will($this->returnValue($this->stateKeyGenerator)); + $this->context->expects($this->any())->method('getCollectionFilter') + ->will($this->returnValue($this->collectionFilter)); + $this->context->expects($this->any())->method('getCollectionProvider') + ->will($this->returnValue($this->collectionProvider)); + + $this->state = $this->getMockBuilder('Magento\Catalog\Model\Layer\State') + ->disableOriginalConstructor() + ->getMock(); + + $this->stateFactory = $this->getMockBuilder('Magento\Catalog\Model\Layer\StateFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->stateFactory->expects($this->any())->method('create')->will($this->returnValue($this->state)); + + $this->collection = $this->getMockBuilder('Magento\Catalog\Model\Resource\Product\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $helper->getObject( + 'Magento\Catalog\Model\Layer', + [ + 'registry' => $this->registry, + 'categoryFactory' => $this->categoryFactory, + 'storeManager' => $this->storeManager, + 'context' => $this->context, + 'layerStateFactory' => $this->stateFactory + ] + ); + } + + public function testGetState() + { + $this->assertInstanceOf('\Magento\Catalog\Model\Layer\State', $this->model->getState()); + } + + public function testGetStateKey() + { + $stateKey = 'sk'; + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($this->category)); + + $this->stateKeyGenerator->expects($this->once())->method('toString') + ->with($this->equalTo($this->category)) + ->will($this->returnValue($stateKey)); + + $this->assertEquals($stateKey, $this->model->getStateKey()); + } + + public function testGetProductCollection() + { + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($this->category)); + + $this->category->expects($this->any())->method('getId')->will($this->returnValue(333)); + + $this->collectionFilter->expects($this->once())->method('filter') + ->with($this->equalTo($this->collection), $this->equalTo($this->category)); + + $this->collectionProvider->expects($this->once())->method('getCollection') + ->with($this->equalTo($this->category)) + ->will($this->returnValue($this->collection)); + + $result = $this->model->getProductCollection(); + $this->assertInstanceOf('\Magento\Catalog\Model\Resource\Product\Collection', $result); + $result = $this->model->getProductCollection(); + $this->assertInstanceOf('\Magento\Catalog\Model\Resource\Product\Collection', $result); + } + + public function testApply() + { + $stateKey = 'sk'; + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($this->category)); + + $this->stateKeyGenerator->expects($this->once())->method('toString') + ->with($this->equalTo($this->category)) + ->will($this->returnValue($stateKey)); + + $this->state->expects($this->any())->method('getFilters')->will($this->returnValue([$this->filter])); + + $this->filter->expects($this->once())->method('getFilter')->will($this->returnValue($this->abstractFilter)); + $this->filter->expects($this->once())->method('getValueString')->will($this->returnValue('t')); + + $this->abstractFilter->expects($this->once())->method('getRequestVar')->will($this->returnValue('t')); + + $result = $this->model->apply(); + $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $result); + } + + public function testPrepareProductCollection() + { + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($this->category)); + + $this->collectionFilter->expects($this->once())->method('filter') + ->with($this->equalTo($this->collection), $this->equalTo($this->category)); + + $result = $this->model->prepareProductCollection($this->collection); + $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $result); + } + + public function testGetCurrentStore() + { + $this->assertInstanceOf('\Magento\Store\Model\Store', $this->model->getCurrentStore()); + } + + public function testSetCurrentCategory() + { + $categoryId = 333; + + $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId)) + ->will($this->returnValue($this->category)); + $this->category->expects($this->at(0))->method('getId')->will($this->returnValue($categoryId)); + $this->category->expects($this->at(1))->method('getId')->will($this->returnValue($categoryId)); + $this->category->expects($this->at(2))->method('getId')->will($this->returnValue($categoryId - 1)); + + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($this->category)); + + $result = $this->model->setCurrentCategory($categoryId); + $this->assertInstanceOf('\Magento\Catalog\Model\Layer', $result); + } + + /** + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage The category must be an instance of \Magento\Catalog\Model\Category. + */ + public function testSetCurrentCategoryInstanceOfException() + { + $this->model->setCurrentCategory(null); + } + + /** + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Please correct the category. + */ + public function testSetCurrentCategoryNotFoundException() + { + $this->category->expects($this->at(0))->method('getId')->will($this->returnValue(null)); + + $this->model->setCurrentCategory($this->category); + } + + /** + * @dataProvider currentCategoryProvider + */ + public function testGetCurrentCategory($currentCategory) + { + $rootCategoryId = 333; + $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category')) + ->will($this->returnValue($currentCategory)); + + $this->category->expects($this->any())->method('load')->with($this->equalTo($rootCategoryId)) + ->will($this->returnValue($this->category)); + + $this->store->expects($this->any())->method('getRootCategoryId') + ->will($this->returnValue($rootCategoryId)); + + $result = $this->model->getCurrentCategory(); + $this->assertInstanceOf('\Magento\Catalog\Model\Category', $result); + } + + public function currentCategoryProvider() + { + $category = $this->getMockBuilder('Magento\Catalog\Model\Category') + ->disableOriginalConstructor() + ->getMock(); + + return [[$category], [null]]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php index d19ffccee4b..fd746b2f5c7 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ProductList/ToolbarTest.php @@ -24,6 +24,8 @@ namespace Magento\Catalog\Model\Product\ProductList; +use Magento\TestFramework\Helper\ObjectManager; + class ToolbarTest extends \PHPUnit_Framework_TestCase { /** @@ -32,23 +34,33 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase protected $toolbarModel; /** - * @var \Magento\Framework\Stdlib\Cookie |\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\CookieManager |\PHPUnit_Framework_MockObject_MockObject */ - protected $cookie; + protected $cookieManagerMock; /** * @var \Magento\Framework\App\Request\Http |\PHPUnit_Framework_MockObject_MockObject */ - protected $request; + protected $requestMock; /** * Set up */ public function setUp() { - $this->cookie = $this->getMock('Magento\Framework\Stdlib\Cookie', array('get'), array(), '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', array('getParam'), array(), '', false); - $this->toolbarModel = new Toolbar($this->cookie, $this->request); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor() + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->toolbarModel = (new ObjectManager($this))->getObject( + 'Magento\Catalog\Model\Product\ProductList\Toolbar', + [ + 'cookieManager' => $this->cookieManagerMock, + 'request' => $this->requestMock, + ] + ); } /** @@ -57,8 +69,8 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ public function testGetOrder($param) { - $this->cookie->expects($this->once()) - ->method('get') + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') ->with(Toolbar::ORDER_COOKIE_NAME) ->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getOrder()); @@ -70,8 +82,8 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ public function testGetDirection($param) { - $this->cookie->expects($this->once()) - ->method('get') + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') ->with(Toolbar::DIRECTION_COOKIE_NAME) ->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getDirection()); @@ -83,8 +95,8 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ public function testGetMode($param) { - $this->cookie->expects($this->once()) - ->method('get') + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') ->with(Toolbar::MODE_COOKIE_NAME) ->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getMode()); @@ -96,8 +108,8 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ public function testGetLimit($param) { - $this->cookie->expects($this->once()) - ->method('get') + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') ->with(Toolbar::LIMIT_COOKIE_NAME) ->will($this->returnValue($param)); $this->assertEquals($param, $this->toolbarModel->getLimit()); @@ -109,7 +121,7 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase */ public function testGetCurrentPage($param) { - $this->request->expects($this->once()) + $this->requestMock->expects($this->once()) ->method('getParam') ->with(Toolbar::PAGE_PARM_NAME) ->will($this->returnValue($param)); @@ -118,7 +130,7 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase public function testGetCurrentPageNoParam() { - $this->request->expects($this->once()) + $this->requestMock->expects($this->once()) ->method('getParam') ->with(Toolbar::PAGE_PARM_NAME) ->will($this->returnValue(false)); @@ -127,17 +139,17 @@ class ToolbarTest extends \PHPUnit_Framework_TestCase public function stringParamProvider() { - return array( - array('stringParam') - ); + return [ + ['stringParam'] + ]; } public function intParamProvider() { - return array( - array('2'), - array(3) - ); + return [ + ['2'], + [3] + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceTest.php index 5d173eb2e4c..54f0b44f91f 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceTest.php @@ -113,7 +113,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue([$productId => $productObject])); $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId)); - $this->category->expects($this->once())->method('getId')->will($this->returnValue(true)); + $this->category->expects($this->once())->method('getId')->will($this->returnValue(333)); $this->category->expects($this->once())->method('getProductsPosition') ->will($this->returnValue([$productId => $productPosition])); $this->category->expects($this->once())->method('getProductCollection') @@ -130,4 +130,30 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals([$productDto], $this->model->assignedProducts($categoryId)); } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testGetCategoryNoSuchEntityException() + { + $categoryId = 3; + $productId = $categoryId + 6; + + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $productObject */ + $productObject = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Framework\Data\Collection\Db|\PHPUnit_Framework_MockObject_MockObject $productCollection */ + $productCollection = $this->getMockBuilder('Magento\Framework\Data\Collection\Db') + ->disableOriginalConstructor() + ->getMock(); + $productCollection->expects($this->any())->method('getItems') + ->will($this->returnValue([$productId => $productObject])); + + $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId)); + $this->category->expects($this->once())->method('getId')->will($this->returnValue(0)); + + $this->model->assignedProducts($categoryId); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/WriteServiceTest.php index 7668158e810..dc75ffd48b7 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/WriteServiceTest.php @@ -103,7 +103,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $storeManager = $this->getMock('Magento\Store\Model\StoreManager', [], [], '', false); $store = $this->getMock( 'Magento\Store\Model\Store', - ['getRootCategoryId', '__sleep', '__wakeup'], [], '', false + ['getRootCategoryId', '__sleep', '__wakeup'], + [], + '', + false ); $store->expects($this->any())->method('getRootCategoryId')->will($this->returnValue($parentId)); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/MapperTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/MapperTest.php index 9382a19bdf2..229cbf74d68 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/MapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/MapperTest.php @@ -38,7 +38,8 @@ class MapperTest extends \PHPUnit_Framework_TestCase public function testToModel() { $categoryFactory = $this->getMock('Magento\Catalog\Model\CategoryFactory', ['create'], [], '', false); - $categoryMapper = $this->objectManagerHelper->getObject('Magento\Catalog\Service\V1\Data\Category\Mapper', + $categoryMapper = $this->objectManagerHelper->getObject( + 'Magento\Catalog\Service\V1\Data\Category\Mapper', [ 'categoryFactory' => $categoryFactory ] @@ -46,18 +47,23 @@ class MapperTest extends \PHPUnit_Framework_TestCase $categoryModel = $this->getMock( 'Magento\Catalog\Model\Category', - ['setPath', 'getDefaultAttributeSetId', '__sleep', '__wakeup'], [], '', false + ['setPath', 'getDefaultAttributeSetId', '__sleep', '__wakeup'], + [], + '', + false ); $categoryFactory->expects($this->at(0))->method('create')->will($this->returnValue($categoryModel)); $categoryObj = $this->getMock('Magento\Catalog\Service\V1\Data\Category', [], [], '', false); $categoryObj->expects($this->any())->method('__toArray') - ->will($this->returnValue( - [ - 'test_code' => 'test_value', - ] - )); + ->will( + $this->returnValue( + [ + 'test_code' => 'test_value', + ] + ) + ); $this->assertEquals($categoryModel, $categoryMapper->toModel($categoryObj)); } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductMapperTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductMapperTest.php index f35c932d4f2..0aa5e5ed0fc 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductMapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductMapperTest.php @@ -54,9 +54,8 @@ class ProductMapperTest extends \PHPUnit_Framework_TestCase $product = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') ->disableOriginalConstructor() ->getMock(); - $product->expects($this->once())->method('__toArray')->will($this->returnValue([ - 'test_code' => 'test_value', - ])); + $product->expects($this->once())->method('__toArray') + ->will($this->returnValue(['test_code' => 'test_value'])); /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $productModel */ $productModel = $this->getMockBuilder('Magento\Catalog\Model\Product') @@ -66,6 +65,48 @@ class ProductMapperTest extends \PHPUnit_Framework_TestCase $productFactory->expects($this->once())->method('create')->will($this->returnValue($productModel)); $this->assertEquals($productModel, $productMapper->toModel($product)); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Illegal product type + */ + public function testToModelRuntimeException() + { + $productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Catalog\Service\V1\Data\ProductMapper $productMapper */ + $productMapper = $this->objectManagerHelper->getObject( + 'Magento\Catalog\Service\V1\Data\ProductMapper', + ['productFactory' => $productFactory] + ); + + $product = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $product->expects($this->once())->method('__toArray') + ->will($this->returnValue(['test_code' => 'test_value'])); + + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $productModel */ + $productModel = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['hasTypeId', 'getTypeId', 'getDefaultAttributeSetId', 'setAttributeSetId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $productModel->expects($this->once())->method('hasTypeId') + ->will($this->returnValue(true)); + $productModel->expects($this->once())->method('getTypeId') + ->will($this->returnValue(333)); + $productModel->expects($this->once())->method('getDefaultAttributeSetId') + ->will($this->returnValue(333)); + $productModel->expects($this->once())->method('setAttributeSetId') + ->with($this->equalTo(333)); + + $productFactory->expects($this->once())->method('create')->will($this->returnValue($productModel)); + $productMapper->toModel($product); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/MetadataServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/MetadataServiceTest.php index e36b4859be1..f5d9ba5d807 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/MetadataServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/MetadataServiceTest.php @@ -25,62 +25,152 @@ namespace Magento\Catalog\Service\V1; class MetadataServiceTest extends \PHPUnit_Framework_TestCase { + /** @var \Magento\Eav\Model\Resource\Entity\Attribute\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ + private $attributeCollectionFactory; + /** @var \Magento\Eav\Model\Resource\Entity\Attribute\Collection|\PHPUnit_Framework_MockObject_MockObject */ + private $attributeCollection; + /** @var \Magento\Catalog\Service\V1\Data\Eav\AttributeMetadataBuilder */ + private $attributeMetadataBuilder; + /** @var \Magento\Catalog\Service\V1\Data\Eav\Product\Attribute\FrontendLabelBuilder */ + private $frontendLabelBuilder; + /** @var \Magento\Catalog\Service\V1\Data\Eav\OptionBuilder */ + private $optionBuilder; + /** @var \Magento\Catalog\Service\V1\Data\Eav\ValidationRuleBuilder */ + private $validationRuleBuilder; + /** @var \Magento\TestFramework\Helper\ObjectManager */ + private $objectManager; + /** @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ + private $eavConfigMock; + /** @var \Magento\Catalog\Service\V1\MetadataService */ + private $service; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', array('getAttribute'), array(), '', false); + $this->validationRuleBuilder = $this->objectManager->getObject( + '\Magento\Catalog\Service\V1\Data\Eav\ValidationRuleBuilder' + ); + $this->optionBuilder = $this->objectManager->getObject('\Magento\Catalog\Service\V1\Data\Eav\OptionBuilder'); + $this->frontendLabelBuilder = $this->objectManager->getObject( + '\Magento\Catalog\Service\V1\Data\Eav\Product\Attribute\FrontendLabelBuilder' + ); + /** @var \Magento\Catalog\Service\V1\Data\Eav\AttributeMetadataBuilder $attrMetadataBuilder */ + $this->attributeMetadataBuilder = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Data\Eav\AttributeMetadataBuilder', + [ + 'optionBuilder' => $this->optionBuilder, + 'validationRuleBuilder' => $this->validationRuleBuilder, + 'frontendLabelBuilder' => $this->frontendLabelBuilder, + ] + ); + + $this->attributeCollectionFactory = $this->getMockBuilder( + 'Magento\Eav\Model\Resource\Entity\Attribute\CollectionFactory' + ) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->attributeCollection = $this->getMockBuilder('Magento\Eav\Model\Resource\Entity\Attribute\Collection') + ->disableOriginalConstructor() + ->setMethods( + ['__wakeup', 'getTable', 'join', 'addFieldToFilter', 'addAttributeGrouping', 'getSize', 'getIterator'] + ) + ->getMock(); + + $this->service = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\MetadataService', + array( + 'eavConfig' => $this->eavConfigMock, + 'attributeMetadataBuilder' => $this->attributeMetadataBuilder, + 'attributeCollectionFactory' => $this->attributeCollectionFactory, + ) + ); + } + /** * Test getAttributeMetadata */ public function testGetAttributeMetadata() { - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $data = array( + $data = [ 'attribute_id' => 1, 'attribute_code' => 'description', 'frontend_label' => 'English', 'store_labels' => array(1 => 'France'), 'frontend_input' => 'textarea', - ); + ]; - //attributeMock $attributeMock = $this->getMock( 'Magento\Framework\Object', - array('usesSource', 'getSource', 'isScopeGlobal'), + array('usesSource', 'getSource', 'isScopeGlobal', 'getId'), array('data' => $data) ); + $attributeMock->expects($this->once())->method('getId')->will($this->returnValue($data['attribute_id'])); $attributeMock->expects($this->any())->method('isScopeGlobal')->will($this->returnValue(true)); $attributeMock->expects($this->any())->method('usesSource')->will($this->returnValue(true)); $attributeMock->expects($this->any())->method('getSource') ->will($this->returnValue(new \Magento\Framework\Object())); - // eavConfigMock - $eavConfigMock = $this->getMock('Magento\Eav\Model\Config', array('getAttribute'), array(), '', false); - $eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock)); + $this->eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock)); - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $validationRuleBuilder = $helper->getObject('\Magento\Catalog\Service\V1\Data\Eav\ValidationRuleBuilder'); - $optionBuilder = $helper->getObject('\Magento\Catalog\Service\V1\Data\Eav\OptionBuilder'); - $frontendLabelBuilder = $helper - ->getObject('\Magento\Catalog\Service\V1\Data\Eav\Product\Attribute\FrontendLabelBuilder'); - /** @var \Magento\Catalog\Service\V1\Data\Eav\AttributeMetadataBuilder $attrMetadataBuilder */ - $attrMetadataBuilder = $objectManager->getObject( - 'Magento\Catalog\Service\V1\Data\Eav\AttributeMetadataBuilder', - [ - 'optionBuilder' => $optionBuilder, - 'validationRuleBuilder' => $validationRuleBuilder, - 'frontendLabelBuilder' => $frontendLabelBuilder, - ] - ); + $dto = $this->service->getAttributeMetadata('entity_type', 'attr_code'); + $this->assertInstanceOf('Magento\Framework\Service\Data\AbstractObject', $dto); + $this->assertEquals($attributeMock->getFrontendInput(), $dto->getFrontendInput()); - // create service - /** @var \Magento\Catalog\Service\V1\MetadataService $service */ - $service = $objectManager->getObject('Magento\Catalog\Service\V1\MetadataService', - array( - 'eavConfig' => $eavConfigMock, - 'attributeMetadataBuilder' - => $attrMetadataBuilder - ) + $this->assertEquals(0, $dto->getFrontendLabel()[0]->getStoreId()); + $this->assertEquals(1, $dto->getFrontendLabel()[1]->getStoreId()); + $this->assertEquals('English', $dto->getFrontendLabel()[0]->getLabel()); + $this->assertEquals('France', $dto->getFrontendLabel()[1]->getLabel()); + } + + /** + * Test getAllAttributeMetadata + */ + public function testGetAllAttributeMetadata() + { + $data = [ + 'attribute_id' => 1, + 'attribute_code' => 'description', + 'frontend_label' => 'English', + 'store_labels' => array(1 => 'France'), + 'frontend_input' => 'textarea', + ]; + + $attributeMock = $this->getMock( + 'Magento\Framework\Object', + array('usesSource', 'getSource', 'isScopeGlobal', 'getId'), + array('data' => $data) ); + $attributeMock->expects($this->once())->method('getId')->will($this->returnValue($data['attribute_id'])); + $attributeMock->expects($this->any())->method('isScopeGlobal')->will($this->returnValue(true)); + $attributeMock->expects($this->any())->method('usesSource')->will($this->returnValue(true)); + $attributeMock->expects($this->any())->method('getSource') + ->will($this->returnValue(new \Magento\Framework\Object())); + $this->eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock)); + + $this->attributeCollectionFactory + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->attributeCollection)); - $dto = $service->getAttributeMetadata('entity_type', 'attr_code'); + $searchCriteria = $this->getMockBuilder('\Magento\Framework\Service\V1\Data\SearchCriteria') + ->disableOriginalConstructor() + ->setMethods(['getFilterGroups']) + ->getMock(); + $searchCriteria->expects($this->once()) + ->method('getFilterGroups') + ->will($this->returnValue(array())); + $this->attributeCollection->expects($this->once()) + ->method('getSize') + ->will($this->returnValue(1)); + $this->attributeCollection->expects($this->once()) + ->method('getIterator') + ->will($this->returnValue(new \ArrayIterator(array($attributeMock)))); + /** @var \Magento\Catalog\Service\V1\Data\Product\Attribute\SearchResults $searchResult */ + $searchResult = $this->service->getAllAttributeMetadata('entity_type', $searchCriteria); + $dto = $searchResult->getItems()[0]; $this->assertInstanceOf('Magento\Framework\Service\Data\AbstractObject', $dto); $this->assertEquals($attributeMock->getFrontendInput(), $dto->getFrontendInput()); @@ -89,4 +179,33 @@ class MetadataServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals('English', $dto->getFrontendLabel()[0]->getLabel()); $this->assertEquals('France', $dto->getFrontendLabel()[1]->getLabel()); } + + /** + * Test NoSuchEntityException getAttributeMetadata + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage No such entity with attributeCode = attr_code + */ + public function testGetAttributeMetadataNoSuchEntityException() + { + $data = [ + 'attribute_id' => 1, + 'attribute_code' => 'description', + 'frontend_label' => 'English', + 'store_labels' => array(1 => 'France'), + 'frontend_input' => 'textarea', + ]; + + $attributeMock = $this->getMock( + 'Magento\Framework\Object', + array('getId'), + array('data' => $data) + ); + + $this->eavConfigMock->expects($this->once())->method('getAttribute')->will($this->returnValue($attributeMock)); + $attributeMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + + $this->service->getAttributeMetadata('entity_type', 'attr_code'); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php index 20f35475e10..f65de7c8249 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -76,20 +75,36 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->repositoryMock = $this->getMock( - '\Magento\Catalog\Model\ProductRepository', array(), array(), '', false + '\Magento\Catalog\Model\ProductRepository', + array(), + array(), + '', + false ); $this->priceBuilderMock = $this->getMock( - 'Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', array(), array(), '', false + 'Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', + array(), + array(), + '', + false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + ->setMethods(['getWebsite']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->groupServiceMock = $this->getMock('\Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->priceModifierMock = $this->getMock('Magento\Catalog\Model\Product\PriceModifier', array(), array(), '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array('getId', '__wakeup'), array(), '', false); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', - array('getData', 'setData', 'validate', 'save', 'getIdBySku', 'load', '__wakeup'), array(), '', false); + $this->productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + array('getData', 'setData', 'validate', 'save', 'getIdBySku', 'load', '__wakeup'), + array(), + '', + false + ); $this->repositoryMock->expects($this->any())->method('get')->with('product_sku') ->will($this->returnValue($this->productMock)); $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); @@ -105,7 +120,7 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase /** * @param string $configValue - * @param array $groupData + * @param array $groupData * @param array $expected * @dataProvider getListDataProvider */ @@ -202,15 +217,27 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetNewPriceWithGlobalPriceScope() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'customer_group_id' => 1, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'customer_group_id' => 1, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\GroupPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -224,6 +251,10 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getValue') ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) + ->will($this->returnValue(1)); + $this->storeManagerMock->expects($this->once())->method('getWebsite') + ->will($this->returnValue($this->websiteMock)); + $this->websiteMock->expects($this->once())->method('getId') ->will($this->returnValue(0)); $this->productMock->expects($this->once())->method('setData')->with( @@ -240,15 +271,27 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetUpdatedPriceWithGlobalPriceScope() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'customer_group_id' => 2, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'customer_group_id' => 2, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\GroupPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -281,15 +324,27 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetThrowsExceptionIfDoesntValidate() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', + array(), + array(), + '', + false ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( 'customer_group_id' => 2, 'value' => 100 - ))); + ) + ) + ); $price = new \Magento\Catalog\Service\V1\Data\Product\GroupPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -300,9 +355,11 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array())); $this->groupServiceMock->expects($this->once())->method('getGroup')->will($this->returnValue($group)); - $this->productMock->expects($this->once())->method('validate')->will($this->returnValue( - array('attr1' => '', 'attr2' => '') - )); + $this->productMock->expects($this->once())->method('validate')->will( + $this->returnValue( + array('attr1' => '', 'attr2' => '') + ) + ); $this->productMock->expects($this->never())->method('save'); $this->service->set('product_sku', $price); } @@ -313,15 +370,27 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetThrowsExceptionIfCantSave() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\GroupPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'customer_group_id' => 2, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'customer_group_id' => 2, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\GroupPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/MetadataServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/MetadataServiceTest.php new file mode 100644 index 00000000000..0cd0e88c706 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/MetadataServiceTest.php @@ -0,0 +1,162 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Catalog\Service\V1\Product; + +use Magento\TestFramework\Helper\ObjectManager; + +class MetadataServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Service\V1\Product\MetadataService + */ + private $service; + + /** + * @var \Magento\Catalog\Service\V1\MetadataService|\PHPUnit_Framework_MockObject_MockObject + */ + private $metadataService; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $searchCriteriaBuilder; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterBuilder; + + /** + * @var \Magento\Framework\Service\V1\Data\Filter|\PHPUnit_Framework_MockObject_MockObject + */ + private $filter; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + private $searchCriteria; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchResults|\PHPUnit_Framework_MockObject_MockObject + */ + private $searchResult; + + /** + * @var \Magento\Framework\Service\Config\MetadataConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $metadataConfig; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->metadataConfig = $this->getMockBuilder('Magento\Framework\Service\Config\MetadataConfig') + ->setMethods(['getCustomAttributesMetadata']) + ->disableOriginalConstructor() + ->getMock(); + + $this->metadataService = $this->getMockBuilder('Magento\Catalog\Service\V1\MetadataService') + ->setMethods(['getAllAttributeMetadata']) + ->disableOriginalConstructor() + ->getMock(); + + $this->searchCriteriaBuilder = $this->getMockBuilder('Magento\Framework\Service\V1\Data\SearchCriteriaBuilder') + ->setMethods(['addFilter', 'create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Service\V1\Data\FilterBuilder') + ->setMethods(['setField', 'setValue', 'create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->filter = $this->getMockBuilder('Magento\Framework\Service\V1\Data\Filter') + ->disableOriginalConstructor() + ->getMock(); + + $this->searchCriteria = $this->getMockBuilder('Magento\Framework\Service\V1\Data\SearchCriteria') + ->disableOriginalConstructor() + ->getMock(); + + $this->searchResult = $this->getMockBuilder('Magento\Framework\Service\V1\Data\SearchResults') + ->setMethods(['getItems']) + ->disableOriginalConstructor() + ->getMock(); + + $this->service = $helper->getObject( + 'Magento\Catalog\Service\V1\Product\MetadataService', + [ + 'metadataService' => $this->metadataService, + 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, + 'filterBuilder' => $this->filterBuilder, + 'metadataConfig' => $this->metadataConfig + ] + ); + } + + public function testGetCustomAttributesMetadata() + { + $this->getProductAttributesMetadata(MetadataServiceInterface::DEFAULT_ATTRIBUTE_SET_ID); + + $this->metadataConfig->expects($this->once())->method('getCustomAttributesMetadata') + ->with($this->equalTo(MetadataServiceInterface::DEFAULT_ATTRIBUTE_SET_ID)) + ->will($this->returnValue([])); + + $result = $this->service->getCustomAttributesMetadata(MetadataServiceInterface::DEFAULT_ATTRIBUTE_SET_ID); + + $this->assertEquals([$this->metadataService], $result); + } + + public function testGetProductAttributesMetadata() + { + $this->getProductAttributesMetadata(MetadataServiceInterface::DEFAULT_ATTRIBUTE_SET_ID); + + $result = $this->service->getProductAttributesMetadata(MetadataServiceInterface::DEFAULT_ATTRIBUTE_SET_ID); + + $this->assertEquals([$this->metadataService], $result); + } + + private function getProductAttributesMetadata($attributeSetId) + { + $this->searchCriteriaBuilder->expects($this->once())->method('addFilter') + ->with($this->equalTo([$this->filter])); + $this->searchCriteriaBuilder->expects($this->once())->method('create') + ->will($this->returnValue($this->searchCriteria)); + + $this->filterBuilder->expects($this->once())->method('setField') + ->with($this->equalTo('attribute_set_id')) + ->will($this->returnValue($this->filterBuilder)); + $this->filterBuilder->expects($this->once())->method('setValue') + ->with($this->equalTo($attributeSetId)) + ->will($this->returnValue($this->filterBuilder)); + $this->filterBuilder->expects($this->once())->method('create') + ->will($this->returnValue($this->filter)); + + $this->metadataService->expects($this->once())->method('getAllAttributeMetadata') + ->with($this->equalTo(MetadataServiceInterface::ENTITY_TYPE), $this->equalTo($this->searchCriteria)) + ->will($this->returnValue($this->searchResult)); + $this->searchResult->expects($this->once())->method('getItems') + ->will($this->returnValue([$this->metadataService])); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php index 476cc986eda..b8e46e76971 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -76,17 +75,30 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->repositoryMock = $this->getMock( - '\Magento\Catalog\Model\ProductRepository', array(), array(), '', false + '\Magento\Catalog\Model\ProductRepository', + array(), + array(), + '', + false ); $this->priceBuilderMock = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false ); $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); $this->groupServiceMock = $this->getMock('\Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array('getId', '__wakeup'), array(), '', false); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', - array('getData', 'getIdBySku', 'load', '__wakeup', 'save', 'validate', 'setData'), array(), '', false); + $this->productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + array('getData', 'getIdBySku', 'load', '__wakeup', 'save', 'validate', 'setData'), + array(), + '', + false + ); $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->priceModifierMock = $this->getMock('Magento\Catalog\Model\Product\PriceModifier', array(), array(), '', false); @@ -214,18 +226,99 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals(true, $this->service->delete('product_sku', 4, 5, 6)); } + public function testSetNewPriceWithGlobalPriceScopeAll() + { + $priceBuilder = $this->getMock( + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'qty' => 3, + 'value' => 100 + ) + ) + ); + $price = new \Magento\Catalog\Service\V1\Data\Product\TierPrice($priceBuilder); + $groupBuilder = $this->getMock( + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false + ); + + $websiteMock = $this->getMockBuilder('Magento\Store\Model\Website') + ->setMethods(['getId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + $websiteMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + + $this->storeManagerMock->expects($this->once())->method('getWebsite')->will($this->returnValue($websiteMock)); + + $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); + $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); + $this->groupServiceMock->expects($this->once())->method('getGroup')->will($this->returnValue($group)); + $this->productMock + ->expects($this->once()) + ->method('getData') + ->with('tier_price') + ->will( + $this->returnValue( + array(array('all_groups' => 0, 'website_id' => 0, 'price_qty' => 4, 'price' => 50)) + ) + ); + $this->configMock + ->expects($this->once()) + ->method('getValue') + ->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE) + ->will($this->returnValue(1)); + + $this->productMock->expects($this->once())->method('setData')->with( + 'tier_price', + array( + array('all_groups' => 0, 'website_id' => 0, 'price_qty' => 4, 'price' => 50), + array( + 'cust_group' => 32000, + 'price' => 100, + 'website_price' => 100, + 'website_id' => 0, + 'price_qty' => 3 + ) + ) + ); + $this->productMock->expects($this->once())->method('save'); + $this->service->set('product_sku', 'all', $price); + } + public function testSetNewPriceWithGlobalPriceScope() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'qty' => 3, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'qty' => 3, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\TierPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -234,9 +327,11 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getData') ->with('tier_price') - ->will($this->returnValue( - array(array('cust_group' => 1, 'website_id' => 0, 'price_qty' => 4, 'price' => 50)) - )); + ->will( + $this->returnValue( + array(array('cust_group' => 1, 'website_id' => 0, 'price_qty' => 4, 'price' => 50)) + ) + ); $this->configMock ->expects($this->once()) ->method('getValue') @@ -257,15 +352,27 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetUpdatedPriceWithGlobalPriceScope() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'qty' => 3, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'qty' => 3, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\TierPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -274,8 +381,10 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getData') ->with('tier_price') - ->will($this->returnValue( - array(array('cust_group' => 1, 'website_id' => 0, 'price_qty' => 3, 'price' => 50))) + ->will( + $this->returnValue( + array(array('cust_group' => 1, 'website_id' => 0, 'price_qty' => 3, 'price' => 50)) + ) ); $this->configMock ->expects($this->once()) @@ -300,15 +409,27 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetThrowsExceptionIfDoesntValidate() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'qty' => 2, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'qty' => 2, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\TierPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); @@ -319,9 +440,11 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array())); $this->groupServiceMock->expects($this->once())->method('getGroup')->will($this->returnValue($group)); - $this->productMock->expects($this->once())->method('validate')->will($this->returnValue( + $this->productMock->expects($this->once())->method('validate')->will( + $this->returnValue( array('attr1' => '', 'attr2' => '') - )); + ) + ); $this->productMock->expects($this->never())->method('save'); $this->service->set('product_sku', 1, $price); } @@ -332,15 +455,27 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase public function testSetThrowsExceptionIfCantSave() { $priceBuilder = $this->getMock( - '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', array(), array(), '', false + '\Magento\Catalog\Service\V1\Data\Product\TierPriceBuilder', + array(), + array(), + '', + false + ); + $priceBuilder->expects($this->any())->method('getData')->will( + $this->returnValue( + array( + 'qty' => 2, + 'value' => 100 + ) + ) ); - $priceBuilder->expects($this->any())->method('getData')->will($this->returnValue(array( - 'qty' => 2, - 'value' => 100 - ))); $price = new \Magento\Catalog\Service\V1\Data\Product\TierPrice($priceBuilder); $groupBuilder = $this->getMock( - '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', array(), array(), '', false + '\Magento\Customer\Service\V1\Data\CustomerGroupBuilder', + array(), + array(), + '', + false ); $groupBuilder->expects($this->any())->method('getData')->will($this->returnValue(array('id' => 1))); $group = new \Magento\Customer\Service\V1\Data\CustomerGroup($groupBuilder); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php index 5a2b458add8..5630dc19d69 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php @@ -101,8 +101,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->searchResultsBuilderMock = $this->getMockBuilder( - 'Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder' - )->disableOriginalConstructor() + 'Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder' + )->disableOriginalConstructor() ->getMock(); $this->metadataServiceMock = $this->getMockBuilder( @@ -151,20 +151,6 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $productService->delete($productSku); } - /** - * @return ProductService - */ - private function _createService() - { - $productService = $this->_objectManager->getObject( - 'Magento\Catalog\Service\V1\ProductService', - [ - 'productLoader' => $this->_productLoaderMock - ] - ); - return $productService; - } - public function testSearch() { $metadata = array(); @@ -250,17 +236,6 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $productService->search($this->_searchBuilder->create()); } - /** - * @param \PHPUnit_Framework_MockObject_MockObject $mock - * @param array $valueMap - */ - private function _mockReturnValue($mock, $valueMap) - { - foreach ($valueMap as $method => $value) { - $mock->expects($this->any())->method($method)->will($this->returnValue($value)); - } - } - public function testGet() { $productId = 100; @@ -347,6 +322,115 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($productSku, $productService->create($product)); } + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Unable to save product + */ + public function testCreateStateException() + { + $initializationHelper = $this + ->getMockBuilder('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper') + ->disableOriginalConstructor() + ->getMock(); + + $productMapper = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductMapper') + ->disableOriginalConstructor() + ->getMock(); + + $productTypeManager = $this + ->getMockBuilder('Magento\Catalog\Model\Product\TypeTransitionManager') + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Catalog\Service\V1\ProductService $productService */ + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'initializationHelper' => $initializationHelper, + 'productMapper' => $productMapper, + 'productTypeManager' => $productTypeManager, + 'productLoader' => $this->_productLoaderMock, + ] + ); + + $productModel = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + $product = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + + $productMapper->expects($this->once())->method('toModel')->with($product) + ->will($this->returnValue($productModel)); + + $initializationHelper->expects($this->once())->method('initialize')->with($productModel); + + $productModel->expects($this->once())->method('validate'); + $productModel->expects($this->once())->method('save'); + + $productModel->expects($this->once())->method('getId')->will($this->returnValue(0)); + + $productService->create($product); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + */ + public function testCreateInputException() + { + $initializationHelper = $this + ->getMockBuilder('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper') + ->disableOriginalConstructor() + ->getMock(); + + $productMapper = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductMapper') + ->disableOriginalConstructor() + ->getMock(); + + $productTypeManager = $this + ->getMockBuilder('Magento\Catalog\Model\Product\TypeTransitionManager') + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Catalog\Service\V1\ProductService $productService */ + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'initializationHelper' => $initializationHelper, + 'productMapper' => $productMapper, + 'productTypeManager' => $productTypeManager, + 'productLoader' => $this->_productLoaderMock, + ] + ); + + $productModel = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + $product = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + + $productMapper->expects($this->once())->method('toModel')->with($product) + ->will($this->returnValue($productModel)); + + $initializationHelper->expects($this->once())->method('initialize')->with($productModel); + + $productModel->expects($this->once())->method('validate'); + $productModel->expects($this->once())->method('save')->will( + $this->returnCallback( + function () { + throw new \Magento\Eav\Model\Entity\Attribute\Exception(); + } + ) + ); + + $productService->create($product); + } + public function testUpdate() { $initializationHelper = $this @@ -405,4 +489,94 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($productSku, $productService->update(5, $product)); } + + /** + * @expectedException \Magento\Framework\Exception\InputException + */ + public function testUpdateInputException() + { + $initializationHelper = $this + ->getMockBuilder('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper') + ->disableOriginalConstructor() + ->getMock(); + + $productMapper = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductMapper') + ->disableOriginalConstructor() + ->getMock(); + + $productTypeManager = $this + ->getMockBuilder('Magento\Catalog\Model\Product\TypeTransitionManager') + ->disableOriginalConstructor() + ->getMock(); + + $productLoader = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductLoader') + ->setMethods(['load']) + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Catalog\Service\V1\ProductService $productService */ + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'initializationHelper' => $initializationHelper, + 'productMapper' => $productMapper, + 'productTypeManager' => $productTypeManager, + 'productLoader' => $productLoader, + ] + ); + + $productModel = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + $product = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $productLoader->expects($this->once())->method('load') + ->will($this->returnValue($productModel)); + + $productMapper->expects($this->once())->method('toModel')->with($product, $productModel) + ->will($this->returnValue($productModel)); + + $initializationHelper->expects($this->once())->method('initialize')->with($productModel); + $productTypeManager->expects($this->once())->method('processProduct')->with($productModel); + + $productModel->expects($this->once())->method('validate'); + $productModel->expects($this->once())->method('save')->will( + $this->returnCallback( + function () { + throw new \Magento\Eav\Model\Entity\Attribute\Exception(); + } + ) + ); + + $productService->update(5, $product); + } + + /** + * @return ProductService + */ + private function _createService() + { + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'productLoader' => $this->_productLoaderMock + ] + ); + return $productService; + } + + /** + * @param \PHPUnit_Framework_MockObject_MockObject $mock + * @param array $valueMap + */ + private function _mockReturnValue($mock, $valueMap) + { + foreach ($valueMap as $method => $value) { + $mock->expects($this->any())->method($method)->will($this->returnValue($value)); + } + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php index 25bbf5ecac2..6bb83f07178 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php @@ -68,6 +68,9 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogInventory\Model\Stock\ItemRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $stockItemRegistry; + /** @var \Magento\CatalogInventory\Service\V1\StockItemService|\PHPUnit_Framework_MockObject_MockObject */ + protected $stockItemService; + protected function setUp() { $this->resource = $this->getMock( @@ -120,6 +123,14 @@ class ItemTest extends \PHPUnit_Framework_TestCase false ); + $this->stockItemService = $this->getMock( + '\Magento\CatalogInventory\Service\V1\StockItemService', + [], + [], + '', + false + ); + $this->objectManagerHelper = new ObjectManagerHelper($this); $this->item = $this->objectManagerHelper->getObject( 'Magento\CatalogInventory\Model\Stock\Item', @@ -131,7 +142,8 @@ class ItemTest extends \PHPUnit_Framework_TestCase 'storeManager' => $this->storeManager, 'productFactory' => $productFactory, 'resource' => $this->resource, - 'stockItemRegistry' => $this->stockItemRegistry + 'stockItemRegistry' => $this->stockItemRegistry, + 'stockItemService' => $this->stockItemService ] ); } @@ -155,6 +167,9 @@ class ItemTest extends \PHPUnit_Framework_TestCase $this->resource->expects($this->once()) ->method('addCommitCallback') ->will($this->returnValue($this->resource)); + $this->stockItemService->expects($this->any()) + ->method('isQty') + ->will($this->returnValue(true)); $this->assertEquals($this->item, $this->item->save()); } diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php index 61357b0d515..d1a843d44b1 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php @@ -23,8 +23,9 @@ */ namespace Magento\CatalogInventory\Service\V1; -use Magento\CatalogInventory\Model\Stock\ItemRegistry; use Magento\Catalog\Model\ProductTypes\ConfigInterface; +use Magento\CatalogInventory\Model\Stock\ItemRegistry; +use Magento\TestFramework\Helper\ObjectManager; /** * Class StockItemTest @@ -74,7 +75,7 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); + $objectManagerHelper = new ObjectManager($this); $this->model = $objectManagerHelper->getObject( 'Magento\CatalogInventory\Service\V1\StockItemService', [ @@ -373,13 +374,11 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); $stockItem->expects($this->any())->method('getData')->will($this->returnValue($stockItemData)); - $this->productLoader->expects($this->any())->method('load')->will($this->returnValueMap([ - [$productSku, $product] - ])); + $this->productLoader->expects($this->any())->method('load') + ->will($this->returnValueMap([[$productSku, $product]])); - $this->stockItemRegistry->expects($this->any())->method('retrieve')->will($this->returnValueMap([ - [$productId, $stockItem] - ])); + $this->stockItemRegistry->expects($this->any())->method('retrieve') + ->will($this->returnValueMap([[$productId, $stockItem]])); $this->stockItemBuilder->expects($this->any()) ->method('create') @@ -421,9 +420,8 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase ->getMock(); // 2. Set fixtures - $this->productLoader->expects($this->any())->method('load')->will($this->returnValueMap([ - [$productSku, $product] - ])); + $this->productLoader->expects($this->any())->method('load') + ->will($this->returnValueMap([[$productSku, $product]])); $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); // 3. Run tested method @@ -492,13 +490,11 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase $stockItem->expects($this->any())->method('save')->will($this->returnSelf()); $stockItem->expects($this->any())->method('getId')->will($this->returnValue($savedStockItemId)); - $this->productLoader->expects($this->any())->method('load')->will($this->returnValueMap([ - [$productSku, $product] - ])); + $this->productLoader->expects($this->any())->method('load') + ->will($this->returnValueMap([[$productSku, $product]])); - $this->stockItemRegistry->expects($this->any())->method('retrieve')->will($this->returnValueMap([ - [$productId, $stockItem] - ])); + $this->stockItemRegistry->expects($this->any())->method('retrieve') + ->will($this->returnValueMap([[$productId, $stockItem]])); $this->stockItemBuilder->expects($this->any()) ->method('create') @@ -561,15 +557,33 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase ->getMock(); // 2. Set fixtures - $this->productLoader->expects($this->any())->method('load')->will($this->returnValueMap([ - [$productSku, $product] - ])); + $this->productLoader->expects($this->any())->method('load') + ->will($this->returnValueMap([[$productSku, $product]])); $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); // 3. Run tested method $this->model->saveStockItemBySku($productSku, $stockItemDetailsDo); } + public function testProcessIsInStock() + { + $stockData = ['product_id' => 333]; + + $stockItemModel = $this->getMockBuilder('Magento\CatalogInventory\Model\Stock\Item') + ->setMethods(['getData', 'setData', 'processIsInStock', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + $this->stockItemRegistry->expects($this->once())->method('retrieve') + ->with($this->equalTo($stockData['product_id'])) + ->will($this->returnValue($stockItemModel)); + + $stockItemModel->expects($this->once())->method('setData')->with($this->equalTo($stockData)); + $stockItemModel->expects($this->once())->method('processIsInStock'); + $stockItemModel->expects($this->once())->method('getData')->will($this->returnValue($stockData)); + + $this->assertEquals($stockData, $this->model->processIsInStock($stockData)); + } + /** * @return array */ diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php index 39e12d61df8..b3c40a76ad5 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php @@ -74,7 +74,7 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface'); $this->requestMock = $this->getMock( '\Magento\Framework\App\RequestInterface', - array( + [ 'getRouteName', 'getControllerName', 'getParam', @@ -82,7 +82,8 @@ class CartTest extends \PHPUnit_Framework_TestCase 'getActionName', 'setModuleName', 'getModuleName', - ) + 'getCookie' + ] ); $contextMock = $this->getMock('\Magento\Framework\App\Helper\Context', [], [], '', false); $contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilderMock)); @@ -116,17 +117,17 @@ class CartTest extends \PHPUnit_Framework_TestCase $quoteItemMock->expects($this->any())->method('getId')->will($this->returnValue($quoteItemId)); $currentUrl = 'http://www.example.com/'; $this->urlBuilderMock->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($currentUrl)); - $params = array( + $params = [ 'id' => $quoteItemId, Action::PARAM_NAME_BASE64_URL => strtr(base64_encode($currentUrl), '+/=', '-_,'), - ); + ]; $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('checkout/cart/delete', $params); $this->helper->getRemoveUrl($quoteItemMock); } public function testGetCartUrl() { - $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('checkout/cart', array()); + $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('checkout/cart', []); $this->helper->getCartUrl(); } @@ -185,7 +186,7 @@ class CartTest extends \PHPUnit_Framework_TestCase $productMock->expects($this->any())->method('getEntityId')->will($this->returnValue($productEntityId)); $productMock->expects($this->any())->method('hasUrlDataObject')->will($this->returnValue(true)); $productMock->expects($this->any())->method('getUrlDataObject') - ->will($this->returnValue(new Object(array('store_id' => $storeId)))); + ->will($this->returnValue(new Object(['store_id' => $storeId]))); $currentUrl = 'http://www.example.com/'; $this->urlBuilderMock->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($currentUrl)); @@ -195,17 +196,17 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->any())->method('getRouteName')->will($this->returnValue('checkout')); $this->requestMock->expects($this->any())->method('getControllerName')->will($this->returnValue('cart')); - $params = array( + $params = [ Action::PARAM_NAME_URL_ENCODED => $currentUrl, 'product' => $productEntityId, 'custom_param' => 'value', '_scope' => $storeId, '_scope_to_url' => true, 'in_cart' => 1, - ); + ]; $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('checkout/cart/add', $params); - $this->helper->getAddUrl($productMock, array('custom_param' => 'value')); + $this->helper->getAddUrl($productMock, ['custom_param' => 'value']); } /** @@ -219,20 +220,20 @@ class CartTest extends \PHPUnit_Framework_TestCase public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); - $coreData = $this->getMock('\Magento\Core\Helper\Data', array(), array(), '', false); + $coreData = $this->getMock('\Magento\Core\Helper\Data', [], [], '', false); $scopeConfig = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface'); - $checkoutCart = $this->getMock('\Magento\Checkout\Model\Cart', array(), array(), '', false); - $checkoutSession = $this->getMock('\Magento\Checkout\Model\Session', array(), array(), '', false); + $checkoutCart = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); + $checkoutSession = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); - $context = $this->getMock('\Magento\Framework\App\Helper\Context', array(), array(), '', false); + $context = $this->getMock('\Magento\Framework\App\Helper\Context', [], [], '', false); $urlBuilder = $this->getMock('Magento\Framework\UrlInterface'); $context->expects($this->once()) ->method('getUrlBuilder') ->will($this->returnValue($urlBuilder)); - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); - $request = $this->getMock('\Magento\Framework\App\Request\Http', array(), array(), '', false); + $item = $this->getMock('Magento\Sales\Model\Quote\Item', [], [], '', false); + $request = $this->getMock('\Magento\Framework\App\Request\Http', [], [], '', false); $context->expects($this->once()) ->method('getRequest') ->will($this->returnValue($request)); @@ -275,21 +276,21 @@ class CartTest extends \PHPUnit_Framework_TestCase $uenc = strtr(base64_encode($url), '+/=', '-_,'); $id = 1; $expectedPostData1 = json_encode( - array( + [ 'action' => $url, - 'data' => array('id' => $id, 'uenc' => $uenc) - ) + 'data' => ['id' => $id, 'uenc' => $uenc] + ] ); $expectedPostData2 = json_encode( - array( + [ 'action' => $url, - 'data' => array('id' => $id) - ) + 'data' => ['id' => $id] + ] ); - return array( - array($id, $url, false, $expectedPostData1), - array($id, $url, true, $expectedPostData2), - ); + return [ + [$id, $url, false, $expectedPostData1], + [$id, $url, true, $expectedPostData2], + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php index 24942c146e4..d5b119bc336 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php @@ -156,7 +156,7 @@ class ExpressRedirectTest extends \PHPUnit_Framework_TestCase $responseMock = $this->getMockBuilder( 'Magento\Framework\App\Response\Http' )->disableOriginalConstructor()->setMethods( - array('setRedirect') + ['setRedirect', '__wakeup'] )->getMock(); $responseMock->expects($this->once())->method('setRedirect')->with($expectedLoginUrl); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 37aab269fdf..93c4e8b2c07 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -116,7 +116,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); $this->requestMock = $this->getMock( 'Magento\Framework\App\RequestInterface', - ['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'] + ['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'] ); $this->addressFactoryMock = $this->getMock('Magento\Customer\Model\AddressFactory'); $this->formFactoryMock = $this->getMock('Magento\Customer\Model\FormFactory'); diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Attribute/LockValidatorTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Attribute/LockValidatorTest.php new file mode 100644 index 00000000000..c7d46959b2c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Attribute/LockValidatorTest.php @@ -0,0 +1,145 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\ConfigurableProduct\Model\Attribute; + +use Magento\TestFramework\Helper\ObjectManager; + +class LockValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\ConfigurableProduct\Model\Attribute\LockValidator + */ + private $model; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + private $select; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection', 'getTableName']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['select', 'fetchOne']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods(['reset', 'from', 'join', 'where', 'group', 'limit']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $helper->getObject( + 'Magento\ConfigurableProduct\Model\Attribute\LockValidator', + ['resource' => $this->resource] + ); + } + + public function testValidate() + { + $this->validate(false); + } + + /** + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage This attribute is used in configurable products. + */ + public function testValidateException() + { + $this->validate(true); + } + + public function validate($exception) + { + $attrTable = 'someAttributeTable'; + $productTable = 'someProductTable'; + $attributeId = 333; + $attributeSet = 'attrSet'; + + $bind = ['attribute_id' => $attributeId, 'attribute_set_id' => $attributeSet]; + + /** @var \Magento\Framework\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject $object */ + $object = $this->getMockBuilder('Magento\Framework\Model\AbstractModel') + ->setMethods(['getAttributeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + $object->expects($this->once())->method('getAttributeId')->will($this->returnValue($attributeId)); + + $this->resource->expects($this->once())->method('getConnection')->with($this->equalTo('read')) + ->will($this->returnValue($this->adapter)); + $this->resource->expects($this->at(1))->method('getTableName') + ->with($this->equalTo('catalog_product_super_attribute')) + ->will($this->returnValue($attrTable)); + $this->resource->expects($this->at(2))->method('getTableName') + ->with($this->equalTo('catalog_product_entity')) + ->will($this->returnValue($productTable)); + + $this->adapter->expects($this->once())->method('select') + ->will($this->returnValue($this->select)); + $this->adapter->expects($this->once())->method('fetchOne') + ->with($this->equalTo($this->select), $this->equalTo($bind)) + ->will($this->returnValue($exception)); + + $this->select->expects($this->once())->method('reset') + ->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('from') + ->with( + $this->equalTo(['main_table' => $attrTable]), + $this->equalTo(['psa_count' => 'COUNT(product_super_attribute_id)']) + ) + ->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('join') + ->with( + $this->equalTo(['entity' => $productTable]), + $this->equalTo('main_table.product_id = entity.entity_id') + ) + ->will($this->returnValue($this->select)); + $this->select->expects($this->any())->method('where') + ->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('group') + ->with($this->equalTo('main_table.attribute_id')) + ->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('limit') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->select)); + + $this->model->validate($object, $attributeSet); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php new file mode 100644 index 00000000000..ed5d9fd5a95 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper; + +use Magento\Eav\Model\Entity\Attribute; +use Magento\TestFramework\Helper\ObjectManager; + +class PluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin + */ + private $model; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + private $registry; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $attributeFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $attribute; + + /** + * @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject + */ + private $magentoObject; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->setMethods(['registry']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeFactory = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\AttributeFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attribute = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute' + ) + ->setMethods(['getUsedAttributes', 'getAttributeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->magentoObject = $this->getMockBuilder('Magento\Framework\Object') + ->setMethods(['getId']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $helper->getObject( + 'Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin', + ['registry' => $this->registry, 'attributeFactory' => $this->attributeFactory] + ); + } + + public function testAroundMap() + { + $attrSetId = 333; + $expected = ['is_configurable' => 1]; + + /** @var \PHPUnit_Framework_MockObject_MockObject $attributeMapper */ + $attributeMapper = $this->getMockBuilder( + 'Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface' + ) + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Eav\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */ + $attribute = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute') + ->disableOriginalConstructor() + ->getMock(); + + $proceed = function (Attribute $attribute) { + return []; + }; + + $this->attributeFactory->expects($this->once())->method('create') + ->will($this->returnValue($this->attribute)); + + $this->attribute->expects($this->once())->method('getUsedAttributes') + ->with($this->equalTo($attrSetId)) + ->will($this->returnValue([$attrSetId])); + + $attribute->expects($this->once())->method('getAttributeId') + ->will($this->returnValue($attrSetId)); + + $this->registry->expects($this->once())->method('registry') + ->with($this->equalTo('current_attribute_set')) + ->will($this->returnValue($this->magentoObject)); + + $this->magentoObject->expects($this->once())->method('getId')->will($this->returnValue($attrSetId)); + + $result = $this->model->aroundMap($attributeMapper, $proceed, $attribute); + $this->assertEquals($expected, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php index 4595b470f15..d2cca1b00f3 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php @@ -83,7 +83,7 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->option = $this->getMockBuilder('Magento\ConfigurableProduct\Service\V1\Data\Option') - ->setMethods(['__toArray', 'getValues']) + ->setMethods(['__toArray', 'getValues', 'getAttributeId', 'getPosition', 'isUseDefault', 'getLabel']) ->disableOriginalConstructor() ->getMock(); @@ -158,6 +158,36 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase $this->assertEquals(true, $value->isPercent()); } + public function testConvertArrayFromData() + { + $values = [$this->value]; + $expected = [ + 'attribute_id' => 3, + 'position' => 333, + 'use_default' => true, + 'label' => 'someLabel', + 'values' => $values + ]; + + $this->option->expects($this->any())->method('getValues')->will($this->returnValue($values)); + $this->option->expects($this->once())->method('getAttributeId') + ->will($this->returnValue($expected['attribute_id'])); + $this->option->expects($this->once())->method('getPosition') + ->will($this->returnValue($expected['position'])); + $this->option->expects($this->once())->method('isUseDefault') + ->will($this->returnValue($expected['use_default'])); + $this->option->expects($this->once())->method('getLabel') + ->will($this->returnValue($expected['label'])); + + $this->valueConverter->expects($this->once())->method('convertArrayFromData') + ->with($this->equalTo($values[0])) + ->will($this->returnValue($values[0])); + + $result = $this->converter->convertArrayFromData($this->option); + + $this->assertEquals($expected, $result); + } + public function testGetModelFromData() { $data = ['data']; diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Link/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Link/WriteServiceTest.php index e2c582fbba3..aac4ec37fb3 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Link/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Link/WriteServiceTest.php @@ -186,4 +186,41 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->assertTrue(true, $this->service->addChild($productSku, $childSku)); } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Product has been already attached + */ + public function testAddChildStateException() + { + $productSku = 'configurable-sku'; + $childSku = 'simple-sku'; + + $configurable = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + $configurable->expects($this->any())->method('getId')->will($this->returnValue(666)); + + $simplee = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + + $simplee->expects($this->any())->method('getId')->will($this->returnValue(1)); + + $this->productRepository->expects($this->at(0))->method('get')->with($productSku)->will( + $this->returnValue($configurable) + ); + + $this->productRepository->expects($this->at(1))->method('get')->with($childSku)->will( + $this->returnValue($simplee) + ); + + $this->configurableType->expects($this->once())->method('getChildrenIds')->with(666) + ->will( + $this->returnValue([0 => [1, 2, 3]]) + ); + + $this->assertTrue(true, $this->service->addChild($productSku, $childSku)); + } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php index 4d73a7f4038..acc5b6256d4 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php @@ -25,16 +25,15 @@ namespace Magento\ConfigurableProduct\Service\V1\Product\Option; use Magento\Catalog\Model\Product\Type as ProductType; use Magento\Catalog\Model\ProductRepository; -use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; use Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory as ConfigurableAttributeFactory; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; use Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection; use Magento\ConfigurableProduct\Service\V1\Data\Option; use Magento\TestFramework\Helper\ObjectManager; /** * Class WriteServiceTest - * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class WriteServiceTest extends \PHPUnit_Framework_TestCase @@ -216,6 +215,144 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->writeService->add($productSku, $option); } + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testAddLoadNewOptionCouldNotSaveException() + { + $productSku = 'test_sku'; + $option = $this->getOption(); + + $productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + ['save', 'setConfigurableAttributesData', 'setStoreId', 'getTypeId', 'setTypeId', '__sleep', '__wakeup'], + [], + '', + false + ); + $productMock->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_SIMPLE)); + $this->productRepositoryMock->expects($this->any()) + ->method('get') + ->will($this->returnValue($productMock)); + + $confAttributeMock = $this->getMock( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute', + [], + [], + '', + false + ); + $this->confAttributeFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($confAttributeMock)); + + $confAttributeMock->expects($this->exactly(2))->method('loadByProductAndAttribute'); + $confAttributeMock->expects($this->at(1))->method('getId')->will($this->returnValue(null)); + $confAttributeMock->expects($this->at(2))->method('getId')->will($this->returnValue(1)); + $confAttributeMock->expects($this->at(3))->method('getId')->will($this->returnValue(null)); + + $productMock->expects($this->once())->method('setTypeId')->with(ConfigurableType::TYPE_CODE); + $productMock->expects($this->once())->method('setConfigurableAttributesData'); + $productMock->expects($this->once())->method('setStoreId')->with(0); + $productMock->expects($this->once())->method('save'); + + $this->optionConverterMock->expects($this->once())->method('convertArrayFromData')->with($option); + + $this->writeService->add($productSku, $option); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testAddHasOptionCouldNotSaveException() + { + $productSku = 'test_sku'; + $option = $this->getOption(); + + $productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + ['save', 'setConfigurableAttributesData', 'setStoreId', 'getTypeId', 'setTypeId', '__sleep', '__wakeup'], + [], + '', + false + ); + $productMock->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_SIMPLE)); + $this->productRepositoryMock->expects($this->any()) + ->method('get') + ->will($this->returnValue($productMock)); + + $confAttributeMock = $this->getMock( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute', + [], + [], + '', + false + ); + $this->confAttributeFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($confAttributeMock)); + + $confAttributeMock->expects($this->once())->method('loadByProductAndAttribute'); + $confAttributeMock->expects($this->once())->method('getId')->will($this->returnValue(1)); + + $this->writeService->add($productSku, $option); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testAddSAveExceptionCouldNotSaveException() + { + $productSku = 'test_sku'; + $option = $this->getOption(); + + $productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + ['save', 'setConfigurableAttributesData', 'setStoreId', 'getTypeId', 'setTypeId', '__sleep', '__wakeup'], + [], + '', + false + ); + $productMock->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_SIMPLE)); + $this->productRepositoryMock->expects($this->any()) + ->method('get') + ->will($this->returnValue($productMock)); + + $confAttributeMock = $this->getMock( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute', + [], + [], + '', + false + ); + $this->confAttributeFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($confAttributeMock)); + + $confAttributeMock->expects($this->once())->method('loadByProductAndAttribute'); + $confAttributeMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + + $productMock->expects($this->once())->method('setTypeId')->with(ConfigurableType::TYPE_CODE); + $productMock->expects($this->once())->method('setConfigurableAttributesData'); + $productMock->expects($this->once())->method('setStoreId')->with(0); + $productMock->expects($this->once())->method('save') + ->will( + $this->returnCallback( + function () { + throw new \Exception(); + } + ) + ); + + $this->writeService->add($productSku, $option); + } + /** * Invalid product type check * diff --git a/dev/tests/unit/testsuite/Magento/Core/Controller/Request/HttpTest.php b/dev/tests/unit/testsuite/Magento/Core/Controller/Request/HttpTest.php deleted file mode 100644 index 51f691cc3fd..00000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Controller/Request/HttpTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Controller\Request; - -class HttpTest extends \PHPUnit_Framework_TestCase -{ - /** @var \Magento\Framework\App\RequestInterface */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_routerListMock; - - protected function setUp() - { - $this->_routerListMock = $this->getMock('\Magento\Framework\App\Route\ConfigInterface'); - $infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); - $infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); - $this->_model = new \Magento\Framework\App\Request\Http($this->_routerListMock, $infoProcessorMock); - } - - /** - * @param $serverVariables array - * @param $expectedResult string - * @dataProvider serverVariablesProvider - */ - public function testGetDistroBaseUrl($serverVariables, $expectedResult) - { - $originalServerValue = $_SERVER; - $_SERVER = $serverVariables; - - $this->assertEquals($expectedResult, $this->_model->getDistroBaseUrl()); - - $_SERVER = $originalServerValue; - } - - public function serverVariablesProvider() - { - $returnValue = array(); - $defaultServerData = array( - 'SCRIPT_NAME' => 'index.php', - 'HTTP_HOST' => 'sample.host.com', - 'SERVER_PORT' => '80', - 'HTTPS' => '1' - ); - - $secureUnusualPort = $noHttpsData = $httpsOffData = $noHostData = $noScriptNameData = $defaultServerData; - - unset($noScriptNameData['SCRIPT_NAME']); - $returnValue['no SCRIPT_NAME'] = array($noScriptNameData, 'http://localhost/'); - - unset($noHostData['HTTP_HOST']); - $returnValue['no HTTP_HOST'] = array($noHostData, 'http://localhost/'); - - $httpsOffData['HTTPS'] = 'off'; - $returnValue['HTTPS off'] = array($httpsOffData, 'http://sample.host.com/'); - - unset($noHttpsData['HTTPS']); - $returnValue['no HTTPS'] = array($noHttpsData, 'http://sample.host.com/'); - - $noHttpsNoServerPort = $noHttpsData; - unset($noHttpsNoServerPort['SERVER_PORT']); - $returnValue['no SERVER_PORT'] = array($noHttpsNoServerPort, 'http://sample.host.com/'); - - $noHttpsButSecurePort = $noHttpsData; - $noHttpsButSecurePort['SERVER_PORT'] = 443; - $returnValue['no HTTP but secure port'] = array($noHttpsButSecurePort, 'https://sample.host.com/'); - - $notSecurePort = $noHttpsData; - $notSecurePort['SERVER_PORT'] = 81; - $notSecurePort['HTTP_HOST'] = 'sample.host.com:81'; - $returnValue['not secure not standard port'] = array($notSecurePort, 'http://sample.host.com:81/'); - - $secureUnusualPort['SERVER_PORT'] = 441; - $secureUnusualPort['HTTP_HOST'] = 'sample.host.com:441'; - $returnValue['not standard secure port'] = array($secureUnusualPort, 'https://sample.host.com:441/'); - - $customUrlPathData = $noHttpsData; - $customUrlPathData['SCRIPT_FILENAME'] = '/some/dir/custom.php'; - $returnValue['custom path'] = array($customUrlPathData, 'http://sample.host.com/'); - - return $returnValue; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php deleted file mode 100644 index 3580c111ecc..00000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Test class for \Magento\Framework\App\ResponseInterface - */ -namespace Magento\Core\Controller\Response; - -class HttpTest extends \PHPUnit_Framework_TestCase -{ - /** - * Test for getHeader method - * - * @dataProvider headersDataProvider - * @covers \Magento\Framework\App\Response\Http::getHeader - * @param string $header - */ - public function testGetHeaderExists($header) - { - $cookieMock = $this->getMock('\Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $contextMock = $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false); - $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); - $response->headersSentThrowsException = false; - $response->setHeader($header['name'], $header['value'], $header['replace']); - $this->assertEquals($header, $response->getHeader($header['name'])); - } - - /** - * Data provider for testGetHeader - * - * @return array - */ - public function headersDataProvider() - { - return array( - array(array('name' => 'X-Frame-Options', 'value' => 'SAMEORIGIN', 'replace' => true)), - array(array('name' => 'Test2', 'value' => 'Test2', 'replace' => false)) - ); - } - - /** - * Test for getHeader method. Validation for attempt to get not existing header - * - * @covers \Magento\Framework\App\Response\Http::getHeader - */ - public function testGetHeaderNotExists() - { - $cookieMock = $this->getMock('\Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $contextMock = $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false); - $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); - $response->headersSentThrowsException = false; - $response->setHeader('Name', 'value', true); - $this->assertFalse($response->getHeader('Wrong name')); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php index da09c3e82d2..9be647b7443 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php @@ -65,8 +65,8 @@ class CreateTest extends \PHPUnit_Framework_TestCase $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); $this->request = $this->getMock( 'Magento\Framework\App\RequestInterface', - array('isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'), - array(), + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], '', false ); @@ -98,7 +98,7 @@ class CreateTest extends \PHPUnit_Framework_TestCase $this->redirectMock->expects($this->once()) ->method('redirect') - ->with($this->response, '*/*', array()) + ->with($this->response, '*/*', []) ->will($this->returnValue(false)); $this->viewMock->expects($this->never()) @@ -129,8 +129,8 @@ class CreateTest extends \PHPUnit_Framework_TestCase $layoutMock = $this->getMock( 'Magento\Framework\View\Layout', - array(), - array(), + [], + [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php index d0d24fe76c1..0df060f96a4 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php @@ -111,22 +111,22 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase { $this->request = $this->getMock( 'Magento\Framework\App\RequestInterface', - array('isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'), - array(), + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], '', false ); $this->response = $this->getMock( 'Magento\Framework\App\ResponseInterface', array('setRedirect', 'sendResponse'), - array(), + [], '', false ); $this->customerSession = $this->getMock( '\Magento\Customer\Model\Session', array('isLoggedIn', 'getLastCustomerId', 'getBeforeAuthUrl', 'setBeforeAuthUrl'), - array(), + [], '', false ); @@ -134,28 +134,28 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase $this->objectManager = $this->getMock( '\Magento\Framework\ObjectManager\ObjectManager', array('get'), - array(), + [], '', false ); $this->_formKeyValidator = $this->getMock( 'Magento\Core\App\Action\FormKeyValidator', - array(), - array(), + [], + [], '', false ); $this->customerHelperMock = $this->getMock( 'Magento\Customer\Helper\Data', - array(), - array(), + [], + [], '', false ); $this->formFactoryMock = $this->getMock( 'Magento\Customer\Model\Metadata\FormFactory', - array(), - array(), + [], + [], '', false ); @@ -214,7 +214,7 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase ), array( 'Magento\Core\Helper\Data', - $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false) + $this->getMock('Magento\Core\Helper\Data', [], [], '', false) ) ) ) diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/NewsletterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/NewsletterTest.php index ab555037798..c1195b265f0 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/NewsletterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/NewsletterTest.php @@ -92,11 +92,10 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_response = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' - )->disableOriginalConstructor()->setMethods( - array('setRedirect', 'getHeader') - )->getMock(); + $this->_response = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods(['setRedirect', 'getHeader', '__wakeup']) + ->getMock(); $this->_response->expects( $this->any() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php index d2cbbce45a4..e8cb97c5574 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -99,7 +99,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase $this->_response = $this->getMockBuilder( 'Magento\Framework\App\Response\Http' )->disableOriginalConstructor()->setMethods( - array('setRedirect', 'getHeader') + ['setRedirect', 'getHeader', '__wakeup'] )->getMock(); $this->_response->expects( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Helper/DataTest.php index 742aeea1892..3974dd8b380 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Helper/DataTest.php @@ -60,8 +60,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_mockRequest = $this->getMock( 'Magento\Framework\App\RequestInterface', - array('getPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'), - array(), + ['getPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], '', false ); @@ -178,7 +178,7 @@ class DataTest extends \PHPUnit_Framework_TestCase )->with( self::ENTITY, self::FORM_CODE, - array(), + [], false, \Magento\Customer\Model\Metadata\Form::DONT_IGNORE_INVISIBLE )->will( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php index 96837c0f3a2..7386b33efe2 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php @@ -56,7 +56,7 @@ class FileTest extends AbstractFormTestCase $this->requestMock = $this->getMockBuilder( 'Magento\Framework\App\RequestInterface' )->disableOriginalConstructor()->setMethods( - array('getParam', 'getParams', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName') + ['getParam', 'getParams', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getCookie'] )->getMock(); } @@ -77,7 +77,7 @@ class FileTest extends AbstractFormTestCase )->method( 'getParam' )->will( - $this->returnValue(array('delete' => $delete)) + $this->returnValue(['delete' => $delete]) ); $this->attributeMetadataMock->expects( @@ -100,7 +100,7 @@ class FileTest extends AbstractFormTestCase { return array( 'ajax' => array(false, '', true), - 'no_file' => array(array()), + 'no_file' => array([]), 'delete' => array(array('delete' => true), '', false, true), 'file_delete' => array(array('attributeCodeValue', 'delete' => true), 'attributeCode', false, true), 'file_!delete' => array(array('attributeCodeValue'), 'attributeCode', false, false) @@ -155,7 +155,7 @@ class FileTest extends AbstractFormTestCase public function extractValueWithRequestScopeDataProvider() { return array( - 'requestScope' => array(array(), 'requestScope'), + 'requestScope' => array([], 'requestScope'), 'mainScope' => array( array('fileKey' => 'attributeValue'), 'mainScope', @@ -200,7 +200,7 @@ class FileTest extends AbstractFormTestCase public function validateValueNotToUploadDataProvider() { return array( - 'emptyValue' => array(true, array(), true), + 'emptyValue' => array(true, [], true), 'someValue' => array(true, array('some value')), 'delete_someValue' => array(true, array('delete' => true, 'some value'), false, false), 'null' => array(array('"attributeLabel" is a required value.'), null) @@ -213,7 +213,7 @@ class FileTest extends AbstractFormTestCase * @param array $parameters * @dataProvider validateValueToUploadDataProvider */ - public function testValidateValueToUpload($expected, $value, $parameters = array()) + public function testValidateValueToUpload($expected, $value, $parameters = []) { $parameters = array_merge(array('uploaded' => true, 'valid' => true), $parameters); $fileForm = $this->getClass($value, false); @@ -281,7 +281,7 @@ class FileTest extends AbstractFormTestCase public function compactValueDataProvider() { - return array('notDelete' => array('value', array()), 'delete' => array('', array('delete' => true))); + return array('notDelete' => array('value', []), 'delete' => array('', array('delete' => true))); } public function testRestoreValue() diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php index 9a475293705..15e977101d8 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php @@ -52,6 +52,17 @@ class StandardTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $_cookieManagerMock; + + + public function setUp() + { + $this->_cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); + } + /** * @param \Magento\Framework\App\RequestInterface $request * @param bool $isVde @@ -83,6 +94,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase */ public function matchDataProvider() { + $this->_cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); $uri = self::TEST_HOST . '/' . self::VDE_FRONT_NAME . self::TEST_PATH; $notVdeUrl = self::TEST_HOST . self::TEST_PATH; @@ -97,7 +109,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase $matchedRequest = $this->getMock( 'Magento\Framework\App\Request\Http', array('_isFrontArea'), - array($routerListMock, $infoProcessorMock, $uri) + array($routerListMock, $infoProcessorMock, $this->_cookieManagerMock, $uri) ); $matchedController = $this->getMockForAbstractClass( @@ -132,14 +144,11 @@ class StandardTest extends \PHPUnit_Framework_TestCase array('matched' => $matchedRouter, 'not_matched' => $notMatchedRouter) ); - $infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); - $infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); - $routers = array( 'not vde request' => array( '$request' => $this->getMock( 'Magento\Framework\App\Request\Http', array('_isFrontArea'), array( - $routerListMock, $infoProcessorMock, $notVdeUrl + $routerListMock, $infoProcessorMock, $this->_cookieManagerMock, $notVdeUrl ) ), '$isVde' => false, @@ -149,7 +158,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase '$request' => $this->getMock( 'Magento\Framework\App\Request\Http', array('_isFrontArea'), - array($routerListMock, $infoProcessorMock, $uri) + array($routerListMock, $infoProcessorMock, $this->_cookieManagerMock, $uri) ), '$isVde' => true, '$isLoggedIn' => false, @@ -158,7 +167,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase '$request' => $this->getMock( 'Magento\Framework\App\Request\Http', array('_isFrontArea'), - array($routerListMock, $infoProcessorMock, $uri) + array($routerListMock, $infoProcessorMock, $this->_cookieManagerMock, $uri) ), '$isVde' => true, '$isLoggedIn' => true, diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Service/V1/Data/FileContentValidatorTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Service/V1/Data/FileContentValidatorTest.php index 9ca32b1c4b1..fc8885d3bc1 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Service/V1/Data/FileContentValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Service/V1/Data/FileContentValidatorTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -50,28 +49,29 @@ class FileContentValidatorTest extends \PHPUnit_Framework_TestCase public function testIsValid() { - $this->fileContentMock->expects($this->any())->method('getData')->will($this->returnValue( - base64_encode('test content') - )); - $this->fileContentMock->expects($this->any())->method('getName')->will($this->returnValue( - 'valid_name' - )); + $this->fileContentMock->expects($this->any())->method('getData') + ->will($this->returnValue(base64_encode('test content'))); + $this->fileContentMock->expects($this->any())->method('getName') + ->will($this->returnValue('valid_name')); $this->assertTrue($this->validator->isValid($this->fileContentMock)); } + public function testValidateLinkResourceInputExceptionUrl() + { + + } + /** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Provided content must be valid base64 encoded data. */ public function testIsValidThrowsExceptionIfProvidedContentIsNotBase64Encoded() { - $this->fileContentMock->expects($this->any())->method('getData')->will($this->returnValue( - 'not_a_base64_encoded_content' - )); - $this->fileContentMock->expects($this->any())->method('getName')->will($this->returnValue( - 'valid_name' - )); + $this->fileContentMock->expects($this->any())->method('getData') + ->will($this->returnValue('not_a_base64_encoded_content')); + $this->fileContentMock->expects($this->any())->method('getName') + ->will($this->returnValue('valid_name')); $this->assertTrue($this->validator->isValid($this->fileContentMock)); } @@ -83,12 +83,10 @@ class FileContentValidatorTest extends \PHPUnit_Framework_TestCase */ public function testIsValidThrowsExceptionIfProvidedImageNameContainsForbiddenCharacters($fileName) { - $this->fileContentMock->expects($this->any())->method('getData')->will($this->returnValue( - base64_encode('test content') - )); - $this->fileContentMock->expects($this->any())->method('getName')->will($this->returnValue( - $fileName - )); + $this->fileContentMock->expects($this->any())->method('getData') + ->will($this->returnValue(base64_encode('test content'))); + $this->fileContentMock->expects($this->any())->method('getName') + ->will($this->returnValue($fileName)); $this->assertTrue($this->validator->isValid($this->fileContentMock)); } diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php index 056c44d6fc5..8e005ca910a 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php @@ -205,7 +205,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase return array( 'main_table_expression' => array( 'col2', '1', - 'SELECT COUNT(*) FROM "some_main_table" AS "main_table"' . "\n" + 'SELECT COUNT(DISTINCT main_table.attribute_id) FROM "some_main_table" AS "main_table"' . "\n" . ' INNER JOIN "some_extra_table" AS "additional_table"' . ' ON additional_table.attribute_id = main_table.attribute_id' . "\n" . ' LEFT JOIN "some_extra_table" AS "scope_table"' @@ -216,7 +216,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase ), 'additional_table_expression' => array( 'col3', '2', - 'SELECT COUNT(*) FROM "some_main_table" AS "main_table"' . "\n" + 'SELECT COUNT(DISTINCT main_table.attribute_id) FROM "some_main_table" AS "main_table"' . "\n" . ' INNER JOIN "some_extra_table" AS "additional_table"' . ' ON additional_table.attribute_id = main_table.attribute_id'. "\n" . ' LEFT JOIN "some_extra_table" AS "scope_table"' diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php index 6f753fe9727..6e174fdf614 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php @@ -105,7 +105,8 @@ class ActionTest extends \PHPUnit_Framework_TestCase 'setModuleName', 'getActionName', 'setActionName', - 'getParam' + 'getParam', + 'getCookie' ], [], '', diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ForwardTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ForwardTest.php index 095270a2382..419f930f809 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Action/ForwardTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Action/ForwardTest.php @@ -23,35 +23,65 @@ */ namespace Magento\Framework\App\Action; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Test Forward + * + * getRequest,getResponse of AbstractAction class is also tested + */ class ForwardTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\App\Action\Forward */ - protected $_actionAbstract; + protected $actionAbstract; /** - * @var \Magento\Framework\App\RequestInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface */ - protected $_request; + protected $request; /** * @var \Magento\Framework\App\ResponseInterface */ - protected $_response; + protected $response; protected function setUp() { - $this->_request = $this->getMock('Magento\Framework\App\Request\Http', array(), array(), '', false); - $this->_response = $this->getMock('\Magento\Framework\App\Response\Http', array(), array(), '', false); + $objectManager = new ObjectManager($this); + $cookieMetadataFactoryMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + )->disableOriginalConstructor()->getMock(); + $cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor()->getMock(); + $contextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->disableOriginalConstructor() + ->getMock(); + $this->response = $objectManager->getObject( + 'Magento\Framework\App\Response\Http', + [ + 'cookieManager' => $cookieManagerMock, + 'cookieMetadataFactory' => $cookieMetadataFactoryMock, + 'context' => $contextMock + ] + ); + + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); - $this->_actionAbstract = new \Magento\Framework\App\Action\Forward($this->_request, $this->_response); + $this->actionAbstract = $objectManager->getObject( + 'Magento\Framework\App\Action\Forward', + [ + 'request' => $this->request, + 'response' => $this->response + ] + ); } public function testDispatch() { - $this->_request->expects($this->once())->method('setDispatched')->with(false); - $this->_actionAbstract->dispatch($this->_request); + $this->request->expects($this->once())->method('setDispatched')->with(false); + $this->actionAbstract->dispatch($this->request); } /** @@ -62,7 +92,7 @@ class ForwardTest extends \PHPUnit_Framework_TestCase */ public function testGetRequest() { - $this->assertEquals($this->_request, $this->_actionAbstract->getRequest()); + $this->assertSame($this->request, $this->actionAbstract->getRequest()); } /** @@ -73,7 +103,7 @@ class ForwardTest extends \PHPUnit_Framework_TestCase */ public function testGetResponse() { - $this->assertEquals($this->_response, $this->_actionAbstract->getResponse()); + $this->assertSame($this->response, $this->actionAbstract->getResponse()); } /** @@ -84,15 +114,6 @@ class ForwardTest extends \PHPUnit_Framework_TestCase */ public function testResponseHeaders() { - $infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); - $routerListMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); - $cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $contextMock = $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false); - $request = new \Magento\Framework\App\Request\Http($routerListMock, $infoProcessorMock); - $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); - $response->headersSentThrowsException = false; - $action = new \Magento\Framework\App\Action\Forward($request, $response); - - $this->assertEquals(array(), $action->getResponse()->getHeaders()); + $this->assertEmpty($this->actionAbstract->getResponse()->getHeaders()); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php index 106703fdabe..96fb6af315d 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php @@ -99,11 +99,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase ->setMethods(['configure', 'get', 'create']) ->getMock(); $objectManagerMock->expects($this->once())->method('configure')->with($areaConfig); - $this->_responseMock = $this->getMockBuilder( - 'Magento\Framework\App\Response\Http' - )->disableOriginalConstructor()->setMethods( - ['setHttpResponseCode', 'setBody'] - )->getMock(); + $this->_responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods(['setHttpResponseCode', 'setBody', '__wakeup']) + ->getMock(); $this->_frontControllerMock = $this->getMockBuilder( 'Magento\Framework\App\FrontControllerInterface' )->disableOriginalConstructor()->setMethods(['dispatch'])->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/FormKeyTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/FormKeyTest.php index c395ef9a021..8c194b0e626 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/FormKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/FormKeyTest.php @@ -39,27 +39,32 @@ class FormKeyTest extends \PHPUnit_Framework_TestCase /** * Cookie mock * - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\CookieManager|\PHPUnit_Framework_MockObject_MockObject */ - protected $cookieMock; + protected $cookieManagerMock; /** * Create cookie mock and FormKey instance */ public function setUp() { - $this->cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array('get'), array(), '', false); - $this->formKey = new \Magento\Framework\App\PageCache\FormKey($this->cookieMock); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor()->getMock(); + $this->formKey = $objectManager->getObject( + 'Magento\Framework\App\PageCache\FormKey', + ['cookieManager' => $this->cookieManagerMock] + ); } public function testGet() { //Data - $formKey = 'test from key'; + $formKey = 'test_from_key'; //Verification - $this->cookieMock->expects($this->once()) - ->method('get') + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') ->with(\Magento\Framework\App\PageCache\FormKey::COOKIE_NAME) ->will($this->returnValue($formKey)); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/KernelTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/KernelTest.php index aace18f5800..8dcbf13d103 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/KernelTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/KernelTest.php @@ -63,7 +63,7 @@ class KernelTest extends \PHPUnit_Framework_TestCase $this->responseMock = $this->getMockBuilder( 'Magento\Framework\App\Response\Http' )->setMethods( - array('getHeader', 'getHttpResponseCode', 'setNoCacheHeaders', 'clearHeader') + ['getHeader', 'getHttpResponseCode', 'setNoCacheHeaders', 'clearHeader', '__wakeup'] )->disableOriginalConstructor()->getMock(); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php index 0fb9ba1342d..971325cc79f 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php @@ -23,6 +23,8 @@ */ namespace Magento\Framework\App\PageCache; +use Magento\TestFramework\ObjectManager; + class VersionTest extends \PHPUnit_Framework_TestCase { /** @@ -33,11 +35,18 @@ class VersionTest extends \PHPUnit_Framework_TestCase protected $version; /** - * Cookie mock + * Cookie manager mock + * + * @var \Magento\Framework\Stdlib\CookieManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieManagerMock; + + /** + * Cookie manager mock * - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $cookieMock; + protected $cookieMetadataFactoryMock; /** * Request mock @@ -51,9 +60,23 @@ class VersionTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array('set'), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', array('isPost'), array(), '', false); - $this->version = new Version($this->cookieMock, $this->requestMock); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor()->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor()->getMock(); + $this->cookieMetadataFactoryMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + ) + ->disableOriginalConstructor()->getMock(); + $this->version = $objectManager->getObject( + 'Magento\Framework\App\PageCache\Version', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + 'request' => $this->requestMock + ] + ); } /** @@ -70,17 +93,40 @@ class VersionTest extends \PHPUnit_Framework_TestCase { $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue($isPost)); if ($isPost) { - $this->cookieMock->expects($this->once())->method('set'); + $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); + $publicCookieMetadataMock->expects($this->once()) + ->method('setPath') + ->with('/') + ->will($this->returnSelf()); + + $publicCookieMetadataMock->expects($this->once()) + ->method('setDuration') + ->with(Version::COOKIE_PERIOD) + ->will($this->returnSelf()); + + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadataMock) + ); + + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie'); } $this->version->process(); } /** * Data provider for testProcess + * * @return array */ public function processProvider() { - return array(array(true), array(false)); + return [ + "post" => [true], + "notPost" => [false] + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php index a449742e8b3..f2382261466 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Request/HttpTest.php @@ -43,35 +43,63 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected $_infoProcessorMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_cookieManagerMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $_objectManager; + protected function setUp() { + $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_routerListMock = $this->getMock('Magento\Framework\App\Route\ConfigInterface'); $this->_infoProcessorMock = $this->getMock('Magento\Framework\App\Request\PathInfoProcessorInterface'); $this->_infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1)); + $this->_cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager'); } public function testGetOriginalPathInfoWithTestUri() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com/value'); + $uri = 'http://test.com/value'; + $this->_model = $this->getModel($uri); + $this->assertEquals('/value', $this->_model->getOriginalPathInfo()); } + private function getModel($uri = null) + { + return $this->_objectManager->getObject( + 'Magento\Framework\App\Request\Http', + [ + 'pathInfoProcessor' => $this->_infoProcessorMock, + 'routeConfig' => $this->_routerListMock, + 'cookieManager' => $this->_cookieManagerMock, + 'uri' => $uri + ] + ); + } + public function testGetOriginalPathInfoWithEmptyUri() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, null); + $this->_model = $this->_model = $this->getModel(); $this->assertEmpty($this->_model->getOriginalPathInfo()); } public function testSetPathInfoWithNullValue() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, null); + $this->_model = $this->_model = $this->getModel(); $actual = $this->_model->setPathInfo(); $this->assertEquals($this->_model, $actual); } public function testSetPathInfoWithValue() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, null); + $this->_model = $this->_model = $this->getModel(); $expected = 'testPathInfo'; $this->_model->setPathInfo($expected); $this->assertEquals($expected, $this->_model->getPathInfo()); @@ -79,11 +107,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testSetPathInfoWithQueryPart() { - $this->_model = new Request( - $this->_routerListMock, - $this->_infoProcessorMock, - 'http://test.com/node?queryValue' - ); + + $uri = 'http://test.com/node?queryValue'; + $this->_model = $this->_model = $this->getModel($uri); $this->_model->setPathInfo(); $this->assertEquals('/node', $this->_model->getPathInfo()); } @@ -91,7 +117,8 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testRewritePathInfoWithNewValue() { $expected = '/other/path'; - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com/one/two'); + $uri = 'http://test.com/one/two'; + $this->_model = $this->_model = $this->getModel($uri); $this->_model->rewritePathInfo($expected); $this->assertEquals($expected, $this->_model->getPathInfo()); } @@ -99,7 +126,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testRewritePathInfoWithSameValue() { $expected = '/one/two'; - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com' . $expected); + + $uri = 'http://test.com' . $expected; + $this->_model = $this->_model = $this->getModel($uri); $this->_model->rewritePathInfo($expected); $this->assertEquals($expected, $this->_model->getPathInfo()); } @@ -107,14 +136,14 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetBasePathWithPath() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setBasePath('http:\/test.com\one/two'); $this->assertEquals('http://test.com/one/two', $this->_model->getBasePath()); } public function testGetBasePathWithoutPath() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setBasePath(); $this->assertEquals('/', $this->_model->getBasePath()); } @@ -122,83 +151,85 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlWithUrl() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setBaseUrl('http:\/test.com\one/two'); $this->assertEquals('http://test.com/one/two', $this->_model->getBaseUrl()); } public function testGetBaseUrlWithEmptyUrl() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setBaseUrl(); $this->assertEmpty($this->_model->getBaseUrl()); } public function testSetRouteNameWithRouter() { - $router = $this->getMock('\Magento\Framework\App\Router\AbstractRouter', array(), array(), '', false); + $router = $this->getMock('Magento\Framework\App\Router\AbstractRouter', array(), array(), '', false); $this->_routerListMock->expects($this->any())->method('getRouteFrontName')->will($this->returnValue($router)); - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setRouteName('RouterName'); $this->assertEquals('RouterName', $this->_model->getRouteName()); } public function testSetRouteNameWithNullRouterValue() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_routerListMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue(null)); $this->_model->setRouteName('RouterName'); } public function testGetFrontName() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com/one/two'); + + $uri = 'http://test.com/one/two'; + $this->_model = $this->getModel($uri); $this->assertEquals('one', $this->_model->getFrontName()); } public function testGetAliasWhenAliasExists() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setAlias('AliasName', 'AliasTarget'); $this->assertEquals('AliasTarget', $this->_model->getAlias('AliasName')); } public function testGetAliasWhenAliasesIsNull() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->assertNull($this->_model->getAlias('someValue')); } public function testGetAliasesWhenAliasSet() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setAlias('AliasName', 'AliasTarget'); $this->assertEquals(array('AliasName' => 'AliasTarget'), $this->_model->getAliases()); } public function testGetAliasesWhenAliasAreEmpty() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->assertEmpty($this->_model->getAliases()); } public function testGetRequestedRouteNameWhenRequestedRouteIsSet() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setRoutingInfo(array('requested_route' => 'ExpectedValue')); $this->assertEquals('ExpectedValue', $this->_model->getRequestedRouteName()); } public function testGetRequestedRouteNameWithNullValueRouteName() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setRouteName('RouteName'); $this->assertEquals('RouteName', $this->_model->getRequestedRouteName()); } public function testGetRequestedRouteNameWithRewritePathInfo() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $expected = 'TestValue'; $this->_model->setPathInfo($expected); $this->_model->rewritePathInfo($expected . '/other'); @@ -216,7 +247,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetRequestedRouteNameWithoutRewritePathInfo() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $expected = 'RouteName'; $this->_model->setRouteName($expected); $this->assertEquals($expected, $this->_model->getRequestedRouteName()); @@ -224,7 +255,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetRequestedControllerNameWithRequestedController() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $expected = array('requested_controller' => 'ControllerName'); $this->_model->setRoutingInfo($expected); $test = $this->_model->getRequestedControllerName(); @@ -233,7 +264,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetRequestedControllerNameWithRewritePathInfo() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $path = 'one/two/'; $this->_model->setPathInfo($path); $this->_model->rewritePathInfo($path . '/last'); @@ -242,14 +273,14 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetRequestedActionNameWithRoutingInfo() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->_model->setRoutingInfo(array('requested_action' => 'ExpectedValue')); $this->assertEquals('ExpectedValue', $this->_model->getRequestedActionName()); } public function testGetRequestedActionNameWithRewritePathInfo() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $path = 'one/two/three'; $this->_model->setPathInfo($path); $this->_model->rewritePathInfo($path . '/last'); @@ -258,19 +289,19 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testIsStraightWithTrueValue() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->assertTrue($this->_model->isStraight(true)); } public function testIsStraightWithDefaultValue() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->assertFalse($this->_model->isStraight()); } public function testGetFullActionName() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); /* empty request */ $this->assertEquals('__', $this->_model->getFullActionName()); $this->_model->setRouteName('test')->setControllerName('controller')->setActionName('action'); @@ -300,7 +331,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected function _initForward() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $beforeForwardInfo = [ 'params' => ['one' => '111', 'two' => '222'], 'action_name' => 'ActionName', @@ -319,7 +350,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testIsAjax() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $this->assertFalse($this->_model->isAjax()); @@ -342,7 +373,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testSetPost() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $post = ['one' => '111', 'two' => '222']; $this->_model->setPost($post); @@ -358,7 +389,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testGetFiles() { - $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock); + $this->_model = $this->_model = $this->getModel(); $_FILES = ['one' => '111', 'two' => '222']; $this->assertEquals($_FILES, $this->_model->getFiles()); @@ -371,4 +402,112 @@ class HttpTest extends \PHPUnit_Framework_TestCase $this->assertEquals('default', $this->_model->getFiles('no_such_file', 'default')); } + + /** + * @param $serverVariables array + * @param $expectedResult string + * @dataProvider serverVariablesProvider + */ + public function testGetDistroBaseUrl($serverVariables, $expectedResult) + { + $originalServerValue = $_SERVER; + $_SERVER = $serverVariables; + $this->_model = $this->_model = $this->getModel(); + $this->assertEquals($expectedResult, $this->_model->getDistroBaseUrl()); + + $_SERVER = $originalServerValue; + } + + public function testGetCookieDefault() + { + $key = "cookieName"; + $default = "defaultValue"; + + $this->_cookieManagerMock + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default) + ->will($this->returnValue($default)); + + $this->assertEquals($default, $this->getModel()->getCookie($key, $default)); + } + + public function testGetCookieNameExists() + { + $key = "cookieName"; + $default = "defaultValue"; + $value = "cookieValue"; + + $this->_cookieManagerMock + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default) + ->will($this->returnValue($value)); + + $this->assertEquals($value, $this->getModel()->getCookie($key, $default)); + } + + public function testGetCookieNullName() + { + $nullKey = null; + $default = "defaultValue"; + + $this->_cookieManagerMock + ->expects($this->once()) + ->method('getCookie') + ->with($nullKey, $default) + ->will($this->returnValue($default)); + + $this->assertEquals($default, $this->getModel()->getCookie($nullKey, $default)); + } + + public function serverVariablesProvider() + { + $returnValue = array(); + $defaultServerData = array( + 'SCRIPT_NAME' => 'index.php', + 'HTTP_HOST' => 'sample.host.com', + 'SERVER_PORT' => '80', + 'HTTPS' => '1' + ); + + $secureUnusualPort = $noHttpsData = $httpsOffData = $noHostData = $noScriptNameData = $defaultServerData; + + unset($noScriptNameData['SCRIPT_NAME']); + $returnValue['no SCRIPT_NAME'] = array($noScriptNameData, 'http://localhost/'); + + unset($noHostData['HTTP_HOST']); + $returnValue['no HTTP_HOST'] = array($noHostData, 'http://localhost/'); + + $httpsOffData['HTTPS'] = 'off'; + $returnValue['HTTPS off'] = array($httpsOffData, 'http://sample.host.com/'); + + unset($noHttpsData['HTTPS']); + $returnValue['no HTTPS'] = array($noHttpsData, 'http://sample.host.com/'); + + $noHttpsNoServerPort = $noHttpsData; + unset($noHttpsNoServerPort['SERVER_PORT']); + $returnValue['no SERVER_PORT'] = array($noHttpsNoServerPort, 'http://sample.host.com/'); + + $noHttpsButSecurePort = $noHttpsData; + $noHttpsButSecurePort['SERVER_PORT'] = 443; + $returnValue['no HTTP but secure port'] = array($noHttpsButSecurePort, 'https://sample.host.com/'); + + $notSecurePort = $noHttpsData; + $notSecurePort['SERVER_PORT'] = 81; + $notSecurePort['HTTP_HOST'] = 'sample.host.com:81'; + $returnValue['not secure not standard port'] = array($notSecurePort, 'http://sample.host.com:81/'); + + $secureUnusualPort['SERVER_PORT'] = 441; + $secureUnusualPort['HTTP_HOST'] = 'sample.host.com:441'; + $returnValue['not standard secure port'] = array($secureUnusualPort, 'https://sample.host.com:441/'); + + $customUrlPathData = $noHttpsData; + $customUrlPathData['SCRIPT_FILENAME'] = '/some/dir/custom.php'; + $returnValue['custom path'] = array($customUrlPathData, 'http://sample.host.com/'); + + return $returnValue; + } + + } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php index 96d144bb6a6..04640c4775f 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Response/Http/FileFactoryTest.php @@ -76,8 +76,8 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase ); $this->_responseMock = $this->getMock( 'Magento\Framework\App\Response\Http', - array('setHeader', 'sendHeaders'), - array(), + ['setHeader', 'sendHeaders', '__wakeup'], + [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php index b258cb23cc4..ef6d099e019 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php @@ -23,69 +23,120 @@ */ namespace Magento\Framework\App\Response; +use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata; +use Magento\Framework\Stdlib\Cookie\CookieMetadata; + class HttpTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\App\Response\Http */ - protected $_model; + protected $model; /** - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\CookieManager */ - protected $_cookieMock; + protected $cookieManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactoryMock; + /** - * @var \Magento\Framework\App\Http\Context + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Http\Context */ - protected $_context; + protected $contextMock; protected function setUp() { - $this->_cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $this->_context = new \Magento\Framework\App\Http\Context(); - $this->_model = new Http($this->_cookieMock, $this->_context); - $this->_model->headersSentThrowsException = false; - $this->_model->setHeader('name', 'value'); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->cookieMetadataFactoryMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + )->disableOriginalConstructor()->getMock(); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor()->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Http\Context')->disableOriginalConstructor() + ->getMock(); + $this->model = $objectManager->getObject( + 'Magento\Framework\App\Response\Http', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + 'context' => $this->contextMock + ] + ); + $this->model->headersSentThrowsException = false; + $this->model->setHeader('name', 'value'); } protected function tearDown() { - unset($this->_model); + unset($this->model); } public function testGetHeaderWhenHeaderNameIsEqualsName() { $expected = array('name' => 'Name', 'value' => 'value', 'replace' => false); - $actual = $this->_model->getHeader('Name'); + $actual = $this->model->getHeader('Name'); $this->assertEquals($expected, $actual); } public function testGetHeaderWhenHeaderNameIsNotEqualsName() { - $this->assertFalse($this->_model->getHeader('Test')); + $this->assertFalse($this->model->getHeader('Test')); } public function testSendVary() { - $vary = array('some-vary-key' => 'some-vary-value'); - $expected = sha1(serialize($vary)); + $data = ['some-vary-key' => 'some-vary-value']; + $expectedCookieName = Http::COOKIE_VARY_STRING; + $expectedCookieValue = sha1(serialize($data)); + $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); + $publicCookieMetadataMock->expects($this->once()) + ->method('setPath') + ->with('/') + ->will($this->returnSelf()); + + $this->contextMock->expects($this->once()) + ->method('getData') + ->with() + ->will( + $this->returnValue($data) + ); + + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadataMock) + ); - $this->_context->setValue('some-vary-key', 'some-vary-value', 'default'); - $this->_cookieMock - ->expects($this->once()) - ->method('set') - ->with(Http::COOKIE_VARY_STRING, $expected); - $this->_model->sendVary(); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with($expectedCookieName, $expectedCookieValue, $publicCookieMetadataMock); + $this->model->sendVary(); } public function testSendVaryEmptyData() { - $this->_cookieMock - ->expects($this->once()) - ->method('set') - ->with(Http::COOKIE_VARY_STRING, null, -1, '/'); - $this->_model->sendVary(); + $expectedCookieName = Http::COOKIE_VARY_STRING; + $cookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadata'); + $cookieMetadataMock->expects($this->once()) + ->method('setPath') + ->with('/') + ->will($this->returnSelf()); + + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createCookieMetadata') + ->with() + ->will($this->returnValue($cookieMetadataMock)); + + $this->cookieManagerMock->expects($this->once()) + ->method('deleteCookie') + ->with($expectedCookieName, $cookieMetadataMock); + $this->model->sendVary(); } /** @@ -98,10 +149,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase $cacheControl = 'public, max-age=' . $ttl . ', s-maxage=' . $ttl; $between = 1000; - $this->_model->setPublicHeaders($ttl); - $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); - $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); - $expiresResult = time($this->_model->getHeader('Expires')['value']); + $this->model->setPublicHeaders($ttl); + $this->assertEquals($pragma, $this->model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')['value']); + $expiresResult = time($this->model->getHeader('Expires')['value']); $this->assertTrue($expiresResult > $between || $expiresResult < $between); } @@ -114,7 +165,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase 'InvalidArgumentException', 'Time to live is a mandatory parameter for set public headers' ); - $this->_model->setPublicHeaders(null); + $this->model->setPublicHeaders(null); } /** @@ -127,10 +178,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase $cacheControl = 'private, max-age=' . $ttl; $expires = gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')); - $this->_model->setPrivateHeaders($ttl); - $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); - $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); - $this->assertEquals($expires, $this->_model->getHeader('Expires')['value']); + $this->model->setPrivateHeaders($ttl); + $this->assertEquals($pragma, $this->model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')['value']); + $this->assertEquals($expires, $this->model->getHeader('Expires')['value']); } /** @@ -142,7 +193,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase 'InvalidArgumentException', 'Time to live is a mandatory parameter for set private headers' ); - $this->_model->setPrivateHeaders(null); + $this->model->setPrivateHeaders(null); } /** @@ -154,10 +205,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0'; $expires = gmdate('D, d M Y H:i:s T', strtotime('-1 year')); - $this->_model->setNoCacheHeaders(); - $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); - $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); - $this->assertEquals($expires, $this->_model->getHeader('Expires')['value']); + $this->model->setNoCacheHeaders(); + $this->assertEquals($pragma, $this->model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')['value']); + $this->assertEquals($expires, $this->model->getHeader('Expires')['value']); } /** @@ -165,9 +216,80 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ public function testRepresentJson() { - $this->_model->setHeader('Content-Type', 'text/javascript'); - $this->_model->representJson('json_string'); - $this->assertEquals('application/json', $this->_model->getHeader('Content-Type')['value']); - $this->assertEquals('json_string', $this->_model->getBody('default')); + $this->model->setHeader('Content-Type', 'text/javascript'); + $this->model->representJson('json_string'); + $this->assertEquals('application/json', $this->model->getHeader('Content-Type')['value']); + $this->assertEquals('json_string', $this->model->getBody('default')); + } + + /** + * Test for getHeader method + * + * @dataProvider headersDataProvider + * @covers \Magento\Framework\App\Response\Http::getHeader + * @param string $header + */ + public function testGetHeaderExists($header) + { + $this->model->setHeader($header['name'], $header['value'], $header['replace']); + $this->assertEquals($header, $this->model->getHeader($header['name'])); + } + + /** + * Data provider for testGetHeader + * + * @return array + */ + public function headersDataProvider() + { + return [ + [['name' => 'X-Frame-Options', 'value' => 'SAMEORIGIN', 'replace' => true]], + [['name' => 'Test2', 'value' => 'Test2', 'replace' => false]] + ]; + } + + /** + * Test for getHeader method. Validation for attempt to get not existing header + * + * @covers \Magento\Framework\App\Response\Http::getHeader + */ + public function testGetHeaderNotExists() + { + $this->model->setHeader('Name', 'value', true); + $this->assertFalse($this->model->getHeader('Wrong name')); + } + + /** + * + * @expectedException \RuntimeException + * @expectedExceptionMessage ObjectManager isn't initialized + */ + public function testWakeUpWithException() + { + $this->model->__wakeup(); + $this->assertNull($this->cookieMetadataFactoryMock); + $this->assertNull($this->cookieManagerMock); + } + + /** + * Test for the magic method __wakeup + * + * @covers \Magento\Framework\App\Response\Http::__wakeup + */ + public function testWakeUpWith() + { + $objectManagerMock = $this->getMock('Magento\Framework\App\ObjectManager', [], [], '', false); + $objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\Stdlib\CookieManager') + ->will($this->returnValue($this->cookieManagerMock)); + + $objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + ->will($this->returnValue($this->cookieMetadataFactoryMock)); + + \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); + $this->model->__wakeup(); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/HTTP/AuthenticationTest.php b/dev/tests/unit/testsuite/Magento/Framework/HTTP/AuthenticationTest.php index 1a21e55b1d9..0a86c28e6fb 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/HTTP/AuthenticationTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/HTTP/AuthenticationTest.php @@ -86,11 +86,17 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase public function testSetAuthenticationFailed() { - $request = $this->getMock('\Magento\Framework\App\Request\Http', array(), array(), '', false); - $cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $contextMock = $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false); - $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); - $authentication = new \Magento\Framework\HTTP\Authentication($request, $response); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $request = $objectManager->getObject('Magento\Framework\App\Request\Http'); + $response = $objectManager->getObject('Magento\Framework\App\Response\Http'); + + $authentication = $objectManager->getObject( + 'Magento\Framework\HTTP\Authentication', + [ + 'httpRequest' => $request, + 'httpResponse' => $response + ] + ); $realm = uniqid(); $response->headersSentThrowsException = false; $authentication->setAuthenticationFailed($realm); diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt index 2d4340d4155..e905faec608 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt @@ -46,15 +46,20 @@ class SampleRepository * * @param int $id * @return \Magento\Framework\ObjectManager\Code\Generator\Sample + * @throws \Magento\Framework\Exception\InputException * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function get($id) { if (!$id) { - throw new \Magento\Framework\Exception\NoSuchEntityException('Requested product doesn\'t exist'); + throw new \Magento\Framework\Exception\InputException('ID required'); } if (!isset($this->registry[$id])) { - $this->registry[$id] = $this->sampleFactory->create()->load($id); + $entity = $this->sampleFactory->create()->load($id); + if (!$entity->getId()) { + throw new \Magento\Framework\Exception\NoSuchEntityException('Requested entity doesn\'t exist'); + } + $this->registry[$id] = $entity; } return $this->registry[$id]; } @@ -89,6 +94,8 @@ class SampleRepository $collection->addFieldToFilter($filter->getField(), [$condition => $filter->getValue()]); } } + $collection->setCurPage($criteria->getCurrentPage()); + $collection->setPageSize($criteria->getPageSize()); foreach ($collection as $object) { $this->register($object); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/AdapterFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/AdapterFactoryTest.php new file mode 100644 index 00000000000..e1632324707 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/AdapterFactoryTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class AdapterFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\AdapterFactory |\PHPUnit_Framework_MockObject_MockObject + */ + private $adapterFactory; + + /** + * @var \Magento\Framework\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $scopeConfig = $this->getMockBuilder('\Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + + $scopeConfig->expects($this->once())->method('getValue') + ->with($this->equalTo('some_path'), $this->equalTo('some_scopeType')) + ->will($this->returnValue('ClassName')); + + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->setMethods(['create', 'get', 'configure']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapterFactory = $helper->getObject( + '\Magento\Framework\Search\AdapterFactory', + [ + 'objectManager' => $this->objectManager, + 'scopeConfig' => $scopeConfig, + 'path' => 'some_path', + 'scopeType' => 'some_scopeType' + ] + ); + } + + public function testCreate() + { + $adapter = $this->getMockBuilder('\Magento\Framework\Search\AdapterInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager->expects($this->once())->method('create') + ->with($this->equalTo('ClassName'), $this->equalTo(['input'])) + ->will($this->returnValue($adapter)); + + $result = $this->adapterFactory->create(['input']); + $this->assertInstanceOf('\Magento\Framework\Search\AdapterInterface', $result); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testCreateExceptionThrown() + { + $adapter = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager->expects($this->once())->method('create') + ->with($this->equalTo('ClassName'), $this->equalTo(['input'])) + ->will($this->returnValue($adapter)); + + $this->adapterFactory->create(['input']); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/AggregationTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/AggregationTest.php new file mode 100644 index 00000000000..9e911c43a10 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/AggregationTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class AggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Aggregation |\PHPUnit_Framework_MockObject_MockObject + */ + private $aggregation; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $buckets = []; + for ($count = 0; $count < 5; $count++) { + $bucket = $this->getMockBuilder('Magento\Framework\Search\Bucket') + ->disableOriginalConstructor() + ->getMock(); + + $bucket->expects($this->any())->method('getName')->will($this->returnValue("$count")); + $bucket->expects($this->any())->method('getValue')->will($this->returnValue($count)); + $buckets[] = $bucket; + } + + $this->aggregation = $helper->getObject( + '\Magento\Framework\Search\Aggregation', + [ + 'buckets' => $buckets, + ] + ); + } + + public function testGetIterator() + { + $count = 0; + foreach ($this->aggregation as $bucket) { + $this->assertEquals($bucket->getName(), "$count"); + $this->assertEquals($bucket->getValue(), $count); + $count++; + } + } + + public function testGetBucketNames() + { + $this->assertEquals( + $this->aggregation->getBucketNames(), + ['0', '1', '2', '3', '4'] + ); + } + + public function testGetBucket() + { + $bucket = $this->aggregation->getBucket('3'); + $this->assertEquals($bucket->getName(), '3'); + $this->assertEquals($bucket->getValue(), 3); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php new file mode 100644 index 00000000000..fcedf7e9e19 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class DocumentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Document |\PHPUnit_Framework_MockObject_MockObject + */ + private $document; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $documentFields = []; + for ($count = 0; $count < 5; $count++) { + $field = $this->getMockBuilder('Magento\Framework\Search\DocumentField') + ->disableOriginalConstructor() + ->getMock(); + + $field->expects($this->any())->method('getName')->will($this->returnValue("$count")); + $field->expects($this->any())->method('getValues')->will($this->returnValue([$count])); + $documentFields[] = $field; + } + + $this->document = $helper->getObject( + 'Magento\Framework\Search\Document', + [ + 'documentId' => 42, + 'documentFields' => $documentFields, + ] + ); + } + + public function testGetIterator() + { + $count = 0; + foreach ($this->document as $field) { + $this->assertEquals($field->getName(), "$count"); + $this->assertEquals($field->getValues(), [$count]); + $count++; + } + } + + public function testGetFieldNames() + { + $this->assertEquals( + $this->document->getFieldNames(), + ['0', '1', '2', '3', '4'] + ); + } + + public function testGetField() + { + $field = $this->document->getField('3'); + $this->assertEquals($field->getValues(), [3]); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php new file mode 100644 index 00000000000..a6dbd0334e9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class QueryResponseTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Document[] + */ + private $documents = []; + + /** + * @var \Magento\Framework\Search\Aggregation[] + */ + private $aggregations = []; + + /** + * @var \Magento\Framework\Search\QueryResponse | \PHPUnit_Framework_MockObject_MockObject + */ + private $queryResponse; + + protected function setUp() + { + $helper = new ObjectManager($this); + + for ($count = 0; $count < 5; $count++) { + $document = $this->getMockBuilder('Magento\Framework\Search\Document') + ->disableOriginalConstructor() + ->getMock(); + + $document->expects($this->any())->method('getId')->will($this->returnValue($count)); + $this->documents[] = $document; + } + + for ($count = 0; $count < 3; $count++) { + $aggregation = $this->getMockBuilder('Magento\Framework\Search\Aggregation') + ->disableOriginalConstructor() + ->getMock(); + $this->aggregations[] = $aggregation; + } + + $this->queryResponse = $helper->getObject( + 'Magento\Framework\Search\QueryResponse', + [ + 'documents' => $this->documents, + 'aggregations' => $this->aggregations, + ] + ); + } + + public function testGetIterator() + { + $count = 0; + foreach ($this->queryResponse as $document) { + $this->assertEquals($document->getId(), $count); + $count++; + } + } + + public function testCount() + { + $this->assertEquals(count($this->queryResponse), 5); + } + + public function testGetAggregations() + { + $aggregations = $this->queryResponse->getAggregations(); + foreach ($aggregations as $aggregation) { + $this->assertInstanceOf('Magento\Framework\Search\Aggregation', $aggregation); + } + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Request/MapperTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Request/MapperTest.php new file mode 100644 index 00000000000..b0e7b9baa97 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Request/MapperTest.php @@ -0,0 +1,1045 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Request; + +use Magento\Framework\Search\Request\Query\Filter; +use Magento\TestFramework\Helper\ObjectManager; + +class MapperTest extends \PHPUnit_Framework_TestCase +{ + const ROOT_QUERY = 'someQuery'; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + private $helper; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + + /** + * @var \Magento\Framework\Search\Request\Query\Match|\PHPUnit_Framework_MockObject_MockObject + */ + private $queryMatch; + + /** + * @var \Magento\Framework\Search\Request\Query\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private $queryBool; + + /** + * @var \Magento\Framework\Search\Request\Query\Filter|\PHPUnit_Framework_MockObject_MockObject + */ + private $queryFilter; + + /** + * @var \Magento\Framework\Search\Request\Filter\Term|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterTerm; + + /** + * @var \Magento\Framework\Search\Request\Filter\Range|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterRange; + + /** + * @var \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterBool; + + protected function setUp() + { + $this->helper = new ObjectManager($this); + + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->setMethods(['create', 'get', 'configure']) + ->disableOriginalConstructor() + ->getMock(); + + $this->queryMatch = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + ->disableOriginalConstructor() + ->getMock(); + + $this->queryBool = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Bool') + ->disableOriginalConstructor() + ->getMock(); + + $this->queryFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Filter') + ->disableOriginalConstructor() + ->getMock(); + + $this->filterTerm = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + ->disableOriginalConstructor() + ->getMock(); + + $this->filterRange = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + ->disableOriginalConstructor() + ->getMock(); + + $this->filterBool = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Bool') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @param $queries + * @dataProvider getQueryMatchProvider + */ + public function testGetQueryMatch($queries) + { + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->once())->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'matches' => $query['match'] + ] + ) + ) + ->will($this->returnValue($this->queryMatch)); + + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryMatch, $mapper->getRootQuery()); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + */ + public function testGetQueryNotUsedStateException() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'boost' => 3, + 'match' => 'someMatches' + ], + 'notUsedQuery' => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'boost' => 3, + 'match' => 'someMatches' + ] + ]; + $query = $queries['someQuery']; + $this->objectManager->expects($this->once())->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'matches' => $query['match'] + ] + ) + ) + ->will($this->returnValue($this->queryMatch)); + + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryMatch, $mapper->getRootQuery()); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + */ + public function testGetQueryUsedStateException() + { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_BOOL, + 'name' => 'someName', + 'queryReference' => [ + [ + 'clause' => 'someClause', + 'ref' => 'someQuery' + ] + ] + ] + ], + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryMatch, $mapper->getRootQuery()); + } + + /** + * @param $queries + * @dataProvider getQueryFilterQueryReferenceProvider + */ + public function testGetQueryFilterQueryReference($queries) + { + $query = $queries['someQueryMatch']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'matches' => 'someMatches' + ] + ) + ) + ->will($this->returnValue($this->queryMatch)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'reference' => $this->queryMatch, + 'referenceType' => Filter::REFERENCE_QUERY + ] + ) + ) + ->will($this->returnValue($this->queryFilter)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Reference is not provided + */ + public function testGetQueryFilterReferenceException() + { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => [ + 'someQuery' => [ + 'type' => QueryInterface::TYPE_FILTER + ] + ], + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $mapper->getRootQuery(); + } + + /** + * @param $queries + * @dataProvider getQueryBoolProvider + */ + public function testGetQueryBool($queries) + { + $query = $queries['someQueryMatch']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Match'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'matches' => 'someMatches' + ] + ) + ) + ->will($this->returnValue($this->queryMatch)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Bool'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'someClause' => ['someQueryMatch' => $this->queryMatch] + ] + ) + ) + ->will($this->returnValue($this->queryBool)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryBool, $mapper->getRootQuery()); + } + + /** + * #@expectedException \InvalidArgumentException + */ + public function testGetQueryInvalidArgumentException() + { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => [ + self::ROOT_QUERY => [ + 'type' => 'invalid_type' + ] + ], + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => [] + ] + ); + + $mapper->getRootQuery(); + } + + /** + * @expectedException \Exception + */ + public function testGetQueryException() + { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => [], + 'rootQueryName' => self::ROOT_QUERY, + 'filters' => [] + ] + ); + + $mapper->getRootQuery(); + } + + public function testGetFilterTerm() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ]; + $filters = [ + 'someFilter' => [ + 'type' => FilterInterface::TYPE_TERM, + 'name' => 'someName', + 'field' => 'someField', + 'value' => 'someValue' + ] + ]; + + $filter = $filters['someFilter']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo( + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'value' => $filter['value'] + ] + ) + ) + ->will($this->returnValue($this->filterTerm)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'reference' => $this->filterTerm, + 'referenceType' => Filter::REFERENCE_FILTER + ] + ) + ) + ->will($this->returnValue($this->queryFilter)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => $filters + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + public function testGetFilterRange() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ]; + $filters = [ + 'someFilter' => [ + 'type' => FilterInterface::TYPE_RANGE, + 'name' => 'someName', + 'field' => 'someField', + 'from' => 'from', + 'to' => 'to' + ] + ]; + + $filter = $filters['someFilter']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Filter\Range'), + $this->equalTo( + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'from' => $filter['from'], + 'to' => $filter['to'] + ] + ) + ) + ->will($this->returnValue($this->filterRange)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'reference' => $this->filterRange, + 'referenceType' => Filter::REFERENCE_FILTER + ] + ) + ) + ->will($this->returnValue($this->queryFilter)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => $filters + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + public function testGetFilterBool() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ]; + $filters = [ + 'someFilter' => [ + 'type' => FilterInterface::TYPE_BOOL, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilterTerm', + 'clause' => 'someClause' + ] + ] + ], + 'someFilterTerm' => [ + 'type' => FilterInterface::TYPE_TERM, + 'name' => 'someName', + 'field' => 'someField', + 'value' => 'someValue' + ] + ]; + + $filter = $filters['someFilterTerm']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo( + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'value' => $filter['value'] + ] + ) + ) + ->will($this->returnValue($this->filterTerm)); + $filter = $filters['someFilter']; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Filter\Bool'), + $this->equalTo( + [ + 'name' => $filter['name'], + 'someClause' => ['someFilterTerm' => $this->filterTerm] + ] + ) + ) + ->will($this->returnValue($this->filterBool)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(2))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'reference' => $this->filterBool, + 'referenceType' => Filter::REFERENCE_FILTER + ] + ) + ) + ->will($this->returnValue($this->queryFilter)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => $filters + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + */ + public function testGetFilterNotUsedStateException() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ]; + $filters = [ + 'someFilter' => [ + 'type' => FilterInterface::TYPE_TERM, + 'name' => 'someName', + 'field' => 'someField', + 'value' => 'someValue' + ], + 'notUsedFilter' => [ + 'type' => FilterInterface::TYPE_TERM, + 'name' => 'someName', + 'field' => 'someField', + 'value' => 'someValue' + ] + ]; + + $filter = $filters['someFilter']; + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Filter\Term'), + $this->equalTo( + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'value' => $filter['value'] + ] + ) + ) + ->will($this->returnValue($this->filterTerm)); + $query = $queries[self::ROOT_QUERY]; + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Query\Filter'), + $this->equalTo( + [ + 'name' => $query['name'], + 'boost' => 1, + 'reference' => $this->filterTerm, + 'referenceType' => Filter::REFERENCE_FILTER + ] + ) + ) + ->will($this->returnValue($this->queryFilter)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => $filters + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + */ + public function testGetFilterUsedStateException() + { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ], + 'rootQueryName' => self::ROOT_QUERY, + 'filters' => [ + 'someFilter' => [ + 'type' => FilterInterface::TYPE_BOOL, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter', + 'clause' => 'someClause' + ] + ] + ] + ], + 'aggregation' => [], + ] + ); + + $this->assertEquals($this->queryMatch, $mapper->getRootQuery()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid filter type + */ + public function testGetFilterInvalidArgumentException() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'filterReference' => [ + [ + 'ref' => 'someFilter' + ] + ] + ] + ]; + $filters = [ + 'someFilter' => [ + 'type' => 'invalid_type' + ] + ]; + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [], + 'filters' => $filters + ] + ); + + $this->assertEquals($this->queryFilter, $mapper->getRootQuery()); + } + + /** + * @expectedException \Exception + */ + public function testGetFilterException() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'boost' => 3, + 'filterReference' => [ + [ + 'ref' => 'someQueryMatch', + 'clause' => 'someClause', + ] + ] + ] + ]; + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'filters' => [] + ] + ); + + $this->assertEquals($this->queryBool, $mapper->getRootQuery()); + } + + public function getQueryMatchProvider() + { + return [ + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'boost' => 3, + 'match' => 'someMatches' + ] + ] + ], + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ] + ] + ]; + } + + public function getQueryFilterQueryReferenceProvider() + { + return [ + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'boost' => 3, + 'queryReference' => [ + [ + 'ref' => 'someQueryMatch', + 'clause' => 'someClause', + ] + ] + ], + 'someQueryMatch' => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ] + ], + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_FILTER, + 'name' => 'someName', + 'queryReference' => [ + [ + 'ref' => 'someQueryMatch', + 'clause' => 'someClause', + ] + ] + ], + 'someQueryMatch' => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ] + ] + ]; + } + + public function getQueryBoolProvider() + { + return [ + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_BOOL, + 'name' => 'someName', + 'boost' => 3, + 'queryReference' => [ + [ + 'ref' => 'someQueryMatch', + 'clause' => 'someClause', + ] + ] + ], + 'someQueryMatch' => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ] + ], + [ + [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_BOOL, + 'name' => 'someName', + 'queryReference' => [ + [ + 'ref' => 'someQueryMatch', + 'clause' => 'someClause', + ] + ] + ], + 'someQueryMatch' => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ] + ] + ]; + } + + public function testGetBucketsTermBucket() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ]; + + $bucket = [ + "name" => "category_bucket", + "field" => "category", + "metric" => [ + ["type" => "sum"], + ["type" => "count"], + ["type" => "min"], + ["type" => "max"] + ], + "type" => "termBucket", + ]; + $metricClass = 'Magento\Framework\Search\Request\Aggregation\Metric'; + $bucketClass = 'Magento\Framework\Search\Request\Aggregation\TermBucket'; + $queryClass = 'Magento\Framework\Search\Request\Query\Match'; + $queryArguments = [ + 'name' => $queries[self::ROOT_QUERY]['name'], + 'boost' => 1, + 'matches' => $queries[self::ROOT_QUERY]['match'] + ]; + $arguments = [ + 'name' => $bucket['name'], + 'field' => $bucket['field'], + 'metrics' => [null, null, null, null], + ]; + $this->objectManager->expects($this->any())->method('create') + ->withConsecutive( + [$this->equalTo($queryClass), $this->equalTo($queryArguments)], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][0]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][1]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][2]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][3]['type']])], + [$this->equalTo($bucketClass), $this->equalTo($arguments)] + ) + ->will($this->returnValue(null)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [$bucket] + ] + ); + $mapper->getBuckets(); + } + + public function testGetBucketsRangeBucket() + { + $queries = [ + self::ROOT_QUERY => [ + 'type' => QueryInterface::TYPE_MATCH, + 'name' => 'someName', + 'match' => 'someMatches' + ] + ]; + + $bucket = [ + "name" => "price_bucket", + "field" => "price", + "metric" => [ + ["type" => "sum"], + ["type" => "count"], + ["type" => "min"], + ["type" => "max"] + ], + "range" => [ + ["from" => "", "to" => "50"], + ["from" => "50", "to" => "100"], + ["from" => "100", "to" => ""], + ], + "type" => "rangeBucket", + ]; + $metricClass = 'Magento\Framework\Search\Request\Aggregation\Metric'; + $bucketClass = 'Magento\Framework\Search\Request\Aggregation\RangeBucket'; + $rangeClass = 'Magento\Framework\Search\Request\Aggregation\Range'; + $queryClass = 'Magento\Framework\Search\Request\Query\Match'; + $queryArguments = [ + 'name' => $queries[self::ROOT_QUERY]['name'], + 'boost' => 1, + 'matches' => $queries[self::ROOT_QUERY]['match'] + ]; + $arguments = [ + 'name' => $bucket['name'], + 'field' => $bucket['field'], + 'metrics' => [null, null, null, null], + 'ranges' => [null, null, null], + ]; + $this->objectManager->expects($this->any())->method('create') + ->withConsecutive( + [$this->equalTo($queryClass), $this->equalTo($queryArguments)], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][0]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][1]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][2]['type']])], + [$this->equalTo($metricClass), $this->equalTo(['type' => $bucket['metric'][3]['type']])], + [ + $this->equalTo($rangeClass), + $this->equalTo(['from' => $bucket['range'][0]['from'], 'to' => $bucket['range'][0]['to']]) + ], + [ + $this->equalTo($rangeClass), + $this->equalTo(['from' => $bucket['range'][1]['from'], 'to' => $bucket['range'][1]['to']]) + ], + [ + $this->equalTo($rangeClass), + $this->equalTo(['from' => $bucket['range'][2]['from'], 'to' => $bucket['range'][2]['to']]) + ], + [ + $this->equalTo($bucketClass), + $this->equalTo($arguments) + ] + ) + ->will($this->returnValue(null)); + + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ + $mapper = $this->helper->getObject( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $queries, + 'rootQueryName' => self::ROOT_QUERY, + 'aggregation' => [$bucket] + ] + ); + $mapper->getBuckets(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php index 2369f366626..651ec06f746 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php @@ -56,7 +56,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->factory = $helper->getObject( - '\Magento\Framework\Search\RequestFactory', + 'Magento\Framework\Search\RequestFactory', [ 'objectManager' => $this->objectManager, 'config' => $this->config @@ -72,9 +72,13 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'queries' => ':str', 'filters' => 'f', 'query' => 'q', + 'aggregation' => 'a', 'index' => 'i', - 'from' => 1, - 'size' => 15 + 'from' => '1', + 'size' => '15', + 'demensions' => [ + 'name' => ['name' =>'', 'value' => ''] + ] ]; $mappedQuery = $configData['query'] . 'Mapped'; $this->config->expects($this->once())->method('get')->with($this->equalTo($requestName)) @@ -82,6 +86,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Search\Request\Mapper|\PHPUnit_Framework_MockObject_MockObject $mapper */ $mapper = $this->getMockBuilder('Magento\Framework\Search\Request\Mapper') + ->setMethods(['getRootQuery', 'getBuckets']) ->disableOriginalConstructor() ->getMock(); @@ -97,12 +102,32 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase [ 'objectManager' => $this->objectManager, 'queries' => $bindValues[':str'], + 'rootQueryName' => $configData['query'], + 'aggregation' => $configData['aggregation'], 'filters' => $configData['filters'] ] ) ) ->will($this->returnValue($mapper)); + + /** @var \Magento\Framework\Search\Request\Dimension|\PHPUnit_Framework_MockObject_MockObject $dimension */ + $dimension = $this->getMockBuilder('Magento\Framework\Search\Request\Dimension') + ->disableOriginalConstructor() + ->getMock(); + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Dimension'), + $this->equalTo( + [ + 'name' => '', + 'value' => '', + ] + ) + ) + ->will($this->returnValue($dimension)); + + $this->objectManager->expects($this->at(2))->method('create') ->with( $this->equalTo('Magento\Framework\Search\Request'), $this->equalTo( @@ -112,14 +137,18 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'from' => $configData['from'], 'size' => $configData['size'], 'query' => $mappedQuery, + 'demensions' => [ + 'name' => $dimension + ], 'buckets' => [], ] ) ) ->will($this->returnValue($request)); - $mapper->expects($this->once())->method('get')->with($this->equalTo($configData['query'])) + $mapper->expects($this->once())->method('getRootQuery') ->will($this->returnValue($mappedQuery)); + $mapper->expects($this->once())->method('getBuckets')->will($this->returnValue([])); $this->assertEquals($request, $this->factory->create($requestName, $bindValues)); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/SearchEngineTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/SearchEngineTest.php new file mode 100644 index 00000000000..2089b8da4ee --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/SearchEngineTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class SearchEngineTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\SearchEngine + */ + private $searchEngine; + + /** + * @var \Magento\Framework\Search\AdapterInterface |\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $adapterFactory = $this->getMockBuilder('Magento\Framework\Search\AdapterFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('Magento\Framework\Search\AdapterInterface') + ->disableOriginalConstructor() + ->getMock(); + + $adapterFactory->expects($this->once())->method('create')->will($this->returnValue($this->adapter)); + + $this->searchEngine = $helper->getObject( + 'Magento\Framework\Search\SearchEngine', + [ + 'adapterFactory' => $adapterFactory, + ] + ); + } + + public function testSearch() + { + $request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); + + $response = $this->getMockBuilder('Magento\Framework\Search\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter->expects($this->once()) + ->method('query') + ->with($this->equalTo($request)) + ->will($this->returnValue($response)); + + $result = $this->searchEngine->search($request); + $this->assertInstanceOf('Magento\Framework\Search\ResponseInterface', $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php index 08ebe6346e6..281a22b2fb1 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php @@ -105,16 +105,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->config->setOptions(''); } - public function testSetOptionsWrongOption() - { - $this->setExpectedException( - '\InvalidArgumentException', - '"session.0" is not a valid sessions-related ini setting.' - ); - - $this->config->setOptions(array('lol')); - } - /** * @dataProvider optionsProvider */ @@ -168,30 +158,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($original, $this->config->toArray()); } - public function testHasOption() - { - $appStateProperty = new \ReflectionProperty('Magento\Framework\Session\Config', 'options'); - $appStateProperty->setAccessible(true); - $original = $appStateProperty->getValue($this->config); - $valueForTest = array('session.test' => 'test2'); - $appStateProperty->setValue($this->config, $valueForTest); - $this->assertTrue($this->config->hasOption('test')); - $this->assertFalse($this->config->hasOption('no_set')); - $appStateProperty->setValue($this->config, $original); - } - public function testNameIsMutable() { $this->config->setName('FOOBAR'); $this->assertEquals('FOOBAR', $this->config->getName()); } - public function testNameAltersIniSetting() - { - $this->config->setName('FOOBAR'); - $this->assertEquals('FOOBAR', ini_get('session.name')); - } - public function testSaveHandlerDefaultsToIniSettings() { $this->assertSame( @@ -207,23 +179,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals('user', $this->config->getSaveHandler()); } - public function testCookieLifetimeDefaultsToIniSettings() - { - $this->assertSame((int)ini_get('session.cookie_lifetime'), $this->config->getCookieLifetime()); - } - public function testCookieLifetimeIsMutable() { $this->config->setCookieLifetime(20); $this->assertEquals(20, $this->config->getCookieLifetime()); } - public function testCookieLifetimeAltersIniSetting() - { - $this->config->setCookieLifetime(24); - $this->assertEquals(24, ini_get('session.cookie_lifetime')); - } - public function testCookieLifetimeCanBeZero() { $this->config->setCookieLifetime(0); @@ -266,18 +227,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, $this->config->getCookieSecure()); } - public function testCookieSecureAltersIniSetting() - { - $value = ini_get('session.cookie_secure') ? false : true; - $this->config->setCookieSecure($value); - $this->assertEquals($value, ini_get('session.cookie_secure')); - } - - public function testCookieDomainDefaultsToIniSettings() - { - $this->assertSame(ini_get('session.cookie_domain'), $this->config->getCookieDomain()); - } - public function testCookieDomainIsMutable() { $this->config->setCookieDomain('example.com'); @@ -290,12 +239,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', $this->config->getCookieDomain()); } - public function testCookieDomainAltersIniSetting() - { - $this->config->setCookieDomain('localhost'); - $this->assertEquals('localhost', ini_get('session.cookie_domain')); - } - public function testSettingInvalidCookieDomainRaisesException() { $this->setExpectedException('\InvalidArgumentException', 'Invalid cookie domain: must be a string'); @@ -323,13 +266,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, $this->config->getCookieHttpOnly()); } - public function testCookieHttpOnlyAltersIniSetting() - { - $value = ini_get('session.cookie_httponly') ? false : true; - $this->config->setCookieHttpOnly($value); - $this->assertEquals($value, ini_get('session.cookie_httponly')); - } - public function testUseCookiesDefaultsToIniSettings() { $this->assertSame((bool)ini_get('session.use_cookies'), $this->config->getUseCookies()); @@ -342,13 +278,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, (bool)$this->config->getUseCookies()); } - public function testUseCookiesAltersIniSetting() - { - $value = ini_get('session.use_cookies') ? false : true; - $this->config->setUseCookies($value); - $this->assertEquals($value, (bool)ini_get('session.use_cookies')); - } - public function testUseOnlyCookiesDefaultsToIniSettings() { $this->assertSame((bool)ini_get('session.use_only_cookies'), $this->config->getUseOnlyCookies()); @@ -361,13 +290,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, (bool)$this->config->getOption('use_only_cookies')); } - public function testUseOnlyCookiesAltersIniSetting() - { - $value = ini_get('session.use_only_cookies') ? false : true; - $this->config->setOption('use_only_cookies', $value); - $this->assertEquals($value, (bool)ini_get('session.use_only_cookies')); - } - public function testRefererCheckDefaultsToIniSettings() { $this->assertSame(ini_get('session.referer_check'), $this->config->getRefererCheck()); @@ -385,15 +307,40 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals('', $this->config->getOption('referer_check')); } - public function testRefererCheckAltersIniSetting() - { - $this->config->setOption('referer_check', 'BARBAZ'); - $this->assertEquals('BARBAZ', ini_get('session.referer_check')); - } - public function testSetSavePath() { $this->config->setSavePath('some_save_path'); $this->assertEquals($this->config->getOption('save_path'), 'some_save_path'); } + + public function testSetLifetimePath() + { + $getValueReturnMap = [ + [ + 'test_web/test_cookie/test_cookie_lifetime', 'store', null, 7200 + ], + [ + 'web/cookie/cookie_path', 'store', null, '' + ], + ]; + + $this->_configMock + ->method('getValue') + ->will($this->returnValueMap($getValueReturnMap)); + + $config = new \Magento\Framework\Session\Config( + $this->_configMock, + $this->_stringHelperMock, + $this->_requestMock, + $this->_appState, + $this->_filesystem, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, + __DIR__, + null, + 'test_web/test_cookie/test_cookie_lifetime' + ); + + $this->assertEquals(7200, $config->getCookieLifetime()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php index d592e998ff3..0c2c5cec0c9 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -64,7 +64,6 @@ namespace Magento\Framework\Session { return call_user_func_array('\session_regenerate_id', func_get_args()); } - /** * Test SessionManager * @@ -89,6 +88,16 @@ namespace Magento\Framework\Session { */ private $mockSessionConfig; + /** + * @var \Magento\Framework\Stdlib\CookieManager | \PHPUnit_Framework_MockObject_MockObject + */ + private $mockCookieManager; + + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory | \PHPUnit_Framework_MockObject_MockObject + */ + private $mockCookieMetadataFactory; + /** * @var bool */ @@ -101,9 +110,20 @@ namespace Magento\Framework\Session { $this->mockSessionConfig = $this->getMockBuilder('\Magento\Framework\Session\Config\ConfigInterface') ->disableOriginalConstructor() ->getMock(); - + $this->mockCookieManager = $this->getMockBuilder('\Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor() + ->getMock(); + $this->mockCookieMetadataFactory = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + ) + ->disableOriginalConstructor() + ->getMock(); $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $arguments = ['sessionConfig' => $this->mockSessionConfig]; + $arguments = [ + 'sessionConfig' => $this->mockSessionConfig, + 'cookieManager' => $this->mockCookieManager, + 'cookieMetadataFactory' => $this->mockCookieMetadataFactory + ]; $this->sessionManager = $this->objectManager->getObject( 'Magento\Framework\Session\SessionManager', $arguments diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php index a9bc0f038ec..fae8ba2ece2 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php @@ -66,7 +66,9 @@ class PublicCookieMetadataTest extends \PHPUnit_Framework_TestCase "getPath" => ["setPath", 'getPath', "path"], "getDuration" => ["setDuration", 'getDuration', 125], "getHttpOnly" => ["setHttpOnly", 'getHttpOnly', true], - "getSecure" => ["setSecure", 'getSecure', true] + "getSecure" => ["setSecure", 'getSecure', true], + "getDurationOneYear" => ["setDurationOneYear", 'getDuration', (3600*24*365)], ]; } + } diff --git a/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php b/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php index 1ab464ff653..c540d549706 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/UrlTest.php @@ -111,7 +111,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase */ protected function getRequestMock($mockMethods = []) { - $interfaceMethods = array('getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam'); + $interfaceMethods = + ['getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie']; return $this->getMock('Magento\Framework\App\RequestInterface', array_merge($interfaceMethods, $mockMethods)); } @@ -147,11 +148,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase public function getCurrentUrlProvider() { - return array( - 'without_port' => array('', 'http://example.com/fancy_uri'), - 'default_port' => array(80, 'http://example.com/fancy_uri'), - 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri') - ); + return [ + 'without_port' => ['', 'http://example.com/fancy_uri'], + 'default_port' => [80, 'http://example.com/fancy_uri'], + 'custom_port' => [8080, 'http://example.com:8080/fancy_uri'] + ]; } public function testGetUseSession() @@ -175,7 +176,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase $urlType = 'not-link'; $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $baseUrlParams = ['_scope' => $this->scopeMock, '_type' => $urlType, '_secure' => true]; $this->assertEquals($baseUrl, $model->getBaseUrl($baseUrlParams)); @@ -207,7 +210,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase $urlType = \Magento\Framework\UrlInterface::URL_TYPE_LINK; $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') ->will($this->returnValue(['id' => 100])); @@ -234,7 +239,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase ]); $model->setData('route_path', 'catalog/product/view'); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->assertEquals('catalog/product/view', $model->getUrl('catalog/product/view')); } @@ -248,7 +255,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase ]); $model->setData('route_name', 'catalog'); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->assertEquals('/product/view/', $model->getUrl('catalog/product/view')); } @@ -263,7 +272,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase 'request' => $this->getRequestMock(['isDirectAccessFrontendName', 'getAlias']), ]); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->assertEquals('/index/index/foo/bar/', $model->getUrl('catalog')); } @@ -280,7 +291,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase 'request' => $request, ]); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->assertEquals('/catalog/product/view/', $model->getUrl('catalog', ['_use_rewrite' => 1])); } @@ -318,14 +331,18 @@ class UrlTest extends \PHPUnit_Framework_TestCase $urlType = \Magento\Framework\UrlInterface::URL_TYPE_LINK; $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); $this->routeParamsResolverMock->expects($this->any())->method('getRouteParams') ->will($this->returnValue(['key' => 'value'])); $requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true)); $requestMock->expects($this->once())->method('getRequestedRouteName')->will($this->returnValue('catalog')); - $requestMock->expects($this->once())->method('getRequestedControllerName')->will($this->returnValue('product')); + $requestMock->expects($this->once()) + ->method('getRequestedControllerName') + ->will($this->returnValue('product')); $requestMock->expects($this->once())->method('getRequestedActionName')->will($this->returnValue('view')); $routeConfigMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue('catalog')); @@ -347,7 +364,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase $urlType = \Magento\Framework\UrlInterface::URL_TYPE_LINK; $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue($baseUrl)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->routeParamsResolverMock->expects($this->any())->method('getType')->will($this->returnValue($urlType)); $requestMock->expects($this->once())->method('isDirectAccessFrontendName')->will($this->returnValue(true)); @@ -390,7 +409,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->routeParamsResolverMock->expects($this->once())->method('hasData')->with('secure_is_forced') ->will($this->returnValue(true)); $this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam'); - $this->queryParamsResolverMock->expects($this->once())->method('getQuery')->will($this->returnValue('foo=bar')); + $this->queryParamsResolverMock->expects($this->once()) + ->method('getQuery') + ->will($this->returnValue('foo=bar')); $this->assertEquals('http://example.com/?foo=bar', $model->getRedirectUrl('http://example.com/')); } @@ -407,7 +428,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('session-id')); $this->sidResolverMock->expects($this->once())->method('getUseSessionVar')->will($this->returnValue(false)); $this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam'); - $this->queryParamsResolverMock->expects($this->once())->method('getQuery')->will($this->returnValue('foo=bar')); + $this->queryParamsResolverMock->expects($this->once()) + ->method('getQuery') + ->will($this->returnValue('foo=bar')); $this->assertEquals('http://example.com/?foo=bar', $model->getRedirectUrl('http://example.com/')); } @@ -496,13 +519,17 @@ class UrlTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('http://localhost/')); $this->routeParamsResolverMock->expects($this->at(0))->method('hasData')->with('secure_is_forced') ->will($this->returnValue(false)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->scopeMock->expects($this->once())->method('isUrlSecure')->will($this->returnValue(true)); $this->routeParamsResolverMock->expects($this->at(1))->method('hasData')->with('secure') ->will($this->returnValue(false)); $this->routeParamsResolverMock->expects($this->any())->method('getType') ->will($this->returnValue($urlType)); - $this->routeParamsResolverMock->expects($this->once())->method('getData')->will($this->returnValue($isSecure)); + $this->routeParamsResolverMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($isSecure)); $urlSecurityInfoMock->expects($this->exactly($isSecureCallCount))->method('isSecure') ->will($this->returnValue(false)); @@ -534,7 +561,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->scopeConfig->expects($this->any()) ->method('getValue') ->with( - 'web/secure/base_url_secure_forced', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->scopeMock + 'web/secure/base_url_secure_forced', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this->scopeMock ) ->will($this->returnValue('http://localhost/')); $this->routeParamsResolverMock->expects($this->once())->method('hasData')->with('secure_is_forced') @@ -542,7 +570,9 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->routeParamsResolverMock->expects($this->once())->method('getData')->with('secure') ->will($this->returnValue(true)); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->assertEquals('http://localhost/', $model->getConfigData('base_url_secure_forced')); } @@ -559,10 +589,17 @@ class UrlTest extends \PHPUnit_Framework_TestCase 'scopeResolver' => $this->scopeResolverMock, 'routeParamsResolver' => $this->getRouteParamsResolver()] ); - $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost')); - $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://localhost')); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); - $this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam'); + $requestMock->expects($this->once()) + ->method('getHttpHost') + ->will($this->returnValue('localhost')); + $this->scopeMock->expects($this->once()) + ->method('getBaseUrl') + ->will($this->returnValue('http://localhost')); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); + $this->sidResolverMock->expects($this->never()) + ->method('getSessionIdQueryParam'); $this->assertEquals($result, $model->sessionUrlVar($html)); } @@ -576,8 +613,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase ); $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('localhost')); - $this->scopeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com')); - $this->scopeResolverMock->expects($this->any())->method('getScope')->will($this->returnValue($this->scopeMock)); + $this->scopeMock->expects($this->once()) + ->method('getBaseUrl') + ->will($this->returnValue('http://example.com')); + $this->scopeResolverMock->expects($this->any()) + ->method('getScope') + ->will($this->returnValue($this->scopeMock)); $this->sidResolverMock->expects($this->once())->method('getSessionIdQueryParam') ->will($this->returnValue('SID')); $this->sessionMock->expects($this->once())->method('getSessionId') diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php index 26882499d59..dff4e4e7ef8 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php @@ -23,6 +23,8 @@ */ namespace Magento\PageCache\Model\App\FrontController; +use Magento\TestFramework\Helper\ObjectManager; + /** * Class MessageBoxTest */ @@ -36,16 +38,25 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase protected $msgBox; /** - * @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject + * Cookie manager mock + * + * @var \Magento\Framework\Stdlib\CookieManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieManagerMock; + + /** + * Public cookie metadata mock + * + * @var \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata|\PHPUnit_Framework_MockObject_MockObject */ - protected $configMock; + protected $publicCookieMetadataMock; /** - * Cookie mock + * Cookie metadata factory mock * - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $cookieMock; + protected $cookieMetadataFactoryMock; /** * Request mock @@ -69,23 +80,34 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase */ protected $responseMock; - /** - * Create cookie and request mock, version instance - */ public function setUp() { - $this->cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', array('isPost'), array(), '', false); - $this->configMock = $this->getMock('Magento\PageCache\Model\Config', array('isEnabled'), array(), '', false); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor() + ->getMock(); + $this->cookieMetadataFactoryMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + )->disableOriginalConstructor() + ->getMock(); + $this->publicCookieMetadataMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + )->disableOriginalConstructor() + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') ->disableOriginalConstructor() ->getMock(); - $this->msgBox = new MessageBox( - $this->cookieMock, - $this->requestMock, - $this->configMock, - $this->messageManagerMock + $this->msgBox = (new ObjectManager($this))->getObject( + 'Magento\PageCache\Model\App\FrontController\MessageBox', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + 'request' => $this->requestMock, + 'messageManager' => $this->messageManagerMock, + ] ); $this->objectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); @@ -93,46 +115,49 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase } /** - * Handle private content message box cookie - * Set cookie if it is not set. - * Set or unset cookie on post request - * In all other cases do nothing. + * @param bool $isPost + * @param int $numOfCalls + * @dataProvider afterDispatchTestDataProvider */ - public function testAfterDispatch() + public function testAfterDispatch($isPost, $numOfCalls) { - $this->messageManagerMock->expects($this->once()) + $this->messageManagerMock->expects($this->exactly($numOfCalls)) ->method('hasMessages') ->will($this->returnValue(true)); $this->requestMock->expects($this->once()) ->method('isPost') - ->will($this->returnValue(true)); - $this->cookieMock->expects($this->once()) - ->method('set') + ->will($this->returnValue($isPost)); + $this->cookieMetadataFactoryMock->expects($this->exactly($numOfCalls)) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($this->publicCookieMetadataMock)); + $this->publicCookieMetadataMock->expects(($this->exactly($numOfCalls))) + ->method('setDuration') + ->with(MessageBox::COOKIE_PERIOD) + ->will($this->returnValue($this->publicCookieMetadataMock)); + $this->publicCookieMetadataMock->expects(($this->exactly($numOfCalls))) + ->method('setPath') + ->with('/') + ->will($this->returnValue($this->publicCookieMetadataMock)); + $this->cookieManagerMock->expects($this->exactly($numOfCalls)) + ->method('setPublicCookie') ->with( - $this->equalTo(MessageBox::COOKIE_NAME), + MessageBox::COOKIE_NAME, 1, - $this->equalTo(MessageBox::COOKIE_PERIOD), - '/' + $this->publicCookieMetadataMock ); - $this->assertInstanceOf( - '\Magento\Framework\App\ResponseInterface', - $this->msgBox->afterDispatch($this->objectMock, $this->responseMock) - ); + $this->assertSame($this->responseMock, $this->msgBox->afterDispatch($this->objectMock, $this->responseMock)); } /** - * IF request is not POST + * Data provider + * + * @return array */ - public function testProcessNoPost() + public function afterDispatchTestDataProvider() { - $this->requestMock->expects($this->once()) - ->method('isPost') - ->will($this->returnValue(false)); - $this->messageManagerMock->expects($this->never()) - ->method('getMessages'); - $this->assertInstanceOf( - '\Magento\Framework\App\ResponseInterface', - $this->msgBox->afterDispatch($this->objectMock, $this->responseMock) - ); + return [ + [true, 1], + [false, 0], + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php index cc748703207..04d046fccae 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php @@ -28,53 +28,80 @@ class SessionTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Persistent\Model\Session */ - protected $_model; + protected $session; /** * @var \Magento\Framework\Session\Config\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $_configMock; + protected $configMock; /** - * @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\CookieManager |\PHPUnit_Framework_MockObject_MockObject */ - protected $_cookieMock; + protected $cookieManagerMock; + + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieMetadataFactoryMock; protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_configMock = $this->getMock('Magento\Framework\Session\Config\ConfigInterface'); - $this->_cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $resourceMock = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb', - array(), '', false, false, true, - array('__wakeup', 'getIdFieldName', 'getConnection', 'beginTransaction', 'delete', 'commit', 'rollBack')); + $this->configMock = $this->getMock('Magento\Framework\Session\Config\ConfigInterface'); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor() + ->getMock(); + $this->cookieMetadataFactoryMock = $this->getMockBuilder( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' + )->disableOriginalConstructor() + ->getMock(); - $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $eventDispatcherMock = $this->getMock( - 'Magento\Framework\Event\ManagerInterface', - array(), - array(), + $resourceMock = $this->getMockForAbstractClass( + 'Magento\Framework\Model\Resource\Db\AbstractDb', + [], '', false, - false + false, + true, + ['__wakeup', 'getIdFieldName', 'getConnection', 'beginTransaction', 'delete', 'commit', 'rollBack'] ); - $cacheManagerMock = $this->getMock('Magento\Framework\App\CacheInterface', array(), array(), '', false, false); - $loggerMock = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); + $actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', array(), array(), '', false + 'Magento\Framework\Model\ActionValidator\RemoveAction', + [], + [], + '', + false ); $actionValidatorMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $context = new \Magento\Framework\Model\Context( - $loggerMock, $eventDispatcherMock, $cacheManagerMock, $appStateMock, $actionValidatorMock + $context = $helper->getObject( + 'Magento\Framework\Model\Context', + [ + 'actionValidator' => $actionValidatorMock, + ] + ); + + $this->session = $helper->getObject( + 'Magento\Persistent\Model\Session', + [ + 'sessionConfig' => $this->configMock, + 'cookieManager' => $this->cookieManagerMock, + 'context' => $context, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + 'resource' => $resourceMock, + ] ); + } - $this->_model = $helper->getObject('Magento\Persistent\Model\Session', array( - 'sessionConfig' => $this->_configMock, - 'cookie' => $this->_cookieMock, - 'resource' => $resourceMock, - 'context' => $context - )); + public function testLoadByCookieKeyWithNull() + { + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') + ->with(\Magento\Persistent\Model\Session::COOKIE_NAME) + ->will($this->returnValue(null)); + $this->session->loadByCookieKey(null); } /** @@ -84,17 +111,112 @@ class SessionTest extends \PHPUnit_Framework_TestCase public function testAfterDeleteCommit() { $cookiePath = 'some_path'; - $this->_configMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($cookiePath)); - $this->_cookieMock->expects( + $this->configMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($cookiePath)); + $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadata') + ->disableOriginalConstructor() + ->getMock(); + $cookieMetadataMock->expects($this->once()) + ->method('setPath') + ->with($cookiePath) + ->will($this->returnSelf()); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createCookieMetadata') + ->will($this->returnValue($cookieMetadataMock)); + $this->cookieManagerMock->expects( $this->once() )->method( - 'set' + 'deleteCookie' )->with( \Magento\Persistent\Model\Session::COOKIE_NAME, - $this->anything(), - $this->anything(), - $cookiePath + $cookieMetadataMock ); - $this->_model->delete(); + $this->session->delete(); + } + + public function testSetPersistentCookie() + { + $cookiePath = 'some_path'; + $duration = 1000; + $key = 'sessionKey'; + $this->session->setKey($key); + $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata') + ->disableOriginalConstructor() + ->getMock(); + $cookieMetadataMock->expects($this->once()) + ->method('setPath') + ->with($cookiePath) + ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->once()) + ->method('setDuration') + ->with($duration) + ->will($this->returnSelf()); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadataMock)); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with( + \Magento\Persistent\Model\Session::COOKIE_NAME, + $key, + $cookieMetadataMock + ); + $this->session->setPersistentCookie($duration, $cookiePath); + } + + /** + * @param $numGetCookieCalls + * @param $numCalls + * @param int $cookieDuration + * @param string $cookieValue + * @param string $cookiePath + * @dataProvider renewPersistentCookieDataProvider + */ + public function testRenewPersistentCookie( + $numGetCookieCalls, + $numCalls, + $cookieDuration = 1000, + $cookieValue = 'cookieValue', + $cookiePath = 'cookiePath' + ) { + $cookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata') + ->disableOriginalConstructor() + ->getMock(); + $cookieMetadataMock->expects($this->exactly($numCalls)) + ->method('setPath') + ->with($cookiePath) + ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->exactly($numCalls)) + ->method('setDuration') + ->with($cookieDuration) + ->will($this->returnSelf()); + $this->cookieMetadataFactoryMock->expects($this->exactly($numCalls)) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadataMock)); + $this->cookieManagerMock->expects($this->exactly($numGetCookieCalls)) + ->method('getCookie') + ->with(\Magento\Persistent\Model\Session::COOKIE_NAME) + ->will($this->returnValue($cookieValue)); + $this->cookieManagerMock->expects($this->exactly($numCalls)) + ->method('setPublicCookie') + ->with( + \Magento\Persistent\Model\Session::COOKIE_NAME, + $cookieValue, + $cookieMetadataMock + ); + $this->session->renewPersistentCookie($cookieDuration, $cookiePath); + } + + /** + * Data provider for testRenewPersistentCookie + * + * @return array + */ + public function renewPersistentCookieDataProvider() + { + return [ + 'no duration' => [0, 0, null ], + 'no cookie' => [1, 0, 1000, null], + 'all' => [1, 1, ], + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php index 0629194aa7e..c131a2f30ae 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php @@ -139,7 +139,8 @@ class PostTest extends \PHPUnit_Framework_TestCase 'setModuleName', 'getActionName', 'setActionName', - 'getParam' + 'getParam', + 'getCookie' ); $this->_registryMock = $this->getMock('Magento\Framework\Registry', array(), array(), '', false); $this->_requestMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Rss/Model/RssTest.php b/dev/tests/unit/testsuite/Magento/Rss/Model/RssTest.php new file mode 100644 index 00000000000..a3c33b42eb1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rss/Model/RssTest.php @@ -0,0 +1,55 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Rss\Model; + +use Magento\TestFramework\Helper\ObjectManager; + +class RssTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rss\Model\Rss + */ + private $model; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->model = $helper->getObject('Magento\Rss\Model\Rss'); + } + + public function testCreateRssXml() + { + $this->model->_addHeader(['title' => 'someTitle', 'link' => 'someLink', 'charset' => 'utf8']); + $result = $this->model->createRssXml(); + + $this->assertContains('<?xml version="1.0" encoding="utf8"?>', $result); + } + + public function testCreateRssXmlError() + { + $this->model->_addHeader(['test']); + $this->assertEquals('Error in processing xml. title key is missing', $this->model->createRssXml()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumnTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumnTest.php new file mode 100644 index 00000000000..6c6deeef03b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumnTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Block\Adminhtml\Items\Column; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class DefaultColumnTest extends \PHPUnit_Framework_TestCase +{ + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** + * @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn + */ + protected $defaultColumn; + + /** + * @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemMock; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->defaultColumn = $this->objectManagerHelper->getObject( + 'Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn' + ); + $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getRowTotal', 'getDiscountAmount', 'getBaseRowTotal', 'getBaseDiscountAmount', '__wakeup']) + ->getMock(); + } + + public function testGetTotalAmount() + { + $rowTotal = 10; + $discountAmount = 2; + $expectedResult = 8; + $this->itemMock->expects($this->once()) + ->method('getRowTotal') + ->will($this->returnValue($rowTotal)); + $this->itemMock->expects($this->once()) + ->method('getDiscountAmount') + ->will($this->returnValue($discountAmount)); + $this->assertEquals($expectedResult, $this->defaultColumn->getTotalAmount($this->itemMock)); + } + + public function testGetBaseTotalAmount() + { + $baseRowTotal = 10; + $baseDiscountAmount = 2; + $expectedResult = 8; + $this->itemMock->expects($this->once()) + ->method('getBaseRowTotal') + ->will($this->returnValue($baseRowTotal)); + $this->itemMock->expects($this->once()) + ->method('getBaseDiscountAmount') + ->will($this->returnValue($baseDiscountAmount)); + $this->assertEquals($expectedResult, $this->defaultColumn->getBaseTotalAmount($this->itemMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php index b72f46f2562..89b00655ed2 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -33,6 +33,24 @@ class GridTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\CatalogInventory\Service\V1\StockItemService */ protected $stockItemService; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Block\Template + */ + protected $priceRenderBlock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Layout + */ + protected $layoutMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Quote\Item */ + protected $itemMock; + /** * Initialize required data */ @@ -76,8 +94,8 @@ class GridTest extends \PHPUnit_Framework_TestCase false ); - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->block = $helper->getObject( + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $this->objectManager->getObject( 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', array( 'wishlistFactory' => $wishlistFactoryMock, @@ -90,6 +108,21 @@ class GridTest extends \PHPUnit_Framework_TestCase 'stockItemService' => $this->stockItemService ) ); + + $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + ->disableOriginalConstructor() + ->setMethods(['setItem', 'toHtml']) + ->getMock(); + + $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['__wakeup']) + ->getMock(); } /** @@ -222,4 +255,88 @@ class GridTest extends \PHPUnit_Framework_TestCase $this->assertEquals('Message', $items[0]->getMessage()); $this->assertEquals(true, $this->block->getQuote()->getIsSuperMode()); } + + protected function getGrid() + { + /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid $grid */ + $grid = $this->objectManager->getObject( + 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', + array( + 'context' => $this->objectManager->getObject( + 'Magento\Backend\Block\Template\Context', + array('layout' => $this->layoutMock) + ) + ) + ); + + return $grid; + } + + public function testGetItemUnitPriceHtml() + { + $html = '$34.28'; + + $grid = $this->getGrid(); + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_unit_price') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $grid->getItemUnitPriceHtml($this->itemMock)); + } + + public function testGetItemRowTotalHtml() + { + $html = '$34.28'; + + $grid = $this->getGrid(); + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_row_total') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $grid->getItemRowTotalHtml($this->itemMock)); + } + public function testGetItemRowTotalWithDiscountHtml() + { + $html = '$34.28'; + + $grid = $this->getGrid(); + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_row_total_with_discount') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $grid->getItemRowTotalWithDiscountHtml($this->itemMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/DefaultItemsTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/DefaultItemsTest.php new file mode 100644 index 00000000000..f6a884be43a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/DefaultItemsTest.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Block\Order\Email\Items; + +class DefaultItemsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Block\Order\Email\Items\DefaultItem + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Block\Template + */ + protected $priceRenderBlock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Layout + */ + protected $layoutMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Quote\Item */ + protected $itemMock; + + /** + * Initialize required data + */ + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->block = $this->objectManager->getObject( + 'Magento\Sales\Block\Order\Email\Items\DefaultItems', + array( + 'context' => $this->objectManager->getObject( + 'Magento\Backend\Block\Template\Context', + array('layout' => $this->layoutMock) + ) + ) + ); + + $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + ->disableOriginalConstructor() + ->setMethods(['setItem', 'toHtml']) + ->getMock(); + + $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['__wakeup']) + ->getMock(); + } + + public function testGetItemPrice() + { + $html = '$34.28'; + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_price') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $this->block->getItemPrice($this->itemMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrderTest.php new file mode 100644 index 00000000000..57eb9725fbf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Email/Items/Order/DefaultOrderTest.php @@ -0,0 +1,104 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Block\Order\Email\Items\Order; + +class DefaultOrderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Block\Template + */ + protected $priceRenderBlock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Layout + */ + protected $layoutMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Quote\Item */ + protected $itemMock; + + /** + * Initialize required data + */ + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->block = $this->objectManager->getObject( + 'Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder', + array( + 'context' => $this->objectManager->getObject( + 'Magento\Backend\Block\Template\Context', + array('layout' => $this->layoutMock) + ) + ) + ); + + $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + ->disableOriginalConstructor() + ->setMethods(['setItem', 'toHtml']) + ->getMock(); + + $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['__wakeup']) + ->getMock(); + } + + public function testGetItemPrice() + { + $html = '$34.28'; + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_price') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $this->block->getItemPrice($this->itemMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php new file mode 100644 index 00000000000..9ed75ece652 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php @@ -0,0 +1,182 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Block\Order\Item\Renderer; + +class DefaultRendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Block\Template + */ + protected $priceRenderBlock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Layout + */ + protected $layoutMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Quote\Item */ + protected $itemMock; + + /** + * Initialize required data + */ + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->block = $this->objectManager->getObject( + 'Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer', + array( + 'context' => $this->objectManager->getObject( + 'Magento\Backend\Block\Template\Context', + array('layout' => $this->layoutMock) + ) + ) + ); + + $this->priceRenderBlock = $this->getMockBuilder('\Magento\Backend\Block\Template') + ->disableOriginalConstructor() + ->setMethods(['setItem', 'toHtml']) + ->getMock(); + + $itemMockMethods = [ + '__wakeup', + 'getRowTotal', + 'getTaxAmount', + 'getDiscountAmount', + 'getHiddenTaxAmount', + 'getWeeeTaxAppliedRowAmount' + ]; + $this->itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods($itemMockMethods) + ->getMock(); + } + + public function testGetItemPriceHtml() + { + $html = '$34.28'; + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_unit_price') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $this->block->getItemPriceHtml($this->itemMock)); + } + + public function testGetItemRowTotalHtml() + { + $html = '$34.28'; + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_row_total') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $this->block->getItemRowTotalHtml($this->itemMock)); + } + + public function testGetItemRowTotalAfterDiscountHtml() + { + $html = '$34.28'; + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with('item_row_total_after_discount') + ->will($this->returnValue($this->priceRenderBlock)); + + $this->priceRenderBlock->expects($this->once()) + ->method('setItem') + ->with($this->itemMock); + + $this->priceRenderBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + + + $this->assertEquals($html, $this->block->getItemRowTotalAfterDiscountHtml($this->itemMock)); + } + + public function testGetTotalAmount() + { + $rowTotal = 100; + $taxAmount = 10; + $hiddenTaxAmount = 2; + $discountAmount = 20; + $weeeTaxAppliedRowAmount = 10; + + $expectedResult = $rowTotal + $taxAmount + $hiddenTaxAmount - $discountAmount + $weeeTaxAppliedRowAmount; + $this->itemMock->expects($this->once()) + ->method('getRowTotal') + ->will($this->returnValue($rowTotal)); + $this->itemMock->expects($this->once()) + ->method('getTaxAmount') + ->will($this->returnValue($taxAmount)); + $this->itemMock->expects($this->once()) + ->method('getHiddenTaxAmount') + ->will($this->returnValue($hiddenTaxAmount)); + $this->itemMock->expects($this->once()) + ->method('getDiscountAmount') + ->will($this->returnValue($discountAmount)); + $this->itemMock->expects($this->once()) + ->method('getWeeeTaxAppliedRowAmount') + ->will($this->returnValue($weeeTaxAppliedRowAmount)); + + $this->assertEquals($expectedResult, $this->block->getTotalAmount($this->itemMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php new file mode 100644 index 00000000000..b56d65e0a06 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/EmailTest.php @@ -0,0 +1,247 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\Action\Context; + +/** + * Class EmailTest + * + * @package Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo + */ +class EmailTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Email + */ + protected $creditmemoEmail; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getMessageManager', + 'getRedirect', + 'getObjectManager', + 'getSession', + 'getActionFlag', + 'getHelper' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], + '', + false + ); + $this->objectManager = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManager = $this->getMock('Magento\Framework\Message\Manager', ['addSuccess'], [], '', false); + $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->context->expects($this->once()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManager)); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->session)); + $this->context->expects($this->once()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlag)); + $this->context->expects($this->once()) + ->method('getHelper') + ->will($this->returnValue($this->helper)); + $this->creditmemoEmail = $objectManagerHelper->getObject( + 'Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo\Email', + [ + 'context' => $this->context, + 'request' => $this->request, + 'response' => $this->response + ] + ); + } + + public function testEmail() + { + $cmId = 10000031; + $creditmemoClassName = 'Magento\Sales\Model\Order\Creditmemo'; + $cmNotifierClassName = 'Magento\Sales\Model\Order\CreditmemoNotifier'; + $creditmemo = $this->getMock($creditmemoClassName, ['load', '__wakeup'], [], '', false); + $cmNotifier = $this->getMock($cmNotifierClassName, ['notify', '__wakeup'], [], '', false); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('creditmemo_id') + ->will($this->returnValue($cmId)); + $this->objectManager->expects($this->at(0)) + ->method('create') + ->with($creditmemoClassName) + ->will($this->returnValue($creditmemo)); + $creditmemo->expects($this->once()) + ->method('load') + ->with($cmId) + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1)) + ->method('create') + ->with($cmNotifierClassName) + ->will($this->returnValue($cmNotifier)); + $cmNotifier->expects($this->once()) + ->method('notify') + ->will($this->returnValue(true)); + $this->messageManager->expects($this->once()) + ->method('addSuccess') + ->with('We sent the message.'); + + $this->prepareRedirect($cmId); + + $this->creditmemoEmail->execute(); + $this->assertEquals($this->response, $this->creditmemoEmail->getResponse()); + } + + public function testEmailNoCreditmemoId() + { + $this->request->expects($this->once()) + ->method('getParam') + ->with('creditmemo_id') + ->will($this->returnValue(null)); + $this->assertNull($this->creditmemoEmail->execute()); + } + + public function testEmailNoCreditmemo() + { + $cmId = 10000031; + $creditmemoClassName = 'Magento\Sales\Model\Order\Creditmemo'; + $creditmemo = $this->getMock($creditmemoClassName, ['load', '__wakeup'], [], '', false); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('creditmemo_id') + ->will($this->returnValue($cmId)); + $this->objectManager->expects($this->at(0)) + ->method('create') + ->with($creditmemoClassName) + ->will($this->returnValue($creditmemo)); + $creditmemo->expects($this->once()) + ->method('load') + ->with($cmId) + ->will($this->returnValue(null)); + + $this->assertNull($this->creditmemoEmail->execute()); + } + + /** + * @param int $cmId + */ + protected function prepareRedirect($cmId) + { + $this->actionFlag->expects($this->once()) + ->method('get') + ->with('', 'check_url_settings') + ->will($this->returnValue(true)); + $this->session->expects($this->once()) + ->method('setIsUrlNotice') + ->with(true); + $path = 'sales/order_creditmemo/view'; + $this->response->expects($this->once()) + ->method('setRedirect') + ->with($path . '/' . $cmId); + $this->helper->expects($this->atLeastOnce()) + ->method('getUrl') + ->with($path, ['creditmemo_id' => $cmId]) + ->will($this->returnValue($path . '/' . $cmId)); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php new file mode 100644 index 00000000000..077fe253021 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php @@ -0,0 +1,254 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class AddCommentTest + */ +class AddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\AddComment + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + public function setUp() + { + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->senderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\AddComment( + $this->contextMock, + $this->loaderMock, + $this->senderMock + ); + } + + public function testExecuteModelException() + { + $message = 'Model exception'; + $e = new \Magento\Framework\Model\Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->requestMock->expects($this->any()) + ->method('setParam') + ->will($this->throwException($e)); + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->willReturn(json_encode($response)); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->willReturn($helperMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $message = 'Cannot add new comment.'; + $e = new \Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->requestMock->expects($this->any()) + ->method('setParam') + ->will($this->throwException($e)); + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->willReturn(json_encode($response)); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->willReturn($helperMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoComment() + { + $message = 'The Comment Text field cannot be empty.'; + $response = ['error' => true, 'message' => $message]; + $data = []; + + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->willReturn(json_encode($response)); + + $this->requestMock->expects($this->once()) + ->method('getPost') + ->with('comment') + ->willReturn($data); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->willReturn($helperMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $comment = 'Test comment'; + $data = ['comment' => $comment]; + $html = 'test output'; + + $this->requestMock->expects($this->once()) + ->method('getPost') + ->with('comment') + ->willReturn($data); + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Comment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoMock->expects($this->once()) + ->method('addComment') + ->withAnyParameters() + ->willReturn($commentMock); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($creditmemoMock); + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Comments') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMock->expects($this->once()) + ->method('toHtml') + ->willReturn($html); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('creditmemo_comments') + ->willReturn($blockMock); + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->willReturn($layoutMock); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php new file mode 100644 index 00000000000..d8f6b8053a9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/CancelTest.php @@ -0,0 +1,262 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class CancelTest + */ +class CancelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Cancel + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + public function setUp() + { + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->getMock(); + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Cancel( + $this->contextMock, + $this->loaderMock + ); + } + + public function testExecuteModelException() + { + $message = 'Model exception'; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->creditmemoMock->expects($this->once()) + ->method('cancel') + ->willThrowException($e); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $message = 'Model exception'; + $e = new \Exception($message); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->creditmemoMock->expects($this->once()) + ->method('cancel') + ->willThrowException($e); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoCreditmemo() + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn(false); + + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->willReturn($transactionMock); + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoMock->expects($this->any()) + ->method('getOrder') + ->willReturn($orderMock); + $this->creditmemoMock->expects($this->any()) + ->method('getInvoice') + ->willReturn($invoiceMock); + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('The credit memo has been canceled.'); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php new file mode 100644 index 00000000000..8dddadfad39 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewActionTest.php @@ -0,0 +1,281 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class NewActionTest + */ +class NewActionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\NewAction + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\App\Action\Context + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader + */ + protected $creditmemoLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ResponseInterface + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Creditmemo + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Invoice + */ + protected $invoiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Action\Title + */ + protected $titleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManager + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Session + */ + protected $backendSessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\ViewInterface + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\LayoutInterface + */ + protected $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\View\Element\BlockInterface + */ + protected $blockMenuMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Menu + */ + protected $modelMenuMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Menu\Item + */ + protected $modelMenuItem; + + public function setUp() + { + $this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false); + $this->creditmemoLoaderMock = $this->getMock( + 'Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader', + ['setOrderId', 'setCreditmemoId', 'setCreditmemo', 'setInvoiceId', 'load'], + [], + '', + false + ); + $this->creditmemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + ['getInvoice', '__wakeup', 'setCommentText'], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + ['getIncrementId', '__wakeup'], + [], + '', + false + ); + $this->objectManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManager', + [], + '', + false, + false, + true, + [] + ); + $this->requestMock = $this->getMockForAbstractClass( + 'Magento\Framework\App\RequestInterface', + [], + '', + false, + false, + true, + [] + ); + $this->responseMock = $this->getMockForAbstractClass( + 'Magento\Framework\App\ResponseInterface', + [], + '', + false, + false, + true, + [] + ); + $this->titleMock = $this->getMock('Magento\Framework\App\Action\Title', [], [], '', false); + $this->backendSessionMock = $this->getMock('Magento\Backend\Model\Session', ['getCommentText'], [], '', false); + $this->viewMock = $this->getMockForAbstractClass( + 'Magento\Framework\App\ViewInterface', + [], + '', + false, + false, + true, + [] + ); + $this->layoutMock = $this->getMockForAbstractClass( + 'Magento\Framework\View\LayoutInterface', + [], + '', + false, + false, + true, + [] + ); + $this->blockMenuMock = $this->getMock( + 'Magento\Backend\Block\Menu', + ['setActive', 'getMenuModel'], + [], + '', + false + ); + $this->modelMenuMock = $this->getMock('Magento\Backend\Model\Menu', ['getParentItems'], [], '', false); + $this->modelMenuItem = $this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false); + $this->contextMock->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->once()) + ->method('getTitle') + ->will($this->returnValue($this->titleMock)); + $this->contextMock->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->controller = new NewAction($this->contextMock, $this->creditmemoLoaderMock); + } + + /** + * test execute method + */ + public function testExecute() + { + $this->requestMock->expects($this->exactly(4)) + ->method('getParam') + ->will($this->returnValueMap([ + ['order_id', null, 'order_id'], + ['creditmemo_id', null, 'creditmemo_id'], + ['creditmemo', null, 'creditmemo'], + ['invoice_id', null, 'invoice_id'], + ])); + $this->creditmemoLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($this->equalTo('order_id')); + $this->creditmemoLoaderMock->expects($this->once()) + ->method('setCreditmemoId') + ->with($this->equalTo('creditmemo_id')); + $this->creditmemoLoaderMock->expects($this->once()) + ->method('setCreditmemo') + ->with($this->equalTo('creditmemo')); + $this->creditmemoLoaderMock->expects($this->once()) + ->method('setInvoiceId') + ->with($this->equalTo('invoice_id')); + $this->creditmemoLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->creditmemoMock)); + $this->creditmemoMock->expects($this->exactly(2)) + ->method('getInvoice') + ->will($this->returnValue($this->invoiceMock)); + $this->invoiceMock->expects($this->once()) + ->method('getIncrementId') + ->will($this->returnValue('invoice-increment-id')); + $this->titleMock->expects($this->exactly(3)) + ->method('add') + ->will($this->returnValueMap([ + ['Credit Memos', null], + ['New Memo for #invoice-increment-id', null], + ['item-title', null], + ])); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with($this->equalTo('Magento\Backend\Model\Session')) + ->will($this->returnValue($this->backendSessionMock)); + $this->backendSessionMock->expects($this->once()) + ->method('getCommentText') + ->with($this->equalTo(true)) + ->will($this->returnValue('comment')); + $this->creditmemoMock->expects($this->once()) + ->method('setCommentText') + ->with($this->equalTo('comment')); + $this->viewMock->expects($this->once()) + ->method('loadLayout'); + $this->viewMock->expects($this->once()) + ->method('renderLayout'); + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($this->layoutMock)); + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with($this->equalTo('menu')) + ->will($this->returnValue($this->blockMenuMock)); + $this->blockMenuMock->expects($this->once()) + ->method('setActive') + ->with($this->equalTo('Magento_Sales::sales_order')); + $this->blockMenuMock->expects($this->once()) + ->method('getMenuModel') + ->will($this->returnValue($this->modelMenuMock)); + $this->modelMenuMock->expects($this->once()) + ->method('getParentItems') + ->will($this->returnValue([$this->modelMenuItem])); + $this->modelMenuItem->expects($this->once()) + ->method('getTitle') + ->will($this->returnValue('item-title')); + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php new file mode 100644 index 00000000000..01fb6bbe984 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/PrintActionTest.php @@ -0,0 +1,209 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class PrintActionTest + */ +class PrintActionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $fileFactoryMock; + + public function setUp() + { + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->getMock(); + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction( + $this->contextMock, + $this->fileFactoryMock, + $this->loaderMock + ); + } + + public function testExecuteModelException() + { + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->willReturn(1); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('creditmemo_id') + ->willReturn(1); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('creditmemo') + ->willReturn('some data'); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('invoice_id') + ->willReturn(1); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php new file mode 100644 index 00000000000..550e79e87cc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php @@ -0,0 +1,263 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class UpdateQtyTest + */ +class UpdateQtyTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\UpdateQty + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + public function setUp() + { + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->getMock(); + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\UpdateQty( + $this->contextMock, + $this->loaderMock + ); + } + + public function testExecuteModelException() + { + $message = 'Model exception'; + $e = new \Magento\Framework\Model\Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willThrowException($e); + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->willReturn(json_encode($response)); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->willReturn($helperMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $message = 'Cannot update the item\'s quantity.'; + $e = new \Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willThrowException($e); + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->willReturn(json_encode($response)); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->willReturn($helperMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $response = 'output'; + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMock = $this->getMockBuilder('Magento\Sales\Block\Order\Items') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMock->expects($this->once()) + ->method('toHtml') + ->willReturn($response); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('order_items') + ->willReturn($blockMock); + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->willReturn($layoutMock); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php new file mode 100644 index 00000000000..b5f4f3c7453 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/ViewTest.php @@ -0,0 +1,253 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class ViewTest + */ +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + public function setUp() + { + $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId']) + ->getMock(); + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View( + $this->contextMock, + $this->loaderMock + ); + } + + public function testExecuteNoCreditMemo() + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn(false); + + $this->assertNull($this->controller->execute()); + } + + /** + * @dataProvider dataProviderForExecute + */ + public function testExecuteNoInvoice($invoice) + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + $this->creditmemoMock->expects($this->any()) + ->method('getInvoice') + ->willReturn($invoice); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockMenuMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + ->disableOriginalConstructor() + ->setMethods(['getMenuModel', 'setActive', 'getParentItems']) + ->getMock(); + $blockMenuMock->expects($this->any()) + ->method('getMenuModel') + ->willReturnSelf(); + $blockMenuMock->expects($this->any()) + ->method('getParentItems') + ->willReturn([]); + $layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with('sales_creditmemo_view') + ->willReturn($blockMock); + $layoutMock->expects($this->at(1)) + ->method('getBlock') + ->with('menu') + ->willReturn($blockMenuMock); + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->willReturn($layoutMock); + + $this->assertNull($this->controller->execute()); + } + + public function dataProviderForExecute() + { + return [ + [false], + [$this->invoiceMock] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php new file mode 100644 index 00000000000..dd37a95be9e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/VoidTest.php @@ -0,0 +1,271 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +/** + * Class VoidTest + */ +class VoidTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\AddComment + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + public function setUp() + { + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', 'void']) + ->getMock(); + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $this->contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $this->contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $this->contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $this->contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->senderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\Void( + $this->contextMock, + $this->loaderMock + ); + } + + public function testExecuteNoCreditmemo() + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn(false); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $message = 'Model exception'; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->creditmemoMock->expects($this->once()) + ->method('void') + ->willThrowException($e); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $message = 'Model exception'; + $e = new \Exception($message); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->creditmemoMock->expects($this->once()) + ->method('void') + ->willThrowException($e); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $this->requestMock->expects($this->any()) + ->method('getParam') + ->withAnyParameters() + ->willReturnArgument(0); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($this->creditmemoMock); + $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->willReturn($transactionMock); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoMock->expects($this->any()) + ->method('getOrder') + ->willReturn($orderMock); + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoMock->expects($this->any()) + ->method('getInvoice') + ->willReturn($invoiceMock); + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('You voided the credit memo.'); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoaderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoaderTest.php new file mode 100644 index 00000000000..ff9459bb113 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoaderTest.php @@ -0,0 +1,274 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order; + +use Magento\Backend\App\Action; + +/** + * Class CreditmemoLoaderTest + */ +class CreditmemoLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader + */ + protected $loader; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $serviceOrderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + public function setUp() + { + $data = []; + $this->creditmemoFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\CreditmemoFactory') + ->disableOriginalConstructor() + ->setMethods(['create', 'get']) + ->getMock(); + $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->invoiceFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\InvoiceFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->serviceOrderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Service\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->helperMock = $this->getMockBuilder('Magento\CatalogInventory\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->loader = new \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader( + $this->creditmemoFactoryMock, + $this->orderFactoryMock, + $this->invoiceFactoryMock, + $this->serviceOrderFactoryMock, + $this->eventManagerMock, + $this->sessionMock, + $this->messageManagerMock, + $this->registryMock, + $this->helperMock, + $data + ); + } + + public function testLoadByCreditmemoId() + { + $this->loader->setCreditmemoId(1); + $this->loader->setOrderId(1); + $this->loader->setCreditmemo('test'); + + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoMock->expects($this->once()) + ->method('load') + ->willReturnSelf(); + $this->creditmemoFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($creditmemoMock); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo', $this->loader->load()); + } + + public function testLoadCannotCreditmemo() + { + $this->loader->setCreditmemoId(0); + $this->loader->setOrderId(1); + $this->loader->setCreditmemo('test'); + $this->loader->setInvoiceId(1); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $orderMock->expects($this->once()) + ->method('load') + ->willReturnSelf(); + $orderMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + $orderMock->expects($this->once()) + ->method('canCreditmemo') + ->willReturn(false); + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($orderMock); + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $invoiceMock->expects($this->any()) + ->method('setOrder') + ->willReturnSelf(); + $invoiceMock->expects($this->any()) + ->method('getId') + ->willReturn(1); + $this->invoiceFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($invoiceMock); + + $this->assertFalse($this->loader->load()); + } + + public function testLoadByOrder() + { + $qty = 1; + $data = ['items' => [1 => ['qty' => $qty, 'back_to_stock' => true]]]; + $this->loader->setCreditmemoId(0); + $this->loader->setOrderId(1); + $this->loader->setCreditmemo($data); + $this->loader->setInvoiceId(1); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $orderMock->expects($this->once()) + ->method('load') + ->willReturnSelf(); + $orderMock->expects($this->once()) + ->method('getId') + ->willReturn(1); + $orderMock->expects($this->once()) + ->method('canCreditmemo') + ->willReturn(true); + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($orderMock); + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $invoiceMock->expects($this->any()) + ->method('setOrder') + ->willReturnSelf(); + $invoiceMock->expects($this->any()) + ->method('getId') + ->willReturn(1); + $this->invoiceFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($invoiceMock); + $serviceOrder = $this->getMockBuilder('Magento\Sales\Model\Service\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $orderItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoItemMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Item') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoItemMock->expects($this->any()) + ->method('getOrderItem') + ->willReturn($orderItemMock); + $items = [$creditmemoItemMock, $creditmemoItemMock, $creditmemoItemMock]; + $creditmemoMock->expects($this->any()) + ->method('getAllItems') + ->willReturn($items); + $serviceOrder->expects($this->any()) + ->method('prepareInvoiceCreditmemo') + ->willReturn($creditmemoMock); + $this->serviceOrderFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($serviceOrder); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo', $this->loader->load()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php new file mode 100644 index 00000000000..a14e60ea6b1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php @@ -0,0 +1,260 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Controller\Adminhtml\Order; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\Action\Context; + +/** + * Class EmailTest + * + * @package Magento\Sales\Controller\Adminhtml\Order + */ +class EmailTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Email + */ + protected $orderEmail; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getMessageManager', + 'getRedirect', + 'getObjectManager', + 'getSession', + 'getActionFlag', + 'getHelper' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], + '', + false + ); + $this->objectManager = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManager = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get', 'set'], [], '', false); + $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->context->expects($this->once()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManager)); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->session)); + $this->context->expects($this->once()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlag)); + $this->context->expects($this->once()) + ->method('getHelper') + ->will($this->returnValue($this->helper)); + $this->orderEmail = $objectManagerHelper->getObject( + 'Magento\Sales\Controller\Adminhtml\Order\Email', + [ + 'context' => $this->context, + 'request' => $this->request, + 'response' => $this->response + ] + ); + } + + public function testEmail() + { + $orderId = 10000031; + $orderClassName = 'Magento\Sales\Model\Order'; + $orderNotifierClassName = 'Magento\Sales\Model\OrderNotifier'; + $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false); + $cmNotifier = $this->getMock($orderNotifierClassName, ['notify', '__wakeup'], [], '', false); + + $this->request->expects($this->once()) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->objectManager->expects($this->at(0)) + ->method('create') + ->with($orderClassName) + ->will($this->returnValue($order)); + $order->expects($this->once()) + ->method('load') + ->with($orderId) + ->will($this->returnSelf()); + $order->expects($this->atLeastOnce()) + ->method('getId') + ->will($this->returnValue($orderId)); + $this->objectManager->expects($this->at(1)) + ->method('create') + ->with($orderNotifierClassName) + ->will($this->returnValue($cmNotifier)); + $cmNotifier->expects($this->once()) + ->method('notify') + ->will($this->returnValue(true)); + $this->messageManager->expects($this->once()) + ->method('addSuccess') + ->with('You sent the order email.'); + $path = 'sales/order/view'; + $arguments = ['order_id' => $orderId]; + $this->prepareRedirect($path, $arguments, 0); + + $this->orderEmail->execute(); + $this->assertEquals($this->response, $this->orderEmail->getResponse()); + } + + public function testEmailNoOrderId() + { + $orderClassName = 'Magento\Sales\Model\Order'; + $order = $this->getMock($orderClassName, ['load', 'getId', '__wakeup'], [], '', false); + $this->request->expects($this->once()) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue(null)); + + $this->objectManager->expects($this->at(0)) + ->method('create') + ->with($orderClassName) + ->will($this->returnValue($order)); + $order->expects($this->once()) + ->method('load') + ->with(null) + ->will($this->returnSelf()); + $this->messageManager->expects($this->once()) + ->method('addError') + ->with('This order no longer exists.'); + + $this->actionFlag->expects($this->once()) + ->method('set') + ->with('', 'no-dispatch', true) + ->will($this->returnValue(true)); + $path = 'sales/*/'; + $this->prepareRedirect($path, [], 0); + + $this->assertNull($this->orderEmail->execute()); + } + + /** + * @param string $path + * @param array $arguments + * @param int $index + */ + protected function prepareRedirect($path, $arguments, $index) + { + $this->actionFlag->expects($this->any()) + ->method('get') + ->with('', 'check_url_settings') + ->will($this->returnValue(true)); + $this->session->expects($this->any()) + ->method('setIsUrlNotice') + ->with(true); + + $url = $path . '/' . (!empty($arguments) ? $arguments['order_id'] : ''); + $this->helper->expects($this->at($index)) + ->method('getUrl') + ->with($path, $arguments) + ->will($this->returnValue($url)); + $this->response->expects($this->at($index)) + ->method('setRedirect') + ->with($url); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php new file mode 100644 index 00000000000..4bf524f2f63 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -0,0 +1,257 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class AddCommentTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class AddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $commentSenderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment + */ + protected $controller; + + public function setUp() + { + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->commentSenderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment( + $contextMock, + $this->invoiceLoaderMock, + $this->commentSenderMock + ); + } + + public function testExecute() + { + $data = ['comment' => 'test comment']; + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + $response = 'some result'; + + $this->requestMock->expects($this->once()) + ->method('getPost') + ->with('comment') + ->will($this->returnValue($data)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(4)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(5)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('addComment') + ->with($data['comment'], false, false); + $invoiceMock->expects($this->once()) + ->method('save'); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $commentsBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View\Comments') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $commentsBlockMock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($response)); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('invoice_comments') + ->will($this->returnValue($commentsBlockMock)); + + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + + $this->commentSenderMock->expects($this->once()) + ->method('send') + ->with($invoiceMock, false, $data['comment']); + + $this->responseMock->expects($this->once()) + ->method('setBody') + ->with($response); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $message = 'model exception'; + $response = ['error' => true, 'message' => $message]; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->will($this->throwException($e)); + + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->will($this->returnValue(json_encode($response))); + + $this->responseMock->expects($this->once()) + ->method('representJson') + ->with(json_encode($response)); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->will($this->returnValue($helperMock)); + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $response = ['error' => true, 'message' => 'Cannot add new comment.']; + $e = new \Exception('test'); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->will($this->throwException($e)); + + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->will($this->returnValue(json_encode($response))); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->will($this->returnValue($helperMock)); + + $this->responseMock->expects($this->once()) + ->method('representJson') + ->with(json_encode($response)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php new file mode 100644 index 00000000000..1f5b91328c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -0,0 +1,327 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class CancelTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class CancelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel + */ + protected $controller; + + public function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['setIsInProcess']) + ->getMock(); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('cancel'); + $invoiceMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $transactionMock->expects($this->at(0)) + ->method('addObject') + ->with($invoiceMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(1)) + ->method('addObject') + ->with($orderMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(2)) + ->method('save'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('You canceled the invoice.'); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->will($this->returnValue($transactionMock)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoInvoice() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue(false)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $message = 'model exception'; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('cancel') + ->will($this->throwException($e)); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with($message); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $message = 'Invoice canceling error'; + $e = new \Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('cancel') + ->will($this->throwException($e)); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with($message); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php new file mode 100644 index 00000000000..acaf5a8db42 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -0,0 +1,327 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class CaptureTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class CaptureTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture + */ + protected $controller; + + public function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['setIsInProcess']) + ->getMock(); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('capture'); + $invoiceMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $transactionMock->expects($this->at(0)) + ->method('addObject') + ->with($invoiceMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(1)) + ->method('addObject') + ->with($orderMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(2)) + ->method('save'); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('The invoice has been captured.'); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->will($this->returnValue($transactionMock)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoInvoice() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue(false)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $message = 'model exception'; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('capture') + ->will($this->throwException($e)); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with($message); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $message = 'Invoice capturing error'; + $e = new \Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('capture') + ->will($this->throwException($e)); + + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with($message); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php new file mode 100644 index 00000000000..f0779b82e77 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php @@ -0,0 +1,254 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +/** + * Class NewActionTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class NewActionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\NewAction + */ + protected $controller; + + public function setUp() + { + $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['getCommentText', 'setIsUrlNotice']) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($titleMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\NewAction( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + $commentText = 'comment test'; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + ->disableOriginalConstructor() + ->setMethods(['getParentItems', 'getMenuModel']) + ->getMock(); + $menuBlockMock->expects($this->any()) + ->method('getMenuModel') + ->will($this->returnSelf()); + $menuBlockMock->expects($this->any()) + ->method('getParentItems') + ->with('Magento_Sales::sales_order') + ->will($this->returnValue([])); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('menu') + ->will($this->returnValue($menuBlockMock)); + + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + + $this->sessionMock->expects($this->once()) + ->method('getCommentText') + ->with(true) + ->will($this->returnValue($commentText)); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Backend\Model\Session') + ->will($this->returnValue($this->sessionMock)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoInvoice() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue(false)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintActionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintActionTest.php new file mode 100644 index 00000000000..52e2e5feb82 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/PrintActionTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class PrintActionTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class PrintActionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $fileFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\PrintAction + */ + protected $controller; + + public function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->fileFactory = $this->getMockBuilder('Magento\Framework\App\Response\Http\FileFactory') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\PrintAction( + $contextMock, + $this->fileFactory, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php new file mode 100644 index 00000000000..b398a1e8c92 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php @@ -0,0 +1,247 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class UpdateQtyTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class UpdateQtyTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\UpdateQty + */ + protected $controller; + + public function setUp() + { + $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\UpdateQty( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = ['comment_text' => 'test']; + $response = 'test data'; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $this->responseMock->expects($this->once()) + ->method('setBody') + ->with($response); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $blockItemMock = $this->getMockBuilder('Magento\Sales\Block\Order\Items') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $blockItemMock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($response)); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('order_items') + ->will($this->returnValue($blockItemMock)); + + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, []) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $message = 'test message'; + $e = new \Magento\Framework\Model\Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->titleMock->expects($this->once()) + ->method('add') + ->with('Invoices') + ->will($this->throwException($e)); + + $this->responseMock->expects($this->once()) + ->method('representJson') + ->with(json_encode($response)); + + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->will($this->returnValue(json_encode($response))); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->will($this->returnValue($helperMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $message = 'Cannot update item quantity.'; + $e = new \Exception($message); + $response = ['error' => true, 'message' => $message]; + + $this->titleMock->expects($this->once()) + ->method('add') + ->with('Invoices') + ->will($this->throwException($e)); + + $this->responseMock->expects($this->once()) + ->method('representJson') + ->with(json_encode($response)); + + $helperMock = $this->getMockBuilder('Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $helperMock->expects($this->once()) + ->method('jsonEncode') + ->with($response) + ->will($this->returnValue(json_encode($response))); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->will($this->returnValue($helperMock)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/ViewTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/ViewTest.php new file mode 100644 index 00000000000..4335aabcaaa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/ViewTest.php @@ -0,0 +1,227 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class ViewTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\View + */ + protected $controller; + + public function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['getCommentText', 'setIsUrlNotice']) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any()) + ->method('getView') + ->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\View( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + ->disableOriginalConstructor() + ->setMethods(['getParentItems', 'getMenuModel']) + ->getMock(); + $menuBlockMock->expects($this->any()) + ->method('getMenuModel') + ->will($this->returnSelf()); + $menuBlockMock->expects($this->any()) + ->method('getParentItems') + ->with('Magento_Sales::sales_order') + ->will($this->returnValue([])); + + $invoiceViewBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View') + ->disableOriginalConstructor() + ->setMethods(['updateBackButtonUrl']) + ->getMock(); + + $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with('menu') + ->will($this->returnValue($menuBlockMock)); + $layoutMock->expects($this->at(1)) + ->method('getBlock') + ->with('sales_invoice_view') + ->will($this->returnValue($invoiceViewBlockMock)); + + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoInvoice() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice', []) + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue(false)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php new file mode 100644 index 00000000000..946fbd30836 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -0,0 +1,331 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Backend\App\Action; + +/** + * Class VoidTest + * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + */ +class VoidTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\UpdateQty + */ + protected $controller; + + public function setUp() + { + $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->helperMock = $this->getMockBuilder('Magento\Backend\Helper\Data') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $contextMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $contextMock->expects($this->any()) + ->method('getTitle') + ->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlagMock)); + $contextMock->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any()) + ->method('getHelper') + ->will($this->returnValue($this->helperMock)); + + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->controller = new \Magento\Sales\Controller\Adminhtml\Order\Invoice\Void( + $contextMock, + $this->invoiceLoaderMock + ); + } + + public function testExecute() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['setIsInProcess']) + ->getMock(); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('void'); + $invoiceMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $transactionMock = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $transactionMock->expects($this->at(0)) + ->method('addObject') + ->with($invoiceMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(1)) + ->method('addObject') + ->with($orderMock) + ->will($this->returnSelf()); + $transactionMock->expects($this->at(2)) + ->method('save'); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->will($this->returnValue($transactionMock)); + + $this->messageManagerMock->expects($this->once()) + ->method('addSuccess') + ->with('The invoice has been voided.'); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteNoInvoice() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue(false)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteModelException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + $message = 'test message'; + $e = new \Magento\Framework\Model\Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('void') + ->will($this->throwException($e)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } + + public function testExecuteException() + { + $orderId = 1; + $invoiceId = 2; + $invoiceData = []; + $message = 'test message'; + $e = new \Exception($message); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('invoice_id') + ->will($this->returnValue($invoiceId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('invoice') + ->will($this->returnValue($invoiceData)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('void') + ->will($this->throwException($e)); + + $this->invoiceLoaderMock->expects($this->once()) + ->method('load') + ->with($orderId, $invoiceId, $invoiceData) + ->will($this->returnValue($invoiceMock)); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php new file mode 100644 index 00000000000..9801d841665 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Controller/Adminhtml/Order/InvoiceLoaderTest.php @@ -0,0 +1,212 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Controller\Adminhtml\Order; + +use Magento\Backend\App\Action; + +/** + * Class InvoiceLoaderTest + * @package Magento\Sales\Controller\Adminhtml\Order + */ +class InvoiceLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader + */ + protected $loader; + + public function setUp() + { + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->loader = new \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader( + $this->objectManagerMock, + $this->registryMock, + $this->messageManagerMock + ); + } + + public function testLoadInvoiceId() + { + $orderId = 1; + $invoiceId = 2; + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Sales\Model\Order\Invoice') + ->will($this->returnValue($invoiceMock)); + + $this->assertFalse($this->loader->load($orderId, $invoiceId)); + } + + public function testLoadNoInvoiceId() + { + $orderId = 1; + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['load', 'getId']) + ->getMock(); + $orderMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + + $this->objectManagerMock->expects($this->at(0)) + ->method('create') + ->with('Magento\Sales\Model\Order') + ->will($this->returnValue($orderMock)); + + $this->assertFalse($this->loader->load($orderId)); + } + + public function testLoadCanNotInvoice() + { + $orderId = 1; + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['load', 'getId', 'canInvoice']) + ->getMock(); + $orderMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + $orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($orderId)); + $orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + + $this->objectManagerMock->expects($this->at(0)) + ->method('create') + ->with('Magento\Sales\Model\Order') + ->will($this->returnValue($orderMock)); + + $this->assertFalse($this->loader->load($orderId)); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Cannot create an invoice without products. + */ + public function testLoadException() + { + $orderId = 1; + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['load', 'getId', 'canInvoice']) + ->getMock(); + $orderMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + $orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($orderId)); + $orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(true)); + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $serviceOrderMock = $this->getMockBuilder('Magento\Sales\Model\Service\Order') + ->disableOriginalConstructor() + ->setMethods(['prepareInvoice']) + ->getMock(); + $serviceOrderMock->expects($this->once()) + ->method('prepareInvoice') + ->with([]) + ->will($this->returnValue($invoiceMock)); + + $this->objectManagerMock->expects($this->at(0)) + ->method('create') + ->with('Magento\Sales\Model\Order') + ->will($this->returnValue($orderMock)); + $this->objectManagerMock->expects($this->at(1)) + ->method('create') + ->with('Magento\Sales\Model\Service\Order', ['order' => $orderMock]) + ->will($this->returnValue($serviceOrderMock)); + + $this->assertFalse($this->loader->load($orderId)); + } + + public function testLoad() + { + $orderId = 1; + $invoiceId = 2; + + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods(['load', 'getId']) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('load') + ->will($this->returnSelf()); + $invoiceMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($invoiceId)); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Sales\Model\Order\Invoice') + ->will($this->returnValue($invoiceMock)); + + $this->assertInstanceOf('Magento\Sales\Model\Order\Invoice', $this->loader->load($orderId, $invoiceId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php index 9eaeded33a2..ebf3e20e2de 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php @@ -56,8 +56,11 @@ class GuestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $sessionMock; - /** @var \Magento\Framework\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject */ - protected $cookieMock; + /** @var \Magento\Framework\Stdlib\CookieManager|\PHPUnit_Framework_MockObject_MockObject */ + protected $cookieManagerMock; + + /** @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $cookieMetadataFactoryMock; /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $managerInterfaceMock; @@ -76,7 +79,14 @@ class GuestTest extends \PHPUnit_Framework_TestCase $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); $this->registryMock = $this->getMock('Magento\Framework\Registry'); $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->cookieMock = $this->getMock('Magento\Framework\Stdlib\Cookie', [], [], '', false); + $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->cookieMetadataFactoryMock = $this->getMock( + '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + [], + [], + '', + false + ); $this->managerInterfaceMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); $this->orderFactoryMock = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); $this->viewInterfaceMock = $this->getMock('Magento\Framework\App\ViewInterface'); @@ -91,7 +101,8 @@ class GuestTest extends \PHPUnit_Framework_TestCase 'appState' => $this->stateMock, 'coreRegistry' => $this->registryMock, 'customerSession' => $this->sessionMock, - 'coreCookie' => $this->cookieMock, + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, 'messageManager' => $this->managerInterfaceMock, 'orderFactory' => $this->orderFactoryMock, 'view' => $this->viewInterfaceMock @@ -142,12 +153,13 @@ class GuestTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); $protectedCode = 'protectedCode'; $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $this->cookieMock->expects($this->once())->method('set')->with( - Guest::COOKIE_NAME, - base64_encode($protectedCode . ':' . $incrementId), - Guest::COOKIE_LIFETIME, - Guest::COOKIE_PATH - ); + $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($metaData)); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); $this->assertTrue($this->guest->loadValidOrder($requestMock, $responseMock)); } @@ -168,17 +180,19 @@ class GuestTest extends \PHPUnit_Framework_TestCase $cookieDataHash = base64_encode($cookieData); $this->orderFactoryMock->expects($this->once())->method('create')->will($this->returnValue($orderMock)); - $this->cookieMock->expects($this->exactly(3))->method('get')->with(Guest::COOKIE_NAME)->will( + $this->cookieManagerMock->expects($this->once())->method('getCookie')->with(Guest::COOKIE_NAME)->will( $this->returnValue($cookieDataHash) ); $orderMock->expects($this->once())->method('loadByIncrementId')->with($incrementId); $orderMock->expects($this->exactly(1))->method('getId')->will($this->returnValue($incrementId)); $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $this->cookieMock->expects($this->once())->method('renew')->with( - Guest::COOKIE_NAME, - Guest::COOKIE_LIFETIME, - Guest::COOKIE_PATH - ); + $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($metaData)); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); $requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php index f2de0967f52..3e620e63329 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php @@ -54,7 +54,11 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase } /** + * Run test validate + * * @param $addressData + * @param $email + * @param $addressType * @param $expectedWarnings * @dataProvider providerAddressData */ diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ConfigTest.php index 0cc17fc8c10..fc74defb4e5 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ConfigTest.php @@ -25,8 +25,6 @@ namespace Magento\Sales\Model\Order; /** * Class ConfigTest - * - * @package Magento\Sales\Model\Order */ class ConfigTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Creditmemo/Comment/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Creditmemo/Comment/ValidatorTest.php new file mode 100644 index 00000000000..9dffd4f5ef9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Creditmemo/Comment/ValidatorTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Creditmemo\Comment; + +/** + * Class ValidatorTest + */ +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment\Validator + */ + protected $validator; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Comment', + ['hasData', 'getData', '__wakeup'], + [], + '', + false + ); + $this->validator = new \Magento\Sales\Model\Order\Creditmemo\Comment\Validator(); + } + + + /** + * Run test validate + * + * @param $commentDataMap + * @param $commentData + * @param $expectedWarnings + * @dataProvider providerCommentData + */ + public function testValidate($commentDataMap, $commentData, $expectedWarnings) + { + $this->commentModelMock->expects($this->any()) + ->method('hasData') + ->will($this->returnValueMap($commentDataMap)); + $this->commentModelMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($commentData)); + $actualWarnings = $this->validator->validate($this->commentModelMock); + $this->assertEquals($expectedWarnings, $actualWarnings); + } + + /** + * Provides comment data for tests + * + * @return array + */ + public function providerCommentData() + { + return [ + [ + [ + ['parent_id', true], + ['comment', true] + ], + [ + 'parent_id' => 25, + 'comment' => 'Hello world!' + ], + [] + ], + [ + [ + ['parent_id', true], + ['comment', false] + ], + [ + 'parent_id' => 0, + 'comment' => null + ], + [ + 'parent_id' => 'Parent Creditmemo Id can not be empty', + 'comment' => 'Comment is a required field' + ] + ] + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoNotifierTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoNotifierTest.php new file mode 100644 index 00000000000..f1047dc2ef6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoNotifierTest.php @@ -0,0 +1,165 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Framework\Mail\Exception; + +/** + * Class CreditmemoNotifierTest + */ +class CreditmemoNotifierTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CollectionFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Sales\Model\CreditmemoNotifier + */ + protected $notifier; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemo; + + /** + * @var \Magento\Framework\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoSenderMock; + + public function setUp() + { + $this->historyCollectionFactory = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->creditmemo = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + ['__wakeUp', 'getEmailSent'], + [], + '', + false + ); + $this->creditmemoSenderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender\CreditmemoSender', + ['send'], + [], + '', + false + ); + $this->loggerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + $this->notifier = new CreditmemoNotifier( + $this->historyCollectionFactory, + $this->loggerMock, + $this->creditmemoSenderMock + ); + } + + /** + * Test case for successful email sending + */ + public function testNotifySuccess() + { + $historyCollection = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection', + ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], + [], + '', + false + ); + $historyItem = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + ['setIsCustomerNotified', 'save', '__wakeUp'], + [], + '', + false + ); + $historyItem->expects($this->at(0)) + ->method('setIsCustomerNotified') + ->with(1); + $historyItem->expects($this->at(1)) + ->method('save'); + $historyCollection->expects($this->once()) + ->method('getUnnotifiedForInstance') + ->with($this->creditmemo) + ->will($this->returnValue($historyItem)); + $this->creditmemo->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(true)); + $this->historyCollectionFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($historyCollection)); + + $this->creditmemoSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->creditmemo)); + + $this->assertTrue($this->notifier->notify($this->creditmemo)); + } + + /** + * Test case when email has not been sent + */ + public function testNotifyFail() + { + $this->creditmemo->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(false)); + $this->assertFalse($this->notifier->notify($this->creditmemo)); + } + + /** + * Test case when Mail Exception has been thrown + */ + public function testNotifyException() + { + $exception = new Exception('Email has not been sent'); + $this->creditmemoSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->creditmemo)) + ->will($this->throwException($exception)); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($this->equalTo($exception)); + $this->assertFalse($this->notifier->notify($this->creditmemo)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php new file mode 100644 index 00000000000..9839f9c0af0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php @@ -0,0 +1,144 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Resource\OrderFactory; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class CreditmemoTest + */ +class CreditmemoTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OrderFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactory; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo + */ + protected $creditmemo; + + public function setUp() + { + $this->orderFactory = $this->getMock( + '\Magento\Sales\Model\OrderFactory', + ['create'], + [], + '', + false + ); + + $objectManagerHelper = new ObjectManagerHelper($this); + $arguments = [ + 'context' => $this->getMock('Magento\Framework\Model\Context', [], [], '', false), + 'registry' => $this->getMock('Magento\Framework\Registry', [], [], '', false), + 'localeDate' => $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', [], [], '', false), + 'dateTime' => $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false), + 'creditmemoConfig' => $this->getMock('Magento\Sales\Model\Order\Creditmemo\Config', [], [], '', false), + 'orderFactory' => $this->orderFactory, + 'cmItemCollectionFactory' => $this->getMock( + 'Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory', + [], + [], + '', + false + ), + 'calculatorFactory' => $this->getMock('Magento\Framework\Math\CalculatorFactory', [], [], '', false), + 'storeManager' => $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), + 'commentFactory' => $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\CommentFactory', + [], + [], + '', + false + ), + 'commentCollectionFactory' => $this->getMock( + 'Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory', + [], + [], + '', + false + ), + ]; + $this->creditmemo = $objectManagerHelper->getObject( + 'Magento\Sales\Model\Order\Creditmemo', + $arguments + ); + } + + public function testGetOrder() + { + $orderId = 100000041; + $this->creditmemo->setOrderId($orderId); + $entityName = 'creditmemo'; + $order = $this->getMock( + 'Magento\Sales\Model\Order', + ['load', 'setHistoryEntityName', '__wakeUp'], + [], + '', + false + ); + $this->creditmemo->setOrderId($orderId); + $order->expects($this->atLeastOnce()) + ->method('setHistoryEntityName') + ->with($entityName) + ->will($this->returnSelf()); + $order->expects($this->atLeastOnce()) + ->method('load') + ->with($orderId) + ->will($this->returnValue($order)); + + $this->orderFactory->expects($this->atLeastOnce()) + ->method('create') + ->will($this->returnValue($order)); + + $this->assertEquals($order, $this->creditmemo->getOrder()); + } + + public function testGetEntityType() + { + $this->assertEquals('creditmemo', $this->creditmemo->getEntityType()); + } + + public function testIsValidGrandTotalGrandTotalEmpty() + { + $this->creditmemo->setGrandTotal(0); + $this->assertFalse($this->creditmemo->isValidGrandTotal()); + } + + public function testIsValidGrandTotalGrandTotal() + { + $this->creditmemo->setGrandTotal(0); + $this->creditmemo->getAllowZeroGrandTotal(true); + $this->assertFalse($this->creditmemo->isValidGrandTotal()); + } + + public function testIsValidGrandTotal() + { + $this->creditmemo->setGrandTotal(1); + $this->assertTrue($this->creditmemo->isValidGrandTotal()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Customer/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Customer/BuilderTest.php new file mode 100644 index 00000000000..6ac81f399da --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Customer/BuilderTest.php @@ -0,0 +1,184 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Customer; + +/** + * Class BuilderTest + */ +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Sales\Model\Order\Customer\Builder + */ + protected $builder; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + + $this->builder = new \Magento\Sales\Model\Order\Customer\Builder($this->objectManagerMock); + } + + /** + * Run test setDob method + */ + public function testSetDob() + { + $this->assertEquals($this->builder, $this->builder->setDob('dob')); + } + + /** + * Run test setEmail method + */ + public function testSetEmail() + { + $this->assertEquals($this->builder, $this->builder->setEmail('email')); + } + + /** + * Run test setFirstName method + */ + public function testSetFirstName() + { + $this->assertEquals($this->builder, $this->builder->setFirstName('first_name')); + } + + /** + * Run test setGender method + */ + public function testSetGender() + { + $this->assertEquals($this->builder, $this->builder->setGender('gender')); + } + + /** + * Run test setGroupId method + */ + public function testSetGroupId() + { + $this->assertEquals($this->builder, $this->builder->setGroupId('group_id')); + } + + /** + * Run test setId method + */ + public function testSetId() + { + $this->assertEquals($this->builder, $this->builder->setId('id')); + } + + /** + * Run test setIsGuest method + */ + public function testSetIsGuest() + { + $this->assertEquals($this->builder, $this->builder->setIsGuest('is_guest')); + } + + /** + * Run test setLastName method + */ + public function testSetLastName() + { + $this->assertEquals($this->builder, $this->builder->setLastName('last_name')); + } + + /** + * Run test setMiddleName method + */ + public function testSetMiddleName() + { + $this->assertEquals($this->builder, $this->builder->setMiddleName('middle_name')); + } + + /** + * Run test setNote method + */ + public function testSetNote() + { + $this->assertEquals($this->builder, $this->builder->setNote('note')); + } + + /** + * Run test setNoteNotify method + */ + public function testSetNoteNotify() + { + $this->assertEquals($this->builder, $this->builder->setNoteNotify('note_notify')); + } + + /** + * Run test setPrefix method + */ + public function testSetPrefix() + { + $this->assertEquals($this->builder, $this->builder->setPrefix('prefix')); + } + + /** + * Run test setSuffix method + */ + public function testSetSuffix() + { + $this->assertEquals($this->builder, $this->builder->setSuffix('suffix')); + } + + /** + * Run test setTaxvat method + */ + public function testSetTaxvat() + { + $this->assertEquals($this->builder, $this->builder->setTaxvat('taxvat')); + } + + /** + * Run test create method + */ + public function testCreate() + { + $customerMock = $this->getMock( + 'Magento\Sales\Model\Order\Customer', + [], + [], + '', + false + ); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($customerMock)); + + $this->assertEquals($customerMock, $this->builder->create()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CustomerTest.php new file mode 100644 index 00000000000..fa1c64fcee3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CustomerTest.php @@ -0,0 +1,265 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order; + +/** + * Class CustomerTest + */ +class CustomerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + } + + /** + * Run test getDob method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetDob(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerDob'], $customer->getDob()); + } + + /** + * Run test getEmail method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetEmail(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerEmail'], $customer->getEmail()); + } + + /** + * Run test getFirstName method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetFirstName(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerFirstName'], $customer->getFirstName()); + } + + /** + * Run test getGender method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetGender(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerGender'], $customer->getGender()); + } + + /** + * Run test getGroupId method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetGroupId(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerGroupId'], $customer->getGroupId()); + } + + /** + * Run test getId method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetId(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerId'], $customer->getId()); + } + + /** + * Run test getIsGuest method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetIsGuest(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerIsGuest'], $customer->getIsGuest()); + } + + /** + * Run test getLastName method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetLastName(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerLastName'], $customer->getLastName()); + } + + /** + * Run test getMiddleName method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetMiddleName(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerMiddleName'], $customer->getMiddleName()); + } + + /** + * Run test getNote method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetNote(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerNote'], $customer->getNote()); + } + + /** + * Run test getNoteNotify method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetNoteNotify(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerNoteNotify'], $customer->getNoteNotify()); + } + + /** + * Run test getPrefix method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetPrefix(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerPrefix'], $customer->getPrefix()); + } + + /** + * Run test getSuffix method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetSuffix(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerSuffix'], $customer->getSuffix()); + } + + /** + * Run test getTaxvat method + * + * @param array $parameters + * @dataProvider providerCustomerData + */ + public function testGetTaxvat(array $parameters) + { + /** @var \Magento\Sales\Model\Order\Customer $customer */ + $customer = $this->objectManager->getObject('Magento\Sales\Model\Order\Customer', $parameters); + + $this->assertEquals($parameters['customerTaxvat'], $customer->getTaxvat()); + } + + /** + * Data to insert into constructor of the test object + * + * @return array + */ + public function providerCustomerData() + { + return [ + [ + [ + 'customerDob' => 'customer_dob', + 'customerEmail' => 'customer_email', + 'customerFirstName' => 'customer_first_name', + 'customerGender' => 'customer_gender', + 'customerGroupId' => 'customer_group_id', + 'customerId' => 'customer_id', + 'customerIsGuest' => 'customer_is_guest', + 'customerLastName' => 'customer_last_name', + 'customerMiddleName' => 'customer_middle_name', + 'customerNote' => 'customer_note', + 'customerNoteNotify' => 'customer_note_notify', + 'customerPrefix' => 'customer_prefix', + 'customerSuffix' => 'customer_suffix', + 'customerTaxvat' => 'customer_taxvat' + ] + ] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Invoice/Comment/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Invoice/Comment/ValidatorTest.php new file mode 100644 index 00000000000..1377a6ccf39 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Invoice/Comment/ValidatorTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Invoice\Comment; + +/** + * Class ValidatorTest + */ +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment\Validator + */ + protected $validator; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Comment', + ['hasData', 'getData', '__wakeup'], + [], + '', + false + ); + $this->validator = new \Magento\Sales\Model\Order\Invoice\Comment\Validator(); + } + + + /** + * Run test validate + * + * @param $commentDataMap + * @param $commentData + * @param $expectedWarnings + * @dataProvider providerCommentData + */ + public function testValidate($commentDataMap, $commentData, $expectedWarnings) + { + $this->commentModelMock->expects($this->any()) + ->method('hasData') + ->will($this->returnValueMap($commentDataMap)); + $this->commentModelMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($commentData)); + $actualWarnings = $this->validator->validate($this->commentModelMock); + $this->assertEquals($expectedWarnings, $actualWarnings); + } + + /** + * Provides comment data for tests + * + * @return array + */ + public function providerCommentData() + { + return [ + [ + [ + ['parent_id', true], + ['comment', true] + ], + [ + 'parent_id' => 25, + 'comment' => 'Hello world!' + ], + [] + ], + [ + [ + ['parent_id', true], + ['comment', false] + ], + [ + 'parent_id' => 0, + 'comment' => null + ], + [ + 'parent_id' => 'Parent Invoice Id can not be empty', + 'comment' => 'Comment is a required field' + ] + ] + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceNotifierTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceNotifierTest.php new file mode 100644 index 00000000000..2c1f3c2e149 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceNotifierTest.php @@ -0,0 +1,165 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Order; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Framework\Mail\Exception; + +/** + * Class InvoiceNotifierTest + */ +class InvoiceNotifierTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CollectionFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Sales\Model\Order\InvoiceNotifier + */ + protected $notifier; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoice; + + /** + * @var \Magento\Framework\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceSenderMock; + + public function setUp() + { + $this->historyCollectionFactory = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->invoice = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + ['__wakeUp', 'getEmailSent'], + [], + '', + false + ); + $this->invoiceSenderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender\InvoiceSender', + ['send'], + [], + '', + false + ); + $this->loggerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + $this->notifier = new InvoiceNotifier( + $this->historyCollectionFactory, + $this->loggerMock, + $this->invoiceSenderMock + ); + } + + /** + * Test case for successful email sending + */ + public function testNotifySuccess() + { + $historyCollection = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection', + ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], + [], + '', + false + ); + $historyItem = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + ['setIsCustomerNotified', 'save', '__wakeUp'], + [], + '', + false + ); + $historyItem->expects($this->at(0)) + ->method('setIsCustomerNotified') + ->with(1); + $historyItem->expects($this->at(1)) + ->method('save'); + $historyCollection->expects($this->once()) + ->method('getUnnotifiedForInstance') + ->with($this->invoice) + ->will($this->returnValue($historyItem)); + $this->invoice->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(true)); + $this->historyCollectionFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($historyCollection)); + + $this->invoiceSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->invoice)); + + $this->assertTrue($this->notifier->notify($this->invoice)); + } + + /** + * Test case when email has not been sent + */ + public function testNotifyFail() + { + $this->invoice->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(false)); + $this->assertFalse($this->notifier->notify($this->invoice)); + } + + /** + * Test case when Mail Exception has been thrown + */ + public function testNotifyException() + { + $exception = new Exception('Email has not been sent'); + $this->invoiceSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->invoice)) + ->will($this->throwException($exception)); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($this->equalTo($exception)); + $this->assertFalse($this->notifier->notify($this->invoice)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php index af190942c1f..7271f5739cf 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php @@ -23,17 +23,29 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Sales\Model\Resource\OrderFactory; + +/** + * Class InvoiceTest + * + * @package Magento\Sales\Model\Order + */ class InvoiceTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Sales\Model\Order\Invoice */ - protected $_model; + protected $model; + + /** + * @var OrderFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactory; /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order */ - protected $_orderMock; + protected $orderMock; /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Payment @@ -43,57 +55,59 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helperManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_orderMock = $this->getMockBuilder( + $this->orderMock = $this->getMockBuilder( 'Magento\Sales\Model\Order' )->disableOriginalConstructor()->setMethods( - array('getPayment', '__wakeup') + ['getPayment', '__wakeup', 'load', 'setHistoryEntityName'] )->getMock(); $this->_paymentMock = $this->getMockBuilder( 'Magento\Sales\Model\Order\Payment' )->disableOriginalConstructor()->setMethods( - array('canVoid', '__wakeup') + ['canVoid', '__wakeup'] )->getMock(); + $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + $arguments = array( - 'orderFactory' => $this->getMock('Magento\Sales\Model\OrderFactory', array(), array(), '', false), + 'orderFactory' => $this->orderFactory, 'orderResourceFactory' => $this->getMock( 'Magento\Sales\Model\Resource\OrderFactory', - array(), - array(), + [], + [], '', false ), 'calculatorFactory' => $this->getMock( 'Magento\Framework\Math\CalculatorFactory', - array(), - array(), + [], + [], '', false ), 'invoiceItemCollectionFactory' => $this->getMock( 'Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory', - array(), - array(), + [], + [], '', false ), 'invoiceCommentFactory' => $this->getMock( 'Magento\Sales\Model\Order\Invoice\CommentFactory', - array(), - array(), + [], + [], '', false ), 'commentCollectionFactory' => $this->getMock( 'Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory', - array(), - array(), + [], + [], '', false ) ); - $this->_model = $helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments); - $this->_model->setOrder($this->_orderMock); + $this->model = $helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments); + $this->model->setOrder($this->orderMock); } /** @@ -102,20 +116,25 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase */ public function testCanVoid($canVoid) { - $this->_orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock)); + $entityName = 'invoice'; + $this->orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock)); + $this->orderMock->expects($this->once()) + ->method('setHistoryEntityName') + ->with($entityName) + ->will($this->returnSelf()); $this->_paymentMock->expects( $this->once() )->method( 'canVoid', '__wakeup' )->with( - $this->equalTo($this->_model) + $this->equalTo($this->model) )->will( $this->returnValue($canVoid) ); - $this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); - $this->assertEquals($canVoid, $this->_model->canVoid()); + $this->model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); + $this->assertEquals($canVoid, $this->model->canVoid()); } /** @@ -124,14 +143,32 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase */ public function testDefaultCanVoid($canVoid) { - $this->_model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); - $this->_model->setCanVoidFlag($canVoid); + $this->model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); + $this->model->setCanVoidFlag($canVoid); - $this->assertEquals($canVoid, $this->_model->canVoid()); + $this->assertEquals($canVoid, $this->model->canVoid()); } public function canVoidDataProvider() { return array(array(true), array(false)); } + + public function testGetOrder() + { + $orderId = 100000041; + $this->model->setOrderId($orderId); + $entityName = 'invoice'; + $this->orderMock->expects($this->atLeastOnce()) + ->method('setHistoryEntityName') + ->with($entityName) + ->will($this->returnSelf()); + + $this->assertEquals($this->orderMock, $this->model->getOrder()); + } + + public function testGetEntityType() + { + $this->assertEquals('invoice', $this->model->getEntityType()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Comment/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Comment/ValidatorTest.php new file mode 100644 index 00000000000..7812ada58f9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Comment/ValidatorTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Shipment\Comment; + +/** + * Class ValidatorTest + */ +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment\Validator + */ + protected $validator; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Comment', + ['hasData', 'getData', '__wakeup'], + [], + '', + false + ); + $this->validator = new \Magento\Sales\Model\Order\Shipment\Comment\Validator(); + } + + + /** + * Run test validate + * + * @param $commentDataMap + * @param $commentData + * @param $expectedWarnings + * @dataProvider providerCommentData + */ + public function testValidate($commentDataMap, $commentData, $expectedWarnings) + { + $this->commentModelMock->expects($this->any()) + ->method('hasData') + ->will($this->returnValueMap($commentDataMap)); + $this->commentModelMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($commentData)); + $actualWarnings = $this->validator->validate($this->commentModelMock); + $this->assertEquals($expectedWarnings, $actualWarnings); + } + + /** + * Provides comment data for tests + * + * @return array + */ + public function providerCommentData() + { + return [ + [ + [ + ['parent_id', true], + ['comment', true] + ], + [ + 'parent_id' => 25, + 'comment' => 'Hello world!' + ], + [] + ], + [ + [ + ['parent_id', true], + ['comment', false] + ], + [ + 'parent_id' => 0, + 'comment' => null + ], + [ + 'parent_id' => 'Parent Shipment Id can not be empty', + 'comment' => 'Comment is a required field' + ] + ] + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Track/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Track/ValidatorTest.php new file mode 100644 index 00000000000..a63fc911163 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Shipment/Track/ValidatorTest.php @@ -0,0 +1,123 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Order\Shipment\Track; + +/** + * Class ValidatorTest + */ +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Shipment\Track\Validator + */ + protected $validator; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $trackModelMock; + + /** + * Set up + */ + protected function setUp() + { + $this->trackModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track', + ['hasData', 'getData', '__wakeup'], + [], + '', + false + ); + $this->validator = new \Magento\Sales\Model\Order\Shipment\Track\Validator(); + } + + + /** + * Run test validate + * + * @param $trackDataMap + * @param $trackData + * @param $expectedWarnings + * @dataProvider providerTrackData + */ + public function testValidate($trackDataMap, $trackData, $expectedWarnings) + { + $this->trackModelMock->expects($this->any()) + ->method('hasData') + ->will($this->returnValueMap($trackDataMap)); + $this->trackModelMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($trackData)); + $actualWarnings = $this->validator->validate($this->trackModelMock); + $this->assertEquals($expectedWarnings, $actualWarnings); + } + + /** + * Provides track data for tests + * + * @return array + */ + public function providerTrackData() + { + return [ + [ + [ + ['parent_id', true], + ['order_id', true], + ['track_number', true], + ['carrier_code', true] + ], + [ + 'parent_id' => 25, + 'order_id' => 12, + 'track_number' => 125, + 'carrier_code' => 'custom' + ], + [] + ], + [ + [ + ['parent_id', true], + ['order_id', false], + ['track_number', true], + ['carrier_code', false] + ], + [ + 'parent_id' => 0, + 'order_id' => null, + 'track_number' => '', + 'carrier_code' => null + ], + [ + 'parent_id' => 'Parent Track Id can not be empty', + 'order_id' => 'Order Id is a required field', + 'track_number' => 'Number can not be empty', + 'carrier_code' => 'Carrier Code is a required field' + ] + ] + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderConverterTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderConverterTest.php new file mode 100644 index 00000000000..bbe7b0f4433 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderConverterTest.php @@ -0,0 +1,486 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model; + +/** + * Class OrderConverterTest + * + * @package Magento\Sales\Model + */ +class OrderConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Builder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderBuilderMock; + + /** + * @var \Magento\Sales\Model\Order\ItemConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemConverterMock; + + /** + * @var \Magento\Sales\Model\Order\PaymentConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentConverterMock; + + /** + * @var \Magento\Sales\Model\Order\AddressConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressConverterMock; + + /** + * @var \Magento\Sales\Model\Order\Customer\Builder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerBuilderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Order + */ + protected $orderDataMock; + + /** + * @var array + */ + protected $orderData; + + /** + * @var \Magento\Sales\Model\OrderConverter + */ + protected $orderConverter; + + public function setUp() + { + $this->orderBuilderMock = $this->getMock( + 'Magento\Sales\Model\Order\Builder', + [], + [], + '', + false + ); + $this->itemConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\ItemConverter', + ['getModel'], + [], + '', + false + ); + $this->paymentConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\PaymentConverter', + ['getModel'], + [], + '', + false + ); + $this->addressConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\AddressConverter', + ['getModel'], + [], + '', + false + ); + $this->customerBuilderMock = $this->getMock( + 'Magento\Sales\Model\Order\Customer\Builder', + [], + [], + '', + false + ); + + $this->orderDataMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Order', + [], + [], + '', + false + ); + + $this->orderData = [ + 'customerDob' => 'customer_dob', + 'customerEmail' => 'customer_email', + 'customerFirstName' => 'customer_first_name', + 'customerGender' => 'customer_gender', + 'customerGroupId' => 'customer_group_id', + 'customerId' => 'customer_id', + 'customerLastName' => 'customer_last_name', + 'customerMiddleName' => 'customer_middle_name', + 'customerIsGuest' => 'customer_is_guest', + 'customerNote' => 'customer_note', + 'customerNotify' => 'customer_notify', + 'customerPrefix' => 'customer_prefix', + 'customerSuffix' => 'customer_suffix', + 'customerTaxvat' => 'customer_taxvat', + 'items' => ['01' => 'item1', '02' => 'item2'], + 'payments' => ['payments'], + 'quoteId' => 'quote_id', + 'appliedRuleIds' => 'applied_rule_ids', + 'isVirtual' => 'is_virtual', + 'remoteIp' => 'remote_ip', + 'baseSubtotal' => 'base_subtotal', + 'subtotal' => 'ubtotal', + 'baseGrandTotal' => 'base_grand_total', + 'grandTotal' => 'grand_total', + 'baseCurrencyCode' => 'base_currency_code', + 'globalCurrencyCode' => 'global_rule_ids', + 'storeCurrencyCode' => 'store_rule_ids', + 'storeId' => 'store_id', + 'storeToBaseRate' => 'store_to_base_rate', + 'baseToGlobalRate' => 'base_to_global_rate', + 'couponCode' => 'coupon_code', + 'billingAddress' => 'billing_address', + 'shippingAddress' => 'shipping_address', + ]; + $this->prepareDataObject(); + + $this->orderConverter = new OrderConverter( + $this->orderBuilderMock, + $this->itemConverterMock, + $this->paymentConverterMock, + $this->addressConverterMock, + $this->customerBuilderMock + ); + } + + protected function prepareDataObject() + { + $this->orderDataMock->expects($this->once()) + ->method('getCustomerDob') + ->will($this->returnValue($this->orderData['customerDob'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerEmail') + ->will($this->returnValue($this->orderData['customerEmail'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerFirstname') + ->will($this->returnValue($this->orderData['customerFirstName'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerGender') + ->will($this->returnValue($this->orderData['customerGender'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerGroupId') + ->will($this->returnValue($this->orderData['customerGroupId'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerId') + ->will($this->returnValue($this->orderData['customerId'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue($this->orderData['customerIsGuest'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerLastname') + ->will($this->returnValue($this->orderData['customerLastName'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerMiddlename') + ->will($this->returnValue($this->orderData['customerMiddleName'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerNote') + ->will($this->returnValue($this->orderData['customerNote'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue($this->orderData['customerNotify'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerPrefix') + ->will($this->returnValue($this->orderData['customerPrefix'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerSuffix') + ->will($this->returnValue($this->orderData['customerSuffix'])); + $this->orderDataMock->expects($this->once()) + ->method('getCustomerTaxvat') + ->will($this->returnValue($this->orderData['customerTaxvat'])); + $this->orderDataMock->expects($this->once()) + ->method('getQuoteId') + ->will($this->returnValue($this->orderData['quoteId'])); + $this->orderDataMock->expects($this->once()) + ->method('getAppliedRuleIds') + ->will($this->returnValue($this->orderData['appliedRuleIds'])); + $this->orderDataMock->expects($this->once()) + ->method('getIsVirtual') + ->will($this->returnValue($this->orderData['isVirtual'])); + $this->orderDataMock->expects($this->once()) + ->method('getRemoteIp') + ->will($this->returnValue($this->orderData['remoteIp'])); + $this->orderDataMock->expects($this->once()) + ->method('getBaseSubtotal') + ->will($this->returnValue($this->orderData['baseSubtotal'])); + $this->orderDataMock->expects($this->once()) + ->method('getSubtotal') + ->will($this->returnValue($this->orderData['subtotal'])); + $this->orderDataMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->will($this->returnValue($this->orderData['baseGrandTotal'])); + $this->orderDataMock->expects($this->once()) + ->method('getGrandTotal') + ->will($this->returnValue($this->orderData['grandTotal'])); + $this->orderDataMock->expects($this->once()) + ->method('getBaseCurrencyCode') + ->will($this->returnValue($this->orderData['baseCurrencyCode'])); + $this->orderDataMock->expects($this->once()) + ->method('getGlobalCurrencyCode') + ->will($this->returnValue($this->orderData['globalCurrencyCode'])); + $this->orderDataMock->expects($this->once()) + ->method('getStoreCurrencyCode') + ->will($this->returnValue($this->orderData['storeCurrencyCode'])); + $this->orderDataMock->expects($this->once()) + ->method('getStoreId') + ->will($this->returnValue($this->orderData['storeId'])); + $this->orderDataMock->expects($this->once()) + ->method('getStoreToBaseRate') + ->will($this->returnValue($this->orderData['storeToBaseRate'])); + $this->orderDataMock->expects($this->once()) + ->method('getBaseToGlobalRate') + ->will($this->returnValue($this->orderData['baseToGlobalRate'])); + $this->orderDataMock->expects($this->once()) + ->method('getCouponCode') + ->will($this->returnValue($this->orderData['couponCode'])); + $this->orderDataMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->orderData['billingAddress'])); + $this->orderDataMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue($this->orderData['shippingAddress'])); + + return $this->orderDataMock; + } + + protected function getCustomer() + { + $this->customerBuilderMock->expects($this->once()) + ->method('setDob') + ->with($this->orderData['customerDob']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setEmail') + ->with($this->orderData['customerEmail']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setFirstname') + ->with($this->orderData['customerFirstName']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setGender') + ->with($this->orderData['customerGender']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setGroupId') + ->with($this->orderData['customerGroupId']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setId') + ->with($this->orderData['customerId']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setIsGuest') + ->with($this->orderData['customerIsGuest']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setLastname') + ->with($this->orderData['customerLastName']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setMiddlename') + ->with($this->orderData['customerMiddleName']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setNote') + ->with($this->orderData['customerNote']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setNoteNotify') + ->with($this->orderData['customerNotify']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setPrefix') + ->with($this->orderData['customerPrefix']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setSuffix') + ->with($this->orderData['customerSuffix']) + ->will($this->returnSelf()); + $this->customerBuilderMock->expects($this->once()) + ->method('setTaxvat') + ->with($this->orderData['customerTaxvat']) + ->will($this->returnSelf()); + $customer = $this->getMock( + 'Magento\Sales\Model\Order\Customer', + [], + [], + '', + false + ); + $this->customerBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($customer)); + + return $customer; + } + + protected function getItems() + { + $this->orderDataMock->expects($this->any()) + ->method('getItems') + ->will($this->returnValue($this->orderData['items'])); + + $orderItem1 = $this->getMock('Magento\Sales\Model\Order\Item', + [], + [], + '', + false + ); + $orderItem2 = $this->getMock('Magento\Sales\Model\Order\Item', + [], + [], + '', + false + ); + + $this->itemConverterMock->expects($this->any()) + ->method('getModel') + ->will($this->returnValueMap([ + [$this->orderData['items']['01'], $orderItem1], + [$this->orderData['items']['02'], $orderItem2] + ])); + + return [$orderItem1, $orderItem2]; + } + + protected function getPayments() + { + $this->orderDataMock->expects($this->any()) + ->method('getPayments') + ->will($this->returnValue($this->orderData['payments'])); + + $payment = $this->getMock('Magento\Sales\Model\Order\Payment', + [], + [], + '', + false + ); + + $this->paymentConverterMock->expects($this->at(0)) + ->method('getModel') + ->with($this->orderData['payments'][0]) + ->will($this->returnValue($payment)); + + return [$payment]; + } + + public function testGetModel() + { + $billingAddressMock = $this->getMock('Magento\Sales\Model\Order\Address', ['__wakeup'], [], '', false); + $shippingAddressMock = clone $billingAddressMock; + $this->addressConverterMock->expects($this->at(0)) + ->method('getModel') + ->with($this->orderData['billingAddress']) + ->will($this->returnValue($billingAddressMock)); + $this->addressConverterMock->expects($this->at(1)) + ->method('getModel') + ->with($this->orderData['shippingAddress']) + ->will($this->returnValue($shippingAddressMock)); + $this->orderBuilderMock->expects($this->once()) + ->method('setCustomer') + ->with($this->getCustomer()) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setQuoteId') + ->with($this->orderData['quoteId']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setAppliedRuleIds') + ->with($this->orderData['appliedRuleIds']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setIsVirtual') + ->with($this->orderData['isVirtual']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setRemoteIp') + ->with($this->orderData['remoteIp']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBaseSubtotal') + ->with($this->orderData['baseSubtotal']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setSubtotal') + ->with($this->orderData['subtotal']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBaseGrandTotal') + ->with($this->orderData['baseGrandTotal']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setGrandTotal') + ->with($this->orderData['grandTotal']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBaseCurrencyCode') + ->with($this->orderData['baseCurrencyCode']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setGlobalCurrencyCode') + ->with($this->orderData['globalCurrencyCode']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setStoreCurrencyCode') + ->with($this->orderData['storeCurrencyCode']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setStoreId') + ->with($this->orderData['storeId']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setStoreToBaseRate') + ->with($this->orderData['storeToBaseRate']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBaseToGlobalRate') + ->with($this->orderData['baseToGlobalRate']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setCouponCode') + ->with($this->orderData['couponCode']) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBillingAddress') + ->with($billingAddressMock) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setShippingAddress') + ->with($shippingAddressMock) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setPayments') + ->with($this->getPayments()) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->getItems()) + ->will($this->returnSelf()); + $orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $this->orderBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($orderMock)); + + $this->assertEquals($orderMock, $this->orderConverter->getModel($this->orderDataMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderNotifierTest.php similarity index 95% rename from dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Model/OrderNotifierTest.php index efc875255ce..5e0e3eb32fa 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderNotifierTest.php @@ -28,9 +28,9 @@ use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; use Magento\Framework\Mail\Exception; /** - * Class NotifierTest + * Class OrderNotifierTest */ -class NotifierTest extends \PHPUnit_Framework_TestCase +class OrderNotifierTest extends \PHPUnit_Framework_TestCase { /** * @var CollectionFactory |\PHPUnit_Framework_MockObject_MockObject @@ -38,7 +38,7 @@ class NotifierTest extends \PHPUnit_Framework_TestCase protected $historyCollectionFactory; /** - * @var \Magento\Sales\Model\Notifier + * @var \Magento\Sales\Model\OrderNotifier */ protected $notifier; @@ -87,7 +87,7 @@ class NotifierTest extends \PHPUnit_Framework_TestCase '', false ); - $this->notifier = new Notifier( + $this->notifier = new OrderNotifier( $this->historyCollectionFactory, $this->loggerMock, $this->orderSenderMock @@ -120,7 +120,7 @@ class NotifierTest extends \PHPUnit_Framework_TestCase ->method('save'); $historyCollection->expects($this->once()) ->method('getUnnotifiedForInstance') - ->with($this->order, \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME) + ->with($this->order) ->will($this->returnValue($historyItem)); $this->order->expects($this->once()) ->method('getEmailSent') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php index 4caf8750d8a..d4bd6704053 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php @@ -22,11 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model; + /** * Test class for \Magento\Sales\Model\Order + * + * @package Magento\Sales\Model */ -namespace Magento\Sales\Model; - class OrderTest extends \PHPUnit_Framework_TestCase { /** @@ -89,7 +91,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase { $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Payment') ->disableOriginalConstructor() - ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo']) + ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); $paymentMock->expects($this->any()) ->method('canReviewPayment') @@ -108,7 +110,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase { $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Payment') ->disableOriginalConstructor() - ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo']) + ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); $paymentMock->expects($this->any()) ->method('canReviewPayment') @@ -130,7 +132,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase { $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Payment') ->disableOriginalConstructor() - ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo']) + ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); $paymentMock->expects($this->any()) ->method('canReviewPayment') @@ -155,7 +157,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase { $paymentMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Payment') ->disableOriginalConstructor() - ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo']) + ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) ->getMock(); $paymentMock->expects($this->any()) ->method('canReviewPayment') @@ -311,7 +313,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase { $itemMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Item') ->disableOriginalConstructor() - ->setMethods(['isDeleted', 'filterByTypes', 'filterByParent', 'getQtyToInvoice']) + ->setMethods(['isDeleted', 'filterByTypes', 'filterByParent', 'getQtyToInvoice', '__wakeUp']) ->getMock(); $itemMock->expects($this->any()) @@ -354,4 +356,9 @@ class OrderTest extends \PHPUnit_Framework_TestCase [true] ]; } + + public function testGetEntityType() + { + $this->assertEquals('order', $this->order->getEntityType()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php index 400ece2cc9a..f7e827e77ad 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php @@ -52,8 +52,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Address\Validator|\PHPUnit_Framework_MockObject_MockObject */ protected $validatorMock; + /** - * + * Set up */ public function setUp() { @@ -103,7 +104,6 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'validator' => $this->validatorMock ] ); - } /** diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php new file mode 100644 index 00000000000..8b7cc77fd4c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Creditmemo; + +/** + * Class CommentTest + */ +class CommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Comment + */ + protected $commentResource; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Comment', + [], + [], + '', + false + ); + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId'], + [], + '', + false + ); + $this->validatorMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Comment\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->commentResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Creditmemo\Comment', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + } + + /** + * Test _beforeSaveMethod via save() + */ + public function testSave() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue([])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } + + /** + * Test _beforeSaveMethod via save() with failed validation + * + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save comment: + */ + public function testSaveValidationFailed() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue(['warning message'])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php new file mode 100644 index 00000000000..dd801ac55f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Invoice; + +/** + * Class CommentTest + */ +class CommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Invoice\Comment + */ + protected $commentResource; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Comment', + [], + [], + '', + false + ); + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId'], + [], + '', + false + ); + $this->validatorMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Comment\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->commentResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Invoice\Comment', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + } + + /** + * Test _beforeSaveMethod via save() + */ + public function testSave() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue([])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } + + /** + * Test _beforeSaveMethod via save() with failed validation + * + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save comment: + */ + public function testSaveValidationFailed() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue(['warning message'])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php new file mode 100644 index 00000000000..d7e20d90ad1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Shipment; + +/** + * Class CommentTest + */ +class CommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Comment + */ + protected $commentResource; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentModelMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Comment', + [], + [], + '', + false + ); + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId'], + [], + '', + false + ); + $this->validatorMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Comment\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->commentResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Shipment\Comment', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + } + + /** + * Test _beforeSaveMethod via save() + */ + public function testSave() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue([])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } + + /** + * Test _beforeSaveMethod via save() with failed validation + * + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save comment: + */ + public function testSaveValidationFailed() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->commentModelMock)) + ->will($this->returnValue(['warning message'])); + $this->commentResource->save($this->commentModelMock); + $this->assertTrue(true); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php new file mode 100644 index 00000000000..c38d4610004 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Shipment; + +/** + * Class TrackTest + */ +class TrackTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Track + */ + protected $trackResource; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $trackModelMock; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * Set up + */ + protected function setUp() + { + $this->trackModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track', + [], + [], + '', + false + ); + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId'], + [], + '', + false + ); + $this->validatorMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->trackResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Shipment\Track', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + } + + /** + * Test _beforeSaveMethod via save() + */ + public function testSave() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->trackModelMock)) + ->will($this->returnValue([])); + $this->trackResource->save($this->trackModelMock); + $this->assertTrue(true); + } + + /** + * Test _beforeSaveMethod via save() with failed validation + * + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save track: + */ + public function testSaveValidationFailed() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->trackModelMock)) + ->will($this->returnValue(['warning message'])); + $this->trackResource->save($this->trackModelMock); + $this->assertTrue(true); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/History/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/History/CollectionTest.php new file mode 100644 index 00000000000..53cd290bfe4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/History/CollectionTest.php @@ -0,0 +1,159 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource\Order\Status\History; + +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Status\History\Collection + */ + protected $collection; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Magento\Sales\Model\Order\Status\History|\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyItemMock; + + /** + * @var \Magento\Framework\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** + * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fetchStrategyMock; + + /** + * @var \Magento\Core\Model\EntityFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + public function setUp() + { + $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $this->connectionMock = $this->getMock('Magento\Framework\DB\Adapter\Pdo\Mysql', [], [], '', false); + $this->selectMock = $this->getMock('Zend_Db_Select', [], [], '', false); + $this->historyItemMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + ['__wakeup', 'addData'], + [], + '', + false + ); + $this->resourceMock = $this->getMockForAbstractClass( + 'Magento\Framework\Model\Resource\Db\AbstractDb', + [], + '', + false, + true, + true, + ['getReadConnection', 'getMainTable', 'getTable', '__wakeup'] + ); + $this->fetchStrategyMock = $this->getMockForAbstractClass( + 'Magento\Framework\Data\Collection\Db\FetchStrategyInterface' + ); + $this->entityFactoryMock = $this->getMock('Magento\Core\Model\EntityFactory', [], [], '', false); + + $this->resourceMock->expects($this->any())->method('getReadConnection')->will( + $this->returnValue($this->connectionMock) + ); + $this->resourceMock->expects($this->any())->method('getTable')->will($this->returnArgument(0)); + + $this->connectionMock->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); + $this->connectionMock->expects($this->atLeastOnce()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + + $data = [['data']]; + $this->historyItemMock->expects($this->once()) + ->method('addData') + ->with($this->equalTo($data[0])) + ->will($this->returnValue($this->historyItemMock)); + + $this->fetchStrategyMock->expects($this->once()) + ->method('fetchAll') + ->will($this->returnValue($data)); + + $this->entityFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->historyItemMock)); + + $logger = $this->getMock('Magento\Framework\Logger', [], [], '', false); + $this->collection = new \Magento\Sales\Model\Resource\Order\Status\History\Collection( + $this->entityFactoryMock, + $logger, + $this->fetchStrategyMock, + $this->eventManagerMock, + $this->connectionMock, + $this->resourceMock + ); + } + + public function testGetUnnotifiedForInstance() + { + $orderId = 100000512; + $entityType = 'order'; + + $order = $this->getMock('Magento\Sales\Model\Order', ['__wakeup', 'getEntityType', 'getId'], [], '', false); + $order->expects($this->once()) + ->method('getEntityType') + ->will($this->returnValue($entityType)); + $order->expects($this->once()) + ->method('getId') + ->will($this->returnValue($orderId)); + + $this->connectionMock = $this->collection->getResource()->getReadConnection(); + $this->connectionMock->expects($this->exactly(3)) + ->method('prepareSqlCondition') + ->will( + $this->returnValueMap( + [ + ['entity_name', $entityType, 'sql-string'], + ['is_customer_notified', 0, 'sql-string'], + ['parent_id', $orderId, 'sql-string'] + ] + ) + ); + $result = $this->collection->getUnnotifiedForInstance($order); + $this->assertEquals($this->historyItemMock, $result); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoAddCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoAddCommentTest.php new file mode 100644 index 00000000000..f6a5a44d1db --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoAddCommentTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoAddCommentTest + */ +class CreditmemoAddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoAddComment + */ + protected $creditmemoAddComment; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\CommentConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentConverterMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataModelMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\CommentConverter', + ['getModel'], + [], + '', + false + ); + $this->dataModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Comment', + ['save', '__wakeup'], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->creditmemoAddComment = new CreditmemoAddComment($this->commentConverterMock); + } + + /** + * Test creditmemo add comment service + */ + public function testInvoke() + { + $this->commentConverterMock->expects($this->once()) + ->method('getModel') + ->with($this->equalTo($this->dataObjectMock)) + ->will($this->returnValue($this->dataModelMock)); + $this->dataModelMock->expects($this->once()) + ->method('save'); + $this->assertTrue($this->creditmemoAddComment->invoke($this->dataObjectMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCancelTest.php new file mode 100644 index 00000000000..d52b4f0db6b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCancelTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoCancelTest + */ +class CreditmemoCancelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCancel + */ + protected $creditmemoCancel; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoRepositoryMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->creditmemoRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\CreditmemoRepository', + ['get'], + [], + '', + false + ); + $this->creditmemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + [], + [], + '', + false + ); + $this->creditmemoCancel = new CreditmemoCancel( + $this->creditmemoRepositoryMock + ); + } + + /** + * test creditmemo cancel service + */ + public function testInvoke() + { + $this->creditmemoRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->creditmemoMock)); + $this->creditmemoMock->expects($this->once()) + ->method('cancel') + ->will($this->returnSelf()); + $this->assertTrue($this->creditmemoCancel->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCommentsListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCommentsListTest.php new file mode 100644 index 00000000000..01b7278f669 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCommentsListTest.php @@ -0,0 +1,197 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoCommentsListTest + */ +class CreditmemoCommentsListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCommentsList + */ + protected $creditmemoCommentsList; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\CommentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentMapperMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $criteriaBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filterBuilderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + protected function setUp() + { + $this->commentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\CommentRepository', + ['find'], + [], + '', + false + ); + $this->commentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentMapper', + ['extractDto'], + [], + '', + false + ); + $this->criteriaBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteriaBuilder', + ['create', 'addFilter'], + [], + '', + false + ); + $this->filterBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\FilterBuilder', + ['setField', 'setValue', 'create'], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->creditmemoCommentMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Comment', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->creditmemoCommentsList = new CreditmemoCommentsList( + $this->commentRepositoryMock, + $this->commentMapperMock, + $this->criteriaBuilderMock, + $this->filterBuilderMock, + $this->searchResultsBuilderMock + ); + + } + + /** + * test creditmemo comments list service + */ + public function testInvoke() + { + $creditmemoId = 1; + $this->filterBuilderMock->expects($this->once()) + ->method('setField') + ->with($this->equalTo('parent_id')) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setValue') + ->with($this->equalTo($creditmemoId)) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('filter')); + $this->criteriaBuilderMock->expects($this->once()) + ->method('addFilter') + ->with($this->equalTo(['eq' => 'filter'])) + ->will($this->returnSelf()); + $this->criteriaBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->searchCriteriaMock)); + + $this->commentRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->creditmemoCommentMock])); + + $this->commentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->creditmemoCommentMock)) + ->will($this->returnValue($this->dataObjectMock)); + + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(1)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + + $this->assertEquals('expected-result', $this->creditmemoCommentsList->invoke($creditmemoId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCreateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCreateTest.php new file mode 100644 index 00000000000..ed74f1a2005 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoCreateTest.php @@ -0,0 +1,143 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoCreateTest + */ +class CreditmemoCreateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCreate + */ + protected $creditmemoCreate; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoConverterMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + public function setUp() + { + $this->creditmemoConverterMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\CreditmemoConverter') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Magento\Framework\Logger') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->creditmemoCreate = new CreditmemoCreate( + $this->creditmemoConverterMock, + $this->loggerMock + ); + } + + public function testInvoke() + { + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoMock->expects($this->once()) + ->method('register'); + $creditmemoMock->expects($this->once()) + ->method('save') + ->will($this->returnValue(true)); + $creditmemoMock->expects($this->once()) + ->method('isValidGrandTotal') + ->will($this->returnValue(true)); + $creditmemoDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoConverterMock->expects($this->once()) + ->method('getModel') + ->with($creditmemoDataObjectMock) + ->will($this->returnValue($creditmemoMock)); + $this->assertTrue($this->creditmemoCreate->invoke($creditmemoDataObjectMock)); + } + + public function testInvokeNotValidTotal() + { + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $creditmemoMock->expects($this->once()) + ->method('isValidGrandTotal') + ->will($this->returnValue(false)); + $creditmemoDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoConverterMock->expects($this->once()) + ->method('getModel') + ->with($creditmemoDataObjectMock) + ->will($this->returnValue($creditmemoMock)); + $this->assertFalse($this->creditmemoCreate->invoke($creditmemoDataObjectMock)); + } + + public function testInvokeNoCreditmemo() + { + $creditmemoDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->creditmemoConverterMock->expects($this->once()) + ->method('getModel') + ->with($creditmemoDataObjectMock) + ->will($this->returnValue(false)); + $this->assertFalse($this->creditmemoCreate->invoke($creditmemoDataObjectMock)); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage An error has occurred during creating Creditmemo + */ + public function testInvokeException() + { + $message = 'Can not save Creditmemo'; + $e = new \Exception($message); + + $creditmemoDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($e); + $this->creditmemoConverterMock->expects($this->once()) + ->method('getModel') + ->with($creditmemoDataObjectMock) + ->will($this->throwException($e)); + $this->creditmemoCreate->invoke($creditmemoDataObjectMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoEmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoEmailTest.php new file mode 100644 index 00000000000..90003ebd87a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoEmailTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Action; + +/** + * Test Class CreditmemoEmailTest for Order Service + * + * @package Magento\Sales\Service\V1 + */ +class CreditmemoEmailTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\CreditmemoRepository + */ + protected $creditmemoRepository; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoNotifier + */ + protected $notifier; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->creditmemoRepository = $this->getMock( + '\Magento\Sales\Model\Order\CreditmemoRepository', + ['get'], + [], + '', + false + ); + $this->notifier = $this->getMock( + '\Magento\Sales\Model\Order\CreditmemoNotifier', + ['notify', '__wakeup'], + [], + '', + false + ); + + $this->service = $objectManager->getObject( + 'Magento\Sales\Service\V1\Action\CreditmemoEmail', + [ + 'creditmemoRepository' => $this->creditmemoRepository, + 'notifier' => $this->notifier + ] + ); + } + + public function testInvoke() + { + $creditmemoId = 1; + $creditmemo = $this->getMock( + '\Magento\Sales\Model\Order\Creditmemo', + ['__wakeup', 'getEmailSent'], + [], + '', + false + ); + + $this->creditmemoRepository->expects($this->once()) + ->method('get') + ->with($creditmemoId) + ->will($this->returnValue($creditmemo)); + $this->notifier->expects($this->any()) + ->method('notify') + ->with($creditmemo) + ->will($this->returnValue(true)); + + $this->assertTrue($this->service->invoke($creditmemoId)); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoGetTest.php new file mode 100644 index 00000000000..20b5d98d457 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoGetTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoGetTest + */ +class CreditmemoGetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoGet + */ + protected $creditmemoGet; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + * + * @return void + */ + protected function setUp() + { + $this->creditmemoRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\CreditmemoRepository', + ['get'], + [], + '', + false + ); + $this->creditmemoMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CreditmemoMapper', + ['extractDto'], + [], + '', + false + ); + $this->creditmemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Creditmemo', + [], + [], + '', + false + ); + + $this->creditmemoGet = new CreditmemoGet( + $this->creditmemoRepositoryMock, + $this->creditmemoMapperMock + ); + } + + /** + * Test creditmemo get service + */ + public function testInvoke() + { + $this->creditmemoRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->creditmemoMock)); + $this->creditmemoMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->creditmemoMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->assertEquals($this->dataObjectMock, $this->creditmemoGet->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoListTest.php new file mode 100644 index 00000000000..43e7690f2ba --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/CreditmemoListTest.php @@ -0,0 +1,154 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class CreditmemoListTest + */ +class CreditmemoListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoList + */ + protected $creditmemoList; + + /** + * @var \Magento\Sales\Model\Order\CreditmemoRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMapperMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + * + * @return void + */ + protected function setUp() + { + $this->creditmemoRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\CreditmemoRepository', + ['find'], + [], + '', + false + ); + $this->creditmemoMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CreditmemoMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CreditmemoSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->creditmemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Creditmemo', + [], + [], + '', + false + ); + $this->creditmemoList = new CreditmemoList( + $this->creditmemoRepositoryMock, + $this->creditmemoMapperMock, + $this->searchResultsBuilderMock + ); + } + + /** + * Test creditmemo list service + * + * @return void + */ + public function testCreditmemo() + { + $this->creditmemoRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->creditmemoMock])); + $this->creditmemoMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->creditmemoMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(count($this->creditmemoMock))) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + $this->assertEquals('expected-result', $this->creditmemoList->invoke($this->searchCriteriaMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceAddCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceAddCommentTest.php new file mode 100644 index 00000000000..2d0dafef7ad --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceAddCommentTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceAddCommentTest + */ +class InvoiceAddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceAddComment + */ + protected $invoiceAddComment; + + /** + * @var \Magento\Sales\Model\Order\Invoice\CommentConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentConverterMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataModelMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\CommentConverter', + ['getModel'], + [], + '', + false + ); + $this->dataModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Comment', + ['save', '__wakeup'], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->invoiceAddComment = new InvoiceAddComment($this->commentConverterMock); + } + + /** + * Test invoice add comment service + */ + public function testInvoke() + { + $this->commentConverterMock->expects($this->once()) + ->method('getModel') + ->with($this->equalTo($this->dataObjectMock)) + ->will($this->returnValue($this->dataModelMock)); + $this->dataModelMock->expects($this->once()) + ->method('save'); + $this->assertTrue($this->invoiceAddComment->invoke($this->dataObjectMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCaptureTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCaptureTest.php new file mode 100644 index 00000000000..c68881cd98d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCaptureTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceCaptureTest + */ +class InvoiceCaptureTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCapture + */ + protected $invoiceCapture; + + /** + * @var \Magento\Sales\Model\Order\InvoiceRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepositoryMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\InvoiceRepository', + ['get'], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + [], + [], + '', + false + ); + $this->invoiceCapture = new InvoiceCapture( + $this->invoiceRepositoryMock + ); + } + + /** + * test invoice capture service + */ + public function testInvoke() + { + $this->invoiceRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->invoiceMock)); + $this->invoiceMock->expects($this->once()) + ->method('capture') + ->will($this->returnSelf()); + $this->assertTrue($this->invoiceCapture->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCommentsListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCommentsListTest.php new file mode 100644 index 00000000000..5636a851eba --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCommentsListTest.php @@ -0,0 +1,197 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceCommentsListTest + */ +class InvoiceCommentsListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCommentsList + */ + protected $invoiceCommentsList; + + /** + * @var \Magento\Sales\Model\Order\Invoice\CommentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentMapperMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $criteriaBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filterBuilderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + protected function setUp() + { + $this->commentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\CommentRepository', + ['find'], + [], + '', + false + ); + $this->commentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentMapper', + ['extractDto'], + [], + '', + false + ); + $this->criteriaBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteriaBuilder', + ['create', 'addFilter'], + [], + '', + false + ); + $this->filterBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\FilterBuilder', + ['setField', 'setValue', 'create'], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->invoiceCommentMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Comment', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->invoiceCommentsList = new InvoiceCommentsList( + $this->commentRepositoryMock, + $this->commentMapperMock, + $this->criteriaBuilderMock, + $this->filterBuilderMock, + $this->searchResultsBuilderMock + ); + + } + + /** + * test invoice comments list service + */ + public function testInvoke() + { + $invoiceId = 1; + $this->filterBuilderMock->expects($this->once()) + ->method('setField') + ->with($this->equalTo('parent_id')) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setValue') + ->with($this->equalTo($invoiceId)) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('filter')); + $this->criteriaBuilderMock->expects($this->once()) + ->method('addFilter') + ->with($this->equalTo(['eq' => 'filter'])) + ->will($this->returnSelf()); + $this->criteriaBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->searchCriteriaMock)); + + $this->commentRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->invoiceCommentMock])); + + $this->commentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->invoiceCommentMock)) + ->will($this->returnValue($this->dataObjectMock)); + + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(1)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + + $this->assertEquals('expected-result', $this->invoiceCommentsList->invoke($invoiceId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCreateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCreateTest.php new file mode 100644 index 00000000000..fbd3c86e50a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceCreateTest.php @@ -0,0 +1,120 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceCreateTest + */ +class InvoiceCreateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCreate + */ + protected $invoiceCreate; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceConverterMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + public function setUp() + { + $this->invoiceConverterMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\InvoiceConverter') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Magento\Framework\Logger') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->invoiceCreate = new InvoiceCreate( + $this->invoiceConverterMock, + $this->loggerMock + ); + } + + public function testInvoke() + { + $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $invoiceMock->expects($this->once()) + ->method('register'); + $invoiceMock->expects($this->once()) + ->method('save') + ->will($this->returnValue(true)); + $invoiceDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->invoiceConverterMock->expects($this->once()) + ->method('getModel') + ->with($invoiceDataObjectMock) + ->will($this->returnValue($invoiceMock)); + $this->assertTrue($this->invoiceCreate->invoke($invoiceDataObjectMock)); + } + + public function testInvokeNoInvoice() + { + $invoiceDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->invoiceConverterMock->expects($this->once()) + ->method('getModel') + ->with($invoiceDataObjectMock) + ->will($this->returnValue(false)); + $this->assertFalse($this->invoiceCreate->invoke($invoiceDataObjectMock)); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage An error has occurred during creating Invoice + */ + public function testInvokeException() + { + $message = 'Can not save Invoice'; + $e = new \Exception($message); + + $invoiceDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($e); + $this->invoiceConverterMock->expects($this->once()) + ->method('getModel') + ->with($invoiceDataObjectMock) + ->will($this->throwException($e)); + $this->invoiceCreate->invoke($invoiceDataObjectMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceEmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceEmailTest.php new file mode 100644 index 00000000000..0ae4e85400a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceEmailTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Action; + +/** + * Test Class InvoiceEmailTest for Order Service + */ +class InvoiceEmailTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\InvoiceRepository + */ + protected $invoiceRepository; + + /** + * @var \Magento\Sales\Model\Order\InvoiceNotifier + */ + protected $notifier; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->invoiceRepository = $this->getMock( + '\Magento\Sales\Model\Order\InvoiceRepository', + ['get'], + [], + '', + false + ); + $this->notifier = $this->getMock( + '\Magento\Sales\Model\Order\InvoiceNotifier', + ['notify', '__wakeup'], + [], + '', + false + ); + + $this->service = $objectManager->getObject( + 'Magento\Sales\Service\V1\Action\InvoiceEmail', + [ + 'invoiceRepository' => $this->invoiceRepository, + 'notifier' => $this->notifier + ] + ); + } + + public function testInvoke() + { + $invoiceId = 1; + $invoice = $this->getMock( + '\Magento\Sales\Model\Order\Invoice', + ['__wakeup', 'getEmailSent'], + [], + '', + false + ); + + $this->invoiceRepository->expects($this->once()) + ->method('get') + ->with($invoiceId) + ->will($this->returnValue($invoice)); + $this->notifier->expects($this->any()) + ->method('notify') + ->with($invoice) + ->will($this->returnValue(true)); + + $this->assertTrue($this->service->invoke($invoiceId)); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceGetTest.php new file mode 100644 index 00000000000..73374d5b744 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceGetTest.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceGetTest + */ +class InvoiceGetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceGet + */ + protected $invoiceGet; + + /** + * @var \Magento\Sales\Model\Order\InvoiceRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\InvoiceMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\InvoiceRepository', + ['get'], + [], + '', + false + ); + $this->invoiceMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\InvoiceMapper', + [], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Invoice', + [], + [], + '', + false + ); + $this->invoiceGet = new InvoiceGet( + $this->invoiceRepositoryMock, + $this->invoiceMapperMock + ); + } + + /** + * test invoice get service + */ + public function testInvoke() + { + $this->invoiceRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->invoiceMock)); + $this->invoiceMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->invoiceMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->assertEquals($this->dataObjectMock, $this->invoiceGet->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceListTest.php new file mode 100644 index 00000000000..c254aca1021 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceListTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceListTest + */ +class InvoiceListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceList + */ + protected $invoiceList; + + /** + * @var \Magento\Sales\Model\Order\InvoiceRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\InvoiceMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMapperMock; + + /** + * @var \Magento\Sales\Service\V1\Data\InvoiceSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\InvoiceRepository', + ['find'], + [], + '', + false + ); + $this->invoiceMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\InvoiceMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\InvoiceSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Invoice', + [], + [], + '', + false + ); + $this->invoiceList = new InvoiceList( + $this->invoiceRepositoryMock, + $this->invoiceMapperMock, + $this->searchResultsBuilderMock + ); + } + + /** + * test invoice list service + */ + public function testInvoke() + { + $this->invoiceRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->invoiceMock])); + $this->invoiceMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->invoiceMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(count($this->invoiceMock))) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + $this->assertEquals('expected-result', $this->invoiceList->invoke($this->searchCriteriaMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceVoidTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceVoidTest.php new file mode 100644 index 00000000000..b1fe989127c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/InvoiceVoidTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class InvoiceVoidTest + */ +class InvoiceVoidTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceVoid + */ + protected $invoiceVoid; + + /** + * @var \Magento\Sales\Model\Order\InvoiceRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepositoryMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\InvoiceRepository', + ['get'], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + [], + [], + '', + false + ); + $this->invoiceVoid = new InvoiceVoid( + $this->invoiceRepositoryMock + ); + } + + /** + * test invoice void service + */ + public function testInvoke() + { + $this->invoiceRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->invoiceMock)); + $this->invoiceMock->expects($this->once()) + ->method('void') + ->will($this->returnSelf()); + $this->assertTrue($this->invoiceVoid->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderAddressUpdateTest.php similarity index 98% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderAddressUpdateTest.php index 2f8d6568a64..8bfea1aab84 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderAddressUpdateTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderAddressUpdateTest diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCancelTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCancelTest.php index b0ba41f3de2..14a8566780d 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCancelTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderCancelTest @@ -29,13 +29,15 @@ namespace Magento\Sales\Service\V1; class OrderCancelTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderCancel + * @var \Magento\Sales\Service\V1\Action\OrderCancel */ protected $orderCancel; + /** * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject */ protected $orderRepositoryMock; + /** * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ @@ -60,7 +62,7 @@ class OrderCancelTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderCancel = new \Magento\Sales\Service\V1\OrderCancel( + $this->orderCancel = new OrderCancel( $this->orderRepositoryMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCommentsListTest.php similarity index 97% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCommentsListTest.php index cea9475a6f6..ca486146b7e 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderCommentsListTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderCommentsListTest @@ -29,37 +29,45 @@ namespace Magento\Sales\Service\V1; class OrderCommentsListTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderCommentsList + * @var \Magento\Sales\Service\V1\Action\OrderCommentsList */ protected $orderCommentsList; + /** * @var \Magento\Sales\Model\Order\Status\HistoryRepository|\PHPUnit_Framework_MockObject_MockObject */ protected $historyRepositoryMock; + /** * @var \Magento\Sales\Service\V1\Data\OrderStatusHistoryMapper|\PHPUnit_Framework_MockObject_MockObject */ protected $historyMapperMock; + /** * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $criteriaBuilderMock; + /** * @var \Magento\Framework\Service\V1\Data\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $filterBuilderMock; + /** * @var \Magento\Sales\Service\V1\Data\OrderSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $searchResultsBuilderMock; + /** * @var \Magento\Sales\Model\Order\Status\History|\PHPUnit_Framework_MockObject_MockObject */ protected $orderCommentMock; + /** * @var \Magento\Sales\Service\V1\Data\OrderStatusHistory|\PHPUnit_Framework_MockObject_MockObject */ protected $dataObjectMock; + /** * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject */ @@ -123,7 +131,7 @@ class OrderCommentsListTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderCommentsList = new \Magento\Sales\Service\V1\OrderCommentsList( + $this->orderCommentsList = new OrderCommentsList( $this->historyRepositoryMock, $this->historyMapperMock, $this->criteriaBuilderMock, diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderEmailTest.php similarity index 84% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderEmailTest.php index b18d26e513b..258a11dfe45 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderEmailTest.php @@ -22,20 +22,19 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** - * Test Class OrderNotifyUserTest for Order Service - * @package Magento\Sales\Service\V1 + * Test Class OrderEmailTest for Order Service */ -class OrderNotifyUserTest extends \PHPUnit_Framework_TestCase +class OrderEmailTest extends \PHPUnit_Framework_TestCase { public function testInvoke() { $orderId = 1; $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $orderRepository = $this->getMock('\Magento\Sales\Model\OrderRepository', ['get'], [], '', false); - $notifier = $this->getMock('\Magento\Sales\Model\Notifier', ['notify', '__wakeup'], [], '', false); + $notifier = $this->getMock('\Magento\Sales\Model\OrderNotifier', ['notify', '__wakeup'], [], '', false); $order = $this->getMock( '\Magento\Sales\Model\Order', ['__wakeup', 'sendNewOrderEmail', 'getEmailSent'], @@ -45,7 +44,7 @@ class OrderNotifyUserTest extends \PHPUnit_Framework_TestCase ); $service = $objectManager->getObject( - 'Magento\Sales\Service\V1\OrderNotifyUser', + 'Magento\Sales\Service\V1\Action\OrderEmail', [ 'orderRepository' => $orderRepository, 'notifier' => $notifier diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetStatusTest.php similarity index 92% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetStatusTest.php index a9539a1d941..4338fafcb23 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetStatusTest.php @@ -21,9 +21,8 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; -use Magento\Sales\Service\V1\OrderGetStatus; use Magento\Sales\Model\OrderRepository; /** @@ -36,6 +35,7 @@ class OrderGetStatusTest extends \PHPUnit_Framework_TestCase * @var OrderGetStatus */ protected $service; + /** * @var OrderRepository | \PHPUnit_Framework_MockObject_MockObject */ @@ -54,7 +54,7 @@ class OrderGetStatusTest extends \PHPUnit_Framework_TestCase false ); - $this->service = new \Magento\Sales\Service\V1\OrderGetStatus($this->orderRepositoryMock); + $this->service = new OrderGetStatus($this->orderRepositoryMock); } public function testInvoke() diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetTest.php similarity index 95% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetTest.php index 89ecd2aa47f..44deab926bc 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderGetTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderGetTest @@ -29,21 +29,25 @@ namespace Magento\Sales\Service\V1; class OrderGetTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderGet + * @var \Magento\Sales\Service\V1\Action\OrderGet */ protected $orderGet; + /** * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject */ protected $orderRepositoryMock; + /** * @var \Magento\Sales\Service\V1\Data\OrderMapper|\PHPUnit_Framework_MockObject_MockObject */ protected $orderMapperMock; + /** * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ protected $orderMock; + /** * @var \Magento\Sales\Service\V1\Data\Order|\PHPUnit_Framework_MockObject_MockObject */ @@ -96,7 +100,7 @@ class OrderGetTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderGet = new \Magento\Sales\Service\V1\OrderGet( + $this->orderGet = new OrderGet( $this->orderRepositoryMock, $this->orderMapperMock ); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderHoldTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderHoldTest.php index b86fd01e6c8..9ed6367c15d 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderHoldTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderHoldTest @@ -29,18 +29,18 @@ namespace Magento\Sales\Service\V1; class OrderHoldTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderHold + * @var \Magento\Sales\Service\V1\Action\OrderHold */ protected $orderHold; + /** * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject */ - protected $orderRepositoryMock; + /** * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ - protected $orderMock; protected function setUp() @@ -59,7 +59,7 @@ class OrderHoldTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderHold = new \Magento\Sales\Service\V1\OrderHold( + $this->orderHold = new OrderHold( $this->orderRepositoryMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderListTest.php similarity index 96% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderListTest.php index 386aa8cfe38..074a9612f86 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderListTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderListTest @@ -29,29 +29,35 @@ namespace Magento\Sales\Service\V1; class OrderListTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderList + * @var \Magento\Sales\Service\V1\Action\OrderList */ protected $orderList; + /** * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject */ protected $orderRepositoryMock; + /** * @var \Magento\Sales\Service\V1\Data\OrderMapper|\PHPUnit_Framework_MockObject_MockObject */ protected $orderMapperMock; + /** * @var \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $searchResultsBuilderMock; + /** * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject */ protected $searchCriteriaMock; + /** * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ protected $orderMock; + /** * @var \Magento\Sales\Service\V1\Data\Order|\PHPUnit_Framework_MockObject_MockObject */ @@ -104,7 +110,7 @@ class OrderListTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderList = new \Magento\Sales\Service\V1\OrderList( + $this->orderList = new OrderList( $this->orderRepositoryMock, $this->orderMapperMock, $this->searchResultsBuilderMock diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderStatusHistoryAddTest.php similarity index 96% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderStatusHistoryAddTest.php index 58b1901c6b0..88b8a448753 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderStatusHistoryAddTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; use Magento\Sales\Model\OrderRepository; use Magento\Sales\Model\Order\Status\HistoryConverter; @@ -33,7 +33,7 @@ use Magento\Sales\Model\Order\Status\HistoryConverter; class OrderStatusHistoryAddTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderStatusHistoryAdd + * @var \Magento\Sales\Service\V1\Action\OrderStatusHistoryAdd */ protected $service; diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderUnHoldTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php rename to dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderUnHoldTest.php index 2c52a1763fc..f78277feff1 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/OrderUnHoldTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Sales\Service\V1\Action; /** * Class OrderUnHoldTest @@ -29,10 +29,10 @@ namespace Magento\Sales\Service\V1; class OrderUnHoldTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Sales\Service\V1\OrderUnHold + * @var \Magento\Sales\Service\V1\Action\OrderUnHold */ - protected $orderUnHold; + /** * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject */ @@ -59,7 +59,7 @@ class OrderUnHoldTest extends \PHPUnit_Framework_TestCase '', false ); - $this->orderUnHold = new \Magento\Sales\Service\V1\OrderUnHold( + $this->orderUnHold = new OrderUnHold( $this->orderRepositoryMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddCommentTest.php new file mode 100644 index 00000000000..069d3725271 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddCommentTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentAddCommentTest + */ +class ShipmentAddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentAddComment + */ + protected $shipmentAddComment; + + /** + * @var \Magento\Sales\Model\Order\Shipment\CommentConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentConverterMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataModelMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * Set up + */ + protected function setUp() + { + $this->commentConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\CommentConverter', + ['getModel'], + [], + '', + false + ); + $this->dataModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Comment', + ['save', '__wakeup'], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->shipmentAddComment = new ShipmentAddComment($this->commentConverterMock); + } + + /** + * Test shipment add comment service + */ + public function testInvoke() + { + $this->commentConverterMock->expects($this->once()) + ->method('getModel') + ->with($this->equalTo($this->dataObjectMock)) + ->will($this->returnValue($this->dataModelMock)); + $this->dataModelMock->expects($this->once()) + ->method('save'); + $this->assertTrue($this->shipmentAddComment->invoke($this->dataObjectMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddTrackTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddTrackTest.php new file mode 100644 index 00000000000..2b1b4d8dd1e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentAddTrackTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentAddTrackTest + */ +class ShipmentAddTrackTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentAddTrack + */ + protected $shipmentAddTrack; + + /** + * @var \Magento\Sales\Model\Order\Shipment\TrackConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $trackConverterMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataModelMock; + + /** + * @var \Magento\Sales\Service\V1\Data\ShipmentTrack|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * Set up + */ + protected function setUp() + { + $this->trackConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\TrackConverter', + ['getModel'], + [], + '', + false + ); + $this->dataModelMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track', + ['save', '__wakeup'], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentTrack', + [], + [], + '', + false + ); + $this->shipmentAddTrack = new ShipmentAddTrack($this->trackConverterMock); + } + + /** + * Test shipment add track service + */ + public function testInvoke() + { + $this->trackConverterMock->expects($this->once()) + ->method('getModel') + ->with($this->equalTo($this->dataObjectMock)) + ->will($this->returnValue($this->dataModelMock)); + $this->dataModelMock->expects($this->once()) + ->method('save'); + $this->assertTrue($this->shipmentAddTrack->invoke($this->dataObjectMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCommentsListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCommentsListTest.php new file mode 100644 index 00000000000..798e6bf4a00 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCommentsListTest.php @@ -0,0 +1,197 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentCommentsListTest + */ +class ShipmentCommentsListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentCommentsList + */ + protected $shipmentCommentsList; + + /** + * @var \Magento\Sales\Model\Order\Shipment\CommentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $commentMapperMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $criteriaBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\FilterBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filterBuilderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Comment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + protected function setUp() + { + $this->commentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\CommentRepository', + ['find'], + [], + '', + false + ); + $this->commentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentMapper', + ['extractDto'], + [], + '', + false + ); + $this->criteriaBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteriaBuilder', + ['create', 'addFilter'], + [], + '', + false + ); + $this->filterBuilderMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\FilterBuilder', + ['setField', 'setValue', 'create'], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CommentSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->shipmentCommentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Comment', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Comment', + [], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->shipmentCommentsList = new ShipmentCommentsList( + $this->commentRepositoryMock, + $this->commentMapperMock, + $this->criteriaBuilderMock, + $this->filterBuilderMock, + $this->searchResultsBuilderMock + ); + + } + + /** + * test shipment comments list service + */ + public function testInvoke() + { + $shipmentId = 1; + $this->filterBuilderMock->expects($this->once()) + ->method('setField') + ->with($this->equalTo('parent_id')) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('setValue') + ->with($this->equalTo($shipmentId)) + ->will($this->returnSelf()); + $this->filterBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('filter')); + $this->criteriaBuilderMock->expects($this->once()) + ->method('addFilter') + ->with($this->equalTo(['eq' => 'filter'])) + ->will($this->returnSelf()); + $this->criteriaBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->searchCriteriaMock)); + + $this->commentRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->shipmentCommentMock])); + + $this->commentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->shipmentCommentMock)) + ->will($this->returnValue($this->dataObjectMock)); + + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(1)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + + $this->assertEquals('expected-result', $this->shipmentCommentsList->invoke($shipmentId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCreateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCreateTest.php new file mode 100644 index 00000000000..69f9b3d7363 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentCreateTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentCreateTest + */ +class ShipmentCreateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentCreate + */ + protected $shipmentCreate; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentConverterMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + public function setUp() + { + $this->shipmentConverterMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\ShipmentConverter') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock = $this->getMockBuilder('Magento\Framework\Logger') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->shipmentCreate = new ShipmentCreate( + $this->shipmentConverterMock, + $this->loggerMock + ); + } + + public function testInvoke() + { + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $orderMock->expects($this->any()) + ->method('setIsInProcess') + ->with(true); + $shipmentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $shipmentMock->expects($this->once()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + $shipmentMock->expects($this->once()) + ->method('register'); + $shipmentMock->expects($this->once()) + ->method('save') + ->will($this->returnValue(true)); + $shipmentDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->shipmentConverterMock->expects($this->once()) + ->method('getModel') + ->with($shipmentDataObjectMock) + ->will($this->returnValue($shipmentMock)); + $this->assertTrue($this->shipmentCreate->invoke($shipmentDataObjectMock)); + } + + public function testInvokeNoShipment() + { + $shipmentDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->shipmentConverterMock->expects($this->once()) + ->method('getModel') + ->with($shipmentDataObjectMock) + ->will($this->returnValue(false)); + $this->assertFalse($this->shipmentCreate->invoke($shipmentDataObjectMock)); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage An error has occurred during creating Shipment + */ + public function testInvokeException() + { + $message = 'Can not save Shipment'; + $e = new \Exception($message); + + $shipmentDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($e); + $this->shipmentConverterMock->expects($this->once()) + ->method('getModel') + ->with($shipmentDataObjectMock) + ->will($this->throwException($e)); + $this->shipmentCreate->invoke($shipmentDataObjectMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentEmailTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentEmailTest.php new file mode 100644 index 00000000000..7c64b19faf8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentEmailTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Service\V1\Action; + +/** + * Test Class ShipmentEmailTest for Shipment Service + */ +class ShipmentEmailTest extends \PHPUnit_Framework_TestCase +{ + public function testInvoke() + { + $orderId = 1; + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $shipmentRepository = $this->getMock('Magento\Sales\Model\Order\ShipmentRepository', ['get'], [], '', false); + $notifier = $this->getMock('Magento\Shipping\Model\ShipmentNotifier', ['notify', '__wakeup'], [], '', false); + $order = $this->getMock( + '\Magento\Sales\Model\Order', + ['__wakeup', 'sendNewOrderEmail', 'getEmailSent'], + [], + '', + false + ); + + $service = $objectManager->getObject( + 'Magento\Sales\Service\V1\Action\ShipmentEmail', + [ + 'shipmentRepository' => $shipmentRepository, + 'notifier' => $notifier + ] + ); + $shipmentRepository->expects($this->once()) + ->method('get') + ->with($orderId) + ->will($this->returnValue($order)); + $notifier->expects($this->any()) + ->method('notify') + ->with($order) + ->will($this->returnValue(true)); + $this->assertTrue($service->invoke($orderId)); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentGetTest.php new file mode 100644 index 00000000000..88138cdc7ac --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentGetTest.php @@ -0,0 +1,117 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentGetTest + */ +class ShipmentGetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentGet + */ + protected $shipmentGet; + + /** + * @var \Magento\Sales\Model\Order\ShipmentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\ShipmentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->shipmentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\ShipmentRepository', + ['get'], + [], + '', + false + ); + $this->shipmentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentSearchResultsBuilder', + [], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Shipment', + [], + [], + '', + false + ); + $this->shipmentGet = new ShipmentGet( + $this->shipmentRepositoryMock, + $this->shipmentMapperMock + ); + } + + /** + * test shipment get service + */ + public function testInvoke() + { + $this->shipmentRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->shipmentMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->assertEquals($this->dataObjectMock, $this->shipmentGet->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentLabelGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentLabelGetTest.php new file mode 100644 index 00000000000..dc2b9ecab55 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentLabelGetTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentLabelGetTest + */ +class ShipmentLabelGetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentLabelGet + */ + protected $shipmentLabelGet; + + /** + * @var \Magento\Sales\Model\Order\ShipmentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentRepositoryMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + protected function setUp() + { + $this->shipmentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\ShipmentRepository', + ['get', 'getShippingLabel'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + [], + [], + '', + false + ); + $this->shipmentLabelGet = new ShipmentLabelGet( + $this->shipmentRepositoryMock + ); + } + + /** + * test shipment label get service + */ + public function testInvoke() + { + $this->shipmentRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once()) + ->method('getShippingLabel') + ->will($this->returnValue('shipping_label')); + $this->assertEquals('shipping_label', $this->shipmentLabelGet->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentListTest.php new file mode 100644 index 00000000000..ffff77e2ffe --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentListTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentListTest + */ +class ShipmentListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentList + */ + protected $shipmentList; + + /** + * @var \Magento\Sales\Model\Order\ShipmentRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentRepositoryMock; + + /** + * @var \Magento\Sales\Service\V1\Data\ShipmentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMapperMock; + + /** + * @var \Magento\Sales\Service\V1\Data\ShipmentSearchResultsBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \Magento\Framework\Service\V1\Data\SearchCriteria|\PHPUnit_Framework_MockObject_MockObject + */ + protected $searchCriteriaMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Sales\Service\V1\Data\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->shipmentRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\ShipmentRepository', + ['find'], + [], + '', + false + ); + $this->shipmentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Shipment', + [], + [], + '', + false + ); + $this->shipmentList = new ShipmentList( + $this->shipmentRepositoryMock, + $this->shipmentMapperMock, + $this->searchResultsBuilderMock + ); + } + + /** + * test shipment list service + */ + public function testInvoke() + { + $this->shipmentRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->shipmentMock])); + $this->shipmentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->shipmentMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo([$this->dataObjectMock])) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setTotalCount') + ->with($this->equalTo(count($this->shipmentMock))) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('setSearchCriteria') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnSelf()); + $this->searchResultsBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('expected-result')); + $this->assertEquals('expected-result', $this->shipmentList->invoke($this->searchCriteriaMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentRemoveTrackTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentRemoveTrackTest.php new file mode 100644 index 00000000000..50ec9e050c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Action/ShipmentRemoveTrackTest.php @@ -0,0 +1,83 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Action; + +/** + * Class ShipmentRemoveTrackTest + */ +class ShipmentRemoveTrackTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentRemoveTrack + */ + protected $shipmentRemoveTrack; + + /** + * @var \Magento\Sales\Model\Order\Shipment\TrackRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $trackRepositoryMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $trackMock; + + /** + * Set up + */ + protected function setUp() + { + $this->trackRepositoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Shipment\TrackRepository', + ['get'], + [], + '', + false + ); + $this->trackMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track', + ['delete', '__wakeup'], + [], + '', + false + ); + + $this->shipmentRemoveTrack = new ShipmentRemoveTrack($this->trackRepositoryMock); + } + + /** + * Test shipment remove track + */ + public function testInvoke() + { + $this->trackRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->trackMock)); + $this->trackMock->expects($this->once()) + ->method('delete'); + + $this->assertTrue($this->shipmentRemoveTrack->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoReadTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoReadTest.php new file mode 100644 index 00000000000..7dc3c992749 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoReadTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class CreditmemoReadTest + */ +class CreditmemoReadTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoGet|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoGetMock; + + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCommentsList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoCommentsListMock; + + /** + * @var \Magento\Sales\Service\V1\CreditmemoRead + */ + protected $creditmemoRead; + + /** + * SetUp + */ + protected function setUp() + { + $this->creditmemoGetMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoGet', + ['invoke'], + [], + '', + false + ); + $this->creditmemoListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoList', + ['invoke'], + [], + '', + false + ); + $this->creditmemoCommentsListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoCommentsList', + ['invoke'], + [], + '', + false + ); + + $this->creditmemoRead = new CreditmemoRead( + $this->creditmemoGetMock, + $this->creditmemoListMock, + $this->creditmemoCommentsListMock + ); + } + + /** + * test creditmemo get + */ + public function testGet() + { + $this->creditmemoGetMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('creditmemo-do')); + $this->assertEquals('creditmemo-do', $this->creditmemoRead->get(1)); + } + + /** + * test creditmemo list + */ + public function testSearch() + { + $searchCriteria = $this->getMock('Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $this->creditmemoListMock->expects($this->once()) + ->method('invoke') + ->with($searchCriteria) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->creditmemoRead->search($searchCriteria)); + } + + /** + * test comments list + */ + public function testCommentsList() + { + $this->creditmemoCommentsListMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->creditmemoRead->commentsList(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoWriteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoWriteTest.php new file mode 100644 index 00000000000..231fcb9ff4f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/CreditmemoWriteTest.php @@ -0,0 +1,148 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class CreditmemoWriteTest + */ +class CreditmemoWriteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoAddComment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoAddCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCancel|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoCancelMock; + + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoEmail|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoEmailMock; + + /** + * @var \Magento\Sales\Service\V1\Action\CreditmemoCreate|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoCreateMock; + + /** + * @var \Magento\Sales\Service\V1\CreditmemoWrite + */ + protected $creditmemoWrite; + + /** + * SetUp + */ + protected function setUp() + { + $this->creditmemoAddCommentMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoAddComment', + ['invoke'], + [], + '', + false + ); + $this->creditmemoCancelMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoCancel', + ['invoke'], + [], + '', + false + ); + $this->creditmemoEmailMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoEmail', + ['invoke'], + [], + '', + false + ); + + $this->creditmemoCreateMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\CreditmemoCreate', + ['invoke'], + [], + '', + false + ); + + $this->creditmemoWrite = new CreditmemoWrite( + $this->creditmemoAddCommentMock, + $this->creditmemoCancelMock, + $this->creditmemoEmailMock, + $this->creditmemoCreateMock + ); + } + + /** + * test creditmemo add comment + */ + public function testAddComment() + { + $comment = $this->getMock('Magento\Sales\Service\V1\Data\Comment', [], [], '', false); + $this->creditmemoAddCommentMock->expects($this->once()) + ->method('invoke') + ->with($comment) + ->will($this->returnValue(true)); + $this->assertTrue($this->creditmemoWrite->addComment($comment)); + } + + /** + * test creditmemo cancel + */ + public function testCancel() + { + $this->creditmemoCancelMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->creditmemoWrite->cancel(1)); + } + + /** + * test creditmemo email + */ + public function testEmail() + { + $this->creditmemoEmailMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->creditmemoWrite->email(1)); + } + + /** + * test creditmemo create + */ + public function testCreate() + { + $creditmemo = $this->getMock('\Magento\Sales\Service\V1\Data\Creditmemo', [], [], '', false); + $this->creditmemoCreateMock->expects($this->once()) + ->method('invoke') + ->with($creditmemo) + ->will($this->returnValue(true)); + $this->assertTrue($this->creditmemoWrite->create($creditmemo)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoCommentTest.php deleted file mode 100644 index 66c692cffbf..00000000000 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoCommentTest.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Service\V1\Data; - -class CreditmemoCommentTest extends \PHPUnit_Framework_TestCase -{ - public function testGetComment() - { - $data = ['comment' => 'test_value_comment']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_comment', $object->getComment()); - } - - public function testGetCreatedAt() - { - $data = ['created_at' => 'test_value_created_at']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_created_at', $object->getCreatedAt()); - } - - public function testGetEntityId() - { - $data = ['entity_id' => 'test_value_entity_id']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_entity_id', $object->getEntityId()); - } - - public function testGetIsCustomerNotified() - { - $data = ['is_customer_notified' => 'test_value_is_customer_notified']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_is_customer_notified', $object->getIsCustomerNotified()); - } - - public function testGetIsVisibleOnFront() - { - $data = ['is_visible_on_front' => 'test_value_is_visible_on_front']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_is_visible_on_front', $object->getIsVisibleOnFront()); - } - - public function testGetParentId() - { - $data = ['parent_id' => 'test_value_parent_id']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\CreditmemoComment($abstractBuilderMock); - - $this->assertEquals('test_value_parent_id', $object->getParentId()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoConverterTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoConverterTest.php new file mode 100644 index 00000000000..3c7b6cfe56a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoConverterTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class CreditmemoConverterTest + */ +class CreditmemoConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoConverter + */ + protected $converter; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $loaderMock; + + public function setUp() + { + $this->loaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->converter = new \Magento\Sales\Service\V1\Data\CreditmemoConverter($this->loaderMock); + } + + public function testGetModel() + { + $itemMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\CreditmemoItem') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $items = [$itemMock]; + + $dataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $dataObjectMock->expects($this->once()) + ->method('getOrderId') + ->willReturn(1); + $dataObjectMock->expects($this->once()) + ->method('getEntityId') + ->willReturn(1); + $dataObjectMock->expects($this->once()) + ->method('getItems') + ->willReturn($items); + $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->loaderMock->expects($this->once()) + ->method('load') + ->willReturn($creditmemoMock); + $this->assertInstanceOf('Magento\Sales\Model\Order\Creditmemo', $this->converter->getModel($dataObjectMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoMapperTest.php new file mode 100644 index 00000000000..839b6c93d04 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoMapperTest.php @@ -0,0 +1,127 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class CreditmemoMapperTest + */ +class CreditmemoMapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoMapper + */ + protected $creditmemoMapper; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoBuilderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\CreditmemoItemMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoItemMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoItemMock; + + /** + * SetUp + * + * @return void + */ + protected function setUp() + { + $this->creditmemoBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CreditmemoBuilder', + ['populateWithArray', 'setItems', 'create'], + [], + '', + false + ); + $this->creditmemoItemMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\CreditmemoItemMapper', + ['extractDto'], + [], + '', + false + ); + $this->creditmemoMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo', + ['getAllItems', 'getData', '__wakeup'], + [], + '', + false + ); + $this->creditmemoItemMock = $this->getMock( + 'Magento\Sales\Model\Order\Creditmemo\Item', + [], + [], + '', + false + ); + $this->creditmemoMapper = new \Magento\Sales\Service\V1\Data\CreditmemoMapper( + $this->creditmemoBuilderMock, + $this->creditmemoItemMapperMock + ); + } + + /** + * Run creditmemo mapper test + * + * @return void + */ + public function testInvoke() + { + $this->creditmemoMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue(['field-1' => 'value-1'])); + $this->creditmemoMock->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue([$this->creditmemoItemMock])); + $this->creditmemoBuilderMock->expects($this->once()) + ->method('populateWithArray') + ->with($this->equalTo(['field-1' => 'value-1'])) + ->will($this->returnSelf()); + $this->creditmemoItemMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->creditmemoItemMock)) + ->will($this->returnValue('item-1')); + $this->creditmemoBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo(['item-1'])) + ->will($this->returnSelf()); + $this->creditmemoBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('data-object-with-creditmemo')); + $this->assertEquals('data-object-with-creditmemo', $this->creditmemoMapper->extractDto($this->creditmemoMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php index cf970c2f404..3766a1599ce 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php @@ -798,4 +798,20 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); } + + public function testGetItems() + { + $data = ['items' => 'test_value_items']; + $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') + ->setMethods(['getData']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $abstractBuilderMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue($data)); + + $object = new \Magento\Sales\Service\V1\Data\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_items', $object->getItems()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceConverterTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceConverterTest.php new file mode 100644 index 00000000000..7fb8d1882b3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceConverterTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class InvoiceConverterTest + * @package Magento\Sales\Service\V1\Data + */ +class InvoiceConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceLoaderMock; + /** + * @var \Magento\Sales\Service\V1\Data\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + /** + * @var \Magento\Sales\Service\V1\Data\InvoiceItem|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceItemMock; + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $modelInvoiceMock; + /** + * @var \Magento\Sales\Service\V1\Data\InvoiceConverter + */ + protected $converter; + + public function setUp() + { + $this->invoiceLoaderMock = $this->getMockBuilder('Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader') + ->disableOriginalConstructor() + ->setMethods(['setOrderId', 'setInvoiceId', 'setInvoiceItems', 'create']) + ->getMock(); + $this->invoiceMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->invoiceItemMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\InvoiceItem') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->modelInvoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->converter = new \Magento\Sales\Service\V1\Data\InvoiceConverter($this->invoiceLoaderMock); + } + + /** + * test for Invoice converter + */ + public function testGetModel() + { + $orderId = 1; + $invoiceId = 2; + $itemId = 3; + $itemQty = 4; + $this->invoiceMock->expects($this->once()) + ->method('getOrderId') + ->will($this->returnValue($orderId)); + $this->invoiceMock->expects($this->once()) + ->method('getEntityId') + ->will($this->returnValue($invoiceId)); + $this->invoiceMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue([$this->invoiceItemMock])); + $this->invoiceItemMock->expects($this->once()) + ->method('getOrderItemId') + ->will($this->returnValue($itemId)); + $this->invoiceItemMock->expects($this->once()) + ->method('getQty') + ->will($this->returnValue($itemQty)); + $this->invoiceLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($this->equalTo($orderId)) + ->will($this->returnSelf()); + $this->invoiceLoaderMock->expects($this->once()) + ->method('setInvoiceId') + ->with($this->equalTo($invoiceId)) + ->will($this->returnSelf()); + $this->invoiceLoaderMock->expects($this->once()) + ->method('setInvoiceItems') + ->with($this->equalTo([$itemId => $itemQty])) + ->will($this->returnSelf()); + $this->invoiceLoaderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->modelInvoiceMock)); + $this->invoiceLoaderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->modelInvoiceMock)); + $this->assertInstanceOf( + 'Magento\Sales\Model\Order\Invoice', + $this->converter->getModel($this->invoiceMock) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceMapperTest.php new file mode 100644 index 00000000000..8c928909eab --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceMapperTest.php @@ -0,0 +1,127 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class InvoiceMapperTest + */ +class InvoiceMapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var InvoiceMapper + */ + protected $invoiceMapper; + + /** + * @var InvoiceBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceBuilderMock; + + /** + * @var InvoiceItemMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceItemMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + /** + * @var \Magento\Sales\Model\Order\Invoice\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceItemMock; + + /** + * SetUp + * + * @return void + */ + protected function setUp() + { + $this->invoiceBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\InvoiceBuilder', + ['populateWithArray', 'setItems', 'create'], + [], + '', + false + ); + $this->invoiceItemMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\InvoiceItemMapper', + ['extractDto'], + [], + '', + false + ); + $this->invoiceMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice', + ['getAllItems', 'getData', '__wakeup'], + [], + '', + false + ); + $this->invoiceItemMock = $this->getMock( + 'Magento\Sales\Model\Order\Invoice\Item', + [], + [], + '', + false + ); + $this->invoiceMapper = new InvoiceMapper( + $this->invoiceBuilderMock, + $this->invoiceItemMapperMock + ); + } + + /** + * Run invoice mapper test + * + * @return void + */ + public function testInvoke() + { + $this->invoiceMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue(['field-1' => 'value-1'])); + $this->invoiceMock->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue([$this->invoiceItemMock])); + $this->invoiceBuilderMock->expects($this->once()) + ->method('populateWithArray') + ->with($this->equalTo(['field-1' => 'value-1'])) + ->will($this->returnSelf()); + $this->invoiceItemMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->invoiceItemMock)) + ->will($this->returnValue('item-1')); + $this->invoiceBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo(['item-1'])) + ->will($this->returnSelf()); + $this->invoiceBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('data-object-with-invoice')); + $this->assertEquals('data-object-with-invoice', $this->invoiceMapper->extractDto($this->invoiceMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php index e05a8f42f9e..f0a74735778 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php @@ -748,22 +748,6 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase $object = new \Magento\Sales\Service\V1\Data\Invoice($abstractBuilderMock); - $this->assertEquals('test_value_items', $object->getItems()); - } - - public function testGetComments() - { - $data = ['comments' => 'test_value_comments']; - $abstractBuilderMock = $this->getMockBuilder('Magento\Framework\Service\Data\AbstractObjectBuilder') - ->setMethods(['getData']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $abstractBuilderMock->expects($this->once()) - ->method('getData') - ->will($this->returnValue($data)); - - $object = new \Magento\Sales\Service\V1\Data\Invoice($abstractBuilderMock); - - $this->assertEquals('test_value_comments', $object->getComments()); + $this->assertEquals(['test_value_items'], $object->getItems()); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentConverterTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentConverterTest.php new file mode 100644 index 00000000000..4ebfa4c5bcf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentConverterTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class ShipmentConverterTest + * @package Magento\Sales\Service\V1\Data + */ +class ShipmentConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Sales\Service\V1\Data\ShipmentConverter + */ + protected $converter; + + public function setUp() + { + $this->shipmentLoaderMock = $this->getMockBuilder('Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->converter = new \Magento\Sales\Service\V1\Data\ShipmentConverter($this->shipmentLoaderMock); + } + + public function testGetModel() + { + $orderId = 1; + $shipmentId = 2; + $items = []; + $tracking = []; + + $shipmentDataObjectMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $shipmentDataObjectMock->expects($this->any()) + ->method('getOrderId') + ->will($this->returnValue($orderId)); + $shipmentDataObjectMock->expects($this->any()) + ->method('getEntityId') + ->will($this->returnValue($shipmentId)); + $shipmentDataObjectMock->expects($this->any()) + ->method('getItems') + ->will($this->returnValue($items)); + $shipmentDataObjectMock->expects($this->any()) + ->method('getTracks') + ->will($this->returnValue($tracking)); + + $shipmentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->with() + ->will($this->returnValue($shipmentMock)); + + $this->assertInstanceOf( + 'Magento\Sales\Model\Order\Shipment', + $this->converter->getModel($shipmentDataObjectMock) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentMapperTest.php new file mode 100644 index 00000000000..90574e39dbe --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentMapperTest.php @@ -0,0 +1,167 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1\Data; + +/** + * Class ShipmentMapperTest + */ +class ShipmentMapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ShipmentMapper + */ + protected $shipmentMapper; + + /** + * @var ShipmentBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentBuilderMock; + + /** + * @var ShipmentItemMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentItemMapperMock; + + /** + * @var ShipmentTrackMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentTrackMapperMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentItemMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentTrackMock; + + /** + * SetUp + * + * @return void + */ + protected function setUp() + { + $this->shipmentBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentBuilder', + ['populateWithArray', 'setItems', 'setTracks', 'create', 'setPackages'], + [], + '', + false + ); + $this->shipmentItemMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentItemMapper', + ['extractDto'], + [], + '', + false + ); + $this->shipmentTrackMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\ShipmentTrackMapper', + ['extractDto'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['getItemsCollection', 'getTracksCollection', 'getData', '__wakeup', 'getPackages'], + [], + '', + false + ); + $this->shipmentItemMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Item', + [], + [], + '', + false + ); + $this->shipmentMapper = new ShipmentMapper( + $this->shipmentBuilderMock, + $this->shipmentItemMapperMock, + $this->shipmentTrackMapperMock + ); + } + + /** + * Run shipment mapper test + * + * @return void + */ + public function testInvoke() + { + $this->shipmentMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue(['field-1' => 'value-1'])); + $this->shipmentBuilderMock->expects($this->once()) + ->method('populateWithArray') + ->with($this->equalTo(['field-1' => 'value-1'])) + ->will($this->returnSelf()); + $this->shipmentMock->expects($this->once()) + ->method('getPackages') + ->will($this->returnValue([[], []])); + $this->shipmentBuilderMock->expects($this->once()) + ->method('setPackages') + ->with($this->equalTo(serialize([[], []]))) + ->will($this->returnSelf()); + + $this->shipmentMock->expects($this->once()) + ->method('getItemsCollection') + ->will($this->returnValue([$this->shipmentItemMock])); + $this->shipmentItemMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->shipmentItemMock)) + ->will($this->returnValue('item-1')); + $this->shipmentBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo(['item-1'])) + ->will($this->returnSelf()); + + + $this->shipmentMock->expects($this->once()) + ->method('getTracksCollection') + ->will($this->returnValue([$this->shipmentTrackMock])); + $this->shipmentTrackMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->shipmentTrackMock)) + ->will($this->returnValue('track-1')); + $this->shipmentBuilderMock->expects($this->once()) + ->method('setTracks') + ->with($this->equalTo(['track-1'])) + ->will($this->returnSelf()); + + $this->shipmentBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('data-object-with-shipment')); + $this->assertEquals('data-object-with-shipment', $this->shipmentMapper->extractDto($this->shipmentMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceReadTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceReadTest.php new file mode 100644 index 00000000000..3caefcc0551 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceReadTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class InvoiceReadTest + */ +class InvoiceReadTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceGet|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceGetMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCommentsList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceCommentsListMock; + + /** + * @var \Magento\Sales\Service\V1\InvoiceRead + */ + protected $invoiceRead; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceGetMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceGet', + ['invoke'], + [], + '', + false + ); + $this->invoiceListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceList', + ['invoke'], + [], + '', + false + ); + $this->invoiceCommentsListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceCommentsList', + ['invoke'], + [], + '', + false + ); + + $this->invoiceRead = new InvoiceRead( + $this->invoiceGetMock, + $this->invoiceListMock, + $this->invoiceCommentsListMock + ); + } + + /** + * test invoice get + */ + public function testGet() + { + $this->invoiceGetMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('invoice-do')); + $this->assertEquals('invoice-do', $this->invoiceRead->get(1)); + } + + /** + * test invoice list + */ + public function testSearch() + { + $searchCriteria = $this->getMock('Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $this->invoiceListMock->expects($this->once()) + ->method('invoke') + ->with($searchCriteria) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->invoiceRead->search($searchCriteria)); + } + + /** + * test invoice comments list + */ + public function testCommentsList() + { + $this->invoiceCommentsListMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->invoiceRead->commentsList(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceWriteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceWriteTest.php new file mode 100644 index 00000000000..ad2b7075c5f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/InvoiceWriteTest.php @@ -0,0 +1,172 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class InvoiceWriteTest + */ +class InvoiceWriteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceAddComment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceAddCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceVoid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceVoidMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceEmail|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceEmailMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCapture|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceCaptureMock; + + /** + * @var \Magento\Sales\Service\V1\Action\InvoiceCreate|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceCreateMock; + + /** + * @var \Magento\Sales\Service\V1\InvoiceWrite + */ + protected $invoiceWrite; + + /** + * SetUp + */ + protected function setUp() + { + $this->invoiceAddCommentMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceAddComment', + ['invoke'], + [], + '', + false + ); + $this->invoiceVoidMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceVoid', + ['invoke'], + [], + '', + false + ); + $this->invoiceEmailMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceEmail', + ['invoke'], + [], + '', + false + ); + $this->invoiceCaptureMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceCapture', + ['invoke'], + [], + '', + false + ); + $this->invoiceCreateMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\InvoiceCreate', + ['invoke'], + [], + '', + false + ); + + $this->invoiceWrite = new InvoiceWrite( + $this->invoiceAddCommentMock, + $this->invoiceVoidMock, + $this->invoiceEmailMock, + $this->invoiceCaptureMock, + $this->invoiceCreateMock + ); + } + + /** + * test invoice add comment + */ + public function testAddComment() + { + $comment = $this->getMock('Magento\Sales\Service\V1\Data\Comment', [], [], '', false); + $this->invoiceAddCommentMock->expects($this->once()) + ->method('invoke') + ->with($comment) + ->will($this->returnValue(true)); + $this->assertTrue($this->invoiceWrite->addComment($comment)); + } + + /** + * test invoice void + */ + public function testVoid() + { + $this->invoiceVoidMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->invoiceWrite->void(1)); + } + + /** + * test invoice email + */ + public function testEmail() + { + $this->invoiceEmailMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->invoiceWrite->email(1)); + } + + /** + * test invoice capture + */ + public function testCapture() + { + $this->invoiceCaptureMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->invoiceWrite->capture(1)); + } + + /** + * test invoice create + */ + public function testCreate() + { + $invoiceDataObject = $this->getMock('Magento\Sales\Service\V1\Data\Invoice', [], [], '', false); + $this->invoiceCreateMock->expects($this->once()) + ->method('invoke') + ->with($invoiceDataObject) + ->will($this->returnValue(true)); + $this->assertTrue($this->invoiceWrite->create($invoiceDataObject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderReadTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderReadTest.php new file mode 100644 index 00000000000..302b128cf01 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderReadTest.php @@ -0,0 +1,146 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class OrderReadTest + */ +class OrderReadTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\OrderGet|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderGetMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderCommentsList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCommentsListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderGetStatus|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderGetStatusMock; + + /** + * @var \Magento\Sales\Service\V1\OrderRead + */ + protected $orderRead; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderGetMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderGet', + ['invoke'], + [], + '', + false + ); + $this->orderListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderList', + ['invoke'], + [], + '', + false + ); + $this->orderCommentsListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderCommentsList', + ['invoke'], + [], + '', + false + ); + $this->orderGetStatusMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderGetStatus', + ['invoke'], + [], + '', + false + ); + + $this->orderRead = new OrderRead( + $this->orderGetMock, + $this->orderListMock, + $this->orderCommentsListMock, + $this->orderGetStatusMock + ); + } + + /** + * test order get + */ + public function testGet() + { + $this->orderGetMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('order-do')); + $this->assertEquals('order-do', $this->orderRead->get(1)); + } + + /** + * test order list + */ + public function testSearch() + { + $searchCriteria = $this->getMock('Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $this->orderListMock->expects($this->once()) + ->method('invoke') + ->with($searchCriteria) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->orderRead->search($searchCriteria)); + } + + /** + * test order comments list + */ + public function testCommentsList() + { + $this->orderCommentsListMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->orderRead->commentsList(1)); + } + + /** + * test order get status + */ + public function testGetStatus() + { + $this->orderGetStatusMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->orderRead->getStatus(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderWriteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderWriteTest.php new file mode 100644 index 00000000000..c98ce8d951f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderWriteTest.php @@ -0,0 +1,224 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class OrderWriteTest + */ +class OrderWriteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\OrderAddressUpdate|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderAddressUpdateMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderCancel|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCancelMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderEmail|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderEmailMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderHold|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderHoldMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderUnHold|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderUnHoldMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderStatusHistoryAdd|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderStatusHistoryAddMock; + + /** + * @var \Magento\Sales\Service\V1\Action\OrderCreate|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderCreateMock; + + /** + * @var \Magento\Sales\Service\V1\OrderWrite + */ + protected $orderWrite; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderAddressUpdateMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderAddressUpdate', + ['invoke'], + [], + '', + false + ); + $this->orderCancelMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderCancel', + ['invoke'], + [], + '', + false + ); + $this->orderEmailMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderEmail', + ['invoke'], + [], + '', + false + ); + $this->orderHoldMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderHold', + ['invoke'], + [], + '', + false + ); + $this->orderUnHoldMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderUnHold', + ['invoke'], + [], + '', + false + ); + $this->orderStatusHistoryAddMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderStatusHistoryAdd', + ['invoke'], + [], + '', + false + ); + + $this->orderCreateMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\OrderCreate', + ['invoke'], + [], + '', + false + ); + + $this->orderWrite = new OrderWrite( + $this->orderAddressUpdateMock, + $this->orderCancelMock, + $this->orderEmailMock, + $this->orderHoldMock, + $this->orderUnHoldMock, + $this->orderStatusHistoryAddMock, + $this->orderCreateMock + ); + } + + /** + * test order address update + */ + public function testAddressUpdate() + { + $orderAddress = $this->getMock('Magento\Sales\Service\V1\Data\OrderAddress', [], [], '', false); + $this->orderAddressUpdateMock->expects($this->once()) + ->method('invoke') + ->with($orderAddress) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->addressUpdate($orderAddress)); + } + + /** + * test order cancel + */ + public function testCancel() + { + $this->orderCancelMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->cancel(1)); + } + + /** + * test order email + */ + public function testEmail() + { + $this->orderEmailMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->email(1)); + } + + /** + * test order hold + */ + public function testHold() + { + $this->orderHoldMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->hold(1)); + } + + /** + * test order unhold + */ + public function testUnHold() + { + $this->orderUnHoldMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->unHold(1)); + } + + /** + * test order status history add + */ + public function testStatusHistoryAdd() + { + $statusHistory = $this->getMock('Magento\Sales\Service\V1\Data\OrderStatusHistory', [], [], '', false); + $this->orderStatusHistoryAddMock->expects($this->once()) + ->method('invoke') + ->with(1, $statusHistory) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->statusHistoryAdd(1, $statusHistory)); + } + + /** + * test order create + */ + public function testCreate() + { + $invoiceDataObject = $this->getMock('Magento\Sales\Service\V1\Data\Order', [], [], '', false); + $this->orderCreateMock->expects($this->once()) + ->method('invoke') + ->with($invoiceDataObject) + ->will($this->returnValue(true)); + $this->assertTrue($this->orderWrite->create($invoiceDataObject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentReadTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentReadTest.php new file mode 100644 index 00000000000..d2fffc4c0e0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentReadTest.php @@ -0,0 +1,146 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class ShipmentReadTest + */ +class ShipmentReadTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentGet|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentGetMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentCommentsList|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentCommentsListMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentLabelGet|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLabelGetMock; + + /** + * @var \Magento\Sales\Service\V1\ShipmentRead + */ + protected $shipmentRead; + + /** + * SetUp + */ + protected function setUp() + { + $this->shipmentGetMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentGet', + ['invoke'], + [], + '', + false + ); + $this->shipmentListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentList', + ['invoke'], + [], + '', + false + ); + $this->shipmentCommentsListMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentCommentsList', + ['invoke'], + [], + '', + false + ); + $this->shipmentLabelGetMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentLabelGet', + ['invoke'], + [], + '', + false + ); + + $this->shipmentRead = new ShipmentRead( + $this->shipmentGetMock, + $this->shipmentListMock, + $this->shipmentCommentsListMock, + $this->shipmentLabelGetMock + ); + } + + /** + * test shipment get + */ + public function testGet() + { + $this->shipmentGetMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('shipment-do')); + $this->assertEquals('shipment-do', $this->shipmentRead->get(1)); + } + + /** + * test shipment list + */ + public function testSearch() + { + $searchCriteria = $this->getMock('Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $this->shipmentListMock->expects($this->once()) + ->method('invoke') + ->with($searchCriteria) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->shipmentRead->search($searchCriteria)); + } + + /** + * test shipment comments list + */ + public function testCommentsList() + { + $this->shipmentCommentsListMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('search_result')); + $this->assertEquals('search_result', $this->shipmentRead->commentsList(1)); + } + + /** + * test shipment label get + */ + public function testGetLabel() + { + $this->shipmentLabelGetMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue('shipment-do')); + $this->assertEquals('shipment-do', $this->shipmentRead->getLabel(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentWriteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentWriteTest.php new file mode 100644 index 00000000000..7340cb5e28a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/ShipmentWriteTest.php @@ -0,0 +1,174 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Service\V1; + +/** + * Class ShipmentWriteTest + */ +class ShipmentWriteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentAddTrack|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentAddTrackMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentRemoveTrack|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentRemoveTrackMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentEmail|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentEmailMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentAddComment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentAddCommentMock; + + /** + * @var \Magento\Sales\Service\V1\Action\ShipmentCreate|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentCreateMock; + + /** + * @var \Magento\Sales\Service\V1\ShipmentWrite + */ + protected $shipmentWrite; + + /** + * SetUp + */ + protected function setUp() + { + $this->shipmentAddTrackMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentAddTrack', + ['invoke'], + [], + '', + false + ); + $this->shipmentRemoveTrackMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentRemoveTrack', + ['invoke'], + [], + '', + false + ); + $this->shipmentEmailMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentEmail', + ['invoke'], + [], + '', + false + ); + $this->shipmentAddCommentMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentAddComment', + ['invoke'], + [], + '', + false + ); + $this->shipmentCreateMock = $this->getMock( + 'Magento\Sales\Service\V1\Action\ShipmentCreate', + ['invoke'], + [], + '', + false + ); + + $this->shipmentWrite = new ShipmentWrite( + $this->shipmentAddTrackMock, + $this->shipmentRemoveTrackMock, + $this->shipmentEmailMock, + $this->shipmentAddCommentMock, + $this->shipmentCreateMock + ); + } + + /** + * test shipment add comment + */ + public function testAddTrack() + { + $track = $this->getMock('Magento\Sales\Service\V1\Data\ShipmentTrack', [], [], '', false); + $this->shipmentAddTrackMock->expects($this->once()) + ->method('invoke') + ->with($track) + ->will($this->returnValue(true)); + $this->assertTrue($this->shipmentWrite->addTrack($track)); + } + + /** + * test shipment removeTrack + */ + public function testRemoveTrack() + { + $track = $this->getMock('Magento\Sales\Service\V1\Data\ShipmentTrack', [], [], '', false); + $this->shipmentRemoveTrackMock->expects($this->once()) + ->method('invoke') + ->with($track) + ->will($this->returnValue(true)); + $this->assertTrue($this->shipmentWrite->removeTrack($track)); + } + + /** + * test shipment email + */ + public function testEmail() + { + $this->shipmentEmailMock->expects($this->once()) + ->method('invoke') + ->with(1) + ->will($this->returnValue(true)); + $this->assertTrue($this->shipmentWrite->email(1)); + } + + /** + * test shipment addComment + */ + public function testAddComment() + { + $comment = $this->getMock('Magento\Sales\Service\V1\Data\Comment', [], [], '', false); + $this->shipmentAddCommentMock->expects($this->once()) + ->method('invoke') + ->with($comment) + ->will($this->returnValue(true)); + $this->assertTrue($this->shipmentWrite->addComment($comment)); + } + + /** + * test shipment create + */ + public function testCreate() + { + $shipmentDataObject = $this->getMock('Magento\Sales\Service\V1\Data\Shipment', [], [], '', false); + $this->shipmentCreateMock->expects($this->once()) + ->method('invoke') + ->with($shipmentDataObject) + ->will($this->returnValue(true)); + $this->assertTrue($this->shipmentWrite->create($shipmentDataObject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php new file mode 100644 index 00000000000..0cfbe11413d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php @@ -0,0 +1,98 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sendfriend\Model; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Test Sendfriend + * + */ +class SendfriendTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sendfriend\Model\Sendfriend + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sendfriendDataMock; + + public function setUp() + { + + $objectManager = new ObjectManager($this); + $this->sendfriendDataMock = $this->getMockBuilder('Magento\Sendfriend\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->cookieManagerMock = $this->getMockBuilder('Magento\Framework\Stdlib\CookieManager') + ->disableOriginalConstructor()->getMock(); + + $this->model = $objectManager->getObject( + 'Magento\Sendfriend\Model\Sendfriend', + [ + 'sendfriendData' => $this->sendfriendDataMock, + 'cookieManager' => $this->cookieManagerMock, + ] + ); + + } + + public function testGetSentCountWithCheckCookie() + { + $cookieName = 'testCookieName'; + $this->sendfriendDataMock->expects($this->once())->method('getLimitBy')->with()->will( + $this->returnValue(\Magento\Sendfriend\Helper\Data::CHECK_COOKIE) + ); + $this->sendfriendDataMock->expects($this->once())->method('getCookieName')->with()->will( + $this->returnValue($cookieName) + ); + + $this->cookieManagerMock->expects($this->once())->method('getCookie')->with($cookieName); + $this->assertEquals(0, $this->model->getSentCount()); + } + + public function testSentCountByCookies() + { + $cookieName = 'testCookieName'; + $this->sendfriendDataMock->expects($this->once())->method('getCookieName')->with()->will( + $this->returnValue($cookieName) + ); + + $this->cookieManagerMock->expects($this->once())->method('getCookie')->with($cookieName); + $this->cookieManagerMock->expects($this->once())->method('setPublicCookie'); + $sendFriendClass = new \ReflectionClass('Magento\Sendfriend\Model\Sendfriend'); + $method = $sendFriendClass->getMethod('_sentCountByCookies'); + $method->setAccessible(true); + $method->invokeArgs($this->model, [true]); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php new file mode 100644 index 00000000000..e17c3f188d9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php @@ -0,0 +1,331 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class AddCommentTest + */ +class AddCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Sales\Model\Order\Email\Sender\ShipmentSender|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentSenderMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Backend\Model\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddComment + */ + protected $controller; + + protected function setUp() + { + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->shipmentSenderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender\ShipmentSender', + ['send'], + [], + '', + false + ); + $this->requestMock = $this->getMock( + 'Magento\Framework\App\Request\Http', + ['getParam', 'getPost', 'setParam'], + [], + '', + false + ); + $this->responseMock = $this->getMock( + 'Magento\Framework\App\Response\Http', + ['setBody', 'representJson'], + [], + '', + false + ); + $this->titleMock = $this->getMock( + 'Magento\Framework\App\Action\Title', + ['add'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['save', 'addComment', '__wakeup'], + [], + '', + false + ); + $this->viewMock = $this->getMock( + 'Magento\Backend\Model\View', + ['getLayout', 'loadLayout'], + [], + '', + false + ); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getResponse', 'getTitle', 'getView', 'getObjectManager'], + [], + '', + false + ); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddComment( + $contextMock, + $this->shipmentLoaderMock, + $this->shipmentSenderMock + ); + + } + + /** + * Processing section runtime errors + * + * @return void + */ + protected function exceptionResponse() + { + $dataMock = $this->getMock( + 'Magento\Core\Helper\Data', + ['jsonEncode'], + [], + '', + false + ); + + $this->objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($dataMock)); + $dataMock->expects($this->once())->method('jsonEncode')->will($this->returnValue('{json-data}')); + $this->responseMock->expects($this->once())->method('representJson')->with('{json-data}'); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $data = ['comment' => 'comment']; + $result = 'result-html'; + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false); + $blockMock = $this->getMock('Magento\Shipping\Block\Adminhtml\View\Comments', ['toHtml'], [], '', false); + + $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId); + $this->requestMock->expects($this->once()) + ->method('getPost') + ->with('comment') + ->will($this->returnValue($data)); + $this->titleMock->expects($this->once())->method('add'); + $this->requestMock->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['id', null, $shipmentId], + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipment], + ['tracking', null, $tracking] + ] + ) + ); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once())->method('addComment'); + $this->shipmentSenderMock->expects($this->once())->method('send'); + $this->shipmentMock->expects($this->once())->method('save'); + $this->viewMock->expects($this->once())->method('loadLayout')->with(false); + $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock)); + $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($blockMock)); + $blockMock->expects($this->once())->method('toHtml')->will($this->returnValue($result)); + $this->responseMock->expects($this->once())->method('setBody')->with($result); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (exception load shipment) + */ + public function testExecuteLoadException() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + $data = ['comment' => 'comment']; + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['id', null, $shipmentId], + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipment], + ['tracking', null, $tracking] + ] + ) + ); + $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId); + $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data)); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->throwException(new \Magento\Framework\Model\Exception())); + $this->exceptionResponse(); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (empty data comment) + */ + public function testEmptyCommentData() + { + $shipmentId = 1; + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId); + $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue([])); + $this->exceptionResponse(); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (save exception) + */ + public function testExecuteExceptionSave() + { + $data = ['comment' => 'comment']; + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId); + $this->requestMock->expects($this->once()) + ->method('getPost') + ->with('comment') + ->will($this->returnValue($data)); + $this->titleMock->expects($this->once())->method('add'); + $this->requestMock->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['id', null, $shipmentId], + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipment], + ['tracking', null, $tracking] + ] + ) + ); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once())->method('addComment'); + $this->shipmentSenderMock->expects($this->once())->method('send'); + $this->shipmentMock->expects($this->once())->method('save')->will($this->throwException(new \Exception())); + $this->exceptionResponse(); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php new file mode 100644 index 00000000000..579ea085aa2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddTrackTest.php @@ -0,0 +1,262 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use \Magento\Backend\App\Action; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; +/** + * Class AddTrackTest + * + * @package Magento\Shipping\Controller\Adminhtml\Order\Shipment + */ +class AddTrackTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoader; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddTrack + */ + protected $controller; + + /** + * @var Action\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $view; + + /** + * @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject + */ + protected $title; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->shipmentLoader = $this->getMockBuilder('Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getRedirect', + 'getObjectManager', + 'getTitle', + 'getView' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse', 'setBody'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + [ + 'isPost', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getParam', + 'getPost', + 'getCookie' + ], + [], + '', + false + ); + $this->objectManager = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create', 'get'], + [], + '', + false + ); + $this->title = $this->getMock('Magento\Framework\App\Action\Title', [], [], '', false); + $this->view = $this->getMock( + 'Magento\Framework\App\ViewInterface', + [], + [], + '', + false + ); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getTitle') + ->will($this->returnValue($this->title)); + $this->context->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->view)); + $this->controller = $objectManagerHelper->getObject( + 'Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddTrack', + [ + 'context' => $this->context, + 'shipmentLoader' => $this->shipmentLoader, + 'request' => $this->request, + 'response' => $this->response, + 'title' => $this->title, + 'view' => $this->view + ] + ); + } + + public function testExecute() + { + $carrier = 'carrier'; + $number = 'number'; + $title = 'title'; + $shipmentId = 1000012; + $orderId = 10003; + $tracking = []; + $shipmentData = ['items' => [], 'send_email' => '']; + $shipment = $this->getMock('Magento\Sales\Model\Order\Shipment', ['addTrack', '__wakeup'], [], '', false); + $this->request->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], + ['shipment', null, $shipmentData], ['tracking', null, $tracking] + ] + ) + ); + $this->request->expects($this->any()) + ->method('getPost') + ->will( + $this->returnValueMap( + [ + ['carrier', $carrier], + ['number', $number], + ['title', $title] + ] + ) + ); + $this->shipmentLoader->expects($this->any()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoader->expects($this->any()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoader->expects($this->any()) + ->method('setShipment') + ->with($shipmentData); + $this->shipmentLoader->expects($this->any()) + ->method('setTracking') + ->with($tracking); + $this->shipmentLoader->expects($this->once()) + ->method('load') + ->will($this->returnValue($shipment)); + $this->title->expects($this->any()) + ->method('add') + ->with('Shipments') + ->will($this->returnSelf()); + $track = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment\Track') + ->disableOriginalConstructor() + ->setMethods(['__wakeup', 'setNumber', 'setCarrierCode', 'setTitle']) + ->getMock(); + $this->objectManager->expects($this->atLeastOnce()) + ->method('create') + ->with('Magento\Sales\Model\Order\Shipment\Track') + ->will($this->returnValue($track)); + $track->expects($this->once()) + ->method('setNumber') + ->with($number) + ->will($this->returnSelf()); + $track->expects($this->once()) + ->method('setCarrierCode') + ->with($carrier) + ->will($this->returnSelf()); + $track->expects($this->once()) + ->method('setTitle') + ->with($title) + ->will($this->returnSelf()); + $this->view->expects($this->once()) + ->method('loadLayout') + ->will($this->returnSelf()); + $layout = $this->getMock('Magento\Framework\View\Layout\Element\Layout', ['getBlock'], [], '', false); + $menuBlock = $this->getMock('Magento\Framework\View\Element\BlockInterface', ['toHtml'], [], '', false); + $html = 'html string'; + $this->view->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layout)); + $layout->expects($this->once()) + ->method('getBlock') + ->with('shipment_tracking') + ->will($this->returnValue($menuBlock)); + $menuBlock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + $shipment->expects($this->once()) + ->method('addTrack') + ->with($this->equalTo($track)) + ->will($this->returnSelf()); + $shipment->expects($this->any()) + ->method('save') + ->will($this->returnSelf()); + $this->response->expects($this->once()) + ->method('setBody') + ->with($html); + $this->assertNull($this->controller->execute()); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php new file mode 100644 index 00000000000..7f3fa60c2ca --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/CreateLabelTest.php @@ -0,0 +1,257 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class CreateLabelTest + */ +class CreateLabelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Shipping\Model\Shipping\LabelGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $labelGenerator; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\CreateLabel + */ + protected $controller; + + protected function setUp() + { + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['__wakeup', 'save'], + [], + '', + false + ); + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', ['getParam'], [], '', false); + $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', ['representJson'], [], '', false); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->labelGenerator = $this->getMock( + 'Magento\Shipping\Model\Shipping\LabelGenerator', + ['create'], + [], + '', + false + ); + + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getResponse', 'getMessageManager', 'getActionFlag', 'getObjectManager'], + [], + '', + false + ); + + $this->loadShipment(); + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\CreateLabel( + $contextMock, + $this->shipmentLoaderMock, + $this->labelGenerator + ); + } + + /** + * Load shipment object + * + * @return void + */ + protected function loadShipment() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipment') + ->with($shipment); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setTracking') + ->with($tracking); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->labelGenerator->expects($this->once()) + ->method('create') + ->with($this->shipmentMock, $this->requestMock) + ->will($this->returnValue(true)); + $this->shipmentMock->expects($this->once())->method('save')->will($this->returnSelf()); + $this->messageManagerMock->expects($this->once())->method('addSuccess'); + $this->responseMock->expects($this->once())->method('representJson'); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (exception load shipment) + */ + public function testExecuteLoadException() + { + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->throwException(new \Magento\Framework\Model\Exception())); + $this->responseMock->expects($this->once())->method('representJson'); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (exception save shipment) + */ + public function testExecuteSaveException() + { + $logerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->labelGenerator->expects($this->once()) + ->method('create') + ->with($this->shipmentMock, $this->requestMock) + ->will($this->returnValue(true)); + $this->shipmentMock->expects($this->once())->method('save')->will($this->throwException(new \Exception())); + $logerMock->expects($this->once())->method('logException'); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\Logger') + ->will($this->returnValue($logerMock)); + $this->responseMock->expects($this->once())->method('representJson'); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (fail generate label) + */ + public function testExecuteLabelGenerateFail() + { + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->labelGenerator->expects($this->once()) + ->method('create') + ->with($this->shipmentMock, $this->requestMock) + ->will($this->throwException(new \Magento\Framework\Model\Exception())); + $this->responseMock->expects($this->once())->method('representJson'); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/EmailTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/EmailTest.php new file mode 100644 index 00000000000..066b7d70120 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/EmailTest.php @@ -0,0 +1,266 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\Action\Context; + +/** + * Class EmailTest + * + * @package Magento\Shipping\Controller\Adminhtml\Order\Shipment + */ +class EmailTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Email + */ + protected $shipmentEmail; + + /** + * @var Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoader; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->shipmentLoader = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getMessageManager', + 'getRedirect', + 'getObjectManager', + 'getSession', + 'getActionFlag', + 'getHelper' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], + '', + false + ); + $this->objectManager = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create'], + [], + '', + false + ); + $this->messageManager = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->session = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->context->expects($this->once()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManager)); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->session)); + $this->context->expects($this->once()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlag)); + $this->context->expects($this->once()) + ->method('getHelper') + ->will($this->returnValue($this->helper)); + $this->shipmentEmail = $objectManagerHelper->getObject( + 'Magento\Shipping\Controller\Adminhtml\Order\Shipment\Email', + [ + 'context' => $this->context, + 'shipmentLoader' => $this->shipmentLoader, + 'request' => $this->request, + 'response' => $this->response + ] + ); + } + + public function testEmail() + { + $shipmentId = 1000012; + $orderId = 10003; + $tracking = []; + $shipment = ['items' => []]; + $orderShipment = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['load', 'save', '__wakeup'], + [], + '', + false + ); + $shipmentNotifierClassName = 'Magento\Shipping\Model\ShipmentNotifier'; + $shipmentNotifier = $this->getMock($shipmentNotifierClassName, ['notify', '__wakeup'], [], '', false); + + $this->request->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipment], + ['tracking', null, $tracking] + ] + ) + ); + $this->shipmentLoader->expects($this->once()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoader->expects($this->once()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoader->expects($this->once()) + ->method('setShipment') + ->with($shipment); + $this->shipmentLoader->expects($this->once()) + ->method('setTracking') + ->with($tracking); + $this->shipmentLoader->expects($this->once()) + ->method('load') + ->will($this->returnValue($orderShipment)); + $orderShipment->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->objectManager->expects($this->once()) + ->method('create') + ->with($shipmentNotifierClassName) + ->will($this->returnValue($shipmentNotifier)); + $shipmentNotifier->expects($this->once()) + ->method('notify') + ->with($orderShipment) + ->will($this->returnValue(true)); + $this->messageManager->expects($this->once()) + ->method('addSuccess') + ->with('You sent the shipment.'); + $path = '*/*/view'; + $arguments = ['shipment_id' => $shipmentId]; + $this->prepareRedirect($path, $arguments, 0); + + $this->shipmentEmail->execute(); + $this->assertEquals($this->response, $this->shipmentEmail->getResponse()); + } + + /** + * @param string $path + * @param array $arguments + * @param int $index + */ + protected function prepareRedirect($path, $arguments, $index) + { + $this->actionFlag->expects($this->any()) + ->method('get') + ->with('', 'check_url_settings') + ->will($this->returnValue(true)); + $this->session->expects($this->any()) + ->method('setIsUrlNotice') + ->with(true); + + $url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : ''); + $this->helper->expects($this->at($index)) + ->method('getUrl') + ->with($path, $arguments) + ->will($this->returnValue($url)); + $this->response->expects($this->at($index)) + ->method('setRedirect') + ->with($url); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php new file mode 100644 index 00000000000..dddb916c7f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/GetShippingItemsGridTest.php @@ -0,0 +1,175 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class GetShippingItemsGridTest + */ +class GetShippingItemsGridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Backend\Model\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\GetShippingItemsGrid + */ + protected $controller; + + protected function setUp() + { + $this->requestMock = $this->getMock( + 'Magento\Framework\App\Request\Http', + ['getParam'], + [], + '', + false + ); + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->viewMock = $this->getMock( + 'Magento\Backend\Model\View', + ['getLayout', 'renderLayout'], + [], + '', + false + ); + $this->responseMock = $this->getMock( + 'Magento\Framework\App\Response\Http', + ['setBody'], + [], + '', + false + ); + + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getResponse', 'getView'], + [], + '', + false + ); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\GetShippingItemsGrid( + $contextMock, + $this->shipmentLoaderMock + ); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + $result = 'result-html'; + + $layoutMock = $this->getMock( + 'Magento\Framework\View\Layout', + ['createBlock'], + [], + '', + false + ); + $gridMock = $this->getMock( + 'Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid', + ['setIndex', 'toHtml'], + [], + '', + false + ); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + $this->shipmentLoaderMock->expects($this->once())->method('load'); + $layoutMock->expects($this->once()) + ->method('createBlock') + ->with('Magento\Shipping\Block\Adminhtml\Order\Packaging\Grid') + ->will($this->returnValue($gridMock)); + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + $this->responseMock->expects($this->once()) + ->method('setBody') + ->with($result) + ->will($this->returnSelf()); + $this->requestMock->expects($this->at(4)) + ->method('getParam') + ->with('index'); + $gridMock->expects($this->once()) + ->method('setIndex') + ->will($this->returnSelf()); + $gridMock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($result)); + + $this->assertNotEmpty('result-html', $this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php new file mode 100644 index 00000000000..fc0a9e1e497 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewActionTest.php @@ -0,0 +1,293 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use \Magento\Backend\App\Action; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class NewActionTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class NewActionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoader; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\NewAction + */ + protected $newAction; + + /** + * @var Action\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject + */ + protected $title; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $view; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->shipmentLoader = $this->getMockBuilder('Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->labelGenerator = $this->getMockBuilder('Magento\Shipping\Model\Shipping\LabelGenerator') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->shipmentSender = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\ShipmentSender') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', + 'getSession', 'getActionFlag', 'getHelper', 'getTitle', 'getView' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], + '', + false + ); + $this->messageManager = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->session = $this->getMock( + 'Magento\Backend\Model\Session', + ['setIsUrlNotice', 'getCommentText'], + [], + '', + false + ); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->helper = $this->getMock('Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->title = $this->getMock('Magento\Framework\App\Action\Title', [], [], '', false); + $this->view = $this->getMock('Magento\Framework\App\ViewInterface', [], [], '', false); + $this->context->expects($this->once()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManager)); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->session)); + $this->context->expects($this->once()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlag)); + $this->context->expects($this->once()) + ->method('getHelper') + ->will($this->returnValue($this->helper)); + $this->context->expects($this->once())->method('getTitle')->will($this->returnValue($this->title)); + $this->context->expects($this->once())->method('getView')->will($this->returnValue($this->view)); + $this->newAction = $objectManagerHelper->getObject( + 'Magento\Shipping\Controller\Adminhtml\Order\Shipment\NewAction', + [ + 'context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, + 'response' => $this->response, 'title' => $this->title, 'view' => $this->view + ] + ); + } + + public function testExecute() + { + $shipmentId = 1000012; + $orderId = 10003; + $tracking = []; + $shipmentData = ['items' => [], 'send_email' => '']; + $shipment = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['load', 'save', 'register', 'getOrder', 'getOrderId', '__wakeup'], + [], + '', + false + ); + $this->request->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipmentData], + ['tracking', null, $tracking] + ] + ) + ); + $this->shipmentLoader->expects($this->any()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoader->expects($this->any()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoader->expects($this->any()) + ->method('setShipment') + ->with($shipmentData); + $this->shipmentLoader->expects($this->any()) + ->method('setTracking') + ->with($tracking); + $this->shipmentLoader->expects($this->once()) + ->method('load') + ->will($this->returnValue($shipment)); + $this->session->expects($this->once()) + ->method('getCommentText') + ->with(true) + ->will($this->returnValue('')); + $this->objectManager->expects($this->atLeastOnce()) + ->method('get') + ->with('Magento\Backend\Model\Session') + ->will($this->returnValue($this->session)); + $this->view->expects($this->once()) + ->method('loadLayout') + ->will($this->returnSelf()); + $this->view->expects($this->once()) + ->method('renderLayout') + ->will($this->returnSelf()); + $layout = $this->getMock('Magento\Framework\View\Layout\Element\Layout', ['getBlock'], [], '', false); + $menuBlock = $this->getMock( + 'Magento\Framework\View\Element\BlockInterface', + ['toHtml', 'setActive', 'getMenuModel'], + [], + '', + false + ); + $menuModel = $this->getMock('Magento\Backend\Model\Menu', ['getParentItems'], [], '', false); + $itemId = 'Magento_Sales::sales_order'; + $parents = [ + new \Magento\Framework\Object(['title' => 'title1']), + new \Magento\Framework\Object(['title' => 'title2']), + new \Magento\Framework\Object(['title' => 'title3']) + ]; + $menuModel->expects($this->once()) + ->method('getParentItems') + ->with($itemId) + ->will($this->returnValue($parents)); + $menuBlock->expects($this->once()) + ->method('setActive') + ->with($itemId); + $menuBlock->expects($this->once()) + ->method('getMenuModel') + ->will($this->returnValue($menuModel)); + $this->view->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layout)); + $layout->expects($this->once()) + ->method('getBlock') + ->with('menu') + ->will($this->returnValue($menuBlock)); + + $this->title->expects($this->any()) + ->method('add') + ->will($this->returnValueMap( + ['Shipments', false, $this->title], + [$parents[0]->getData('title'), true, $this->title], + [$parents[1]->getData('title'), true, $this->title], + [$parents[2]->getData('title'), true, $this->title] + )); + + $this->assertNull($this->newAction->execute()); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabelTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabelTest.php new file mode 100644 index 00000000000..67213b28464 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintLabelTest.php @@ -0,0 +1,386 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class PrintLabelTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class PrintLabelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Framework\App\Response\Http\FileFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fileFactoryMock; + + /** + * @var \Magento\Shipping\Model\Shipping\LabelGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $labelGenerator; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\PrintLabel + */ + protected $controller; + + protected function setUp() + { + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->labelGenerator = $this->getMock( + 'Magento\Shipping\Model\Shipping\LabelGenerator', + ['createPdfPageFromImageString'], + [], + '', + false + ); + $this->fileFactoryMock = $this->getMock( + 'Magento\Framework\App\Response\Http\FileFactory', + ['create'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['getIncrementId', 'getShippingLabel', '__wakeup'], + [], + '', + false + ); + $this->messageManagerMock = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addError'], + [], + '', + false + ); + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', ['getParam'], [], '', false); + $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + $this->helperMock = $this->getMock( + 'Magento\Backend\Helper\Data', + ['getUrl'], + [], + '', + false + ); + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', + 'getResponse', + 'getMessageManager', + 'getSession', + 'getActionFlag', + 'getObjectManager', + 'getHelper' + ], + [], + '', + false + ); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlag)); + $contextMock->expects($this->any())->method('getHelper')->will($this->returnValue($this->helperMock)); + $contextMock->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManagerMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $this->loadShipment(); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\PrintLabel( + $contextMock, + $this->shipmentLoaderMock, + $this->labelGenerator, + $this->fileFactoryMock + ); + } + + /** + * Load shipment object + * + * @return void + */ + protected function loadShipment() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipment') + ->with($shipment); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setTracking') + ->with($tracking); + } + + /** + * Run file create section + * + * @return string + */ + protected function fileCreate() + { + $resultContent = 'result-pdf-content'; + $incrementId = '1000001'; + + $this->shipmentMock->expects($this->once()) + ->method('getIncrementId') + ->will($this->returnValue($incrementId)); + $this->fileFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($resultContent)); + + return $resultContent; + } + + /** + * Redirect into response section + * + * @return void + */ + protected function redirectSection() + { + $this->actionFlag->expects($this->once()) + ->method('get') + ->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true); + $this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path')); + $this->responseMock->expects($this->once())->method('setRedirect'); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $labelContent = '%PDF-label-content'; + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once()) + ->method('getShippingLabel') + ->will($this->returnValue($labelContent)); + + $this->assertEquals($this->fileCreate(), $this->controller->execute()); + } + + /** + * Run test execute method (create new file for render) + */ + public function testExecuteFromImageString() + { + $labelContent = 'Label-content'; + $pdfPageMock = $this->getMock( + 'Zend_Pdf_Page', + ['render', 'getPageDictionary'], + [], + '', + false + ); + $pageDictionaryMock = $this->getMock( + 'Zend_Pdf_Element_Dictionary', + ['touch', 'getObject'], + [], + '', + false + ); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once()) + ->method('getShippingLabel') + ->will($this->returnValue($labelContent)); + $this->labelGenerator->expects($this->once()) + ->method('createPdfPageFromImageString') + ->with($labelContent) + ->will($this->returnValue($pdfPageMock)); + $pdfPageMock->expects($this->any()) + ->method('getPageDictionary') + ->will($this->returnValue($pageDictionaryMock)); + $pageDictionaryMock->expects($this->any()) + ->method('getObject') + ->will($this->returnSelf()); + + $this->assertEquals($this->fileCreate(), $this->controller->execute()); + } + + /** + * Run test execute method (fail load page from image string) + */ + public function testExecuteImageStringFail() + { + $labelContent = 'Label-content'; + $incrementId = '1000001'; + + $loggerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once()) + ->method('getShippingLabel') + ->will($this->returnValue($labelContent)); + $this->shipmentMock->expects($this->once()) + ->method('getIncrementId') + ->will($this->returnValue($incrementId)); + $this->labelGenerator->expects($this->once()) + ->method('createPdfPageFromImageString') + ->with($labelContent) + ->will($this->returnValue(false)); + $this->messageManagerMock->expects($this->at(0)) + ->method('addError') + ->with(sprintf('We don\'t recognize or support the file extension in this shipment: %s.', $incrementId)) + ->will($this->throwException(new \Exception())); + $this->messageManagerMock->expects($this->at(1)) + ->method('addError') + ->with('An error occurred while creating shipping label.') + ->will($this->returnSelf()); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\Logger') + ->will($this->returnValue($loggerMock)); + $loggerMock->expects($this->once()) + ->method('logException'); + $this->requestMock->expects($this->at(4)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue(1)); + $this->redirectSection(); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (fail load shipment model) + */ + public function testExecuteLoadShipmentFail() + { + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->throwException(new \Magento\Framework\Model\Exception())); + $this->messageManagerMock->expects($this->once())->method('addError')->will($this->returnSelf()); + $this->redirectSection(); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackageTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackageTest.php new file mode 100644 index 00000000000..3424b10accd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/PrintPackageTest.php @@ -0,0 +1,243 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class PrintPackageTest + */ +class PrintPackageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Framework\App\Response\Http\FileFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fileFactoryMock; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\PrintPackage + */ + protected $controller; + + protected function setUp() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', ['getParam'], [], '', false); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + $this->responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->sessionMock = $this->getMock('Magento\Backend\Model\Session', ['setIsUrlNotice'], [], '', false); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->shipmentMock = $this->getMock('Magento\Sales\Model\Order\Shipment', ['__wakeup'], [], '', false); + $this->fileFactoryMock = $this->getMock( + 'Magento\Framework\App\Response\Http\FileFactory', + ['create'], + [], + '', + false + ); + + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getObjectManager', 'getResponse', 'getSession', 'getActionFlag'], + [], + '', + false + ); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlag)); + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipment') + ->with($shipment); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setTracking') + ->with($tracking); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\PrintPackage( + $contextMock, + $this->shipmentLoaderMock, + $this->fileFactoryMock + ); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $date = '9999-99-99_77-77-77'; + $content = 'PDF content'; + + $packagingMock = $this->getMock( + 'Magento\Shipping\Model\Order\Pdf\Packaging', + ['getPdf'], + [], + '', + false + ); + $pdfMock = $this->getMock( + 'Zend_Pdf', + ['render'], + [], + '', + false + ); + $dateTimeMock = $this->getMock( + 'Magento\Framework\Stdlib\DateTime\DateTime', + ['date'], + [], + '', + false + ); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Shipping\Model\Order\Pdf\Packaging') + ->will($this->returnValue($packagingMock)); + $packagingMock->expects($this->once()) + ->method('getPdf') + ->with($this->shipmentMock) + ->will($this->returnValue($pdfMock)); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Framework\Stdlib\DateTime\DateTime') + ->will($this->returnValue($dateTimeMock)); + $dateTimeMock->expects($this->once())->method('date')->with('Y-m-d_H-i-s')->will($this->returnValue($date)); + $pdfMock->expects($this->once())->method('render')->will($this->returnValue($content)); + $this->fileFactoryMock->expects($this->once()) + ->method('create') + ->with( + 'packingslip' . $date . '.pdf', + $content, + \Magento\Framework\App\Filesystem::VAR_DIR, + 'application/pdf' + )->will($this->returnValue('result-pdf-content')); + + $this->assertEquals('result-pdf-content', $this->controller->execute()); + } + + /** + * Run test execute method (fail print) + */ + public function testExecuteFail() + { + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->actionFlag->expects($this->once()) + ->method('get') + ->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once()) + ->method('setIsUrlNotice') + ->with(true); + + $this->assertNull($this->controller->execute()); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrackTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrackTest.php new file mode 100644 index 00000000000..7b922c53174 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/RemoveTrackTest.php @@ -0,0 +1,325 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class RemoveTrackTest + */ +class RemoveTrackTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment\Track|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentTrackMock; + + /** + * @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Backend\Model\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\RemoveTrack + */ + protected $controller; + + protected function setUp() + { + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', ['getParam'], [], '', false); + $this->objectManagerMock = $this->getMock( + 'Magento\Framework\ObjectManager', + ['create', 'get', 'configure'], + [], + '', + false + ); + $this->shipmentTrackMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment\Track', + ['load', 'getId', 'delete', '__wakeup'], + [], + '', + false + ); + $this->titleMock = $this->getMock( + 'Magento\Framework\App\Action\Title', + ['add'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['getIncrementId', '__wakeup'], + [], + '', + false + ); + $this->viewMock = $this->getMock( + 'Magento\Backend\Model\View', + ['loadLayout', 'getLayout'], + [], + '', + false + ); + $this->responseMock = $this->getMock( + 'Magento\Framework\App\Response\Http', + [], + [], + '', + false + ); + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getObjectManager', 'getTitle', 'getView', 'getResponse'], + [], + '', + false + ); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('Magento\Sales\Model\Order\Shipment\Track') + ->will($this->returnValue($this->shipmentTrackMock)); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManagerMock)); + $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\RemoveTrack( + $contextMock, + $this->shipmentLoaderMock + ); + } + + /** + * Shipment load sections + * + * @return void + */ + protected function shipmentLoad() + { + $orderId = 1; + $shipmentId = 1; + $trackId = 1; + $shipment = []; + $tracking = []; + + $this->shipmentTrackMock->expects($this->once()) + ->method('load') + ->with($trackId) + ->will($this->returnSelf()); + $this->shipmentTrackMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($trackId)); + $this->titleMock->expects($this->once()) + ->method('add') + ->with('Shipments') + ->will($this->returnSelf()); + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('track_id') + ->will($this->returnValue($trackId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(4)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + } + + /** + * Represent json json section + * + * @param array $errors + * @return void + */ + protected function representJson(array $errors) + { + $dataHelper = $this->getMock('Magento\Core\Helper\Data', ['jsonEncode'], [], '', false); + $dataHelper->expects($this->once()) + ->method('jsonEncode') + ->with($errors) + ->will($this->returnValue('{json}')); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Data') + ->will($this->returnValue($dataHelper)); + $this->responseMock->expects($this->once()) + ->method('representJson') + ->with('{json}'); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $response = 'html-data'; + $this->shipmentLoad(); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentTrackMock->expects($this->once()) + ->method('delete') + ->will($this->returnSelf()); + + $layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false); + $trackingBlockMock = $this->getMock( + 'Magento\Shipping\Block\Adminhtml\Order\Tracking', + ['toHtml'], + [], + '', + false + ); + + $trackingBlockMock->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($response)); + $layoutMock->expects($this->once()) + ->method('getBlock') + ->with('shipment_tracking') + ->will($this->returnValue($trackingBlockMock)); + $this->viewMock->expects($this->once())->method('loadLayout')->will($this->returnSelf()); + $this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock)); + $this->responseMock->expects($this->once()) + ->method('setBody') + ->with($response); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (fail track load) + */ + public function testExecuteTrackIdFail() + { + $trackId = null; + $errors = ['error' => true, 'message' => 'Cannot load track with retrieving identifier.']; + + $this->shipmentTrackMock->expects($this->once()) + ->method('load') + ->with($trackId) + ->will($this->returnSelf()); + $this->shipmentTrackMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($trackId)); + $this->representJson($errors); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (fail load shipment) + */ + public function testExecuteShipmentLoadFail() + { + $errors = [ + 'error' => true, + 'message' => 'Cannot initialize shipment for delete tracking number.' + ]; + $this->shipmentLoad(); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(null)); + $this->representJson($errors); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (delete exception) + */ + public function testExecuteDeleteFail() + { + $errors = ['error' => true, 'message' => 'Cannot delete tracking number.']; + $this->shipmentLoad(); + + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentTrackMock->expects($this->once()) + ->method('delete') + ->will($this->throwException(new \Exception())); + $this->representJson($errors); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php new file mode 100644 index 00000000000..a08033176e0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php @@ -0,0 +1,317 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use \Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; +/** + * Class SaveTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class SaveTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoader; + + /** + * @var \Magento\Shipping\Model\Shipping\LabelGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $labelGenerator; + + /** + * @var ShipmentSender|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentSender; + + /** + * @var Action\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save + */ + protected $saveAction; + + public function setUp() + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->shipmentLoader = $this->getMockBuilder('Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->labelGenerator = $this->getMockBuilder('Magento\Shipping\Model\Shipping\LabelGenerator') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->shipmentSender = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\ShipmentSender') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->context = $this->getMock( + 'Magento\Backend\App\Action\Context', + [ + 'getRequest', 'getResponse', 'getMessageManager', 'getRedirect', + 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper' + ], + [], + '', + false + ); + $this->response = $this->getMock( + 'Magento\Framework\App\ResponseInterface', + ['setRedirect', 'sendResponse'], + [], + '', + false + ); + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + ['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], + [], + '', + false + ); + $this->objectManager = $this->getMock( + 'Magento\Framework\ObjectManager\ObjectManager', + ['create', 'get'], + [], + '', + false + ); + $this->messageManager = $this->getMock( + 'Magento\Framework\Message\Manager', + ['addSuccess', 'addError'], + [], + '', + false + ); + $this->session = $this->getMock( + 'Magento\Backend\Model\Session', + ['setIsUrlNotice', 'getCommentText'], + [], + '', + false + ); + $this->actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', ['get'], [], '', false); + $this->helper = $this->getMock('\Magento\Backend\Helper\Data', ['getUrl'], [], '', false); + $this->context->expects($this->once()) + ->method('getMessageManager') + ->will($this->returnValue($this->messageManager)); + $this->context->expects($this->once()) + ->method('getRequest') + ->will($this->returnValue($this->request)); + $this->context->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($this->response)); + $this->context->expects($this->once()) + ->method('getObjectManager') + ->will($this->returnValue($this->objectManager)); + $this->context->expects($this->once()) + ->method('getSession') + ->will($this->returnValue($this->session)); + $this->context->expects($this->once()) + ->method('getActionFlag') + ->will($this->returnValue($this->actionFlag)); + $this->context->expects($this->once()) + ->method('getHelper') + ->will($this->returnValue($this->helper)); + $this->saveAction = $objectManagerHelper->getObject( + 'Magento\Shipping\Controller\Adminhtml\Order\Shipment\Save', + [ + 'labelGenerator' => $this->labelGenerator, 'shipmentSender' => $this->shipmentSender, + 'context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, + 'request' => $this->request, 'response' => $this->response + ] + ); + } + + public function testExecute() + { + $shipmentId = 1000012; + $orderId = 10003; + $tracking = []; + $shipmentData = ['items' => [], 'send_email' => '']; + $shipment = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['load', 'save', 'register', 'getOrder', 'getOrderId', '__wakeup'], + [], + '', + false + ); + $order = $this->getMock( + 'Magento\Sales\Model\Order', + ['setCustomerNoteNotify', '__wakeup'], + [], + '', + false + ); + + $this->request->expects($this->any()) + ->method('getParam') + ->will( + $this->returnValueMap( + [ + ['order_id', null, $orderId], + ['shipment_id', null, $shipmentId], + ['shipment', null, $shipmentData], + ['tracking', null, $tracking] + ] + ) + ); + $this->shipmentLoader->expects($this->any()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoader->expects($this->any()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoader->expects($this->any()) + ->method('setShipment') + ->with($shipmentData); + $this->shipmentLoader->expects($this->any()) + ->method('setTracking') + ->with($tracking); + $this->shipmentLoader->expects($this->once()) + ->method('load') + ->will($this->returnValue($shipment)); + $shipment->expects($this->once()) + ->method('register') + ->will($this->returnSelf()); + $shipment->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($order)); + $order->expects($this->once()) + ->method('setCustomerNoteNotify') + ->with(false); + $this->labelGenerator->expects($this->any()) + ->method('create') + ->with($shipment, $this->request) + ->will($this->returnValue(true)); + $saveTransaction = $this->getMockBuilder('Magento\Framework\DB\Transaction') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $saveTransaction->expects($this->at(0)) + ->method('addObject') + ->with($shipment) + ->will($this->returnSelf()); + $saveTransaction->expects($this->at(1)) + ->method('addObject') + ->with($order) + ->will($this->returnSelf()); + $saveTransaction->expects($this->at(2)) + ->method('save'); + + $this->session->expects($this->once()) + ->method('getCommentText') + ->with(true); + + $this->objectManager->expects($this->once()) + ->method('create') + ->with('Magento\Framework\DB\Transaction') + ->will($this->returnValue($saveTransaction)); + $this->objectManager->expects($this->once()) + ->method('get') + ->with('Magento\Backend\Model\Session') + ->will($this->returnValue($this->session)); + $path = 'sales/order/view'; + $arguments = ['order_id' => $orderId]; + $shipment->expects($this->once()) + ->method('getOrderId') + ->will($this->returnValue($orderId)); + $this->prepareRedirect($path, $arguments); + + $this->saveAction->execute(); + $this->assertEquals($this->response, $this->saveAction->getResponse()); + } + + /** + * @param string $path + * @param array $arguments + */ + protected function prepareRedirect($path, array $arguments = []) + { + $this->actionFlag->expects($this->any()) + ->method('get') + ->with('', 'check_url_settings') + ->will($this->returnValue(true)); + $this->session->expects($this->any()) + ->method('setIsUrlNotice') + ->with(true); + + $url = $path . '/' . (!empty($arguments) ? $arguments['order_id'] : ''); + $this->helper->expects($this->atLeastOnce()) + ->method('getUrl') + ->with($path, $arguments) + ->will($this->returnValue($url)); + $this->response->expects($this->atLeastOnce()) + ->method('setRedirect') + ->with($url); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/ViewTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/ViewTest.php new file mode 100644 index 00000000000..3854858a57f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/ViewTest.php @@ -0,0 +1,300 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +/** + * Class ViewTest + */ +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentLoaderMock; + + /** + * @var \Magento\Framework\App\Action\Title|\PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + /** + * @var \Magento\Backend\Model\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Shipping\Block\Adminhtml\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $blockMock; + + /** + * @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlag; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View + */ + protected $controller; + + protected function setUp() + { + $this->requestMock = $this->getMock( + 'Magento\Framework\App\Request\Http', + ['getParam'], + [], + '', + false + ); + $this->shipmentLoaderMock = $this->getMock( + 'Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader', + ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], + [], + '', + false + ); + $this->shipmentMock = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['getIncrementId', '__wakeup'], + [], + '', + false + ); + $this->titleMock = $this->getMock( + 'Magento\Framework\App\Action\Title', + ['add'], + [], + '', + false + ); + $this->viewMock = $this->getMock( + 'Magento\Backend\Model\View', + ['loadLayout', 'getLayout', 'renderLayout'], + [], + '', + false + ); + $this->responseMock = $this->getMock( + 'Magento\Framework\App\Response\Http', + [], + [], + '', + false + ); + $this->sessionMock = $this->getMock( + 'Magento\Backend\Model\Session', + ['setIsUrlNotice'], + [], + '', + false + ); + $this->actionFlag = $this->getMock( + 'Magento\Framework\App\ActionFlag', + ['get'], + [], + '', + false + ); + $contextMock = $this->getMock( + 'Magento\Backend\App\Action\Context', + ['getRequest', 'getResponse', 'getTitle', 'getView', 'getSession', 'getActionFlag'], + [], + '', + false + ); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock)); + $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); + $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock)); + $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlag)); + + $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View( + $contextMock, + $this->shipmentLoaderMock + ); + } + + /** + * Run test execute method + */ + public function testExecute() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + $incrementId = '10000001'; + $comeFrom = true; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->requestMock->expects($this->at(4)) + ->method('getParam') + ->with('come_from') + ->will($this->returnValue($comeFrom)); + $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment); + $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->shipmentMock)); + $this->shipmentMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($incrementId)); + $this->titleMock->expects($this->at(0))->method('add')->with('Shipments')->will($this->returnSelf()); + $this->titleMock->expects($this->at(1))->method('add')->with('#' . $incrementId)->will($this->returnSelf()); + + $menuBlockMock = $this->getMock( + 'Magento\Backend\Block\Menu', + ['getParentItems', 'getMenuModel'], + [], + '', + false + ); + $menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf()); + $menuBlockMock->expects($this->any()) + ->method('getParentItems') + ->with('Magento_Sales::sales_order') + ->will($this->returnValue([])); + $shipmentBlockMock = $this->getMock( + 'Magento\Shipping\Block\Adminhtml\View', + ['updateBackButtonUrl'], + [], + '', + false + ); + $layoutMock = $this->getMock( + 'Magento\Framework\View\Layout', + ['getBlock'], + [], + '', + false + ); + $shipmentBlockMock->expects($this->once()) + ->method('updateBackButtonUrl') + ->with($comeFrom) + ->will($this->returnSelf()); + $layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with('sales_shipment_view') + ->will($this->returnValue($shipmentBlockMock)); + $layoutMock->expects($this->at(1)) + ->method('getBlock') + ->with('menu') + ->will($this->returnValue($menuBlockMock)); + + $this->viewMock->expects($this->once())->method('loadLayout')->will($this->returnSelf()); + $this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock)); + $this->viewMock->expects($this->once())->method('renderLayout')->will($this->returnSelf()); + + $this->assertNull($this->controller->execute()); + } + + /** + * Run test execute method (no shipment) + */ + public function testExecuteNoShipment() + { + $orderId = 1; + $shipmentId = 1; + $shipment = []; + $tracking = []; + + $this->requestMock->expects($this->at(0)) + ->method('getParam') + ->with('order_id') + ->will($this->returnValue($orderId)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with('shipment_id') + ->will($this->returnValue($shipmentId)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with('shipment') + ->will($this->returnValue($shipment)); + $this->requestMock->expects($this->at(3)) + ->method('getParam') + ->with('tracking') + ->will($this->returnValue($tracking)); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setOrderId') + ->with($orderId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipmentId') + ->with($shipmentId); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setShipment') + ->with($shipment); + $this->shipmentLoaderMock->expects($this->once()) + ->method('setTracking') + ->with($tracking); + $this->shipmentLoaderMock->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->actionFlag->expects($this->once()) + ->method('get') + ->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED) + ->will($this->returnValue(true)); + $this->sessionMock->expects($this->once()) + ->method('setIsUrlNotice') + ->with(true); + + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoaderTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoaderTest.php new file mode 100644 index 00000000000..6e4b57e9918 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoaderTest.php @@ -0,0 +1,211 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Controller\Adminhtml\Order; + +use Magento\Backend\App\Action; + +/** + * Class ShipmentLoaderTest + * + * @package Magento\Shipping\Controller\Adminhtml\Order + */ +class ShipmentLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderServiceFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $trackFactoryMock; + + /** + * @var \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader + */ + protected $loader; + + public function setUp() + { + $this->shipmentFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\ShipmentFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->orderServiceFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Service\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->trackFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment\TrackFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\Manager') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $data = [ + 'order_id' => 100032, + 'shipment_id' => 1000065, + 'shipment' => + ['items' => [1 => 1, 2 => 2]], + 'tracking' => [ + ['number' => 'jds0395'], + ['number' => 'lsk984g'] + ] + ]; + + $this->loader = new \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader( + $this->messageManagerMock, + $this->registryMock, + $this->shipmentFactoryMock, + $this->orderFactoryMock, + $this->orderServiceFactoryMock, + $this->trackFactoryMock, + $data + ); + } + + public function testLoadShipmentId() + { + $shipmentModelMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->shipmentFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($shipmentModelMock)); + $shipmentModelMock->expects($this->once()) + ->method('load') + ->with($this->loader->getShipmentId()) + ->will($this->returnSelf()); + $this->registryMock->expects($this->once()) + ->method('register') + ->with('current_shipment', $shipmentModelMock); + $this->assertEquals($shipmentModelMock, $this->loader->load()); + } + + public function testLoadOrderId() + { + $this->loader->unsetData('shipment_id'); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($orderMock)); + $orderMock->expects($this->once()) + ->method('load') + ->with($this->loader->getOrderId()) + ->will($this->returnSelf()); + $orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($this->loader->getOrderId())); + $orderMock->expects($this->any()) + ->method('getForcedShipmentWithInvoice') + ->will($this->returnValue(true)); + $orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(true)); + $orderServiceMock = $this->getMockBuilder('Magento\Sales\Model\Service\Order') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $shipmentModelMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->orderServiceFactoryMock->expects($this->once()) + ->method('create') + ->with(['order' => $orderMock]) + ->will($this->returnValue($orderServiceMock)); + $orderServiceMock->expects($this->once()) + ->method('prepareShipment') + ->with($this->loader->getShipment()['items']) + ->will($this->returnValue($shipmentModelMock)); + $trackMock = $this->getMockBuilder('Magento\Sales\Model\Order\Shipment\Track') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + $this->trackFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($trackMock)); + $trackMock->expects($this->any()) + ->method('addData') + ->will( + $this->returnValueMap( + [ + [$this->loader->getTracking()[0], $trackMock], + [$this->loader->getTracking()[1], $trackMock] + ] + ) + ); + $shipmentModelMock->expects($this->any()) + ->method('addTrack') + ->with($this->equalTo($trackMock)) + ->will($this->returnSelf()); + $this->registryMock->expects($this->once()) + ->method('register') + ->with('current_shipment', $shipmentModelMock); + + $this->assertEquals($shipmentModelMock, $this->loader->load()); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentNotifierTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentNotifierTest.php new file mode 100644 index 00000000000..0b7bb87996b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentNotifierTest.php @@ -0,0 +1,165 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Model; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Framework\Mail\Exception; + +/** + * Class ShipmentNotifierTest + */ +class ShipmentNotifierTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CollectionFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Sales\Model\ShipmentNotifier + */ + protected $notifier; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipment; + + /** + * @var \Magento\Framework\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentSenderMock; + + public function setUp() + { + $this->historyCollectionFactory = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->shipment = $this->getMock( + 'Magento\Sales\Model\Order\Shipment', + ['__wakeUp', 'getEmailSent'], + [], + '', + false + ); + $this->shipmentSenderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender\ShipmentSender', + ['send'], + [], + '', + false + ); + $this->loggerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + $this->notifier = new ShipmentNotifier( + $this->historyCollectionFactory, + $this->loggerMock, + $this->shipmentSenderMock + ); + } + + /** + * Test case for successful email sending + */ + public function testNotifySuccess() + { + $historyCollection = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection', + ['getUnnotifiedForInstance', 'save', 'setIsCustomerNotified'], + [], + '', + false + ); + $historyItem = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + ['setIsCustomerNotified', 'save', '__wakeUp'], + [], + '', + false + ); + $historyItem->expects($this->at(0)) + ->method('setIsCustomerNotified') + ->with(1); + $historyItem->expects($this->at(1)) + ->method('save'); + $historyCollection->expects($this->once()) + ->method('getUnnotifiedForInstance') + ->with($this->shipment) + ->will($this->returnValue($historyItem)); + $this->shipment->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(true)); + $this->historyCollectionFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($historyCollection)); + + $this->shipmentSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->shipment)); + + $this->assertTrue($this->notifier->notify($this->shipment)); + } + + /** + * Test case when email has not been sent + */ + public function testNotifyFail() + { + $this->shipment->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(false)); + $this->assertFalse($this->notifier->notify($this->shipment)); + } + + /** + * Test case when Mail Exception has been thrown + */ + public function testNotifyException() + { + $exception = new Exception('Email has not been sent'); + $this->shipmentSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->shipment)) + ->will($this->throwException($exception)); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($this->equalTo($exception)); + $this->assertFalse($this->notifier->notify($this->shipment)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentTest.php new file mode 100644 index 00000000000..3b5db9b7155 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Model/ShipmentTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Model; + +use Magento\Sales\Model\Resource\OrderFactory; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class ShipmentTest + */ +class ShipmentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OrderFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactory; + + /** + * @var \Magento\Sales\Model\Order\Shipment + */ + protected $shipment; + + public function setUp() + { + $this->orderFactory = $this->getMock( + '\Magento\Sales\Model\OrderFactory', + ['create'], + [], + '', + false + ); + + $objectManagerHelper = new ObjectManagerHelper($this); + $arguments = [ + 'context' => $this->getMock('Magento\Framework\Model\Context', [], [], '', false), + 'registry' => $this->getMock('Magento\Framework\Registry', [], [], '', false), + 'localeDate' => $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', [], [], '', false), + 'dateTime' => $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false), + 'orderFactory' => $this->orderFactory, + 'shipmentItemCollectionFactory' => $this->getMock( + 'Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory', + [], + [], + '', + false + ), + 'trackCollectionFactory' => $this->getMock( + 'Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory', + [], + [], + '', + false + ), + 'commentFactory' => $this->getMock( + 'Magento\Sales\Model\Order\Shipment\CommentFactory', + [], + [], + '', + false + ), + 'commentCollectionFactory' => $this->getMock( + 'Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory', + [], + [], + '', + false + ), + ]; + $this->shipment = $objectManagerHelper->getObject( + 'Magento\Sales\Model\Order\Shipment', + $arguments + ); + } + + public function testGetOrder() + { + $orderId = 100000041; + $this->shipment->setOrderId($orderId); + $entityName = 'shipment'; + $order = $this->getMock( + 'Magento\Sales\Model\Order', + ['load', 'setHistoryEntityName', '__wakeUp'], + [], + '', + false + ); + $this->shipment->setOrderId($orderId); + $order->expects($this->atLeastOnce()) + ->method('setHistoryEntityName') + ->with($entityName) + ->will($this->returnSelf()); + $order->expects($this->atLeastOnce()) + ->method('load') + ->with($orderId) + ->will($this->returnValue($order)); + + $this->orderFactory->expects($this->atLeastOnce()) + ->method('create') + ->will($this->returnValue($order)); + + $this->assertEquals($order, $this->shipment->getOrder()); + } + + public function testGetEntityType() + { + $this->assertEquals('shipment', $this->shipment->getEntityType()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php index 717c727dd40..365e06d976e 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php @@ -79,40 +79,48 @@ class ContextTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $requestMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieManagerMock; + /** * Set up */ public function setUp() { $this->sessionMock = $this->getMock('Magento\Framework\Session\Generic', - array('getCurrencyCode'), array(), '', false); + ['getCurrencyCode'], [], '', false); $this->httpContextMock = $this->getMock('Magento\Framework\App\Http\Context', - array(), array(), '', false); + [], [], '', false); $this->httpRequestMock = $this->getMock('Magento\Framework\App\Request\Http', - array('getCookie', 'getParam'), array(), '', false); + ['getParam'], [], '', false); $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', - array('getWebsite', '__wakeup'), array(), '', false); + ['getWebsite', '__wakeup'], [], '', false); $this->storeMock = $this->getMock('Magento\Store\Model\Store', - array('__wakeup', 'getDefaultCurrency'), array(), '', false); + ['__wakeup', 'getDefaultCurrency'], [], '', false); $this->currencyMock = $this->getMock('Magento\Directory\Model\Currency', - array('getCode', '__wakeup'), array(), '', false); + ['getCode', '__wakeup'], [], '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', - array('getDefaultStore', '__wakeup'), array(), '', false); + ['getDefaultStore', '__wakeup'], [], '', false); $this->closureMock = function () { return 'ExpectedValue'; }; - $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', array(), array(), '', false); + $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); + $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', [], [], '', false); $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); $this->plugin = new \Magento\Store\App\Action\Plugin\Context( $this->sessionMock, $this->httpContextMock, $this->httpRequestMock, - $this->storeManagerMock + $this->storeManagerMock, + $this->cookieManagerMock ); } @@ -142,17 +150,17 @@ class ContextTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('___store')) ->will($this->returnValue('default')); - $this->httpRequestMock->expects($this->once()) + $this->cookieManagerMock->expects($this->once()) ->method('getCookie') ->with($this->equalTo(\Magento\Store\Model\Store::COOKIE_NAME)) ->will($this->returnValue(null)); $this->httpContextMock->expects($this->atLeastOnce()) ->method('setValue') - ->will($this->returnValueMap(array( - array(\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock), - array(\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock), - ))); + ->will($this->returnValueMap([ + [\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock], + [\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock], + ])); $this->assertEquals( 'ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php index a1319beb297..5866f1a9932 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php @@ -55,7 +55,8 @@ class PathInfoProcessorTest extends \PHPUnit_Framework_TestCase 'setModuleName', 'getActionName', 'setActionName', - 'getParam' + 'getParam', + 'getCookie' ) ); $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php index 42d91bb87bb..52048dd9f3b 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php @@ -72,7 +72,8 @@ class RedirectTest extends \PHPUnit_Framework_TestCase 'setModuleName', 'getActionName', 'setActionName', - 'getParam' + 'getParam', + 'getCookie' ) ); $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Store/Helper/CookieTest.php b/dev/tests/unit/testsuite/Magento/Store/Helper/CookieTest.php index cff534f4fe1..2dd2773a136 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Helper/CookieTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Helper/CookieTest.php @@ -137,9 +137,9 @@ class CookieTest extends \PHPUnit_Framework_TestCase } /** - * Create cookie model stub + * Generate getCookie stub for mock request object + * * @param array $cookieString - * @return \Magento\Framework\Stdlib\Cookie */ protected function _getCookieStub($cookieString = array()) { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php index d15acc6ee61..81400abe380 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php @@ -85,7 +85,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase /** * @var array */ - protected $_arguments = array(); + protected $_arguments = []; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -122,77 +122,97 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ protected $request; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cookieMetadataFactoryMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $helper; protected function setUp() { - $this->_arguments = array('test' => 'argument', 'scopeCode' => '', 'scopeType' => ''); + $this->_arguments = ['test' => 'argument', 'scopeCode' => '', 'scopeType' => '']; $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); $this->_eventManagerMock = $this->getMock( 'Magento\Framework\Event\ManagerInterface', - array(), - array(), + [], + [], '', false ); - $this->_logMock = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); + $this->_logMock = $this->getMock('Magento\Framework\Logger', [], [], '', false); $this->_sidResolverMock = $this->getMock( '\Magento\Framework\Session\SidResolverInterface', - array(), - array(), + [], + [], '', false ); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); + $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->_cookie = $this->getMock('Magento\Framework\Stdlib\Cookie', array(), array(), '', false); - $this->_httpContext = $this->getMock('Magento\Framework\App\Http\Context', array(), array(), '', false); + $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->_httpContext = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false); $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->request = $this->getMock('Magento\Framework\App\RequestInterface', array(), array(), '', false); + $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); + $this->cookieMetadataFactoryMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + [], + [], + '', + false + ); - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_model = $helper->getObject('\Magento\Store\Model\StorageFactory', array( + $this->_model = $this->helper->getObject('\Magento\Store\Model\StorageFactory', [ 'objectManager' => $this->_objectManagerMock, 'eventManager' => $this->_eventManagerMock, 'logger' => $this->_logMock, 'sidResolver' => $this->_sidResolverMock, 'appState' => $this->_appStateMock, - 'cookie' => $this->_cookie, + 'cookieManager' => $this->cookieManagerMock, 'httpContext' => $this->_httpContext, 'scopeConfig' => $this->_scopeConfig, 'request' => $this->request, - 'defaultStorageClassName' => $this->_defaultStorage, - 'installedStorageClassName' => $this->_dbStorage - )); + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock + ]); - $this->store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); + $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->store->expects($this->any())->method('getCode')->will($this->returnValue('store1')); - $this->website = $this->getMock('Magento\Store\Model\Website', array(), array(), '', false); + $this->website = $this->getMock('Magento\Store\Model\Website', [], [], '', false); $this->website->expects($this->any())->method('getCode')->will($this->returnValue('website1')); $this->group = $this->getMock( 'Magento\Store\Model\Group', - array('getDefaultStoreId', '__sleep', '__wakeup'), - array(), + ['getDefaultStoreId', '__sleep', '__wakeup'], + [], '', false ); - $this->storage = $this->getMock('Magento\Store\Model\Storage\Db', array(), array(), '', false); + $this->storage = $this->getMock('Magento\Store\Model\Storage\Db', [], [], '', false); $this->storage->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website)); $this->storage->expects($this->any())->method('getWebsites')->will($this->returnValue( - array('website1' => $this->website) + ['website1' => $this->website] )); - $this->storage->expects($this->any())->method('getGroups')->will($this->returnValue(array(11 => $this->group))); + $this->storage->expects($this->any())->method('getGroups')->will($this->returnValue([11 => $this->group])); $this->storage->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->storage->expects($this->any()) ->method('getStores') ->will($this->returnCallback(function ($withDefault, $codeKey) { if ($codeKey) { - return array('store1' => $this->store); + return ['store1' => $this->store]; } else { - return array(21 => $this->store); + return [21 => $this->store]; } })); } @@ -226,7 +246,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase { $this->_appStateMock->expects($this->exactly(2))->method('isInstalled')->will($this->returnValue(true)); - $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); + $store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->_storeManager->expects($this->exactly(3))->method('getStore')->will($this->returnValue($store)); @@ -289,7 +309,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase { $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $invalidObject = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); + $invalidObject = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->_objectManagerMock->expects( $this->once() @@ -351,15 +371,15 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ public function getWithStoresReinitDataProvider() { - return array( - array('', '', 21, 11, 'store1'), - array('11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, 21, null, 'store1'), - array('12', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, 22, null, null), - array('11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, null, null, null), - array('website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 21, 11, 'store1'), - array('31', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 22, null, null), - array('website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, null, 0, null), - ); + return [ + ['', '', 21, 11, 'store1'], + ['11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, 21, null, 'store1'], + ['12', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, 22, null, null], + ['11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP, null, null, null], + ['website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 21, 11, 'store1'], + ['31', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 22, null, null], + ['website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, null, 0, null], + ]; } /** @@ -401,7 +421,10 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); - $this->_cookie->expects($this->atLeastOnce())->method('get')->will($this->returnValue('store1')); + $this->cookieManagerMock->expects($this->atLeastOnce()) + ->method('getCookie') + ->with(Store::COOKIE_NAME) + ->will($this->returnValue('store1')); $this->assertEquals($this->storage, $this->_model->get($this->_arguments)); } @@ -411,11 +434,11 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ public function getFromCookieDataProvider() { - return array( - array('website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE), - array('11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP), - array('store1', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), - ); + return [ + ['website1', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE], + ['11', \Magento\Store\Model\ScopeInterface::SCOPE_GROUP], + ['store1', \Magento\Store\Model\ScopeInterface::SCOPE_STORE], + ]; } /** @@ -432,7 +455,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase { $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $storeDefault = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); + $storeDefault = $this->getMock('Magento\Store\Model\Store', [], [], '', false); if (!$isDefault) { $storeDefault->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(22)); $this->_httpContext->expects($this->once())->method('setValue')->with( @@ -455,7 +478,12 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->storage->expects($this->any())->method('setCurrentStore')->with('store1'); + $numCreateCookieCalls = $isDefault ? 0 : 1; $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); + $cookieMetadata = $this->helper->getObject('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', []); + $this->cookieMetadataFactoryMock->expects($this->exactly($numCreateCookieCalls)) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadata)); $this->request->expects($this->atLeastOnce()) ->method('getParam') @@ -470,10 +498,10 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ public function getFromRequestDataProvider() { - return array( - array(false, true), - array(true, true), - array(true, false), - ); + return [ + [false, true], + [true, true], + [true, false], + ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php index 40644391cf9..61001e986b6 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php @@ -34,9 +34,25 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ protected $objectManagerHelper; + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $requestMock; + public function setUp() { $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->requestMock = $this->getMock('\Magento\Framework\App\RequestInterface', [ + 'getRequestString', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getParam', + 'getQuery', + 'getCookie', + 'getDistroBaseUrl', + ], [], '', false); } /** @@ -51,7 +67,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $resource = $this->getMock( '\Magento\Store\Model\Resource\Store', array('load', 'getIdFieldName', '__wakeup'), - array(), + [], '', false ); @@ -74,7 +90,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testSetWebsite() { - $website = $this->getMock('\Magento\Store\Model\Website', array('getId', '__wakeup'), array(), '', false); + $website = $this->getMock('\Magento\Store\Model\Website', array('getId', '__wakeup'), [], '', false); $website->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); @@ -106,7 +122,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getWebsiteDataProvider() { - $website = $this->getMock('\Magento\Store\Model\Website', array('__wakeup'), array(), '', false); + $website = $this->getMock('\Magento\Store\Model\Website', array('__wakeup'), [], '', false); return array( array(null, false), array(2, $website) @@ -116,7 +132,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetUrl() { $params = array('_scope_to_url' => true); - $defaultStore = $this->getMock('\Magento\Store\Model\Store', array('getId', '__wakeup'), array(), '', false); + $defaultStore = $this->getMock('\Magento\Store\Model\Store', array('getId', '__wakeup'), [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); @@ -155,16 +171,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetBaseUrl($type, $secure, $expectedPath, $expectedBaseUrl) { - $request = $this->getMock('\Magento\Framework\App\RequestInterface', array( - 'getRequestString', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getDistroBaseUrl' - ), array(), '', false); - $request->expects($this->any())->method('getDistroBaseUrl')->will($this->returnValue('http://distro.com/')); + $this->requestMock->expects($this->any()) + ->method('getDistroBaseUrl') + ->will($this->returnValue('http://distro.com/')); /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $configMock */ $configMock = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ReinitableConfigInterface'); @@ -181,7 +190,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'Magento\Store\Model\Store', array( 'config' => $configMock, - 'request' => $request, + 'request' => $this->requestMock, 'isCustomEntryPoint' => !$secure, ) ); @@ -299,7 +308,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'getId', 'isCurrentlySecure', '__wakeup' - ), array(), '', false); + ), [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); $defaultStore->expects($this->atLeastOnce())->method('isCurrentlySecure')->will($this->returnValue($secure)); @@ -308,17 +317,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase $config = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ReinitableConfigInterface'); - $request = $this->getMock('\Magento\Framework\App\RequestInterface', array( - 'getRequestString', - 'getModuleName', - 'setModuleName', - 'getActionName', - 'setActionName', - 'getParam', - 'getQuery' - ), array(), '', false); - $request->expects($this->atLeastOnce())->method('getRequestString')->will($this->returnValue('')); - $request->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue(array( + + $this->requestMock->expects($this->atLeastOnce())->method('getRequestString')->will($this->returnValue('')); + $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue(array( 'SID' => 'sid' ))); @@ -336,7 +337,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array('storeManager' => $storeManager, 'url' => $urlMock, 'request' => $request, 'config' => $config) + ['storeManager' => $storeManager, 'url' => $urlMock, 'request' => $this->requestMock, 'config' => $config] ); $model->setStoreId(2); $model->setCode('scope_code'); @@ -365,9 +366,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase $model->setData('default_currency', false); $this->assertInstanceOf('\Magento\Framework\Filter\Sprintf', $model->getPriceFilter()); - $filter = $this->getMock('\Magento\Directory\Model\Currency\Filter', array(), array(), '', false); + $filter = $this->getMock('\Magento\Directory\Model\Currency\Filter', [], [], '', false); - $defaultCurrency = $this->getMock('\Magento\Directory\Model\Currency', array(), array(), '', false); + $defaultCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $defaultCurrency->expects($this->any())->method('getFilter')->will($this->returnValue($filter)); $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); @@ -378,10 +379,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase $filter->expects($this->any())->method('setRate')->with(2.1)->will($this->returnSelf()); - $currentCurrency = $this->getMock('\Magento\Directory\Model\Currency', array(), array(), '', false); + $currentCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $currentCurrency->expects($this->any())->method('getFilter')->will($this->returnValue($filter)); - $baseCurrency = $this->getMock('\Magento\Directory\Model\Currency', array(), array(), '', false); + $baseCurrency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $baseCurrency->expects($this->any())->method('getRate')->with($currentCurrency)->will($this->returnValue(2.1)); $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); @@ -408,7 +409,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase array('currency/options/base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'scope_code', 'UAH'), ))); - $currency = $this->getMock('\Magento\Directory\Model\Currency', array(), array(), '', false); + $currency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $currency->expects($this->any())->method('load')->with($currencyCode)->will($this->returnSelf()); $currencyFactory = $this->getMock( @@ -417,7 +418,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase ); $currencyFactory->expects($this->any())->method('create')->will($this->returnValue($currency)); - $appState = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); + $appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false); $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', @@ -445,7 +446,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $configMock = $this->getMockForAbstractClass( 'Magento\Framework\App\Config\ReinitableConfigInterface', - array(), + [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Tax/Block/Adminhtml/Items/Price/RendererTest.php b/dev/tests/unit/testsuite/Magento/Tax/Block/Adminhtml/Items/Price/RendererTest.php new file mode 100644 index 00000000000..952d40f3b1a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Tax/Block/Adminhtml/Items/Price/RendererTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Tax\Block\Adminhtml\Items\Price; + +use Magento\Framework\Object; + +class RendererTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Tax\Block\Adminhtml\Items\Price\Renderer + */ + protected $renderer; + + /** + * @var \Magento\Tax\Block\Item\Price\Renderer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemPriceRenderer; + + /** + * @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn|\PHPUnit_Framework_MockObject_MockObject + */ + protected $defaultColumnRenderer; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->itemPriceRenderer = $this->getMockBuilder('\Magento\Tax\Block\Item\Price\Renderer') + ->disableOriginalConstructor() + ->setMethods( + [ + 'displayPriceInclTax', + 'displayPriceExclTax', + 'displayBothPrices', + 'getTotalAmount', + 'formatPrice', + ] + ) + ->getMock(); + + $this->defaultColumnRenderer = $this->getMockBuilder( + '\Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn' + )->disableOriginalConstructor() + ->setMethods(['displayPrices']) + ->getMock(); + + $this->renderer = $objectManager->getObject( + '\Magento\Tax\Block\Adminhtml\Items\Price\Renderer', + [ + 'itemPriceRenderer' => $this->itemPriceRenderer, + 'defaultColumnRenderer' => $this->defaultColumnRenderer, + ] + ); + } + + public function testDisplayPriceInclTax() + { + $flag = false; + $this->itemPriceRenderer->expects($this->once()) + ->method('displayPriceInclTax') + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayPriceInclTax()); + } + + public function testDisplayPriceExclTax() + { + $flag = true; + $this->itemPriceRenderer->expects($this->once()) + ->method('displayPriceExclTax') + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayPriceExclTax()); + } + + public function testDisplayBothPrices() + { + $flag = true; + $this->itemPriceRenderer->expects($this->once()) + ->method('displayBothPrices') + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayBothPrices()); + } + + public function testDisplayPrices() + { + $basePrice = 3; + $price = 4; + $display = "$3 [L4]"; + + $this->defaultColumnRenderer->expects($this->once()) + ->method('displayPrices') + ->with($basePrice, $price) + ->will($this->returnValue($display)); + + $this->assertEquals($display, $this->renderer->displayPrices($basePrice, $price)); + } + + public function testFormatPrice() + { + $price = 4; + $display = "$3"; + + $this->itemPriceRenderer->expects($this->once()) + ->method('formatPrice') + ->with($price) + ->will($this->returnValue($display)); + + $this->assertEquals($display, $this->renderer->formatPrice($price)); + } + + public function testGetTotalAmount() + { + $totalAmount = 10; + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->getMock(); + + $this->itemPriceRenderer->expects($this->once()) + ->method('getTotalAmount') + ->with($itemMock) + ->will($this->returnValue($totalAmount)); + + $this->assertEquals($totalAmount, $this->renderer->getTotalAmount($itemMock)); + } + +} diff --git a/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php b/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php index 3557f30c30d..5fdd6366134 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Block/Item/Price/RendererTest.php @@ -24,6 +24,7 @@ namespace Magento\Tax\Block\Item\Price; use Magento\Framework\Object; +use Magento\Framework\Pricing\Render; class RendererTest extends \PHPUnit_Framework_TestCase { @@ -44,7 +45,12 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->taxHelper = $this->getMockBuilder('\Magento\Tax\Helper\Data') ->disableOriginalConstructor() ->setMethods([ - 'displayCartPriceExclTax', 'displayCartBothPrices', 'displayCartPriceInclTax' + 'displayCartPriceExclTax', + 'displayCartBothPrices', + 'displayCartPriceInclTax', + 'displaySalesPriceExclTax', + 'displaySalesBothPrices', + 'displaySalesPriceInclTax', ]) ->getMock(); @@ -52,31 +58,389 @@ class RendererTest extends \PHPUnit_Framework_TestCase '\Magento\Tax\Block\Item\Price\Renderer', [ 'taxHelper' => $this->taxHelper, + 'data' => [ + 'zone' => Render::ZONE_CART, + ] ] ); } - public function testDisplayPriceInclTax() + /** + * @param $storeId + * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Item + */ + protected function getItemMockWithStoreId($storeId) + { + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getStoreId', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getStoreId') + ->will($this->returnValue($storeId)); + + return $itemMock; + } + + /** + * Test displayPriceInclTax + * + * @param string $zone + * @param string $methodName + * @dataProvider testDisplayPriceInclTaxDataProvider + */ + public function testDisplayPriceInclTax($zone, $methodName) { + $storeId = 1; + $flag = true; + + $itemMock = $this->getItemMockWithStoreId($storeId); + $this->renderer->setItem($itemMock); + $this->renderer->setZone($zone); $this->taxHelper->expects($this->once()) - ->method('displayCartPriceInclTax'); + ->method($methodName) + ->with($storeId) + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayPriceInclTax()); + } + + public function testDisplayPriceInclTaxDataProvider() + { + $data = [ + 'cart' => [ + 'zone' => Render::ZONE_CART, + 'method_name' => 'displayCartPriceInclTax' + ], + 'anythingelse' => [ + 'zone' => 'anythingelse', + 'method_name' => 'displayCartPriceInclTax' + ], + 'sale' => [ + 'zone' => Render::ZONE_SALES, + 'method_name' => 'displaySalesPriceInclTax' + ], + 'email' => [ + 'zone' => Render::ZONE_EMAIL, + 'method_name' => 'displaySalesPriceInclTax' + ] + ]; - $this->renderer->displayPriceInclTax(); + return $data; } - public function testDisplayPriceExclTax() + /** + * Test displayPriceExclTax + * + * @param string $zone + * @param string $methodName + * @dataProvider testDisplayPriceExclTaxDataProvider + */ + public function testDisplayPriceExclTax($zone, $methodName) { + $storeId = 1; + $flag = true; + + $itemMock = $this->getItemMockWithStoreId($storeId); + $this->renderer->setItem($itemMock); + $this->renderer->setZone($zone); $this->taxHelper->expects($this->once()) - ->method('displayCartPriceExclTax'); + ->method($methodName) + ->with($storeId) + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayPriceExclTax()); + } + + public function testDisplayPriceExclTaxDataProvider() + { + $data = [ + 'cart' => [ + 'zone' => Render::ZONE_CART, + 'method_name' => 'displayCartPriceExclTax' + ], + 'anythingelse' => [ + 'zone' => 'anythingelse', + 'method_name' => 'displayCartPriceExclTax' + ], + 'sale' => [ + 'zone' => Render::ZONE_SALES, + 'method_name' => 'displaySalesPriceExclTax' + ], + 'email' => [ + 'zone' => Render::ZONE_EMAIL, + 'method_name' => 'displaySalesPriceExclTax' + ] + ]; - $this->renderer->displayPriceExclTax(); + return $data; } - public function testDisplayBothPrices() + /** + * Test displayBothPrices + * + * @param string $zone + * @param string $methodName + * @dataProvider testDisplayBothPricesDataProvider + */ + public function testDisplayBothPrices($zone, $methodName) { + $storeId = 1; + $flag = true; + + $itemMock = $this->getItemMockWithStoreId($storeId); + $this->renderer->setItem($itemMock); + $this->renderer->setZone($zone); $this->taxHelper->expects($this->once()) - ->method('displayCartBothPrices'); + ->method($methodName) + ->with($storeId) + ->will($this->returnValue($flag)); + + $this->assertEquals($flag, $this->renderer->displayBothPrices()); + } + + public function testDisplayBothPricesDataProvider() + { + $data = [ + 'cart' => [ + 'zone' => Render::ZONE_CART, + 'method_name' => 'displayCartBothPrices' + ], + 'anythingelse' => [ + 'zone' => 'anythingelse', + 'method_name' => 'displayCartBothPrices' + ], + 'sale' => [ + 'zone' => Render::ZONE_SALES, + 'method_name' => 'displaySalesBothPrices' + ], + 'email' => [ + 'zone' => Render::ZONE_EMAIL, + 'method_name' => 'displaySalesBothPrices' + ] + ]; + + return $data; + } + + public function testFormatPriceQuoteItem() + { + $price = 3.554; + $formattedPrice = "$3.55"; + + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->setMethods(['formatPrice', '__wakeup']) + ->getMock(); + + $storeMock->expects($this->once()) + ->method('formatPrice') + ->with($price, true) + ->will($this->returnValue($formattedPrice)); + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['getStore', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($storeMock)); + + $this->renderer->setItem($itemMock); + $this->assertEquals($formattedPrice, $this->renderer->formatPrice($price)); + } + + public function testFormatPriceOrderItem() + { + $price = 3.554; + $formattedPrice = "$3.55"; + + $orderMock = $this->getMockBuilder('\Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['formatPrice', '__wakeup']) + ->getMock(); + + $orderMock->expects($this->once()) + ->method('formatPrice') + ->with($price, false) + ->will($this->returnValue($formattedPrice)); + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getOrder', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $this->renderer->setItem($itemMock); + $this->assertEquals($formattedPrice, $this->renderer->formatPrice($price)); + } + + public function testFormatPriceInvoiceItem() + { + $price = 3.554; + $formattedPrice = "$3.55"; + + $orderMock = $this->getMockBuilder('\Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['formatPrice', '__wakeup']) + ->getMock(); + + $orderMock->expects($this->once()) + ->method('formatPrice') + ->with($price, false) + ->will($this->returnValue($formattedPrice)); + + + $orderItemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getOrder', '__wakeup']) + ->getMock(); + + $orderItemMock->expects($this->once()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $invoiceItemMock = $this->getMockBuilder('\Magento\Sales\Model\Invoice\Item') + ->disableOriginalConstructor() + ->setMethods(['getOrderItem', '__wakeup', 'getStoreId']) + ->getMock(); + + $invoiceItemMock->expects($this->once()) + ->method('getOrderItem') + ->will($this->returnValue($orderItemMock)); + + $this->renderer->setItem($invoiceItemMock); + $this->assertEquals($formattedPrice, $this->renderer->formatPrice($price)); + } + + public function testGetZone() + { + $this->assertEquals(Render::ZONE_CART, $this->renderer->getZone()); + } + + public function testGetStoreId() + { + $storeId = 'default'; + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['getStoreId', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getStoreId') + ->will($this->returnValue($storeId)); + + $this->renderer->setItem($itemMock); + $this->assertEquals($storeId, $this->renderer->getStoreId()); + } + + public function testGetItemDisplayPriceExclTaxQuoteItem() + { + $price = 10; + + /** @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $quoteItemMock */ + $quoteItemMock = $this->getMockBuilder('\Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['getCalculationPrice', '__wakeup']) + ->getMock(); + + $quoteItemMock->expects($this->once()) + ->method('getCalculationPrice') + ->will($this->returnValue($price)); + + $this->renderer->setItem($quoteItemMock); + $this->assertEquals($price, $this->renderer->getItemDisplayPriceExclTax()); + } + + public function testGetItemDisplayPriceExclTaxOrderItem() + { + $price = 10; + + /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject $orderItemMock */ + $orderItemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getPrice', '__wakeup']) + ->getMock(); + + $orderItemMock->expects($this->once()) + ->method('getPrice') + ->will($this->returnValue($price)); + + $this->renderer->setItem($orderItemMock); + $this->assertEquals($price, $this->renderer->getItemDisplayPriceExclTax()); + } + + public function testGetTotalAmount() + { + $rowTotal = 100; + $taxAmount = 10; + $hiddenTaxAmount = 2; + $discountAmount = 20; + + $expectedValue = $rowTotal + $taxAmount + $hiddenTaxAmount - $discountAmount; + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getRowTotal', 'getTaxAmount', 'getHiddenTaxAmount', 'getDiscountAmount', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getRowTotal') + ->will($this->returnValue($rowTotal)); + + $itemMock->expects($this->once()) + ->method('getTaxAmount') + ->will($this->returnValue($taxAmount)); + + $itemMock->expects($this->once()) + ->method('getHiddenTaxAmount') + ->will($this->returnValue($hiddenTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getDiscountAmount') + ->will($this->returnValue($discountAmount)); + + $this->assertEquals($expectedValue, $this->renderer->getTotalAmount($itemMock)); + } + + public function testGetBaseTotalAmount() + { + $baseRowTotal = 100; + $baseTaxAmount = 10; + $baseHiddenTaxAmount = 2; + $baseDiscountAmount = 20; + + $expectedValue = 92; + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods( + ['getBaseRowTotal', 'getBaseTaxAmount', 'getBaseHiddenTaxAmount', 'getBaseDiscountAmount', '__wakeup'] + ) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getBaseRowTotal') + ->will($this->returnValue($baseRowTotal)); + + $itemMock->expects($this->once()) + ->method('getBaseTaxAmount') + ->will($this->returnValue($baseTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getBaseHiddenTaxAmount') + ->will($this->returnValue($baseHiddenTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getBaseDiscountAmount') + ->will($this->returnValue($baseDiscountAmount)); - $this->renderer->displayBothPrices(); + $this->assertEquals($expectedValue, $this->renderer->getBaseTotalAmount($itemMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php new file mode 100644 index 00000000000..a611c653ae3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php @@ -0,0 +1,111 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Tax\Model\Resource; + +use Magento\TestFramework\Helper\ObjectManager; + +class CalculationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests the building of the search templates for the postal code + * + * @param string $postalCode + * @param string|null $exactPostalcode + * @dataProvider dataProviderCreateSearchPostCodeTemplates + */ + public function testCreateSearchPostCodeTemplates($postalCode, $exactPostalcode) + { + // create the mocks + $resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + + $taxData = $this->getMock('Magento\Tax\Helper\Data', ['getPostCodeSubStringLength'], [], '', false); + $taxData + ->expects($this->any()) + ->method('getPostCodeSubStringLength') + ->will($this->returnValue(10)); + + $objectManager = new ObjectManager($this); + $calcMock = $objectManager->getObject( + 'Magento\Tax\Model\Resource\Calculation', + [ + 'resource' => $resource, + 'taxData' => $taxData, + 'storeManager' => $storeManager + ] + ); + + // get access to the method + $method = new \ReflectionMethod('Magento\Tax\Model\Resource\Calculation', '_createSearchPostCodeTemplates'); + $method->setAccessible(true); + + // test & verify + $resultsArr = $method->invokeArgs($calcMock, [$postalCode, $exactPostalcode]); + $this->verifyResults($resultsArr, $postalCode, $exactPostalcode); + } + + /** + * Verify the results array, based on certain properties of the codes + * + * @param array $resultsArr + * @param string $code1 + * @param string|null $code2 + */ + private function verifyResults($resultsArr, $code1, $code2 = null) + { + // determine expected size of the results array + $expectedSize = strlen($code1) + 1; // array will also include the vanilla 'code1' value + if ($code2) { + $expectedSize = strlen($code2) + 2; // array will include both 'code1' and 'code2' + } + $actualSize = count($resultsArr); + $this->assertEquals( + $expectedSize, + $actualSize, + 'Expected size of the result array was ' . $expectedSize . ' but actual was ' . $actualSize + ); + + // verify code(s) are present within the array + $this->assertTrue( in_array($code1, $resultsArr, 'Expected to find code "' . $code1 . '"')); + if ($code2) { + $this->assertTrue( in_array($code2, $resultsArr, 'Expected to find code "' . $code2 . '"')); + } + } + + /** + * @return array + */ + public function dataProviderCreateSearchPostCodeTemplates() + { + return [ + 'USA basic' => + ['78729', null], + 'USA zip+4' => + ['54321', '12345-6789'], + 'Poland' => + ['05-509', null] + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php new file mode 100644 index 00000000000..404171484c1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Test class for /Magento/UrlRewrite/Model/UrlRewrite + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\UrlRewrite\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManager; +use Magento\UrlRewrite\Model\UrlRewrite as UrlRewrite; + +class UrlRewriteTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\UrlRewrite\Model\UrlRewrite + */ + private $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $resourceMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + private $objectManager; + + public function setUp() + { + + $resourceMethods = ['getIdFieldName', 'loadByRequestPath', 'load',]; + $this->resourceMock = $this->getMockForAbstractClass('\Magento\Framework\Model\Resource\AbstractResource', + [], '', false, true, true, $resourceMethods + + ); + + $this->objectManager= new ObjectManager($this); + + $this->model = $this->objectManager->getObject('\Magento\UrlRewrite\Model\UrlRewrite', + [ + 'resource' => $this->resourceMock, + ] + ); + } + + public function testLoadByRequestPath() + { + $path = 'path'; + + $this->resourceMock->expects($this->once()) + ->method('loadByRequestPath') + ->with($this->model, $path); + + $this->model->loadByRequestPath($path); + + } + + public function testLoadByIdPath() + { + $path = 'path'; + + $this->resourceMock->expects($this->once()) + ->method('load') + ->with($this->model, $path, UrlRewrite::PATH_FIELD); + + $this->model->loadByIdPath($path); + } + + public function testHasOption() + { + $searchOption = 'option2'; + $options='option1,' . $searchOption . ',option3'; + $this->assertTrue($this->model->setOptions($options)->hasOption('option2')); + } + + public function testGetStoreId() + { + $id = 42; + $this->assertEquals($id, $this->model->setStoreId($id)->getStoreId()); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RequestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RequestTest.php new file mode 100644 index 00000000000..8969e79cef1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RequestTest.php @@ -0,0 +1,68 @@ +<?php +/** + * \Magento\Webapi\Controller\Request + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Webapi\Controller; + + +use Magento\TestFramework\Helper\ObjectManager; + +class RequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Webapi\Controller\Request + */ + private $request; + + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + private $cookieManager; + + public function setUp() + { + + $objectManager = new ObjectManager($this); + $this->cookieManager = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); + + $this->request = $objectManager->getObject( + '\Magento\Webapi\Controller\Request', + ['cookieManager' => $this->cookieManager] + ); + } + + public function testGetCookie() + { + $key = "cookieName"; + $default = "defaultValue"; + + $this->cookieManager + ->expects($this->once()) + ->method('getCookie') + ->with($key, $default); + + $this->request->getCookie($key, $default); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RequestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RequestTest.php index 492e54cb7b1..8b9edb462b9 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RequestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RequestTest.php @@ -34,6 +34,11 @@ class RequestTest extends \PHPUnit_Framework_TestCase */ protected $_request; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $_cookieManagerMock; + /** @var \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory */ protected $_deserializerFactory; @@ -50,11 +55,13 @@ class RequestTest extends \PHPUnit_Framework_TestCase $areaListMock->expects($this->once())->method('getFrontName')->will($this->returnValue('rest')); /** Instantiate request. */ // TODO: Get rid of SUT mocks. + $this->_cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); $this->_request = $this->getMock( 'Magento\Webapi\Controller\Rest\Request', array('getHeader', 'getMethod', 'isGet', 'isPost', 'isPut', 'isDelete', 'getRawBody'), - array($areaListMock, $configScopeMock, $this->_deserializerFactory) + array($areaListMock, $configScopeMock,$this->_cookieManagerMock, $this->_deserializerFactory,) ); + parent::setUp(); } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RouterTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RouterTest.php index 38407a76d78..1e11dc81309 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RouterTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Rest/RouterTest.php @@ -43,24 +43,34 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->_apiConfigMock = $this->getMockBuilder( 'Magento\Webapi\Model\Rest\Config' )->disableOriginalConstructor()->getMock(); - $deserializerFactory = $this->getMockBuilder( - 'Magento\Webapi\Controller\Rest\Request\Deserializer\Factory' - )->disableOriginalConstructor()->getMock(); + $this->_routeMock = $this->getMockBuilder( 'Magento\Webapi\Controller\Rest\Router\Route' )->disableOriginalConstructor()->setMethods( array('match') )->getMock(); - $areaListMock = $this->getMock('Magento\Framework\App\AreaList', array(), array(), '', false); - $configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $areaListMock->expects($this->once())->method('getFrontName')->will($this->returnValue('rest')); - $this->_request = new \Magento\Webapi\Controller\Rest\Request( - $areaListMock, - $configScopeMock, - $deserializerFactory + + $areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); + + $areaListMock->expects($this->once()) + ->method('getFrontName') + ->will($this->returnValue('rest')); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_request = $objectManager->getObject( + 'Magento\Webapi\Controller\Rest\Request', + [ + 'areaList' => $areaListMock, + ] ); + /** Initialize SUT. */ - $this->_router = new \Magento\Webapi\Controller\Rest\Router($this->_apiConfigMock); + $this->_router = $objectManager->getObject( + 'Magento\Webapi\Controller\Rest\Router', + [ + 'apiConfig' => $this->_apiConfigMock + ] + ); } protected function tearDown() diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/RequestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/RequestTest.php index f7949188b1e..cd35d772953 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/RequestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/RequestTest.php @@ -33,12 +33,18 @@ class RequestTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** Prepare mocks for SUT constructor. */ - $areaListMock = $this->getMock('Magento\Framework\App\AreaList', array(), array(), '', false); - $configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); + $areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); $areaListMock->expects($this->once())->method('getFrontName')->will($this->returnValue('soap')); /** Initialize SUT. */ - $this->_soapRequest = new \Magento\Webapi\Controller\Soap\Request($areaListMock, $configScopeMock); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_soapRequest = $objectManager->getObject( + 'Magento\Webapi\Controller\Soap\Request', + [ + 'areaList' => $areaListMock + ] + ); + parent::setUp(); } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php index 6c69df742d5..a005e4c949a 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php @@ -82,7 +82,8 @@ class TypeProcessorTest extends \PHPUnit_Framework_TestCase $this->_typeProcessor->setTypeData('typeA', array('dataA1')); $this->_typeProcessor->setTypeData('typeA', array('dataA2')); $this->_typeProcessor->setTypeData('typeA', array('dataA3')); - $this->assertEquals(array('dataA1', 'dataA2', 'dataA3'), $this->_typeProcessor->getTypeData('typeA')); + $this->_typeProcessor->setTypeData('typeA', array(null)); + $this->assertEquals(array('dataA1', 'dataA2', 'dataA3', null), $this->_typeProcessor->getTypeData('typeA')); } public function testNormalizeType() diff --git a/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php b/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php index 2229ad11bcd..9220b25bd06 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Block/Item/Price/RendererTest.php @@ -48,6 +48,9 @@ class RendererTest extends \PHPUnit_Framework_TestCase */ protected $item; + const STORE_ID = 'store_id'; + const ZONE = 'zone'; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -55,7 +58,12 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->weeeHelper = $this->getMockBuilder('\Magento\Weee\Helper\Data') ->disableOriginalConstructor() ->setMethods([ - 'isEnabled', 'typeOfDisplay', 'getWeeeTaxInclTax', 'getRowWeeeTaxInclTax' + 'isEnabled', + 'typeOfDisplay', + 'getWeeeTaxInclTax', + 'getRowWeeeTaxInclTax', + 'getBaseRowWeeeTaxInclTax', + 'getBaseWeeeTaxInclTax', ]) ->getMock(); @@ -74,9 +82,21 @@ class RendererTest extends \PHPUnit_Framework_TestCase 'getCalculationPrice', 'getRowTotal', 'getWeeeTaxAppliedRowAmount', + 'getStoreId', + 'getBaseRowTotalInclTax', + 'getBaseRowTotal', + 'getBaseWeeeTaxAppliedRowAmnt', + 'getBasePrice', + 'getBaseWeeeTaxAppliedAmount', + 'getBaseWeeeTaxInclTax', + 'getBasePriceInclTax', ]) ->getMock(); + $this->item->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue(self::STORE_ID)); + $this->renderer = $objectManager->getObject( '\Magento\Weee\Block\Item\Price\Renderer', [ @@ -85,24 +105,33 @@ class RendererTest extends \PHPUnit_Framework_TestCase ] ); $this->renderer->setItem($this->item); + $this->renderer->setZone(self::ZONE); } /** * @param bool $isWeeeEnabled * @param bool #showWeeeDetails * @param bool $hasWeeeAmount + * @param bool $expectedValue * @dataProvider testDisplayPriceWithWeeeDetailsDataProvider */ - public function testDisplayPriceWithWeeeDetails($isWeeeEnabled, $showWeeeDetails, $hasWeeeAmount, $expectedValue) - { + public function testDisplayPriceWithWeeeDetails( + $isWeeeEnabled, + $showWeeeDetails, + $hasWeeeAmount, + $expectedValue + ) { $this->weeeHelper->expects($this->once()) ->method('isEnabled') ->will($this->returnValue($isWeeeEnabled)); $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') - ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR], 'sales', null) - ->will($this->returnValue($showWeeeDetails)); + ->with( + [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL], + self::ZONE, + self::STORE_ID + )->will($this->returnValue($showWeeeDetails)); $this->item->expects($this->any()) ->method('getWeeeTaxAppliedAmount') @@ -197,13 +226,50 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') - ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) ->will($this->returnValue($includeWeee)); $this->assertEquals($expectedValue, $this->renderer->getUnitDisplayPriceInclTax()); } + /** + * @param $basePriceInclTax + * @param $baseWeeeTaxInclTax + * @param $weeeEnabled + * @param $includeWeee + * @param $expectedValue + * @dataProvider testGetDisplayPriceDataProvider + */ + public function testGetBaseUnitDisplayPriceInclTax( + $basePriceInclTax, + $baseWeeeTaxInclTax, + $weeeEnabled, + $includeWeee, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->weeeHelper->expects($this->any()) + ->method('getBaseWeeeTaxInclTax') + ->with($this->item) + ->will($this->returnValue($baseWeeeTaxInclTax)); + + $this->item->expects($this->once()) + ->method('getBasePriceInclTax') + ->will($this->returnValue($basePriceInclTax)); + + $this->weeeHelper->expects($this->any()) + ->method('typeOfDisplay') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) + ->will($this->returnValue($includeWeee)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseUnitDisplayPriceInclTax()); + + } + /** * @param $priceExclTax * @param $weeeTaxExclTax @@ -233,13 +299,49 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') - ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) ->will($this->returnValue($includeWeee)); $this->assertEquals($expectedValue, $this->renderer->getUnitDisplayPriceExclTax()); } + /** + * @param $basePriceExclTax + * @param $baseWeeeTaxExclTax + * @param $weeeEnabled + * @param $includeWeee + * @param $expectedValue + * @dataProvider testGetDisplayPriceDataProvider + */ + public function testGetBaseUnitDisplayPriceExclTax( + $basePriceExclTax, + $baseWeeeTaxExclTax, + $weeeEnabled, + $includeWeee, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->item->expects($this->any()) + ->method('getBaseWeeeTaxAppliedAmount') + ->will($this->returnValue($baseWeeeTaxExclTax)); + + $this->item->expects($this->once()) + ->method('getBasePrice') + ->will($this->returnValue($basePriceExclTax)); + + $this->weeeHelper->expects($this->any()) + ->method('typeOfDisplay') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) + ->will($this->returnValue($includeWeee)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseUnitDisplayPriceExclTax()); + + } + /** * @param $rowTotal * @param $rowWeeeTaxExclTax @@ -269,13 +371,49 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') - ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) ->will($this->returnValue($includeWeee)); $this->assertEquals($expectedValue, $this->renderer->getRowDisplayPriceExclTax()); } + /** + * @param $baseRowTotal + * @param $baseRowWeeeTaxExclTax + * @param $weeeEnabled + * @param $includeWeee + * @param $expectedValue + * @dataProvider testGetDisplayPriceDataProvider + */ + public function testGetBaseRowDisplayPriceExclTax( + $baseRowTotal, + $baseRowWeeeTaxExclTax, + $weeeEnabled, + $includeWeee, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->item->expects($this->any()) + ->method('getBaseWeeeTaxAppliedRowAmnt') + ->will($this->returnValue($baseRowWeeeTaxExclTax)); + + $this->item->expects($this->once()) + ->method('getBaseRowTotal') + ->will($this->returnValue($baseRowTotal)); + + $this->weeeHelper->expects($this->any()) + ->method('typeOfDisplay') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) + ->will($this->returnValue($includeWeee)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseRowDisplayPriceExclTax()); + + } + /** * @param $rowTotalInclTax * @param $rowWeeeTaxInclTax @@ -306,13 +444,50 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->weeeHelper->expects($this->any()) ->method('typeOfDisplay') - ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], 'sales') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) ->will($this->returnValue($includeWeee)); $this->assertEquals($expectedValue, $this->renderer->getRowDisplayPriceInclTax()); } + /** + * @param $baseRowTotalInclTax + * @param $baseRowWeeeTaxInclTax + * @param $weeeEnabled + * @param $includeWeee + * @param $expectedValue + * @dataProvider testGetDisplayPriceDataProvider + */ + public function testGetBaseRowDisplayPriceInclTax( + $baseRowTotalInclTax, + $baseRowWeeeTaxInclTax, + $weeeEnabled, + $includeWeee, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->weeeHelper->expects($this->any()) + ->method('getBaseRowWeeeTaxInclTax') + ->with($this->item) + ->will($this->returnValue($baseRowWeeeTaxInclTax)); + + $this->item->expects($this->once()) + ->method('getBaseRowTotalInclTax') + ->will($this->returnValue($baseRowTotalInclTax)); + + $this->weeeHelper->expects($this->any()) + ->method('typeOfDisplay') + ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE) + ->will($this->returnValue($includeWeee)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseRowDisplayPriceInclTax()); + + } + public function testGetDisplayPriceDataProvider() { $data = [ @@ -378,6 +553,35 @@ class RendererTest extends \PHPUnit_Framework_TestCase } + /** + * @param $basePriceInclTax + * @param $baseWeeeTaxInclTax + * @param $weeeEnabled + * @param $expectedValue + * @dataProvider testGetFinalDisplayPriceDataProvider + */ + public function testGetBaseFinalUnitDisplayPriceInclTax( + $basePriceInclTax, + $baseWeeeTaxInclTax, + $weeeEnabled, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->weeeHelper->expects($this->any()) + ->method('getBaseWeeeTaxInclTax') + ->with($this->item) + ->will($this->returnValue($baseWeeeTaxInclTax)); + + $this->item->expects($this->once()) + ->method('getBasePriceInclTax') + ->will($this->returnValue($basePriceInclTax)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseFinalUnitDisplayPriceInclTax()); + } + /** * @param $priceExclTax * @param $weeeTaxExclTax @@ -407,6 +611,35 @@ class RendererTest extends \PHPUnit_Framework_TestCase } + /** + * @param $basePriceExclTax + * @param $baseWeeeTaxExclTax + * @param $weeeEnabled + * @param $expectedValue + * @dataProvider testGetFinalDisplayPriceDataProvider + */ + public function testGetBaseFinalUnitDisplayPriceExclTax( + $basePriceExclTax, + $baseWeeeTaxExclTax, + $weeeEnabled, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->item->expects($this->any()) + ->method('getBaseWeeeTaxAppliedAmount') + ->will($this->returnValue($baseWeeeTaxExclTax)); + + $this->item->expects($this->once()) + ->method('getBasePrice') + ->will($this->returnValue($basePriceExclTax)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseFinalUnitDisplayPriceExclTax()); + + } + /** * @param $rowTotal * @param $rowWeeeTaxExclTax @@ -436,6 +669,35 @@ class RendererTest extends \PHPUnit_Framework_TestCase } + /** + * @param $baseRowTotal + * @param $baseRowWeeeTaxExclTax + * @param $weeeEnabled + * @param $expectedValue + * @dataProvider testGetFinalDisplayPriceDataProvider + */ + public function testGetBaseFianlRowDisplayPriceExclTax( + $baseRowTotal, + $baseRowWeeeTaxExclTax, + $weeeEnabled, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->item->expects($this->any()) + ->method('getBaseWeeeTaxAppliedRowAmnt') + ->will($this->returnValue($baseRowWeeeTaxExclTax)); + + $this->item->expects($this->once()) + ->method('getBaseRowTotal') + ->will($this->returnValue($baseRowTotal)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceExclTax()); + + } + /** * @param $rowTotalInclTax * @param $rowWeeeTaxInclTax @@ -466,6 +728,36 @@ class RendererTest extends \PHPUnit_Framework_TestCase } + /** + * @param $baseRowTotalInclTax + * @param $baseRowWeeeTaxInclTax + * @param $weeeEnabled + * @param $expectedValue + * @dataProvider testGetFinalDisplayPriceDataProvider + */ + public function testGetBaseFinalRowDisplayPriceInclTax( + $baseRowTotalInclTax, + $baseRowWeeeTaxInclTax, + $weeeEnabled, + $expectedValue + ) { + $this->weeeHelper->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue($weeeEnabled)); + + $this->weeeHelper->expects($this->any()) + ->method('getBaseRowWeeeTaxInclTax') + ->with($this->item) + ->will($this->returnValue($baseRowWeeeTaxInclTax)); + + $this->item->expects($this->once()) + ->method('getBaseRowTotalInclTax') + ->will($this->returnValue($baseRowTotalInclTax)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceInclTax()); + + } + public function testGetFinalDisplayPriceDataProvider() { $data = [ @@ -485,15 +777,83 @@ class RendererTest extends \PHPUnit_Framework_TestCase return $data; } - public function testFormatPrice() + public function testGetTotalAmount() { - $price = 10; - $formattedPrice ="$10.00"; - $this->priceCurrency->expects($this->once()) - ->method('format') - ->with($price) - ->will($this->returnValue($formattedPrice)); - - $this->assertEquals($formattedPrice, $this->renderer->formatPrice($price)); + $rowTotal = 100; + $taxAmount = 10; + $hiddenTaxAmount = 2; + $discountAmount = 20; + $weeeAmount = 5; + + $expectedValue = 97; + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods(['getRowTotal', 'getTaxAmount', 'getHiddenTaxAmount', 'getDiscountAmount', '__wakeup']) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getRowTotal') + ->will($this->returnValue($rowTotal)); + + $itemMock->expects($this->once()) + ->method('getTaxAmount') + ->will($this->returnValue($taxAmount)); + + $itemMock->expects($this->once()) + ->method('getHiddenTaxAmount') + ->will($this->returnValue($hiddenTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getDiscountAmount') + ->will($this->returnValue($discountAmount)); + + $this->weeeHelper->expects($this->once()) + ->method('getRowWeeeTaxInclTax') + ->with($itemMock) + ->will($this->returnValue($weeeAmount)); + + $this->assertEquals($expectedValue, $this->renderer->getTotalAmount($itemMock)); + } + + public function testGetBaseTotalAmount() + { + $baseRowTotal = 100; + $baseTaxAmount = 10; + $baseHiddenTaxAmount = 2; + $baseDiscountAmount = 20; + $baseWeeeAmount = 5; + + $expectedValue = $baseRowTotal + $baseTaxAmount + $baseHiddenTaxAmount - $baseDiscountAmount + $baseWeeeAmount; + + $itemMock = $this->getMockBuilder('\Magento\Sales\Model\Order\Item') + ->disableOriginalConstructor() + ->setMethods( + ['getBaseRowTotal', 'getBaseTaxAmount', 'getBaseHiddenTaxAmount', 'getBaseDiscountAmount', '__wakeup'] + ) + ->getMock(); + + $itemMock->expects($this->once()) + ->method('getBaseRowTotal') + ->will($this->returnValue($baseRowTotal)); + + $itemMock->expects($this->once()) + ->method('getBaseTaxAmount') + ->will($this->returnValue($baseTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getBaseHiddenTaxAmount') + ->will($this->returnValue($baseHiddenTaxAmount)); + + $itemMock->expects($this->once()) + ->method('getBaseDiscountAmount') + ->will($this->returnValue($baseDiscountAmount)); + + $this->weeeHelper->expects($this->once()) + ->method('getBaseRowWeeeTaxInclTax') + ->with($itemMock) + ->will($this->returnValue($baseWeeeAmount)); + + $this->assertEquals($expectedValue, $this->renderer->getBaseTotalAmount($itemMock)); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php b/dev/tests/unit/testsuite/Magento/_files/session_set_name_mock.php similarity index 79% rename from app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php rename to dev/tests/unit/testsuite/Magento/_files/session_set_name_mock.php index 2ed67edf6cc..29f3c2a4242 100644 --- a/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php +++ b/dev/tests/unit/testsuite/Magento/_files/session_set_name_mock.php @@ -21,18 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Framework\Session; -/** - * Class OrderNotifyUser - */ -interface OrderNotifyUserInterface +use \Magento\Backend\Model\SessionTest; + +function session_name($name) { - /** - * Invoke notifyUser service - * - * @param int $id - * @return bool - */ - public function invoke($id); + SessionTest::assertEquals($name, 'adminhtml'); } diff --git a/lib/internal/Magento/Framework/App/Console/Request.php b/lib/internal/Magento/Framework/App/Console/Request.php index cfa00214f2e..6b30e426886 100644 --- a/lib/internal/Magento/Framework/App/Console/Request.php +++ b/lib/internal/Magento/Framework/App/Console/Request.php @@ -105,4 +105,15 @@ class Request implements \Magento\Framework\App\RequestInterface } return $defaultValue; } + + /** + * Stub to satisfy RequestInterface + * + * @param null|string $name + * @param null|string $default + * @return null|string|void + */ + public function getCookie($name, $default) + { + } } diff --git a/lib/internal/Magento/Framework/App/PageCache/FormKey.php b/lib/internal/Magento/Framework/App/PageCache/FormKey.php index 5ea0c4b5531..dfbf440fc4c 100644 --- a/lib/internal/Magento/Framework/App/PageCache/FormKey.php +++ b/lib/internal/Magento/Framework/App/PageCache/FormKey.php @@ -35,19 +35,19 @@ class FormKey const COOKIE_NAME = 'form_key'; /** - * Cookie + * CookieManager * - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $cookie; + protected $cookieManager; /** - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager */ public function __construct( - \Magento\Framework\Stdlib\Cookie $cookie + \Magento\Framework\Stdlib\CookieManager $cookieManager ) { - $this->cookie = $cookie; + $this->cookieManager = $cookieManager; } /** @@ -57,6 +57,6 @@ class FormKey */ public function get() { - return $this->cookie->get(self::COOKIE_NAME); + return $this->cookieManager->getCookie(self::COOKIE_NAME); } } diff --git a/lib/internal/Magento/Framework/App/PageCache/Version.php b/lib/internal/Magento/Framework/App/PageCache/Version.php index 5127f71b84c..55705dd2d3c 100644 --- a/lib/internal/Magento/Framework/App/PageCache/Version.php +++ b/lib/internal/Magento/Framework/App/PageCache/Version.php @@ -40,11 +40,11 @@ class Version const COOKIE_PERIOD = 315360000; /** - * Cookie + * Cookie Manager * - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager */ - protected $cookie; + protected $cookieManager; /** * Request @@ -54,13 +54,23 @@ class Version protected $request; /** - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactory; + + /** + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\App\Request\Http $request */ - public function __construct(\Magento\Framework\Stdlib\Cookie $cookie, \Magento\Framework\App\Request\Http $request) - { - $this->cookie = $cookie; + public function __construct( + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, + \Magento\Framework\App\Request\Http $request + ) { + $this->cookieManager = $cookieManager; $this->request = $request; + $this->cookieMetadataFactory = $cookieMetadataFactory; } /** @@ -84,7 +94,10 @@ class Version public function process() { if ($this->request->isPost()) { - $this->cookie->set(self::COOKIE_NAME, $this->generateValue(), self::COOKIE_PERIOD, '/'); + $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration(self::COOKIE_PERIOD) + ->setPath('/'); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $this->generateValue(), $publicCookieMetadata); } } } diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php index 353e2e8c71c..b3423de5f1a 100644 --- a/lib/internal/Magento/Framework/App/Request/Http.php +++ b/lib/internal/Magento/Framework/App/Request/Http.php @@ -99,15 +99,22 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\Framework\A */ private $_pathInfoProcessor; + /** + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $_cookieManager; + /** * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig * @param PathInfoProcessorInterface $pathInfoProcessor + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param string $uri * @param array $directFrontNames */ public function __construct( \Magento\Framework\App\Route\ConfigInterface $routeConfig, PathInfoProcessorInterface $pathInfoProcessor, + \Magento\Framework\Stdlib\CookieManager $cookieManager, $uri = null, $directFrontNames = array() ) { @@ -115,6 +122,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\Framework\A $this->_directFrontNames = $directFrontNames; parent::__construct($uri); $this->_pathInfoProcessor = $pathInfoProcessor; + $this->_cookieManager = $cookieManager; } /** @@ -599,4 +607,16 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\Framework\A { return array(); } + + /** + * Retrieve a value from a cookie. + * + * @param string|null $name + * @param string|null $default The default value to return if no value could be found for the given $name. + * @return string|null + */ + public function getCookie($name = null, $default = null) + { + return $this->_cookieManager->getCookie($name, $default); + } } diff --git a/lib/internal/Magento/Framework/App/RequestInterface.php b/lib/internal/Magento/Framework/App/RequestInterface.php index b22916ac6b4..35eeb3104d1 100644 --- a/lib/internal/Magento/Framework/App/RequestInterface.php +++ b/lib/internal/Magento/Framework/App/RequestInterface.php @@ -65,4 +65,13 @@ interface RequestInterface * @return mixed */ public function getParam($key, $defaultValue = null); + + /** + * Retrieve cookie value + * + * @param string|null $name + * @param string|null $default + * @return string|null + */ + public function getCookie($name, $default); } diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index 71c0255665c..76eeceb2411 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -25,6 +25,11 @@ */ namespace Magento\Framework\App\Response; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Stdlib\CookieManager; +use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; +use Magento\Framework\App\Http\Context; + class Http extends \Zend_Controller_Response_Http implements HttpInterface { /** @@ -33,9 +38,14 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface const COOKIE_VARY_STRING = 'X-Magento-Vary'; /** - * @var \Magento\Framework\Stdlib\Cookie + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManager; + + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory */ - protected $cookie; + protected $cookieMetadataFactory; /** * @var \Magento\Framework\App\Http\Context @@ -43,12 +53,17 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface protected $context; /** - * @param \Magento\Framework\Stdlib\Cookie $cookie + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param \Magento\Framework\App\Http\Context $context */ - public function __construct(\Magento\Framework\Stdlib\Cookie $cookie, \Magento\Framework\App\Http\Context $context) - { - $this->cookie = $cookie; + public function __construct( + CookieManager $cookieManager, + CookieMetadataFactory $cookieMetadataFactory, + Context $context + ) { + $this->cookieManager = $cookieManager; + $this->cookieMetadataFactory = $cookieMetadataFactory; $this->context = $context; } @@ -72,17 +87,23 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface /** * Send Vary coookie + * * @return void */ public function sendVary() { + $data = $this->context->getData(); if (!empty($data)) { ksort($data); - $vary = sha1(serialize($data)); - $this->cookie->set(self::COOKIE_VARY_STRING, $vary, null, '/'); + $cookieValue = sha1(serialize($data)); + $publicCookMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setPath('/'); + $this->cookieManager->setPublicCookie(self::COOKIE_VARY_STRING, $cookieValue, $publicCookMetadata); } else { - $this->cookie->set(self::COOKIE_VARY_STRING, null, -1, '/'); + $cookieMetadata = $this->cookieMetadataFactory->createCookieMetadata() + ->setPath('/'); + $this->cookieManager->deleteCookie(self::COOKIE_VARY_STRING, $cookieMetadata); } } @@ -162,6 +183,18 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface */ public function __sleep() { - return array('_body', '_exceptions', '_headers', '_headersRaw', '_httpResponseCode', 'context', 'cookie'); + return ['_body', '_exceptions', '_headers', '_headersRaw', '_httpResponseCode', 'context']; + } + + /** + * Need to reconstruct dependencies when being de-serialized. + * + * @return void + */ + public function __wakeup() + { + $objectManager = ObjectManager::getInstance(); + $this->cookieManager = $objectManager->create('Magento\Framework\Stdlib\CookieManager'); + $this->cookieMetadataFactory = $objectManager->get('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory'); } } diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index f8ac21218bb..6d9736238af 100644 --- a/lib/internal/Magento/Framework/AppInterface.php +++ b/lib/internal/Magento/Framework/AppInterface.php @@ -35,7 +35,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '0.1.0-alpha92'; + const VERSION = '0.1.0-alpha93'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php b/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php index b26501324df..813759118a0 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php @@ -61,12 +61,41 @@ class Editablemultiselect extends \Magento\Framework\Data\Form\Element\Multisele $selectConfigJson = \Zend_Json::encode($selectConfig); $jsObjectName = $this->getJsObjectName(); - $html .= '<script type="text/javascript">' . - 'require(["jquery","jquery/ui"], function($) {'. - 'setTimeout(function () { ' . - "var {$jsObjectName} = new {$elementJsClass}({$selectConfigJson}); " . - "{$jsObjectName}.init(); }); }, 1000);" . - '</script>'; + + // TODO: TaxRateEditableMultiselect should be moved to a static .js module. + $html .= " + <script type='text/javascript'> + require([ + 'jquery', + 'jquery/ui' + ], function( $ ){ + + function isResolved(){ + return typeof window['{$elementJsClass}'] !== 'undefined'; + } + + function init(){ + var {$jsObjectName} = new {$elementJsClass}({$selectConfigJson}); + + {$jsObjectName}.init(); + } + + function check( tries, delay ){ + if( isResolved() ){ + init(); + } + else if( tries-- ){ + setTimeout( check.bind(this, tries, delay), delay); + } + else{ + console.warn( 'Unable to resolve dependency: {$elementJsClass}' ); + } + } + + check(8, 500); + + }); + </script>"; return $html; } diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php index de3cd6c97bd..bc43a467506 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php @@ -37,6 +37,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract * No Such Entity Exception */ const NO_SUCH_ENTITY_EXCEPTION = '\\Magento\Framework\Exception\NoSuchEntityException'; + const INPUT_EXCEPTION = '\\Magento\Framework\Exception\InputException'; const SEARCH_CRITERIA = '\\Magento\Framework\Service\V1\Data\SearchCriteria'; /** @@ -181,12 +182,14 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract protected function _getGetMethod() { $body = "if (!\$id) {\n" - . " throw new " . self::NO_SUCH_ENTITY_EXCEPTION . "('Requested product doesn\\'t exist');\n" + . " throw new " . self::INPUT_EXCEPTION . "('ID required');\n" . "}\n" . "if (!isset(\$this->registry[\$id])) {\n" - . " \$this->registry[\$id] = \$this->" - . $this->_getSourceFactoryPropertyName() - . "->create()->load(\$id);\n" + . " \$entity = \$this->" . $this->_getSourceFactoryPropertyName() . "->create()->load(\$id);\n" + . " if (!\$entity->getId()) {\n" + . " throw new " . self::NO_SUCH_ENTITY_EXCEPTION . "('Requested entity doesn\\'t exist');\n" + . " }\n" + . " \$this->registry[\$id] = \$entity;\n" . "}\n" . "return \$this->registry[\$id];"; return [ @@ -209,6 +212,10 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'name' => 'return', 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()), ], + [ + 'name' => 'throws', + 'description' => self::INPUT_EXCEPTION, + ], [ 'name' => 'throws', 'description' => self::NO_SUCH_ENTITY_EXCEPTION, @@ -255,7 +262,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract } /** - * Returns get() method + * Returns find() method * * @return string */ @@ -268,6 +275,8 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract . " \$collection->addFieldToFilter(\$filter->getField(), [\$condition => \$filter->getValue()]);\n" . " }\n" . "}\n" + . "\$collection->setCurPage(\$criteria->getCurrentPage());\n" + . "\$collection->setPageSize(\$criteria->getPageSize());\n" . "foreach (\$collection as \$object) {\n" . " \$this->register(\$object);\n" . "}\n" diff --git a/lib/internal/Magento/Framework/Pricing/Render.php b/lib/internal/Magento/Framework/Pricing/Render.php index 77d625b37f4..4eda7df712d 100644 --- a/lib/internal/Magento/Framework/Pricing/Render.php +++ b/lib/internal/Magento/Framework/Pricing/Render.php @@ -46,6 +46,7 @@ class Render extends AbstractBlock const ZONE_ITEM_OPTION = 'item_option'; const ZONE_SALES = 'sales'; const ZONE_EMAIL = 'email'; + const ZONE_CART = 'cart'; const ZONE_DEFAULT = null; /**@#-*/ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php new file mode 100644 index 00000000000..0f39d132f71 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php @@ -0,0 +1,77 @@ +<?php +/** + * MySQL Search Adapter + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\Search\AdapterInterface; +use Magento\Framework\Search\RequestInterface; + +class Adapter implements AdapterInterface +{ + /** + * Mapper instance + * + * @var Mapper + */ + protected $mapper; + + /** + * Response Factory + * + * @var ResponseFactory + */ + protected $responseFactory; + + /** + * @param Mapper $mapper + * @param ResponseFactory $responseFactory + */ + public function __construct( + Mapper $mapper, + ResponseFactory $responseFactory + ) { + $this->mapper = $mapper; + $this->responseFactory = $responseFactory; + } + + /** + * {@inheritdoc} + */ + public function query(RequestInterface $request) + { + $query = $this->mapper->buildQuery($request); + $response = $this->executeQuery($query); + return $this->responseFactory->create($response); + } + + /** + * Executes query and return raw response + * + * @return mixed + */ + private function executeQuery() + { + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php new file mode 100644 index 00000000000..855cc50bf85 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * Aggregation Factory + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +class AggregationFactory +{ + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager + ) { + $this->objectManager = $objectManager; + } + + /** + * Create Aggregation instance + * + * @param mixed $rawAggregation + * @return \Magento\Framework\Search\Aggregation + */ + public function create($rawAggregation) + { + $buckets = array(); + foreach ($rawAggregation as $rawBucket) { + /** @var \Magento\Framework\Search\Bucket[] $buckets */ + $buckets[] = $this->objectManager->create( + '\Magento\Framework\Search\Bucket', + [ + $rawBucket['name'], + $rawBucket['value'] + ] + ); + } + return $this->objectManager->create('\Magento\Framework\Search\Aggregation', $buckets); + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php new file mode 100644 index 00000000000..5d28d026424 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php @@ -0,0 +1,67 @@ +<?php +/** + * Response Factory + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +class DocumentFactory +{ + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager + ) { + $this->objectManager = $objectManager; + } + + /** + * Create Search Document instance + * + * @param mixed $rawDocument + * @return \Magento\Framework\Search\Document + */ + public function create($rawDocument) + { + $fields = array(); + foreach ($rawDocument as $rawField) { + /** @var \Magento\Framework\Search\DocumentField[] $fields */ + $fields[] = $this->objectManager->create( + '\Magento\Framework\Search\DocumentField', + [ + $rawField['name'], + $rawField['values'] + ] + ); + } + return $this->objectManager->create('\Magento\Framework\Search\Document', $fields); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderListInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php similarity index 69% rename from app/code/Magento/Sales/Service/V1/OrderListInterface.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php index 508fd35e1f5..938d160486d 100644 --- a/app/code/Magento/Sales/Service/V1/OrderListInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php @@ -1,5 +1,7 @@ <?php /** + * Mapper class. Maps library request to specific adapter dependent query + * * Magento * * NOTICE OF LICENSE @@ -21,20 +23,20 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Framework\Search\Adapter\Mysql; -use Magento\Framework\Service\V1\Data\SearchCriteria; +use Magento\Framework\Search\RequestInterface; -/** - * Interface OrderListInterface - */ -interface OrderListInterface +class Mapper { /** - * Invoke OrderList service + * Build adapter dependent query * - * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria - * @return \Magento\Catalog\Service\V1\Data\Product\SearchResults + * @param RequestInterface $request + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return mixed */ - public function invoke(SearchCriteria $searchCriteria); + public function buildQuery(RequestInterface $request) + { + } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php new file mode 100644 index 00000000000..1040b48b5d9 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php @@ -0,0 +1,91 @@ +<?php +/** + * Response Factory + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\Search\QueryResponse; + +class ResponseFactory +{ + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * Document Factory + * + * @var DocumentFactory + */ + protected $documentFactory; + + /** + * Aggregation Factory + * + * @var AggregationFactory + */ + protected $aggregationFactory; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + * @param DocumentFactory $documentFactory + * @param AggregationFactory $aggregationFactory + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + DocumentFactory $documentFactory, + AggregationFactory $aggregationFactory + ) { + $this->objectManager = $objectManager; + $this->documentFactory = $documentFactory; + $this->aggregationFactory = $aggregationFactory; + } + + /** + * Create Query Response instance + * + * @param mixed $rawResponse + * @return QueryResponse + */ + public function create($rawResponse) + { + $documents = array(); + foreach ($rawResponse['documents'] as $rawDocument) { + /** @var \Magento\Framework\Search\Document[] $documents */ + $documents[] = $this->documentFactory->create($rawDocument); + } + /** @var \Magento\Framework\Search\Aggregation $aggregations */ + $aggregations = $this->documentFactory->create($rawResponse['aggregation']); + return $this->objectManager->create( + '\Magento\Framework\Search\QueryResponse', + [ + 'documents' => $documents, + 'aggregations' => $aggregations + ] + ); + } +} diff --git a/lib/internal/Magento/Framework/Search/AdapterFactory.php b/lib/internal/Magento/Framework/Search/AdapterFactory.php new file mode 100644 index 00000000000..72af3424bd6 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/AdapterFactory.php @@ -0,0 +1,91 @@ +<?php +/** + * Adapter Factory + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class AdapterFactory +{ + /** + * Scope configuration + * + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * Config path + * + * @var string + */ + protected $path; + + /** + * Config Scope + */ + protected $scope; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param string $path + * @param string $scopeType + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + $path, + $scopeType + ) { + $this->objectManager = $objectManager; + $this->scopeConfig = $scopeConfig; + $this->path = $path; + $this->scope = $scopeType; + } + + /** + * Create Adapter instance + * + * @param array $data + * @return AdapterInterface + */ + public function create(array $data = array()) + { + $adapterClass = $this->scopeConfig->getValue($this->path, $this->scope); + $adapter = $this->objectManager->create($adapterClass, $data); + if (!($adapter instanceof \Magento\Framework\Search\AdapterInterface)) { + throw new \InvalidArgumentException( + 'Adapter must implement \Magento\Framework\Search\AdapterInterface' + ); + } + return $adapter; + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php b/lib/internal/Magento/Framework/Search/AdapterInterface.php similarity index 77% rename from app/code/Magento/Sales/Service/V1/OrderHoldInterface.php rename to lib/internal/Magento/Framework/Search/AdapterInterface.php index 0ba9ba3733c..b439981f00e 100644 --- a/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php +++ b/lib/internal/Magento/Framework/Search/AdapterInterface.php @@ -1,5 +1,7 @@ <?php /** + * Search Adapter interface + * * Magento * * NOTICE OF LICENSE @@ -21,19 +23,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Framework\Search; -/** - * Interface OrderHoldInterface - */ -interface OrderHoldInterface +interface AdapterInterface { /** - * Invoke orderHold service + * Process Search Request * - * @param int $id - * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @param RequestInterface $request + * @return QueryResponse */ - public function invoke($id); + public function query(RequestInterface $request); } diff --git a/lib/internal/Magento/Framework/Search/Aggregation.php b/lib/internal/Magento/Framework/Search/Aggregation.php new file mode 100644 index 00000000000..b9a065fb599 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Aggregation.php @@ -0,0 +1,75 @@ +<?php +/** + * Faceted data + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class Aggregation implements \IteratorAggregate +{ + /** + * Buckets array + * + * @var Bucket[] + */ + protected $buckets; + + /** + * @param Bucket[] $buckets + */ + public function __construct(array $buckets) + { + $this->buckets = $buckets; + } + + /** + * Implementation of \IteratorAggregate::getIterator() + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->buckets); + } + + /** + * Get Document field + * + * @param string $bucketName + * @return Bucket + */ + public function getBucket($bucketName) + { + return $this->buckets[$bucketName]; + } + + /** + * Get Document field names + * + * @return array + */ + public function getBucketNames() + { + return array_keys($this->buckets); + } +} diff --git a/lib/internal/Magento/Framework/Search/Bucket.php b/lib/internal/Magento/Framework/Search/Bucket.php new file mode 100644 index 00000000000..17e7f27a704 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Bucket.php @@ -0,0 +1,73 @@ +<?php +/** + * Facet Bucket + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class Bucket +{ + /** + * Bucket name + * + * @var string + */ + protected $name; + + /** + * Bucket value + * + * @var mixed + */ + protected $value; + + /** + * @param string $name + * @param mixed $value + */ + public function __construct($name, $value) + { + $this->name = $name; + $this->value = $value; + } + + /** + * Get bucket name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get bucket values + * + * @return mixed + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/internal/Magento/Framework/Search/Document.php b/lib/internal/Magento/Framework/Search/Document.php new file mode 100644 index 00000000000..ea540197a39 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Document.php @@ -0,0 +1,97 @@ +<?php +/** + * Search Document + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class Document implements \IteratorAggregate +{ + /** + * Document fields array + * + * @var DocumentField[] + */ + protected $documentFields; + + /** + * Document Id + * + * @var int + */ + protected $documentId; + + /** + * @param int $documentId + * @param DocumentField[] $documentFields + */ + public function __construct( + $documentId, + array $documentFields + ) { + $this->documentId = $documentId; + $this->documentFields = $documentFields; + } + + /** + * Implementation of \IteratorAggregate::getIterator() + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->documentFields); + } + + /** + * Get Document field + * + * @param string $fieldName + * @return DocumentField + */ + public function getField($fieldName) + { + return $this->documentFields[$fieldName]; + } + + /** + * Get Document field names + * + * @return array + */ + public function getFieldNames() + { + return array_keys($this->documentFields); + } + + /** + * Get Document Id + * + * @return int + * @codeCoverageIgnore + */ + public function getId() + { + return $this->documentId; + } +} diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php b/lib/internal/Magento/Framework/Search/DocumentField.php similarity index 57% rename from dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php rename to lib/internal/Magento/Framework/Search/DocumentField.php index c2c4aa6befb..5e8af0f3cfe 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php +++ b/lib/internal/Magento/Framework/Search/DocumentField.php @@ -1,5 +1,7 @@ <?php /** + * Search Document Field + * * Magento * * NOTICE OF LICENSE @@ -21,31 +23,51 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Test; +namespace Magento\Framework\Search; -class CookieTest extends \PHPUnit_Framework_TestCase +class DocumentField { /** - * Name of the sample cookie to be used in tests + * Document field name + * + * @var string */ - const SAMPLE_COOKIE_NAME = 'sample_cookie'; + protected $name; /** - * @var \Magento\TestFramework\Cookie + * Document field values + * + * @var array */ - protected $_model; + protected $values; + + /** + * @param string $name + * @param array $values + */ + public function __construct($name, array $values) + { + $this->name = $name; + $this->values = $values; + } - protected function setUp() + /** + * Get field name + * + * @return string + */ + public function getName() { - $this->_model = new \Magento\TestFramework\Cookie(); + return $this->name; } - public function testSet() + /** + * Get field values + * + * @return array + */ + public function getValues() { - $cookieValue = 'some_cookie_value'; - $this->assertNull($this->_model->get(self::SAMPLE_COOKIE_NAME)); - $this->_model->set(self::SAMPLE_COOKIE_NAME, $cookieValue); - $this->assertEquals($cookieValue, $this->_model->get(self::SAMPLE_COOKIE_NAME)); - $this->assertEquals($cookieValue, $_COOKIE[self::SAMPLE_COOKIE_NAME]); + return $this->values; } } diff --git a/lib/internal/Magento/Framework/Search/QueryResponse.php b/lib/internal/Magento/Framework/Search/QueryResponse.php new file mode 100644 index 00000000000..f93bb915642 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/QueryResponse.php @@ -0,0 +1,82 @@ +<?php +/** + * Search Response + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search; + +class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable +{ + /** + * Document Collection + * + * @var Document[] + */ + protected $documents; + + /** + * Aggregation Collection + * + * @var Aggregation[] + */ + protected $aggregations; + + /** + * @param Document[] $documents + * @param Aggregation[] $aggregations + */ + public function __construct(array $documents, array $aggregations) + { + $this->documents = $documents; + $this->aggregations = $aggregations; + } + + /** + * Countable: return count of fields in document + * @return int + */ + public function count() + { + return count($this->documents); + } + + /** + * Implementation of \IteratorAggregate::getIterator() + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->documents); + } + + /** + * Return Aggregation Collection + * + * @return Aggregation[] + */ + public function getAggregations() + { + return $this->aggregations; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request.php b/lib/internal/Magento/Framework/Search/Request.php index 5bae18e314a..787aed2417a 100644 --- a/lib/internal/Magento/Framework/Search/Request.php +++ b/lib/internal/Magento/Framework/Search/Request.php @@ -25,6 +25,7 @@ namespace Magento\Framework\Search; use Magento\Framework\Search\Request\BucketInterface; +use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\QueryInterface; /** @@ -64,12 +65,18 @@ class Request implements RequestInterface */ protected $size; + /** + * @var Dimension[] + */ + protected $dimensions; + /** * @param string $name * @param string $indexName * @param QueryInterface $query * @param int|null $from * @param int|null $size + * @param Dimension[] $dimensions * @param BucketInterface[] $buckets */ public function __construct( @@ -78,14 +85,16 @@ class Request implements RequestInterface QueryInterface $query, $from = null, $size = null, + array $dimensions = null, array $buckets = null ) { $this->name = $name; $this->index = $indexName; - $this->buckets = $buckets; $this->query = $query; $this->from = $from; $this->size = $size; + $this->buckets = $buckets; + $this->dimensions = $dimensions; } /** @@ -104,6 +113,14 @@ class Request implements RequestInterface return $this->index; } + /** + * @return Dimension[] + */ + public function getDimensions() + { + $this->dimensions; + } + /** * {@inheritdoc} */ diff --git a/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php similarity index 73% rename from app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php rename to lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php index 821a64129ae..ac529f8ed12 100644 --- a/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php @@ -1,5 +1,7 @@ <?php /** + * Metric + * * Magento * * NOTICE OF LICENSE @@ -21,20 +23,30 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Framework\Search\Request\Aggregation; -/** - * Interface OrderGetStatusInterface - * @package Magento\Sales\Service\V1 - */ -interface OrderGetStatusInterface +class Metric { /** - * Retrieve order status by id + * @var string + */ + protected $type; + + /** + * @param string $type + */ + public function __construct($type) + { + $this->type = $type; + } + + /** + * Get Type * - * @param int $id * @return string - * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function invoke($id); + public function getType() + { + return $this->type; + } } diff --git a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php index 8fc0463fe21..3457b288179 100644 --- a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php @@ -30,9 +30,9 @@ interface BucketInterface /** * #@+ Bucket Types */ - const TYPE_TERM = 'term'; + const TYPE_TERM = 'termBucket'; - const TYPE_RANGE = 'range'; + const TYPE_RANGE = 'rangeBucket'; /**#@-*/ diff --git a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php index 87bd3895fbe..9c244774944 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php @@ -42,9 +42,10 @@ class Converter implements \Magento\Framework\Config\ConverterInterface /** @var \DOMElement $requestNode */ $name = $requestNode->getAttribute('query'); $request = $this->mergeAttributes((array)$simpleXmlNode); + $request['dimensions'] = $this->convertNodes($simpleXmlNode->dimensions, 'name'); $request['queries'] = $this->convertNodes($simpleXmlNode->queries, 'name'); $request['filters'] = $this->convertNodes($simpleXmlNode->filters, 'name'); - //$request['aggregation'] = $this->convertNodes($simpleXmlNode->aggregation, 'name'); + $request['aggregation'] = $this->convertNodes($simpleXmlNode->aggregation, 'name'); $requests[$name] = $request; } return $requests; @@ -89,10 +90,8 @@ class Converter implements \Magento\Framework\Config\ConverterInterface /** @var \SimpleXMLElement $node */ foreach ($nodes->children() as $node) { $element = $this->convertToArray($node->attributes()); - if (count($node->children()) > 0) { - foreach ($node->children() as $child) { - $element[$child->getName()][] = $this->convertToArray($child); - } + if ($node->count() > 0) { + $element = $this->convertChildNodes($element, $node); } $type = (string)$node->attributes('xsi', true)['type']; if (!empty($type)) { @@ -103,4 +102,23 @@ class Converter implements \Magento\Framework\Config\ConverterInterface } return $list; } + + /** + * Convert child nodes to array + * + * @param array $element + * @param \SimpleXMLElement $node + * @return array + */ + protected function convertChildNodes(array $element, \SimpleXMLElement $node) + { + if ($node->count() == 0) { + $element[$node->getName()][] = $this->convertToArray($node); + } else { + foreach ($node->children() as $child) { + $element = $this->convertChildNodes($element, $child); + } + } + return $element; + } } diff --git a/lib/internal/Magento/Framework/Search/Request/Dimension.php b/lib/internal/Magento/Framework/Search/Request/Dimension.php new file mode 100644 index 00000000000..1cdc73a0b24 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Dimension.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Request; + +class Dimension +{ + /** @var string */ + private $name; + + /** @var string */ + private $value; + + /** + * @param string $name + * @param string $value + */ + public function __construct($name, $value) + { + $this->name = $name; + $this->value = $value; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php index a54a217ce80..8b76ac54787 100644 --- a/lib/internal/Magento/Framework/Search/Request/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php @@ -24,6 +24,7 @@ namespace Magento\Framework\Search\Request; use Magento\Framework\Search\Request\Query\Filter; +use Magento\Framework\Exception\StateException; class Mapper { @@ -37,24 +38,62 @@ class Mapper */ private $filters; + /** + * @var string[] + */ + private $mappedQueries; + + /** + * @var string[] + */ + private $mappedFilters; + + /** + * @var array + */ + private $aggregation; + /** * @var \Magento\Framework\ObjectManager */ private $objectManager; + /** + * @var QueryInterface + */ + private $rootQuery = null; + /** * @param \Magento\Framework\ObjectManager $objectManager * @param array $queries + * @param string $rootQueryName + * @param array $aggregation * @param array $filters + * @throws \Exception + * @throws \InvalidArgumentException + * @throws StateException */ public function __construct( \Magento\Framework\ObjectManager $objectManager, array $queries, - array $filters = null + $rootQueryName, + array $aggregation, + array $filters = [] ) { $this->objectManager = $objectManager; $this->queries = $queries; + $this->aggregation = $aggregation; $this->filters = $filters; + + $this->rootQuery = $this->get($rootQueryName); + } + + /** + * @return QueryInterface + */ + public function getRootQuery() + { + return $this->rootQuery; } /** @@ -62,24 +101,36 @@ class Mapper * * @param string $queryName * @return QueryInterface + * @throws \Exception + * @throws \InvalidArgumentException + * @throws StateException */ - public function get($queryName) + private function get($queryName) { - return $this->mapQuery($queryName); + $this->mappedQueries = []; + $this->mappedFilters = []; + $query = $this->mapQuery($queryName); + $this->validate(); + return $query; } /** * Convert array to Query instance * * @param string $queryName - * @throws \Exception * @return QueryInterface + * @throws \Exception + * @throws \InvalidArgumentException + * @throws StateException */ private function mapQuery($queryName) { if (!isset($this->queries[$queryName])) { throw new \Exception('Query ' . $queryName . ' does not exist'); + } elseif (in_array($queryName, $this->mappedQueries)) { + throw new StateException('Cycle found. Query %1 already used in request hierarchy', [$queryName]); } + $this->mappedQueries[] = $queryName; $query = $this->queries[$queryName]; switch ($query['type']) { case QueryInterface::TYPE_MATCH: @@ -164,12 +215,18 @@ class Mapper * @param string $filterName * @throws \Exception * @return FilterInterface + * @throws \Exception + * @throws \InvalidArgumentException + * @throws StateException */ private function mapFilter($filterName) { if (!isset($this->filters[$filterName])) { throw new \Exception('Filter ' . $filterName . ' does not exist'); + } elseif (in_array($filterName, $this->mappedFilters)) { + throw new StateException('Cycle found. Filter %1 already used in request hierarchy', [$filterName]); } + $this->mappedFilters[] = $filterName; $filter = $this->filters[$filterName]; switch ($filter['type']) { case FilterInterface::TYPE_TERM: @@ -209,4 +266,129 @@ class Mapper } return $filter; } + + /** + * @return void + * @throws StateException + */ + private function validate() + { + $this->validateQueries(); + $this->validateFilters(); + } + + /** + * @return void + * @throws StateException + */ + private function validateQueries() + { + $this->validateNotUsed($this->queries, $this->mappedQueries, 'Query %1 not used in request hierarchy'); + } + + /** + * @return void + * @throws StateException + */ + private function validateFilters() + { + $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 not used in request hierarchy'); + } + + /** + * @param array $elements + * @param string[] $mappedElements + * @param string $errorMessage + * @return void + * @throws \Magento\Framework\Exception\StateException + */ + private function validateNotUsed($elements, $mappedElements, $errorMessage) + { + $allElements = array_keys($elements); + $notUsedElements = implode(', ', array_diff($allElements, $mappedElements)); + if (!empty($notUsedElements)) { + throw new StateException($errorMessage, [$notUsedElements]); + } + } + + /** + * Build BucketInterface[] from array + * + * @return array + * @throws StateException + */ + public function getBuckets() + { + $buckets = array(); + foreach ($this->aggregation as $bucketData) { + $arguments = + [ + 'name' => $bucketData['name'], + 'field' => $bucketData['field'], + 'metrics' => $this->mapMetrics($bucketData['metric']) + ]; + switch ($bucketData['type']) { + case BucketInterface::TYPE_TERM: + $bucket = $this->objectManager->create( + 'Magento\Framework\Search\Request\Aggregation\TermBucket', + $arguments + ); + break; + case BucketInterface::TYPE_RANGE: + $bucket = $this->objectManager->create( + 'Magento\Framework\Search\Request\Aggregation\RangeBucket', + array_merge( + $arguments, + ['ranges' => $this->mapRanges($bucketData['range'])] + ) + ); + break; + default: + throw new StateException('Invalid bucket type'); + } + $buckets[] = $bucket; + } + return $buckets; + } + + /** + * Build Metric[] from array + * + * @param array $metrics + * @return array + */ + private function mapMetrics(array $metrics) + { + $metricObjects = array(); + foreach ($metrics as $metric) { + $metricObjects[] = $this->objectManager->create( + 'Magento\Framework\Search\Request\Aggregation\Metric', + [ + 'type' => $metric['type'] + ] + ); + } + return $metricObjects; + } + + /** + * Build Range[] from array + * + * @param array $ranges + * @return array + */ + private function mapRanges(array $ranges) + { + $rangeObjects = array(); + foreach ($ranges as $range) { + $rangeObjects[] = $this->objectManager->create( + 'Magento\Framework\Search\Request\Aggregation\Range', + [ + 'from' => $range['from'], + 'to' => $range['to'] + ] + ); + } + return $rangeObjects; + } } diff --git a/lib/internal/Magento/Framework/Search/RequestFactory.php b/lib/internal/Magento/Framework/Search/RequestFactory.php index 38db68f9dbe..a83c16c9c6f 100644 --- a/lib/internal/Magento/Framework/Search/RequestFactory.php +++ b/lib/internal/Magento/Framework/Search/RequestFactory.php @@ -96,11 +96,14 @@ class RequestFactory */ private function convert($data) { + /** @var \Magento\Framework\Search\Request\Mapper $mapper */ $mapper = $this->objectManager->create( 'Magento\Framework\Search\Request\Mapper', [ 'objectManager' => $this->objectManager, + 'rootQueryName' => $data['query'], 'queries' => $data['queries'], + 'aggregation' => $data['aggregation'], 'filters' => $data['filters'] ] ); @@ -111,8 +114,17 @@ class RequestFactory 'indexName' => $data['index'], 'from' => $data['from'], 'size' => $data['size'], - 'query' => $mapper->get($data['query']), - 'buckets' => [], + 'query' => $mapper->getRootQuery(), + 'demensions' => array_map( + function ($data) { + return $this->objectManager->create( + 'Magento\Framework\Search\Request\Dimension', + $data + ); + }, + isset($data['demensions']) ? $data['demensions'] : [] + ), + 'buckets' => $mapper->getBuckets() ] ); } diff --git a/lib/internal/Magento/Framework/Search/RequestInterface.php b/lib/internal/Magento/Framework/Search/RequestInterface.php index b249646af65..822b29af80d 100644 --- a/lib/internal/Magento/Framework/Search/RequestInterface.php +++ b/lib/internal/Magento/Framework/Search/RequestInterface.php @@ -25,9 +25,9 @@ */ namespace Magento\Framework\Search; -use Magento\Framework\Search\Request\FilterInterface; use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\Search\Request\QueryInterface; +use Magento\Framework\Search\Request\Dimension; interface RequestInterface { @@ -45,6 +45,11 @@ interface RequestInterface */ public function getIndex(); + /** + * @return Dimension[] + */ + public function getDimensions(); + /** * Get Aggregation Buckets * diff --git a/lib/internal/Magento/Framework/Search/SearchEngine.php b/lib/internal/Magento/Framework/Search/SearchEngine.php index 7a738edf64f..8297585cd90 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngine.php +++ b/lib/internal/Magento/Framework/Search/SearchEngine.php @@ -27,11 +27,25 @@ namespace Magento\Framework\Search; class SearchEngine implements SearchEngineInterface { + /** + * @var AdapterInterface + */ + protected $adapter; + + /** + * @param AdapterFactory $adapterFactory + */ + public function __construct( + AdapterFactory $adapterFactory + ) { + $this->adapter = $adapterFactory->create(); + } + /** * {@inheritdoc} - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function search(RequestInterface $request) { + return $this->adapter->query($request); } } diff --git a/lib/internal/Magento/Framework/Search/etc/requests.xsd b/lib/internal/Magento/Framework/Search/etc/requests.xsd index 67d2cfb81dc..cfdd133b458 100644 --- a/lib/internal/Magento/Framework/Search/etc/requests.xsd +++ b/lib/internal/Magento/Framework/Search/etc/requests.xsd @@ -27,6 +27,7 @@ <xs:complexType name="request"> <xs:sequence> + <xs:element type="dimensions" name="dimensions" minOccurs="0" maxOccurs="1"/> <xs:element type="queries" name="queries" minOccurs="1"> <xs:key name="queryName"> <xs:selector xpath="query" /> @@ -65,6 +66,21 @@ </xs:simpleType> </xs:attribute> + <xs:complexType name="dimension"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="name" use="required" /> + <xs:attribute type="xs:string" name="value" use="required" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="dimensions"> + <xs:sequence> + <xs:element type="dimension" name="dimension" /> + </xs:sequence> + </xs:complexType> + <!-- Queries Type hierarchy --> <xs:complexType name="queries"> <xs:annotation> diff --git a/lib/internal/Magento/Framework/Session/Config.php b/lib/internal/Magento/Framework/Session/Config.php index 407750a9ade..f66cb6fcbcf 100644 --- a/lib/internal/Magento/Framework/Session/Config.php +++ b/lib/internal/Magento/Framework/Session/Config.php @@ -123,6 +123,11 @@ class Config implements ConfigInterface */ protected $_scopeType; + /** + * @var \Magento\TestFramework\ObjectManager + */ + protected $_objectManager; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\String $stringHelper @@ -165,7 +170,7 @@ class Config implements ConfigInterface $this->setOption('session.cache_limiter', $cacheLimiter); } - $lifetime = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, $this->_scopeType); + $lifetime = $this->_scopeConfig->getValue($lifetimePath, $this->_scopeType); $lifetime = is_numeric($lifetime) ? $lifetime : self::COOKIE_LIFETIME_DEFAULT; $this->setCookieLifetime($lifetime); @@ -231,10 +236,7 @@ class Config implements ConfigInterface public function setOption($option, $value) { $option = $this->getFixedOptionName($option); - if (!array_key_exists($option, $this->options) || $this->options[$option] != $value) { - $this->setStorageOption($option, $value); - $this->options[$option] = $value; - } + $this->options[$option] = $value; return $this; } @@ -248,7 +250,7 @@ class Config implements ConfigInterface public function getOption($option) { $option = $this->getFixedOptionName($option); - if ($this->hasOption($option)) { + if (array_key_exists($option, $this->options)) { return $this->options[$option]; } @@ -261,18 +263,6 @@ class Config implements ConfigInterface return null; } - /** - * Check to see if an internal option has been set for the key provided. - * - * @param string $option - * @return bool - */ - public function hasOption($option) - { - $option = $this->getFixedOptionName($option); - return array_key_exists($option, $this->options); - } - /** * Convert config to array * @@ -390,13 +380,6 @@ class Config implements ConfigInterface */ public function getCookiePath() { - if (!$this->hasOption('session.cookie_path')) { - $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType); - if (empty($path)) { - $path = $this->_httpRequest->getBasePath(); - } - $this->setCookiePath($path); - } return (string)$this->getOption('session.cookie_path'); } @@ -499,24 +482,6 @@ class Config implements ConfigInterface return (bool)$this->getOption('session.use_cookies'); } - /** - * Set storage option in backend configuration store - * - * @param string $option - * @param string $value - * @return $this - * @throws \InvalidArgumentException - */ - protected function setStorageOption($option, $value) - { - $result = ini_set($option, $value); - if ($result === false) { - throw new \InvalidArgumentException(sprintf('"%s" is not a valid sessions-related ini setting.', $option)); - } - - return $this; - } - /** * Retrieve a storage option from a backend configuration store * diff --git a/lib/internal/Magento/Framework/Session/Config/ConfigInterface.php b/lib/internal/Magento/Framework/Session/Config/ConfigInterface.php index b6f88385634..6df53723a77 100644 --- a/lib/internal/Magento/Framework/Session/Config/ConfigInterface.php +++ b/lib/internal/Magento/Framework/Session/Config/ConfigInterface.php @@ -59,14 +59,6 @@ interface ConfigInterface */ public function getOption($option); - /** - * Check to see if an internal option has been set for the key provided. - * - * @param string $option - * @return bool - */ - public function hasOption($option); - /** * Convert config to array * diff --git a/lib/internal/Magento/Framework/Session/Generic.php b/lib/internal/Magento/Framework/Session/Generic.php index 35f2350ba36..d429ec02720 100644 --- a/lib/internal/Magento/Framework/Session/Generic.php +++ b/lib/internal/Magento/Framework/Session/Generic.php @@ -34,6 +34,8 @@ class Generic extends SessionManager * @param SaveHandlerInterface $saveHandler * @param ValidatorInterface $validator * @param StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param null $sessionName */ public function __construct( @@ -43,9 +45,20 @@ class Generic extends SessionManager SaveHandlerInterface $saveHandler, ValidatorInterface $validator, StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, $sessionName = null ) { - parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); + parent::__construct( + $request, + $sidResolver, + $sessionConfig, + $saveHandler, + $validator, + $storage, + $cookieManager, + $cookieMetadataFactory + ); $this->start($sessionName); } } diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php index 4df283272e9..219a76b39d5 100644 --- a/lib/internal/Magento/Framework/Session/SessionManager.php +++ b/lib/internal/Magento/Framework/Session/SessionManager.php @@ -25,6 +25,8 @@ */ namespace Magento\Framework\Session; +use Magento\Framework\Session\Config\ConfigInterface; + /** * Session Manager */ @@ -90,23 +92,39 @@ class SessionManager implements SessionManagerInterface */ protected $storage; + /** + * Cookie Manager + * + * @var \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManager; + + /** + * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactory; + /** * Constructor * * @param \Magento\Framework\App\Request\Http $request * @param SidResolverInterface $sidResolver - * @param Config\ConfigInterface $sessionConfig + * @param ConfigInterface $sessionConfig * @param SaveHandlerInterface $saveHandler * @param ValidatorInterface $validator * @param StorageInterface $storage + * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory */ public function __construct( \Magento\Framework\App\Request\Http $request, SidResolverInterface $sidResolver, - Config\ConfigInterface $sessionConfig, + ConfigInterface $sessionConfig, SaveHandlerInterface $saveHandler, ValidatorInterface $validator, - StorageInterface $storage + StorageInterface $storage, + \Magento\Framework\Stdlib\CookieManager $cookieManager, + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { $this->request = $request; $this->sidResolver = $sidResolver; @@ -114,6 +132,8 @@ class SessionManager implements SessionManagerInterface $this->saveHandler = $saveHandler; $this->validator = $validator; $this->storage = $storage; + $this->cookieManager = $cookieManager; + $this->cookieMetadataFactory = $cookieMetadataFactory; // Enable session.use_only_cookies ini_set('session.use_only_cookies', '1'); @@ -157,6 +177,8 @@ class SessionManager implements SessionManagerInterface { if (!$this->isSessionExists()) { \Magento\Framework\Profiler::start('session_start'); + // Need to apply the config options so they can be ready by session_start + $this->initIniOptions(); if (!empty($sessionName)) { $this->setName($sessionName); } @@ -464,15 +486,12 @@ class SessionManager implements SessionManagerInterface foreach (array_keys($this->_getHosts()) as $host) { // Delete cookies with the same name for parent domains if (strpos($this->sessionConfig->getCookieDomain(), $host) > 0) { - setcookie( - $this->getName(), - '', - 0, - $this->sessionConfig->getCookiePath(), - $host, - $this->sessionConfig->getCookieSecure(), - $this->sessionConfig->getCookieHttpOnly() - ); + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); + $metadata->setPath($this->sessionConfig->getCookiePath()); + $metadata->setDomain($host); + $metadata->setSecure($this->sessionConfig->getCookieSecure()); + $metadata->setHttpOnly($this->sessionConfig->getCookieHttpOnly()); + $this->cookieManager->deleteCookie($this->getName(), $metadata); } } } @@ -490,15 +509,24 @@ class SessionManager implements SessionManagerInterface return; } - setcookie( - $this->getName(), - '', - 0, - $this->sessionConfig->getCookiePath(), - $this->sessionConfig->getCookieDomain(), - $this->sessionConfig->getCookieSecure(), - $this->sessionConfig->getCookieHttpOnly() - ); + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); + $metadata->setPath($this->sessionConfig->getCookiePath()); + $metadata->setDomain($this->sessionConfig->getCookieDomain()); + $metadata->setSecure($this->sessionConfig->getCookieSecure()); + $metadata->setHttpOnly($this->sessionConfig->getCookieHttpOnly()); + $this->cookieManager->deleteCookie($this->getName(), $metadata); $this->clearSubDomainSessionCookie(); } + + /** + * Performs ini_set for all of the config options so they can be read by session_start + * + * @return void + */ + private function initIniOptions() + { + foreach ($this->sessionConfig->getOptions() as $option => $value) { + ini_set($option, $value); + } + } } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie.php b/lib/internal/Magento/Framework/Stdlib/Cookie.php deleted file mode 100644 index 59f29dfc482..00000000000 --- a/lib/internal/Magento/Framework/Stdlib/Cookie.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\Stdlib; - -/** - * Core cookie model - */ -class Cookie -{ - /** - * Set cookie - * - * @param string $name The cookie name - * @param string $value The cookie value - * @param int $period Lifetime period - * @param string $path - * @param string $domain - * @param bool|int|string $secure - * @param bool|string $httponly - * @return $this - */ - public function set($name, $value, $period = null, $path = null, $domain = null, $secure = null, $httponly = null) - { - /** - * Check headers sent - */ - if (headers_sent()) { - return $this; - } - - if ($period === true) { - $period = 3600 * 24 * 365; - } - - if ($period == 0) { - $expire = 0; - } else { - $expire = time() + $period; - } - - setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); - - return $this; - } - - /** - * Postpone cookie expiration time if cookie value defined - * - * @param string $name The cookie name - * @param int $period Lifetime period - * @param string $path - * @param string $domain - * @param bool|int|string $secure - * @param string|bool $httponly - * @return $this - */ - public function renew($name, $period = null, $path = null, $domain = null, $secure = null, $httponly = null) - { - if ($period === null) { - return $this; - } - $value = $this->get($name, false); - if ($value !== false) { - $this->set($name, $value, $period, $path, $domain, $secure, $httponly); - } - return $this; - } - - /** - * Retrieve cookie or false if not exists - * - * @param string|null $name - * @param mixed|null $default - * @return mixed - */ - public function get($name = null, $default = null) - { - if (null === $name) { - return $_COOKIE; - } - return (isset($_COOKIE[$name])) ? $_COOKIE[$name] : $default; - } -} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php index f41a5fdf5f2..7b733c3cf1d 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php @@ -78,7 +78,7 @@ class CookieMetadataFactory * @param array $metadata * @return CookieMetadata */ - public function createCookieMetadata($metadata) + public function createCookieMetadata($metadata = []) { return $this->objectManager->create( 'Magento\Framework\Stdlib\Cookie\CookieMetadata', diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index dc5729ccc25..90ba0fa4077 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -122,7 +122,7 @@ class PhpCookieManager implements CookieManager * @throws CookieSizeLimitReachedException Thrown when the cookie is too big to store any additional data. * @throws InputException If the cookie name is empty or contains invalid characters. */ - private function setCookie($name, $value, array $metadataArray) + protected function setCookie($name, $value, array $metadataArray) { $expire = $this->computeExpirationTime($metadataArray); @@ -272,9 +272,6 @@ class PhpCookieManager implements CookieManager */ public function deleteCookie($name, CookieMetadata $metadata = null) { - // Remove the cookie - unset($_COOKIE[$name]); - $metadataArray = $this->scope->getCookieMetadata($metadata)->__toArray(); // explicitly set an expiration time in the metadataArray. @@ -284,5 +281,8 @@ class PhpCookieManager implements CookieManager // cookie value set to empty string to delete from the remote client $this->setCookie($name, '', $metadataArray); + + // Remove the cookie + unset($_COOKIE[$name]); } } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php index ef6089a3f6b..f8d146701ab 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php @@ -51,6 +51,16 @@ class PublicCookieMetadata extends CookieMetadata return $this->set(self::KEY_DURATION, $duration); } + /** + * Set the cookie duration to one year + * + * @return $this + */ + public function setDurationOneYear() + { + return $this->setDuration(3600 * 24 * 365); + } + /** * Get the number of seconds until the cookie expires * diff --git a/lib/internal/Magento/Framework/View/Element/Html/Date.php b/lib/internal/Magento/Framework/View/Element/Html/Date.php index aa0f083c9d6..f725e3f2dcd 100644 --- a/lib/internal/Magento/Framework/View/Element/Html/Date.php +++ b/lib/internal/Magento/Framework/View/Element/Html/Date.php @@ -41,9 +41,6 @@ class Date extends \Magento\Framework\View\Element\Template $calendarYearsRange = $this->getYearsRange(); $html .= '<script type="text/javascript"> require(["jquery", "mage/calendar"], function($){ - //<![CDATA[ - (function($) { - $(document).ready(function(){ $("#' . $this->getId() . '").calendar({ @@ -72,10 +69,7 @@ class Date extends \Magento\Framework\View\Element\Template ) . '" }) - }); }); - }); - //]]> </script>'; return $html; diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 9f523df43e0..d833446ad66 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,7 +2,7 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.1.0-alpha92", + "version": "0.1.0-alpha93", "require": { "php": "~5.4.11|~5.5.0", "ext-spl": "*", diff --git a/lib/web/app-config.js b/lib/web/app-config.js index 2b3bda7d3f6..d97b793ecad 100644 --- a/lib/web/app-config.js +++ b/lib/web/app-config.js @@ -46,7 +46,7 @@ require.config({ "jquery/hover-intent": "jquery/jquery.hoverIntent", "jquery/template": "jquery/jquery.tmpl.min", "jquery/farbtastic": "jquery/farbtastic/jquery.farbtastic", - "jquery/file-uploader": "jquery/fileUploader/jquery.fileupload-ui", + "jquery/file-uploader": "jquery/fileUploader/jquery.fileupload-fp", "handlebars": "jquery/handlebars/handlebars-v1.3.0", "jquery/jquery.hashchange": "jquery/jquery.ba-hashchange.min", "prototype": "prototype/prototype-amd", diff --git a/lib/web/css/source/lib/popups.less b/lib/web/css/source/lib/popups.less index e2647a2890f..a483ace643f 100644 --- a/lib/web/css/source/lib/popups.less +++ b/lib/web/css/source/lib/popups.less @@ -125,7 +125,7 @@ } .popup-actions { .action.close { - position: @_popup-button-close-position; + .css(position, @_popup-button-close-position); ._popup-button-close-icon( @_popup-button-close-icon, @_popup-icon-font-content, diff --git a/lib/web/jquery/fileUploader/jquery.fileupload.js b/lib/web/jquery/fileUploader/jquery.fileupload.js index f4813d16a10..8b73c9fbc45 100644 --- a/lib/web/jquery/fileUploader/jquery.fileupload.js +++ b/lib/web/jquery/fileUploader/jquery.fileupload.js @@ -18,7 +18,8 @@ // Register as an anonymous AMD module: define([ 'jquery', - 'jquery/ui' + 'jquery/ui', + 'jquery/fileUploader/jquery.iframe-transport' ], factory); } else { // Browser globals: diff --git a/lib/web/mage/backend/button.js b/lib/web/mage/backend/button.js index b5c82ccd8bb..7f056a48566 100644 --- a/lib/web/mage/backend/button.js +++ b/lib/web/mage/backend/button.js @@ -20,6 +20,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ +/*global require:true*/ (function (factory) { if (typeof define === 'function' && define.amd) { define([ @@ -32,13 +33,16 @@ }(function ($) { 'use strict'; + var resolver = require && require.resolver; + $.widget('ui.button', $.ui.button, { options: { - eventData: {} + eventData: {}, + waitTillResolved: true }, /** - * Button creation + * Button creation. * @protected */ _create: function() { @@ -50,15 +54,54 @@ }, /** - * Bind handler on button click + * Bind handler on button click. * @protected */ _bind: function() { + var waitTillResolved = this.options.waitTillResolved, + handler = !waitTillResolved || !resolver ? this._click : this._proxyClick; + this.element - .off('click.button') - .on('click.button', $.proxy(function() { - $(this.target).trigger(this.event, [this.eventData]); - }, this.options)); + .off( 'click.button' ) + .on( 'click.button', $.proxy(handler, this) ); + }, + + /** + * Button click handler. + * @protected + */ + _click: function(){ + var options = this.options; + + $(options.target).trigger(options.event, [options.eventData]); + }, + + /** + * Proxy button click handler that might postpone the event + * untill all of the rjs dependencies will be resolved. + * @protected + */ + _proxyClick: function(){ + var options = this.options; + + if( resolver.resolved ){ + this._click(); + } + else if( !resolver.hasListeners('spinnerCover') ){ + $('body').trigger('processStart'); + + resolver.on('spinnerCover', $.proxy(this._onResolve, this) ); + } + }, + + /** + * Callback of the rjs resolver 'onAllResolved' event. + * @protected + */ + _onResolve: function(){ + $('body').trigger('processStop'); + + this._click(); } }); })); diff --git a/lib/web/mage/backend/validation.js b/lib/web/mage/backend/validation.js index ae008f7aff7..e74ac419694 100644 --- a/lib/web/mage/backend/validation.js +++ b/lib/web/mage/backend/validation.js @@ -126,7 +126,8 @@ context: $('body'), success: $.proxy(this._onSuccess, this), error: $.proxy(this._onError, this), - showLoader: true + showLoader: true, + dontHide: true }); }, diff --git a/lib/web/mage/loader_old.js b/lib/web/mage/loader_old.js index dc53d813090..9468f881883 100644 --- a/lib/web/mage/loader_old.js +++ b/lib/web/mage/loader_old.js @@ -187,7 +187,7 @@ } }, _onAjaxComplete: function(e, jqxhr, settings) { - if (settings && settings.showLoader) { + if (settings && settings.showLoader && !settings.dontHide) { this._getJqueryObj(settings.loaderContext).trigger('processStop'); } } diff --git a/lib/web/mage/mage.js b/lib/web/mage/mage.js index dac3a1f72ec..2a87af8bbe2 100644 --- a/lib/web/mage/mage.js +++ b/lib/web/mage/mage.js @@ -79,13 +79,6 @@ }); }; - window.onerror = function (message) { - if ($.mage.isDevMode()) { - $('[data-container-for=messages]').append( - '<div class="messages"><div class="message error" data-role="js-error"><div>' + message + '</div></div></div>' - ); - } - }; /** * Storage of declared resources diff --git a/lib/web/mage/requirejs/resolver.js b/lib/web/mage/requirejs/resolver.js new file mode 100644 index 00000000000..497501f70a4 --- /dev/null +++ b/lib/web/mage/requirejs/resolver.js @@ -0,0 +1,130 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + /*global require:true*/ +(function(factory){ + if( require && define && define.amd ){ + factory( require ); + } +}(function(require){ + + var context = require.s.contexts._, + completeLoad = context.completeLoad, + registry = context.registry, + resolver, + listeners; + + listeners = {}; + + /** + * Method that triggers all of the attached 'onAllResolved' callbacks. + * @protected + */ + function trigger(){ + var namespace, + handlers, + hi, + hl; + + resolver.resolved = true; + + for( namespace in listeners ){ + handlers = listeners[ namespace ]; + hl = handlers.length; + + for( hi = 0; hi < hl; hi++ ){ + handlers[ hi ](); + } + + handlers.splice( 0, hl ); + } + + } + + resolver = { + + /** + * Checks wethre all of the current dependencies are resolved. + * returns {Boolean} + */ + isResolved: function(){ + return !Object.keys( registry ).length; + }, + + + /** + * Attaches event handler for the 'onAllResolved' event. + * @param {String} [namespace = _default] - Namespace of the handler. + * @param {Function} callback - Events' callback function. + */ + on: function( namespace, callback ){ + var handlers; + + if( arguments.length === 1 && typeof namespace === 'function' ){ + callback = namespace; + namespace = '_default'; + } + + if( this.isResolved() ){ + callback(); + } + else{ + handlers = listeners[namespace] = listeners[namespace] || []; + + handlers.push( callback ); + } + + return resolver; + }, + + /** + * Checks for the attached listeners. + * @praram {String} [namespace = _default] - Namespace of the handler. + * @return {Boolean} + */ + hasListeners: function( namespace ){ + var handlers; + + if( typeof namespace === 'undefined' ){ + namespace = '_default'; + } + + handlers = listeners[namespace]; + + return handlers && handlers.length; + } + }; + + + /** + * Inner requirejs's context method that fires whenever script has been loaded. + */ + context.completeLoad = function(){ + completeLoad.apply(context, arguments); + + if( resolver.isResolved() ){ + trigger(); + } + }; + + require.resolver = resolver; +})); diff --git a/pub/errors/404.php b/pub/errors/404.php index 1fa58c285e0..a301c545ce2 100644 --- a/pub/errors/404.php +++ b/pub/errors/404.php @@ -22,14 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; -require_once 'processor.php'; +require_once 'processorFactory.php'; -$processor = new \Magento\Framework\Error\Processor( - new \Magento\Framework\App\Response\Http( - new \Magento\Framework\Stdlib\Cookie(), - new \Magento\Framework\App\Http\Context() - ) -); +$processorFactory = new \Magento\Framework\Error\ProcessorFactory(); +$processor = $processorFactory->createProcessor(); $response = $processor->process404(); $response->sendResponse(); diff --git a/pub/errors/503.php b/pub/errors/503.php index d975494a64c..740f2508975 100644 --- a/pub/errors/503.php +++ b/pub/errors/503.php @@ -22,14 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; -require_once 'processor.php'; +require_once 'processorFactory.php'; -$processor = new \Magento\Framework\Error\Processor( - new \Magento\Framework\App\Response\Http( - new \Magento\Framework\Stdlib\Cookie(), - new \Magento\Framework\App\Http\Context() - ) -); +$processorFactory = new \Magento\Framework\Error\ProcessorFactory(); +$processor = $processorFactory->createProcessor(); $response = $processor->process503(); $response->sendResponse(); diff --git a/pub/errors/noCache.php b/pub/errors/noCache.php index 991353cad29..b0c2028dbb6 100644 --- a/pub/errors/noCache.php +++ b/pub/errors/noCache.php @@ -22,13 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once 'processor.php'; +require_once 'processorFactory.php'; -$processor = new \Magento\Framework\Error\Processor( - new \Magento\Framework\App\Response\Http( - new \Magento\Framework\Stdlib\Cookie(), - new \Magento\Framework\App\Http\Context() - ) -); +$processorFactory = new \Magento\Framework\Error\ProcessorFactory(); +$processor = $processorFactory->createProcessor(); $response = $processor->processNoCache(); $response->sendResponse(); diff --git a/pub/errors/processor.php b/pub/errors/processor.php index 8325828bf8c..a03bf221ac5 100644 --- a/pub/errors/processor.php +++ b/pub/errors/processor.php @@ -139,7 +139,7 @@ class Processor /** * Http response * - * @var Magento\Framework\App\Response\Http + * @var \Magento\Framework\App\Response\Http */ protected $_response; diff --git a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php b/pub/errors/processorFactory.php similarity index 64% rename from app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php rename to pub/errors/processorFactory.php index d02279df3f8..290fafb42d5 100644 --- a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php +++ b/pub/errors/processorFactory.php @@ -21,22 +21,26 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Sales\Service\V1; +namespace Magento\Framework\Error; -use Magento\Sales\Service\V1\Data\OrderStatusHistory; +require_once __DIR__ . '/../../app/bootstrap.php'; +require_once 'processor.php'; /** - * Interface OrderCommentsAddInterface - * @package Magento\Sales\Service\V1 + * Error processor factory */ -interface OrderStatusHistoryAddInterface +class ProcessorFactory { /** - * Invoke service + * Create Processor * - * @param int $id - * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory - * @return bool + * @return Processor */ - public function invoke($id, OrderStatusHistory $statusHistory); + public function createProcessor() + { + $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory(); + $locator = $locatorFactory->create(BP, $_SERVER); + $response = $locator->create('\Magento\Framework\App\Response\Http'); + return new Processor($response); + } } diff --git a/pub/errors/report.php b/pub/errors/report.php index fd18d192917..7ed45f7b4b8 100644 --- a/pub/errors/report.php +++ b/pub/errors/report.php @@ -22,15 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; -require_once 'processor.php'; +require_once 'processorFactory.php'; -$processor = new \Magento\Framework\Error\Processor( - new \Magento\Framework\App\Response\Http( - new \Magento\Framework\Stdlib\Cookie(), - new \Magento\Framework\App\Http\Context() - ) -); + +$processorFactory = new \Magento\Framework\Error\ProcessorFactory(); +$processor = $processorFactory->createProcessor(); if (isset($reportData) && is_array($reportData)) { $processor->saveReport($reportData); } -- GitLab