From 623d88f1771ca93cc139517a2fed12ecc9d97735 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Tue, 12 Aug 2014 09:08:14 -0700 Subject: [PATCH] 0.1.0-alpha90 * Service layer implementation: * Created the Admin Shopping Cart Service * Created the Create Shopping Cart Items Service * Created the Create Shopping Cart Shipping Address Service * Created the Create Shopping Cart Billing Address Service * Created the Service Layer for Orders * Created CRUD service & APIs to manage options for configurable products * Created CRUD service & APIs to manage options for bundle products * Fixed bugs: * Fixed an issue where adding a customer address with an invalid value of the custom address attribute caused a fatal error in SOAP * Fixed an issue where the wrong FedEx rates were displayed * Fixed an issue where the Bill Me Later option did not work in Payflow payment methods * Fixed an issue where order comments were broken for orders placed with Authorize.net * Fixed the naming of the My Account -> Recurring Payment page * Fixed a UI elements issue in the disabled Magento_PayPalRecurringPayment and Magento_RecurringPayment modules * Fixed an issue where it was impossible to save configuration of a configurable product when adding it to an order in the Admin panel * Fixed an issue where the Select a store page was displayed during admin order creation when the Single Store mode was enabled * Fixed an issue when an exception was thrown when attempting to open the Customer Account page if the Recently Viewed widget was configured for the store * Updated the content of the Privacy Policy page * Fixed an issue where it was possible to update a tax rate using the POST http method * Fixed an issue where it was impossible to update Inventory Qty for a SKU using API * Fixed a JavaScript syntax error on the Create New Customer page * Fixed an issue where it was impossible to add new sample while creating a downloadable product * Fixed a JavaScript which appeared when clicking the Add New Address button in the Address Book on the storefront * Fixed an issue where it was possible to update Tax Rules using the PUT http method which is supposed to be used for create operation only * Fixed an issue where it was possible to create a Tax Rule specifying a product tax class instead of a customer tax class and vice versa * Fixed an issue with making websiteId a mandatory field when updating a customer using REST * Fixed an issue where the default value was not applied after clicking the 'Use default' link for a product price field in the catalog in the Admin panel * Fixed an issue where the price update mass action could not be performed * Fixed a JS error in the cross-sells product settings in the Admin panel * Added the following functional tests: * Mass Delete Backend Customer * Moderate Product Review * Framework improvements: * Added the ability to access admin functionality using admin user login for mobile * Refactored and unified Access Control List (ACL) to make it more consistent * Created a Cookie Manager (a cookie management class) * Changes in functional tests: * Enabled the CustomerMetadataService tests for SOAP * Themes update: * Fixed issues in the Blank theme * Implemented improvements for the Blank theme, core templates and Storefront UI Library * Modularity: * Created the Notification library component and made it possible to disable the AdminNotification module * Made it possible to disable the SendToFriend module * Created an optional ConfigurableImportExport module to remove dependency between the CatalogImportExport and ConfigurableProduct modules * Created an optional GroupedImportExport module to remove dependency between the CatalogImportExport and GroupedProduct modules * Introduce search library: * Created a Search request configuration * Created a Query object structure from the XML declaration * Composer Integration: * Added support for using 3rd-party components as Composer packages --- .gitignore | 1 + CHANGELOG.md | 55 + README.md | 1 + app/autoload.php | 5 + app/bootstrap.php | 7 +- .../Block/Grid/Renderer/Severity.php | 18 +- .../Block/System/Messages.php | 8 +- .../System/Messages/UnreadMessagePopup.php | 4 +- .../Magento/AdminNotification/Model/Inbox.php | 32 +- .../Resource/Inbox/Collection/Critical.php | 2 +- .../Resource/System/Message/Collection.php | 8 +- .../Message/Collection/Synchronized.php | 6 +- .../Model/System/Message.php | 4 +- .../Model/System/Message/Baseurl.php | 2 +- .../Model/System/Message/CacheOutdated.php | 4 +- .../Message/Media/AbstractSynchronization.php | 4 +- .../Model/System/Message/Security.php | 4 +- .../Magento/AdminNotification/composer.json | 14 +- .../etc/{adminhtml => }/acl.xml | 2 +- .../AdminNotification/etc/adminhtml/di.xml | 3 +- app/code/Magento/AdminNotification/etc/di.xml | 34 + .../view/adminhtml/web/system/notification.js | 14 +- .../Authorization/Model/Acl/AclRetriever.php | 165 ++ .../Model/Acl/Loader/Role.php | 20 +- .../Model/Acl/Loader/Rule.php | 4 +- .../Model/Acl/Role/Generic.php | 4 +- .../Model/Acl/Role/Group.php | 4 +- .../Model/Acl/Role/User.php | 4 +- .../Model/CompositeUserContext.php | 129 + .../Model/Resource/Permissions/Collection.php | 4 +- .../Model/Resource/Role.php | 58 +- .../Model/Resource/Role/Collection.php | 6 +- .../Model/Resource/Role/Grid/Collection.php | 6 +- .../Model/Resource/Rules.php | 8 +- .../Model/Resource/Rules/Collection.php | 4 +- .../Model/Resource/Setup.php | 38 +- .../{User => Authorization}/Model/Role.php | 57 +- .../{User => Authorization}/Model/Rules.php | 27 +- .../Model/UserContextInterface.php} | 20 +- app/code/Magento/Authorization/composer.json | 20 + .../data-install-1.0.0.0.php} | 41 +- app/code/Magento/Authorization/etc/di.xml | 47 + .../di.xml => Authorization/etc/module.xml} | 9 +- .../authorization_setup/install-1.0.0.0.php | 171 ++ app/code/Magento/Authorizenet/Helper/Data.php | 68 +- .../Authorizenet/Model/Authorizenet.php | 4 +- .../Magento/Authorizenet/Model/Directpost.php | 12 +- app/code/Magento/Authorizenet/composer.json | 22 +- .../Magento/Authz/Model/UserIdentifier.php | 135 - .../Magento/Authz/Service/AuthorizationV1.php | 377 --- .../Service/AuthorizationV1Interface.php | 88 - app/code/Magento/Authz/composer.json | 21 - app/code/Magento/Authz/i18n/de_DE.csv | 5 - app/code/Magento/Authz/i18n/en_US.csv | 5 - app/code/Magento/Authz/i18n/es_ES.csv | 5 - app/code/Magento/Authz/i18n/fr_FR.csv | 5 - app/code/Magento/Authz/i18n/nl_NL.csv | 5 - app/code/Magento/Authz/i18n/pt_BR.csv | 5 - app/code/Magento/Authz/i18n/zh_CN.csv | 5 - .../Magento/Backend/Model/Auth/Session.php | 2 +- app/code/Magento/Backend/Model/Observer.php | 23 - app/code/Magento/Backend/composer.json | 49 +- .../Backend/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Backend/etc/module.xml | 1 - app/code/Magento/Backup/composer.json | 16 +- .../Backup/etc/{adminhtml => }/acl.xml | 2 +- .../Bundle/Model/Plugin/PriceBackend.php | 11 +- .../Bundle/Service/V1/Data/Product/Option.php | 104 + .../Service/V1/Data/Product/Option/Type.php | 56 + .../V1/Data/Product/Option/TypeBuilder.php | 54 + .../V1/Data/Product/Option/TypeConverter.php | 53 + .../Service/V1/Data/Product/OptionBuilder.php | 98 + .../V1/Data/Product/OptionConverter.php | 99 + .../Service/V1/Product/Link/WriteService.php | 2 +- .../Service/V1/Product/Option/ReadService.php | 113 + .../Product/Option/ReadServiceInterface.php | 48 + .../V1/Product/Option/Type/ReadService.php | 66 + .../Option/Type/ReadServiceInterface.php | 34 + .../V1/Product/Option/WriteService.php | 159 ++ .../Product/Option/WriteServiceInterface.php | 61 + app/code/Magento/Bundle/composer.json | 36 +- app/code/Magento/Bundle/etc/di.xml | 3 + app/code/Magento/Bundle/etc/webapi.xml | 36 + .../order/creditmemo/items/renderer.phtml | 6 +- .../sales/order/invoice/items/renderer.phtml | 6 +- .../sales/order/items/renderer.phtml | 10 +- .../sales/order/shipment/items/renderer.phtml | 6 +- app/code/Magento/Captcha/composer.json | 16 +- .../view/frontend/templates/default.phtml | 2 +- .../Adminhtml/Product/Edit/Tab/Crosssell.php | 16 +- .../Product/Edit/Tab/Options/Option.php | 28 +- .../Product/Edit/Tab/Options/Type/Select.php | 7 +- .../Adminhtml/Product/Edit/Tab/Upsell.php | 16 +- .../Block/Adminhtml/Product/Edit/Tabs.php | 19 +- .../Catalog/Block/Product/AbstractProduct.php | 30 - .../Product/Initialization/Helper.php | 33 +- .../Magento/Catalog/Model/Product/Link.php | 8 +- .../Option/Validator/DefaultValidator.php | 28 +- .../Model/Product/Option/Validator/Select.php | 35 +- .../Product/Link/Product/Collection.php | 34 +- .../Catalog/Model/Resource/Product/Option.php | 146 +- .../Model/Resource/Product/Option/Value.php | 144 +- .../V1/Category/ProductLinks/ReadService.php | 5 +- .../ProductLinks/ReadServiceInterface.php | 2 +- .../V1/Category/ProductLinks/WriteService.php | 2 +- .../ProductLinks/WriteServiceInterface.php | 6 +- .../Service/V1/Category/WriteService.php | 12 +- .../V1/Category/WriteServiceInterface.php | 3 +- .../Data/{Eav => }/Category/ProductLink.php | 2 +- .../{Eav => }/Category/ProductLinkBuilder.php | 2 +- .../Catalog/Service/V1/Data/Category/Tree.php | 1 + .../Service/V1/Data/Eav/Category/Tree.php | 11 + .../V1/Data/Eav/Category/TreeBuilder.php | 11 + app/code/Magento/Catalog/composer.json | 52 +- .../Catalog/etc/{adminhtml => }/acl.xml | 2 +- .../catalog/product/edit/options/option.phtml | 6 +- .../product/edit/options/type/select.phtml | 5 +- .../templates/product/compare/list.phtml | 12 +- .../templates/product/list/toolbar.phtml | 22 +- .../frontend/templates/product/listing.phtml | 2 +- .../templates/product/view/details.phtml | 2 +- .../Model/Export/Product.php | 5 +- .../Magento/CatalogImportExport/composer.json | 24 +- .../Magento/CatalogImportExport/etc/di.xml | 7 - .../CatalogImportExport/etc/export.xml | 2 - .../CatalogImportExport/etc/import.xml | 2 - .../CatalogImportExport/etc/module.xml | 2 - .../Service/V1/Data/StockItemDetails.php | 28 +- .../Magento/CatalogInventory/composer.json | 22 +- .../etc/{adminhtml => }/acl.xml | 2 +- .../Magento/CatalogInventory/etc/webapi.xml | 4 +- app/code/Magento/CatalogRule/composer.json | 20 +- .../CatalogRule/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/CatalogSearch/composer.json | 24 +- .../CatalogSearch/etc/{adminhtml => }/acl.xml | 2 +- .../view/frontend/templates/form.mini.phtml | 8 +- .../Magento/CatalogUrlRewrite/composer.json | 14 +- app/code/Magento/Centinel/composer.json | 16 +- .../Magento/Checkout/Model/Type/Onepage.php | 13 +- .../V1/Address/Billing/ReadService.php | 72 + .../Address/Billing/ReadServiceInterface.php | 38 + .../V1/Address/Billing/WriteService.php | 115 + .../Address/Billing/WriteServiceInterface.php | 40 + .../Checkout/Service/V1/Address/Converter.php | 111 + .../V1/Address/Shipping/ReadService.php | 81 + .../Address/Shipping/ReadServiceInterface.php | 38 + .../V1/Address/Shipping/WriteService.php | 117 + .../Shipping/WriteServiceInterface.php | 40 + .../Checkout/Service/V1/Address/Validator.php | 93 + .../Checkout/Service/V1/Cart/ReadService.php | 278 ++ .../Service/V1/Cart/ReadServiceInterface.php | 46 + .../Checkout/Service/V1/Cart/WriteService.php | 108 + .../Service/V1/Cart/WriteServiceInterface.php | 44 + .../Magento/Checkout/Service/V1/Data/Cart.php | 252 ++ .../Checkout/Service/V1/Data/Cart/Address.php | 241 ++ .../Service/V1/Data/Cart/Address/Region.php | 71 + .../V1/Data/Cart/Address/RegionBuilder.php | 68 + .../Service/V1/Data/Cart/AddressBuilder.php | 296 +++ .../Service/V1/Data/Cart/Currency.php | 128 + .../Service/V1/Data/Cart/CurrencyBuilder.php | 120 + .../Service/V1/Data/Cart/Customer.php | 213 ++ .../Service/V1/Data/Cart/CustomerBuilder.php | 197 ++ .../Checkout/Service/V1/Data/Cart/Item.php | 60 +- .../Service/V1/Data/Cart/ItemBuilder.php | 81 + .../Checkout/Service/V1/Data/Cart/Totals.php | 104 + .../Service/V1/Data/Cart/TotalsBuilder.php | 98 + .../Checkout/Service/V1/Data/CartBuilder.php | 228 ++ .../Service/V1/Data/CartSearchResults.php | 37 + .../V1/Data/CartSearchResultsBuilder.php | 55 + .../Checkout/Service/V1/Item/ReadService.php | 87 + .../Service/V1/Item/ReadServiceInterface.php | 34 + .../Checkout/Service/V1/Item/WriteService.php | 144 ++ .../Service/V1/Item/WriteServiceInterface.php | 57 + .../Checkout/Service/V1/QuoteLoader.php | 59 + app/code/Magento/Checkout/composer.json | 36 +- app/code/Magento/Checkout/etc/di.xml | 8 + app/code/Magento/Checkout/etc/webapi.xml | 100 + .../frontend/templates/cart/minicart.phtml | 2 +- .../frontend/templates/onepage/billing.phtml | 2 +- .../frontend/templates/onepage/payment.phtml | 2 +- .../templates/onepage/review/item.phtml | 8 +- .../frontend/web/js/opc-checkout-method.js | 5 +- .../Magento/CheckoutAgreements/composer.json | 12 +- .../etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Cms/composer.json | 22 +- .../data-upgrade-1.6.0.0.0-1.6.0.0.1.php | 8 - .../Magento/Cms/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/CmsUrlRewrite/composer.json | 10 +- .../Export/Product/Type/Configurable.php | 2 +- .../Model/Export/RowCustomizer.php | 4 +- .../Import/Product/Type/Configurable.php | 4 +- .../ConfigurableImportExport/composer.json | 23 + .../ConfigurableImportExport/etc/di.xml | 34 + .../ConfigurableImportExport/etc/export.xml | 28 + .../ConfigurableImportExport/etc/import.xml | 28 + .../etc/module.xml | 13 +- .../Model/Product/Type/Configurable.php | 32 +- .../Product/Type/Configurable/Attribute.php | 2 + .../Product/Type/Configurable/Attribute.php | 72 + .../{ConfigurableAttribute.php => Option.php} | 33 +- .../Value.php | 15 +- .../ValueBuilder.php | 6 +- .../Service/V1/Data/Option/ValueConverter.php | 40 + ...AttributeBuilder.php => OptionBuilder.php} | 46 +- .../Service/V1/Data/OptionConverter.php | 152 ++ .../Service/V1/Product/Option/ReadService.php | 144 ++ .../Product/Option/ReadServiceInterface.php | 58 + .../V1/Product/Option/WriteService.php | 202 ++ .../Product/Option/WriteServiceInterface.php | 61 + .../Service/V1/ReadService.php | 18 +- .../Service/V1/ReadServiceInterface.php | 4 +- .../Magento/ConfigurableProduct/composer.json | 34 +- .../Magento/ConfigurableProduct/etc/di.xml | 3 + .../ConfigurableProduct/etc/webapi.xml | 36 + app/code/Magento/Contact/composer.json | 14 +- .../Contact/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Core/composer.json | 18 +- .../data-upgrade-1.6.0.4-1.6.0.5.php | 2 +- app/code/Magento/Cron/composer.json | 10 +- app/code/Magento/CurrencySymbol/composer.json | 16 +- .../etc/{adminhtml => }/acl.xml | 2 +- .../CustomerSessionUserContext.php | 66 + .../Model/Plugin/CustomerAuthorization.php | 79 + .../Customer/Model/Resource/Address.php | 9 +- .../Customer/Model/Resource/Customer.php | 9 +- app/code/Magento/Customer/Model/Session.php | 5 +- .../Service/V1/CustomerAccountService.php | 6 +- .../Service/V1/CustomerMetadataService.php | 3 +- .../Service/V1/Data/Eav/AttributeMetadata.php | 8 +- .../V1/Data/Eav/AttributeMetadataBuilder.php | 4 +- app/code/Magento/Customer/composer.json | 40 +- .../Customer/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Customer/etc/di.xml | 2 +- app/code/Magento/Customer/etc/module.xml | 2 + app/code/Magento/Customer/etc/webapi.xml | 2 +- .../Magento/Customer/etc/webapi_rest/di.xml | 45 + .../etc/webapi_soap}/di.xml | 4 +- .../frontend/templates/account/customer.phtml | 4 +- .../Customer/view/frontend/web/address.js | 7 +- .../CustomerImportExport/composer.json | 20 +- app/code/Magento/DesignEditor/composer.json | 18 +- .../DesignEditor/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Dhl/composer.json | 24 +- app/code/Magento/Directory/composer.json | 12 +- .../view/frontend/templates/currency.phtml | 19 +- app/code/Magento/Downloadable/composer.json | 36 +- .../Downloadable/etc/{adminhtml => }/acl.xml | 2 +- .../product/edit/downloadable/samples.phtml | 8 + .../templates/customer/products/list.phtml | 5 - app/code/Magento/Eav/composer.json | 14 +- app/code/Magento/Email/composer.json | 16 +- .../Magento/Email/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Fedex/Model/Carrier.php | 19 +- app/code/Magento/Fedex/composer.json | 20 +- app/code/Magento/GiftMessage/composer.json | 24 +- app/code/Magento/GoogleAdwords/composer.json | 10 +- .../Magento/GoogleAnalytics/composer.json | 10 +- .../etc/{adminhtml => }/acl.xml | 2 +- .../Magento/GoogleOptimizer/composer.json | 16 +- .../Adminhtml/Googleshopping/Items.php | 17 + .../Googleshopping/Items/MassAdd.php | 3 +- .../Googleshopping/Items/Refresh.php | 4 +- .../GoogleShopping/Model/MassOperations.php | 38 +- .../Magento/GoogleShopping/Model/Observer.php | 21 +- app/code/Magento/GoogleShopping/composer.json | 25 +- .../etc/{adminhtml => }/acl.xml | 2 +- .../Magento/GoogleShopping/etc/module.xml | 1 - .../Model/Export/Product/Type/Grouped.php | 30 + .../Model/Export/RowCustomizer.php | 69 + .../Model/Import/Product/Type/Grouped.php | 4 +- .../Magento/GroupedImportExport/composer.json | 23 + .../Magento/GroupedImportExport/etc/di.xml | 34 + .../GroupedImportExport/etc/export.xml | 28 + .../GroupedImportExport/etc/import.xml | 28 + .../GroupedImportExport/etc/module.xml | 36 + app/code/Magento/GroupedProduct/composer.json | 28 +- app/code/Magento/ImportExport/composer.json | 16 +- .../ImportExport/etc/{adminhtml => }/acl.xml | 2 +- .../Model/System/Message/IndexOutdated.php | 4 +- app/code/Magento/Index/composer.json | 11 +- .../Magento/Index/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Index/etc/adminhtml/di.xml | 2 +- app/code/Magento/Index/etc/module.xml | 1 - app/code/Magento/Indexer/composer.json | 10 +- .../Indexer/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Install/Block/End.php | 8 +- .../Controller/Adminhtml/Survey.php | 4 +- .../Controller/Adminhtml/Survey/Index.php | 6 +- .../Magento/Install/Controller/Wizard/End.php | 2 +- .../Model/Survey.php | 8 +- .../Model/System/Message/Survey.php | 14 +- app/code/Magento/Install/composer.json | 17 +- .../Magento/Install/etc/adminhtml/routes.xml | 32 + app/code/Magento/Install/etc/di.xml | 7 + app/code/Magento/Install/etc/module.xml | 1 - .../Install/view/adminhtml/layout/default.xml | 34 + .../view/adminhtml/web/survey_notification.js | 41 + .../Block/Adminhtml/Integration/Tokens.php | 6 +- .../Adminhtml/Integration/TokensExchange.php | 2 +- .../Magento/Integration/Model/Integration.php | 14 + .../Magento/Integration/Model/Oauth/Token.php | 164 +- .../Model/Oauth/Token/Provider.php | 37 +- .../Model/Resource/Integration.php | 17 + .../Model/Resource/Oauth/Token.php | 64 +- .../Service/V1/AuthorizationService.php | 214 ++ .../V1/AuthorizationServiceInterface.php | 68 + .../Integration/Service/V1/Integration.php | 9 + .../Service/V1/IntegrationInterface.php | 8 + .../Magento/Integration/Service/V1/Oauth.php | 12 +- .../Integration/Service/V1/OauthInterface.php | 6 +- .../Integration/Service/V1/TokenService.php | 132 + .../Service/V1/TokenServiceInterface.php | 58 + app/code/Magento/Integration/composer.json | 18 +- app/code/Magento/Integration/etc/di.xml | 2 + app/code/Magento/Integration/etc/module.xml | 5 +- app/code/Magento/Integration/etc/webapi.xml | 40 + .../upgrade-1.0.0.2-1.0.0.3.php | 68 + .../Magento/LayeredNavigation/composer.json | 10 +- .../view/frontend/layout/page_one_column.xml | 2 +- .../view/frontend/templates/layer/state.phtml | 4 +- .../view/frontend/templates/layer/view.phtml | 18 +- app/code/Magento/Log/composer.json | 18 +- .../Model/Checkout/Type/Multishipping.php | 11 +- app/code/Magento/Multishipping/composer.json | 24 +- .../Multishipping/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Newsletter/composer.json | 26 +- .../Newsletter/etc/{adminhtml => }/acl.xml | 2 +- .../Magento/OfflinePayments/composer.json | 8 +- .../Magento/OfflineShipping/composer.json | 22 +- app/code/Magento/Ogone/Controller/Api.php | 17 +- app/code/Magento/Ogone/composer.json | 14 +- app/code/Magento/PageCache/composer.json | 10 +- .../PayPalRecurringPayment/Model/Ipn.php | 13 +- .../PayPalRecurringPayment/composer.json | 17 +- .../PayPalRecurringPayment/etc/module.xml | 1 + app/code/Magento/Payment/composer.json | 16 +- .../Payment/etc/{adminhtml => }/acl.xml | 2 +- .../Magento/Paypal/Model/Express/Checkout.php | 11 +- app/code/Magento/Paypal/Model/Ipn.php | 25 +- app/code/Magento/Paypal/Model/Payflowlink.php | 12 +- app/code/Magento/Paypal/composer.json | 32 +- .../Paypal/etc/{adminhtml => }/acl.xml | 2 +- .../Magento/Paypal/etc/adminhtml/system.xml | 2 +- app/code/Magento/Persistent/composer.json | 18 +- .../Persistent/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/ProductAlert/composer.json | 16 +- .../Controller/RecurringPayment.php | 6 +- .../RecurringPayment/Model/Plugin/Tabs.php | 60 + .../Magento/RecurringPayment/composer.json | 26 +- .../data-install-1.0.0.0.php | 2 +- .../etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/RecurringPayment/etc/di.xml | 4 +- .../product/view/payment/schedule.phtml | 6 +- .../frontend/templates/recurring/grid.phtml | 3 - app/code/Magento/Reports/composer.json | 38 +- .../Reports/etc/{adminhtml => }/acl.xml | 2 +- .../product/widget/viewed/item.phtml | 9 +- .../column/compared_default_list.phtml | 9 +- .../compared/content/compared_grid.phtml | 9 +- .../compared/content/compared_list.phtml | 9 +- .../viewed/column/viewed_default_list.phtml | 15 +- .../widget/viewed/content/viewed_grid.phtml | 9 +- .../widget/viewed/content/viewed_list.phtml | 9 +- app/code/Magento/RequireJs/composer.json | 8 +- app/code/Magento/Review/composer.json | 24 +- .../Review/etc/{adminhtml => }/acl.xml | 2 +- .../frontend/templates/customer/list.phtml | 5 - app/code/Magento/Rss/composer.json | 28 +- .../Magento/Rss/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Rule/composer.json | 14 +- .../Creditmemo/AbstractCreditmemo/Email.php | 8 +- .../Invoice/AbstractInvoice/Email.php | 48 +- .../Controller/Adminhtml/Order/AddComment.php | 7 +- .../Adminhtml/Order/Creditmemo/AddComment.php | 14 +- .../Adminhtml/Order/Creditmemo/Save.php | 14 +- .../Controller/Adminhtml/Order/Email.php | 7 +- .../Adminhtml/Order/Invoice/AddComment.php | 16 +- .../Adminhtml/Order/Invoice/Save.php | 26 +- app/code/Magento/Sales/Helper/Data.php | 16 +- .../Magento/Sales/Model/AdminOrder/Create.php | 15 +- .../Sales/Model/AdminOrder/EmailSender.php | 16 +- app/code/Magento/Sales/Model/Notifier.php | 96 + app/code/Magento/Sales/Model/Order.php | 301 +-- .../Sales/Model/Order/Address/Validator.php | 70 + .../Magento/Sales/Model/Order/Creditmemo.php | 309 --- .../Model/Order/Email/Container/Container.php | 152 ++ .../Container/CreditmemoCommentIdentity.php | 90 + .../Email/Container/CreditmemoIdentity.php | 90 + .../Email/Container/IdentityInterface.php | 92 + .../Container/InvoiceCommentIdentity.php | 91 + .../Order/Email/Container/InvoiceIdentity.php | 90 + .../Email/Container/OrderCommentIdentity.php | 91 + .../Order/Email/Container/OrderIdentity.php | 103 + .../Container/ShipmentCommentIdentity.php | 90 + .../Email/Container/ShipmentIdentity.php | 106 + .../Model/Order/Email/Container/Template.php | 110 + .../Sales/Model/Order/Email/NotifySender.php | 57 + .../Sales/Model/Order/Email/Sender.php | 127 + .../Email/Sender/CreditmemoCommentSender.php | 70 + .../Order/Email/Sender/CreditmemoSender.php | 108 + .../Email/Sender/InvoiceCommentSender.php | 69 + .../Order/Email/Sender/InvoiceSender.php | 107 + .../Order/Email/Sender/OrderCommentSender.php | 66 + .../Model/Order/Email/Sender/OrderSender.php | 112 + .../Email/Sender/ShipmentCommentSender.php | 69 + .../Order/Email/Sender/ShipmentSender.php | 107 + .../Sales/Model/Order/Email/SenderBuilder.php | 122 + .../Magento/Sales/Model/Order/Invoice.php | 310 --- .../Magento/Sales/Model/Order/Shipment.php | 302 --- .../Model/Order/Status/History/Validator.php | 53 + .../Magento/Sales/Model/Quote/Address.php | 30 +- .../Sales/Model/Quote/Address/Validator.php | 76 + .../Sales/Model/Resource/Order/Address.php | 30 +- .../Model/Resource/Order/Status/History.php | 44 + .../Magento/Sales/Service/V1/Data/Comment.php | 99 + .../Sales/Service/V1/Data/Creditmemo.php | 753 ++++++ .../Service/V1/Data/CreditmemoComment.php | 122 + .../Sales/Service/V1/Data/CreditmemoItem.php | 527 ++++ .../Magento/Sales/Service/V1/Data/Invoice.php | 539 ++++ .../Sales/Service/V1/Data/InvoiceItem.php | 392 +++ .../Magento/Sales/Service/V1/Data/Order.php | 1542 ++++++++++++ .../Sales/Service/V1/Data/OrderAddress.php | 422 ++++ .../Sales/Service/V1/Data/OrderItem.php | 1167 +++++++++ .../Sales/Service/V1/Data/OrderMapper.php | 144 ++ .../Sales/Service/V1/Data/OrderPayment.php | 842 +++++++ .../Service/V1/Data/OrderStatusHistory.php | 121 + .../Sales/Service/V1/Data/Shipment.php | 257 ++ .../Sales/Service/V1/Data/ShipmentItem.php | 213 ++ .../Sales/Service/V1/Data/ShipmentTrack.php | 198 ++ .../Sales/Service/V1/OrderAddressUpdate.php | 59 + .../V1/OrderAddressUpdateInterface.php | 40 + .../Magento/Sales/Service/V1/OrderCancel.php | 58 + .../Sales/Service/V1/OrderCancelInterface.php | 39 + .../Sales/Service/V1/OrderCommentsList.php | 104 + .../Service/V1/OrderCommentsListInterface.php | 38 + .../Magento/Sales/Service/V1/OrderGet.php | 68 + .../Sales/Service/V1/OrderGetInterface.php | 39 + .../Sales/Service/V1/OrderGetStatus.php | 35 +- .../Service/V1/OrderGetStatusInterface.php | 40 + .../Magento/Sales/Service/V1/OrderHold.php | 57 + .../Sales/Service/V1/OrderHoldInterface.php | 39 + .../Magento/Sales/Service/V1/OrderList.php | 83 + .../Sales/Service/V1/OrderListInterface.php | 40 + .../Service/V1/OrderNotifyUser.php} | 47 +- .../Service/V1/OrderNotifyUserInterface.php | 38 + .../Service/V1/OrderStatusHistoryAdd.php | 72 + .../V1/OrderStatusHistoryAddInterface.php | 42 + .../Magento/Sales/Service/V1/OrderUnHold.php | 57 + .../Sales/Service/V1/OrderUnHoldInterface.php | 39 + app/code/Magento/Sales/composer.json | 46 +- .../Magento/Sales/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Sales/etc/di.xml | 12 +- app/code/Magento/Sales/etc/webapi.xml | 88 + .../templates/order/create/form.phtml | 3 +- .../view/adminhtml/web/order/create/form.js | 2 +- .../frontend/templates/order/history.phtml | 3 - app/code/Magento/SalesRule/composer.json | 38 +- .../SalesRule/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Sendfriend/composer.json | 16 +- .../Adminhtml/Order/Shipment/AddComment.php | 14 +- .../Adminhtml/Order/Shipment/Email.php | 15 +- .../Adminhtml/Order/Shipment/Save.php | 13 +- app/code/Magento/Shipping/composer.json | 28 +- .../Shipping/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Sitemap/composer.json | 18 +- .../Sitemap/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Store/composer.json | 12 +- .../frontend/templates/switch/languages.phtml | 21 +- .../Model/System/Message/Notifications.php | 6 +- .../V1/Data/TaxClassSearchResultsBuilder.php | 6 +- .../V1/Data/TaxRateSearchResultsBuilder.php | 6 +- .../Magento/Tax/Service/V1/TaxRateService.php | 5 + .../Magento/Tax/Service/V1/TaxRuleService.php | 61 +- app/code/Magento/Tax/composer.json | 33 +- .../Magento/Tax/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Tax/etc/adminhtml/di.xml | 4 +- app/code/Magento/Tax/etc/module.xml | 1 - .../sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php | 2 +- .../sql/tax_setup/upgrade-1.6.0.5-1.6.0.6.php | 2 +- app/code/Magento/Theme/composer.json | 18 +- .../Magento/Theme/etc/{adminhtml => }/acl.xml | 2 +- .../view/frontend/templates/html/block.phtml | 4 +- .../frontend/templates/html/collapsible.phtml | 33 + .../frontend/templates/html/container.phtml | 25 + .../view/frontend/templates/html/header.phtml | 2 +- .../frontend/templates/html/sections.phtml | 53 + app/code/Magento/Translation/composer.json | 12 +- app/code/Magento/Ups/composer.json | 20 +- app/code/Magento/UrlRedirect/composer.json | 18 +- .../UrlRedirect/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/UrlRewrite/composer.json | 12 +- .../Magento/User/Block/Role/Grid/User.php | 16 +- app/code/Magento/User/Block/Role/Tab/Edit.php | 32 +- .../User/Block/User/Edit/Tab/Roles.php | 6 +- .../User/Controller/Adminhtml/User/Role.php | 16 +- .../Adminhtml/User/Role/SaveRole.php | 14 +- .../AdminSessionUserContext.php} | 14 +- .../Model/Plugin/AuthorizationRole.php} | 39 +- app/code/Magento/User/Model/Resource/User.php | 59 +- app/code/Magento/User/Model/User.php | 17 +- app/code/Magento/User/composer.json | 48 +- .../data-upgrade-1.6.1.1-1.6.1.2.php | 241 -- .../Magento/User/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/User/etc/di.xml | 16 +- app/code/Magento/User/etc/module.xml | 32 +- app/code/Magento/User/etc/webapi_rest/di.xml | 37 + .../User/sql/user_setup/install-1.6.0.0.php | 126 - .../user_setup/upgrade-1.6.1.0-1.6.1.1.php | 2 - .../user_setup/upgrade-1.6.1.2-1.6.1.3.php | 49 - .../layout/adminhtml_user_role_grid_block.xml | 2 +- app/code/Magento/Usps/composer.json | 20 +- .../Adminhtml/Integration/Edit/Tab/Webapi.php | 6 +- .../Magento/Webapi/Controller/Login/Index.php | 129 - .../Magento/Webapi/Controller/Request.php | 21 - app/code/Magento/Webapi/Controller/Rest.php | 113 +- app/code/Magento/Webapi/Controller/Soap.php | 10 - .../Controller/Soap/Request/Handler.php | 16 +- .../Model/Authorization/GuestUserContext.php} | 12 +- .../Model/Authorization/OauthUserContext.php | 112 + .../Model/Authorization/TokenUserContext.php | 169 ++ .../Webapi/Model/Authz/UserLocator.php | 71 - .../Model/Plugin/AuthorizationServiceV1.php | 100 - .../Model/Plugin/GuestAuthorization.php | 59 + .../V1/Integration.php} | 72 +- .../Magento/Webapi/Model/Plugin/Setup.php | 33 +- .../Webapi/Model/WebapiRoleLocator.php | 76 + app/code/Magento/Webapi/composer.json | 19 +- app/code/Magento/Webapi/etc/di.xml | 2 +- app/code/Magento/Webapi/etc/module.xml | 5 +- app/code/Magento/Webapi/etc/webapi.xsd | 2 - .../Magento/Webapi/etc/webapi_rest/di.xml | 38 +- .../Magento/Webapi/etc/webapi_soap/di.xml | 28 +- .../Magento/Weee/Block/Sales/Order/Totals.php | 10 +- app/code/Magento/Weee/composer.json | 26 +- app/code/Magento/Widget/composer.json | 18 +- .../Widget/etc/{adminhtml => }/acl.xml | 2 +- app/code/Magento/Wishlist/composer.json | 34 +- .../Wishlist/etc/{adminhtml => }/acl.xml | 2 +- .../wishlist_index_configure_type_bundle.xml | 2 +- .../view/frontend/web/js/add-to-wishlist.js | 5 +- .../Magento_Theme/web/css/source/module.less | 3 + .../adminhtml/Magento/backend/composer.json | 6 +- .../adminhtml/Magento/backend/theme.xml | 2 +- .../Magento/backend/web/css/source/theme.less | 10 +- .../Magento_Bundle/web/css/source/module.less | 5 +- .../layout/catalog_product_view.xml | 1 + .../web/css/source/module.less | 283 +-- .../web/css/source/toolbar.less | 161 ++ .../web/css/source/widgets.less | 2 +- .../web/css/source/module.less | 21 +- .../Magento_Checkout/web/css/source/cart.less | 32 +- .../web/css/source/minicart.less | 37 +- .../web/css/source/module.less | 120 +- .../layout/customer_account.xml | 64 + .../web/css/source/module.less | 131 +- .../web/css/source/module.less | 27 +- .../web/css/source/module.less | 2 +- .../web/css/source/module.less | 2 +- .../Magento_Paypal/web/css/source/module.less | 13 +- .../web/css/source/module.less | 30 + .../Magento_Review/web/css/source/module.less | 169 +- .../Magento_Sales/web/css/source/module.less | 108 +- .../web/css/source/module.less | 3 +- .../blank/Magento_Theme/layout/default.xml | 40 +- .../Magento_Theme/web/css/source/module.less | 13 +- .../web/css/source/module.less | 14 +- .../frontend/Magento/blank/composer.json | 6 +- app/design/frontend/Magento/blank/theme.xml | 2 +- .../blank/web/css/source/abstract.less | 50 +- .../blank/web/css/source/actions-toolbar.less | 2 +- .../Magento/blank/web/css/source/forms.less | 16 +- .../Magento/blank/web/css/source/layout.less | 53 +- .../blank/web/css/source/navigation.less | 334 +-- .../blank/web/css/source/sections.less | 7 +- .../Magento/blank/web/css/source/tables.less | 16 +- .../blank/web/css/source/typography.less | 2 +- .../Magento/blank/web/js/navigation-menu.js | 3 +- .../frontend/Magento/blank/web/js/theme.js | 3 + .../frontend/Magento/plushe/composer.json | 8 +- app/design/frontend/Magento/plushe/theme.xml | 2 +- app/design/install/Magento/basic/theme.xml | 2 +- app/etc/di.xml | 22 + app/etc/vendor_path.php | 28 + 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 | 183 +- .../Backend/Test/Block/Widget/Grid.php | 2 +- .../Test/Page/Product/CatalogProductView.php | 17 +- .../Catalog/Test/Block/Product/View.php | 37 +- .../AssertProductCompareItemsLinkIsAbsent.php | 2 +- .../Fixture/CatalogProductSimple/TaxClass.php | 74 +- .../Test/Handler/CatalogAttributeSet/Curl.php | 17 +- .../Handler/CatalogProductSimple/Curl.php | 9 +- .../Test/Repository/CatalogProductSimple.php | 5 + .../CreateCategoryEntityTest/test.csv | 2 +- .../CreateProductAttributeEntityTest.php | 3 +- .../AssertAdvancedSearchProductsResult.php | 3 - .../AdvancedSearchEntityTest/testSearch.csv | 27 +- .../app/Magento/Checkout/Test/Block/Cart.php | 6 +- .../Checkout/Test/Page/CheckoutCart.php | 3 - .../Magento/Cms/Test/Handler/CmsPage/Curl.php | 2 +- .../System/Variable/FormPageActions.php | 15 +- .../UpdateCustomVariableEntityTest.php | 4 +- .../Test/Block/Account/Dashboard/Address.php | 4 +- .../Test/Block/Account/Dashboard/Info.php | 2 +- .../AssertCustomerDefaultAddresses.php | 11 +- .../AssertCustomerGroupOnCustomerForm.php | 2 +- .../AssertCustomerMassDeleteInGrid.php | 74 + .../AssertCustomerMassDeleteNotInGrid.php | 73 + ...AssertCustomerMassDeleteSuccessMessage.php | 73 + .../Constraint/AssertCustomerNotInGrid.php | 19 +- .../Test/Fixture/AddressInjectable.php | 13 + .../Test/Fixture/CustomerInjectable.php | 12 + .../Test/Fixture/CustomerInjectable.xml | 6 + .../Fixture/CustomerInjectable/Address.php | 126 + .../Fixture/CustomerInjectable/GroupId.php | 124 + .../Test/Handler/CustomerInjectable/Curl.php | 138 +- .../Test/Repository/AddressInjectable.php | 61 +- .../Test/Repository/CustomerInjectable.php | 15 +- .../testCreateCustomerBackendEntity.csv | 2 +- .../testCreateCustomerGroup.csv | 2 +- .../DeleteCustomerBackendEntityTest.php | 10 +- .../MassDeleteCustomerBackendEntityTest.php | 131 + .../test.csv | 2 + .../testUpdateCustomerBackendEntity.csv | 2 +- .../Customer/Test/etc/global/constraint.xml | 12 + .../Review/Test/Block/Product/View.php | 64 +- .../AssertProductReviewNotOnProductPage.php | 76 + .../AssertProductReviewOnProductPage.php | 88 + .../Test/Handler/ReviewInjectable/Curl.php | 52 +- .../Test/Repository/ReviewInjectable.php | 12 +- .../ModerateProductReviewEntityTest.php | 99 + .../ModerateProductReviewEntityTest/test.csv | 3 + .../Review/Test/TestCase/ReviewTest.php | 17 +- .../Review/Test/etc/global/constraint.xml | 6 + .../app/Magento/Store/Test/Block/Switcher.php | 2 +- .../Test/Block/Adminhtml/Rule/Edit/Form.php | 29 +- .../Test/Block/Adminhtml/Rule/Edit/Form.xml | 6 +- .../Tax/Test/Constraint/AssertTaxRateForm.php | 1 - .../Constraint/AssertTaxRuleIsApplied.php | 1 + .../testUpdateTaxRate.csv | 2 +- .../Test/TestCase/UpdateTaxRuleEntityTest.php | 15 +- .../app/Magento/Theme/Test/Block/Links.php | 11 +- .../Test/Handler/UrlRewrite/Curl.php | 5 +- .../UrlRewrite/Test/Repository/UrlRewrite.php | 6 + .../CreateCustomUrlRewriteEntityTest.php | 2 +- .../testDeleteProductUrlRewrite.csv | 2 +- .../User/Test/Fixture/AdminUserRole.xml | 2 +- .../TestCase/CreateAdminUserEntityTest.php | 2 +- .../Magento/User/Test/etc/global/fixture.xml | 2 +- .../Wishlist/Test/Page/WishlistIndex.php | 52 + .../Wishlist/Test/Page/WishlistIndex.xml | 33 + .../Magento/Wishlist/Test/etc/global/page.xml | 31 + .../Magento/TestFramework/Application.php | 14 +- .../_files/notifications.php | 20 +- .../Model/Resource/Role/CollectionTest.php | 9 +- .../Resource/Role/Grid/CollectionTest.php | 8 +- .../Model/Resource/RoleTest.php | 6 +- .../Model/Resource/Rules/CollectionTest.php | 6 +- .../Model/RoleTest.php | 15 +- .../Model/RulesTest.php | 8 +- .../Authz/Service/AuthorizationV1Test.php | 236 -- .../Magento/Bundle/_files/product.php | 13 +- .../Product/Link/Product/CollectionTest.php | 78 + .../Model/Resource/Product/OptionTest.php | 214 ++ .../Checkout/Model/Type/OnepageTest.php | 3 +- .../Checkout/_files/quote_with_address.php | 6 +- .../quote_with_address_saved_rollback.php | 30 + ...quote_with_virtual_product_and_address.php | 65 + ...h_virtual_product_and_address_rollback.php | 29 + .../Controller/Adminhtml/IndexTest.php | 3 - ...stomer_non_default_website_id_rollback.php | 39 + .../Customer/_files/customer_rollback.php | 21 +- .../order_with_downloadable_product.php | 3 +- .../SourceClassWithNamespaceInterceptor.php | 2 +- .../Search/Request/Config/ConverterTest.php | 45 + .../Framework/Search/Request/MapperTest.php | 45 + .../Search/_files/search_request.xml | 58 + .../Search/_files/search_request_config.php | 111 + .../Framework/Session/SessionManagerTest.php | 9 + .../Stdlib/Cookie/CookieScopeTest.php | 232 ++ .../Stdlib/Cookie/PhpCookieManagerTest.php | 98 + .../Magento/Install/Model/InstallerTest.php | 2 +- .../Controller/Adminhtml/IntegrationTest.php | 12 +- .../Service/V1/AuthorizationServiceTest.php | 173 ++ .../Service/V1/TokenServiceTest.php | 176 ++ .../_files/recurring_payment.php | 23 +- .../Magento/Paypal/Controller/ExpressTest.php | 3 +- .../Magento/Paypal/Controller/PayflowTest.php | 3 +- .../Paypal/Controller/PayflowadvancedTest.php | 2 +- .../Magento/Paypal/_files/order_express.php | 5 +- .../Paypal/_files/order_payflowpro.php | 3 +- .../Magento/Paypal/_files/order_standard.php | 4 +- .../Paypal/_files/quote_payment_express.php | 2 + .../Paypal/_files/quote_payment_standard.php | 1 + .../Adminhtml/Order/AuthorizationMock.php | 39 + .../Controller/Adminhtml/Order/CreateTest.php | 15 - .../Magento/Sales/Model/Order/AddressTest.php | 6 +- .../Sender/CreditmemoSenderTest.php} | 27 +- .../Sender/InvoiceSenderTest.php} | 15 +- .../Sender/OrderSenderTest.php} | 18 +- .../Order/Email/Sender/ShipmentSenderTest.php | 99 + .../Sales/Model/Order/ShipmentTest.php | 30 - .../Magento/Sales/Model/Service/QuoteTest.php | 1 + .../Magento/Sales/_files/order_info.php | 2 + .../_files/order_paid_with_payflowpro.php | 2 + .../testsuite/Magento/Sales/_files/quote.php | 1 + .../Magento/Sales/_files/quote_rollback.php | 34 +- .../Sales/_files/quote_with_customer.php | 9 +- .../_files/quote_with_customer_rollback.php | 25 + .../Magento/Store/_files/second_store.php | 41 +- .../Store/_files/second_store_rollback.php | 40 + .../Tax/Service/V1/TaxRateServiceTest.php | 19 + .../Tax/Service/V1/TaxRuleServiceTest.php | 65 +- .../Integrity/Modular/AclConfigFilesTest.php | 2 +- .../Magento/User/Block/Role/Tab/EditTest.php | 3 +- .../Controller/Adminhtml/User/RoleTest.php | 3 +- .../testsuite/Magento/User/Model/UserTest.php | 6 +- .../Magento/User/_files/user_with_role.php | 42 + .../TestFramework/Inspection/WordsFinder.php | 4 +- .../Magento/TestFramework/Utility/Classes.php | 2 +- .../Test/Integrity/Di/CompilerTest.php | 15 +- .../Magento/Framework/Search/ConfigTest.php | 148 ++ .../Framework/Search/_files/invalid.xml | 36 + .../Search/_files/invalid_partial.xml | 72 + .../Magento/Framework/Search/_files/valid.xml | 116 + .../Framework/Search/_files/valid_partial.xml | 88 + .../Integrity/_files/blacklist/namespace.txt | 1 + .../_files/dependency_test/tables_ce.php | 4 +- .../Test/Legacy/_files/obsolete_classes.php | 87 +- .../Test/Legacy/_files/obsolete_methods.php | 14 +- .../Legacy/_files/obsolete_namespaces.php | 1 - .../Test/Legacy/_files/obsolete_paths.php | 5 - .../Magento/Test/Legacy/_files/words_ce.xml | 2 +- .../Test/Php/_files/blacklist/common.txt | 2 - .../Php/_files/phpcpd/blacklist/common.txt | 4 +- .../Test/Php/_files/whitelist/common.txt | 3 + .../TestFramework/Helper/ObjectManager.php | 2 +- .../Model/System/Message/BaseurlTest.php | 2 +- .../Media/Synchronization/ErrorTest.php | 2 +- .../Media/Synchronization/SuccessTest.php | 2 +- .../Model/Acl/AclRetrieverTest.php | 191 ++ .../Model/Acl/Loader/RoleTest.php | 12 +- .../Model/Acl/Loader/RuleTest.php | 9 +- .../Model/CompositeUserContextTest.php | 199 ++ .../Magento/Authorizenet/Helper/DataTest.php | 119 + .../Authz/Model/UserIdentifierTest.php | 92 - .../Authz/Service/AuthorizationV1Test.php | 91 - .../Magento/Backend/Model/SessionTest.php | 2 +- .../Bundle/Model/Plugin/PriceBackendTest.php | 1 - .../V1/Product/Link/WriteServiceTest.php | 1 + .../V1/Product/Option/ReadServiceTest.php | 217 ++ .../Product/Option/Type/ReadServiceTest.php | 87 + .../V1/Product/Option/WriteServiceTest.php | 393 +++ .../Product/Initialization/HelperTest.php | 232 +- .../Option/Validator/DefaultValidatorTest.php | 111 +- .../Resource/Product/Option/ValueTest.php | 71 - .../Category/ProductLinks/ReadServiceTest.php | 11 +- .../ProductLinks/WriteServiceTest.php | 4 +- .../Service/V1/Category/WriteServiceTest.php | 4 +- .../Service/V1/Data/Category/TreeTest.php | 6 +- .../V1/Address/Billing/ReadServiceTest.php | 77 + .../V1/Address/Billing/WriteServiceTest.php | 170 ++ .../Service/V1/Address/ConverterTest.php | 154 ++ .../V1/Address/Shipping/ReadServiceTest.php | 96 + .../V1/Address/Shipping/WriteServiceTest.php | 205 ++ .../Service/V1/Address/ValidatorTest.php | 224 ++ .../Service/V1/Cart/ReadServiceTest.php | 380 +++ .../Service/V1/Cart/WriteServiceTest.php | 268 ++ .../Service/V1/Item/ReaderServiceTest.php | 93 + .../Service/V1/Item/WriteServiceTest.php | 332 +++ .../Checkout/Service/V1/QuoteLoaderTest.php | 81 + .../Model/Export/RowCustomizerTest.php | 6 +- .../Service/V1/Data/OptionConverterTest.php | 185 ++ .../V1/Product/Option/ReadServiceTest.php | 307 +++ .../V1/Product/Option/WriteServiceTest.php | 426 ++++ .../Service/V1/ReadServiceTest.php | 6 +- .../CustomerSessionUserContextTest.php | 93 + .../Magento/Fedex/Model/CarrierTest.php | 184 ++ .../Event/Config/_files/valid_events.xml | 4 +- .../Notification/NotifierListTest.php | 74 + .../Notification/NotifierPoolTest.php | 111 + .../Code/Generator/ConverterTest.php | 152 ++ .../Code/Generator/GenerateRepositoryTest.php | 113 + .../Code/Generator/RepositoryTest.php | 155 ++ .../Generator/_files/SampleRepository.txt | 98 + .../Framework/Search/RequestFactoryTest.php | 138 + .../Service/Code/Generator/BuilderTest.php | 156 ++ .../Code/Generator/GenerateBuilderTest.php | 83 + .../Code/Generator/GenerateMapperTest.php | 83 + .../GenerateSearchResultsBuilderTest.php | 85 + .../Generator/GenerateSearchResultsTest.php | 85 + .../Service/Code/Generator/MapperTest.php | 155 ++ .../Generator/SearchResultsBuilderTest.php | 157 ++ .../Code/Generator/SearchResultsTest.php | 155 ++ .../Service/Code/Generator/_files/Sample.php | 44 + .../Code/Generator/_files/SampleBuilder.txt | 15 + .../Code/Generator/_files/SampleMapper.txt | 43 + .../Generator/_files/SampleSearchResults.txt | 14 + .../_files/SampleSearchResultsBuilder.txt | 17 + .../Framework/Session/SessionManagerTest.php | 133 + .../Stdlib/Cookie/CookieScopeTest.php | 309 +++ .../Stdlib/Cookie/PhpCookieManagerTest.php | 782 ++++++ .../Cookie/PublicCookieMetadataTest.php | 72 + .../Cookie/SensitiveCookieMetadataTest.php | 68 + .../Framework/Validator/ExceptionTest.php | 9 +- .../View/Element/AbstractBlockTest.php | 7 +- .../Googleshopping/Items/MassAddTest.php | 117 + .../Googleshopping/Items/RefreshTest.php | 111 + .../Model/MassOperationsTest.php | 193 ++ .../GoogleShopping/Model/ObserverTest.php | 92 + .../Integration/TokensDialogTest.php | 2 +- .../Magento/Integration/Oauth/OauthTest.php | 6 +- .../Service/V1/AuthorizationServiceTest.php | 77 + .../Service/V1/IntegrationTest.php | 7 - .../Integration/Service/V1/OauthTest.php | 18 +- .../Model/Plugin/TabsTest.php | 73 + .../Magento/Sales/Helper/DataTest.php | 27 +- .../Sales/Model/AdminOrder/CreateTest.php | 20 +- .../Model/AdminOrder/EmailSenderTest.php | 23 +- .../Magento/Sales/Model/NotifierTest.php | 165 ++ .../Model/Order/Address/ValidatorTest.php | 124 + .../CreditmemoCommentIdentityTest.php | 222 ++ .../Container/CreditmemoIdentityTest.php | 222 ++ .../Container/InvoiceCommentIdentityTest.php | 222 ++ .../Email/Container/InvoiceIdentityTest.php | 222 ++ .../Container/OrderCommentIdentityTest.php | 222 ++ .../Email/Container/OrderIdentityTest.php | 222 ++ .../Container/ShipmentCommentIdentityTest.php | 222 ++ .../Email/Container/ShipmentIdentityTest.php | 222 ++ .../Stub/ScopeConfigInterfaceMock.php | 39 + .../Order/Email/Container/TemplateTest.php | 61 + .../Sender/CreditmemoCommentSenderTest.php | 238 ++ .../Email/Sender/CreditmemoSenderTest.php | 283 +++ .../Email/Sender/InvoiceCommentSenderTest.php | 254 ++ .../Order/Email/Sender/InvoiceSenderTest.php | 284 +++ .../Email/Sender/OrderCommentSenderTest.php | 169 ++ .../Order/Email/Sender/OrderSenderTest.php | 275 ++ .../Sender/ShipmentCommentSenderTest.php | 237 ++ .../Order/Email/Sender/ShipmentSenderTest.php | 284 +++ .../Model/Order/Email/SenderBuilderTest.php | 194 ++ .../Email/Stub/TransportInterfaceMock.php | 39 + .../Order/Status/History/ValidatorTest.php | 48 + .../Model/Quote/Address/ValidatorTest.php | 121 + .../Model/Resource/Order/AddressTest.php | 137 + .../Resource/Order/Status/HistoryTest.php | 141 ++ .../Sales/Service/V1/Data/CommentTest.php | 123 + .../Service/V1/Data/CreditmemoCommentTest.php | 123 + .../Service/V1/Data/CreditmemoItemTest.php | 555 ++++ .../Sales/Service/V1/Data/CreditmemoTest.php | 801 ++++++ .../Sales/Service/V1/Data/InvoiceItemTest.php | 411 +++ .../Sales/Service/V1/Data/InvoiceTest.php | 769 ++++++ .../Service/V1/Data/OrderAddressTest.php | 443 ++++ .../Sales/Service/V1/Data/OrderItemTest.php | 1537 +++++++++++ .../Sales/Service/V1/Data/OrderMapperTest.php | 198 ++ .../Service/V1/Data/OrderPaymentTest.php | 897 +++++++ .../V1/Data/OrderStatusHistoryTest.php | 155 ++ .../Sales/Service/V1/Data/OrderTest.php | 2242 +++++++++++++++++ .../Service/V1/Data/ShipmentItemTest.php | 219 ++ .../Sales/Service/V1/Data/ShipmentTest.php | 267 ++ .../Service/V1/Data/ShipmentTrackTest.php | 203 ++ .../Service/V1/OrderAddressUpdateTest.php | 85 + .../Sales/Service/V1/OrderCancelTest.php | 82 + .../Service/V1/OrderCommentsListTest.php | 189 ++ .../Sales/Service/V1/OrderGetStatusTest.php | 80 + .../Magento/Sales/Service/V1/OrderGetTest.php | 120 + .../Sales/Service/V1/OrderHoldTest.php | 81 + .../Sales/Service/V1/OrderListTest.php | 144 ++ .../Sales/Service/V1/OrderNotifyUserTest.php | 65 + .../Service/V1/OrderStatusHistoryAddTest.php | 96 + .../Sales/Service/V1/OrderUnHoldTest.php | 81 + .../Tax/Service/V1/TaxRateServiceTest.php | 18 + .../Tax/Service/V1/TaxRuleServiceTest.php | 98 +- .../AdminSessionUserContextTest.php | 108 + .../testsuite/Magento/User/Model/UserTest.php | 2 +- .../Magento/Webapi/Controller/RestTest.php | 62 +- .../Controller/Soap/Request/HandlerTest.php | 8 +- .../Magento/Webapi/Controller/SoapTest.php | 25 - .../Authorization/GuestUserContextTest.php | 62 + .../Authorization/OauthUserContextTest.php | 159 ++ .../Authorization/TokenUserContextTest.php | 239 ++ .../Webapi/Model/Config/_files/webapi.php | 4 +- .../Webapi/Model/Config/_files/webapi.xml | 2 +- .../V1/IntegrationTest.php} | 74 +- .../Magento/Webapi/Model/Plugin/SetupTest.php | 80 +- .../Webapi/Model/WebapiRoleLocatorTest.php | 135 + .../_files/session_backend_mock.php | 0 dev/tools/Magento/Tools/Di/compiler.php | 16 +- .../Magento/Tools/Di/entity_generator.php | 20 +- .../factory_table_names/replace_ce.php | 4 +- .../Framework/Acl/Resource/Provider.php | 3 +- .../Magento/Framework/AppInterface.php | 2 +- .../Framework/Authorization/RoleLocator.php | 2 +- .../Code/Generator/EntityAbstract.php | 6 +- .../Code/Generator/Interceptor.php | 4 +- .../Notification}/MessageInterface.php | 14 +- .../Framework/Notification}/MessageList.php | 33 +- .../Notification/NotifierInterface.php | 90 + .../Framework/Notification/NotifierList.php | 90 + .../Framework/Notification/NotifierPool.php | 133 + .../Framework/Oauth/Helper/Request.php | 8 +- .../Code/Generator/Converter.php | 171 ++ .../Code/Generator/Repository.php | 336 +++ .../ObjectManager/DefinitionFactory.php | 26 +- .../Magento/Framework/Search/Request.php | 138 + .../Search/Request/Aggregation/Range.php | 72 + .../Request/Aggregation/RangeBucket.php | 111 + .../Search/Request/Aggregation/TermBucket.php | 94 + .../Search/Request/BucketInterface.php | 52 + .../Framework/Search/Request/Config.php | 40 + .../Search/Request/Config/Converter.php | 106 + .../Search/Request/Config/SchemaLocator.php | 49 + .../Framework/Search/Request/Filter/Bool.php | 116 + .../Framework/Search/Request/Filter/Range.php | 114 + .../Framework/Search/Request/Filter/Term.php | 94 + .../Search/Request/FilterInterface.php | 54 + .../Framework/Search/Request/Mapper.php | 212 ++ .../Framework/Search/Request/Query/Bool.php | 135 + .../Framework/Search/Request/Query/Filter.php | 124 + .../Framework/Search/Request/Query/Match.php | 101 + .../Search/Request/QueryInterface.php | 61 + .../Framework/Search/RequestFactory.php | 119 + .../Framework/Search/RequestInterface.php | 75 + .../Magento/Framework/Search/Response.php | 6 +- .../Framework/Search/ResponseInterface.php | 6 +- .../Magento/Framework/Search/SearchEngine.php | 20 +- .../Search/SearchEngineInterface.php | 37 + .../Magento/Framework/Search/etc/requests.xsd | 276 ++ .../Framework/Search/etc/search_request.xsd | 46 + .../Search/etc/search_request_merged.xsd | 48 + .../Service/Code/Generator/Builder.php | 156 ++ .../Service/Code/Generator/Mapper.php | 169 ++ .../Service/Code/Generator/SearchResults.php | 102 + .../Code/Generator/SearchResultsBuilder.php | 139 + .../Framework/Session/SessionManager.php | 8 +- .../Session/SessionManagerInterface.php | 3 +- .../Stdlib/Cookie/CookieMetadata.php | 137 + .../Stdlib/Cookie/CookieMetadataFactory.php | 88 + .../Framework/Stdlib/Cookie/CookieScope.php | 133 + .../CookieSizeLimitReachedException.php | 39 + .../Stdlib/Cookie/FailureToSendException.php | 36 + .../Stdlib/Cookie/PhpCookieManager.php | 288 +++ .../Stdlib/Cookie/PublicCookieMetadata.php | 107 + .../Stdlib/Cookie/SensitiveCookieMetadata.php | 36 + .../Framework/Stdlib/CookieManager.php | 97 + .../Validator/ValidatorException.php | 35 +- .../Framework/View/Element/AbstractBlock.php | 34 +- lib/internal/Magento/Framework/composer.json | 7 +- .../Zend/Code/Generator/DocBlockGenerator.php | 4 +- lib/internal/Zend/Escaper/composer.json | 2 +- .../I18n/Exception/ExceptionInterface.php | 2 +- .../Exception/InvalidArgumentException.php | 2 +- .../I18n/Exception/OutOfBoundsException.php | 2 +- .../Zend/I18n/Exception/ParseException.php | 2 +- .../Zend/I18n/Exception/RangeException.php | 2 +- .../Zend/I18n/Exception/RuntimeException.php | 2 +- .../Zend/I18n/Filter/AbstractLocale.php | 3 +- lib/internal/Zend/I18n/Filter/Alnum.php | 4 +- lib/internal/Zend/I18n/Filter/Alpha.php | 3 +- .../Zend/I18n/Filter/NumberFormat.php | 5 + .../Translator/TranslatorServiceFactory.php | 2 +- lib/internal/Zend/I18n/Validator/Alnum.php | 3 +- lib/internal/Zend/I18n/Validator/Alpha.php | 4 +- lib/internal/Zend/I18n/Validator/Float.php | 3 +- lib/internal/Zend/I18n/Validator/Int.php | 3 +- lib/internal/Zend/I18n/Validator/PostCode.php | 3 +- .../View/Helper/AbstractTranslatorHelper.php | 4 +- .../Zend/I18n/View/Helper/CurrencyFormat.php | 42 +- lib/internal/Zend/I18n/composer.json | 3 +- lib/internal/Zend/Server/composer.json | 2 +- .../AbstractFactoryInterface.php | 38 + .../ServiceManager/AbstractPluginManager.php | 222 ++ lib/internal/Zend/ServiceManager/Config.php | 155 ++ .../Zend/ServiceManager/ConfigInterface.php | 26 + .../Di/DiAbstractServiceFactory.php | 62 + .../Di/DiInstanceManagerProxy.php | 72 + .../ServiceManager/Di/DiServiceFactory.php | 124 + .../Di/DiServiceInitializer.php | 69 + .../CircularDependencyFoundException.php | 20 + .../Exception/ExceptionInterface.php | 20 + .../Exception/InvalidArgumentException.php | 20 + .../Exception/InvalidServiceNameException.php | 20 + .../Exception/RuntimeException.php | 20 + .../Exception/ServiceNotCreatedException.php | 20 + .../Exception/ServiceNotFoundException.php | 20 + .../Zend/ServiceManager/FactoryInterface.php | 26 + .../ServiceManager/InitializerInterface.php | 29 + .../ServiceLocatorAwareInterface.php | 32 + .../ServiceLocatorInterface.php | 37 + .../Zend/ServiceManager/ServiceManager.php | 960 +++++++ .../ServiceManagerAwareInterface.php | 25 + .../Zend/ServiceManager/composer.json | 21 + lib/internal/Zend/Soap/AutoDiscover.php | 5 +- lib/internal/Zend/Soap/Client.php | 2 +- .../Soap/Server/DocumentLiteralWrapper.php | 1 - lib/internal/Zend/Soap/composer.json | 2 +- lib/internal/Zend/Uri/composer.json | 2 +- .../Zend/Validator/AbstractValidator.php | 2 +- lib/internal/Zend/Validator/Barcode.php | 2 +- .../Validator/Barcode/AbstractAdapter.php | 2 +- .../Validator/Barcode/AdapterInterface.php | 2 +- .../Zend/Validator/Barcode/Codabar.php | 2 +- .../Zend/Validator/Barcode/Code128.php | 2 +- .../Zend/Validator/Barcode/Code25.php | 2 +- .../Validator/Barcode/Code25interleaved.php | 2 +- .../Zend/Validator/Barcode/Code39.php | 2 +- .../Zend/Validator/Barcode/Code39ext.php | 2 +- .../Zend/Validator/Barcode/Code93.php | 2 +- .../Zend/Validator/Barcode/Code93ext.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean12.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean13.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean14.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean18.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean2.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean5.php | 2 +- lib/internal/Zend/Validator/Barcode/Ean8.php | 2 +- .../Zend/Validator/Barcode/Gtin12.php | 2 +- .../Zend/Validator/Barcode/Gtin13.php | 2 +- .../Zend/Validator/Barcode/Gtin14.php | 2 +- .../Zend/Validator/Barcode/Identcode.php | 2 +- .../Validator/Barcode/Intelligentmail.php | 2 +- lib/internal/Zend/Validator/Barcode/Issn.php | 2 +- lib/internal/Zend/Validator/Barcode/Itf14.php | 2 +- .../Zend/Validator/Barcode/Leitcode.php | 2 +- .../Zend/Validator/Barcode/Planet.php | 2 +- .../Zend/Validator/Barcode/Postnet.php | 2 +- .../Zend/Validator/Barcode/Royalmail.php | 2 +- lib/internal/Zend/Validator/Barcode/Sscc.php | 2 +- lib/internal/Zend/Validator/Barcode/Upca.php | 2 +- lib/internal/Zend/Validator/Barcode/Upce.php | 2 +- lib/internal/Zend/Validator/Between.php | 2 +- lib/internal/Zend/Validator/Callback.php | 2 +- lib/internal/Zend/Validator/CreditCard.php | 2 +- lib/internal/Zend/Validator/Date.php | 8 +- lib/internal/Zend/Validator/DateStep.php | 41 +- lib/internal/Zend/Validator/Db/AbstractDb.php | 2 +- .../Zend/Validator/Db/NoRecordExists.php | 2 +- .../Zend/Validator/Db/RecordExists.php | 2 +- lib/internal/Zend/Validator/Digits.php | 2 +- lib/internal/Zend/Validator/EmailAddress.php | 4 +- .../Exception/ExceptionInterface.php | 2 +- lib/internal/Zend/Validator/Explode.php | 4 +- lib/internal/Zend/Validator/File/Count.php | 2 +- lib/internal/Zend/Validator/File/Crc32.php | 2 +- .../Zend/Validator/File/ExcludeExtension.php | 2 +- .../Zend/Validator/File/ExcludeMimeType.php | 2 +- lib/internal/Zend/Validator/File/Exists.php | 2 +- .../Zend/Validator/File/Extension.php | 2 +- .../Zend/Validator/File/FilesSize.php | 2 +- lib/internal/Zend/Validator/File/Hash.php | 2 +- .../Zend/Validator/File/ImageSize.php | 2 +- .../Zend/Validator/File/IsCompressed.php | 2 +- lib/internal/Zend/Validator/File/IsImage.php | 2 +- lib/internal/Zend/Validator/File/Md5.php | 2 +- lib/internal/Zend/Validator/File/MimeType.php | 4 +- .../Zend/Validator/File/NotExists.php | 2 +- lib/internal/Zend/Validator/File/Sha1.php | 3 +- lib/internal/Zend/Validator/File/Size.php | 2 +- lib/internal/Zend/Validator/File/Upload.php | 2 +- .../Zend/Validator/File/WordCount.php | 2 +- lib/internal/Zend/Validator/GreaterThan.php | 2 +- lib/internal/Zend/Validator/Hex.php | 2 +- lib/internal/Zend/Validator/Hostname/Biz.php | 2 +- lib/internal/Zend/Validator/Hostname/Cn.php | 2 +- lib/internal/Zend/Validator/Hostname/Com.php | 2 +- lib/internal/Zend/Validator/Hostname/Jp.php | 2 +- lib/internal/Zend/Validator/Iban.php | 4 +- lib/internal/Zend/Validator/Identical.php | 2 +- lib/internal/Zend/Validator/InArray.php | 2 +- lib/internal/Zend/Validator/Ip.php | 5 +- lib/internal/Zend/Validator/Isbn.php | 2 +- lib/internal/Zend/Validator/LessThan.php | 2 +- lib/internal/Zend/Validator/NotEmpty.php | 2 +- lib/internal/Zend/Validator/Regex.php | 2 +- .../Zend/Validator/Sitemap/Changefreq.php | 2 +- .../Zend/Validator/Sitemap/Lastmod.php | 2 +- lib/internal/Zend/Validator/Sitemap/Loc.php | 2 +- .../Zend/Validator/Sitemap/Priority.php | 2 +- .../Zend/Validator/StaticValidator.php | 2 +- lib/internal/Zend/Validator/Step.php | 2 +- lib/internal/Zend/Validator/StringLength.php | 2 +- lib/internal/Zend/Validator/Uri.php | 2 +- .../Zend/Validator/ValidatorInterface.php | 2 +- .../Zend/Validator/ValidatorPluginManager.php | 2 +- lib/internal/Zend/Validator/composer.json | 3 +- lib/web/app-config.js | 1 + lib/web/css/docs/source/actions-toolbar.less | 2 +- lib/web/css/docs/source/sections.less | 2 +- lib/web/css/docs/source/tables.less | 4 +- lib/web/css/source/lib/abstract.less | 4 +- lib/web/css/source/lib/buttons.less | 47 +- lib/web/css/source/lib/forms.less | 12 +- lib/web/css/source/lib/icons.less | 4 +- lib/web/css/source/lib/messages.less | 63 +- lib/web/css/source/lib/navigation.less | 242 +- lib/web/css/source/lib/rating.less | 1 + lib/web/css/source/lib/resets.less | 78 +- lib/web/css/source/lib/responsive.less | 26 +- lib/web/css/source/lib/typography.less | 14 +- lib/web/css/source/lib/variables.less | 148 +- lib/web/mage/adminhtml/tools.js | 16 +- lib/web/mage/menu.js | 19 +- 1107 files changed, 59413 insertions(+), 7369 deletions(-) rename app/code/Magento/AdminNotification/etc/{adminhtml => }/acl.xml (95%) create mode 100644 app/code/Magento/AdminNotification/etc/di.xml create mode 100644 app/code/Magento/Authorization/Model/Acl/AclRetriever.php rename app/code/Magento/{User => Authorization}/Model/Acl/Loader/Role.php (79%) rename app/code/Magento/{User => Authorization}/Model/Acl/Loader/Rule.php (95%) rename app/code/Magento/{User => Authorization}/Model/Acl/Role/Generic.php (93%) rename app/code/Magento/{User => Authorization}/Model/Acl/Role/Group.php (90%) rename app/code/Magento/{User => Authorization}/Model/Acl/Role/User.php (90%) create mode 100644 app/code/Magento/Authorization/Model/CompositeUserContext.php rename app/code/Magento/{User => Authorization}/Model/Resource/Permissions/Collection.php (88%) rename app/code/Magento/{User => Authorization}/Model/Resource/Role.php (76%) rename app/code/Magento/{User => Authorization}/Model/Resource/Role/Collection.php (89%) rename app/code/Magento/{User => Authorization}/Model/Resource/Role/Grid/Collection.php (85%) rename app/code/Magento/{User => Authorization}/Model/Resource/Rules.php (95%) rename app/code/Magento/{User => Authorization}/Model/Resource/Rules/Collection.php (91%) rename app/code/Magento/{User => Authorization}/Model/Resource/Setup.php (69%) rename app/code/Magento/{User => Authorization}/Model/Role.php (58%) rename app/code/Magento/{User => Authorization}/Model/Rules.php (68%) rename app/code/Magento/{Authz/Model/UserLocatorInterface.php => Authorization/Model/UserContextInterface.php} (76%) create mode 100644 app/code/Magento/Authorization/composer.json rename app/code/Magento/{User/data/user_setup/data-install-1.6.0.0.php => Authorization/data/authorization_setup/data-install-1.0.0.0.php} (69%) create mode 100644 app/code/Magento/Authorization/etc/di.xml rename app/code/Magento/{Authz/etc/di.xml => Authorization/etc/module.xml} (80%) create mode 100644 app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php delete mode 100644 app/code/Magento/Authz/Model/UserIdentifier.php delete mode 100644 app/code/Magento/Authz/Service/AuthorizationV1.php delete mode 100644 app/code/Magento/Authz/Service/AuthorizationV1Interface.php delete mode 100644 app/code/Magento/Authz/composer.json delete mode 100644 app/code/Magento/Authz/i18n/de_DE.csv delete mode 100644 app/code/Magento/Authz/i18n/en_US.csv delete mode 100644 app/code/Magento/Authz/i18n/es_ES.csv delete mode 100644 app/code/Magento/Authz/i18n/fr_FR.csv delete mode 100644 app/code/Magento/Authz/i18n/nl_NL.csv delete mode 100644 app/code/Magento/Authz/i18n/pt_BR.csv delete mode 100644 app/code/Magento/Authz/i18n/zh_CN.csv rename app/code/Magento/Backend/etc/{adminhtml => }/acl.xml (98%) rename app/code/Magento/Backup/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/Option.php create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php create mode 100644 app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadService.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php rename app/code/Magento/Catalog/Service/V1/Data/{Eav => }/Category/ProductLink.php (96%) rename app/code/Magento/Catalog/Service/V1/Data/{Eav => }/Category/ProductLinkBuilder.php (96%) rename app/code/Magento/Catalog/etc/{adminhtml => }/acl.xml (96%) rename app/code/Magento/CatalogInventory/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/CatalogRule/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/CatalogSearch/etc/{adminhtml => }/acl.xml (93%) create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Converter.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Address/Validator.php create mode 100644 app/code/Magento/Checkout/Service/V1/Cart/ReadService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Cart/WriteService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/CurrencyBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php rename dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php => app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php (53%) create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/ItemBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php create mode 100644 app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php create mode 100644 app/code/Magento/Checkout/Service/V1/Item/ReadService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/Item/WriteService.php create mode 100644 app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php create mode 100644 app/code/Magento/Checkout/Service/V1/QuoteLoader.php create mode 100644 app/code/Magento/Checkout/etc/webapi.xml rename app/code/Magento/CheckoutAgreements/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/Cms/etc/{adminhtml => }/acl.xml (95%) rename app/code/Magento/{CatalogImportExport => ConfigurableImportExport}/Model/Export/Product/Type/Configurable.php (93%) rename app/code/Magento/{CatalogImportExport => ConfigurableImportExport}/Model/Export/RowCustomizer.php (96%) rename app/code/Magento/{CatalogImportExport => ConfigurableImportExport}/Model/Import/Product/Type/Configurable.php (99%) create mode 100644 app/code/Magento/ConfigurableImportExport/composer.json create mode 100644 app/code/Magento/ConfigurableImportExport/etc/di.xml create mode 100644 app/code/Magento/ConfigurableImportExport/etc/export.xml create mode 100644 app/code/Magento/ConfigurableImportExport/etc/import.xml rename app/code/Magento/{Authz => ConfigurableImportExport}/etc/module.xml (76%) rename app/code/Magento/ConfigurableProduct/Service/V1/Data/{ConfigurableAttribute.php => Option.php} (76%) rename app/code/Magento/ConfigurableProduct/Service/V1/Data/{ConfigurableAttribute => Option}/Value.php (82%) rename app/code/Magento/ConfigurableProduct/Service/V1/Data/{ConfigurableAttribute => Option}/ValueBuilder.php (88%) create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php rename app/code/Magento/ConfigurableProduct/Service/V1/Data/{ConfigurableAttributeBuilder.php => OptionBuilder.php} (58%) create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php create mode 100644 app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php rename app/code/Magento/Contact/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/CurrencySymbol/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php create mode 100644 app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php rename app/code/Magento/Customer/etc/{adminhtml => }/acl.xml (95%) create mode 100644 app/code/Magento/Customer/etc/webapi_rest/di.xml rename app/code/Magento/{Authz/etc/adminhtml => Customer/etc/webapi_soap}/di.xml (86%) rename app/code/Magento/DesignEditor/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/Downloadable/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Email/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/GoogleAnalytics/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/GoogleShopping/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php create mode 100644 app/code/Magento/GroupedImportExport/Model/Export/RowCustomizer.php rename app/code/Magento/{CatalogImportExport => GroupedImportExport}/Model/Import/Product/Type/Grouped.php (98%) create mode 100644 app/code/Magento/GroupedImportExport/composer.json create mode 100644 app/code/Magento/GroupedImportExport/etc/di.xml create mode 100644 app/code/Magento/GroupedImportExport/etc/export.xml create mode 100644 app/code/Magento/GroupedImportExport/etc/import.xml create mode 100644 app/code/Magento/GroupedImportExport/etc/module.xml rename app/code/Magento/ImportExport/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Index/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/Indexer/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/{AdminNotification => Install}/Controller/Adminhtml/Survey.php (90%) rename app/code/Magento/{AdminNotification => Install}/Controller/Adminhtml/Survey/Index.php (83%) rename app/code/Magento/{AdminNotification => Install}/Model/Survey.php (94%) rename app/code/Magento/{AdminNotification => Install}/Model/System/Message/Survey.php (87%) create mode 100644 app/code/Magento/Install/etc/adminhtml/routes.xml create mode 100644 app/code/Magento/Install/view/adminhtml/layout/default.xml create mode 100644 app/code/Magento/Install/view/adminhtml/web/survey_notification.js create mode 100644 app/code/Magento/Integration/Service/V1/AuthorizationService.php create mode 100644 app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php create mode 100644 app/code/Magento/Integration/Service/V1/TokenService.php create mode 100644 app/code/Magento/Integration/Service/V1/TokenServiceInterface.php create mode 100644 app/code/Magento/Integration/etc/webapi.xml create mode 100644 app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php rename app/code/Magento/Multishipping/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Newsletter/etc/{adminhtml => }/acl.xml (96%) rename app/code/Magento/Payment/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Paypal/etc/{adminhtml => }/acl.xml (96%) rename app/code/Magento/Persistent/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php rename app/code/Magento/RecurringPayment/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Reports/etc/{adminhtml => }/acl.xml (97%) rename app/code/Magento/Review/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Rss/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/Sales/Model/Notifier.php create mode 100644 app/code/Magento/Sales/Model/Order/Address/Validator.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/Container.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Container/Template.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/NotifySender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php create mode 100644 app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php create mode 100644 app/code/Magento/Sales/Model/Order/Status/History/Validator.php create mode 100644 app/code/Magento/Sales/Model/Quote/Address/Validator.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/Comment.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/Creditmemo.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/Invoice.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/Order.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/OrderAddress.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/OrderItem.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/OrderMapper.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/OrderPayment.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/Shipment.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php create mode 100644 app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderCancel.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderCancelInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderCommentsList.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderGet.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderGetInterface.php rename dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php => app/code/Magento/Sales/Service/V1/OrderGetStatus.php (60%) create mode 100644 app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderHold.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderHoldInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderList.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderListInterface.php rename app/code/Magento/{Webapi/Controller/Login/Anonymous.php => Sales/Service/V1/OrderNotifyUser.php} (54%) create mode 100644 app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderUnHold.php create mode 100644 app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php rename app/code/Magento/Sales/etc/{adminhtml => }/acl.xml (97%) create mode 100644 app/code/Magento/Sales/etc/webapi.xml rename app/code/Magento/SalesRule/etc/{adminhtml => }/acl.xml (95%) rename app/code/Magento/Shipping/etc/{adminhtml => }/acl.xml (94%) rename app/code/Magento/Sitemap/etc/{adminhtml => }/acl.xml (95%) rename app/code/Magento/Tax/etc/{adminhtml => }/acl.xml (95%) rename app/code/Magento/Theme/etc/{adminhtml => }/acl.xml (93%) create mode 100644 app/code/Magento/Theme/view/frontend/templates/html/collapsible.phtml create mode 100644 app/code/Magento/Theme/view/frontend/templates/html/container.phtml create mode 100644 app/code/Magento/Theme/view/frontend/templates/html/sections.phtml rename app/code/Magento/UrlRedirect/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/{Authz/Model/UserLocator/Admin.php => User/Model/Authorization/AdminSessionUserContext.php} (83%) rename app/code/Magento/{Authz/Model/UserIdentifier/Factory.php => User/Model/Plugin/AuthorizationRole.php} (57%) delete mode 100644 app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php rename app/code/Magento/User/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/code/Magento/User/etc/webapi_rest/di.xml delete mode 100644 app/code/Magento/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php delete mode 100644 app/code/Magento/Webapi/Controller/Login/Index.php rename app/code/Magento/{Authz/Model/UserLocator/Guest.php => Webapi/Model/Authorization/GuestUserContext.php} (82%) create mode 100644 app/code/Magento/Webapi/Model/Authorization/OauthUserContext.php create mode 100644 app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php delete mode 100644 app/code/Magento/Webapi/Model/Authz/UserLocator.php delete mode 100644 app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php create mode 100644 app/code/Magento/Webapi/Model/Plugin/GuestAuthorization.php rename app/code/Magento/Webapi/Model/Plugin/{IntegrationServiceV1.php => Service/V1/Integration.php} (67%) create mode 100644 app/code/Magento/Webapi/Model/WebapiRoleLocator.php rename app/code/Magento/Widget/etc/{adminhtml => }/acl.xml (93%) rename app/code/Magento/Wishlist/etc/{adminhtml => }/acl.xml (94%) create mode 100644 app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/toolbar.less create mode 100644 app/design/frontend/Magento/blank/Magento_Customer/layout/customer_account.xml create mode 100644 app/design/frontend/Magento/blank/Magento_RecurringPayment/web/css/source/module.less create mode 100644 app/etc/vendor_path.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteInGrid.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteNotInGrid.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteSuccessMessage.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/Address.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewNotOnProductPage.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/page.xml rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/Resource/Role/CollectionTest.php (86%) rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/Resource/Role/Grid/CollectionTest.php (85%) rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/Resource/RoleTest.php (90%) rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/Resource/Rules/CollectionTest.php (91%) rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/RoleTest.php (80%) rename dev/tests/integration/testsuite/Magento/{User => Authorization}/Model/RulesTest.php (94%) delete mode 100644 dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/OptionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_saved_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address.php create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_non_default_website_id_rollback.php rename app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.4-1.6.1.5.php => dev/tests/integration/testsuite/Magento/Customer/_files/customer_rollback.php (62%) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AuthorizationMock.php rename dev/tests/integration/testsuite/Magento/Sales/Model/Order/{CreditmemoTest.php => Email/Sender/CreditmemoSenderTest.php} (72%) rename dev/tests/integration/testsuite/Magento/Sales/Model/Order/{InvoiceTest.php => Email/Sender/InvoiceSenderTest.php} (82%) rename dev/tests/integration/testsuite/Magento/Sales/Model/Order/{OrderTest.php => Email/Sender/OrderSenderTest.php} (82%) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php rename app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php => dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php (53%) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer_rollback.php rename app/code/Magento/User/sql/user_setup/upgrade-1.6.1.4-1.6.1.5.php => dev/tests/integration/testsuite/Magento/Store/_files/second_store.php (53%) create mode 100644 dev/tests/integration/testsuite/Magento/Store/_files/second_store_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/User/_files/user_with_role.php create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid.xml create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid_partial.xml create mode 100644 dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/AclRetrieverTest.php rename dev/tests/unit/testsuite/Magento/{User => Authorization}/Model/Acl/Loader/RoleTest.php (92%) rename dev/tests/unit/testsuite/Magento/{User => Authorization}/Model/Acl/Loader/RuleTest.php (92%) create mode 100644 dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Authorizenet/Helper/DataTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Authz/Model/UserIdentifierTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Authz/Service/AuthorizationV1Test.php create mode 100644 dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/WriteServiceTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php rename dev/tests/unit/testsuite/Magento/{ConfigurableProduct => ConfigurableImportExport}/Model/Export/RowCustomizerTest.php (97%) create mode 100644 dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Model/Authorization/CustomerSessionUserContextTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierPoolTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/ConverterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/GenerateRepositoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/RepositoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/BuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateMapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/MapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/Sample.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleBuilder.txt create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleMapper.txt create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResults.txt create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResultsBuilder.txt create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/RefreshTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Plugin/TabsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentIdentityTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/Stub/ScopeConfigInterfaceMock.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/TemplateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderCommentSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/SenderBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Stub/TransportInterfaceMock.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Order/Status/History/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/ValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CommentTest.php create 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/CreditmemoItemTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceItemTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderAddressTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderItemTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderMapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderPaymentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderStatusHistoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentItemTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTrackTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php create mode 100644 dev/tests/unit/testsuite/Magento/User/Model/Authorization/AdminSessionUserContextTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/GuestUserContextTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/OauthUserContextTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/TokenUserContextTest.php rename dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/{IntegrationServiceV1Test.php => Service/V1/IntegrationTest.php} (52%) create mode 100644 dev/tests/unit/testsuite/Magento/Webapi/Model/WebapiRoleLocatorTest.php rename dev/tests/unit/testsuite/Magento/{Backend/Model => }/_files/session_backend_mock.php (100%) rename {app/code/Magento/AdminNotification/Model/System => lib/internal/Magento/Framework/Notification}/MessageInterface.php (88%) rename {app/code/Magento/AdminNotification/Model/System => lib/internal/Magento/Framework/Notification}/MessageList.php (70%) create mode 100644 lib/internal/Magento/Framework/Notification/NotifierInterface.php create mode 100644 lib/internal/Magento/Framework/Notification/NotifierList.php create mode 100644 lib/internal/Magento/Framework/Notification/NotifierPool.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php create mode 100644 lib/internal/Magento/Framework/Search/Request.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php create mode 100644 lib/internal/Magento/Framework/Search/Request/BucketInterface.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Config.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Config/Converter.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Filter/Bool.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Filter/Range.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Filter/Term.php create mode 100644 lib/internal/Magento/Framework/Search/Request/FilterInterface.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Mapper.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Query/Bool.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Query/Filter.php create mode 100644 lib/internal/Magento/Framework/Search/Request/Query/Match.php create mode 100644 lib/internal/Magento/Framework/Search/Request/QueryInterface.php create mode 100644 lib/internal/Magento/Framework/Search/RequestFactory.php create mode 100644 lib/internal/Magento/Framework/Search/RequestInterface.php rename dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php => lib/internal/Magento/Framework/Search/Response.php (88%) rename app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Grouped.php => lib/internal/Magento/Framework/Search/ResponseInterface.php (86%) rename dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test/UserLocatorStub.php => lib/internal/Magento/Framework/Search/SearchEngine.php (75%) create mode 100644 lib/internal/Magento/Framework/Search/SearchEngineInterface.php create mode 100644 lib/internal/Magento/Framework/Search/etc/requests.xsd create mode 100644 lib/internal/Magento/Framework/Search/etc/search_request.xsd create mode 100644 lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd create mode 100644 lib/internal/Magento/Framework/Service/Code/Generator/Builder.php create mode 100644 lib/internal/Magento/Framework/Service/Code/Generator/Mapper.php create mode 100644 lib/internal/Magento/Framework/Service/Code/Generator/SearchResults.php create mode 100644 lib/internal/Magento/Framework/Service/Code/Generator/SearchResultsBuilder.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php create mode 100644 lib/internal/Magento/Framework/Stdlib/CookieManager.php create mode 100644 lib/internal/Zend/ServiceManager/AbstractFactoryInterface.php create mode 100644 lib/internal/Zend/ServiceManager/AbstractPluginManager.php create mode 100644 lib/internal/Zend/ServiceManager/Config.php create mode 100644 lib/internal/Zend/ServiceManager/ConfigInterface.php create mode 100644 lib/internal/Zend/ServiceManager/Di/DiAbstractServiceFactory.php create mode 100644 lib/internal/Zend/ServiceManager/Di/DiInstanceManagerProxy.php create mode 100644 lib/internal/Zend/ServiceManager/Di/DiServiceFactory.php create mode 100644 lib/internal/Zend/ServiceManager/Di/DiServiceInitializer.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/CircularDependencyFoundException.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/ExceptionInterface.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/InvalidArgumentException.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/InvalidServiceNameException.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/RuntimeException.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/ServiceNotCreatedException.php create mode 100644 lib/internal/Zend/ServiceManager/Exception/ServiceNotFoundException.php create mode 100644 lib/internal/Zend/ServiceManager/FactoryInterface.php create mode 100644 lib/internal/Zend/ServiceManager/InitializerInterface.php create mode 100644 lib/internal/Zend/ServiceManager/ServiceLocatorAwareInterface.php create mode 100644 lib/internal/Zend/ServiceManager/ServiceLocatorInterface.php create mode 100644 lib/internal/Zend/ServiceManager/ServiceManager.php create mode 100644 lib/internal/Zend/ServiceManager/ServiceManagerAwareInterface.php create mode 100644 lib/internal/Zend/ServiceManager/composer.json diff --git a/.gitignore b/.gitignore index 7a2f12aac25..90b240f3af0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ atlassian* /var/* !/var/.htaccess +/vendor diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a4d7ccf5c6..a00a72467d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,58 @@ +0.1.0-alpha90 +============= + * Service layer implementation: + * Created the Admin Shopping Cart Service + * Created the Create Shopping Cart Items Service + * Created the Create Shopping Cart Shipping Address Service + * Created the Create Shopping Cart Billing Address Service + * Created the Service Layer for Orders + * Created CRUD service & APIs to manage options for configurable products + * Created CRUD service & APIs to manage options for bundle products + * Fixed bugs: + * Fixed an issue where adding a customer address with an invalid value of the custom address attribute caused a fatal error in SOAP + * Fixed an issue where the wrong FedEx rates were displayed + * Fixed an issue where the Bill Me Later option did not work in Payflow payment methods + * Fixed an issue where order comments were broken for orders placed with Authorize.net + * Fixed the naming of the My Account -> Recurring Payment page + * Fixed a UI elements issue in the disabled Magento_PayPalRecurringPayment and Magento_RecurringPayment modules + * Fixed an issue where it was impossible to save configuration of a configurable product when adding it to an order in the Admin panel + * Fixed an issue where the Select a store page was displayed during admin order creation when the Single Store mode was enabled + * Fixed an issue when an exception was thrown when attempting to open the Customer Account page if the Recently Viewed widget was configured for the store + * Updated the content of the Privacy Policy page + * Fixed an issue where it was possible to update a tax rate using the POST http method + * Fixed an issue where it was impossible to update Inventory Qty for a SKU using API + * Fixed a JavaScript syntax error on the Create New Customer page + * Fixed an issue where it was impossible to add new sample while creating a downloadable product + * Fixed a JavaScript which appeared when clicking the Add New Address button in the Address Book on the storefront + * Fixed an issue where it was possible to update Tax Rules using the PUT http method which is supposed to be used for create operation only + * Fixed an issue where it was possible to create a Tax Rule specifying a product tax class instead of a customer tax class and vice versa + * Fixed an issue with making websiteId a mandatory field when updating a customer using REST + * Fixed an issue where the default value was not applied after clicking the 'Use default' link for a product price field in the catalog in the Admin panel + * Fixed an issue where the price update mass action could not be performed + * Fixed a JS error in the cross-sells product settings in the Admin panel + * Added the following functional tests: + * Mass Delete Backend Customer + * Moderate Product Review + * Framework improvements: + * Added the ability to access admin functionality using admin user login for mobile + * Refactored and unified Access Control List (ACL) to make it more consistent + * Created a Cookie Manager (a cookie management class) + * Changes in functional tests: + * Enabled the CustomerMetadataService tests for SOAP + * Themes update: + * Fixed issues in the Blank theme + * Implemented improvements for the Blank theme, core templates and Storefront UI Library + * Modularity: + * Created the Notification library component and made it possible to disable the AdminNotification module + * Made it possible to disable the SendToFriend module + * Created an optional ConfigurableImportExport module to remove dependency between the CatalogImportExport and ConfigurableProduct modules + * Created an optional GroupedImportExport module to remove dependency between the CatalogImportExport and GroupedProduct modules + * Introduce search library: + * Created a Search request configuration + * Created a Query object structure from the XML declaration + * Composer Integration: + * Added support for using 3rd-party components as Composer packages + 0.1.0-alpha89 ============= * Fixed bugs: diff --git a/README.md b/README.md index fe79310ea4c..2b7d837ea17 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ All Submissions you make to Magento, an eBay Inc. company (“Magentoâ€) throug 1. You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submissionâ€) you submit through GitHub. 2. Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. +3. You agree to the X.commerce Agreement found here: https://www.x.com/developers/x.commerce/x.commerce-user-agreement. diff --git a/app/autoload.php b/app/autoload.php index f2ab699eefe..073340091ce 100644 --- a/app/autoload.php +++ b/app/autoload.php @@ -23,5 +23,10 @@ * @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) */ +$vendorDir = require __DIR__ . '/etc/vendor_path.php'; +$vendorAutoload = __DIR__ . '/../' . $vendorDir . '/autoload.php'; +if (file_exists($vendorAutoload)) { + require_once $vendorAutoload; +} require_once __DIR__ . '/../lib/internal/Magento/Framework/Autoload/IncludePath.php'; spl_autoload_register([new \Magento\Framework\Autoload\IncludePath(), 'load']); diff --git a/app/bootstrap.php b/app/bootstrap.php index f9b998c6bce..31abb9bdfa5 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -30,9 +30,9 @@ error_reporting(E_ALL); umask(0); /* PHP version validation */ -if (version_compare(phpversion(), '5.4.0', '<') === true) { +if (version_compare(phpversion(), '5.4.11', '<') === true) { if (PHP_SAPI == 'cli') { - echo 'Magento supports PHP 5.4.0 or newer. Please read http://www.magento.com/install.'; + echo 'Magento supports PHP 5.4.11 or newer. Please read http://www.magento.com/install.'; } else { echo <<<HTML <div style="font:12px/1.35em arial, helvetica, sans-serif;"> @@ -40,7 +40,7 @@ if (version_compare(phpversion(), '5.4.0', '<') === true) { <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> Whoops, it looks like you have an invalid PHP version.</h3> </div> - <p>Magento supports PHP 5.4.0 or newer. + <p>Magento supports PHP 5.4.11 or newer. <a href="http://www.magento.com/install" target="">Find out</a> how to install Magento using PHP-CGI as a work-around. </p> @@ -60,7 +60,6 @@ define('BP', dirname(__DIR__)); * Require necessary files */ require_once BP . '/app/functions.php'; - require_once __DIR__ . '/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array(BP . '/app/code', BP . '/lib/internal')); $classMapPath = BP . '/var/classmap.ser'; diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php index e227a878d8c..a3be2bc9cce 100644 --- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php +++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php @@ -25,6 +25,8 @@ */ namespace Magento\AdminNotification\Block\Grid\Renderer; +use \Magento\Framework\Notification\MessageInterface; + class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** @@ -58,21 +60,21 @@ class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra $value = ''; switch ($row->getData($this->getColumn()->getIndex())) { - case \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL: + case MessageInterface::SEVERITY_CRITICAL: $class = 'critical'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR: + case MessageInterface::SEVERITY_MAJOR: $class = 'major'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MAJOR); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR: + case MessageInterface::SEVERITY_MINOR: $class = 'minor'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MINOR); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE: + case MessageInterface::SEVERITY_NOTICE: $class = 'notice'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE); break; } return '<span class="grid-severity-' . $class . '"><span>' . $value . '</span></span>'; diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 19695d3a9e4..9af0a88bfcc 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -70,14 +70,14 @@ class Messages extends \Magento\Backend\Block\Template /** * Retrieve message list * - * @return \Magento\AdminNotification\Model\System\MessageInterface[] + * @return \Magento\Framework\Notification\MessageInterface[] */ public function getLastCritical() { $items = array_values($this->_messages->getItems()); if (isset( $items[0] - ) && $items[0]->getSeverity() == \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL + ) && $items[0]->getSeverity() == \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL ) { return $items[0]; } @@ -92,7 +92,7 @@ class Messages extends \Magento\Backend\Block\Template public function getCriticalCount() { return $this->_messages->getCountBySeverity( - \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL ); } @@ -104,7 +104,7 @@ class Messages extends \Magento\Backend\Block\Template public function getMajorCount() { return $this->_messages->getCountBySeverity( - \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR + \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR ); } diff --git a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php index fbc13f17552..e5e88769696 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php @@ -17,13 +17,13 @@ * 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\AdminNotification\Block\System\Messages; -use Magento\AdminNotification\Model\System\MessageInterface; +use Magento\Framework\Notification\MessageInterface; class UnreadMessagePopup extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php index 7e762b79a6e..e620d1472a6 100644 --- a/app/code/Magento/AdminNotification/Model/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Inbox.php @@ -23,6 +23,9 @@ */ namespace Magento\AdminNotification\Model; +use \Magento\Framework\Notification\MessageInterface; +use \Magento\Framework\Notification\NotifierInterface; + /** * AdminNotification Inbox model * @@ -45,16 +48,8 @@ namespace Magento\AdminNotification\Model; * * @author Magento Core Team <core@magentocommerce.com> */ -class Inbox extends \Magento\Framework\Model\AbstractModel +class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface { - const SEVERITY_CRITICAL = 1; - - const SEVERITY_MAJOR = 2; - - const SEVERITY_MINOR = 3; - - const SEVERITY_NOTICE = 4; - /** * @return void */ @@ -72,10 +67,10 @@ class Inbox extends \Magento\Framework\Model\AbstractModel public function getSeverities($severity = null) { $severities = array( - self::SEVERITY_CRITICAL => __('critical'), - self::SEVERITY_MAJOR => __('major'), - self::SEVERITY_MINOR => __('minor'), - self::SEVERITY_NOTICE => __('notice') + MessageInterface::SEVERITY_CRITICAL => __('critical'), + MessageInterface::SEVERITY_MAJOR => __('major'), + MessageInterface::SEVERITY_MINOR => __('minor'), + MessageInterface::SEVERITY_NOTICE => __('notice') ); if (!is_null($severity)) { @@ -118,7 +113,8 @@ class Inbox extends \Magento\Framework\Model\AbstractModel */ public function parse(array $data) { - return $this->getResource()->parse($this, $data); + $this->getResource()->parse($this, $data); + return $this; } /** @@ -167,7 +163,7 @@ class Inbox extends \Magento\Framework\Model\AbstractModel */ public function addCritical($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_CRITICAL, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_CRITICAL, $title, $description, $url, $isInternal); return $this; } @@ -182,7 +178,7 @@ class Inbox extends \Magento\Framework\Model\AbstractModel */ public function addMajor($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_MAJOR, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_MAJOR, $title, $description, $url, $isInternal); return $this; } @@ -197,7 +193,7 @@ class Inbox extends \Magento\Framework\Model\AbstractModel */ public function addMinor($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_MINOR, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_MINOR, $title, $description, $url, $isInternal); return $this; } @@ -212,7 +208,7 @@ class Inbox extends \Magento\Framework\Model\AbstractModel */ public function addNotice($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_NOTICE, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_NOTICE, $title, $description, $url, $isInternal); return $this; } } diff --git a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php index 870c60a0c1a..48086ca6ec0 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php @@ -54,7 +54,7 @@ class Critical extends \Magento\Framework\Model\Resource\Db\Collection\AbstractC array('neq' => 1) )->addFieldToFilter( 'severity', - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setPageSize( 1 ); diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php index 8e44afd3851..bea61d7a1c4 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php @@ -17,7 +17,7 @@ * 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) */ @@ -28,7 +28,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * System message list * - * @var \Magento\AdminNotification\Model\System\MessageList + * @var \Magento\Framework\Notification\MessageList */ protected $_messageList; @@ -44,7 +44,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\AdminNotification\Model\System\MessageList $messageList + * @param \Magento\Framework\Notification\MessageList $messageList * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -53,7 +53,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\AdminNotification\Model\System\MessageList $messageList, + \Magento\Framework\Notification\MessageList $messageList, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php index c848602c9de..444e85dfa2e 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php @@ -17,7 +17,7 @@ * 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) */ @@ -28,7 +28,7 @@ class Synchronized extends \Magento\AdminNotification\Model\Resource\System\Mess /** * Unread message list * - * @var \Magento\AdminNotification\Model\System\MessageInterface[] + * @var \Magento\Framework\Notification\MessageInterface[] */ protected $_unreadMessages = array(); @@ -74,7 +74,7 @@ class Synchronized extends \Magento\AdminNotification\Model\Resource\System\Mess /** * Retrieve list of unread messages * - * @return \Magento\AdminNotification\Model\System\MessageInterface[] + * @return \Magento\Framework\Notification\MessageInterface[] */ public function getUnread() { diff --git a/app/code/Magento/AdminNotification/Model/System/Message.php b/app/code/Magento/AdminNotification/Model/System/Message.php index d4588cf27e1..47014047848 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/System/Message.php @@ -17,13 +17,13 @@ * 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\AdminNotification\Model\System; -class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\AdminNotification\Model\System\MessageInterface +class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Notification\MessageInterface { /** * @return void diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 2ede00eb20d..92cc992a3b3 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class Baseurl implements \Magento\AdminNotification\Model\System\MessageInterface +class Baseurl implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Framework\UrlInterface diff --git a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php index a7f57b85e21..75154b6ad9c 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class CacheOutdated implements \Magento\AdminNotification\Model\System\MessageInterface +class CacheOutdated implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Framework\UrlInterface @@ -124,6 +124,6 @@ class CacheOutdated implements \Magento\AdminNotification\Model\System\MessageIn */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL; } } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php index 5e1c628a00d..515b60a1229 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message\Media; -abstract class AbstractSynchronization implements \Magento\AdminNotification\Model\System\MessageInterface +abstract class AbstractSynchronization implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Core\Model\File\Storage\Flag @@ -94,6 +94,6 @@ abstract class AbstractSynchronization implements \Magento\AdminNotification\Mod */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; } } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php index 6a67afb6d0f..be463235215 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class Security implements \Magento\AdminNotification\Model\System\MessageInterface +class Security implements \Magento\Framework\Notification\MessageInterface { /** * Cache key for saving verification result @@ -160,6 +160,6 @@ class Security implements \Magento\AdminNotification\Model\System\MessageInterfa */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL; } } diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index d6f84501f54..ebd21d9c35d 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-admin-notification", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml b/app/code/Magento/AdminNotification/etc/acl.xml similarity index 95% rename from app/code/Magento/AdminNotification/etc/adminhtml/acl.xml rename to app/code/Magento/AdminNotification/etc/acl.xml index 86839ec9013..46059d5147d 100644 --- a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml +++ b/app/code/Magento/AdminNotification/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml index 3c16d79e9a5..9c8ba85f63d 100644 --- a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml +++ b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml @@ -24,13 +24,12 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\AdminNotification\Model\System\MessageList"> + <type name="Magento\Framework\Notification\MessageList"> <arguments> <argument name="messages" xsi:type="array"> <item name="baseurl" xsi:type="string">Magento\AdminNotification\Model\System\Message\Baseurl</item> <item name="security" xsi:type="string">Magento\AdminNotification\Model\System\Message\Security</item> <item name="cacheOutdated" xsi:type="string">Magento\AdminNotification\Model\System\Message\CacheOutdated</item> - <item name="survey" xsi:type="string">Magento\AdminNotification\Model\System\Message\Survey</item> <item name="media_synchronization_error" xsi:type="string">Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error</item> <item name="media_synchronization_success" xsi:type="string">Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success</item> </argument> diff --git a/app/code/Magento/AdminNotification/etc/di.xml b/app/code/Magento/AdminNotification/etc/di.xml new file mode 100644 index 00000000000..a6372146ba8 --- /dev/null +++ b/app/code/Magento/AdminNotification/etc/di.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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Framework\Notification\NotifierList"> + <arguments> + <argument name="notifiers" xsi:type="array"> + <item name="adminnotification" xsi:type="string">Magento\AdminNotification\Model\Inbox</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js index 710f9b6561a..b5710b6b028 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js +++ b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js @@ -55,18 +55,6 @@ define([ }); $(document).ready(function(){ - $('body').on('surveyYes surveyNo', function(e, data) { - if (e.type == 'surveyYes') { - var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1'); - win.focus(); - } - $.ajax({ - url: data.surveyAction, - type: 'post', - data: {decision: data.decision} - }) - }); - $('#system_messages .message-system-short .error').on('click', function() { $('#message-system-all').systemMessageDialog('open', 1); }); @@ -75,4 +63,4 @@ define([ }); }); -}); \ No newline at end of file +}); diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php new file mode 100644 index 00000000000..2e131fb3e14 --- /dev/null +++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.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\Authorization\Model\Acl; + +use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; +use Magento\Authorization\Model\Resource\Rules\CollectionFactory as RulesCollectionFactory; +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\Acl\Builder as AclBuilder; +use Magento\Framework\Exception\AuthorizationException; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Logger; + +/** + * Permission tree retriever + */ +class AclRetriever +{ + const PERMISSION_ANONYMOUS = 'anonymous'; + const PERMISSION_SELF = 'self'; + + /** @var Logger */ + protected $logger; + + /** @var RulesCollectionFactory */ + protected $rulesCollectionFactory; + + /** @var AclBuilder */ + protected $aclBuilder; + + /** @var RoleCollectionFactory */ + protected $roleCollectionFactory; + + /** + * Initialize dependencies. + * + * @param AclBuilder $aclBuilder + * @param RoleCollectionFactory $roleCollectionFactory + * @param RulesCollectionFactory $rulesCollectionFactory + * @param Logger $logger + */ + public function __construct( + AclBuilder $aclBuilder, + RoleCollectionFactory $roleCollectionFactory, + RulesCollectionFactory $rulesCollectionFactory, + Logger $logger + ) { + $this->logger = $logger; + $this->rulesCollectionFactory = $rulesCollectionFactory; + $this->aclBuilder = $aclBuilder; + $this->roleCollectionFactory = $roleCollectionFactory; + } + + /** + * Get a list of available resources using user details + * + * @param string $userType + * @param int $userId + * @return string[] + * @throws AuthorizationException + * @throws LocalizedException + */ + public function getAllowedResourcesByUser($userType, $userId) + { + if ($userType == UserContextInterface::USER_TYPE_GUEST) { + return [self::PERMISSION_ANONYMOUS]; + } elseif ($userType == UserContextInterface::USER_TYPE_CUSTOMER) { + return [self::PERMISSION_SELF]; + } + try { + $role = $this->_getUserRole($userType, $userId); + if (!$role) { + throw new AuthorizationException('The role associated with the specified user cannot be found.'); + } + $allowedResources = $this->getAllowedResourcesByRole($role->getId()); + } catch (AuthorizationException $e) { + throw $e; + } catch (\Exception $e) { + $this->logger->logException($e); + throw new LocalizedException( + 'Error happened while getting a list of allowed resources. Check exception log for details.' + ); + } + return $allowedResources; + } + + /** + * Get a list of available resource using user role id + * + * @param string $roleId + * @return string[] + */ + public function getAllowedResourcesByRole($roleId) + { + $allowedResources = []; + $rulesCollection = $this->rulesCollectionFactory->create(); + $rulesCollection->getByRoles($roleId)->load(); + $acl = $this->aclBuilder->getAcl(); + /** @var \Magento\Authorization\Model\Rules $ruleItem */ + foreach ($rulesCollection->getItems() as $ruleItem) { + $resourceId = $ruleItem->getResourceId(); + if ($acl->has($resourceId) && $acl->isAllowed($roleId, $resourceId)) { + $allowedResources[] = $resourceId; + } + } + return $allowedResources; + } + + /** + * Identify user role from user identifier. + * + * @param string $userType + * @param int $userId + * @return \Magento\Authorization\Model\Role|bool False if no role associated with provided user was found. + * @throws \LogicException + */ + protected function _getUserRole($userType, $userId) + { + if (!$this->_canRoleBeCreatedForUserType($userType)) { + throw new \LogicException( + "The role with user type '{$userType}' does not exist and cannot be created" + ); + } + $roleCollection = $this->roleCollectionFactory->create(); + /** @var Role $role */ + $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem(); + return $role->getId() ? $role : false; + } + + /** + * Check if the role can be associated with user having provided user type. + * + * Roles can be created for integrations and admin users only. + * + * @param int $userType + * @return bool + */ + protected function _canRoleBeCreatedForUserType($userType) + { + return ($userType == UserContextInterface::USER_TYPE_INTEGRATION) + || ($userType == UserContextInterface::USER_TYPE_ADMIN); + } +} diff --git a/app/code/Magento/User/Model/Acl/Loader/Role.php b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php similarity index 79% rename from app/code/Magento/User/Model/Acl/Loader/Role.php rename to app/code/Magento/Authorization/Model/Acl/Loader/Role.php index 4054deab325..dc82131a87f 100644 --- a/app/code/Magento/User/Model/Acl/Loader/Role.php +++ b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php @@ -21,10 +21,10 @@ * @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\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; -use Magento\User\Model\Acl\Role\Group as RoleGroup; -use Magento\User\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\User as RoleUser; class Role implements \Magento\Framework\Acl\LoaderInterface { @@ -34,23 +34,23 @@ class Role implements \Magento\Framework\Acl\LoaderInterface protected $_resource; /** - * @var \Magento\User\Model\Acl\Role\GroupFactory + * @var \Magento\Authorization\Model\Acl\Role\GroupFactory */ protected $_groupFactory; /** - * @var \Magento\User\Model\Acl\Role\UserFactory + * @var \Magento\Authorization\Model\Acl\Role\UserFactory */ protected $_roleFactory; /** - * @param \Magento\User\Model\Acl\Role\GroupFactory $groupFactory - * @param \Magento\User\Model\Acl\Role\UserFactory $roleFactory + * @param \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory + * @param \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory * @param \Magento\Framework\App\Resource $resource */ public function __construct( - \Magento\User\Model\Acl\Role\GroupFactory $groupFactory, - \Magento\User\Model\Acl\Role\UserFactory $roleFactory, + \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory, + \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory, \Magento\Framework\App\Resource $resource ) { $this->_resource = $resource; @@ -66,7 +66,7 @@ class Role implements \Magento\Framework\Acl\LoaderInterface */ public function populateAcl(\Magento\Framework\Acl $acl) { - $roleTableName = $this->_resource->getTableName('admin_role'); + $roleTableName = $this->_resource->getTableName('authorization_role'); $adapter = $this->_resource->getConnection('core_read'); $select = $adapter->select()->from($roleTableName)->order('tree_level'); diff --git a/app/code/Magento/User/Model/Acl/Loader/Rule.php b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.php similarity index 95% rename from app/code/Magento/User/Model/Acl/Loader/Rule.php rename to app/code/Magento/Authorization/Model/Acl/Loader/Rule.php index 25230c259ff..8a2953d65d1 100644 --- a/app/code/Magento/User/Model/Acl/Loader/Rule.php +++ b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.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\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; class Rule implements \Magento\Framework\Acl\LoaderInterface { @@ -53,7 +53,7 @@ class Rule implements \Magento\Framework\Acl\LoaderInterface */ public function populateAcl(\Magento\Framework\Acl $acl) { - $ruleTable = $this->_resource->getTableName("admin_rule"); + $ruleTable = $this->_resource->getTableName("authorization_rule"); $adapter = $this->_resource->getConnection('core_read'); diff --git a/app/code/Magento/User/Model/Acl/Role/Generic.php b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php similarity index 93% rename from app/code/Magento/User/Model/Acl/Role/Generic.php rename to app/code/Magento/Authorization/Model/Acl/Role/Generic.php index 80a8b3f6cde..3b39cf76eaa 100644 --- a/app/code/Magento/User/Model/Acl/Role/Generic.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php @@ -21,10 +21,10 @@ * @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\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** - * User acl role + * Generic acl role */ class Generic extends \Zend_Acl_Role { diff --git a/app/code/Magento/User/Model/Acl/Role/Group.php b/app/code/Magento/Authorization/Model/Acl/Role/Group.php similarity index 90% rename from app/code/Magento/User/Model/Acl/Role/Group.php rename to app/code/Magento/Authorization/Model/Acl/Role/Group.php index 08b5df20688..7c2346d4f59 100644 --- a/app/code/Magento/User/Model/Acl/Role/Group.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/Group.php @@ -21,12 +21,12 @@ * @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\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** * Acl Group model */ -class Group extends \Magento\User\Model\Acl\Role\Generic +class Group extends \Magento\Authorization\Model\Acl\Role\Generic { /** * All the group roles are prepended by G diff --git a/app/code/Magento/User/Model/Acl/Role/User.php b/app/code/Magento/Authorization/Model/Acl/Role/User.php similarity index 90% rename from app/code/Magento/User/Model/Acl/Role/User.php rename to app/code/Magento/Authorization/Model/Acl/Role/User.php index 4d37e7ca89a..69383609782 100644 --- a/app/code/Magento/User/Model/Acl/Role/User.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/User.php @@ -21,12 +21,12 @@ * @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\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** * User acl role */ -class User extends \Magento\User\Model\Acl\Role\Generic +class User extends \Magento\Authorization\Model\Acl\Role\Generic { /** * All the user roles are prepended by U diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php new file mode 100644 index 00000000000..5707ac12a32 --- /dev/null +++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php @@ -0,0 +1,129 @@ +<?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\Authorization\Model; + +class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface +{ + /** + * @var UserContextInterface[] + */ + protected $userContexts = []; + + /** + * @var UserContextInterface|bool + */ + protected $chosenUserContext; + + /** + * Register user contexts. + * + * @param UserContextInterface[] $userContexts + */ + public function __construct($userContexts = []) + { + $userContexts = array_filter( + $userContexts, + function ($item) { + return isset($item['type']) && isset($item['sortOrder']); + } + ); + + uasort($userContexts, array($this, 'compareContextsSortOrder')); + + foreach ($userContexts as $userContext) { + $this->add($userContext['type']); + } + } + + /** + * Add user context. + * + * @param UserContextInterface $userContext + * @return CompositeUserContext + */ + protected function add(UserContextInterface $userContext) + { + $this->userContexts[] = $userContext; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + return $this->getUserContext() ? $this->getUserContext()->getUserId() : null; + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + return $this->getUserContext() ? $this->getUserContext()->getUserType() : null; + } + + /** + * Retrieve user context + * + * @return UserContextInterface|bool False if none of the registered user contexts can identify user type + */ + protected function getUserContext() + { + if (is_null($this->chosenUserContext)) { + /** @var UserContextInterface $userContext */ + foreach ($this->userContexts as $userContext) { + if ($userContext->getUserType() && !is_null($userContext->getUserId())) { + $this->chosenUserContext = $userContext; + break; + } + } + if (is_null($this->chosenUserContext)) { + $this->chosenUserContext = false; + } + } + return $this->chosenUserContext; + } + + /** + * Compare contexts sortOrder + * + * @param array $contextDataFirst + * @param array $contextDataSecond + * @return int + */ + protected function compareContextsSortOrder($contextDataFirst, $contextDataSecond) + { + if ((int)$contextDataFirst['sortOrder'] == (int)$contextDataSecond['sortOrder']) { + return 0; + } + + if ((int)$contextDataFirst['sortOrder'] < (int)$contextDataSecond['sortOrder']) { + return -1; + } else { + return 1; + } + } +} diff --git a/app/code/Magento/User/Model/Resource/Permissions/Collection.php b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php similarity index 88% rename from app/code/Magento/User/Model/Resource/Permissions/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php index 2ca9f8d6506..4fca3cee80e 100644 --- a/app/code/Magento/User/Model/Resource/Permissions/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.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\User\Model\Resource\Permissions; +namespace Magento\Authorization\Model\Resource\Permissions; /** * Admin permissions collection @@ -37,6 +37,6 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules'); } } diff --git a/app/code/Magento/User/Model/Resource/Role.php b/app/code/Magento/Authorization/Model/Resource/Role.php similarity index 76% rename from app/code/Magento/User/Model/Resource/Role.php rename to app/code/Magento/Authorization/Model/Resource/Role.php index ea45c024f84..e79cf181e42 100644 --- a/app/code/Magento/User/Model/Resource/Role.php +++ b/app/code/Magento/Authorization/Model/Resource/Role.php @@ -21,22 +21,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\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; -use Magento\User\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\Acl\Role\User as RoleUser; /** * Admin role resource model */ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb { - /** - * Users table - * - * @var string - */ - protected $_usersTable; - /** * Rule table * @@ -78,10 +71,8 @@ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _construct() { - $this->_init('admin_role', 'role_id'); - - $this->_usersTable = $this->getTable('admin_user'); - $this->_ruleTable = $this->getTable('admin_rule'); + $this->_init('authorization_role', 'role_id'); + $this->_ruleTable = $this->getTable('authorization_rule'); } /** @@ -139,7 +130,6 @@ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $role) { - $this->_updateRoleUsersAcl($role); $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Backend\Block\Menu::CACHE_TAGS)); return $this; } @@ -164,47 +154,21 @@ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Get role users * - * @param \Magento\User\Model\Role $role + * @param \Magento\Authorization\Model\Role $role * @return array */ - public function getRoleUsers(\Magento\User\Model\Role $role) + public function getRoleUsers(\Magento\Authorization\Model\Role $role) { $read = $this->_getReadAdapter(); $binds = array('role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE); - $select = $read->select()->from( - $this->getMainTable(), - array('user_id') - )->where( - 'parent_id = :role_id' - )->where( - 'role_type = :role_type' - )->where( - 'user_id > 0' - ); + $select = $read->select() + ->from($this->getMainTable(), array('user_id')) + ->where('parent_id = :role_id') + ->where('role_type = :role_type') + ->where('user_id > 0'); return $read->fetchCol($select, $binds); } - - /** - * Update role users ACL - * - * @param \Magento\User\Model\Role $role - * @return bool - */ - private function _updateRoleUsersAcl(\Magento\User\Model\Role $role) - { - $write = $this->_getWriteAdapter(); - $users = $this->getRoleUsers($role); - $rowsCount = 0; - - if (sizeof($users) > 0) { - $bind = array('reload_acl_flag' => 1); - $where = array('user_id IN(?)' => $users); - $rowsCount = $write->update($this->_usersTable, $bind, $where); - } - - return $rowsCount > 0; - } } diff --git a/app/code/Magento/User/Model/Resource/Role/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Collection.php similarity index 89% rename from app/code/Magento/User/Model/Resource/Role/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Role/Collection.php index 3cce8f1b699..98e25949f8a 100644 --- a/app/code/Magento/User/Model/Resource/Role/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Role/Collection.php @@ -21,9 +21,9 @@ * @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\User\Model\Resource\Role; +namespace Magento\Authorization\Model\Resource\Role; -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; /** * Admin role collection @@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Role', 'Magento\User\Model\Resource\Role'); + $this->_init('Magento\Authorization\Model\Role', 'Magento\Authorization\Model\Resource\Role'); } /** diff --git a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php similarity index 85% rename from app/code/Magento/User/Model/Resource/Role/Grid/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php index a111d9b1d60..9355017b41d 100644 --- a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.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\User\Model\Resource\Role\Grid; +namespace Magento\Authorization\Model\Resource\Role\Grid; -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; /** * Admin role data grid collection */ -class Collection extends \Magento\User\Model\Resource\Role\Collection +class Collection extends \Magento\Authorization\Model\Resource\Role\Collection { /** * Prepare select for load diff --git a/app/code/Magento/User/Model/Resource/Rules.php b/app/code/Magento/Authorization/Model/Resource/Rules.php similarity index 95% rename from app/code/Magento/User/Model/Resource/Rules.php rename to app/code/Magento/Authorization/Model/Resource/Rules.php index 1a82b9a4982..478eff8864c 100644 --- a/app/code/Magento/User/Model/Resource/Rules.php +++ b/app/code/Magento/Authorization/Model/Resource/Rules.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\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; /** * Admin rule resource model @@ -80,17 +80,17 @@ class Rules extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _construct() { - $this->_init('admin_rule', 'rule_id'); + $this->_init('authorization_rule', 'rule_id'); } /** * Save ACL resources * - * @param \Magento\User\Model\Rules $rule + * @param \Magento\Authorization\Model\Rules $rule * @return void * @throws \Magento\Framework\Model\Exception */ - public function saveRel(\Magento\User\Model\Rules $rule) + public function saveRel(\Magento\Authorization\Model\Rules $rule) { try { $adapter = $this->_getWriteAdapter(); diff --git a/app/code/Magento/User/Model/Resource/Rules/Collection.php b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.php similarity index 91% rename from app/code/Magento/User/Model/Resource/Rules/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Rules/Collection.php index 8814282b440..a0778882587 100644 --- a/app/code/Magento/User/Model/Resource/Rules/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.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\User\Model\Resource\Rules; +namespace Magento\Authorization\Model\Resource\Rules; /** * Rules collection @@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules'); } /** diff --git a/app/code/Magento/User/Model/Resource/Setup.php b/app/code/Magento/Authorization/Model/Resource/Setup.php similarity index 69% rename from app/code/Magento/User/Model/Resource/Setup.php rename to app/code/Magento/Authorization/Model/Resource/Setup.php index da215bd1e58..e66ee4ec3dd 100644 --- a/app/code/Magento/User/Model/Resource/Setup.php +++ b/app/code/Magento/Authorization/Model/Resource/Setup.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\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; /** * Resource Setup Model @@ -34,49 +34,49 @@ class Setup extends \Magento\Framework\Module\Setup /** * Role model factory * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleCollectionFactory; /** - * Factory for user rules model + * Factory for rules model * - * @var \Magento\User\Model\RulesFactory + * @var \Magento\Authorization\Model\RulesFactory */ protected $_rulesCollectionFactory; /** * Role model factory * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; /** * Rules model factory * - * @var \Magento\User\Model\RulesFactory + * @var \Magento\Authorization\Model\RulesFactory */ protected $_rulesFactory; /** * @param \Magento\Framework\Module\Setup\Context $context * @param string $resourceName - * @param \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory - * @param \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory - * @param \Magento\User\Model\RoleFactory $roleFactory - * @param \Magento\User\Model\RulesFactory $rulesFactory + * @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory + * @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RulesFactory $rulesFactory * @param string $moduleName * @param string $connectionName */ public function __construct( \Magento\Framework\Module\Setup\Context $context, $resourceName, - \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory, - \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, - \Magento\User\Model\RoleFactory $roleFactory, - \Magento\User\Model\RulesFactory $rulesFactory, - $moduleName = 'Magento_User', + \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory, + \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RulesFactory $rulesFactory, + $moduleName = 'Magento_Authorization', $connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION ) { $this->_roleCollectionFactory = $roleCollectionFactory; @@ -89,7 +89,7 @@ class Setup extends \Magento\Framework\Module\Setup /** * Creates role collection * - * @return \Magento\User\Model\Resource\Role\Collection + * @return \Magento\Authorization\Model\Resource\Role\Collection */ public function createRoleCollection() { @@ -99,7 +99,7 @@ class Setup extends \Magento\Framework\Module\Setup /** * Creates rules collection * - * @return \Magento\User\Model\Resource\Rules\Collection + * @return \Magento\Authorization\Model\Resource\Rules\Collection */ public function createRulesCollection() { @@ -109,7 +109,7 @@ class Setup extends \Magento\Framework\Module\Setup /** * Creates role model * - * @return \Magento\User\Model\Role + * @return \Magento\Authorization\Model\Role */ public function createRole() { @@ -119,7 +119,7 @@ class Setup extends \Magento\Framework\Module\Setup /** * Creates rules model * - * @return \Magento\User\Model\Rules + * @return \Magento\Authorization\Model\Rules */ public function createRules() { diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/Authorization/Model/Role.php similarity index 58% rename from app/code/Magento/User/Model/Role.php rename to app/code/Magento/Authorization/Model/Role.php index ae3bc63f634..68d9f927631 100644 --- a/app/code/Magento/User/Model/Role.php +++ b/app/code/Magento/Authorization/Model/Role.php @@ -21,57 +21,49 @@ * @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\User\Model; +namespace Magento\Authorization\Model; /** * Admin Role Model * - * @method \Magento\User\Model\Resource\Role _getResource() - * @method \Magento\User\Model\Resource\Role getResource() + * @method \Magento\Authorization\Model\Resource\Role _getResource() + * @method \Magento\Authorization\Model\Resource\Role getResource() * @method int getParentId() - * @method \Magento\User\Model\Role setParentId(int $value) + * @method \Magento\Authorization\Model\Role setParentId(int $value) * @method int getTreeLevel() - * @method \Magento\User\Model\Role setTreeLevel(int $value) + * @method \Magento\Authorization\Model\Role setTreeLevel(int $value) * @method int getSortOrder() - * @method \Magento\User\Model\Role setSortOrder(int $value) + * @method \Magento\Authorization\Model\Role setSortOrder(int $value) * @method string getRoleType() - * @method \Magento\User\Model\Role setRoleType(string $value) + * @method \Magento\Authorization\Model\Role setRoleType(string $value) * @method int getUserId() - * @method \Magento\User\Model\Role setUserId(int $value) + * @method \Magento\Authorization\Model\Role setUserId(int $value) * @method string getUserType() - * @method \Magento\User\Model\Role setUserType(string $value) + * @method \Magento\Authorization\Model\Role setUserType(string $value) * @method string getRoleName() - * @method \Magento\User\Model\Role setRoleName(string $value) + * @method \Magento\Authorization\Model\Role setRoleName(string $value) */ class Role extends \Magento\Framework\Model\AbstractModel { /** * @var string */ - protected $_eventPrefix = 'admin_roles'; - - /** - * @var \Magento\User\Model\Resource\Role\User\CollectionFactory - */ - protected $_userRolesFactory; + protected $_eventPrefix = 'authorization_roles'; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param Resource\Role\User\CollectionFactory $userRolesFactory - * @param Resource\Role $resource - * @param Resource\Role\Collection $resourceCollection + * @param \Magento\Authorization\Model\Resource\Role $resource + * @param \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory, - \Magento\User\Model\Resource\Role $resource, - \Magento\User\Model\Resource\Role\Collection $resourceCollection, + \Magento\Authorization\Model\Resource\Role $resource, + \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection, array $data = array() ) { - $this->_userRolesFactory = $userRolesFactory; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -81,7 +73,7 @@ class Role extends \Magento\Framework\Model\AbstractModel public function __sleep() { $properties = parent::__sleep(); - return array_diff($properties, array('_userRolesFactory', '_resource', '_resourceCollection')); + return array_diff($properties, array('_resource', '_resourceCollection')); } /** @@ -91,9 +83,8 @@ class Role extends \Magento\Framework\Model\AbstractModel { parent::__wakeup(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $this->_userRolesFactory = $objectManager->get('Magento\User\Model\Resource\Role\User\CollectionFactory'); - $this->_resource = $objectManager->get('Magento\User\Model\Resource\Role'); - $this->_resourceCollection = $objectManager->get('Magento\User\Model\Resource\Role\Collection'); + $this->_resource = $objectManager->get('Magento\Authorization\Model\Resource\Role'); + $this->_resourceCollection = $objectManager->get('Magento\Authorization\Model\Resource\Role\Collection'); } /** @@ -103,7 +94,7 @@ class Role extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\User\Model\Resource\Role'); + $this->_init('Magento\Authorization\Model\Resource\Role'); } /** @@ -117,16 +108,6 @@ class Role extends \Magento\Framework\Model\AbstractModel return $this; } - /** - * Retrieve users collection - * - * @return \Magento\User\Model\Resource\Role\User\Collection - */ - public function getUsersCollection() - { - return $this->_userRolesFactory->create(); - } - /** * Return users for role * diff --git a/app/code/Magento/User/Model/Rules.php b/app/code/Magento/Authorization/Model/Rules.php similarity index 68% rename from app/code/Magento/User/Model/Rules.php rename to app/code/Magento/Authorization/Model/Rules.php index abfa69254f8..8418ffaa3ff 100644 --- a/app/code/Magento/User/Model/Rules.php +++ b/app/code/Magento/Authorization/Model/Rules.php @@ -21,23 +21,24 @@ * @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\User\Model; + +namespace Magento\Authorization\Model; /** * Admin Rules Model * - * @method \Magento\User\Model\Resource\Rules _getResource() - * @method \Magento\User\Model\Resource\Rules getResource() + * @method \Magento\Authorization\Model\Resource\Rules _getResource() + * @method \Magento\Authorization\Model\Resource\Rules getResource() * @method int getRoleId() - * @method \Magento\User\Model\Rules setRoleId(int $value) + * @method \Magento\Authorization\Model\Rules setRoleId(int $value) * @method string getResourceId() - * @method \Magento\User\Model\Rules setResourceId(string $value) + * @method \Magento\Authorization\Model\Rules setResourceId(string $value) * @method string getPrivileges() - * @method \Magento\User\Model\Rules setPrivileges(string $value) + * @method \Magento\Authorization\Model\Rules setPrivileges(string $value) * @method int getAssertId() - * @method \Magento\User\Model\Rules setAssertId(int $value) + * @method \Magento\Authorization\Model\Rules setAssertId(int $value) * @method string getPermission() - * @method \Magento\User\Model\Rules setPermission(string $value) + * @method \Magento\Authorization\Model\Rules setPermission(string $value) */ class Rules extends \Magento\Framework\Model\AbstractModel { @@ -46,15 +47,15 @@ class Rules extends \Magento\Framework\Model\AbstractModel * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param Resource\Rules $resource - * @param Resource\Permissions\Collection $resourceCollection + * @param \Magento\Authorization\Model\Resource\Rules $resource + * @param \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\User\Model\Resource\Rules $resource, - \Magento\User\Model\Resource\Permissions\Collection $resourceCollection, + \Magento\Authorization\Model\Resource\Rules $resource, + \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection, array $data = array() ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -67,7 +68,7 @@ class Rules extends \Magento\Framework\Model\AbstractModel */ protected function _construct() { - $this->_init('Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Resource\Rules'); } /** diff --git a/app/code/Magento/Authz/Model/UserLocatorInterface.php b/app/code/Magento/Authorization/Model/UserContextInterface.php similarity index 76% rename from app/code/Magento/Authz/Model/UserLocatorInterface.php rename to app/code/Magento/Authorization/Model/UserContextInterface.php index 361e62e09ce..948eb755390 100644 --- a/app/code/Magento/Authz/Model/UserLocatorInterface.php +++ b/app/code/Magento/Authorization/Model/UserContextInterface.php @@ -21,24 +21,34 @@ * @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\Authz\Model; + +namespace Magento\Authorization\Model; /** * Interface for current user identification. */ -interface UserLocatorInterface +interface UserContextInterface { + /**#@+ + * User type + */ + const USER_TYPE_INTEGRATION = 1; + const USER_TYPE_ADMIN = 2; + const USER_TYPE_CUSTOMER = 3; + const USER_TYPE_GUEST = 4; + /**#@-*/ + /** * Identify current user ID. * - * @return int + * @return int|null */ public function getUserId(); /** - * Retrieve current user type (Admin, Customer, Guest, Integration). + * Retrieve current user type. * - * @return string + * @return int|null */ public function getUserType(); } diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json new file mode 100644 index 00000000000..a00c08d4b68 --- /dev/null +++ b/app/code/Magento/Authorization/composer.json @@ -0,0 +1,20 @@ +{ + "name": "magento/module-authorization", + "description": "Authorization module provides access to Magento ACL functionality.", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "version": "0.1.0-alpha90", + "extra": { + "map": [ + [ + "*", + "Magento/Authorization" + ] + ] + } +} diff --git a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php similarity index 69% rename from app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php rename to app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php index 013d4117f47..483a6ee18fc 100644 --- a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php +++ b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php @@ -21,30 +21,22 @@ * @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\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\UserContextInterface; /** * Save administrators group role and rules */ -/** @var \Magento\User\Model\Resource\Setup $this */ +/** @var \Magento\Authorization\Model\Resource\Setup $this */ -$roleCollection = $this->createRoleCollection()->addFieldToFilter( - 'parent_id', - 0 -)->addFieldToFilter( - 'tree_level', - 1 -)->addFieldToFilter( - 'role_type', - RoleGroup::ROLE_TYPE -)->addFieldToFilter( - 'user_id', - 0 -)->addFieldToFilter( - 'role_name', - 'Administrators' -); +$roleCollection = $this->createRoleCollection() + ->addFieldToFilter('parent_id', 0) + ->addFieldToFilter('tree_level', 1) + ->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE) + ->addFieldToFilter('user_id', 0) + ->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN) + ->addFieldToFilter('role_name', 'Administrators'); if ($roleCollection->count() == 0) { $admGroupRole = $this->createRole()->setData( @@ -54,6 +46,7 @@ if ($roleCollection->count() == 0) { 'sort_order' => 1, 'role_type' => RoleGroup::ROLE_TYPE, 'user_id' => 0, + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => 'Administrators' ) )->save(); @@ -64,13 +57,9 @@ if ($roleCollection->count() == 0) { } } -$rulesCollection = $this->createRulesCollection()->addFieldToFilter( - 'role_id', - $admGroupRole->getId() -)->addFieldToFilter( - 'resource_id', - 'all' -); +$rulesCollection = $this->createRulesCollection() + ->addFieldToFilter('role_id', $admGroupRole->getId()) + ->addFieldToFilter('resource_id', 'all'); if ($rulesCollection->count() == 0) { $this->createRules()->setData( @@ -82,7 +71,7 @@ if ($rulesCollection->count() == 0) { ) )->save(); } else { - /** @var \Magento\User\Model\Rules $rule */ + /** @var \Magento\Authorization\Model\Rules $rule */ foreach ($rulesCollection as $rule) { $rule->setData('resource_id', 'Magento_Adminhtml::all')->save(); } diff --git a/app/code/Magento/Authorization/etc/di.xml b/app/code/Magento/Authorization/etc/di.xml new file mode 100644 index 00000000000..afd3f40acd4 --- /dev/null +++ b/app/code/Magento/Authorization/etc/di.xml @@ -0,0 +1,47 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Authorization\Model\Role" shared="false" /> + <type name="Magento\Authorization\Model\Resource\Rules"> + <arguments> + <argument name="rootResource" xsi:type="object">Magento\Framework\Acl\RootResource\Proxy</argument> + <argument name="aclCache" xsi:type="object">Magento\Framework\Acl\Cache\Proxy</argument> + </arguments> + </type> + <type name="Magento\Framework\Module\Updater\SetupFactory"> + <arguments> + <argument name="resourceTypes" xsi:type="array"> + <item name="authorization_setup" xsi:type="string">Magento\Authorization\Model\Resource\Setup</item> + </argument> + </arguments> + </type> + <type name="Magento\Framework\Acl\Builder"> + <arguments> + <argument name="ruleLoader" xsi:type="object">Magento\Authorization\Model\Acl\Loader\Rule</argument> + <argument name="roleLoader" xsi:type="object">Magento\Authorization\Model\Acl\Loader\Role</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Authz/etc/di.xml b/app/code/Magento/Authorization/etc/module.xml similarity index 80% rename from app/code/Magento/Authz/etc/di.xml rename to app/code/Magento/Authorization/etc/module.xml index 324792fc21e..4224828dc06 100644 --- a/app/code/Magento/Authz/etc/di.xml +++ b/app/code/Magento/Authorization/etc/module.xml @@ -23,7 +23,10 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Authz\Service\AuthorizationV1Interface" type="Magento\Authz\Service\AuthorizationV1"/> - <preference for="Magento\Authz\Model\UserLocatorInterface" type="Magento\Authz\Model\UserLocator\Guest"/> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> + <module name="Magento_Authorization" schema_version="1.0.0.0" active="true"> + <depends> + <module name="Magento_Backend"/> + </depends> + </module> </config> diff --git a/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php new file mode 100644 index 00000000000..eb6661c9dc2 --- /dev/null +++ b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.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) + */ + +/* @var $installer \Magento\Framework\Module\Setup */ +$installer = $this; + +$installer->startSetup(); + +if ($installer->getConnection()->isTableExists($installer->getTable('admin_role'))) { + /** + * Rename existing 'admin_role' table into 'authorization_role' (to avoid forcing Magento re-installation) + * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline + */ + $installer->getConnection()->renameTable( + $installer->getTable('admin_role'), + $installer->getTable('authorization_role') + ); + +} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_role'))) { + /** + * Create table 'authorization_role' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('authorization_role') + )->addColumn( + 'role_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Role ID' + )->addColumn( + 'parent_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Parent Role ID' + )->addColumn( + 'tree_level', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role Tree Level' + )->addColumn( + 'sort_order', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role Sort Order' + )->addColumn( + 'role_type', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 1, + array('nullable' => false, 'default' => '0'), + 'Role Type' + )->addColumn( + 'user_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'User ID' + )->addColumn( + 'user_type', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 16, + array('nullable' => true, 'default' => null), + 'User Type' + )->addColumn( + 'role_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + array('nullable' => true, 'default' => null), + 'Role Name' + )->addIndex( + $installer->getIdxName('authorization_role', array('parent_id', 'sort_order')), + array('parent_id', 'sort_order') + )->addIndex( + $installer->getIdxName('authorization_role', array('tree_level')), + array('tree_level') + )->setComment( + 'Admin Role Table' + ); + $installer->getConnection()->createTable($table); +} + +if ($installer->getConnection()->isTableExists($installer->getTable('admin_rule'))) { + /** + * Rename existing 'admin_rule' table into 'authorization_rule' (to avoid forcing Magento re-installation) + * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline + */ + $installer->getConnection()->renameTable( + $installer->getTable('admin_rule'), + $installer->getTable('authorization_rule') + ); + +} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_rule'))) { + /** + * Create table 'authorization_rule' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('authorization_rule') + )->addColumn( + 'rule_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Rule ID' + )->addColumn( + 'role_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role ID' + )->addColumn( + 'resource_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array('nullable' => true, 'default' => null), + 'Resource ID' + )->addColumn( + 'privileges', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 20, + array('nullable' => true), + 'Privileges' + )->addColumn( + 'permission', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 10, + array(), + 'Permission' + )->addIndex( + $installer->getIdxName('authorization_rule', array('resource_id', 'role_id')), + array('resource_id', 'role_id') + )->addIndex( + $installer->getIdxName('authorization_rule', array('role_id', 'resource_id')), + array('role_id', 'resource_id') + )->addForeignKey( + $installer->getFkName('authorization_rule', 'role_id', 'authorization_role', 'role_id'), + 'role_id', + $installer->getTable('authorization_role'), + 'role_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->setComment( + 'Admin Rule Table' + ); + $installer->getConnection()->createTable($table); +} + +$installer->endSetup(); diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 8bcfa32014d..0398481a245 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -197,39 +197,10 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper implements Helpe * @param \Magento\Framework\Object $card * @param bool|float $amount * @param bool|string $exception + * @param bool|string $additionalMessage * @return bool|string */ public function getTransactionMessage( - $payment, - $requestType, - $lastTransactionId, - $card, - $amount = false, - $exception = false - ) { - return $this->getExtendedTransactionMessage( - $payment, - $requestType, - $lastTransactionId, - $card, - $amount, - $exception - ); - } - - /** - * Return message for gateway transaction request - * - * @param \Magento\Payment\Model\Info $payment - * @param string $requestType - * @param string $lastTransactionId - * @param \Magento\Framework\Object $card - * @param bool|float $amount - * @param bool|string $exception - * @param bool|string $additionalMessage - * @return bool|mixed - */ - public function getExtendedTransactionMessage( $payment, $requestType, $lastTransactionId, @@ -238,40 +209,27 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper implements Helpe $exception = false, $additionalMessage = false ) { + $message[] = __('Credit Card: xxxx-%1', $card->getCcLast4()); + if ($amount) { + $message[] = __('amount %1', $this->_formatPrice($payment, $amount)); + } $operation = $this->_getOperation($requestType); - if (!$operation) { return false; - } - - if ($amount) { - $amount = __('amount %1', $this->_formatPrice($payment, $amount)); - } - - if ($exception) { - $result = __('failed'); } else { - $result = __('successful'); + $message[] = $operation; } - - $card = __('Credit Card: xxxx-%1', $card->getCcLast4()); - - $pattern = '%s %s %s - %s.'; - $texts = array($card, $amount, $operation, $result); - + $message[] = ($exception) ? '- ' . __('failed.') : '- ' . __('successful.'); if (!is_null($lastTransactionId)) { - $pattern .= ' %s.'; - $texts[] = __('Authorize.Net Transaction ID %1', $lastTransactionId); + $message[] = __('Authorize.Net Transaction ID %1.', $lastTransactionId); } - if ($additionalMessage) { - $pattern .= ' %s.'; - $texts[] = $additionalMessage; + $message[] = $additionalMessage; } - $pattern .= ' %s'; - $texts[] = $exception; - - return call_user_func_array('__', array_merge(array($pattern), $texts)); + if ($exception) { + $message[] = $exception; + } + return implode(' ', $message); } /** diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index cf5b2a3bf55..df8c1202f6e 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -1054,14 +1054,14 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc 'parent_transaction_id' => $authTransactionId ), array(), - $this->_authorizenetData->getExtendedTransactionMessage( + $this->_authorizenetData->getTransactionMessage( $payment, self::REQUEST_TYPE_VOID, null, $card, false, false, - __('Parent Authorize.Net transaction (ID %1) expired', $realAuthTransactionId) + __('Parent Authorize.Net transaction (ID %1) expired.', $realAuthTransactionId) ) ); } diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index ef24c34cdb2..9d3f76530f6 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -23,6 +23,8 @@ */ namespace Magento\Authorizenet\Model; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * Authorize.net DirectPost payment method model. */ @@ -90,6 +92,11 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet */ protected $_helper; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData @@ -110,6 +117,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory * @param \Magento\Authorizenet\Model\Directpost\Response $response * @param \Magento\Authorizenet\Helper\HelperInterface $helper + * @param OrderSender $orderSender * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -134,6 +142,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory, \Magento\Authorizenet\Model\Directpost\Response $response, \Magento\Authorizenet\Helper\HelperInterface $helper, + OrderSender $orderSender, array $data = array() ) { parent::__construct( @@ -158,6 +167,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet $this->_requestFactory = $directRequestFactory; $this->_response = $response; $this->_helper = $helper; + $this->orderSender = $orderSender; } /** @@ -705,7 +715,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet try { if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save(); diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 83732fee639..6b8835ccde6 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-authorizenet", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Authz/Model/UserIdentifier.php b/app/code/Magento/Authz/Model/UserIdentifier.php deleted file mode 100644 index 999a7f259c8..00000000000 --- a/app/code/Magento/Authz/Model/UserIdentifier.php +++ /dev/null @@ -1,135 +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\Authz\Model; - -/** - * User identifier class. By user can be understood admin, customer, guest, web API integration. - */ -class UserIdentifier -{ - /**#@+ - * User types. - */ - const USER_TYPE_GUEST = 'Guest'; - - const USER_TYPE_CUSTOMER = 'Customer'; - - const USER_TYPE_ADMIN = 'Admin'; - - const USER_TYPE_INTEGRATION = 'Integration'; - - /**#@-*/ - - /** - * User type (admin, customer, guest, web API integration). - * - * @var string - */ - protected $_userType; - - /** - * @var int - */ - protected $_userId; - - /** - * Initialize user type and user id. - * - * @param UserLocatorInterface $userLocator Locator of active user. - * @param string|null $userType - * @param int|null $userId - * @throws \LogicException - */ - public function __construct(UserLocatorInterface $userLocator, $userType = null, $userId = null) - { - $userType = isset($userType) ? $userType : $userLocator->getUserType(); - $userId = isset($userId) ? $userId : $userLocator->getUserId(); - if ($userType == self::USER_TYPE_GUEST && $userId) { - throw new \LogicException('Guest user must not have user ID set.'); - } - $this->_setUserId($userId); - $this->_setUserType($userType); - } - - /** - * Get user ID. Null is possible when user type is 'guest'. - * - * @return int - */ - public function getUserId() - { - return $this->_userId; - } - - /** - * Retrieve user type (admin, customer, guest, web API integration). - * - * @return string - */ - public function getUserType() - { - return $this->_userType; - } - - /** - * Set user ID. - * - * @param int $userId - * @return $this - * @throws \LogicException - */ - protected function _setUserId($userId) - { - $userId = is_numeric($userId) ? (int)$userId : $userId; - if (!is_integer($userId) || $userId < 0) { - throw new \LogicException("Invalid user ID: '{$userId}'."); - } - $this->_userId = $userId; - return $this; - } - - /** - * Set user type. - * - * @param string $userType - * @return $this - * @throws \LogicException - */ - protected function _setUserType($userType) - { - $availableTypes = array( - self::USER_TYPE_GUEST, - self::USER_TYPE_CUSTOMER, - self::USER_TYPE_ADMIN, - self::USER_TYPE_INTEGRATION - ); - if (!in_array($userType, $availableTypes)) { - throw new \LogicException( - "Invalid user type: '{$userType}'. Allowed types: " . implode(", ", $availableTypes) - ); - } - $this->_userType = $userType; - return $this; - } -} diff --git a/app/code/Magento/Authz/Service/AuthorizationV1.php b/app/code/Magento/Authz/Service/AuthorizationV1.php deleted file mode 100644 index 216c3c56c8a..00000000000 --- a/app/code/Magento/Authz/Service/AuthorizationV1.php +++ /dev/null @@ -1,377 +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\Authz\Service; - -use Magento\Authz\Model\UserIdentifier; -use Magento\Framework\Acl; -use Magento\Framework\Acl\Builder as AclBuilder; -use Magento\Framework\Acl\RootResource as RootAclResource; -use Magento\Framework\Exception\AuthorizationException; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Logger; -use Magento\User\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; -use Magento\User\Model\Resource\Rules\CollectionFactory as RulesCollectionFactory; -use Magento\User\Model\Role; -use Magento\User\Model\RoleFactory; -use Magento\User\Model\RulesFactory; - -/** - * Authorization service. - * - * @SuppressWarnings(PHPMD.LongVariable) - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class AuthorizationV1 implements AuthorizationV1Interface -{ - const PERMISSION_ANONYMOUS = 'anonymous'; - const PERMISSION_SELF = 'self'; - - /** - * @var AclBuilder - */ - protected $_aclBuilder; - - /** - * @var UserIdentifier - */ - protected $_userIdentifier; - - /** - * @var RoleFactory - */ - protected $_roleFactory; - - /** - * @var RoleCollectionFactory - */ - protected $_roleCollectionFactory; - - /** - * @var RulesFactory - */ - protected $_rulesFactory; - - /** - * @var RulesCollectionFactory - */ - protected $_rulesCollectionFactory; - - /** - * @var Logger - */ - protected $_logger; - - /** - * @var RootAclResource - */ - protected $_rootAclResource; - - /** - * Initialize dependencies. - * - * @param AclBuilder $aclBuilder - * @param UserIdentifier $userIdentifier - * @param RoleFactory $roleFactory - * @param RoleCollectionFactory $roleCollectionFactory - * @param RulesFactory $rulesFactory - * @param RulesCollectionFactory $rulesCollectionFactory - * @param Logger $logger - * @param RootAclResource $rootAclResource - */ - public function __construct( - AclBuilder $aclBuilder, - UserIdentifier $userIdentifier, - RoleFactory $roleFactory, - RoleCollectionFactory $roleCollectionFactory, - RulesFactory $rulesFactory, - RulesCollectionFactory $rulesCollectionFactory, - Logger $logger, - RootAclResource $rootAclResource - ) { - $this->_aclBuilder = $aclBuilder; - $this->_userIdentifier = $userIdentifier; - $this->_roleFactory = $roleFactory; - $this->_rulesFactory = $rulesFactory; - $this->_rulesCollectionFactory = $rulesCollectionFactory; - $this->_roleCollectionFactory = $roleCollectionFactory; - $this->_logger = $logger; - $this->_rootAclResource = $rootAclResource; - } - - /** - * {@inheritdoc} - */ - public function isAllowed($resources, UserIdentifier $userIdentifier = null) - { - $resources = is_array($resources) ? $resources : [$resources]; - $userIdentifier = $userIdentifier ? $userIdentifier : $this->_userIdentifier; - if ($this->_isAnonymousOrSelfAllowed($resources, $userIdentifier)) { - return true; - } - return $this->_isUserWithRoleAllowed($resources, $userIdentifier); - } - - /** - * {@inheritdoc} - */ - public function grantPermissions(UserIdentifier $userIdentifier, array $resources) - { - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - $role = $this->_createRole($userIdentifier); - } - $this->_associateResourcesWithRole($role, $resources); - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException('Error happened while granting permissions. Check exception log for details.'); - } - } - - /** - * {@inheritdoc} - */ - public function grantAllPermissions(UserIdentifier $userIdentifier) - { - $this->grantPermissions($userIdentifier, array($this->_rootAclResource->getId())); - } - - /** - * {@inheritdoc} - */ - public function getAllowedResources(UserIdentifier $userIdentifier) - { - if ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_GUEST) { - return [self::PERMISSION_ANONYMOUS]; - } elseif ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER) { - return [self::PERMISSION_SELF]; - } - $allowedResources = []; - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - throw new AuthorizationException('The role associated with the specified user cannot be found.'); - } - $rulesCollection = $this->_rulesCollectionFactory->create(); - $rulesCollection->getByRoles($role->getId())->load(); - $acl = $this->_aclBuilder->getAcl(); - /** @var \Magento\User\Model\Rules $ruleItem */ - foreach ($rulesCollection->getItems() as $ruleItem) { - $resourceId = $ruleItem->getResourceId(); - if ($acl->has($resourceId) && $acl->isAllowed($role->getId(), $resourceId)) { - $allowedResources[] = $resourceId; - } - } - } catch (AuthorizationException $e) { - throw $e; - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException( - 'Error happened while getting a list of allowed resources. Check exception log for details.' - ); - } - return $allowedResources; - } - - /** - * {@inheritdoc} - */ - public function removePermissions(UserIdentifier $userIdentifier) - { - try { - $this->_deleteRole($userIdentifier); - } catch (NoSuchEntityException $e) { - throw $e; - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException( - 'Error happened while deleting role and permissions. Check exception log for details.' - ); - } - } - - /** - * Create new ACL role. - * - * @param UserIdentifier $userIdentifier - * @return Role - * @throws NoSuchEntityException - * @throws \LogicException - */ - protected function _createRole($userIdentifier) - { - $userType = $userIdentifier->getUserType(); - if (!$this->_canRoleBeCreatedForUserType($userType)) { - throw new \LogicException("The role with user type '{$userType}' cannot be created"); - } - $userId = $userIdentifier->getUserId(); - switch ($userType) { - case UserIdentifier::USER_TYPE_INTEGRATION: - $roleName = $userType . $userId; - $roleType = \Magento\User\Model\Acl\Role\User::ROLE_TYPE; - $parentId = 0; - $userId = $userIdentifier->getUserId(); - break; - default: - throw NoSuchEntityException::singleField('userType', $userType); - } - $role = $this->_roleFactory->create(); - $role->setRoleName($roleName) - ->setUserType($userType) - ->setUserId($userId) - ->setRoleType($roleType) - ->setParentId($parentId) - ->save(); - return $role; - } - - /** - * Remove an ACL role. This deletes the cascading permissions - * - * @param UserIdentifier $userIdentifier - * @return Role - * @throws NoSuchEntityException - * @throws \LogicException - */ - protected function _deleteRole($userIdentifier) - { - $userType = $userIdentifier->getUserType(); - if (!$this->_canRoleBeCreatedForUserType($userType)) { - throw new \LogicException("The role with user type '{$userType}' cannot be created or deleted."); - } - $userId = $userIdentifier->getUserId(); - switch ($userType) { - case UserIdentifier::USER_TYPE_INTEGRATION: - $roleName = $userType . $userId; - break; - default: - throw NoSuchEntityException::singleField('userType', $userType); - } - $role = $this->_roleFactory->create()->load($roleName, 'role_name'); - return $role->delete(); - } - - /** - * Identify user role from user identifier. - * - * @param UserIdentifier $userIdentifier - * @return Role|false Return false in case when no role associated with provided user was found. - * @throws \LogicException - */ - protected function _getUserRole($userIdentifier) - { - if (!$this->_canRoleBeCreatedForUserType($userIdentifier)) { - throw new \LogicException( - "The role with user type '{$userIdentifier->getUserType()}' does not exist and cannot be created" - ); - } - $roleCollection = $this->_roleCollectionFactory->create(); - $userType = $userIdentifier->getUserType(); - /** @var Role $role */ - $userId = $userIdentifier->getUserId(); - $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem(); - return $role->getId() ? $role : false; - } - - /** - * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. - * - * @param Role $role - * @param string[] $resources - * @return void - * @throws \LogicException - */ - protected function _associateResourcesWithRole($role, array $resources) - { - /** @var \Magento\User\Model\Rules $rules */ - $rules = $this->_rulesFactory->create(); - $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); - } - - /** - * Check if there role can be associated with user having provided user type. - * - * Roles cannot be created for guests and customers. - * - * @param string $userType - * @return bool - */ - protected function _canRoleBeCreatedForUserType($userType) - { - return ($userType != UserIdentifier::USER_TYPE_CUSTOMER) && ($userType != UserIdentifier::USER_TYPE_GUEST); - } - - /** - * Check if the user has permission to access the requested resources. - * - * @param string[] $resources - * @param UserIdentifier $userIdentifier - * @return bool - */ - protected function _isAnonymousOrSelfAllowed($resources, UserIdentifier $userIdentifier) - { - if (count($resources) == 1) { - $resource = reset($resources); - $isAnonymousAccess = ($resource == self::PERMISSION_ANONYMOUS); - $isSelfAccess = ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER) - && ($resource == self::PERMISSION_SELF); - if ($isAnonymousAccess || $isSelfAccess) { - return true; - } - } - return false; - } - - /** - * Check if user who has role is allowed to access requested resources. - * - * @param string[] $resources - * @param UserIdentifier $userIdentifier - * @return bool - */ - protected function _isUserWithRoleAllowed($resources, UserIdentifier $userIdentifier) - { - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - throw NoSuchEntityException::doubleField( - 'userId', - $userIdentifier->getUserId(), - 'userType', - $userIdentifier->getUserType() - ); - } - foreach ($resources as $resource) { - if (!$this->_aclBuilder->getAcl()->isAllowed($role->getId(), $resource)) { - return false; - } - } - return true; - } catch (\Exception $e) { - $this->_logger->logException($e); - return false; - } - } -} diff --git a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php b/app/code/Magento/Authz/Service/AuthorizationV1Interface.php deleted file mode 100644 index 9fbd2a5cc86..00000000000 --- a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php +++ /dev/null @@ -1,88 +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\Authz\Service; - -use Magento\Authz\Model\UserIdentifier; -use Magento\Framework\Exception\AuthorizationException; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Exception\NoSuchEntityException; - -/** - * Authorization service interface. - */ -interface AuthorizationV1Interface -{ - /** - * Grant permissions to user to access the specified resources. - * - * @param UserIdentifier $userIdentifier - * @param string[] $resources List of resources which should be available to the specified user. - * @return void - * @throws NoSuchEntityException - * @throws LocalizedException - */ - public function grantPermissions(UserIdentifier $userIdentifier, array $resources); - - /** - * Grant permissions to the user to access all resources available in the system. - * - * @param UserIdentifier $userIdentifier - * @return void - * @throws NoSuchEntityException - * @throws LocalizedException - */ - public function grantAllPermissions(UserIdentifier $userIdentifier); - - /** - * Check if the user has permission to access the requested resources. - * - * Access is prohibited if there is a lack of permissions to any of the requested resources. - * - * @param string|string[] $resources Single resource or a list of resources - * @param UserIdentifier|null $userIdentifier Context of current user is used by default - * @return bool - * @throws NoSuchEntityException - */ - public function isAllowed($resources, UserIdentifier $userIdentifier = null); - - /** - * Get a list of resources available to the specified user. - * - * @param UserIdentifier $userIdentifier - * @return string[] - * @throws AuthorizationException - * @throws LocalizedException - */ - public function getAllowedResources(UserIdentifier $userIdentifier); - - /** - * Remove user role and associated permissions. - * - * @param UserIdentifier $userIdentifier - * @return void - * @throws NoSuchEntityException - * @throws LocalizedException - */ - public function removePermissions(UserIdentifier $userIdentifier); -} diff --git a/app/code/Magento/Authz/composer.json b/app/code/Magento/Authz/composer.json deleted file mode 100644 index 97348d965fc..00000000000 --- a/app/code/Magento/Authz/composer.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "magento/module-authz", - "description": "N/A", - "require": { - "php": "5.4.*|5.5.*", - "magento/module-user": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", - "magento/magento-composer-installer": "*" - }, - "type": "magento2-module", - "version": "0.1.0-alpha89", - "extra": { - "map": [ - [ - "*", - "Magento/Authz" - ] - ] - } -} diff --git a/app/code/Magento/Authz/i18n/de_DE.csv b/app/code/Magento/Authz/i18n/de_DE.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/de_DE.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/en_US.csv b/app/code/Magento/Authz/i18n/en_US.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/en_US.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/es_ES.csv b/app/code/Magento/Authz/i18n/es_ES.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/es_ES.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/fr_FR.csv b/app/code/Magento/Authz/i18n/fr_FR.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/fr_FR.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/nl_NL.csv b/app/code/Magento/Authz/i18n/nl_NL.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/nl_NL.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/pt_BR.csv b/app/code/Magento/Authz/i18n/pt_BR.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/pt_BR.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Authz/i18n/zh_CN.csv b/app/code/Magento/Authz/i18n/zh_CN.csv deleted file mode 100644 index e3b44044195..00000000000 --- a/app/code/Magento/Authz/i18n/zh_CN.csv +++ /dev/null @@ -1,5 +0,0 @@ -"Error happened while granting permissions. Check exception log for details.","Error happened while granting permissions. Check exception log for details." -"The role associated with the specified user cannot be found.","The role associated with the specified user cannot be found." -"Error happened while getting a list of allowed resources. Check exception log for details.","Error happened while getting a list of allowed resources. Check exception log for details." -"Error happened while deleting role and permissions. Check exception log for details.","Error happened while deleting role and permissions. Check exception log for details." -"Role for user with ID ""%1"" and user type ""%2"" cannot be found.","Role for user with ID ""%1"" and user type ""%2"" cannot be found." diff --git a/app/code/Magento/Backend/Model/Auth/Session.php b/app/code/Magento/Backend/Model/Auth/Session.php index 4137ab6844a..42b75dd1e62 100644 --- a/app/code/Magento/Backend/Model/Auth/Session.php +++ b/app/code/Magento/Backend/Model/Auth/Session.php @@ -234,7 +234,7 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage public function processLogin() { if ($this->getUser()) { - $this->regenerateId(false); + $this->regenerateId(); if ($this->_backendUrl->useSecretKey()) { $this->_backendUrl->renewSecretUrls(); diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php index a95b840671a..fced5d795f6 100644 --- a/app/code/Magento/Backend/Model/Observer.php +++ b/app/code/Magento/Backend/Model/Observer.php @@ -85,27 +85,4 @@ class Observer { return $this; } - - /** - * Set url class name for store 'admin' - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function setUrlClassName(\Magento\Framework\Event\Observer $observer) - { - /** @var $storeCollection \Magento\Store\Model\Resource\Store\Collection */ - $storeCollection = $observer->getEvent()->getStoreCollection(); - /** @var $store \Magento\Store\Model\Store */ - foreach ($storeCollection as $store) { - if ($store->getId() == 0) { - $store->setUrlClassName('Magento\Backend\Model\UrlInterface'); - break; - } - } - $this->cache->remove( - \Magento\AdminNotification\Model\System\Message\Security::VERIFICATION_RESULT_CACHE_KEY - ); - return $this; - } } diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 22d9a7215c1..2ff611ae678 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -2,34 +2,33 @@ "name": "magento/module-backend", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-sendfriend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-catalog-search": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-user": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backup": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-url-rewrite": "0.1.0-alpha89", - "magento/module-translation": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-sendfriend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-catalog-search": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backup": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-url-rewrite": "0.1.0-alpha90", + "magento/module-translation": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/adminhtml/acl.xml b/app/code/Magento/Backend/etc/acl.xml similarity index 98% rename from app/code/Magento/Backend/etc/adminhtml/acl.xml rename to app/code/Magento/Backend/etc/acl.xml index 45f9521fd7a..3393e749dbb 100644 --- a/app/code/Magento/Backend/etc/adminhtml/acl.xml +++ b/app/code/Magento/Backend/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::all" title="Allow everything" sortOrder="10" /> diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 101b83e0776..1b15e3702c4 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -33,7 +33,6 @@ <module name="Magento_Directory"/> <module name="Magento_Core"/> <module name="Magento_Eav"/> - <module name="Magento_AdminNotification"/> <module name="Magento_Cron"/> <module name="Magento_Sendfriend"/> <module name="Magento_Theme"/> diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 8af68b4da04..b14d7243026 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-backup", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Backup/etc/adminhtml/acl.xml b/app/code/Magento/Backup/etc/acl.xml similarity index 94% rename from app/code/Magento/Backup/etc/adminhtml/acl.xml rename to app/code/Magento/Backup/etc/acl.xml index eb2139dc270..1abed0fc99e 100644 --- a/app/code/Magento/Backup/etc/adminhtml/acl.xml +++ b/app/code/Magento/Backup/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php index 1a70af60d63..678da2ceea6 100644 --- a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php +++ b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php @@ -33,21 +33,22 @@ class PriceBackend /** * @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject * @param \Closure $proceed - * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Model\Product|\Magento\Framework\Object $object * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundValidate( \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, - \Magento\Catalog\Model\Product $product + $object ) { - if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE - && $product->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC + if ($object instanceof \Magento\Catalog\Model\Product + && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE + && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC ) { return true; } else { - return $proceed($product); + return $proceed($object); } } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php new file mode 100644 index 00000000000..dfb605d843b --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.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\Bundle\Service\V1\Data\Product; + +use \Magento\Framework\Service\Data\AbstractObject; + +/** + * @codeCoverageIgnore + */ +class Option extends AbstractObject +{ + const ID = 'id'; + + const TITLE = 'title'; + + const REQUIRED = 'required'; + + const TYPE = 'type'; + + const POSITION = 'position'; + + const SKU = 'sku'; + + /** + * Get option id + * + * @return int|null + */ + public function getId() + { + return $this->_get(self::ID); + } + + /** + * Get option title + * + * @return string|null + */ + public function getTitle() + { + return $this->_get(self::TITLE); + } + + /** + * Get is required option + * + * @return bool|null + */ + public function isRequired() + { + return $this->_get(self::REQUIRED); + } + + /** + * Get input type + * + * @return string|null + */ + public function getType() + { + return $this->_get(self::TYPE); + } + + /** + * Get option position + * + * @return int|null + */ + public function getPosition() + { + return $this->_get(self::POSITION); + } + + /** + * Get product sku + * + * @return string|null + */ + public function getSku() + { + return $this->_get(self::SKU); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php new file mode 100644 index 00000000000..596a44f5343 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.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) + */ +namespace Magento\Bundle\Service\V1\Data\Product\Option; + +use \Magento\Framework\Service\Data\AbstractObject; + +/** + * @codeCoverageIgnore + */ +class Type extends AbstractObject +{ + const LABEL = 'label'; + + const CODE = 'code'; + + /** + * Get type label + * + * @return string + */ + public function getLabel() + { + return $this->_get(self::LABEL); + } + + /** + * Get type code + * + * @return string + */ + public function getCode() + { + return $this->_get(self::CODE); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php new file mode 100644 index 00000000000..04af6800a31 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php @@ -0,0 +1,54 @@ +<?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\Bundle\Service\V1\Data\Product\Option; + +use Magento\Framework\Service\Data\AbstractObjectBuilder; + +/** + * @codeCoverageIgnore + */ +class TypeBuilder extends AbstractObjectBuilder +{ + /** + * Set type label + * + * @param int $value + * @return $this + */ + public function setLabel($value) + { + return $this->_set(Type::LABEL, $value); + } + + /** + * Set type code + * + * @param int $value + * @return $this + */ + public function setCode($value) + { + return $this->_set(Type::CODE, $value); + } +} 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 new file mode 100644 index 00000000000..b64fecdbd27 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php @@ -0,0 +1,53 @@ +<?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\Bundle\Service\V1\Data\Product\Option; + + +class TypeConverter +{ + /** + * @var TypeBuilder + */ + private $builder; + + /** + * @param TypeBuilder $builder + */ + public function __construct(TypeBuilder $builder) + { + $this->builder = $builder; + } + + /** + * @param array $option + * @return Type + */ + public function createDataFromModel(array $option) + { + $this->builder->populateWithArray($option) + ->setCode($option['value']); + return $this->builder->create(); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php new file mode 100644 index 00000000000..398f8f1a995 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.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\Bundle\Service\V1\Data\Product; + +use Magento\Framework\Service\Data\AbstractObjectBuilder; + +/** + * @codeCoverageIgnore + */ +class OptionBuilder extends AbstractObjectBuilder +{ + /** + * Set option id + * + * @param int $value + * @return $this + */ + public function setId($value) + { + return $this->_set(Option::ID, $value); + } + + /** + * Set option title + * + * @param string $value + * @return $this + */ + public function setTitle($value) + { + return $this->_set(Option::TITLE, $value); + } + + /** + * Set is required option + * + * @param bool $value + * @return $this + */ + public function setRequired($value) + { + return $this->_set(Option::REQUIRED, $value); + } + + /** + * Set input type + * + * @param string $value + * @return $this + */ + public function setType($value) + { + return $this->_set(Option::TYPE, $value); + } + + /** + * Set option position + * + * @param int $value + * @return $this + */ + public function setPosition($value) + { + return $this->_set(Option::POSITION, $value); + } + + /** + * Set product sku + * + * @param string $value + * @return $this + */ + public function setSku($value) + { + return $this->_set(Option::SKU, $value); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php new file mode 100644 index 00000000000..b5de09c3576 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php @@ -0,0 +1,99 @@ +<?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\Bundle\Service\V1\Data\Product; + +use Magento\Bundle\Model\Option as OptionModel; +use Magento\Bundle\Model\OptionFactory; +use Magento\Catalog\Model\Product; + +/** + * @codeCoverageIgnore + */ +class OptionConverter +{ + /** + * @var OptionBuilder + */ + private $builder; + /** + * @var \Magento\Bundle\Model\OptionFactory + */ + private $optionFactory; + + /** + * @param OptionBuilder $builder + * @param OptionFactory $optionFactory + */ + public function __construct( + OptionBuilder $builder, + OptionFactory $optionFactory + ) { + $this->builder = $builder; + $this->optionFactory = $optionFactory; + } + + /** + * @param OptionModel $option + * @param Product $product + * @return Option + */ + public function createDataFromModel(OptionModel $option, Product $product) + { + $this->builder->populateWithArray($option->getData()) + ->setId($option->getId()) + ->setTitle(is_null($option->getTitle()) ? $option->getDefaultTitle() : $option->getTitle()) + ->setSku($product->getSku()); + return $this->builder->create(); + } + + /** + * @param Option $option + * @param Product $product + * @return OptionModel + */ + public function createModelFromData(Option $option, Product $product) + { + $optionModel = $this->optionFactory->create(); + $optionModel->addData($option->__toArray()) + ->unsetData($optionModel->getIdFieldName()) + ->setParentId($product->getId()) + ->setDefaultTitle($option->getTitle()); + return $optionModel; + } + + /** + * @param Option $option + * @param OptionModel $optionModel + * @return OptionModel + */ + public function getModelFromData(Option $option, OptionModel $optionModel) + { + $newOptionModel = $this->optionFactory->create(); + $newOptionModel->setData($optionModel->getData()) + ->addData($option->__toArray()) + ->setId($optionModel->getId()) + ->setDefaultTitle(is_null($option->getTitle()) ? $optionModel->getTitle() : $option->getTitle()); + return $newOptionModel; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php index 1218d7fcfa7..2964310bc69 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php @@ -169,7 +169,7 @@ class WriteService implements WriteServiceInterface $removeSelectionIds = array(); foreach ($this->getOptions($product) as $option) { foreach ($option->getSelections() as $selection) { - if (($selection->getSku() == $childSku) && ($selection->getOptionId() == $optionId)) { + if ((strcasecmp($selection->getSku(), $childSku) == 0) && ($selection->getOptionId() == $optionId)) { $removeSelectionIds[] = $selection->getSelectionId(); continue; } diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php new file mode 100644 index 00000000000..714401d72e4 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.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\Bundle\Service\V1\Product\Option; + +use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\OptionConverter; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ProductRepository; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Webapi\Exception; + +class ReadService implements ReadServiceInterface +{ + /** + * @var ProductRepository + */ + private $productRepository; + + /** + * @var OptionConverter + */ + private $optionConverter; + /** + * @var Type + */ + private $type; + + /** + * @param OptionConverter $optionConverter + * @param ProductRepository $productRepository + * @param Type $type + */ + public function __construct( + OptionConverter $optionConverter, + ProductRepository $productRepository, + Type $type + ) { + $this->optionConverter = $optionConverter; + $this->productRepository = $productRepository; + $this->type = $type; + } + + /** + * {@inheritdoc} + */ + public function get($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $option */ + $option = $optionCollection->getFirstItem(); + if (!$option->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + return $this->optionConverter->createDataFromModel($option, $product); + } + + /** + * {@inheritdoc} + */ + public function getList($productSku) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + + /** @var \Magento\Bundle\Service\V1\Data\Product\Option[] $optionDtoList */ + $optionDtoList = []; + /** @var \Magento\Bundle\Model\Option $option */ + foreach ($optionCollection as $option) { + $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product); + } + return $optionDtoList; + } + + /** + * @param string $productSku + * @return Product + * @throws Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + + if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + throw new Exception('Only implemented for bundle product', Exception::HTTP_FORBIDDEN); + } + + return $product; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php new file mode 100644 index 00000000000..14abab5ec34 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.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\Bundle\Service\V1\Product\Option; + +interface ReadServiceInterface +{ + /** + * Get option for bundle product + * + * @param string $productSku + * @param int $optionId + * @return \Magento\Bundle\Service\V1\Data\Product\Option + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function get($productSku, $optionId); + + /** + * Get all options for bundle product + * + * @param string $productSku + * @return \Magento\Bundle\Service\V1\Data\Product\Option[] + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function getList($productSku); +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadService.php new file mode 100644 index 00000000000..073a80b88ae --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadService.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\Bundle\Service\V1\Product\Option\Type; + +use Magento\Bundle\Model\Source\Option\Type as TypeModel; +use Magento\Bundle\Service\V1\Data\Product\Option\Type; +use Magento\Bundle\Service\V1\Data\Product\Option\TypeConverter; + +class ReadService implements ReadServiceInterface +{ + /** + * @var TypeModel + */ + private $type; + + /** + * @var TypeConverter + */ + private $typeConverter; + + /** + * @param TypeModel $type + * @param TypeConverter $typeConverter + */ + public function __construct(TypeModel $type, TypeConverter $typeConverter) + { + $this->type = $type; + $this->typeConverter = $typeConverter; + } + + /** + * {@inheritdoc} + */ + public function getTypes() + { + $optionList = $this->type->toOptionArray(); + + /** @var Type[] $typeDtoList */ + $typeDtoList = []; + foreach ($optionList as $option) { + $typeDtoList[] = $this->typeConverter->createDataFromModel($option); + } + return $typeDtoList; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php new file mode 100644 index 00000000000..90fbc02a75e --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.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) + */ +namespace Magento\Bundle\Service\V1\Product\Option\Type; + +interface ReadServiceInterface +{ + /** + * Get all types for options for bundle products + * + * @return \Magento\Bundle\Service\V1\Data\Product\Option\Type[] + */ + public function getTypes(); +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php new file mode 100644 index 00000000000..d48888f5229 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.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\Bundle\Service\V1\Product\Option; + +use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Data\Product\OptionConverter; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ProductRepository; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Webapi\Exception; + +class WriteService implements WriteServiceInterface +{ + /** + * @var ProductRepository + */ + private $productRepository; + /** + * @var Type + */ + private $type; + /** + * @var \Magento\Bundle\Service\V1\Data\Product\OptionConverter + */ + private $optionConverter; + /** + * @var \Magento\Store\Model\StoreManager + */ + private $storeManager; + + /** + * @param ProductRepository $productRepository + * @param Type $type + * @param OptionConverter $optionConverter + * @param StoreManagerInterface $storeManager + */ + public function __construct( + ProductRepository $productRepository, + Type $type, + OptionConverter $optionConverter, + StoreManagerInterface $storeManager + ) { + $this->productRepository = $productRepository; + $this->type = $type; + $this->optionConverter = $optionConverter; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function remove($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $removeOption */ + $removeOption = $optionCollection->getFirstItem(); + if (!$removeOption->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $removeOption->delete(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function add($productSku, Option $option) + { + $product = $this->getProduct($productSku); + $optionModel = $this->optionConverter->createModelFromData($option, $product); + $optionModel->setStoreId($this->storeManager->getStore()->getId()); + + try { + $optionModel->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not save option', [], $e); + } + + return $optionModel->getId(); + } + + /** + * {@inheritdoc} + */ + public function update($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Option $option) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $optionModel */ + $optionModel = $optionCollection->getFirstItem(); + $updateOption = $this->optionConverter->getModelFromData($option, $optionModel); + + if (!$updateOption->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $updateOption->setStoreId($this->storeManager->getStore()->getId()); + + try { + $updateOption->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not save option', [], $e); + } + + return true; + } + + /** + * @param string $productSku + * @return Product + * @throws Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + + if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + throw new Exception( + 'Product with specified sku: "%1" is not a bundle product', + Exception::HTTP_FORBIDDEN, + Exception::HTTP_FORBIDDEN, + [ + $product->getSku() + ] + ); + } + + return $product; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php new file mode 100644 index 00000000000..a5992eb2f7a --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.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\Bundle\Service\V1\Product\Option; + +interface WriteServiceInterface +{ + /** + * Remove bundle option + * + * @param string $productSku + * @param int $optionId + * @return bool + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Webapi\Exception + */ + public function remove($productSku, $optionId); + + /** + * Add new option for bundle product + * + * @param string $productSku + * @param \Magento\Bundle\Service\V1\Data\Product\Option $option + * @return int + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Webapi\Exception + */ + public function add($productSku, \Magento\Bundle\Service\V1\Data\Product\Option $option); + + /** + * Update option for bundle product + * + * @param string $productSku + * @param int $optionId + * @param \Magento\Bundle\Service\V1\Data\Product\Option $option + * @return bool + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Webapi\Exception + */ + public function update($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Option $option); +} diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 8bc03c33985..c0a9d91f9b5 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -2,27 +2,27 @@ "name": "magento/module-bundle", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", - "magento/module-webapi": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-webapi": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index fd02cc8f4cc..b33dcd27d2b 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -26,6 +26,9 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Bundle\Service\V1\Product\Link\ReadServiceInterface" type="Magento\Bundle\Service\V1\Product\Link\ReadService" /> <preference for="Magento\Bundle\Service\V1\Product\Link\WriteServiceInterface" type="Magento\Bundle\Service\V1\Product\Link\WriteService" /> + <preference for="Magento\Bundle\Service\V1\Product\Option\ReadServiceInterface" type="Magento\Bundle\Service\V1\Product\Option\ReadService" /> + <preference for="Magento\Bundle\Service\V1\Product\Option\WriteServiceInterface" type="Magento\Bundle\Service\V1\Product\Option\WriteService" /> + <preference for="Magento\Bundle\Service\V1\Product\Option\Type\ReadServiceInterface" type="Magento\Bundle\Service\V1\Product\Option\Type\ReadService" /> <type name="Magento\Bundle\Model\Source\Option\Type"> <arguments> <argument name="options" xsi:type="array"> diff --git a/app/code/Magento/Bundle/etc/webapi.xml b/app/code/Magento/Bundle/etc/webapi.xml index 757c74cee5b..8e9ea1b5287 100644 --- a/app/code/Magento/Bundle/etc/webapi.xml +++ b/app/code/Magento/Bundle/etc/webapi.xml @@ -43,4 +43,40 @@ <resource ref="Magento_Catalog::products"/> </resources> </route> + <route url="/V1/bundle-products/:productSku/option/all" method="GET"> + <service class="Magento\Bundle\Service\V1\Product\Option\ReadServiceInterface" method="getList" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/bundle-products/option/types" method="GET"> + <service class="Magento\Bundle\Service\V1\Product\Option\Type\ReadServiceInterface" method="getTypes" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/bundle-products/:productSku/option/:optionId" method="GET"> + <service class="Magento\Bundle\Service\V1\Product\Option\ReadServiceInterface" method="get" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/bundle-products/:productSku/option/add" method="POST"> + <service class="Magento\Bundle\Service\V1\Product\Option\WriteServiceInterface" method="add" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/bundle-products/:productSku/option/:optionId" method="PUT"> + <service class="Magento\Bundle\Service\V1\Product\Option\WriteServiceInterface" method="update" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/bundle-products/:productSku/option/:optionId" method="DELETE"> + <service class="Magento\Bundle\Service\V1\Product\Option\WriteServiceInterface" method="remove" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> </routes> 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 c66e9c8e707..f59849e66d5 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 @@ -42,19 +42,19 @@ <?php if ($_item->getOrderItem()->getParentItem()): ?> <?php $attributes = $this->getSelectionAttributes($_item) ?> <?php if ($_prevOptionId != $attributes['option_id']): ?> - <tr> + <tr class="options-label"> <td class="col label" colspan="7"><div class="option label"><?php echo $attributes['option_label'] ?></div></td> </tr> <?php $_prevOptionId = $attributes['option_id'] ?> <?php endif; ?> <?php endif; ?> -<tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getOrderItem()->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"> +<tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getOrderItem()->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"<?php if ($_item->getParentItem()): ?> data-th="<?php echo $attributes['option_label'] ?>"<?php endif; ?>> <?php if (!$_item->getOrderItem()->getParentItem()): ?> <td class="col name" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"> <strong class="product name product-item-name"><?php echo $this->escapeHtml($_item->getName()) ?></strong> </td> <?php else: ?> - <td class="col value"><?php echo $this->getValueHtml($_item) ?></td> + <td class="col value" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"><?php echo $this->getValueHtml($_item) ?></td> <?php endif; ?> <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')); ?>"> 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 2515d5a29c3..20b29c9f317 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 @@ -41,19 +41,19 @@ <?php if ($_item->getOrderItem()->getParentItem()): ?> <?php $attributes = $this->getSelectionAttributes($_item) ?> <?php if ($_prevOptionId != $attributes['option_id']): ?> - <tr> + <tr class="options-label"> <td class="col label" colspan="5"><div class="option label"><?php echo $attributes['option_label'] ?></div></td> </tr> <?php $_prevOptionId = $attributes['option_id'] ?> <?php endif; ?> <?php endif; ?> - <tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getOrderItem()->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"> + <tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getOrderItem()->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"<?php if ($_item->getOrderItem()->getParentItem()): ?> data-th="<?php echo $attributes['option_label'] ?>"<?php endif; ?>> <?php if (!$_item->getOrderItem()->getParentItem()): ?> <td class="col name" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"> <strong class="product name product-item-name"><?php echo $this->escapeHtml($_item->getName()) ?></strong> </td> <?php else: ?> - <td class="col value"><?php echo $this->getValueHtml($_item) ?></td> + <td class="col value" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"><?php echo $this->getValueHtml($_item) ?></td> <?php endif; ?> <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')); ?>"> 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 1581213677e..b1908e1964b 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 @@ -42,19 +42,19 @@ <?php if ($_item->getParentItem()): ?> <?php $attributes = $this->getSelectionAttributes($_item) ?> <?php if ($_prevOptionId != $attributes['option_id']): ?> - <tr<?php if ($_item->getLastRow()) echo 'class="last"'; ?>> - <td class="col label" colspan="5"><div class="option label"><?php echo $attributes['option_label'] ?></div></td> + <tr class="options-label"> + <td class="col label" colspan="5"><?php echo $attributes['option_label'] ?></td> </tr> <?php $_prevOptionId = $attributes['option_id'] ?> <?php endif; ?> <?php endif; ?> -<tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"> +<tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"<?php if ($_item->getParentItem()): ?> data-th="<?php echo $attributes['option_label'] ?>"<?php endif; ?>> <?php if (!$_item->getParentItem()): ?> <td class="col name" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"> <strong class="product name product-item-name"><?php echo $this->escapeHtml($_item->getName()) ?></strong> </td> <?php else: ?> - <td class="col value"><?php echo $this->getValueHtml($_item)?></td> + <td class="col value" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"><?php echo $this->getValueHtml($_item)?></td> <?php endif; ?> <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')); ?>"> @@ -295,7 +295,7 @@ <?php endforeach; ?> <?php if ($_showlastRow): ?> <tr> - <td class="col options" colspan="5"> + <td class="col options" colspan="5" > <?php if($_options = $this->getItemOptions()): ?> <dl class="item options"> <?php foreach ($_options as $_option) : ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml index d47b684a7d8..5e3fc45b43d 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml @@ -41,19 +41,19 @@ <?php if ($_item->getParentItem()): ?> <?php $attributes = $this->getSelectionAttributes($_item) ?> <?php if ($_prevOptionId != $attributes['option_id']): ?> - <tr> + <tr class="options-label"> <td colspan="3" class="col label"><div class="option label"><?php echo $attributes['option_label'] ?></div></td> </tr> <?php $_prevOptionId = $attributes['option_id'] ?> <?php endif; ?> <?php endif; ?> - <tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"> + <tr id="order-item-row-<?php echo $_item->getId() ?>" class="<?php if ($_item->getParentItem()): ?>item-options<?php else: ?>item-parent<?php endif; ?>"<?php if ($_item->getParentItem()): ?> data-th="<?php echo $attributes['option_label'] ?>"<?php endif; ?>> <?php if (!$_item->getParentItem()): ?> <td class="col name" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"> <strong class="product name product-item-name"><?php echo $this->escapeHtml($_item->getName()) ?></strong> </td> <?php else: ?> - <td class="col value"><?php echo $this->getValueHtml($_item) ?></td> + <td class="col value" data-th="<?php echo $this->escapeHtml(__('Product Name')); ?>"><?php echo $this->getValueHtml($_item) ?></td> <?php endif; ?> <td class="col sku" data-th="<?php echo $this->escapeHtml(__('SKU')); ?>"><?php echo $this->escapeHtml($_item->getSku()) ?></td> <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty Shipped')); ?>"> diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index 958b9216861..c00bf2b0825 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-captcha", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Captcha/view/frontend/templates/default.phtml b/app/code/Magento/Captcha/view/frontend/templates/default.phtml index ef872a1f592..f382e4f6eb3 100644 --- a/app/code/Magento/Captcha/view/frontend/templates/default.phtml +++ b/app/code/Magento/Captcha/view/frontend/templates/default.phtml @@ -36,13 +36,13 @@ data-mage-init='{"captcha":{"url": "<?php echo $this->getRefreshUrl()?>", "type": "<?php echo $this->getFormId() ?>"}}'> <div class="control captcha-image"> - <button type="button" class="action reload captcha-reload" title="<?php echo __('Reload captcha') ?>"><span><?php echo __('Reload captcha') ?></span></button> <img alt="<?php echo __('Please type the letters below')?>" class="captcha-img" height="<?php echo $this->getImgHeight() ?>" src="<?php echo $captcha->getImgSrc() ?>"/> <?php if ($captcha->isCaseSensitive()) :?> <div class="captcha-note note"> <?php echo __('<strong>Attention</strong>: Captcha is case sensitive.') ?> </div> <?php endif; ?> + <button type="button" class="action reload captcha-reload" title="<?php echo __('Reload captcha') ?>"><span><?php echo __('Reload captcha') ?></span></button> </div> </div> </div> diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php index 5d17b451a4a..d4a5e5e111d 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php @@ -334,7 +334,8 @@ class Crosssell extends Extended 'editable' => !$this->isReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', - 'column_css_class' => 'col-position' + 'column_css_class' => 'col-position', + 'filter_condition_callback' => array($this, 'filterProductPosition') ) ); @@ -385,4 +386,17 @@ class Crosssell extends Extended } return $products; } + + /** + * Apply `position` filter to cross-sell grid. + * + * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection $collection + * @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column + * @return $this + */ + public function filterProductPosition($collection, $column) + { + $collection->addLinkAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition()); + return $this; + } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php index 738fe7b50d2..323ead3a5cf 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php @@ -340,7 +340,7 @@ class Option extends Widget ) : '', 'price_type' => $showPrice ? $_value->getPriceType() : 0, 'sku' => $this->escapeHtml($_value->getSku()), - 'sort_order' => $_value->getSortOrder() + 'sort_order' => $_value->getSortOrder(), ); if ($this->getProduct()->getStoreId() != '0') { @@ -358,7 +358,8 @@ class Option extends Widget $_value->getOptionId(), 'price', is_null($_value->getstorePrice()), - $_value->getOptionTypeId() + $_value->getOptionTypeId(), + ['$(this).up(1).previous()'] ); $value['optionValues'][$i]['scopePriceDisabled'] = is_null( $_value->getStorePrice() @@ -404,9 +405,10 @@ class Option extends Widget * @param string $name * @param boolean $checked * @param string $select_id + * @param array $containers * @return string */ - public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1') + public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1', array $containers = []) { $checkedHtml = ''; if ($checked) { @@ -418,14 +420,20 @@ class Option extends Widget $selectNameHtml = '[values][' . $select_id . ']'; $selectIdHtml = 'select_' . $select_id . '_'; } + $containers[] = '$(this).up(1)'; + $containers = implode(',', $containers); + $localId = $this->getFieldId() . '_' . $id . '_' . $selectIdHtml . $name . '_use_default'; + $localName = "options_use_default[" . $id . "]" . $selectNameHtml . "[" . $name . "]"; $useDefault = - '<div class="field-service">' . '<label for="' . $this->getFieldId() . '_' . $id . '_' . $selectIdHtml - . $name . '" class="use-default">' . '<input value="1" type="checkbox" class="use-default-control"' - . 'name="' . $this->getFieldName() . '[' . $id . ']' . $selectNameHtml . '[scope][' . $name . ']"' . 'id="' - . $this->getFieldId() . '_' . $id . '_' . $selectIdHtml . $name . '_use_default"' . $checkedHtml - . ' /><span class="use-default-label">' . __( - 'Use Default' - ) . '</span></label></div>'; + '<div class="field-service">' + . '<input type="checkbox" class="use-default-control"' + . ' name="' . $localName . '"' . 'id="' . $localId . '"' + . ' value=""' + . $checkedHtml + . ' onchange="toggleSeveralValueElements(this, [' . $containers . ']);" ' + . ' />' + . '<label for="' . $localId . '" class="use-default">' + . '<span class="use-default-label">' . __('Use Default') . '</span></label></div>'; return $useDefault; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php index 5fc2bd2a146..e55b1ef0ec3 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php @@ -94,9 +94,12 @@ class Select extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\T } /** + * Return select input for price type + * + * @param string $extraParams * @return string */ - public function getPriceTypeSelectHtml() + public function getPriceTypeSelectHtml($extraParams = '') { $this->getChildBlock( 'option_price_type' @@ -105,7 +108,7 @@ class Select extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\T 'product_option_${id}_select_${select_id}_price_type' )->setName( 'product[options][${id}][values][${select_id}][price_type]' - ); + )->setExtraParams($extraParams); return parent::getPriceTypeSelectHtml(); } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php index b17bdfcbb78..746bb97b500 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php @@ -325,7 +325,8 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended 'editable' => !$this->getProduct()->getUpsellReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', - 'column_css_class' => 'col-position' + 'column_css_class' => 'col-position', + 'filter_condition_callback' => array($this, 'filterProductPosition') ) ); @@ -376,4 +377,17 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended } return $products; } + + /** + * Apply `position` filter to cross-sell grid. + * + * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection + * @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column + * @return $this + */ + public function filterProductPosition($collection, $column) + { + $collection->addLinkAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition()); + return $this; + } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index c8d62fa9e67..81a22bbbdd4 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -122,6 +122,18 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs $this->setDestElementId('product-edit-form-tabs'); } + /** + * @param int $attributeSetId + * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection + */ + public function getGroupCollection($attributeSetId) + { + return $this->_collectionFactory->create() + ->setAttributeSetFilter($attributeSetId) + ->setSortOrder() + ->load(); + } + /** * @return $this */ @@ -134,16 +146,13 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs } if ($setId) { - $groupCollection = $this->_collectionFactory->create()->setAttributeSetFilter( - $setId - )->setSortOrder()->load(); - $tabAttributesBlock = $this->getLayout()->createBlock( $this->getAttributeTabBlock(), $this->getNameInLayout() . '_attributes_tab' ); $advancedGroups = array(); - foreach ($groupCollection as $group) { + + foreach ($this->getGroupCollection($setId) as $group) { /** @var $group \Magento\Eav\Model\Entity\Attribute\Group*/ $attributes = $product->getAttributes($group->getId(), true); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index 0e5cc16085e..d1a2a44fcf6 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -244,36 +244,6 @@ abstract class AbstractProduct extends \Magento\Framework\View\Element\Template return $minSaleQty > 0 ? $minSaleQty : null; } - /** - * Returns product price block html - * - * @param \Magento\Catalog\Model\Product $product - * @param boolean $displayMinimalPrice - * @param string $idSuffix - * @return string - * @deprecated - */ - public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') - { - $typeId = $product->getTypeId(); - if ($this->_catalogData->canApplyMsrp($product)) { - $realPriceHtml = $this->_preparePriceRenderer($typeId) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - $product->setAddToCartUrl($this->getAddToCartUrl($product)); - $product->setRealPriceHtml($realPriceHtml); - $typeId = $this->_mapRenderer; - } - - return $this->_preparePriceRenderer($typeId) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - } - /** * Get product reviews summary * diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index e16c7a36c3b..c6ef67d1947 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -139,7 +139,12 @@ class Helper * Initialize product options */ if (isset($productData['options']) && !$product->getOptionsReadonly()) { - $product->setProductOptions($productData['options']); + // mark custom options that should to fall back to default value + $options = $this->mergeProductOptions( + $productData['options'], + $this->request->getPost('options_use_default') + ); + $product->setProductOptions($options); } $product->setCanSaveCustomOptions( @@ -148,4 +153,30 @@ class Helper return $product; } + + /** + * Merge product and default options for product + * + * @param array $productOptions product options + * @param array $overwriteOptions default value options + * @return array + */ + public function mergeProductOptions($productOptions, $overwriteOptions) + { + if (!is_array($productOptions)) { + $productOptions = []; + } + if (is_array($overwriteOptions)) { + $options = array_replace_recursive($productOptions, $overwriteOptions); + array_walk_recursive($options, function (&$item) { + if ($item === "") { + $item = null; + } + }); + } else { + $options = $productOptions; + } + + return $options; + } } diff --git a/app/code/Magento/Catalog/Model/Product/Link.php b/app/code/Magento/Catalog/Model/Product/Link.php index 447b1712261..40955dc3b44 100644 --- a/app/code/Magento/Catalog/Model/Product/Link.php +++ b/app/code/Magento/Catalog/Model/Product/Link.php @@ -51,7 +51,7 @@ class Link extends \Magento\Framework\Model\AbstractModel /** * @var mixed */ - protected $_attributeCollection = null; + protected $_attributes = null; /** * Product collection factory @@ -169,7 +169,11 @@ class Link extends \Magento\Framework\Model\AbstractModel if (is_null($type)) { $type = $this->getLinkTypeId(); } - return $this->_getResource()->getAttributesByType($type); + if (!isset($this->_attributes[$type])) { + $this->_attributes[$type] = $this->_getResource()->getAttributesByType($type); + } + + return $this->_attributes[$type]; } /** diff --git a/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php b/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php index 6433e327fcb..72067a2e193 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php @@ -102,7 +102,33 @@ class DefaultValidator extends \Magento\Framework\Validator\AbstractValidator */ protected function validateOptionRequiredFields(Option $option) { - return !$this->isEmpty($option->getTitle()) && !$this->isEmpty($option->getType()); + $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + $product = $option->getProduct(); + if ($product) { + $storeId = $product->getStoreId(); + } + $title = $option->getTitle(); + return $this->isValidOptionTitle($title, $storeId) && !$this->isEmpty($option->getType()); + } + + /** + * Validate option title + * + * @param string $title + * @param int $storeId + * @return bool + */ + protected function isValidOptionTitle($title, $storeId) + { + // we should be able to set null title for not default store (used for deletion from store view) + if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $title === null) { + return true; + } + if ($this->isEmpty($title)) { + return false; + } + + return true; } /** diff --git a/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php b/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php index 37a8dfc9ad0..4ee412006c0 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php @@ -62,14 +62,41 @@ class Select extends DefaultValidator return false; } + $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + if ($option->getProduct()) { + $storeId = $option->getProduct()->getStoreId(); + } foreach ($option->getData('values') as $value) { - $type = isset($value['price_type']) ? $value['price_type'] : ''; - $price = isset($value['price']) ? $value['price'] : 0; - $title = isset($value['title']) ? $value['title'] : ''; - if (!$this->isInRange($type, $this->priceTypes) || $this->isNegative($price) || $this->isEmpty($title)) { + $type = isset($value['price_type']) ? $value['price_type'] : null; + $price = isset($value['price']) ? $value['price'] : null; + $title = isset($value['title']) ? $value['title'] : null; + if (!$this->isValidOptionPrice($type, $price, $storeId) + || !$this->isValidOptionTitle($title, $storeId) + ) { return false; } } return true; } + + /** + * Validate option price + * + * @param string $priceType + * @param int $price + * @param int $storeId + * @return bool + */ + protected function isValidOptionPrice($priceType, $price, $storeId) + { + // we should be able to remove website values for default store fallback + if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $priceType === null && $price === null) { + return true; + } + if (!$this->isInRange($priceType, $this->priceTypes) || $this->isNegative($price)) { + return false; + } + + return true; + } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php index 6fa34b62577..a23c57bfcd1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php @@ -280,10 +280,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection if (!$this->getLinkModel()) { return $this; } - $attributes = $this->getLinkModel()->getAttributes(); - $attributesByType = array(); - foreach ($attributes as $attribute) { + foreach ($this->getLinkAttributes() as $attribute) { $table = $this->getLinkModel()->getAttributeTypeTable($attribute['type']); $alias = sprintf('link_attribute_%s_%s', $attribute['code'], $attribute['type']); @@ -319,4 +317,34 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection } return parent::setOrder($attribute, $dir); } + + /** + * Get attributes of specified link type + * + * @param int $type + * @return array + */ + public function getLinkAttributes($type = null) + { + return $this->getLinkModel()->getAttributes($type); + } + + /** + * Add link attribute to filter. + * + * @param string $code + * @param array $condition + * @return $this + */ + public function addLinkAttributeToFilter($code, $condition) + { + foreach ($this->getLinkAttributes() as $attribute) { + if ($attribute['code'] == $code) { + $alias = sprintf('link_attribute_%s_%s', $code, $attribute['type']); + $whereCondition = $this->_getConditionSql($alias.'.`value`', $condition); + $this->getSelect()->where($whereCondition); + } + } + return $this; + } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index 60578fff48f..a87e5e2bdf8 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -252,95 +252,87 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object) { - $readAdapter = $this->_getReadAdapter(); $writeAdapter = $this->_getWriteAdapter(); - $titleTable = $this->getTable('catalog_product_option_title'); - - //title - if (!$object->getData('scope', 'title')) { - $statement = $readAdapter->select()->from( - $titleTable - )->where( - 'option_id = ?', - $object->getId() - )->where( - 'store_id = ?', + $titleTableName = $this->getTable('catalog_product_option_title'); + foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) { + $existInCurrentStore = $this->getColFromOptionTable($titleTableName, (int)$object->getId(), (int)$storeId); + $existInDefaultStore = $this->getColFromOptionTable( + $titleTableName, + (int)$object->getId(), \Magento\Store\Model\Store::DEFAULT_STORE_ID ); - - if ($readAdapter->fetchOne($statement)) { - if ($object->getStoreId() == '0') { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object(array('title' => $object->getTitle())), - $titleTable - ); - - $writeAdapter->update( - $titleTable, - $data, + if ($object->getTitle()) { + if ($existInCurrentStore) { + if ($object->getStoreId() == $storeId) { + $data = $this->_prepareDataForTable( + new \Magento\Framework\Object(array('title' => $object->getTitle())), + $titleTableName + ); + $writeAdapter->update( + $titleTableName, + $data, + array( + 'option_id = ?' => $object->getId(), + 'store_id = ?' => $storeId, + ) + ); + } + } else { + // we should insert record into not default store only of if it does not exist in default store + if (($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore) + || ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) + ) { + $data = $this->_prepareDataForTable( + new \Magento\Framework\Object( + array( + 'option_id' => $object->getId(), + 'store_id' => $storeId, + 'title' => $object->getTitle(), + ) + ), + $titleTableName + ); + $writeAdapter->insert($titleTableName, $data); + } + } + } else { + if ($object->getId() && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID + && $storeId + ) { + $writeAdapter->delete( + $titleTableName, array( 'option_id = ?' => $object->getId(), - 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID + 'store_id = ?' => $object->getStoreId(), ) ); } - } else { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object( - array( - 'option_id' => $object->getId(), - 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, - 'title' => $object->getTitle() - ) - ), - $titleTable - ); - - $writeAdapter->insert($titleTable, $data); } } + } - if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) { - $statement = $readAdapter->select()->from( - $titleTable - )->where( - 'option_id = ?', - $object->getId() - )->where( - 'store_id = ?', - $object->getStoreId() - ); - - if ($readAdapter->fetchOne($statement)) { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object(array('title' => $object->getTitle())), - $titleTable - ); + /** + * Get first col from from first row for option table + * + * @param string $tableName + * @param int $optionId + * @param int $storeId + * @return string + */ + protected function getColFromOptionTable($tableName, $optionId, $storeId) + { + $readAdapter = $this->_getReadAdapter(); + $statement = $readAdapter->select()->from( + $tableName + )->where( + 'option_id = ?', + $optionId + )->where( + 'store_id = ?', + $storeId + ); - $writeAdapter->update( - $titleTable, - $data, - array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()) - ); - } else { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object( - array( - 'option_id' => $object->getId(), - 'store_id' => $object->getStoreId(), - 'title' => $object->getTitle() - ) - ), - $titleTable - ); - $writeAdapter->insert($titleTable, $data); - } - } elseif ($object->getData('scope', 'title')) { - $writeAdapter->delete( - $titleTable, - array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()) - ); - } + return $readAdapter->fetchOne($statement); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php index 8cbe4443b0a..741aa4c7c3e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -109,7 +109,7 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb $price = (double)sprintf('%F', $object->getPrice()); $priceType = $object->getPriceType(); - if (!$object->getData('scope', 'price')) { + if ($object->getPrice() && $priceType) { //save for store_id = 0 $select = $this->_getReadAdapter()->select()->from( $priceTable, @@ -149,7 +149,11 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - if ($object->getStoreId() != '0' && $scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE) { + if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE + && $priceType + && $object->getPrice() + && $object->getStoreId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID + ) { $baseCurrency = $this->_config->getValue( \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, @@ -203,12 +207,18 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb } } } else { - if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE && $object->getData('scope', 'price')) { - $where = array( - 'option_type_id = ?' => (int)$object->getId(), - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->delete($priceTable, $where); + if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE + && !$object->getPrice() + && !$priceType + ) { + $storeIds = $this->_storeManager->getStore($object->getStoreId())->getWebsite()->getStoreIds(); + foreach ($storeIds as $storeId) { + $where = array( + 'option_type_id = ?' => (int)$object->getId(), + 'store_id = ?' => $storeId, + ); + $this->_getWriteAdapter()->delete($priceTable, $where); + } } } } @@ -221,9 +231,8 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object) { - $titleTable = $this->getTable('catalog_product_option_type_title'); - - if (!$object->getData('scope', 'title')) { + foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) { + $titleTable = $this->getTable('catalog_product_option_type_title'); $select = $this->_getReadAdapter()->select()->from( $titleTable, array('option_type_id') @@ -232,69 +241,78 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb (int)$object->getId() )->where( 'store_id = ?', - \Magento\Store\Model\Store::DEFAULT_STORE_ID + (int)$storeId ); $optionTypeId = $this->_getReadAdapter()->fetchOne($select); - - if ($optionTypeId) { - if ($object->getStoreId() == '0') { + $existInCurrentStore = $this->getOptionIdFromOptionTable($titleTable, (int)$object->getId(), (int)$storeId); + if ($object->getTitle()) { + if ($existInCurrentStore) { + if ($storeId == $object->getStoreId()) { + $where = array( + 'option_type_id = ?' => (int)$optionTypeId, + 'store_id = ?' => $storeId, + ); + $bind = array('title' => $object->getTitle()); + $this->_getWriteAdapter()->update($titleTable, $bind, $where); + } + } else { + $existInDefaultStore = $this->getOptionIdFromOptionTable( + $titleTable, + (int)$object->getId(), + \Magento\Store\Model\Store::DEFAULT_STORE_ID + ); + // we should insert record into not default store only of if it does not exist in default store + if (($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore) + || ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) + ) { + $bind = array( + 'option_type_id' => (int)$object->getId(), + 'store_id' => $storeId, + 'title' => $object->getTitle() + ); + $this->_getWriteAdapter()->insert($titleTable, $bind); + } + } + } else { + if ($storeId + && $optionTypeId + && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID + ) { $where = array( 'option_type_id = ?' => (int)$optionTypeId, - 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID + 'store_id = ?' => $storeId, ); - $bind = array('title' => $object->getTitle()); - $bind = array('title' => $object->getTitle()); - $this->_getWriteAdapter()->update($titleTable, $bind, $where); + $this->_getWriteAdapter()->delete($titleTable, $where); } - } else { - $bind = array( - 'option_type_id' => (int)$object->getId(), - 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, - 'title' => $object->getTitle() - ); - $this->_getWriteAdapter()->insert($titleTable, $bind); } } + } - if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) { - $select = $this->_getReadAdapter()->select()->from( - $titleTable, - array('option_type_id') - )->where( - 'option_type_id = ?', - (int)$object->getId() - )->where( - 'store_id = ?', - (int)$object->getStoreId() - ); - $optionTypeId = $this->_getReadAdapter()->fetchOne($select); - - if ($optionTypeId) { - $bind = array('title' => $object->getTitle()); - $where = array( - 'option_type_id = ?' => (int)$optionTypeId, - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->update($titleTable, $bind, $where); - } else { - $bind = array( - 'option_type_id' => (int)$object->getId(), - 'store_id' => (int)$object->getStoreId(), - 'title' => $object->getTitle() - ); - $this->_getWriteAdapter()->insert($titleTable, $bind); - } - } else { - if ($object->getData('scope', 'title')) { - $where = array( - 'option_type_id = ?' => (int)$object->getId(), - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->delete($titleTable, $where); - } - } + /** + * Get first col from from first row for option table + * + * @param string $tableName + * @param int $optionId + * @param int $storeId + * @return string + */ + protected function getOptionIdFromOptionTable($tableName, $optionId, $storeId) + { + $readAdapter = $this->_getReadAdapter(); + $select = $readAdapter->select()->from( + $tableName, + array('option_type_id') + )->where( + 'option_type_id = ?', + $optionId + )->where( + 'store_id = ?', + (int)$storeId + ); + return $readAdapter->fetchOne($select); } + /** * Delete values by option id * diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php index 6b8b1d3fa5a..15a67d8eac5 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php @@ -26,9 +26,8 @@ namespace Magento\Catalog\Service\V1\Category\ProductLinks; use Magento\Catalog\Model\Category as CategoryModel; use Magento\Catalog\Model\CategoryFactory; use Magento\Catalog\Service\V1\Data\Category; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductConverterFactory; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLinkBuilder; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLinkBuilder; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php index 597d5401938..2d9601c55df 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php @@ -27,7 +27,7 @@ interface ReadServiceInterface { /** * @param int $categoryId - * @return \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink[] + * @return \Magento\Catalog\Service\V1\Data\Category\ProductLink[] * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function assignedProducts($categoryId); diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php index b52114a39f1..082b927dd10 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php @@ -29,7 +29,7 @@ use Magento\Catalog\Model\Product as ProductModel; use Magento\Catalog\Model\ProductFactory; use Magento\Catalog\Service\V1\Category\CategoryLoaderFactory; use Magento\Catalog\Service\V1\Data\Category; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\StateException; diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php index cd0c22d8e44..bcf6f752504 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php @@ -23,7 +23,7 @@ */ namespace Magento\Catalog\Service\V1\Category\ProductLinks; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; interface WriteServiceInterface { @@ -31,7 +31,7 @@ interface WriteServiceInterface * Assign a product to the required category * * @param int $categoryId - * @param \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink $productLink + * @param \Magento\Catalog\Service\V1\Data\Category\ProductLink $productLink * @return bool Will returned True if assigned * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\NoSuchEntityException @@ -41,7 +41,7 @@ interface WriteServiceInterface /** * @param int $categoryId - * @param \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink $productLink + * @param \Magento\Catalog\Service\V1\Data\Category\ProductLink $productLink * @return bool Will returned True if updated * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\NoSuchEntityException diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php index 8936631404a..8e0a607ff18 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php @@ -27,7 +27,9 @@ use Magento\Catalog\Model\Category; use Magento\Catalog\Model\CategoryFactory; use Magento\Catalog\Service\V1\Data\Category as CategoryDataObject; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\StateException; use Magento\Catalog\Service\V1\Data\Category\Mapper as CategoryMapper; use Magento\Store\Model\StoreManagerInterface; @@ -94,13 +96,16 @@ class WriteService implements WriteServiceInterface */ public function delete($categoryId) { + if (\Magento\Catalog\Model\Category::TREE_ROOT_ID == $categoryId) { + throw new InputException('Cannot remove the system category.'); + } /** @var Category $category */ $category = $this->loadCategory($categoryId); try { $category->delete(); } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot delete category with id %1', [$categoryId], $e); + throw new StateException('Cannot delete category with id %1', [$categoryId], $e); } return true; @@ -131,10 +136,11 @@ class WriteService implements WriteServiceInterface $model = $this->loadCategory($categoryId); $parentCategory = $this->loadCategory($parentId); - if (is_null($afterId) && $parentCategory->hasChildren()) { + if ($parentCategory->hasChildren()) { $parentChildren = $parentCategory->getChildren(); $categoryIds = explode(',', $parentChildren); - $afterId = array_pop($categoryIds); + $lastId = array_pop($categoryIds); + $afterId = (is_null($afterId) || $afterId > $lastId) ? $lastId : $afterId; } if (strpos($parentCategory->getPath(), $model->getPath()) === 0) { diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php index 29a6ec66464..46d46f87299 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php @@ -39,7 +39,8 @@ interface WriteServiceInterface * * @param int $categoryId category which will deleted * @return bool Will returned True if deleted - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\StateException * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function delete($categoryId); diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.php similarity index 96% rename from app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php rename to app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.php index fe5a6a1976b..8383aa9a983 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.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\Catalog\Service\V1\Data\Eav\Category; +namespace Magento\Catalog\Service\V1\Data\Category; /** * @codeCoverageIgnore diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.php similarity index 96% rename from app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php rename to app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.php index 7b0a76b7e10..6f00b75e686 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.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\Catalog\Service\V1\Data\Eav\Category; +namespace Magento\Catalog\Service\V1\Data\Category; /** * @codeCoverageIgnore diff --git a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php index 33bf85cbaa6..e0eb7642466 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php @@ -136,6 +136,7 @@ class Tree ->setPosition($node->getPosition()) ->setLevel($node->getLevel()) ->setActive($node->getIsActive()) + ->setProductCount($node->getProductCount()) ->setChildren([]); if ($node->hasChildren()) { 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 1b77875b87c..087b9798c7f 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 @@ -32,6 +32,7 @@ class Tree extends \Magento\Framework\Service\Data\AbstractObject const POSITION = 'position'; const LEVEL = 'level'; const CHILDREN = 'children'; + const PRODUCT_COUNT = 'product_count'; /** * Get category ID @@ -93,6 +94,16 @@ class Tree extends \Magento\Framework\Service\Data\AbstractObject return $this->_get(self::LEVEL); } + /** + * Get product count + * + * @return int + */ + public function getProductCount() + { + return $this->_get(self::PRODUCT_COUNT); + } + /** * Get category level * 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 b2250ff04e5..f46ca55aadd 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 @@ -82,6 +82,17 @@ class TreeBuilder extends AbstractObjectBuilder return $this->_set(Tree::POSITION, $position); } + /** + * Set product count + * + * @param int $productCount + * @return int + */ + public function setProductCount($productCount) + { + return $this->_set(Tree::PRODUCT_COUNT, $productCount); + } + /** * Set category level * diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index ff3ef067362..76630102310 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -2,35 +2,35 @@ "name": "magento/module-catalog", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-indexer": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-bundle": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-search": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-product-alert": "0.1.0-alpha89", - "magento/module-url-rewrite": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-indexer": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-bundle": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-search": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-product-alert": "0.1.0-alpha90", + "magento/module-url-rewrite": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/adminhtml/acl.xml b/app/code/Magento/Catalog/etc/acl.xml similarity index 96% rename from app/code/Magento/Catalog/etc/adminhtml/acl.xml rename to app/code/Magento/Catalog/etc/acl.xml index ca0bad3473d..d7e16006409 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/acl.xml +++ b/app/code/Magento/Catalog/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml index 96c4185e5a7..15128975a4c 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml @@ -58,7 +58,9 @@ class="required-entry input-text" type="text" value="${title}" - data-store-label="${title}"> + data-store-label="${title}" + {{if typeof(scopeTitleDisabled) != 'undefined' && scopeTitleDisabled != null}} disabled="disabled" {{/if}} + > {{html checkboxScopeTitle}} </div> </div> @@ -83,7 +85,7 @@ </div> </fieldset> </fieldset> - </div> + </div> </div> </script> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml index 732dc463639..ea85c37c21b 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml @@ -59,11 +59,12 @@ <td class="col-name select-opt-title"> <input name="product[options][${id}][values][${select_id}][option_type_id]" type="hidden" value="${option_type_id}"> <input id="product_option_${id}_select_${select_id}_is_delete" name="product[options][${id}][values][${select_id}][is_delete]" type="hidden" value=""> - <input id="product_option_${id}_select_${select_id}_title" name="product[options][${id}][values][${select_id}][title]" class="required-entry input-text select-type-title" type="text" value="${title}" data-store-label="${title}">{{html checkboxScopeTitle}} + <input id="product_option_${id}_select_${select_id}_title" {{if typeof(scopeTitleDisabled) != 'undefined' && scopeTitleDisabled != null}} disabled="disabled" {{/if}} name="product[options][${id}][values][${select_id}][title]" class="required-entry input-text select-type-title {{if typeof(scopeTitleDisabled) != 'undefined' && scopeTitleDisabled != null}} disabled {{/if}}" type="text" value="${title}" data-store-label="${title}">{{html checkboxScopeTitle}} </td> <?php if ($this->getCanReadPrice() !== false) : ?> <td class="col-price select-opt-price"> <input id="product_option_${id}_select_${select_id}_price" + {{if typeof(scopePriceDisabled) != 'undefined' && scopePriceDisabled != null}} disabled="disabled" {{/if}} name="product[options][${id}][values][${select_id}][price]" class="input-text validate-number product-option-price" type="text" value="${price}" data-store-label="${price}" @@ -71,7 +72,7 @@ disabled="disabled" <?php endif; ?>> </td> - <td class="col-price-type select-opt-price-type"><?php echo $this->getPriceTypeSelectHtml() ?>{{html checkboxScopePrice}}</td> + <td class="col-price-type select-opt-price-type"><?php echo $this->getPriceTypeSelectHtml('{{if typeof(scopePriceDisabled) != "undefined" && scopePriceDisabled != null}} disabled="disabled" {{/if}}') ?>{{html checkboxScopePrice}}</td> <?php else : ?> <input id="product_option_${id}_select_${select_id}_price" name="product[options][${id}][values][${select_id}][price]" type="hidden"> <input id="product_option_${id}_select_${select_id}_price_type" name="product[options][${id}][values][${select_id}][price_type]" type="hidden"> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml index e3692359697..8aef6a6e4b9 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml @@ -30,7 +30,7 @@ </a> <?php $imageBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Image'); ?> <div class="table-wrapper comparison"> - <table class="data-table data table comparison" id="product-comparison" + <table class="data table table-comparison" id="product-comparison" data-mage-init='{"compareList":{ "windowPrintSelector":".action.print", "productsInRow":"5", @@ -65,19 +65,19 @@ <th scope="row" class="cell label product"><span><?php echo __('Product') ?></span></th> <?php endif; ?> <td class="cell product info"> - <a class="product photo" href="<?php echo $this->getProductUrl($_item) ?>" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"> + <a class="product-item-photo" href="<?php echo $this->getProductUrl($_item) ?>" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"> <?php /* product_comparison_list */ ?> <?php echo $imageBlock->init($_item, 'product_comparison_list')->toHtml() ?> </a> - <strong class="product name"> + <strong class="product-item-name"> <a href="<?php echo $this->getProductUrl($_item) ?>" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"> <?php echo $_helper->productAttribute($_item, $_item->getName(), 'name') ?> </a> </strong> <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?> <?php echo $this->getProductPrice($_item, '-compare-list-top') ?> - <div class="product actions"> - <div class="primary"> + <div class="product-item-actions"> + <div class="actions-primary"> <?php if($_item->isSaleable()): ?> <button type="button" class="action tocart primary" data-url="<?php echo $this->helper('Magento\Catalog\Helper\Product\Compare')->getAddToCartUrl($_item) ?>"> @@ -92,7 +92,7 @@ <?php endif; ?> </div> <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()) : ?> - <div class="secondary-addto-links" data-role="add-to-links"> + <div class="secondary-addto-links actions-secondary" data-role="add-to-links"> <a href="#" data-post='<?php echo $this->getAddToWishlistParams($_item); ?>' class="action towishlist" data-action="add-to-wishlist"> <span><?php echo __('Add to Wishlist') ?></span> </a> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml index 85a7526d962..1c1b3024f7d 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list/toolbar.phtml @@ -31,17 +31,19 @@ use \Magento\Catalog\Model\Product\ProductList\Toolbar; ?> <?php if ($this->getCollection()->getSize()): ?> -<div class="toolbar products" data-mage-init='<?php echo $this->getWidgetOptionsJson(); ?>'> - <?php if ($this->isExpanded()): ?> - <div class="settings"> - <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?> - <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?> - </div> - <?php endif; ?> - <?php echo $this->getPagerHtml() ?> - <div class="pager"> + <div class="toolbar toolbar-products" data-mage-init='<?php echo $this->getWidgetOptionsJson(); ?>'> + <?php if ($this->isExpanded()): ?> + <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/viewmode.phtml')) ?> + <?php endif; ?> + <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/amount.phtml')) ?> + + <?php echo $this->getPagerHtml() ?> + <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/limiter.phtml')) ?> + + <?php if ($this->isExpanded()): ?> + <?php include($this->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?> + <?php endif; ?> </div> -</div> <?php endif ?> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml index ca2bf99f653..8f583b7c97e 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml @@ -72,7 +72,7 @@ $imageBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Im . $this->stripTags($_product->getName(), null, true) . '">' . $_helper->productAttribute($_product, $_product->getName(), 'name') . '</a></strong>'; - $info['price'] = $this->getPriceHtml($_product, true); + $info['price'] = $this->getProductPrice($_product); $info['review'] = $this->getReviewsSummaryHtml($_product, $templateType); if ($_product->isSaleable()) { diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/details.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/details.phtml index a7f8a836a7b..1db4a503d3f 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/details.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/details.phtml @@ -36,6 +36,6 @@ <div class="data item title" data-role="collapsible"><a class="data switch" data-toggle="switch" href="#<?php echo $alias; ?>"><?php echo $label; ?></a></div> <div class="data item content" id="<?php echo $alias; ?>" data-role="content"><?php echo $html; ?></div> <?php endforeach;?> - </dl> + </div> </div> <?php endif; ?> diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 8903427a9ae..10f60a27f71 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -660,10 +660,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity '_crosssell_sku', '_crosssell_position', '_upsell_sku', - '_upsell_position', - '_associated_sku', - '_associated_default_qty', - '_associated_position' + '_upsell_position' ), array('_tier_price_website', '_tier_price_customer_group', '_tier_price_qty', '_tier_price_price'), array('_group_price_website', '_group_price_customer_group', '_group_price_price'), diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 086a9a961fc..0425996d87d 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -2,23 +2,21 @@ "name": "magento/module-catalog-import-export", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-import-export": "0.1.0-alpha89", - "magento/module-indexer": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-grouped-product": "0.1.0-alpha89", - "magento/module-configurable-product": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-import-export": "0.1.0-alpha90", + "magento/module-indexer": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogImportExport/etc/di.xml b/app/code/Magento/CatalogImportExport/etc/di.xml index 467acd5938d..c4d6e35f5d2 100644 --- a/app/code/Magento/CatalogImportExport/etc/di.xml +++ b/app/code/Magento/CatalogImportExport/etc/di.xml @@ -31,11 +31,4 @@ <plugin name="invalidateStockIndexerOnImport" type="\Magento\CatalogImportExport\Model\Indexer\Stock\Plugin\Import" /> <plugin name="invalidateEavIndexerOnImport" type="\Magento\CatalogImportExport\Model\Indexer\Product\Eav\Plugin\Import" /> </type> - <type name="Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite"> - <arguments> - <argument name="customizers" xsi:type="array"> - <item name="configurableProduct" xsi:type="string">Magento\CatalogImportExport\Model\Export\RowCustomizer</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/CatalogImportExport/etc/export.xml b/app/code/Magento/CatalogImportExport/etc/export.xml index 9d3fce872ca..6c1b4d4ccdb 100644 --- a/app/code/Magento/CatalogImportExport/etc/export.xml +++ b/app/code/Magento/CatalogImportExport/etc/export.xml @@ -27,7 +27,5 @@ <entity name="catalog_product" label="Products" model="Magento\CatalogImportExport\Model\Export\Product" entityAttributeFilterType="catalog_product"/> <entityType entity="catalog_product" name="simple" model="Magento\CatalogImportExport\Model\Export\Product\Type\Simple" /> <entityType entity="catalog_product" name="virtual" model="Magento\CatalogImportExport\Model\Export\Product\Type\Simple" /> - <entityType entity="catalog_product" name="grouped" model="Magento\CatalogImportExport\Model\Export\Product\Type\Grouped" /> - <entityType entity="catalog_product" name="configurable" model="Magento\CatalogImportExport\Model\Export\Product\Type\Configurable" /> <fileFormat name="csv" label="CSV" model="Magento\ImportExport\Model\Export\Adapter\Csv" /> </config> diff --git a/app/code/Magento/CatalogImportExport/etc/import.xml b/app/code/Magento/CatalogImportExport/etc/import.xml index 74324b3e3ba..9ef92240f45 100644 --- a/app/code/Magento/CatalogImportExport/etc/import.xml +++ b/app/code/Magento/CatalogImportExport/etc/import.xml @@ -27,8 +27,6 @@ <entity name="catalog_product" label="Products" model="Magento\CatalogImportExport\Model\Import\Product" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" /> <entityType entity="catalog_product" name="simple" model="Magento\CatalogImportExport\Model\Import\Product\Type\Simple" /> <entityType entity="catalog_product" name="virtual" model="Magento\CatalogImportExport\Model\Import\Product\Type\Simple" /> - <entityType entity="catalog_product" name="grouped" model="Magento\CatalogImportExport\Model\Import\Product\Type\Grouped" /> - <entityType entity="catalog_product" name="configurable" model="Magento\CatalogImportExport\Model\Import\Product\Type\Configurable" /> <relatedIndexer entity="catalog_product" name="catalog_product_price" /> <relatedIndexer entity="catalog_product" name="catalogsearch_fulltext" /> <relatedIndexer entity="catalog_product" name="catalog_product_flat" /> diff --git a/app/code/Magento/CatalogImportExport/etc/module.xml b/app/code/Magento/CatalogImportExport/etc/module.xml index f4dfd26b5d9..d6c6bf1fa3f 100644 --- a/app/code/Magento/CatalogImportExport/etc/module.xml +++ b/app/code/Magento/CatalogImportExport/etc/module.xml @@ -34,8 +34,6 @@ <module name="Magento_Store"/> <module name="Magento_CatalogInventory"/> <module name="Magento_Customer"/> - <module name="Magento_GroupedProduct"/> - <module name="Magento_ConfigurableProduct"/> </depends> </module> </config> diff --git a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php index 79c275304cf..d6fa3ad65e9 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php +++ b/app/code/Magento/CatalogInventory/Service/V1/Data/StockItemDetails.php @@ -63,7 +63,7 @@ class StockItemDetails extends AbstractObject /**#@-*/ /** - * @return float + * @return float|null */ public function getQty() { @@ -71,7 +71,7 @@ class StockItemDetails extends AbstractObject } /** - * @return float + * @return float|null */ public function getMinQty() { @@ -79,7 +79,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function getIsQtyDecimal() { @@ -87,7 +87,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function isBackorders() { @@ -95,7 +95,7 @@ class StockItemDetails extends AbstractObject } /** - * @return float + * @return float|null */ public function getMinSaleQty() { @@ -103,7 +103,7 @@ class StockItemDetails extends AbstractObject } /** - * @return float + * @return float|null */ public function getMaxSaleQty() { @@ -111,7 +111,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function getIsInStock() { @@ -119,7 +119,7 @@ class StockItemDetails extends AbstractObject } /** - * @return string + * @return string|null */ public function getLowStockDate() { @@ -127,7 +127,7 @@ class StockItemDetails extends AbstractObject } /** - * @return float + * @return float|null */ public function getNotifyStockQty() { @@ -135,7 +135,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function isManageStock() { @@ -143,7 +143,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function isStockStatusChangedAuto() { @@ -151,7 +151,7 @@ class StockItemDetails extends AbstractObject } /** - * @return float + * @return float|null */ public function getQtyIncrements() { @@ -159,7 +159,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function isEnableQtyIncrements() { @@ -167,7 +167,7 @@ class StockItemDetails extends AbstractObject } /** - * @return bool + * @return bool|null */ public function getIsDecimalDivided() { diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 5fef7ba97da..f9750651c87 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-catalog-inventory", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-indexer": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-indexer": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/etc/adminhtml/acl.xml b/app/code/Magento/CatalogInventory/etc/acl.xml similarity index 94% rename from app/code/Magento/CatalogInventory/etc/adminhtml/acl.xml rename to app/code/Magento/CatalogInventory/etc/acl.xml index c7ceecc5506..285a510a2a3 100644 --- a/app/code/Magento/CatalogInventory/etc/adminhtml/acl.xml +++ b/app/code/Magento/CatalogInventory/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/CatalogInventory/etc/webapi.xml b/app/code/Magento/CatalogInventory/etc/webapi.xml index de443919ca7..25eef2be1b9 100644 --- a/app/code/Magento/CatalogInventory/etc/webapi.xml +++ b/app/code/Magento/CatalogInventory/etc/webapi.xml @@ -31,7 +31,7 @@ <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockItem/:productSku" method="POST"> + <route url="/V1/stockItem/:productSku" method="PUT"> <service class="Magento\CatalogInventory\Service\V1\StockItemServiceInterface" method="saveStockItemBySku"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> @@ -44,7 +44,7 @@ <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockItem/lowStock/" method="PUT"> + <route url="/V1/stockItem/lowStock/" method="GET"> <service class="Magento\CatalogInventory\Service\V1\StockStatusServiceInterface" method="getLowStockItems"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 1078ad11fc5..6a1e618d320 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -2,19 +2,19 @@ "name": "magento/module-catalog-rule", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-rule": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-rule": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogRule/etc/adminhtml/acl.xml b/app/code/Magento/CatalogRule/etc/acl.xml similarity index 93% rename from app/code/Magento/CatalogRule/etc/adminhtml/acl.xml rename to app/code/Magento/CatalogRule/etc/acl.xml index 49694bd4a88..a08b52ccbb5 100644 --- a/app/code/Magento/CatalogRule/etc/adminhtml/acl.xml +++ b/app/code/Magento/CatalogRule/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 4a8594d5454..8942d05ba4e 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-catalog-search", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/etc/adminhtml/acl.xml b/app/code/Magento/CatalogSearch/etc/acl.xml similarity index 93% rename from app/code/Magento/CatalogSearch/etc/adminhtml/acl.xml rename to app/code/Magento/CatalogSearch/etc/acl.xml index 76081cbaba7..9da0b4e2bd8 100644 --- a/app/code/Magento/CatalogSearch/etc/adminhtml/acl.xml +++ b/app/code/Magento/CatalogSearch/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/CatalogSearch/view/frontend/templates/form.mini.phtml b/app/code/Magento/CatalogSearch/view/frontend/templates/form.mini.phtml index 9079ef2bcdb..cdf1ba1eb18 100644 --- a/app/code/Magento/CatalogSearch/view/frontend/templates/form.mini.phtml +++ b/app/code/Magento/CatalogSearch/view/frontend/templates/form.mini.phtml @@ -27,9 +27,9 @@ /** @var $helper \Magento\CatalogSearch\Helper\Data */ $helper = $this->helper('Magento\CatalogSearch\Helper\Data'); ?> -<div class="block search"> - <div class="title"><strong><?php echo __('Search'); ?></strong></div> - <div class="content search"> +<div class="block block-search"> + <div class="block block-title"><strong><?php echo __('Search'); ?></strong></div> + <div class="block block-content"> <form class="form minisearch" id="search_mini_form" action="<?php echo $helper->getResultUrl() ?>" method="get"> <div class="field search"> <label class="label" for="search"><span><?php echo __('Search'); ?></span></label> @@ -46,7 +46,7 @@ $helper = $this->helper('Magento\CatalogSearch\Helper\Data'); placeholder="<?php echo __('Search entire store here...'); ?>" class="input-text" autocomplete="off"/> - <div id="search_autocomplete" class="search autocomplete"></div> + <div id="search_autocomplete" class="search-autocomplete"></div> <div class="nested"> <a class="action advanced" href="<?php echo $helper->getAdvancedSearchUrl(); ?>"> <?php echo __('Advanced Search'); ?> diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 54b974665bf..7c65d2df592 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-catalog-url-rewrite", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-url-redirect": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89" + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-url-redirect": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index 1f4cbfb18b7..d3387325b8f 100644 --- a/app/code/Magento/Centinel/composer.json +++ b/app/code/Magento/Centinel/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-centinel", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index c28297f672c..2f2b214c8cf 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -36,6 +36,7 @@ use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\CustomerAddressServiceInterface; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface as CustomerMetadata; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; class Onepage { @@ -148,6 +149,11 @@ class Onepage /** @var CustomerAccountServiceInterface */ protected $_customerAccountService; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Checkout\Helper\Data $helper @@ -171,6 +177,7 @@ class Onepage * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param CustomerAddressServiceInterface $customerAddressService + * @param OrderSender $orderSender */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, @@ -194,7 +201,8 @@ class Onepage \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Encryption\EncryptorInterface $encryptor, CustomerAddressServiceInterface $customerAddressService, - CustomerAccountServiceInterface $accountService + CustomerAccountServiceInterface $accountService, + OrderSender $orderSender ) { $this->_eventManager = $eventManager; $this->_customerData = $customerData; @@ -218,6 +226,7 @@ class Onepage $this->_encryptor = $encryptor; $this->_customerAddressService = $customerAddressService; $this->_customerAccountService = $accountService; + $this->orderSender = $orderSender; } /** @@ -943,7 +952,7 @@ class Onepage */ if (!$redirectUrl && $order->getCanSendNewEmailFlag()) { try { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } catch (\Exception $e) { $this->_logger->logException($e); } diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php new file mode 100644 index 00000000000..8c2fa58e98b --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php @@ -0,0 +1,72 @@ +<?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\Checkout\Service\V1\Address\Billing; + +use \Magento\Checkout\Service\V1\Address\Converter as AddressConverter; + +class ReadService implements ReadServiceInterface +{ + /** + * @var \Magento\Checkout\Service\V1\QuoteLoader + */ + protected $quoteLoader; + + /** + * @var AddressConverter + */ + protected $addressConverter; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param AddressConverter $addressConverter + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, + AddressConverter $addressConverter, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->quoteLoader = $quoteLoader; + $this->addressConverter = $addressConverter; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function getAddress($cartId) + { + $storeId = $this->storeManager->getStore()->getId(); + + /** @var \Magento\Sales\Model\Quote\Address $address */ + $address = $this->quoteLoader->load($cartId, $storeId)->getBillingAddress(); + return $this->addressConverter->convertModelToDataObject($address); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php new file mode 100644 index 00000000000..690cfd7c30f --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadServiceInterface.php @@ -0,0 +1,38 @@ +<?php +/** + * Quote billing address service + * + * 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\Checkout\Service\V1\Address\Billing; + +interface ReadServiceInterface +{ + /** + * Get billing address of the quote + * + * @param int $cartId + * @return \Magento\Checkout\Service\V1\Data\Cart\Address + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getAddress($cartId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php new file mode 100644 index 00000000000..c94d3dc4b18 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php @@ -0,0 +1,115 @@ +<?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\Checkout\Service\V1\Address\Billing; + +use Magento\Framework\Exception\InputException; +use Magento\Framework\Logger; +use \Magento\Checkout\Service\V1\QuoteLoader; +use \Magento\Sales\Model\Quote\AddressFactory; +use \Magento\Store\Model\StoreManagerInterface; +use \Magento\Checkout\Service\V1\Address\Converter; +use \Magento\Checkout\Service\V1\Address\Validator; + +class WriteService implements WriteServiceInterface +{ + /** + * @var Validator + */ + protected $addressValidator; + + /** + * @var Logger + */ + protected $logger; + + /** + * @var AddressFactory + */ + protected $quoteAddressFactory; + + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * @var Converter + */ + protected $addressConverter; + + /** + * @var QuoteLoader + */ + protected $quoteLoader; + + /** + * @param QuoteLoader $quoteLoader + * @param StoreManagerInterface $storeManager + * @param Converter $addressConverter + * @param Validator $addressValidator + * @param AddressFactory $quoteAddressFactory + * @param Logger $logger + */ + public function __construct( + QuoteLoader $quoteLoader, + StoreManagerInterface $storeManager, + Converter $addressConverter, + Validator $addressValidator, + AddressFactory $quoteAddressFactory, + Logger $logger + ) { + $this->addressValidator = $addressValidator; + $this->storeManager = $storeManager; + $this->logger = $logger; + $this->quoteLoader = $quoteLoader; + $this->quoteAddressFactory = $quoteAddressFactory; + $this->addressConverter = $addressConverter; + } + + /** + * {@inheritdoc} + */ + public function setAddress($cartId, $addressData) + { + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + /** @var \Magento\Sales\Model\Quote\Address $address */ + $address = $this->quoteAddressFactory->create(); + $this->addressValidator->validate($addressData); + if ($addressData->getId()) { + $address->load($addressData->getId()); + } + $address = $this->addressConverter->convertDataObjectToModel($addressData, $address); + $quote->setBillingAddress($address); + $quote->setDataChanges(true); + try { + $quote->save(); + } catch (\Exception $e) { + $this->logger->logException($e); + throw new InputException('Unable to save address. Please, check input data.'); + } + return $quote->getBillingAddress()->getId(); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php new file mode 100644 index 00000000000..406c6860684 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteServiceInterface.php @@ -0,0 +1,40 @@ +<?php +/** + * Quote billing address service + * + * 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\Checkout\Service\V1\Address\Billing; + +interface WriteServiceInterface +{ + /** + * Assign billing address to cart + * + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\InputException + * @param int $cartId + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData + * @return int + */ + public function setAddress($cartId, $addressData); +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Converter.php b/app/code/Magento/Checkout/Service/V1/Address/Converter.php new file mode 100644 index 00000000000..def300b8fd3 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Converter.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\Checkout\Service\V1\Address; + +use \Magento\Checkout\Service\V1\Data\Cart\Address; +use \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\Address\Region; +use \Magento\Framework\Service\Data\Eav\AttributeValue; + +class Converter +{ + /** + * @var AddressBuilder + */ + protected $addressBuilder; + + /** + * @param AddressBuilder $addressBuilder + */ + public function __construct(AddressBuilder $addressBuilder) + { + $this->addressBuilder = $addressBuilder; + } + + /** + * @param \Magento\Sales\Model\Quote\Address $address + * @return \Magento\Checkout\Service\V1\Data\Cart\Address + */ + public function convertModelToDataObject(\Magento\Sales\Model\Quote\Address $address) + { + $data = [ + Address::KEY_COUNTRY_ID => $address->getCountryId(), + Address::KEY_ID => $address->getId(), + Address::KEY_CUSTOMER_ID => $address->getCustomerId(), + Address::KEY_REGION => array( + Region::KEY_REGION => $address->getRegion(), + Region::KEY_REGION_ID => $address->getRegionId(), + Region::KEY_REGION_CODE => $address->getRegionCode() + ), + Address::KEY_STREET => $address->getStreet(), + Address::KEY_COMPANY => $address->getCompany(), + Address::KEY_TELEPHONE => $address->getTelephone(), + Address::KEY_FAX => $address->getFax(), + Address::KEY_POSTCODE => $address->getPostcode(), + Address::KEY_CITY => $address->getCity(), + Address::KEY_FIRSTNAME => $address->getFirstname(), + Address::KEY_LASTNAME => $address->getLastname(), + Address::KEY_MIDDLENAME => $address->getMiddlename(), + Address::KEY_PREFIX => $address->getPrefix(), + Address::KEY_SUFFIX => $address->getSuffix(), + Address::KEY_EMAIL => $address->getEmail(), + Address::KEY_VAT_ID => $address->getVatId() + ]; + + foreach ($this->addressBuilder->getCustomAttributesCodes() as $attributeCode) { + $method = 'get' . \Magento\Framework\Service\DataObjectConverter::snakeCaseToCamelCase($attributeCode); + $data[Address::CUSTOM_ATTRIBUTES_KEY][] = + [AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $address->$method()]; + } + + return $this->addressBuilder->populateWithArray($data)->create(); + } + + /** + * Convert address data object to quote address model + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $dataObject + * @param \Magento\Sales\Model\Quote\Address $address + * @return \Magento\Sales\Model\Quote\Address + */ + public function convertDataObjectToModel($dataObject, $address) + { + $address->setData($dataObject->__toArray()); + + //set custom attributes + $customAttributes = $dataObject->getCustomAttributes(); + /** @var \Magento\Framework\Service\Data\Eav\AttributeValue $attributeData */ + foreach ($customAttributes as $attributeData) { + $address->setData($attributeData->getAttributeCode(), $attributeData->getValue()); + } + + //set fields with custom logic + $address->setStreet($dataObject->getStreet()); + $address->setRegionId($dataObject->getRegion()->getRegionId()); + $address->setRegion($dataObject->getRegion()->getRegion()); + + return $address; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php new file mode 100644 index 00000000000..4c3e9289a48 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.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\Checkout\Service\V1\Address\Shipping; + +use \Magento\Checkout\Service\V1\Address\Converter as AddressConverter; +use \Magento\Framework\Exception\NoSuchEntityException; + +class ReadService implements ReadServiceInterface +{ + /** + * @var \Magento\Checkout\Service\V1\QuoteLoader + */ + protected $quoteLoader; + + /** + * @var AddressConverter + */ + protected $addressConverter; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param AddressConverter $addressConverter + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, + AddressConverter $addressConverter, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->quoteLoader = $quoteLoader; + $this->addressConverter = $addressConverter; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function getAddress($cartId) + { + $storeId = $this->storeManager->getStore()->getId(); + + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $storeId); + if ($quote->isVirtual()) { + throw new NoSuchEntityException( + 'Cart contains virtual product(s) only. Shipping address is not applicable' + ); + } + + /** @var \Magento\Sales\Model\Quote\Address $address */ + $address = $quote->getShippingAddress(); + return $this->addressConverter->convertModelToDataObject($address); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php new file mode 100644 index 00000000000..d657f9c0201 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceInterface.php @@ -0,0 +1,38 @@ +<?php +/** + * Quote shipping address service + * + * 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\Checkout\Service\V1\Address\Shipping; + +interface ReadServiceInterface +{ + /** + * Get shipping address of the quote + * + * @param int $cartId + * @return \Magento\Checkout\Service\V1\Data\Cart\Address + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getAddress($cartId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php new file mode 100644 index 00000000000..96276b6fd7b --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.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\Checkout\Service\V1\Address\Shipping; + +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Logger; + +class WriteService implements WriteServiceInterface +{ + /** + * @var \Magento\Checkout\Service\V1\QuoteLoader + */ + protected $quoteLoader; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\Sales\Model\Quote\AddressFactory + */ + protected $quoteAddressFactory; + + /** + * @var \Magento\Checkout\Service\V1\Address\Converter + */ + protected $addressConverter; + + /** + * @var \Magento\Checkout\Service\V1\Address\Validator + */ + protected $addressValidator; + + /** + * @var Logger + */ + protected $logger; + + /** + * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Checkout\Service\V1\Address\Converter $addressConverter + * @param \Magento\Checkout\Service\V1\Address\Validator $addressValidator + * @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory + * @param Logger $logger + */ + public function __construct( + \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Checkout\Service\V1\Address\Converter $addressConverter, + \Magento\Checkout\Service\V1\Address\Validator $addressValidator, + \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, + Logger $logger + ) { + $this->quoteLoader = $quoteLoader; + $this->quoteAddressFactory = $quoteAddressFactory; + $this->addressConverter = $addressConverter; + $this->addressValidator = $addressValidator; + $this->storeManager = $storeManager; + $this->logger = $logger; + } + + /** + * {@inheritdoc} + */ + public function setAddress($cartId, $addressData) + { + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); + if ($quote->isVirtual()) { + throw new NoSuchEntityException( + 'Cart contains virtual product(s) only. Shipping address is not applicable' + ); + } + /** @var \Magento\Sales\Model\Quote\Address $address */ + $address = $this->quoteAddressFactory->create(); + $this->addressValidator->validate($addressData); + if ($addressData->getId()) { + $address->load($addressData->getId()); + } + $address = $this->addressConverter->convertDataObjectToModel($addressData, $address); + $address->setSameAsBilling(0); + $quote->setShippingAddress($address); + $quote->setDataChanges(true); + try { + $quote->save(); + } catch (\Exception $e) { + $this->logger->logException($e); + throw new InputException('Unable to save address. Please, check input data.'); + } + return $quote->getShippingAddress()->getId(); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php new file mode 100644 index 00000000000..caa591b0362 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceInterface.php @@ -0,0 +1,40 @@ +<?php +/** + * Quote shipping address service + * + * 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\Checkout\Service\V1\Address\Shipping; + +interface WriteServiceInterface +{ + /** + * Assign shipping address to cart + * + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\InputException + * @param int $cartId + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData + * @return int + */ + public function setAddress($cartId, $addressData); +} diff --git a/app/code/Magento/Checkout/Service/V1/Address/Validator.php b/app/code/Magento/Checkout/Service/V1/Address/Validator.php new file mode 100644 index 00000000000..6390f90e3b5 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Address/Validator.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\Checkout\Service\V1\Address; + +class Validator +{ + /** + * @var \Magento\Sales\Model\Quote\AddressFactory + */ + protected $quoteAddressFactory; + + /** + * @var \Magento\Customer\Model\CustomerFactory + */ + protected $customerFactory; + + /** + * @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory + * @param \Magento\Customer\Model\CustomerFactory $customerFactory + */ + public function __construct( + \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, + \Magento\Customer\Model\CustomerFactory $customerFactory + ) { + $this->quoteAddressFactory = $quoteAddressFactory; + $this->customerFactory = $customerFactory; + } + + /** + * Validate data object fields + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $addressData + * @return bool + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function validate($addressData) + { + //validate customer id + if ($addressData->getCustomerId()) { + $customer = $this->customerFactory->create(); + $customer->load($addressData->getCustomerId()); + if (!$customer->getId()) { + throw new \Magento\Framework\Exception\NoSuchEntityException( + 'Invalid customer id ' . $addressData->getCustomerId() + ); + } + } + + // validate address id + if ($addressData->getId()) { + $address = $this->quoteAddressFactory->create(); + $address->load($addressData->getId()); + if (!$address->getId()) { + throw new \Magento\Framework\Exception\NoSuchEntityException( + 'Invalid address id ' . $addressData->getId() + ); + } + + // check correspondence between customer id and address id + if ($addressData->getCustomerId()) { + if ($address->getCustomerId() != $addressData->getCustomerId()) { + throw new \Magento\Framework\Exception\InputException( + 'Address with id ' . $addressData->getId() . ' belongs to another customer' + ); + } + } + } + return true; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadService.php new file mode 100644 index 00000000000..70b272700d7 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/ReadService.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\Checkout\Service\V1\Cart; + +use \Magento\Framework\Service\V1\Data\SearchCriteria; +use \Magento\Sales\Model\QuoteFactory; +use \Magento\Sales\Model\Quote; +use \Magento\Sales\Model\Resource\Quote\Collection as QuoteCollection; + +use \Magento\Framework\Exception\NoSuchEntityException; +use \Magento\Framework\Exception\InputException; +use \Magento\Framework\Service\V1\Data\Search\FilterGroup; +use \Magento\Checkout\Service\V1\Data\CartBuilder; +use \Magento\Checkout\Service\V1\Data\CartSearchResultsBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\CustomerBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\CurrencyBuilder; +use \Magento\Checkout\Service\V1\Data\Cart; +use \Magento\Checkout\Service\V1\Data\Cart\Totals; +use \Magento\Checkout\Service\V1\Data\Cart\Customer; +use \Magento\Checkout\Service\V1\Data\Cart\Currency; + +class ReadService implements ReadServiceInterface +{ + /** + * @var QuoteFactory + */ + private $quoteFactory; + + /** + * @var CartBuilder + */ + private $cartBuilder; + + /** + * @var QuoteCollection + */ + private $quoteCollection; + + /** + * @var CartSearchResultsBuilder + */ + private $searchResultsBuilder; + + /** + * @var CustomerBuilder + */ + private $customerBuilder; + + /** + * @var TotalsBuilder + */ + private $totalsBuilder; + + /** + * @var CurrencyBuilder; + */ + private $currencyBuilder; + + /** + * @var array + */ + private $validSearchFields = array( + 'id', 'store_id', 'created_at', 'updated_at', 'converted_at', 'is_active', 'is_virtual', + 'items_count', 'items_qty', 'checkout_method', 'reserved_order_id', 'orig_order_id', 'base_grand_total', + 'grand_total', 'base_subtotal', 'subtotal', 'base_subtotal_with_discount', 'subtotal_with_discount', + 'customer_is_guest', 'customer_id', 'customer_group_id', 'customer_id', 'customer_tax_class_id', + 'customer_email', 'global_currency_code', 'base_currency_code', 'store_currency_code', 'quote_currency_code', + 'store_to_base_rate', 'store_to_quote_rate', 'base_to_global_rate', 'base_to_quote_rate', + ); + + /** + * Cart data object - quote field map + * + * @var array + */ + private $searchFieldMap = array( + 'id' => 'entity_id', + ); + + /** + * @param QuoteFactory $quoteFactory + * @param QuoteCollection $quoteCollection + * @param CartBuilder $cartBuilder + * @param CartSearchResultsBuilder $searchResultsBuilder + * @param TotalsBuilder $totalsBuilder + * @param CustomerBuilder $customerBuilder + * @param CurrencyBuilder $currencyBuilder + */ + public function __construct( + QuoteFactory $quoteFactory, + QuoteCollection $quoteCollection, + CartBuilder $cartBuilder, + CartSearchResultsBuilder $searchResultsBuilder, + TotalsBuilder $totalsBuilder, + CustomerBuilder $customerBuilder, + CurrencyBuilder $currencyBuilder + ) { + $this->quoteFactory = $quoteFactory; + $this->quoteCollection = $quoteCollection; + $this->cartBuilder = $cartBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + $this->totalsBuilder = $totalsBuilder; + $this->customerBuilder = $customerBuilder; + $this->currencyBuilder = $currencyBuilder; + } + + /** + * {@inheritdoc} + */ + public function getCart($cartId) + { + $quote = $this->quoteFactory->create()->load($cartId); + if ($quote->getId() != $cartId) { + throw new NoSuchEntityException('There is no cart with provided ID.'); + } + return $this->createCartDataObject($quote); + } + + /** + * {@inheritdoc} + */ + public function getCartList(SearchCriteria $searchCriteria) + { + $this->searchResultsBuilder->setSearchCriteria($searchCriteria); + + foreach ($searchCriteria->getFilterGroups() as $group) { + $this->addFilterGroupToCollection($group, $this->quoteCollection); + } + + $this->searchResultsBuilder->setTotalCount($this->quoteCollection->getSize()); + $sortOrders = $searchCriteria->getSortOrders(); + if ($sortOrders) { + foreach ($sortOrders as $field => $direction) { + $this->quoteCollection->addOrder( + $this->getQuoteSearchField($field), + $direction == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC' + ); + } + } + $this->quoteCollection->setCurPage($searchCriteria->getCurrentPage()); + $this->quoteCollection->setPageSize($searchCriteria->getPageSize()); + + $cartList = []; + /** @var Quote $quote */ + foreach ($this->quoteCollection as $quote) { + $cartList[] = $this->createCartDataObject($quote); + } + $this->searchResultsBuilder->setItems($cartList); + + return $this->searchResultsBuilder->create(); + } + + /** + * Create cart data object based on given quote + * + * @param Quote $quote + * @return Cart + */ + protected function createCartDataObject(Quote $quote) + { + $this->cartBuilder->populateWithArray(array( + Cart::ID => $quote->getId(), + Cart::STORE_ID => $quote->getStoreId(), + Cart::CREATED_AT => $quote->getCreatedAt(), + Cart::UPDATED_AT => $quote->getUpdatedAt(), + Cart::CONVERTED_AT => $quote->getConvertedAt(), + Cart::IS_ACTIVE => $quote->getIsActive(), + Cart::IS_VIRTUAL => $quote->getIsVirtual(), + Cart::ITEMS_COUNT => $quote->getItemsCount(), + Cart::ITEMS_QUANTITY => $quote->getItemsQty(), + Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), + Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), + Cart::ORIG_ORDER_ID => $quote->getOrigOrderId(), + )); + + $this->totalsBuilder->populateWithArray(array( + Totals::BASE_GRAND_TOTAL => $quote->getBaseGrandTotal(), + Totals::GRAND_TOTAL => $quote->getGrandTotal(), + Totals::BASE_SUBTOTAL => $quote->getBaseSubtotal(), + Totals::SUBTOTAL => $quote->getSubtotal(), + Totals::BASE_SUBTOTAL_WITH_DISCOUNT => $quote->getBaseSubtotalWithDiscount(), + Totals::SUBTOTAL_WITH_DISCOUNT => $quote->getSubtotalWithDiscount(), + )); + + $this->customerBuilder->populateWithArray(array( + Customer::ID => $quote->getCustomerId(), + Customer::EMAIL => $quote->getCustomerEmail(), + Customer::GROUP_ID => $quote->getCustomerGroupId(), + Customer::TAX_CLASS_ID => $quote->getCustomerTaxClassId(), + Customer::PREFIX => $quote->getCustomerPrefix(), + Customer::FIRST_NAME => $quote->getCustomerFirstname(), + Customer::MIDDLE_NAME => $quote->getCustomerMiddlename(), + Customer::LAST_NAME => $quote->getCustomerLastname(), + Customer::SUFFIX => $quote->getCustomerSuffix(), + Customer::DOB => $quote->getCustomerDob(), + Customer::NOTE => $quote->getCustomerNote(), + Customer::NOTE_NOTIFY => $quote->getCustomerNoteNotify(), + Customer::IS_GUEST => $quote->getCustomerIsGuest(), + Customer::GENDER => $quote->getCustomerGender(), + Customer::TAXVAT => $quote->getCustomerTaxvat(), + )); + + $this->currencyBuilder->populateWithArray(array( + Currency::GLOBAL_CURRENCY_CODE => $quote->getGlobalCurrencyCode(), + Currency::BASE_CURRENCY_CODE => $quote->getBaseCurrencyCode(), + Currency::STORE_CURRENCY_CODE => $quote->getStoreCurrencyCode(), + Currency::QUOTE_CURRENCY_CODE => $quote->getQuoteCurrencyCode(), + Currency::STORE_TO_BASE_RATE => $quote->getStoreToBaseRate(), + Currency::STORE_TO_QUOTE_RATE => $quote->getStoreToQuoteRate(), + Currency::BASE_TO_GLOBAL_RATE => $quote->getBaseToGlobalRate(), + Currency::BASE_TO_QUOTE_RATE => $quote->getBaseToQuoteRate(), + )); + + $this->cartBuilder->setCustomer($this->customerBuilder->create()); + $this->cartBuilder->setTotals($this->totalsBuilder->create()); + $this->cartBuilder->setCurrency($this->currencyBuilder->create()); + return $this->cartBuilder->create(); + } + + /** + * Add FilterGroup to the given quote collection. + * + * @param FilterGroup $filterGroup + * @param QuoteCollection $collection + * @return void + * @throws InputException + */ + protected function addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCollection $collection) + { + $fields = []; + $conditions = []; + foreach ($filterGroup->getFilters() as $filter) { + $fields[] = $this->getQuoteSearchField($filter->getField()); + $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; + $conditions[] = array($condition => $filter->getValue()); + } + if ($fields) { + $collection->addFieldToFilter($fields, $conditions); + } + } + + /** + * Retrieve mapped search field + * + * @param string $field + * @return string + * @throws InputException + */ + protected function getQuoteSearchField($field) + { + if (!in_array($field, $this->validSearchFields)) { + throw new InputException("Field '{$field}' cannot be used for search."); + } + return isset($this->searchFieldMap[$field]) ? $this->searchFieldMap[$field] : $field; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php new file mode 100644 index 00000000000..6b309e31b1e --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/ReadServiceInterface.php @@ -0,0 +1,46 @@ +<?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\Checkout\Service\V1\Cart; + +use \Magento\Framework\Service\V1\Data\SearchCriteria; + +interface ReadServiceInterface +{ + /** + * Retrieve information about cart represented by given ID + * + * @param int $cartId + * @return \Magento\Checkout\Service\V1\Data\Cart + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getCart($cartId); + + /** + * Retrieve list of carts that match given search criteria + * + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Checkout\Service\V1\Data\CartSearchResults + */ + public function getCartList(SearchCriteria $searchCriteria); +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php new file mode 100644 index 00000000000..9ea16bab045 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php @@ -0,0 +1,108 @@ +<?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\Checkout\Service\V1\Cart; + +use Magento\Framework\Exception\CouldNotSaveException; +use \Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\StateException; + +class WriteService implements WriteServiceInterface +{ + /** + * @var \Magento\Sales\Model\QuoteFactory + */ + protected $quoteFactory; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\Customer\Model\CustomerRegistry + */ + protected $customerRegistry; + + /** + * @param \Magento\Sales\Model\QuoteFactory $quoteFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry + */ + public function __construct( + \Magento\Sales\Model\QuoteFactory $quoteFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Customer\Model\CustomerRegistry $customerRegistry + ) { + $this->quoteFactory = $quoteFactory; + $this->storeManager = $storeManager; + $this->customerRegistry = $customerRegistry; + } + + /** + * {@inheritdoc} + */ + public function create() + { + $storeId = $this->storeManager->getStore()->getId(); + + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteFactory->create(); + $quote->setStoreId($storeId); + try { + $quote->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Cannot create quote'); + } + return $quote->getId(); + } + + /** + * {@inheritdoc} + */ + public function assignCustomer($cartId, $customerId) + { + $storeId = $this->storeManager->getStore()->getId(); + $quote = $this->quoteFactory->create()->load($cartId); + if ($quote->getId() != $cartId || $quote->getStoreId() != $storeId) { + throw new NoSuchEntityException('There is no cart with provided ID.'); + } + $customer = $this->customerRegistry->retrieve($customerId); + if (!in_array($storeId, $customer->getSharedStoreIds())) { + throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.'); + } + if ($quote->getCustomerId()) { + throw new StateException('Cannot assign customer to the given cart. The cart is not anonymous.'); + } + $currentCustomerQuote = $this->quoteFactory->create()->loadByCustomer($customer); + if ($currentCustomerQuote->getId()) { + throw new StateException('Cannot assign customer to the given cart. Customer already has active cart.'); + } + + $quote->setCustomer($customer); + $quote->setCustomerIsGuest(0); + $quote->save(); + return true; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php new file mode 100644 index 00000000000..6f761b98e07 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteServiceInterface.php @@ -0,0 +1,44 @@ +<?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\Checkout\Service\V1\Cart; + +interface WriteServiceInterface +{ + /** + * Create empty cart/quote for anonymous customer + * + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @return int cart id + */ + public function create(); + + /** + * Assign customer to the given shopping cart + * + * @param int $cartId + * @param int $customerId + * @return boolean + */ + public function assignCustomer($cartId, $customerId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart.php b/app/code/Magento/Checkout/Service/V1/Data/Cart.php new file mode 100644 index 00000000000..103d8b0ee26 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart.php @@ -0,0 +1,252 @@ +<?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\Checkout\Service\V1\Data; + +/** + * Cart data object + * + * @codeCoverageIgnore + */ +class Cart extends \Magento\Framework\Service\Data\AbstractObject +{ + const ID = 'id'; + + const STORE_ID = 'store_id'; + + const CREATED_AT = 'created_at'; + + const UPDATED_AT = 'updated_at'; + + const CONVERTED_AT = 'converted_at'; + + const IS_ACTIVE = 'is_active'; + + const IS_VIRTUAL = 'is_virtual'; + + const ITEMS = 'items'; + + const ITEMS_COUNT = 'items_count'; + + const ITEMS_QUANTITY = 'items_qty'; + + const CUSTOMER = 'customer'; + + const CHECKOUT_METHOD = 'checkout_method'; + + const SHIPPING_ADDRESS = 'shipping_address'; + + const BILLING_ADDRESS = 'shipping_address'; + + const TOTALS = 'totals'; + + const RESERVED_ORDER_ID = 'reserved_order_id'; + + const ORIG_ORDER_ID = 'orig_order_id'; + + const CURRENCY = 'currency'; + + /** + * Cart/Quote id + * + * @return int + */ + public function getId() + { + return $this->_get(self::ID); + } + + /** + * Store id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Creation date and time + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Last update date and time + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Get conversion date and time + * + * @return string|null + */ + public function getConvertedAt() + { + return $this->_get(self::CONVERTED_AT); + } + + /** + * Get active status flag + * + * @return bool|null + */ + public function getIsActive() + { + $value = $this->_get(self::IS_ACTIVE); + if (!is_null($value)) { + $value = (bool)$value; + } + + return $value; + } + + /** + * Get virtual flag(cart contains virtual products) + * + * @return bool|null + */ + public function getIsVirtual() + { + $value = $this->_get(self::IS_VIRTUAL); + if (!is_null($value)) { + $value = (bool)$value; + } + + return $value; + } + + /** + * Get cart items + * + * @return \Magento\Checkout\Service\V1\Data\Cart\Item[]|null + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } + + /** + * Amount of different items/products in cart + * + * @return int|null + */ + public function getItemsCount() + { + return $this->_get(self::ITEMS_COUNT); + } + + /** + * Get quantity of all items/products in cart + * + * @return float|null + */ + public function getItemsQty() + { + return $this->_get(self::ITEMS_QUANTITY); + } + + /** + * Get customer data + * + * @return \Magento\Checkout\Service\V1\Data\Cart\Customer + */ + public function getCustomer() + { + return $this->_get(self::CUSTOMER); + } + + /** + * Get checkout method + * + * @return string|null + */ + public function getCheckoutMethod() + { + return $this->_get(self::CHECKOUT_METHOD); + } + + /** + * @return \Magento\Checkout\Service\V1\Data\Cart\Address|null + */ + public function getShippingAddress() + { + return $this->_get(self::SHIPPING_ADDRESS); + } + + /** + * @return \Magento\Checkout\Service\V1\Data\Cart\Address|null + */ + public function getBillingAddress() + { + return $this->_get(self::BILLING_ADDRESS); + } + + /** + * @return \Magento\Checkout\Service\V1\Data\Cart\Totals|null + */ + public function getTotals() + { + return $this->_get(self::TOTALS); + } + + /** + * Get reserved order id + * + * @return string|null + */ + public function getReservedOrderId() + { + return $this->_get(self::RESERVED_ORDER_ID); + } + + /** + * Get original order id + * + * @return string|null + */ + public function getOrigOrderId() + { + return $this->_get(self::ORIG_ORDER_ID); + } + + /** + * Get currency information + * + * @return \Magento\Checkout\Service\V1\Data\Cart\Currency|null + */ + public function getCurrency() + { + return $this->_get(self::CURRENCY); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php new file mode 100644 index 00000000000..0bb4ff7e5e4 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address.php @@ -0,0 +1,241 @@ +<?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\Checkout\Service\V1\Data\Cart; + +/** + * Quote billing/shipping address data + * + * @codeCoverageIgnore + */ +class Address extends \Magento\Framework\Service\Data\Eav\AbstractObject +{ + /**#@+ + * Constants defined for keys of array, makes typos less likely + */ + const KEY_EMAIL = 'email'; + + const KEY_COUNTRY_ID = 'country_id'; + + const KEY_ID = 'id'; + + const KEY_CUSTOMER_ID = 'customer_id'; + + const KEY_REGION = 'region'; + + const KEY_STREET = 'street'; + + const KEY_COMPANY = 'company'; + + const KEY_TELEPHONE = 'telephone'; + + const KEY_FAX = 'fax'; + + const KEY_POSTCODE = 'postcode'; + + const KEY_CITY = 'city'; + + const KEY_FIRSTNAME = 'firstname'; + + const KEY_LASTNAME = 'lastname'; + + const KEY_MIDDLENAME = 'middlename'; + + const KEY_PREFIX = 'prefix'; + + const KEY_SUFFIX = 'suffix'; + + const KEY_VAT_ID = 'vat_id'; + + /**#@-*/ + + /** + * Get id + * + * @return int|null + */ + public function getId() + { + return $this->_get(self::KEY_ID); + } + + /** + * Get region + * + * @return \Magento\Checkout\Service\V1\Data\Cart\Address\Region|null + */ + public function getRegion() + { + return $this->_get(self::KEY_REGION); + } + + /** + * Get country id + * + * @return string + */ + public function getCountryId() + { + return $this->_get(self::KEY_COUNTRY_ID); + } + + /** + * Get street + * + * @return string[] + */ + public function getStreet() + { + return $this->_get(self::KEY_STREET); + } + + /** + * Get company + * + * @return string|null + */ + public function getCompany() + { + return $this->_get(self::KEY_COMPANY); + } + + /** + * Get telephone number + * + * @return string + */ + public function getTelephone() + { + return $this->_get(self::KEY_TELEPHONE); + } + + /** + * Get fax number + * + * @return string|null + */ + public function getFax() + { + return $this->_get(self::KEY_FAX); + } + + /** + * Get postcode + * + * @return string + */ + public function getPostcode() + { + return $this->_get(self::KEY_POSTCODE); + } + + /** + * Get city name + * + * @return string + */ + public function getCity() + { + return $this->_get(self::KEY_CITY); + } + + /** + * Get first name + * + * @return string + */ + public function getFirstname() + { + return $this->_get(self::KEY_FIRSTNAME); + } + + /** + * Get last name + * + * @return string + */ + public function getLastname() + { + return $this->_get(self::KEY_LASTNAME); + } + + /** + * Get middle name + * + * @return string|null + */ + public function getMiddlename() + { + return $this->_get(self::KEY_MIDDLENAME); + } + + /** + * Get prefix + * + * @return string|null + */ + public function getPrefix() + { + return $this->_get(self::KEY_PREFIX); + } + + /** + * Get suffix + * + * @return string|null + */ + public function getSuffix() + { + return $this->_get(self::KEY_SUFFIX); + } + + /** + * Get Vat id + * + * @return string|null + */ + public function getVatId() + { + return $this->_get(self::KEY_VAT_ID); + } + + /** + * Get customer id + * + * @return string|null + */ + public function getCustomerId() + { + return $this->_get(self::KEY_CUSTOMER_ID); + } + + /** + * Get billing/shipping email + * + * @return string + */ + public function getEmail() + { + return $this->_get(self::KEY_EMAIL); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.php new file mode 100644 index 00000000000..553e9ef3ba5 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/Region.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\Checkout\Service\V1\Data\Cart\Address; + +/** + * Data Object for Address Region + */ +class Region extends \Magento\Framework\Service\Data\AbstractObject +{ + /**#@+ + * Array keys + */ + const KEY_REGION_CODE = 'region_code'; + + const KEY_REGION = 'region'; + + const KEY_REGION_ID = 'region_id'; + + /**#@-*/ + + /** + * Get region code + * + * @return string + */ + public function getRegionCode() + { + return $this->_get(self::KEY_REGION_CODE); + } + + /** + * Get region + * + * @return string + */ + public function getRegion() + { + return $this->_get(self::KEY_REGION); + } + + /** + * Get region id + * + * @return int + */ + public function getRegionId() + { + return $this->_get(self::KEY_REGION_ID); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php new file mode 100644 index 00000000000..b82b502487f --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Address/RegionBuilder.php @@ -0,0 +1,68 @@ +<?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\Checkout\Service\V1\Data\Cart\Address; + +/** + * Builder for the Region Service Data Object + * + * @method Region create() + */ +class RegionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * Set region code + * + * @param string $regionCode + * @return $this + */ + public function setRegionCode($regionCode) + { + $this->_data[Region::KEY_REGION_CODE] = $regionCode; + return $this; + } + + /** + * Set region + * + * @param string $regionName + * @return $this + */ + public function setRegion($regionName) + { + $this->_data[Region::KEY_REGION] = $regionName; + return $this; + } + + /** + * Set region id + * + * @param string $regionId + * @return $this + */ + public function setRegionId($regionId) + { + $this->_data[Region::KEY_REGION_ID] = $regionId; + return $this; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php new file mode 100644 index 00000000000..f16445015be --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php @@ -0,0 +1,296 @@ +<?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\Checkout\Service\V1\Data\Cart; + +use Magento\Framework\Service\Data\Eav\AbstractObjectBuilder; +use Magento\Framework\Service\Data\Eav\AttributeValueBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\Address\Region; + +/** + * Quote address data object builder + * + * @codeCoverageIgnore + */ +class AddressBuilder extends AbstractObjectBuilder +{ + /** + * Region builder + * + * @var \Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder + */ + protected $_regionBuilder; + + /** + * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface + */ + protected $metadataService; + + /** + * @param \Magento\Framework\Service\Data\ObjectFactory $objectFactory + * @param AttributeValueBuilder $valueBuilder + * @param RegionBuilder $regionBuilder + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService + */ + public function __construct( + \Magento\Framework\Service\Data\ObjectFactory $objectFactory, + AttributeValueBuilder $valueBuilder, + RegionBuilder $regionBuilder, + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService + ) { + parent::__construct($objectFactory, $valueBuilder); + $this->metadataService = $metadataService; + $this->_regionBuilder = $regionBuilder; + $this->_data[Address::KEY_REGION] = $regionBuilder->create(); + } + + /** + * Convenience method to return region builder + * + * @return RegionBuilder + */ + public function getRegionBuilder() + { + return $this->_regionBuilder; + } + + /** + * Set id + * + * @param int $id + * @return $this + */ + public function setId($id) + { + return $this->_set(Address::KEY_ID, $id); + } + + /** + * {@inheritdoc} + */ + protected function _setDataValues(array $data) + { + if (array_key_exists(Address::KEY_REGION, $data)) { + if (!is_array($data[Address::KEY_REGION])) { + // Region data has been submitted as individual keys of Address object. Let's extract it. + $regionData = array(); + foreach (array(Region::KEY_REGION, Region::KEY_REGION_CODE, Region::KEY_REGION_ID) as $attrCode) { + if (isset($data[$attrCode])) { + $regionData[$attrCode] = $data[$attrCode]; + } + } + } else { + $regionData = $data[Address::KEY_REGION]; + } + $data[Address::KEY_REGION] = $this->_regionBuilder->populateWithArray($regionData)->create(); + } + return parent::_setDataValues($data); + } + + /** + * {@inheritdoc} + */ + public function getCustomAttributesCodes() + { + $attributeCodes = array(); + foreach ($this->metadataService->getCustomAddressAttributeMetadata() as $attribute) { + $attributeCodes[] = $attribute->getAttributeCode(); + } + return $attributeCodes; + } + + /** + * Set region + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Address\Region $region + * @return $this + */ + public function setRegion(\Magento\Checkout\Service\V1\Data\Cart\Address\Region $region) + { + return $this->_set(Address::KEY_REGION, $region); + } + + /** + * Set country id + * + * @param int $countryId + * @return $this + */ + public function setCountryId($countryId) + { + return $this->_set(Address::KEY_COUNTRY_ID, $countryId); + } + + /** + * Set street + * + * @param string[] $street + * @return $this + */ + public function setStreet($street) + { + return $this->_set(Address::KEY_STREET, $street); + } + + /** + * Set company + * + * @param string $company + * @return $this + */ + public function setCompany($company) + { + return $this->_set(Address::KEY_COMPANY, $company); + } + + /** + * Set telephone number + * + * @param string $telephone + * @return $this + */ + public function setTelephone($telephone) + { + return $this->_set(Address::KEY_TELEPHONE, $telephone); + } + + /** + * Set fax number + * + * @param string $fax + * @return $this + */ + public function setFax($fax) + { + return $this->_set(Address::KEY_FAX, $fax); + } + + /** + * Set postcode + * + * @param string $postcode + * @return $this + */ + public function setPostcode($postcode) + { + return $this->_set(Address::KEY_POSTCODE, $postcode); + } + + /** + * Set city name + * + * @param string $city + * @return $this + */ + public function setCity($city) + { + return $this->_set(Address::KEY_CITY, $city); + } + + /** + * Set first name + * + * @param string $firstname + * @return $this + */ + public function setFirstname($firstname) + { + return $this->_set(Address::KEY_FIRSTNAME, $firstname); + } + + /** + * Set last name + * + * @param string $lastname + * @return $this + */ + public function setLastname($lastname) + { + return $this->_set(Address::KEY_LASTNAME, $lastname); + } + + /** + * Set middle name + * + * @param string $middlename + * @return $this + */ + public function setMiddlename($middlename) + { + return $this->_set(Address::KEY_MIDDLENAME, $middlename); + } + + /** + * Set prefix + * + * @param string $prefix + * @return $this + */ + public function setPrefix($prefix) + { + return $this->_set(Address::KEY_PREFIX, $prefix); + } + + /** + * Set suffix + * + * @param string $suffix + * @return $this + */ + public function setSuffix($suffix) + { + return $this->_set(Address::KEY_SUFFIX, $suffix); + } + + /** + * Set Vat id + * + * @param string $vatId + * @return $this + */ + public function setVatId($vatId) + { + return $this->_set(Address::KEY_VAT_ID, $vatId); + } + + /** + * Set customer id + * + * @param string $customerId + * @return $this + */ + public function setCustomerId($customerId) + { + return $this->_set(Address::KEY_CUSTOMER_ID, $customerId); + } + + /** + * @param $value string + * @return $this + */ + public function setEmail($value) + { + return $this->_set(Address::KEY_EMAIL, $value); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php new file mode 100644 index 00000000000..7dd0a3a81b6 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Currency.php @@ -0,0 +1,128 @@ +<?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\Checkout\Service\V1\Data\Cart; + +/** + * Currency data for quote + * + * @codeCoverageIgnore + */ +class Currency extends \Magento\Framework\Service\Data\AbstractObject +{ + const GLOBAL_CURRENCY_CODE = 'global_currency_code'; + + const BASE_CURRENCY_CODE = 'base_currency_code'; + + const STORE_CURRENCY_CODE = 'store_currency_code'; + + const QUOTE_CURRENCY_CODE = 'quote_currency_code'; + + const STORE_TO_BASE_RATE = 'store_to_base_rate'; + + const STORE_TO_QUOTE_RATE = 'store_to_quote_rate'; + + const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'; + + const BASE_TO_QUOTE_RATE = 'base_to_quote_rate'; + + /** + * Get global currency code + * + * @return string|null + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Get base currency code + * + * @return string|null + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Get store currency code + * + * @return string|null + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Get quote currency code + * + * @return string|null + */ + public function getQuoteCurrencyCode() + { + return $this->_get(self::QUOTE_CURRENCY_CODE); + } + + /** + * Get store currency to base currency rate + * + * @return float|null + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Get store currency to quote currency rate + * + * @return float|null + */ + public function getStoreToQuoteRate() + { + return $this->_get(self::STORE_TO_QUOTE_RATE); + } + + /** + * Get base currency to global currency rate + * + * @return float|null + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Get base currency to quote currency rate + * + * @return float|null + */ + public function getBaseToQuoteRate() + { + return $this->_get(self::BASE_TO_QUOTE_RATE); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/CurrencyBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/CurrencyBuilder.php new file mode 100644 index 00000000000..bfb50e3c24e --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/CurrencyBuilder.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\Checkout\Service\V1\Data\Cart; + +/** + * Currency data builder for quote + * + * @codeCoverageIgnore + */ +class CurrencyBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * Set global currency code + * + * @param string|null $value + * @return $this + */ + public function setGlobalCurrencyCode($value) + { + return $this->_set(Currency::GLOBAL_CURRENCY_CODE, $value); + } + + /** + * Set base currency code + * + * @param string|null $value + * @return $this + */ + public function setBaseCurrencyCode($value) + { + return $this->_set(Currency::BASE_CURRENCY_CODE, $value); + } + + /** + * Set store currency code + * + * @param string|null $value + * @return $this + */ + public function setStoreCurrencyCode($value) + { + return $this->_set(Currency::STORE_CURRENCY_CODE, $value); + } + + /** + * Set quote currency code + * + * @param string|null $value + * @return $this + */ + public function setQuoteCurrencyCode($value) + { + return $this->_set(Currency::QUOTE_CURRENCY_CODE, $value); + } + + /** + * Set store currency to base currency rate + * + * @param float|null $value + * @return $this + */ + public function setStoreToBaseRate($value) + { + return $this->_set(Currency::STORE_TO_BASE_RATE, $value); + } + + /** + * Set store currency to quote currency rate + * + * @param float|null $value + * @return $this + */ + public function setStoreToQuoteRate($value) + { + return $this->_set(Currency::STORE_TO_QUOTE_RATE, $value); + } + + /** + * Set base currency to global currency rate + * + * @param float|null $value + * @return $this + */ + public function setBaseToGlobalRate($value) + { + return $this->_set(Currency::BASE_TO_GLOBAL_RATE, $value); + } + + /** + * Set base currency to quote currency rate + * + * @param float|null $value + * @return $this + */ + public function setBaseToQuoteRate($value) + { + return $this->_set(Currency::BASE_TO_QUOTE_RATE, $value); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php new file mode 100644 index 00000000000..66368c8d9ec --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Customer.php @@ -0,0 +1,213 @@ +<?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\Checkout\Service\V1\Data\Cart; + +/** + * Customer data for quote + * + * @codeCoverageIgnore + */ +class Customer extends \Magento\Framework\Service\Data\AbstractObject +{ + const ID = 'id'; + + const TAX_CLASS_ID = 'tax_class_id'; + + const GROUP_ID = 'group_id'; + + const EMAIL = 'email'; + + const PREFIX = 'prefix'; + + const FIRST_NAME = 'first_name'; + + const MIDDLE_NAME = 'middle_name'; + + const LAST_NAME = 'last_name'; + + const SUFFIX = 'suffix'; + + const DOB = 'dob'; + + const NOTE = 'note'; + + const NOTE_NOTIFY = 'note_notify'; + + const IS_GUEST = 'is_guest'; + + const TAXVAT = 'taxvat'; + + const GENDER = 'gender'; + + /** + * Get customer id + * + * @return int|null + */ + public function getId() + { + return $this->_get(self::ID); + } + + /** + * Get customer tax class id + * + * @return int|null + */ + public function getTaxClassId() + { + return $this->_get(self::TAX_CLASS_ID); + } + + /** + * Get customer group id + * + * @return int|null + */ + public function getGroupId() + { + return $this->_get(self::GROUP_ID); + } + + /** + * Get customer email + * + * @return string|null + */ + public function getEmail() + { + return $this->_get(self::EMAIL); + } + + /** + * Get customer name prefix + * + * @return string|null + */ + public function getPrefix() + { + return $this->_get(self::PREFIX); + } + + /** + * Get customer first name + * + * @return string|null + */ + public function getFirstName() + { + return $this->_get(self::FIRST_NAME); + } + + /** + * Get customer middle name + * + * @return string|null + */ + public function getMiddleName() + { + return $this->_get(self::MIDDLE_NAME); + } + + /** + * Get customer last name + * + * @return string|null + */ + public function getLastName() + { + return $this->_get(self::LAST_NAME); + } + + /** + * Get customer name suffix + * + * @return string|null + */ + public function getSuffix() + { + return $this->_get(self::SUFFIX); + } + + /** + * Get customer date of birth + * + * @return string|null + */ + public function getDob() + { + return $this->_get(self::DOB); + } + + /** + * Get note + * + * @return string|null + */ + public function getNote() + { + return $this->_get(self::NOTE); + } + + /** + * Get notification status + * + * @return string|null + */ + public function getNoteNotify() + { + return $this->_get(self::NOTE_NOTIFY); + } + + /** + * Is customer a guest? + * + * @return bool + */ + public function getIsGuest() + { + return (bool)$this->_get(self::IS_GUEST); + } + + + /** + * Get taxvat value + * + * @return string|null + */ + public function getTaxVat() + { + return $this->_get(self::TAXVAT); + } + + /** + * Get gender + * + * @return string|null + */ + public function getGender() + { + return $this->_get(self::GENDER); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.php new file mode 100644 index 00000000000..c98a28eccd0 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/CustomerBuilder.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\Checkout\Service\V1\Data\Cart; + +/** + * Customer data builder for quote + * + * @codeCoverageIgnore + */ +class CustomerBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * Set customer id + * + * @param int|null $value + * @return $this + */ + public function setId($value) + { + return $this->_set(Customer::ID, $value); + } + + /** + * Set customer tax class id + * + * @param int|null $value + * @return $this + */ + public function setTaxClassId($value) + { + return $this->_set(Customer::TAX_CLASS_ID, $value); + } + + /** + * Set customer group id + * + * @param int|null $value + * @return $this + */ + public function setGroupId($value) + { + return $this->_set(Customer::GROUP_ID, $value); + } + + /** + * Set customer email + * + * @param string|null $value + * @return $this + */ + public function setEmail($value) + { + return $this->_set(Customer::EMAIL, $value); + } + + /** + * Set customer name prefix + * + * @param string|null $value + * @return $this + */ + public function setPrefix($value) + { + return $this->_set(Customer::PREFIX, $value); + } + + /** + * Set customer first name + * + * @param string|null $value + * @return $this + */ + public function setFirstName($value) + { + return $this->_set(Customer::FIRST_NAME, $value); + } + + /** + * Set customer middle name + * + * @param string|null $value + * @return $this + */ + public function setMiddleName($value) + { + return $this->_set(Customer::MIDDLE_NAME, $value); + } + + /** + * Set customer last name + * + * @param string|null $value + * @return $this + */ + public function setLastName($value) + { + return $this->_set(Customer::LAST_NAME, $value); + } + + /** + * Set customer name suffix + * + * @param string|null $value + * @return $this + */ + public function setSuffix($value) + { + return $this->_set(Customer::SUFFIX, $value); + } + + /** + * Set customer date of birth + * + * @param string|null $value + * @return $this + */ + public function setDob($value) + { + return $this->_set(Customer::DOB, $value); + } + + /** + * Set note + * + * @param string|null $value + * @return $this + */ + public function setNote($value) + { + return $this->_set(Customer::NOTE, $value); + } + + /** + * Set notification status + * + * @param string|null $value + * @return $this + */ + public function setNoteNotify($value) + { + return $this->_set(Customer::NOTE_NOTIFY, $value); + } + + /** + * Is customer a guest? + * + * @param bool $value + * @return $this + */ + public function setIsGuest($value) + { + return (bool)$this->_set(Customer::IS_GUEST, $value); + } + + /** + * Get taxvat value + * + * @param string $value + * @return $this + */ + public function setTaxVat($value) + { + return $this->_set(Customer::TAXVAT, $value); + } + + /** + * Get gender + * + * @param string $value + * @return $this + */ + public function setGender($value) + { + return $this->_set(Customer::GENDER, $value); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php similarity index 53% rename from dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php rename to app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php index e30bbe22065..6519220126c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Item.php @@ -21,34 +21,64 @@ * @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\Resource\Product\Option; + +namespace Magento\Checkout\Service\V1\Data\Cart; /** - * Extend \Magento\Framework\DB\Adapter\Pdo\Mysql and stub needed methods + * @codeCoverageIgnore */ -class MysqlStub extends \Magento\Framework\DB\Adapter\Pdo\Mysql +class Item extends \Magento\Framework\Service\Data\AbstractObject { + /**#@+ + * Constants defined for keys of array + */ + const SKU = 'sku'; + + const QTY = 'qty'; + + const NAME = 'name'; + + const PRICE = 'price'; + + const TYPE = 'type'; + /** - * Disable parent constructor + * @return string|null */ - public function __construct() + public function getSku() { + return $this->_get(self::SKU); } /** - * Stub delete method and add needed asserts - * - * @param string $table - * @param array|string $where * @return int */ - public function delete($table, $where = '') + public function getQty() { - \PHPUnit_Framework_TestCase::assertEquals('catalog_product_option_type_title', $table); - \PHPUnit_Framework_TestCase::assertInternalType('array', $where); - \PHPUnit_Framework_TestCase::assertEquals(ValueTest::$valueTitleData['id'], $where['option_type_id = ?']); - \PHPUnit_Framework_TestCase::assertEquals(ValueTest::$valueTitleData['store_id'], $where['store_id = ?']); + return $this->_get(self::QTY); + } - return 0; + /** + * @return string|null + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * @return float|null + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * @return string|null + */ + public function getType() + { + return $this->_get(self::TYPE); } } diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ItemBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/ItemBuilder.php new file mode 100644 index 00000000000..721c7fe528f --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/ItemBuilder.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\Checkout\Service\V1\Data\Cart; + +/** + * @codeCoverageIgnore + */ +class ItemBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * @param string $value + * @return $this + */ + public function setSku($value) + { + $this->_set(Item::SKU, $value); + return $this; + } + + /** + * @param int $value + * @return $this + */ + public function setQty($value) + { + $this->_set(Item::QTY, $value); + return $this; + } + + /** + * @param string $value + * @return $this + */ + public function setName($value) + { + $this->_set(Item::NAME, $value); + return $this; + } + + /** + * @param float $value + * @return $this + */ + public function setPrice($value) + { + $this->_set(Item::PRICE, $value); + return $this; + } + + /** + * @param string $value + * @return $this + */ + public function setType($value) + { + $this->_set(Item::TYPE, $value); + return $this; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.php new file mode 100644 index 00000000000..4138653216a --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals.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\Checkout\Service\V1\Data\Cart; + +/** + * Cart Totals + * + * @codeCoverageIgnore + */ +class Totals extends \Magento\Framework\Service\Data\AbstractObject +{ + const GRAND_TOTAL = 'grand_total'; + + const BASE_GRAND_TOTAL = 'base_grand_total'; + + const SUBTOTAL = 'subtotal'; + + const BASE_SUBTOTAL = 'base_subtotal'; + + const SUBTOTAL_WITH_DISCOUNT = 'subtotal_with_discount'; + + const BASE_SUBTOTAL_WITH_DISCOUNT = 'base_subtotal_with_discount'; + + /** + * Get grand total in quote currency + * + * @return float|null + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + /** + * Get grand total in base currency + * + * @return float|null + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Get subtotal in quote currency + * + * @return float|null + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Get subtotal in base currency + * + * @return float|null + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Get subtotal in quote currency with applied discount + * + * @return float|null + */ + public function getSubtotalWithDiscount() + { + return $this->_get(self::SUBTOTAL_WITH_DISCOUNT); + } + + /** + * Get subtotal in base currency with applied discount + * + * @return float|null + */ + public function getBaseSubtotalWithDiscount() + { + return $this->_get(self::BASE_SUBTOTAL_WITH_DISCOUNT); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.php new file mode 100644 index 00000000000..bf185a0c095 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/TotalsBuilder.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\Checkout\Service\V1\Data\Cart; + +/** + * Cart Totals Builder + * + * @codeCoverageIgnore + */ +class TotalsBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * Set grand total in quote currency + * + * @param float|null $value + * @return $this + */ + public function setGrandTotal($value) + { + return $this->_set(Totals::GRAND_TOTAL, $value); + } + + /** + * Set grand total in base currency + * + * @param float|null $value + * @return $this + */ + public function setBaseGrandTotal($value) + { + return $this->_set(Totals::BASE_GRAND_TOTAL, $value); + } + + /** + * Set subtotal in quote currency + * + * @param float|null $value + * @return $this + */ + public function setSubtotal($value) + { + return $this->_set(Totals::SUBTOTAL, $value); + } + + /** + * Set subtotal in base currency + * + * @param float|null $value + * @return $this + */ + public function setBaseSubtotal($value) + { + return $this->_set(Totals::BASE_SUBTOTAL, $value); + } + + /** + * Set subtotal in quote currency with applied discount + * + * @param float|null $value + * @return $this + */ + public function setSubtotalWithDiscount($value) + { + return $this->_set(Totals::SUBTOTAL_WITH_DISCOUNT, $value); + } + + /** + * Set subtotal in base currency with applied discount + * + * @param float|null $value + * @return $this + */ + public function setBaseSubtotalWithDiscount($value) + { + return $this->_set(Totals::BASE_SUBTOTAL_WITH_DISCOUNT, $value); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php new file mode 100644 index 00000000000..547800779ae --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/CartBuilder.php @@ -0,0 +1,228 @@ +<?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\Checkout\Service\V1\Data; + +use \Magento\Checkout\Service\V1\Data\Cart\Currency; + +/** + * Cart data object builder + * + * @codeCoverageIgnore + */ +class CartBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * Cart/quote id + * + * @param int $value + * @return $this + */ + public function setId($value) + { + return $this->_set(Cart::ID, $value); + } + + /** + * Store id + * + * @param int $value + * @return $this + */ + public function setStoreId($value) + { + return $this->_set(Cart::STORE_ID, $value); + } + + /** + * set creation date and time + * + * @param string $value + * @return $this + */ + public function setCreatedAt($value) + { + return $this->_set(Cart::CREATED_AT, $value); + } + + /** + * Set last update date and time + * + * @param string $value + * @return $this + */ + public function setUpdatedAt($value) + { + return $this->_set(Cart::UPDATED_AT, $value); + } + + /** + * Set convertion date and time + * + * @param string $value + * @return $this + */ + public function setConvertedAt($value) + { + return $this->_set(Cart::CONVERTED_AT, $value); + } + + /** + * Set active status + * + * @param bool|null $value + * @return $this + */ + public function setIsActive($value) + { + return $this->_set(Cart::IS_ACTIVE, $value); + } + + /** + * Set virtual flag(if cart contains virtual products) + * + * @param bool|null $value + * @return $this + */ + public function setIsVirtual($value) + { + return $this->_set(Cart::IS_VIRTUAL, $value); + } + + /** + * Set cart items + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Item[] $value + * @return $this + */ + public function setItems($value) + { + return $this->_set(Cart::ITEMS, $value); + } + + /** + * Set items count(amount of different products) + * + * @param int $value + * @return $this + */ + public function setItemsCount($value) + { + return $this->_set(Cart::ITEMS_COUNT, $value); + } + + /** + * Set items quantity(total amount of all products) + * + * @param float $value + * @return $this + */ + public function setItemsQty($value) + { + return $this->_set(Cart::ITEMS_QUANTITY, $value); + } + + /** + * Set customer data object + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Customer $value + * @return $this + */ + public function setCustomer($value) + { + return $this->_set(Cart::CUSTOMER, $value); + } + + /** + * Set checkout method + * + * @param string $value + * @return $this + */ + public function setCheckoutMethod($value) + { + return $this->_set(Cart::CHECKOUT_METHOD, $value); + } + + /** + * Set shipping address data object + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $value + * @return $this + */ + public function setShippingAddress($value) + { + return $this->_set(Cart::SHIPPING_ADDRESS, $value); + } + + /** + * Set billing address data object + * + * @param \Magento\Checkout\Service\V1\Data\Cart\Address $value + * @return $this + */ + public function setBillingAddress($value) + { + return $this->_set(Cart::BILLING_ADDRESS, $value); + } + + /** + * @param \Magento\Checkout\Service\V1\Data\Cart\Totals $value + * @return $this + */ + public function setTotals($value) + { + return $this->_set(Cart::TOTALS, $value); + } + + /** + * Set reserved order id + * + * @param string $value + * @return $this + */ + public function setReservedOrderId($value) + { + return $this->_set(Cart::RESERVED_ORDER_ID, $value); + } + + /** + * Set original order id + * + * @param string $value + * @return $this + */ + public function setOrigOrderId($value) + { + return $this->_set(Cart::ORIG_ORDER_ID, $value); + } + + /** + * @param \Magento\Checkout\Service\V1\Data\Cart\Currency|null $value + * @return $this + */ + public function setCurrency($value) + { + return $this->_set(Cart::CURRENCY, $value); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php new file mode 100644 index 00000000000..fdde733b14c --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResults.php @@ -0,0 +1,37 @@ +<?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\Checkout\Service\V1\Data; + +class CartSearchResults extends \Magento\Framework\Service\V1\Data\SearchResults +{ + /** + * Get items + * + * @return \Magento\Checkout\Service\V1\Data\Cart[] + */ + public function getItems() + { + return parent::getItems(); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php new file mode 100644 index 00000000000..4941eaa7367 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.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\Checkout\Service\V1\Data; + +use Magento\Framework\Service\Data\ObjectFactory; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder; + +class CartSearchResultsBuilder extends AbstractSearchResultsBuilder +{ + /** + * @param ObjectFactory $objectFactory + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param CartBuilder $itemObjectBuilder + */ + public function __construct( + ObjectFactory $objectFactory, + SearchCriteriaBuilder $searchCriteriaBuilder, + CartBuilder $itemObjectBuilder + ) { + parent::__construct($objectFactory, $searchCriteriaBuilder, $itemObjectBuilder); + } + + /** + * Set cart list + * + * @param \Magento\Checkout\Service\V1\Data\Cart[] $items + * @return $this + */ + public function setItems($items) + { + return parent::setItems($items); + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadService.php b/app/code/Magento/Checkout/Service/V1/Item/ReadService.php new file mode 100644 index 00000000000..87c100879d7 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Item/ReadService.php @@ -0,0 +1,87 @@ +<?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\Checkout\Service\V1\Item; + +use Magento\Framework\Exception\NoSuchEntityException; +use \Magento\Checkout\Service\V1\Data\Cart\ItemBuilder as ItemBuilder; +use \Magento\Checkout\Service\V1\Data\Cart\Item as Item; + +class ReadService implements ReadServiceInterface +{ + /** + * @var \Magento\Checkout\Service\V1\QuoteLoader + */ + protected $quoteLoader; + + /** + * @var ItemBuilder + */ + protected $itemBuilder; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param ItemBuilder $itemBuilder + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, + ItemBuilder $itemBuilder, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->quoteLoader = $quoteLoader; + $this->itemBuilder = $itemBuilder; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function getList($cartId) + { + $output = []; + $storeId = $this->storeManager->getStore()->getId(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $storeId); + + /** @var \Magento\Sales\Model\Quote\Item $item */ + foreach ($quote->getAllItems() as $item) { + $data = [ + Item::SKU => $item->getSku(), + Item::NAME => $item->getName(), + Item::PRICE => $item->getPrice(), + Item::QTY => $item->getQty(), + Item::TYPE => $item->getProductType() + ]; + + $output[] = $this->itemBuilder->populateWithArray($data)->create(); + } + return $output; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.php new file mode 100644 index 00000000000..2ced087aeea --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Item/ReadServiceInterface.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) + */ +namespace Magento\Checkout\Service\V1\Item; + +interface ReadServiceInterface +{ + /** + * @param int $cartId + * @return \Magento\Checkout\Service\V1\Data\Cart\Item[] + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function getList($cartId); +} diff --git a/app/code/Magento/Checkout/Service/V1/Item/WriteService.php b/app/code/Magento/Checkout/Service/V1/Item/WriteService.php new file mode 100644 index 00000000000..fcc8a13b80c --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Item/WriteService.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\Checkout\Service\V1\Item; + +use Magento\Framework\Exception\NoSuchEntityException; +use \Magento\Checkout\Service\V1\Data\Cart\ItemBuilder as ItemBuilder; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; + +class WriteService implements WriteServiceInterface +{ + /** + * @var \Magento\Checkout\Service\V1\QuoteLoader + */ + protected $quoteLoader; + + /** + * @var ItemBuilder + */ + protected $itemBuilder; + + /** + * @var \Magento\Catalog\Service\V1\Product\ProductLoader + */ + protected $productLoader; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader + * @param ItemBuilder $itemBuilder + * @param \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, + ItemBuilder $itemBuilder, + \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader, + \Magento\Store\Model\StoreManagerInterface $storeManager + ) { + $this->quoteLoader = $quoteLoader; + $this->itemBuilder = $itemBuilder; + $this->productLoader = $productLoader; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function addItem($cartId, \Magento\Checkout\Service\V1\Data\Cart\Item $data) + { + $qty = $data->getQty(); + if (!is_numeric($qty) || $qty <= 0) { + throw InputException::invalidFieldValue('qty', $qty); + } + $storeId = $this->storeManager->getStore()->getId(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $storeId); + + $product = $this->productLoader->load($data->getSku()); + + try { + $quote->addProduct($product, $qty); + $quote->collectTotals()->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not add item to quote'); + } + return true; + } + + /** + * {@inheritdoc} + */ + public function updateItem($cartId, $itemSku, \Magento\Checkout\Service\V1\Data\Cart\Item $data) + { + $qty = $data->getQty(); + if (!is_numeric($qty) || $qty <= 0) { + throw InputException::invalidFieldValue('qty', $qty); + } + $storeId = $this->storeManager->getStore()->getId(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $storeId); + $product = $this->productLoader->load($itemSku); + $quoteItem = $quote->getItemByProduct($product); + if (!$quoteItem) { + throw new NoSuchEntityException("Cart $cartId doesn't contain product $itemSku"); + } + $quoteItem->setData('qty', $qty); + + try { + $quote->collectTotals()->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not update quote item'); + } + return true; + } + + /** + * {@inheritdoc} + */ + public function removeItem($cartId, $itemSku) + { + $storeId = $this->storeManager->getStore()->getId(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->quoteLoader->load($cartId, $storeId); + $product = $this->productLoader->load($itemSku); + $quoteItem = $quote->getItemByProduct($product); + if (!$quoteItem) { + throw new NoSuchEntityException("Cart $cartId doesn't contain product $itemSku"); + } + try { + $quote->removeItem($quoteItem->getId()); + $quote->collectTotals()->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not remove item from quote'); + } + return true; + } +} diff --git a/app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php b/app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.php new file mode 100644 index 00000000000..c733728512a --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/Item/WriteServiceInterface.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\Checkout\Service\V1\Item; + +interface WriteServiceInterface +{ + /** + * @param int $cartId + * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\InputException + */ + public function addItem($cartId, \Magento\Checkout\Service\V1\Data\Cart\Item $data); + + /** + * @param int $cartId + * @param string $itemSku + * @param \Magento\Checkout\Service\V1\Data\Cart\Item $data + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\InputException + */ + public function updateItem($cartId, $itemSku, \Magento\Checkout\Service\V1\Data\Cart\Item $data); + + /** + * @param int $cartId + * @param string $itemSku + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function removeItem($cartId, $itemSku); +} diff --git a/app/code/Magento/Checkout/Service/V1/QuoteLoader.php b/app/code/Magento/Checkout/Service/V1/QuoteLoader.php new file mode 100644 index 00000000000..7a83786c105 --- /dev/null +++ b/app/code/Magento/Checkout/Service/V1/QuoteLoader.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\Checkout\Service\V1; + +use \Magento\Framework\Exception\NoSuchEntityException; + +class QuoteLoader +{ + /** + * @var \Magento\Sales\Model\QuoteFactory + */ + protected $quoteFactory; + + /** + * @param \Magento\Sales\Model\QuoteFactory $quoteFactory + */ + public function __construct(\Magento\Sales\Model\QuoteFactory $quoteFactory) + { + $this->quoteFactory = $quoteFactory; + } + + /** + * @param int $cartId + * @param int $storeId + * @return \Magento\Sales\Model\Quote + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function load($cartId, $storeId) + { + $quote = $this->quoteFactory->create(); + $quote->setStoreId($storeId)->load($cartId); + if (!$quote->getId()) { + throw NoSuchEntityException::singleField('cartId', $cartId); + } + return $quote; + } +} diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 024648037a0..8517a00dd58 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -2,27 +2,27 @@ "name": "magento/module-checkout", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index 8f8a86386aa..619a36b0ec9 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -41,4 +41,12 @@ <argument name="storage" xsi:type="object">Magento\Checkout\Model\Session\Storage</argument> </arguments> </type> + <preference for="Magento\Checkout\Service\V1\Item\ReadServiceInterface" type="Magento\Checkout\Service\V1\Item\ReadService" /> + <preference for="\Magento\Checkout\Service\V1\Item\WriteServiceInterface" type="Magento\Checkout\Service\V1\Item\WriteService" /> + <preference for="\Magento\Checkout\Service\V1\Address\Shipping\ReadServiceInterface" type="Magento\Checkout\Service\V1\Address\Shipping\ReadService" /> + <preference for="\Magento\Checkout\Service\V1\Address\Shipping\WriteServiceInterface" type="Magento\Checkout\Service\V1\Address\Shipping\WriteService" /> + <preference for="\Magento\Checkout\Service\V1\Address\Billing\ReadServiceInterface" type="Magento\Checkout\Service\V1\Address\Billing\ReadService" /> + <preference for="\Magento\Checkout\Service\V1\Address\Billing\WriteServiceInterface" type="Magento\Checkout\Service\V1\Address\Billing\WriteService" /> + <preference for="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" type="Magento\Checkout\Service\V1\Cart\ReadService" /> + <preference for="\Magento\Checkout\Service\V1\Cart\WriteServiceInterface" type="Magento\Checkout\Service\V1\Cart\WriteService" /> </config> diff --git a/app/code/Magento/Checkout/etc/webapi.xml b/app/code/Magento/Checkout/etc/webapi.xml new file mode 100644 index 00000000000..c641c11faab --- /dev/null +++ b/app/code/Magento/Checkout/etc/webapi.xml @@ -0,0 +1,100 @@ +<?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) + */ +--> +<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> + <route url="/V1/carts/" method="POST"> + <service class="Magento\Checkout\Service\V1\Cart\WriteServiceInterface" method="create"/> + <resources> + <resource ref="Magento_Sales::create" /> + </resources> + </route> + <route url="/V1/carts/:cartId" method="PUT"> + <service class="Magento\Checkout\Service\V1\Cart\WriteServiceInterface" method="assignCustomer"/> + <resources> + <resource ref="Magento_Sales::create" /> + </resources> + </route> + <route url="/V1/carts/:cartId/items" method="GET"> + <service class="Magento\Checkout\Service\V1\Item\ReadServiceInterface" method="getList"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts/:cartId/items" method="POST"> + <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="addItem"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts/:cartId/items/:itemSku" method="PUT"> + <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="updateItem"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts/:cartId/items/:itemSku" method="DELETE"> + <service class="Magento\Checkout\Service\V1\Item\WriteServiceInterface" method="removeItem"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts/:cartId" method="GET"> + <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCart"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts" method="PUT"> + <service class="Magento\Checkout\Service\V1\Cart\ReadServiceInterface" method="getCartList"/> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/carts/:cartId/shipping-address" method="GET"> + <service class="Magento\Checkout\Service\V1\Address\Shipping\ReadServiceInterface" method="getAddress"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/carts/:cartId/shipping-address" method="POST"> + <service class="Magento\Checkout\Service\V1\Address\Shipping\WriteServiceInterface" method="setAddress"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/carts/:cartId/billing-address" method="GET"> + <service class="Magento\Checkout\Service\V1\Address\Billing\ReadServiceInterface" method="getAddress"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/carts/:cartId/billing-address" method="POST"> + <service class="Magento\Checkout\Service\V1\Address\Billing\WriteServiceInterface" method="setAddress"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> +</routes> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml index ebd7e0e0920..8216a39c0f1 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml @@ -36,7 +36,7 @@ <span class="counter qty<?php echo ($_cartQty > 0) ? '' : ' empty'; ?>"><?php echo ($_cartQty == 1) ? __('1 item') : __('%1 items',$_cartQty) ?></span> </a> <?php if ($this->getIsNeedToDisplaySideBar()): ?> - <div class="block minicart<?php echo ($_cartQty > 0) ? '' : ' empty'; ?>" <?php if ($this->getIsNeedToDisplaySideBar()): ?> data-mage-init='{"dropdownDialog":{"appendTo":"[data-block=minicart]", "triggerTarget":".showcart", "timeout": "2000", "triggerClass":"active", "parentClass":"active"}}'<?php endif ?>> + <div class="block block-minicart<?php echo ($_cartQty > 0) ? '' : ' empty'; ?>" <?php if ($this->getIsNeedToDisplaySideBar()): ?> data-mage-init='{"dropdownDialog":{"appendTo":"[data-block=minicart]", "triggerTarget":".showcart", "timeout": "2000", "triggerClass":"active", "parentClass":"active"}}'<?php endif ?>> <div class="title"> <strong> <span class="text"><?php echo __('My Cart'); ?></span> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml index bdd25a6c7aa..5691c5ce71d 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml @@ -156,7 +156,7 @@ <?php if ($customerAttributes): ?> <?php $customerAttributes->setEntityModelClass('Magento\Customer\Model\Customer')->setFieldIdFormat('billing:%1$s');?> <?php $customerAttributes->setFieldNameFormat('billing[%1$s]')->setShowContainer(false);?> - <?php echo $customerAttributes->setExcludeFileAttributes(true)->toHtml()?> + <?php echo $customerAttributes->toHtml()?> <?php endif;?> <div class="field password required"> <label class="label" for="billing:customer_password"><span><?php echo __('Password') ?></span></label> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml index cfc0b4adde2..d798a79f5b2 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml @@ -26,7 +26,7 @@ <?php echo $this->getBlockHtml('formkey') ?> <fieldset class="fieldset"> <?php echo $this->getChildChildHtml('methods_additional') ?> - <div id="checkout-payment-method-load"><?php echo $this->getChildHtml('methods') ?></div> + <div id="checkout-payment-method-load" class="opc-payment"><?php echo $this->getChildHtml('methods') ?></div> </fieldset> <?php echo $this->getChildChildHtml('additional') ?> <div class="actions-toolbar" id="payment-buttons-container"> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml index 309a7f7125a..d303b4da48f 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml @@ -29,7 +29,7 @@ $_item = $this->getItem(); $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); ?> <tr> - <td class="col item"><strong class="product name"><?php echo $this->escapeHtml($this->getProductName()) ?></strong> + <td class="col item" data-th="<?php echo $this->escapeHtml(__('Product Name'));?>"><strong class="product name"><?php echo $this->escapeHtml($this->getProductName()) ?></strong> <?php if ($_options = $this->getOptionList()):?> <dl class="review-item-options"> <?php foreach ($_options as $_option) : ?> @@ -54,7 +54,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); <?php endif;?> </td> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col price excl tax"> + <td class="col price excl tax" data-th="<?php echo $this->escapeHtml(__('Price'));?>"> <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> <span class="cart tax total" data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $_item->getId(); ?>"}'> <?php else: ?> @@ -138,9 +138,9 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); <?php endif; ?> </td> <?php endif; ?> - <td class="col qty"><span class="qty"><?php echo $_item->getQty() ?></span></td> + <td class="col qty" data-th="<?php echo $this->escapeHtml(__('Qty'));?>"><span class="qty"><?php echo $_item->getQty() ?></span></td> <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col subtotal excl tax"> + <td class="col subtotal excl tax" data-th="<?php echo $this->escapeHtml(__('Subtotal'));?>"> <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> <span class="cart tax total" data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> <?php else: ?> 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 3cbfea4d169..5b5dfcf568b 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 @@ -44,6 +44,7 @@ define([ registerCustomerPasswordSelector: '#co-billing-form .field.password,#co-billing-form .field.confirm', suggestRegistration: false }, + pageMessages: '#maincontent .messages .message', sectionSelectorPrefix: 'opc-', billingSection: 'billing', ajaxLoaderPlaceButton: false, @@ -174,6 +175,9 @@ define([ loginRegister = $( checkout.loginRegisterSelector )[0], method = 'register', action = 'show'; + + //Remove page messages + $(this.options.pageMessages).remove(); if (json.isGuestCheckoutAllowed) { @@ -288,5 +292,4 @@ define([ } } }); - }); diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index e7721e20423..53612c3a15a 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-checkout-agreements", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml b/app/code/Magento/CheckoutAgreements/etc/acl.xml similarity index 93% rename from app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml rename to app/code/Magento/CheckoutAgreements/etc/acl.xml index b51f0fe9565..5bedc875cd0 100644 --- a/app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml +++ b/app/code/Magento/CheckoutAgreements/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 94f9e1f5d55..04e668fb805 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-cms", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-install": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-install": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php index e01cc7508ba..2ad56df0bea 100644 --- a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php +++ b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php @@ -202,14 +202,6 @@ $pageContent = <<<EOD <th>PERSISTENT_SHOPPING_CART</th> <td>A link to information about your cart and viewing history if you have asked the site.</td> </tr> - <tr> - <th>POLL</th> - <td>The ID of any polls you have recently voted in.</td> - </tr> - <tr> - <th>POLLN</th> - <td>Information on what polls you have voted on.</td> - </tr> <tr> <th>RECENTLYCOMPARED</th> <td>The items that you have recently compared. </td> diff --git a/app/code/Magento/Cms/etc/adminhtml/acl.xml b/app/code/Magento/Cms/etc/acl.xml similarity index 95% rename from app/code/Magento/Cms/etc/adminhtml/acl.xml rename to app/code/Magento/Cms/etc/acl.xml index 59a0ca89f89..c26880bbbbb 100644 --- a/app/code/Magento/Cms/etc/adminhtml/acl.xml +++ b/app/code/Magento/Cms/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 8eb91f0ab2b..091d2ae7c31 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -2,13 +2,13 @@ "name": "magento/module-cms-url-rewrite", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-url-redirect": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89" + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-url-redirect": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.php similarity index 93% rename from app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php rename to app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.php index 290a8019075..8aa67371907 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.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\CatalogImportExport\Model\Export\Product\Type; +namespace Magento\ConfigurableImportExport\Model\Export\Product\Type; class Configurable extends \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php similarity index 96% rename from app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php rename to app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php index 97db1a13b3c..280d3af873b 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php @@ -21,7 +21,9 @@ * @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\CatalogImportExport\Model\Export; +namespace Magento\ConfigurableImportExport\Model\Export; + +use \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface; class RowCustomizer implements RowCustomizerInterface { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php similarity index 99% rename from app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php rename to app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php index 8baafce4c66..ba6b3f4ddec 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php @@ -1,7 +1,7 @@ <?php /** * Import entity configurable product type model - * + * * Magento * * NOTICE OF LICENSE @@ -23,7 +23,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\CatalogImportExport\Model\Import\Product\Type; +namespace Magento\ConfigurableImportExport\Model\Import\Product\Type; class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType { diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json new file mode 100644 index 00000000000..f00320c5f0e --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-configurable-import-export", + "description": "N/A", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-import-export": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-import-export": "0.1.0-alpha90", + "magento/module-configurable-product": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" + }, + "type": "magento2-module", + "version": "0.1.0-alpha90", + "extra": { + "map": [ + [ + "*", + "Magento/ConfigurableImportExport" + ] + ] + } +} diff --git a/app/code/Magento/ConfigurableImportExport/etc/di.xml b/app/code/Magento/ConfigurableImportExport/etc/di.xml new file mode 100644 index 00000000000..e708ec578be --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/etc/di.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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite"> + <arguments> + <argument name="customizers" xsi:type="array"> + <item name="configurableProduct" xsi:type="string">Magento\ConfigurableImportExport\Model\Export\RowCustomizer</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/ConfigurableImportExport/etc/export.xml b/app/code/Magento/ConfigurableImportExport/etc/export.xml new file mode 100644 index 00000000000..ff4060a99d8 --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/etc/export.xml @@ -0,0 +1,28 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ImportExport/etc/export.xsd"> + <entityType entity="catalog_product" name="configurable" model="Magento\ConfigurableImportExport\Model\Export\Product\Type\Configurable" /> +</config> diff --git a/app/code/Magento/ConfigurableImportExport/etc/import.xml b/app/code/Magento/ConfigurableImportExport/etc/import.xml new file mode 100644 index 00000000000..0ae338bc6fe --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/etc/import.xml @@ -0,0 +1,28 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ImportExport/etc/import.xsd"> + <entityType entity="catalog_product" name="configurable" model="Magento\ConfigurableImportExport\Model\Import\Product\Type\Configurable" /> +</config> diff --git a/app/code/Magento/Authz/etc/module.xml b/app/code/Magento/ConfigurableImportExport/etc/module.xml similarity index 76% rename from app/code/Magento/Authz/etc/module.xml rename to app/code/Magento/ConfigurableImportExport/etc/module.xml index 6d155cc6374..1d64d1dcc52 100644 --- a/app/code/Magento/Authz/etc/module.xml +++ b/app/code/Magento/ConfigurableImportExport/etc/module.xml @@ -24,14 +24,13 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Authz" schema_version="1.0.0.0" active="true"> - <sequence> - <module name="Magento_User"/> - </sequence> + <module name="Magento_ConfigurableImportExport" schema_version="1.0.0.0" active="true"> <depends> - <!--TODO: Dependency on Magento_User is temporary and should be eliminated when ACL is made global--> - <module name="Magento_User"/> - <module name="Magento_Backend"/> + <module name="Magento_Catalog"/> + <module name="Magento_Eav"/> + <module name="Magento_ImportExport"/> + <module name="Magento_CatalogImportExport"/> + <module name="Magento_ConfigurableProduct"/> </depends> </module> </config> diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 040930fe748..9326f2db453 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -409,7 +409,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection */ - public function getConfigurableAttributeCollection($product) + public function getConfigurableAttributeCollection(\Magento\Catalog\Model\Product $product) { return $this->_attributeCollectionFactory->create()->setProductFilter($product); } @@ -537,8 +537,9 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType /** * Save configurable product depended data * - * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Model\Product $product * @return $this + * @throws \InvalidArgumentException */ public function save($product) { @@ -553,21 +554,26 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType if (!$product->getIsDuplicate()) { if (!empty($attributeData['id'])) { $configurableAttribute->load($attributeData['id']); - } else { - $configurableAttribute->loadByProductAndAttribute( - $product, - $this->getAttributeById($attributeData['attribute_id'], $product) + $attributeData['attribute_id'] = $configurableAttribute->getAttributeId(); + } elseif (!empty($attributeData['attribute_id'])) { + $attribute = $this->_eavConfig->getAttribute( + \Magento\Catalog\Model\Product::ENTITY, $attributeData['attribute_id'] ); + $attributeData['attribute_id'] = $attribute->getId(); + if (!$this->canUseAttribute($attribute)) { + throw new \InvalidArgumentException( + 'Provided attribute can not be used with configurable product' + ); + } + $configurableAttribute->loadByProductAndAttribute($product, $attribute); } } unset($attributeData['id']); - $configurableAttribute->addData( - $attributeData - )->setStoreId( - $product->getStoreId() - )->setProductId( - $product->getId() - )->save(); + $configurableAttribute + ->addData($attributeData) + ->setStoreId($product->getStoreId()) + ->setProductId($product->getId()) + ->save(); } /** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection */ $configurableAttributesCollection = $this->_attributeCollectionFactory->create(); diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php index dc79a87d084..f00b3751617 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php @@ -25,6 +25,8 @@ */ namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use Magento\Framework\Model\Context; + /** * @method Attribute _getResource() * @method Attribute getResource() diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php index a84a84b5745..b832a6c8c4e 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php @@ -25,6 +25,8 @@ */ namespace Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute as ConfigurableAttribute; + class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** @@ -349,4 +351,74 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb ); $this->_getWriteAdapter()->query($this->_getReadAdapter()->deleteFromSelect($select, $this->getMainTable())); } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object) + { + parent::_afterLoad($object); + $this->loadLabel($object); + $this->loadPrices($object); + return $this; + } + + /** + * Load label for configurable attribute + * + * @param ConfigurableAttribute $object + * @return $this + */ + protected function loadLabel(ConfigurableAttribute $object) + { + $storeId = (int)$this->_storeManager->getStore()->getId(); + $connection = $this->_getReadAdapter(); + $useDefaultCheck = $connection + ->getCheckSql('store.use_default IS NULL', 'def.use_default', 'store.use_default'); + $labelCheck = $connection->getCheckSql('store.value IS NULL', 'def.value', 'store.value'); + $select = $connection + ->select() + ->from(array('def' => $this->_labelTable)) + ->joinLeft( + array('store' => $this->_labelTable), + $connection->quoteInto( + 'store.product_super_attribute_id = def.product_super_attribute_id AND store.store_id = ?', + $storeId + ), + array('use_default' => $useDefaultCheck, 'label' => $labelCheck) + ) + ->where('def.product_super_attribute_id = ?', $object->getId()) + ->where('def.store_id = ?', 0); + + $data = $connection->fetchRow($select); + $object->setLabel($data['label']); + $object->setUseDefault($data['use_default']); + return $this; + } + + /** + * Load prices for configurable attribute + * + * @param ConfigurableAttribute $object + * @return $this + */ + protected function loadPrices(ConfigurableAttribute $object) + { + $websiteId = $this->_catalogData->isPriceGlobal() ? 0 : (int)$this->_storeManager->getStore()->getWebsiteId(); + $select = $this->_getReadAdapter()->select() + ->from($this->_priceTable) + ->where('product_super_attribute_id = ?', $object->getId()) + ->where('website_id = ?', $websiteId); + + foreach ($select->query() as $row) { + $data = [ + 'value_index' => $row['value_index'], + 'is_percent' => $row['is_percent'], + 'pricing_value' => $row['pricing_value'], + ]; + $object->addPrice($data); + } + return $this; + } } diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php similarity index 76% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php index 99e92729f39..0a723a8b6f2 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php @@ -23,14 +23,25 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; -class ConfigurableAttribute extends \Magento\Framework\Service\Data\AbstractObject +class Option extends \Magento\Framework\Service\Data\AbstractObject { + /**#@+ + * Constants defined for keys of array + */ const ID = 'id'; + const LABEL = 'label'; + + const TYPE = 'type'; + const USE_DEFAULT = 'use_default'; + const POSITION = 'position'; + const VALUES = 'values'; + const ATTRIBUTE_ID = 'attribute_id'; + /**#@-*/ /** * @return int|null @@ -41,7 +52,7 @@ class ConfigurableAttribute extends \Magento\Framework\Service\Data\AbstractObje } /** - * @return string + * @return string|null */ public function getAttributeId() { @@ -56,6 +67,22 @@ class ConfigurableAttribute extends \Magento\Framework\Service\Data\AbstractObje return $this->_get(self::LABEL); } + /** + * @return string|null + */ + public function getType() + { + return $this->_get(self::TYPE); + } + + /** + * @return int|null + */ + public function getPosition() + { + return $this->_get(self::POSITION); + } + /** * @return bool|null */ @@ -65,7 +92,7 @@ class ConfigurableAttribute extends \Magento\Framework\Service\Data\AbstractObje } /** - * @return \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute\Value[] + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option\Value[]|null */ public function getValues() { diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php similarity index 82% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php index 6b88e10b4ac..0ecd1e14924 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php @@ -1,6 +1,4 @@ <?php -namespace Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute; - /** * Magento * @@ -23,11 +21,14 @@ namespace Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute; * @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; + class Value extends \Magento\Framework\Service\Data\AbstractObject { - const INDEX = 'value_index'; - const PRICE = 'pricing_value'; - const PRICE_IS_PERCENT = 'is_percent'; + const INDEX = 'index'; + const PRICE = 'price'; + const IS_PERCENT = 'percent'; /** * @return float|null @@ -40,9 +41,9 @@ class Value extends \Magento\Framework\Service\Data\AbstractObject /** * @return int|null */ - public function getPriceIsPercent() + public function isPercent() { - return $this->_get(self::PRICE_IS_PERCENT); + return $this->_get(self::IS_PERCENT); } /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php similarity index 88% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php index 511e1c33b15..f113fde85bf 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.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\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute; +namespace Magento\ConfigurableProduct\Service\V1\Data\Option; use Magento\Framework\Service\Data\AbstractObjectBuilder; @@ -40,9 +40,9 @@ class ValueBuilder extends AbstractObjectBuilder * @param int $value * @return self */ - public function setPriceIsPercent($value) + public function setPercent($value) { - return $this->_set(Value::PRICE_IS_PERCENT, $value); + return $this->_set(Value::IS_PERCENT, $value); } /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php new file mode 100644 index 00000000000..202c6f19b1f --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php @@ -0,0 +1,40 @@ +<?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\Service\V1\Data\Option; + +class ValueConverter +{ + /** + * @param Value $value + * @return array + */ + public function convertArrayFromData(Value $value) + { + return [ + 'value_index' => $value->getIndex(), + 'is_percent' => $value->isPercent(), + 'pricing_value' => $value->getPrice(), + ]; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php similarity index 58% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php index a50a266156f..e720f3e8213 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php @@ -23,50 +23,68 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; -class ConfigurableAttributeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +class OptionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** - * @param int $value - * @return self + * @param int $value + * @return $this */ public function setId($value) { - return $this->_set(ConfigurableAttribute::ID, $value); + return $this->_set(Option::ID, $value); } /** * @param string $value - * @return self + * @return $this */ public function setAttributeId($value) { - return $this->_set(ConfigurableAttribute::ATTRIBUTE_ID, $value); + return $this->_set(Option::ATTRIBUTE_ID, $value); } /** - * @param string $value - * @return self + * @param string $value + * @return $this */ public function setLabel($value) { - return $this->_set(ConfigurableAttribute::LABEL, $value); + return $this->_set(Option::LABEL, $value); + } + + /** + * @param int $value + * @return $this + */ + public function setPosition($value) + { + return $this->_set(Option::POSITION, $value); } /** * @param bool $value * @return self */ - public function useDefault($value) + public function setType($value) { - return $this->_set(ConfigurableAttribute::USE_DEFAULT, $value); + return $this->_set(Option::TYPE, $value); } /** - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute\Value[] $value - * @return self + * @param bool $value + * @return $this + */ + public function setUseDefault($value) + { + return $this->_set(Option::USE_DEFAULT, $value); + } + + /** + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option\Value[] $value + * @return $this */ public function setValues($value) { - return $this->_set(ConfigurableAttribute::VALUES, $value); + return $this->_set(Option::VALUES, $value); } } diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php new file mode 100644 index 00000000000..d50d21f1f61 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php @@ -0,0 +1,152 @@ +<?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\Service\V1\Data; + +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory; +use Magento\ConfigurableProduct\Service\V1\Data\Option\ValueBuilder; +use Magento\ConfigurableProduct\Service\V1\Data\Option; +use Magento\ConfigurableProduct\Service\V1\Data\Option\ValueConverter; + +class OptionConverter +{ + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionBuilder + */ + protected $optionBuilder; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option\ValueBuilder + */ + protected $valueBuilder; + + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory + */ + private $attributeFactory; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option\ValueConverter + */ + private $valueConverter; + + /** + * @param OptionBuilder $optionBuilder + * @param ValueBuilder $valueBuilder + * @param AttributeFactory $attributeFactory + * @param ValueConverter $valueConverter + */ + public function __construct( + OptionBuilder $optionBuilder, + ValueBuilder $valueBuilder, + AttributeFactory $attributeFactory, + ValueConverter $valueConverter + ) { + $this->optionBuilder = $optionBuilder; + $this->valueBuilder = $valueBuilder; + $this->attributeFactory = $attributeFactory; + $this->valueConverter = $valueConverter; + } + + /** + * Convert configurable attribute to option data object + * + * @param Attribute $configurableAttribute + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option + */ + public function convertFromModel(Attribute $configurableAttribute) + { + $values = []; + $prices = $configurableAttribute->getPrices(); + if (is_array($prices)) { + foreach ($prices as $price) { + $values[] = $this->valueBuilder + ->setIndex($price['value_index']) + ->setPrice($price['pricing_value']) + ->setPercent($price['is_percent']) + ->create(); + } + } + + $data = [ + Option::ID => $configurableAttribute->getId(), + Option::ATTRIBUTE_ID => $configurableAttribute->getAttributeId(), + Option::LABEL => $configurableAttribute->getLabel(), + Option::TYPE => $configurableAttribute->getProductAttribute()->getFrontend()->getInputType(), + Option::POSITION => $configurableAttribute->getPosition(), + Option::USE_DEFAULT => $configurableAttribute->getData('use_default'), + Option::VALUES => $values + ]; + + return $this->optionBuilder->populateWithArray($data)->create(); + } + + /** + * @param Option $option + * @return array + */ + public function convertArrayFromData(Option $option) + { + $values = []; + if (is_array($option->getValues())) { + foreach ($option->getValues() as $value) { + $values[] = $this->valueConverter->convertArrayFromData($value); + } + } + return [ + 'attribute_id' => $option->getAttributeId(), + 'position' => $option->getPosition(), + 'use_default' => $option->isUseDefault(), + 'label' => $option->getLabel(), + 'values' => $values + ]; + } + + /** + * @param Option $option + * @param Attribute $configurableAttribute + * @return Attribute + */ + public function getModelFromData(Option $option, Attribute $configurableAttribute) + { + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $returnConfigurableAttribute */ + $returnConfigurableAttribute = $this->attributeFactory->create(); + $returnConfigurableAttribute->setData($configurableAttribute->getData()); + $returnConfigurableAttribute->addData($option->__toArray()); + $returnConfigurableAttribute->setId($configurableAttribute->getId()); + $returnConfigurableAttribute->setAttributeId($configurableAttribute->getAttributeId()); + $returnConfigurableAttribute->setValues($configurableAttribute->getPrices()); + + $values = $option->getValues(); + if (!is_null($values)) { + $prices = []; + foreach ($values as $value) { + $prices[] = $this->valueConverter->convertArrayFromData($value); + } + $returnConfigurableAttribute->setValues($prices); + } + + return $returnConfigurableAttribute; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php new file mode 100644 index 00000000000..57b4e17625f --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.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\ConfigurableProduct\Service\V1\Product\Option; + +use Magento\Catalog\Model\ProductRepository; +use Magento\Catalog\Model\System\Config\Source\Inputtype as InputType; +use Magento\Catalog\Service\V1\Data\Product; +use Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection; +use Magento\ConfigurableProduct\Service\V1\Data\Option; +use Magento\ConfigurableProduct\Service\V1\Data\OptionConverter; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Webapi\Exception; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; + +class ReadService implements ReadServiceInterface +{ + /** + * @var OptionConverter + */ + private $optionConverter; + /** + * @var ProductRepository + */ + private $productRepository; + /** + * @var ConfigurableType + */ + private $configurableType; + /** + * @var InputType + */ + private $inputType; + + /** + * @param ProductRepository $productRepository + * @param OptionConverter $optionConverter + * @param ConfigurableType $configurableType + * @param InputType $inputType + */ + public function __construct( + ProductRepository $productRepository, + OptionConverter $optionConverter, + ConfigurableType $configurableType, + InputType $inputType + ) { + $this->productRepository = $productRepository; + $this->optionConverter = $optionConverter; + $this->configurableType = $configurableType; + $this->inputType = $inputType; + } + + /** + * {@inheritdoc} + */ + public function get($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $collection = $this->getConfigurableAttributesCollection($product); + $collection->addFieldToFilter($collection->getResource()->getIdFieldName(), $optionId); + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $configurableAttribute */ + $configurableAttribute = $collection->getFirstItem(); + if (!$configurableAttribute->getId()) { + throw new NoSuchEntityException(sprintf('Requested option doesn\'t exist: %s', $optionId)); + } + return $this->optionConverter->convertFromModel($configurableAttribute); + } + + /** + * {@inheritdoc} + */ + public function getList($productSku) + { + $options = []; + $product = $this->getProduct($productSku); + foreach ($this->getConfigurableAttributesCollection($product) as $option) { + $options[] = $this->optionConverter->convertFromModel($option); + } + return $options; + } + + /** + * @inheritdoc + */ + public function getTypes() + { + return array_map( + function ($inputType) { + return $inputType['value']; + }, + $this->inputType->toOptionArray() + ); + } + + /** + * Retrieve product instance by sku + * + * @param string $productSku + * @return \Magento\Catalog\Model\Product + * @throws \Magento\Webapi\Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + if (ConfigurableType::TYPE_CODE !== $product->getTypeId()) { + throw new Exception( + sprintf('Only implemented for configurable product: %s', $productSku), + Exception::HTTP_FORBIDDEN + ); + } + return $product; + } + + /** + * Retrieve configurable attribute collection through product object + * + * @param \Magento\Catalog\Model\Product $product + * @return Collection + */ + private function getConfigurableAttributesCollection(\Magento\Catalog\Model\Product $product) + { + return $this->configurableType->getConfigurableAttributeCollection($product); + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php new file mode 100644 index 00000000000..1cfd5c2d8e8 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php @@ -0,0 +1,58 @@ +<?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\Service\V1\Product\Option; + +interface ReadServiceInterface +{ + + /** + * Get option for configurable product + * + * @param string $productSku + * @param int $optionId + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function get($productSku, $optionId); + + /** + * Get all options for configurable product + * + * @param string $productSku + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option[] + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function getList($productSku); + + /** + * Get all available option types for configurable product + * + * @return string[] + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function getTypes(); +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php new file mode 100644 index 00000000000..9a5dcbf2446 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.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\ConfigurableProduct\Service\V1\Product\Option; + +use Magento\Catalog\Model\ProductRepository; +use Magento\ConfigurableProduct\Service\V1\Data\Option; +use Magento\ConfigurableProduct\Service\V1\Data\OptionConverter; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory as ConfigurableAttributeFactory; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; +use Magento\Eav\Model\Config as EavConfig; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Webapi\Exception; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class WriteService implements WriteServiceInterface +{ + /** + * @var \Magento\Catalog\Model\ProductRepository + */ + protected $productRepository; + + /** + * @var ConfigurableAttributeFactory + */ + protected $configurableAttributeFactory; + + /** + * Eav config + * + * @var EavConfig + */ + protected $eavConfig; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionConverter + */ + protected $optionConverter; + + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable + */ + private $productType; + + /** + * @param ProductRepository $productRepository + * @param ConfigurableAttributeFactory $configurableAttributeFactory + * @param EavConfig $eavConfig + * @param OptionConverter $optionConverter + * @param StoreManagerInterface $storeManager + * @param ConfigurableType $productType + */ + public function __construct( + ProductRepository $productRepository, + ConfigurableAttributeFactory $configurableAttributeFactory, + EavConfig $eavConfig, + OptionConverter $optionConverter, + StoreManagerInterface $storeManager, + ConfigurableType $productType + ) { + $this->productRepository = $productRepository; + $this->configurableAttributeFactory = $configurableAttributeFactory; + $this->eavConfig = $eavConfig; + $this->optionConverter = $optionConverter; + $this->storeManager = $storeManager; + $this->productType = $productType; + } + + /** + * {@inheritdoc} + */ + public function add($productSku, Option $option) + { + $product = $this->productRepository->get($productSku); + $allowedTypes = [ProductType::TYPE_SIMPLE, ProductType::TYPE_VIRTUAL, ConfigurableType::TYPE_CODE]; + if (!in_array($product->getTypeId(), $allowedTypes)) { + throw new \InvalidArgumentException('Incompatible product type'); + } + + $eavAttribute = $this->eavConfig->getAttribute(Product::ENTITY, $option->getAttributeId()); + + /** @var $configurableAttribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); + if ($configurableAttribute->getId()) { + throw new CouldNotSaveException('Product already has this option'); + } + + try { + $product->setTypeId(ConfigurableType::TYPE_CODE); + $product->setConfigurableAttributesData([$this->optionConverter->convertArrayFromData($option)]); + $product->setStoreId($this->storeManager->getStore(Store::ADMIN_CODE)->getId()); + $product->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('An error occurred while saving option'); + } + + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); + if (!$configurableAttribute->getId()) { + throw new CouldNotSaveException('An error occurred while saving option'); + } + + return $configurableAttribute->getId(); + } + + /** + * {@inheritdoc} + */ + public function update($productSku, $optionId, Option $option) + { + $product = $this->getProduct($productSku); + + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->load($optionId); + if (!$configurableAttribute->getId() || $configurableAttribute->getProductId() != $product->getId()) { + throw new NoSuchEntityException('Option with id "%1" not found', [$optionId]); + } + $configurableAttribute = $this->optionConverter->getModelFromData($option, $configurableAttribute); + try { + $configurableAttribute->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not update option with id "%1"', [$optionId]); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function remove($productSku, $optionId) + { + $product = $this->getProduct($productSku); + + $attributeCollection = $this->productType->getConfigurableAttributeCollection($product); + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */ + $option = $attributeCollection->getItemById($optionId); + + if ($option === null) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $option->delete(); + + return true; + } + + /** + * @param string $productSku + * @return \Magento\Catalog\Model\Product + * @throws \Magento\Webapi\Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + if (ConfigurableType::TYPE_CODE !== $product->getTypeId()) { + throw new Exception( + 'Product with specified sku: "%1" is not a configurable product', + Exception::HTTP_FORBIDDEN, + Exception::HTTP_FORBIDDEN, + [ + $product->getSku() + ] + ); + } + return $product; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php new file mode 100644 index 00000000000..4b01d72194b --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.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\ConfigurableProduct\Service\V1\Product\Option; + +interface WriteServiceInterface +{ + /** + * Add option to the product + * + * @param string $productSku + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option $option + * @return int + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \InvalidArgumentException + */ + public function add($productSku, \Magento\ConfigurableProduct\Service\V1\Data\Option $option); + + /** + * @param string $productSku + * @param int $optionId + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option $option + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function update($productSku, $optionId, \Magento\ConfigurableProduct\Service\V1\Data\Option $option); + + /** + * Remove option from configurable product + * + * @param string $productSku + * @param int $optionId + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Webapi\Exception + */ + public function remove($productSku, $optionId); +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/ReadService.php b/app/code/Magento/ConfigurableProduct/Service/V1/ReadService.php index d79190379d3..6e00dd933b8 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/ReadService.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/ReadService.php @@ -63,9 +63,9 @@ class ReadService implements ReadServiceInterface /** * {@inheritdoc} */ - public function generateVariation(Product $product, $configurableAttributes) + public function generateVariation(Product $product, $options) { - $attributes = $this->getAttributesForMatrix($configurableAttributes); + $attributes = $this->getAttributesForMatrix($options); $variations = $this->variationMatrix->getVariations($attributes); $products = $this->populateProductVariation($product, $variations, $attributes); return $products; @@ -74,18 +74,18 @@ class ReadService implements ReadServiceInterface /** * Prepare attribute info for variation matrix generation * - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute[] $configurableAttributes + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option[] $options * @return array */ - private function getAttributesForMatrix($configurableAttributes) + private function getAttributesForMatrix($options) { $attributes = []; - foreach ($configurableAttributes as $configurableAttribute) { - $configurable = $configurableAttribute->__toArray(); - $attribute = $this->attributeReadService->info($configurableAttribute->getAttributeId()); + foreach ($options as $option) { + $configurable = $option->__toArray(); + $attribute = $this->attributeReadService->info($option->getAttributeId()); $configurable['options'] = $attribute->__toArray()['options']; $configurable['attribute_code'] = $attribute->getAttributeCode(); - $attributes[$configurableAttribute->getAttributeId()] = $configurable; + $attributes[$option->getAttributeId()] = $configurable; } return $attributes; } @@ -113,7 +113,7 @@ class ReadService implements ReadServiceInterface ); $priceInfo = $valueInfo['price']; $price += (!empty($priceInfo['is_percent']) ? $product->getPrice() / 100.0 : 1.0) - * $priceInfo['pricing_value']; + * $priceInfo['price']; } $this->productBuilder->setPrice($price); $this->productBuilder->setName($product->getName() . $suffix); diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php index 49ac8f1ff90..7b4bd51b405 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php @@ -29,11 +29,11 @@ interface ReadServiceInterface * Generate variation based on same product * * @param \Magento\Catalog\Service\V1\Data\Product $product - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute[] $configurableAttributes + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option[] $options * @return \Magento\Catalog\Service\V1\Data\Product[] */ public function generateVariation( \Magento\Catalog\Service\V1\Data\Product $product, - $configurableAttributes + $options ); } diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 27f4fed2b11..7c456e44c9b 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -2,26 +2,26 @@ "name": "magento/module-configurable-product", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", - "magento/module-webapi": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-webapi": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/etc/di.xml b/app/code/Magento/ConfigurableProduct/etc/di.xml index 472fdd85bdc..447c8e94c50 100644 --- a/app/code/Magento/ConfigurableProduct/etc/di.xml +++ b/app/code/Magento/ConfigurableProduct/etc/di.xml @@ -24,9 +24,12 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\ConfigurableProduct\Service\V1\Product\Option\WriteServiceInterface" type="Magento\ConfigurableProduct\Service\V1\Product\Option\WriteService" /> <preference for="Magento\ConfigurableProduct\Service\V1\Product\Link\ReadServiceInterface" type="Magento\ConfigurableProduct\Service\V1\Product\Link\ReadService" /> <preference for="Magento\ConfigurableProduct\Service\V1\Product\Link\WriteServiceInterface" type="Magento\ConfigurableProduct\Service\V1\Product\Link\WriteService" /> <preference for="Magento\ConfigurableProduct\Service\V1\ReadServiceInterface" type="Magento\ConfigurableProduct\Service\V1\ReadService" /> + <preference for="Magento\ConfigurableProduct\Service\V1\Product\Option\ReadServiceInterface" type="Magento\ConfigurableProduct\Service\V1\Product\Option\ReadService" /> + <preference for="Magento\ConfigurableProduct\Service\V1\Product\Option\Type\ReadServiceInterface" type="Magento\ConfigurableProduct\Service\V1\Product\Option\Type\ReadService" /> <type name="Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option"> <plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Quote\Item\QuantityValidator\Initializer\Option\Plugin\ConfigurableProduct" sortOrder="50" /> </type> diff --git a/app/code/Magento/ConfigurableProduct/etc/webapi.xml b/app/code/Magento/ConfigurableProduct/etc/webapi.xml index fd11c2f6b29..315bcd1423e 100644 --- a/app/code/Magento/ConfigurableProduct/etc/webapi.xml +++ b/app/code/Magento/ConfigurableProduct/etc/webapi.xml @@ -49,4 +49,40 @@ <resource ref="Magento_Catalog::products" /> </resources> </route> + <route url="/V1/configurable-products/:productSku/options/:optionId" method="GET"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\ReadServiceInterface" method="get"/> + <resources> + <resource ref="Magento_Catalog::products"/> + </resources> + </route> + <route url="/V1/configurable-products/:productSku/options/all" method="GET"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\ReadServiceInterface" method="getList"/> + <resources> + <resource ref="Magento_Catalog::products"/> + </resources> + </route> + <route url="/V1/configurable-products/options/types" method="GET"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\ReadServiceInterface" method="getTypes" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/configurable-products/:productSku/options" method="POST"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\WriteServiceInterface" method="add" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/configurable-products/:productSku/options/:optionId" method="PUT"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\WriteServiceInterface" method="update" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> + <route url="/V1/configurable-products/:productSku/options/:optionId" method="DELETE"> + <service class="Magento\ConfigurableProduct\Service\V1\Product\Option\WriteServiceInterface" method="remove" /> + <resources> + <resource ref="Magento_Catalog::products" /> + </resources> + </route> </routes> diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 067e82511f5..acae9e53d5a 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-contact", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Contact/etc/adminhtml/acl.xml b/app/code/Magento/Contact/etc/acl.xml similarity index 94% rename from app/code/Magento/Contact/etc/adminhtml/acl.xml rename to app/code/Magento/Contact/etc/acl.xml index d957ae0cd5a..4a8bd27964d 100644 --- a/app/code/Magento/Contact/etc/adminhtml/acl.xml +++ b/app/code/Magento/Contact/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 1cef33c5715..a79885d900b 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -2,19 +2,19 @@ "name": "magento/module-core", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php index 56d23dbff9d..0e03bc5a296 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php @@ -26,7 +26,7 @@ $installer = $this; $installer->startSetup(); -$tableName = $installer->getTable('admin_rule'); +$tableName = $installer->getTable('authorization_rule'); if ($tableName) { $installer->getConnection()->delete($tableName, array('resource_id = ?' => 'admin/system/tools/compiler')); } diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index a46386ee521..24bb9c00e22 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-cron", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index a47864769f5..616e2e5509a 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-currency-symbol", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml b/app/code/Magento/CurrencySymbol/etc/acl.xml similarity index 94% rename from app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml rename to app/code/Magento/CurrencySymbol/etc/acl.xml index 001ddce9668..5afa8f8b167 100644 --- a/app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml +++ b/app/code/Magento/CurrencySymbol/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php b/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php new file mode 100644 index 00000000000..4fa7209e979 --- /dev/null +++ b/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.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\Customer\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Customer\Model\Session as CustomerSession; + +/** + * Session-based customer user context + */ +class CustomerSessionUserContext implements UserContextInterface +{ + /** + * @var CustomerSession + */ + protected $_customerSession; + + /** + * Initialize dependencies. + * + * @param CustomerSession $customerSession + */ + public function __construct( + CustomerSession $customerSession + ) { + $this->_customerSession = $customerSession; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + return $this->_customerSession->getId(); + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + return UserContextInterface::USER_TYPE_CUSTOMER; + } +} diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php b/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php new file mode 100644 index 00000000000..d75d2f4d91e --- /dev/null +++ b/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.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\Customer\Model\Plugin; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Integration\Service\V1\AuthorizationServiceInterface as AuthorizationService; + +/** + * Plugin around \Magento\Framework\Authorization::isAllowed + * + * Plugin to allow customer users to access resources with self permission + */ +class CustomerAuthorization +{ + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * Inject dependencies. + * + * @param UserContextInterface $userContext + */ + public function __construct(UserContextInterface $userContext) + { + $this->userContext = $userContext; + } + + /** + * Check if resource for which access is needed has self permissions defined in webapi config. + * + * @param \Magento\Framework\Authorization $subject + * @param callable $proceed + * @param string $resource + * @param string $privilege + * + * @return bool true If resource permission is self, to allow + * customer access without further checks in parent method + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundIsAllowed( + \Magento\Framework\Authorization $subject, + \Closure $proceed, + $resource, + $privilege = null + ) { + if ($resource == AuthorizationService::PERMISSION_SELF + && $this->userContext->getUserId() + && $this->userContext->getUserType() === UserContextInterface::USER_TYPE_CUSTOMER + ) { + return true; + } else { + return $proceed($resource, $privilege); + } + } +} diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php index 756b65d6fef..c86f39abb47 100644 --- a/app/code/Magento/Customer/Model/Resource/Address.php +++ b/app/code/Magento/Customer/Model/Resource/Address.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Resource; +use \Magento\Framework\Exception\InputException; + class Address extends \Magento\Eav\Model\Entity\AbstractEntity { /** @@ -140,7 +142,12 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity $validator = $this->_validatorFactory->createValidator('customer_address', 'save'); if (!$validator->isValid($address)) { - throw new \Magento\Framework\Validator\ValidatorException($validator->getMessages()); + throw new \Magento\Framework\Validator\ValidatorException( + InputException::DEFAULT_MESSAGE, + [], + null, + $validator->getMessages() + ); } } diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index 663754c47e0..b4e646ba88c 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -23,6 +23,8 @@ */ namespace Magento\Customer\Model\Resource; +use \Magento\Framework\Exception\InputException; + /** * Customer entity resource model */ @@ -174,7 +176,12 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity $validator = $this->_validatorFactory->createValidator('customer', 'save'); if (!$validator->isValid($customer)) { - throw new \Magento\Framework\Validator\ValidatorException($validator->getMessages()); + throw new \Magento\Framework\Validator\ValidatorException( + InputException::DEFAULT_MESSAGE, + [], + null, + $validator->getMessages() + ); } } diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index b98cad217d0..5b847f192ad 100755 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -547,12 +547,11 @@ class Session extends \Magento\Framework\Session\SessionManager /** * Reset core session hosts after reseting session ID * - * @param bool $deleteOldSession * @return $this */ - public function regenerateId($deleteOldSession = true) + public function regenerateId() { - parent::regenerateId($deleteOldSession); + parent::regenerateId(); $this->_cleanHosts(); return $this; } diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php index be9307eff68..5a14411d22d 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -278,10 +278,10 @@ class CustomerAccountService implements CustomerAccountServiceInterface $this->eventManager->dispatch('customer_login', array('customer' => $customerModel)); - $customerDto = $this->converter->createCustomerFromModel($customerModel); - $this->eventManager->dispatch('customer_data_object_login', array('customer' => $customerDto)); + $customerData = $this->converter->createCustomerFromModel($customerModel); + $this->eventManager->dispatch('customer_data_object_login', array('customer' => $customerData)); - return $customerDto; + return $customerData; } /** diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 1551885f957..ae79cc3044e 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -226,7 +226,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface } $validationRules = []; foreach ($attribute->getValidateRules() as $name => $value) { - $validationRules[$name] = $this->_validationRuleBuilder->setName($name) + $validationRules[] = $this->_validationRuleBuilder->setName($name) ->setValue($value) ->create(); } @@ -243,6 +243,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface ->setOptions($options) ->setFrontendClass($attribute->getFrontend()->getClass()) ->setFrontendLabel($attribute->getFrontendLabel()) + ->setBackendType($attribute->getBackendType()) ->setNote($attribute->getNote()) ->setIsSystem($attribute->getIsSystem()) ->setIsUserDefined($attribute->getIsUserDefined()) diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php index c9ba34c2d77..4ba3c371fcb 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php @@ -51,7 +51,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject const DATA_MODEL = 'data_model'; - const IS_USER_DEFINED = 'is_user_defined'; + const USER_DEFINED = 'user_defined'; const FRONTEND_CLASS = 'frontend_class'; @@ -59,7 +59,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject const FRONTEND_LABEL = 'frontend_label'; - const IS_SYSTEM = 'is_system'; + const SYSTEM = 'system'; const NOTE = 'note'; @@ -184,7 +184,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject */ public function isUserDefined() { - return $this->_get(self::IS_USER_DEFINED); + return $this->_get(self::USER_DEFINED); } /** @@ -224,7 +224,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject */ public function isSystem() { - return $this->_get(self::IS_SYSTEM); + return $this->_get(self::SYSTEM); } /** diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php index e45d018fad6..ef50ab9a124 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php @@ -188,7 +188,7 @@ class AttributeMetadataBuilder extends \Magento\Framework\Service\Data\AbstractO */ public function setIsUserDefined($isUserDefined) { - return $this->_set(AttributeMetadata::IS_USER_DEFINED, $isUserDefined); + return $this->_set(AttributeMetadata::USER_DEFINED, $isUserDefined); } /** @@ -221,7 +221,7 @@ class AttributeMetadataBuilder extends \Magento\Framework\Service\Data\AbstractO */ public function setIsSystem($isSystem) { - return $this->_set(AttributeMetadata::IS_SYSTEM, $isSystem); + return $this->_set(AttributeMetadata::SYSTEM, $isSystem); } /** diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 020cabb48bc..883e23e784e 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -2,28 +2,30 @@ "name": "magento/module-customer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-newsletter": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-newsletter": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-authorization": "0.1.0-alpha90", + "magento/module-integration": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/adminhtml/acl.xml b/app/code/Magento/Customer/etc/acl.xml similarity index 95% rename from app/code/Magento/Customer/etc/adminhtml/acl.xml rename to app/code/Magento/Customer/etc/acl.xml index 392c11a8359..0544b9cd0e6 100644 --- a/app/code/Magento/Customer/etc/adminhtml/acl.xml +++ b/app/code/Magento/Customer/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 186380578ca..f84399e87a6 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -68,7 +68,7 @@ <type name="Magento\Customer\Service\V1\Data\Eav\AttributeMetadataBuilder" shared="false" /> <type name="Magento\Customer\Service\V1\Data\Eav\OptionBuilder" shared="false" /> <type name="Magento\Customer\Service\V1\Data\RegionBuilder" shared="false" /> - <type name="Magento\Customer\Service\V1\Data\Response\CreateCustomerAccountResponseBuilder" shared="false" /> + <!--<type name="Magento\Customer\Service\V1\Data\Response\CreateCustomerAccountResponseBuilder" shared="false" />--> <type name="Magento\Customer\Service\V1\Data\SearchResultsBuilder" shared="false" /> <type name="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite"> <arguments> diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 91d05a2966c..57366ea6e06 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -30,6 +30,7 @@ <module name="Magento_Directory"/> </sequence> <depends> + <module name="Magento_Authorization"/> <module name="Magento_Store"/> <module name="Magento_Eav"/> <module name="Magento_Directory"/> @@ -46,6 +47,7 @@ <module name="Magento_Review"/> <module name="Magento_Tax"/> <module name="Magento_PageCache"/> + <module name="Magento_Integration"/> </depends> </module> </config> diff --git a/app/code/Magento/Customer/etc/webapi.xml b/app/code/Magento/Customer/etc/webapi.xml index 2d2179ffa7a..842e90b8f04 100644 --- a/app/code/Magento/Customer/etc/webapi.xml +++ b/app/code/Magento/Customer/etc/webapi.xml @@ -161,7 +161,7 @@ <resource ref="self"/> </resources> <data> - <parameter name="customerId" force="true" source="session" method="getUserId">null</parameter> + <parameter name="customerId" force="true">%customer_id%</parameter> </data> </route> <route url="/V1/customerAccounts/:customerId/customer" method="GET"> diff --git a/app/code/Magento/Customer/etc/webapi_rest/di.xml b/app/code/Magento/Customer/etc/webapi_rest/di.xml new file mode 100644 index 00000000000..8eb5b6d92ba --- /dev/null +++ b/app/code/Magento/Customer/etc/webapi_rest/di.xml @@ -0,0 +1,45 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Framework\Authorization"> + <plugin name="customerAuthorization" type="Magento\Customer\Model\Plugin\CustomerAuthorization" /> + </type> + <type name="Magento\Customer\Model\Session"> + <arguments> + <argument name="sessionName" xsi:type="string">frontend</argument> + </arguments> + </type> + <type name="Magento\Authorization\Model\CompositeUserContext"> + <arguments> + <argument name="userContexts" xsi:type="array"> + <item name="customerSessionUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Customer\Model\Authorization\CustomerSessionUserContext</item> + <item name="sortOrder" xsi:type="string">20</item> + </item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Authz/etc/adminhtml/di.xml b/app/code/Magento/Customer/etc/webapi_soap/di.xml similarity index 86% rename from app/code/Magento/Authz/etc/adminhtml/di.xml rename to app/code/Magento/Customer/etc/webapi_soap/di.xml index d4a583c57f7..2b574a8f237 100644 --- a/app/code/Magento/Authz/etc/adminhtml/di.xml +++ b/app/code/Magento/Customer/etc/webapi_soap/di.xml @@ -24,5 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Authz\Model\UserLocatorInterface" type="Magento\Authz\Model\UserLocator\Admin"/> + <type name="Magento\Framework\Authorization"> + <plugin name="customerAuthorization" type="Magento\Customer\Model\Plugin\CustomerAuthorization" /> + </type> </config> diff --git a/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml b/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml index d4be822c8c8..81f3c80517d 100644 --- a/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml @@ -23,13 +23,13 @@ */ ?> <?php if($this->customerLoggedIn()): ?> - <li class="customer welcome"> + <li class="customer welcome customer-welcome"> <span class="customer name" data-toggle="dropdown"> <span><?php echo $this->getCustomerName(); ?></span> <button type="button" class="action switch"><span><?php echo __('Change')?></span></button> </span> <?php if($this->getChildHtml()):?> - <div class="customer menu" data-target="dropdown"> + <div class="customer menu customer-menu" data-target="dropdown"> <?php echo $this->getChildHtml();?> </div> <?php endif; ?> diff --git a/app/code/Magento/Customer/view/frontend/web/address.js b/app/code/Magento/Customer/view/frontend/web/address.js index 89338ed4a90..c584a11c567 100644 --- a/app/code/Magento/Customer/view/frontend/web/address.js +++ b/app/code/Magento/Customer/view/frontend/web/address.js @@ -22,8 +22,13 @@ */ /*jshint browser:true, jquery:true*/ /*global confirm:true*/ -define(["jquery","jquery/ui","mage/translate"], function(jQuery){ +define([ + "jquery", + "jquery/ui", + "mage/translate" +], function($){ "use strict"; + $.widget('mage.address', { /** * Options common to all instances of this widget. diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index df27250c37b..1ac83c3b036 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -2,19 +2,19 @@ "name": "magento/module-customer-import-export", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-import-export": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-import-export": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index d88235ca453..ac8de66b7a1 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-design-editor", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-url-rewrite": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-url-rewrite": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/DesignEditor/etc/adminhtml/acl.xml b/app/code/Magento/DesignEditor/etc/acl.xml similarity index 93% rename from app/code/Magento/DesignEditor/etc/adminhtml/acl.xml rename to app/code/Magento/DesignEditor/etc/acl.xml index 7b37bc1c5bc..8cd96036334 100644 --- a/app/code/Magento/DesignEditor/etc/adminhtml/acl.xml +++ b/app/code/Magento/DesignEditor/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index b915d938c8b..0832f2077df 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-dhl", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index 1ad64b018d6..d8fee1dd15c 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-directory", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/view/frontend/templates/currency.phtml b/app/code/Magento/Directory/view/frontend/templates/currency.phtml index 5e1cfa4988f..db6065030b1 100644 --- a/app/code/Magento/Directory/view/frontend/templates/currency.phtml +++ b/app/code/Magento/Directory/view/frontend/templates/currency.phtml @@ -32,18 +32,25 @@ <?php if ($this->getCurrencyCount() > 1): ?> <?php $currencies = $this->getCurrencies(); ?> <?php $currentCurrencyCode = $this->getCurrentCurrencyCode(); ?> -<div class="switcher currency"> - <strong class="label"><span><?php echo __('Currency') ?></span></strong> - <div class="actions dropdown options"> - <div class="action toggle" id="currency-switcher"> +<?php $id = $this->getIdModifier() ? '-' . $this->getIdModifier() : ''?> +<div class="switcher currency switcher-currency" id="switcher-currency<?php echo $id?>"> + <strong class="label switcher-label"><span><?php echo __('Currency') ?></span></strong> + <div class="actions dropdown options switcher-options"> + <div class="action toggle switcher-trigger" id="switcher-currency-trigger<?php echo $id?>"> <strong class="language-<?php echo $this->escapeHtml($this->getCurrentCurrencyCode()) ?>"> <span><?php echo $this->escapeHtml($currentCurrencyCode) ?> - <?php echo @$this->escapeHtml($currencies[$currentCurrencyCode]) ?></span> </strong> </div> - <ul class="dropdown" data-mage-init='{"dropdownDialog":{"appendTo":".switcher.currency > .options", "triggerTarget":"#currency-switcher", "closeOnMouseLeave": false, "triggerClass":"active", "parentClass":"active", "buttons":null}}'> + <ul class="dropdown switcher-dropdown" data-mage-init='{"dropdownDialog":{ + "appendTo":"#switcher-currency<?php echo $id?> > .options", + "triggerTarget":"#switcher-currency-trigger<?php echo $id?>", + "closeOnMouseLeave": false, + "triggerClass":"active", + "parentClass":"active", + "buttons":null}}'> <?php foreach ($currencies as $_code => $_name): ?> <?php if($_code != $currentCurrencyCode): ?> - <li class="currency-<?php echo $_code ?>"> + <li class="currency-<?php echo $_code ?> switcher-option"> <a href="#" data-post='<?php echo $this->getSwitchCurrencyPostData($_code); ?>'><?php echo $_code ?> - <?php echo $_name ?></a> </li> <?php endif; ?> diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index fd70a198701..dfaa9b07ab4 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -2,27 +2,27 @@ "name": "magento/module-downloadable", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/etc/adminhtml/acl.xml b/app/code/Magento/Downloadable/etc/acl.xml similarity index 94% rename from app/code/Magento/Downloadable/etc/adminhtml/acl.xml rename to app/code/Magento/Downloadable/etc/acl.xml index 5c136bb1549..6cc54d7359e 100644 --- a/app/code/Magento/Downloadable/etc/adminhtml/acl.xml +++ b/app/code/Magento/Downloadable/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml index 41b453a9236..453013f3755 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml +++ b/app/code/Magento/Downloadable/view/adminhtml/templates/product/edit/downloadable/samples.phtml @@ -251,6 +251,14 @@ sampleUploader = function (id) { })(jQuery, id); }; +if($('add_sample_item')){ + Event.observe('add_sample_item', 'click', sampleItems.add.bind(sampleItems)); +} + +<?php foreach ($this->getSampleData() as $item): ?> + sampleItems.add(<?php echo $item->toJson() ?>); +<?php endforeach; ?> + }); </script> diff --git a/app/code/Magento/Downloadable/view/frontend/templates/customer/products/list.phtml b/app/code/Magento/Downloadable/view/frontend/templates/customer/products/list.phtml index 5353cba99ec..62dfb148d2d 100644 --- a/app/code/Magento/Downloadable/view/frontend/templates/customer/products/list.phtml +++ b/app/code/Magento/Downloadable/view/frontend/templates/customer/products/list.phtml @@ -29,11 +29,6 @@ ?> <?php $_items = $this->getItems(); ?> <?php if(count($_items)): ?> - <?php if ($this->getChildHtml('pager')): ?> - <div class="toolbar downloadable-products-toolbar top"> - <?php echo $this->getChildHtml('pager'); ?> - </div> - <?php endif; ?> <div class="table-wrapper downloadable-products"> <table id="my-downloadable-products-table" class="data table table-downloadable-products"> <caption class="table caption"><?php echo __('Downloadable Products') ?></caption> diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 650b3fa8db6..4ff54743f58 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-eav", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index 3f8c783a0bf..1f01b6d4c0d 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-email", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/etc/adminhtml/acl.xml b/app/code/Magento/Email/etc/acl.xml similarity index 93% rename from app/code/Magento/Email/etc/adminhtml/acl.xml rename to app/code/Magento/Email/etc/acl.xml index 46699dfcc8f..39c597eb28d 100644 --- a/app/code/Magento/Email/etc/adminhtml/acl.xml +++ b/app/code/Magento/Email/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 10a02701ac6..1daa81c68b1 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -62,6 +62,22 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C */ protected $_code = self::CODE; + /** + * Types of rates, order is important + * + * @var array + */ + protected $_ratesOrder = [ + 'RATED_ACCOUNT_PACKAGE', + 'PAYOR_ACCOUNT_PACKAGE', + 'RATED_ACCOUNT_SHIPMENT', + 'PAYOR_ACCOUNT_SHIPMENT', + 'RATED_LIST_PACKAGE', + 'PAYOR_LIST_PACKAGE', + 'RATED_LIST_SHIPMENT', + 'PAYOR_LIST_SHIPMENT' + ]; + /** * Rate request data * @@ -585,8 +601,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C $rateTypeAmounts[$rateType] = $netAmount; } - // Order is important - foreach (array('RATED_ACCOUNT_SHIPMENT', 'RATED_LIST_SHIPMENT', 'RATED_LIST_PACKAGE') as $rateType) { + foreach ($this->_ratesOrder as $rateType) { if (!empty($rateTypeAmounts[$rateType])) { $amount = $rateTypeAmounts[$rateType]; break; diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 9c13f7eb7d8..462b906d620 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-fedex", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index d48fce67def..1b7228317bb 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-gift-message", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-multishipping": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-multishipping": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 5fc47874f0d..d6f7e5d6a8e 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-google-adwords", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 5cb9bc78c25..4919131005d 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-google-analytics", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml b/app/code/Magento/GoogleAnalytics/etc/acl.xml similarity index 94% rename from app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml rename to app/code/Magento/GoogleAnalytics/etc/acl.xml index 7354a089cf2..4107ab44caa 100644 --- a/app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml +++ b/app/code/Magento/GoogleAnalytics/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 094f6b1f9dc..c4caba7bbb7 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-google-optimizer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-google-analytics": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-google-analytics": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php index 512f6b69ab8..74e74bb2929 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -23,6 +23,9 @@ */ namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; +use \Magento\Framework\Notification\NotifierInterface; +use \Magento\Backend\App\Action; + /** * GoogleShopping Admin Items Controller * @@ -31,6 +34,20 @@ namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; */ class Items extends \Magento\Backend\App\Action { + /** + * @var NotifierInterface + */ + protected $notifier; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param NotifierInterface $notifier + */ + public function __construct(Action\Context $context, NotifierInterface $notifier) + { + parent::__construct($context); + $this->notifier = $notifier; + } /** * Retrieve synchronization process mutex diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php index 0b8245af5f0..d3030a4e92e 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php @@ -44,7 +44,6 @@ class MassAdd extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshoppin $storeId = $this->_getStore()->getId(); $productIds = $this->getRequest()->getParam('product', null); - $notifier = $this->_objectManager->create('Magento\AdminNotification\Model\Inbox'); try { $flag->lock(); @@ -64,7 +63,7 @@ class MassAdd extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshoppin return; } catch (\Exception $e) { $flag->unlock(); - $notifier->addMajor( + $this->notifier->addMajor( __('An error has occurred while adding products to google shopping account.'), $e->getMessage() ); diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php index bb294d6af1e..2e6514c7b19 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php @@ -68,9 +68,7 @@ class Refresh extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshoppin return; } catch (\Exception $e) { $flag->unlock(); - $this->_objectManager->create( - 'Magento\AdminNotification\Model\Inbox' - )->addMajor( + $this->notifier->addMajor( __('An error has occurred while deleting products from google shopping account.'), __( 'One or more products were not deleted from google shopping account. Refer to the log file for details.' diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index 8cf0e940823..180aa443eee 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -69,11 +69,11 @@ class MassOperations protected $_productFactory; /** - * Inbox factory + * Notifier * - * @var \Magento\AdminNotification\Model\InboxFactory + * @var \Magento\Framework\Notification\NotifierInterface */ - protected $_inboxFactory; + protected $_notifier; /** * Collection factory @@ -86,7 +86,7 @@ class MassOperations * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory * @param \Magento\GoogleShopping\Model\ItemFactory $itemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory + * @param \Magento\Framework\Notification\NotifierInterface $notifier * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\GoogleShopping\Helper\Data $gleShoppingData @@ -97,7 +97,7 @@ class MassOperations \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory, \Magento\GoogleShopping\Model\ItemFactory $itemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\AdminNotification\Model\InboxFactory $inboxFactory, + \Magento\Framework\Notification\NotifierInterface $notifier, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\GoogleShopping\Helper\Data $gleShoppingData, @@ -107,7 +107,7 @@ class MassOperations $this->_collectionFactory = $collectionFactory; $this->_itemFactory = $itemFactory; $this->_productFactory = $productFactory; - $this->_inboxFactory = $inboxFactory; + $this->_notifier = $notifier; $this->_storeManager = $storeManager; $this->_gleShoppingData = $gleShoppingData; $this->_gleShoppingCategory = $gleShoppingCategory; @@ -211,18 +211,18 @@ class MassOperations } if ($totalAdded > 0) { - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Products were added to Google Shopping account.'), __('A total of %1 product(s) have been added to Google Content.', $totalAdded) ); } if (count($errors)) { - $this->_getNotifier()->addMajor(__('Errors happened while adding products to Google Shopping.'), $errors); + $this->_notifier->addMajor(__('Errors happened while adding products to Google Shopping.'), $errors); } if ($this->_flag->isExpired()) { - $this->_getNotifier()->addMajor( + $this->_notifier->addMajor( __('Operation of adding products to Google Shopping expired.'), __('Some products may have not been added to Google Shopping bacause of expiration') ); @@ -298,7 +298,7 @@ class MassOperations return $this; } - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Product synchronization with Google Shopping completed'), __( 'A total of %1 items(s) have been deleted; a total of %2 items(s) have been updated.', @@ -308,7 +308,7 @@ class MassOperations ); if ($totalFailed > 0 || count($errors)) { array_unshift($errors, __("We cannot update %1 items.", $totalFailed)); - $this->_getNotifier()->addMajor( + $this->_notifier->addMajor( __('Errors happened during synchronization with Google Shopping'), $errors ); @@ -359,13 +359,13 @@ class MassOperations } if ($totalDeleted > 0) { - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Google Shopping item removal process succeded'), __('Total of %1 items(s) have been removed from Google Shopping.', $totalDeleted) ); } if (count($errors)) { - $this->_getNotifier()->addMajor(__('Errors happened while deleting items from Google Shopping'), $errors); + $this->_notifier->addMajor(__('Errors happened while deleting items from Google Shopping'), $errors); } return $this; @@ -390,16 +390,6 @@ class MassOperations return $itemsCollection; } - /** - * Retrieve admin notifier - * - * @return \Magento\AdminNotification\Model\Inbox - */ - protected function _getNotifier() - { - return $this->_inboxFactory->create(); - } - /** * Provides general error information * @@ -408,7 +398,7 @@ class MassOperations protected function _addGeneralError() { if (!$this->_hasError) { - $this->_getNotifier()->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage()); + $this->_notifier->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage()); $this->_hasError = true; } } diff --git a/app/code/Magento/GoogleShopping/Model/Observer.php b/app/code/Magento/GoogleShopping/Model/Observer.php index 83dd68d6432..4eafd2d0704 100644 --- a/app/code/Magento/GoogleShopping/Model/Observer.php +++ b/app/code/Magento/GoogleShopping/Model/Observer.php @@ -55,11 +55,11 @@ class Observer protected $_operationsFactory; /** - * Inbox factory + * Notifier * - * @var \Magento\AdminNotification\Model\InboxFactory + * @var \Magento\Framework\Notification\NotifierInterface */ - protected $_inboxFactory; + protected $_notifier; /** * Collection factory @@ -71,7 +71,7 @@ class Observer /** * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory * @param \Magento\GoogleShopping\Model\MassOperationsFactory $operationsFactory - * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory + * @param \Magento\Framework\Notification\NotifierInterface $notifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\GoogleShopping\Model\Flag $flag @@ -79,14 +79,14 @@ class Observer public function __construct( \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory, \Magento\GoogleShopping\Model\MassOperationsFactory $operationsFactory, - \Magento\AdminNotification\Model\InboxFactory $inboxFactory, + \Magento\Framework\Notification\NotifierInterface $notifier, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\GoogleShopping\Model\Flag $flag ) { $this->_collectionFactory = $collectionFactory; $this->_operationsFactory = $operationsFactory; - $this->_inboxFactory = $inboxFactory; + $this->_notifier = $notifier; $this->_scopeConfig = $scopeConfig; $this->messageManager = $messageManager; $this->_flag = $flag; @@ -146,7 +146,12 @@ class Observer } foreach ($items as $item) { - if (!$this->_scopeConfig->isSetFlag('google/googleshopping/observed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $item->getStoreId())) { + $flag = $this->_scopeConfig->isSetFlag( + 'google/googleshopping/observed', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $item->getStoreId() + ); + if (!$flag) { $items->removeItemByKey($item->getId()); } } @@ -164,7 +169,7 @@ class Observer { $this->_flag->loadSelf(); if ($this->_flag->isExpired()) { - $this->_inboxFactory->create()->addMajor( + $this->_notifier->addMajor( __('Google Shopping operation has expired.'), __('One or more google shopping synchronization operations failed because of timeout.') ); diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 1714fabb509..5fc87f04a43 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -2,22 +2,21 @@ "name": "magento/module-google-shopping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml b/app/code/Magento/GoogleShopping/etc/acl.xml similarity index 94% rename from app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml rename to app/code/Magento/GoogleShopping/etc/acl.xml index 965d797ebb1..0a8c2e4245c 100644 --- a/app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml +++ b/app/code/Magento/GoogleShopping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/GoogleShopping/etc/module.xml b/app/code/Magento/GoogleShopping/etc/module.xml index e7a52ba4ee9..89c6286283d 100644 --- a/app/code/Magento/GoogleShopping/etc/module.xml +++ b/app/code/Magento/GoogleShopping/etc/module.xml @@ -30,7 +30,6 @@ </sequence> <depends> <module name="Magento_Store"/> - <module name="Magento_AdminNotification"/> <module name="Magento_Core"/> <module name="Magento_Backend"/> <module name="Magento_Catalog"/> diff --git a/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php b/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php new file mode 100644 index 00000000000..1f8478909aa --- /dev/null +++ b/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php @@ -0,0 +1,30 @@ +<?php +/** + * Export entity of grouped product type + * + * 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\GroupedImportExport\Model\Export\Product\Type; + +class Grouped extends \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType +{ +} diff --git a/app/code/Magento/GroupedImportExport/Model/Export/RowCustomizer.php b/app/code/Magento/GroupedImportExport/Model/Export/RowCustomizer.php new file mode 100644 index 00000000000..1c56df62dc6 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/Model/Export/RowCustomizer.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\GroupedImportExport\Model\Export; + +use \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface; + +class RowCustomizer implements RowCustomizerInterface +{ + /** + * @inheritdoc + */ + public function prepareData($collection, $productIds) + { + return; + } + + /** + * @inheritdoc + */ + public function addHeaderColumns($columns) + { + $columns = array_merge( + $columns, + array( + '_associated_sku', + '_associated_default_qty', + '_associated_position' + ) + ); + return $columns; + } + + /** + * @inheritdoc + */ + public function addData($dataRow, $productId) + { + return $dataRow; + } + + /** + * @inheritdoc + */ + public function getAdditionalRowsCount($additionalRowsCount, $productId) + { + return $additionalRowsCount; + } +} diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Grouped.php b/app/code/Magento/GroupedImportExport/Model/Import/Product/Type/Grouped.php similarity index 98% rename from app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Grouped.php rename to app/code/Magento/GroupedImportExport/Model/Import/Product/Type/Grouped.php index 7492697f6a7..1323fb73de8 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedImportExport/Model/Import/Product/Type/Grouped.php @@ -23,9 +23,9 @@ * @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\CatalogImportExport\Model\Import\Product\Type; +namespace Magento\GroupedImportExport\Model\Import\Product\Type; -class Grouped extends AbstractType +class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType { /** * Column names that holds values with particular meaning. diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json new file mode 100644 index 00000000000..9ddd9462305 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-grouped-import-export", + "description": "N/A", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-import-export": "0.1.0-alpha90", + "magento/module-catalog-import-export": "0.1.0-alpha90", + "magento/module-grouped-product": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" + }, + "type": "magento2-module", + "version": "0.1.0-alpha90", + "extra": { + "map": [ + [ + "*", + "Magento/GroupedImportExport" + ] + ] + } +} diff --git a/app/code/Magento/GroupedImportExport/etc/di.xml b/app/code/Magento/GroupedImportExport/etc/di.xml new file mode 100644 index 00000000000..2fee2173b7b --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/di.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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite"> + <arguments> + <argument name="customizers" xsi:type="array"> + <item name="gropedProduct" xsi:type="string">Magento\GroupedImportExport\Model\Export\RowCustomizer</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/GroupedImportExport/etc/export.xml b/app/code/Magento/GroupedImportExport/etc/export.xml new file mode 100644 index 00000000000..c29cda67913 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/export.xml @@ -0,0 +1,28 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ImportExport/etc/export.xsd"> + <entityType entity="catalog_product" name="grouped" model="Magento\GroupedImportExport\Model\Export\Product\Type\Grouped" /> +</config> diff --git a/app/code/Magento/GroupedImportExport/etc/import.xml b/app/code/Magento/GroupedImportExport/etc/import.xml new file mode 100644 index 00000000000..20251196082 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/import.xml @@ -0,0 +1,28 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../ImportExport/etc/import.xsd"> + <entityType entity="catalog_product" name="grouped" model="Magento\GroupedImportExport\Model\Import\Product\Type\Grouped" /> +</config> diff --git a/app/code/Magento/GroupedImportExport/etc/module.xml b/app/code/Magento/GroupedImportExport/etc/module.xml new file mode 100644 index 00000000000..27708b2a032 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/module.xml @@ -0,0 +1,36 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> + <module name="Magento_GroupedImportExport" schema_version="1.0.0.0" active="true"> + <depends> + <module name="Magento_Catalog"/> + <module name="Magento_ImportExport"/> + <module name="Magento_CatalogImportExport"/> + <module name="Magento_GroupedProduct"/> + <module name="Magento_Eav"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 65984cf03f5..cf8b138e08e 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -2,23 +2,23 @@ "name": "magento/module-grouped-product", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 004eb3554d5..3b83b038476 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-import-export", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/etc/adminhtml/acl.xml b/app/code/Magento/ImportExport/etc/acl.xml similarity index 94% rename from app/code/Magento/ImportExport/etc/adminhtml/acl.xml rename to app/code/Magento/ImportExport/etc/acl.xml index 21a4534e03b..1ea1488aedc 100644 --- a/app/code/Magento/ImportExport/etc/adminhtml/acl.xml +++ b/app/code/Magento/ImportExport/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Index/Model/System/Message/IndexOutdated.php b/app/code/Magento/Index/Model/System/Message/IndexOutdated.php index a5a46aa6bd0..a25fc378e56 100644 --- a/app/code/Magento/Index/Model/System/Message/IndexOutdated.php +++ b/app/code/Magento/Index/Model/System/Message/IndexOutdated.php @@ -17,13 +17,13 @@ * 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\Index\Model\System\Message; -class IndexOutdated implements \Magento\AdminNotification\Model\System\MessageInterface +class IndexOutdated implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Index\Model\Indexer diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 4d5201a449c..fcf3e916598 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -2,15 +2,14 @@ "name": "magento/module-index", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/etc/adminhtml/acl.xml b/app/code/Magento/Index/etc/acl.xml similarity index 93% rename from app/code/Magento/Index/etc/adminhtml/acl.xml rename to app/code/Magento/Index/etc/acl.xml index 3c2f0f49250..915fc10d066 100644 --- a/app/code/Magento/Index/etc/adminhtml/acl.xml +++ b/app/code/Magento/Index/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Index/etc/adminhtml/di.xml b/app/code/Magento/Index/etc/adminhtml/di.xml index 8ec4ff4eadd..5805634b012 100644 --- a/app/code/Magento/Index/etc/adminhtml/di.xml +++ b/app/code/Magento/Index/etc/adminhtml/di.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\AdminNotification\Model\System\MessageList"> + <type name="Magento\Framework\Notification\MessageList"> <arguments> <argument name="messages" xsi:type="array"> <item name="indexer" xsi:type="string">Magento\Index\Model\System\Message\IndexOutdated</item> diff --git a/app/code/Magento/Index/etc/module.xml b/app/code/Magento/Index/etc/module.xml index 8ff8a9e206d..92b3bfd022c 100644 --- a/app/code/Magento/Index/etc/module.xml +++ b/app/code/Magento/Index/etc/module.xml @@ -32,7 +32,6 @@ <depends> <module name="Magento_Store"/> <module name="Magento_Backend"/> - <module name="Magento_AdminNotification"/> </depends> </module> </config> diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 71272f04ac0..4409860e4a0 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-indexer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/etc/adminhtml/acl.xml b/app/code/Magento/Indexer/etc/acl.xml similarity index 94% rename from app/code/Magento/Indexer/etc/adminhtml/acl.xml rename to app/code/Magento/Indexer/etc/acl.xml index 43be5a63053..ecc2b372817 100644 --- a/app/code/Magento/Indexer/etc/adminhtml/acl.xml +++ b/app/code/Magento/Indexer/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Install/Block/End.php b/app/code/Magento/Install/Block/End.php index 012870dabd8..75d895086e9 100644 --- a/app/code/Magento/Install/Block/End.php +++ b/app/code/Magento/Install/Block/End.php @@ -24,8 +24,6 @@ /** * Installation ending block - * - * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\Install\Block; @@ -37,7 +35,7 @@ class End extends \Magento\Install\Block\AbstractBlock protected $_template = 'end.phtml'; /** - * @var \Magento\AdminNotification\Model\Survey + * @var \Magento\Install\Model\Survey */ protected $_survey; @@ -53,7 +51,7 @@ class End extends \Magento\Install\Block\AbstractBlock * @param \Magento\Install\Model\Installer $installer * @param \Magento\Install\Model\Wizard $installWizard * @param \Magento\Framework\Session\Generic $session - * @param \Magento\AdminNotification\Model\Survey $survey + * @param \Magento\Install\Model\Survey $survey * @param string $cryptKey * @param array $data */ @@ -62,7 +60,7 @@ class End extends \Magento\Install\Block\AbstractBlock \Magento\Install\Model\Installer $installer, \Magento\Install\Model\Wizard $installWizard, \Magento\Framework\Session\Generic $session, - \Magento\AdminNotification\Model\Survey $survey, + \Magento\Install\Model\Survey $survey, $cryptKey, array $data = array() ) { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php b/app/code/Magento/Install/Controller/Adminhtml/Survey.php similarity index 90% rename from app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php rename to app/code/Magento/Install/Controller/Adminhtml/Survey.php index e7650a90e5a..5358b053e9d 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php +++ b/app/code/Magento/Install/Controller/Adminhtml/Survey.php @@ -21,12 +21,10 @@ * @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\AdminNotification\Controller\Adminhtml; +namespace Magento\Install\Controller\Adminhtml; /** * Adminhtml Survey Action - * - * @author Magento Core Team <core@magentocommerce.com> */ class Survey extends \Magento\Backend\App\Action { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php b/app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php similarity index 83% rename from app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php rename to app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php index 98caa51c392..69fb6a58c2b 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php +++ b/app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php @@ -22,9 +22,9 @@ * @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\AdminNotification\Controller\Adminhtml\Survey; +namespace Magento\Install\Controller\Adminhtml\Survey; -class Index extends \Magento\AdminNotification\Controller\Adminhtml\Survey +class Index extends \Magento\Install\Controller\Adminhtml\Survey { /** * Index Action @@ -34,7 +34,7 @@ class Index extends \Magento\AdminNotification\Controller\Adminhtml\Survey public function execute() { if ($this->getRequest()->getParam('isAjax', false)) { - $this->_objectManager->get('Magento\AdminNotification\Model\Survey')->saveSurveyViewed(true); + $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); } $this->getResponse()->representJson(\Zend_Json::encode(array('survey_decision_saved' => 1))); } diff --git a/app/code/Magento/Install/Controller/Wizard/End.php b/app/code/Magento/Install/Controller/Wizard/End.php index dfd9c13d944..ce9238c0348 100644 --- a/app/code/Magento/Install/Controller/Wizard/End.php +++ b/app/code/Magento/Install/Controller/Wizard/End.php @@ -42,7 +42,7 @@ class End extends \Magento\Install\Controller\Wizard $this->_getInstaller()->finish(); - $this->_objectManager->get('Magento\AdminNotification\Model\Survey')->saveSurveyViewed(true); + $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); $this->_prepareLayout(); $this->_view->getLayout()->initMessages(); diff --git a/app/code/Magento/AdminNotification/Model/Survey.php b/app/code/Magento/Install/Model/Survey.php similarity index 94% rename from app/code/Magento/AdminNotification/Model/Survey.php rename to app/code/Magento/Install/Model/Survey.php index 1b061be7a1d..1278e3938f4 100644 --- a/app/code/Magento/AdminNotification/Model/Survey.php +++ b/app/code/Magento/Install/Model/Survey.php @@ -24,11 +24,9 @@ /** - * AdminNotification survey model - * - * @author Magento Core Team <core@magentocommerce.com> + * Installation survey model */ -namespace Magento\AdminNotification\Model; +namespace Magento\Install\Model; class Survey { @@ -37,7 +35,7 @@ class Survey /** * @var string */ - protected $_flagCode = 'admin_notification_survey'; + protected $_flagCode = 'install_survey'; /** * @var \Magento\Framework\Flag diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Survey.php b/app/code/Magento/Install/Model/System/Message/Survey.php similarity index 87% rename from app/code/Magento/AdminNotification/Model/System/Message/Survey.php rename to app/code/Magento/Install/Model/System/Message/Survey.php index e2aad410190..3d516ed61c2 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Survey.php +++ b/app/code/Magento/Install/Model/System/Message/Survey.php @@ -21,9 +21,9 @@ * @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\AdminNotification\Model\System\Message; +namespace Magento\Install\Model\System\Message; -class Survey implements \Magento\AdminNotification\Model\System\MessageInterface +class Survey implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Backend\Model\Auth\Session @@ -41,7 +41,7 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface protected $_urlBuilder; /** - * @var \Magento\AdminNotification\Model\Survey + * @var \Magento\Install\Model\Survey */ protected $_survey; @@ -49,13 +49,13 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\AdminNotification\Model\Survey $survey + * @param \Magento\Install\Model\Survey $survey */ public function __construct( \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\AdminNotification\Model\Survey $survey + \Magento\Install\Model\Survey $survey ) { $this->_authorization = $authorization; $this->_authSession = $authSession; @@ -118,7 +118,7 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface ) ); return __( - 'We appreciate our merchants\' feedback. Please <a href="#" data-mage-init=%1>take our survey</a> and tell us about features you\'d like to see in Magento.', + 'We appreciate our merchants\' feedback. Please <a href="#" data-mage-init="%1">take our survey</a> and tell us about features you\'d like to see in Magento.', json_encode($params, JSON_FORCE_OBJECT) ); } @@ -130,6 +130,6 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; } } diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index fc8c08ee1d0..37ae0241420 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -2,18 +2,17 @@ "name": "magento/module-install", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-user": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/etc/adminhtml/routes.xml b/app/code/Magento/Install/etc/adminhtml/routes.xml new file mode 100644 index 00000000000..6561687d777 --- /dev/null +++ b/app/code/Magento/Install/etc/adminhtml/routes.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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> + <router id="admin"> + <route id="adminhtml"> + <module name="Magento_Install" before="Magento_Adminhtml" /> + </route> + </router> +</config> diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index 5978523573d..c502e62e5a7 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -36,6 +36,13 @@ <argument name="storage" xsi:type="object">Magento\Install\Model\Session\Storage</argument> </arguments> </virtualType> + <type name="Magento\Framework\Notification\MessageList"> + <arguments> + <argument name="messages" xsi:type="array"> + <item name="survey" xsi:type="string">Magento\Install\Model\System\Message\Survey</item> + </argument> + </arguments> + </type> <type name="Magento\Install\Block\Begin"> <arguments> <argument name="eulaFile" xsi:type="string">LICENSE.html</argument> diff --git a/app/code/Magento/Install/etc/module.xml b/app/code/Magento/Install/etc/module.xml index bb2fd20c81d..64f36117539 100644 --- a/app/code/Magento/Install/etc/module.xml +++ b/app/code/Magento/Install/etc/module.xml @@ -31,7 +31,6 @@ </sequence> <depends> <module name="Magento_Store"/> - <module name="Magento_AdminNotification"/> <module name="Magento_Directory"/> <module name="Magento_User"/> <module name="Magento_Backend"/> diff --git a/app/code/Magento/Install/view/adminhtml/layout/default.xml b/app/code/Magento/Install/view/adminhtml/layout/default.xml new file mode 100644 index 00000000000..4eb246a43bf --- /dev/null +++ b/app/code/Magento/Install/view/adminhtml/layout/default.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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/layout_single.xsd"> + <referenceBlock name="head"> + <block class="Magento\Theme\Block\Html\Head\Script" name="magento-install-survey-notification-js" after="jquery"> + <arguments> + <argument name="file" xsi:type="string">Magento_Install::survey_notification.js</argument> + </arguments> + </block> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Install/view/adminhtml/web/survey_notification.js b/app/code/Magento/Install/view/adminhtml/web/survey_notification.js new file mode 100644 index 00000000000..c008c47217a --- /dev/null +++ b/app/code/Magento/Install/view/adminhtml/web/survey_notification.js @@ -0,0 +1,41 @@ +/** + * 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) + */ +/*jshint jquery:true*/ +require(["jquery"], function($){ + "use strict"; + + $(document).ready(function(){ + $('body').on('surveyYes surveyNo', function(e, data) { + if (e.type == 'surveyYes') { + var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1'); + win.focus(); + } + $.ajax({ + url: data.surveyAction, + type: 'post', + data: {decision: data.decision} + }); + }); + }); + +}); diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php index a18d4416e1e..fc65d977e6a 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php @@ -33,16 +33,12 @@ use Magento\Integration\Controller\Adminhtml\Integration as IntegrationControlle class Tokens extends \Magento\Backend\Block\Widget\Form\Generic { /**#@+ - * Form elements names. + * Form element name. */ const DATA_TOKEN = 'token'; - const DATA_TOKEN_SECRET = 'token_secret'; - const DATA_CONSUMER_KEY = 'consumer_key'; - const DATA_CONSUMER_SECRET = 'consumer_secret'; - /**#@-*/ /** diff --git a/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php b/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php index 6c68fd46dfd..978d7394e6b 100644 --- a/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php +++ b/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php @@ -60,7 +60,7 @@ class TokensExchange extends \Magento\Integration\Controller\Adminhtml\Integrati $integration = $this->_integrationService->get($integrationId); if ($isReauthorize) { /** Remove existing token associated with consumer before issuing a new one. */ - $this->_oauthService->deleteToken($integration->getConsumerId()); + $this->_oauthService->deleteIntegrationToken($integration->getConsumerId()); $integration->setStatus(IntegrationModel::STATUS_INACTIVE)->save(); } //Integration chooses to use Oauth for token exchange diff --git a/app/code/Magento/Integration/Model/Integration.php b/app/code/Magento/Integration/Model/Integration.php index 03df47f4b40..4daefc25f71 100644 --- a/app/code/Magento/Integration/Model/Integration.php +++ b/app/code/Magento/Integration/Model/Integration.php @@ -43,6 +43,7 @@ namespace Magento\Integration\Model; * @method Integration setCreatedAt(\string $createdAt) * @method \string getUpdatedAt() * @method Integration setUpdatedAt(\string $createdAt) + * @method \Magento\Integration\Model\Resource\Integration getResource() */ class Integration extends \Magento\Framework\Model\AbstractModel { @@ -147,6 +148,19 @@ class Integration extends \Magento\Framework\Model\AbstractModel return $this->load($consumerId, self::CONSUMER_ID); } + /** + * Load active integration by oAuth consumer ID. + * + * @param int $consumerId + * @return $this + */ + public function loadActiveIntegrationByConsumerId($consumerId) + { + $integrationData = $this->getResource()->selectActiveIntegrationByConsumerId($consumerId); + $this->setData($integrationData ? $integrationData : []); + return $this; + } + /** * Get integration status. Cast to the type of STATUS_* constants in order to make strict comparison valid. * diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php index 67f2a3632d4..1d692ba2c65 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Oauth/Token.php @@ -23,6 +23,7 @@ */ namespace Magento\Integration\Model\Oauth; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\Oauth\Helper\Oauth as OauthHelper; use Magento\Integration\Model\Resource\Oauth\Token\Collection as TokenCollection; use Magento\Framework\Oauth\Exception as OauthException; @@ -41,6 +42,8 @@ use Magento\Framework\Oauth\Exception as OauthException; * @method Token setAdminId() setAdminId(int $adminId) * @method int getCustomerId() * @method Token setCustomerId() setCustomerId(int $customerId) + * @method int getUserType() + * @method Token setUserType() setUserType(int $userType) * @method string getType() * @method Token setType() setType(string $type) * @method string getCallbackUrl() @@ -70,15 +73,6 @@ class Token extends \Magento\Framework\Model\AbstractModel /**#@- */ - /**#@+ - * Customer types - */ - const USER_TYPE_ADMIN = 'admin'; - - const USER_TYPE_CUSTOMER = 'customer'; - - /**#@- */ - /** * @var OauthHelper */ @@ -191,65 +185,52 @@ class Token extends \Magento\Framework\Model\AbstractModel 'token' => $this->_oauthHelper->generateToken(), 'secret' => $this->_oauthHelper->generateTokenSecret(), 'verifier' => $this->_oauthHelper->generateVerifier(), - 'callback_url' => OauthHelper::CALLBACK_ESTABLISHED + 'callback_url' => OauthHelper::CALLBACK_ESTABLISHED, + 'user_type' => UserContextInterface::USER_TYPE_INTEGRATION //As of now only integrations use Oauth ) ); + $this->validate(); $this->save(); } return $this; } /** - * Authorize token + * Convert token to access type * - * @param int $userId Authorization user identifier - * @param string $userType Authorization user type * @return $this * @throws OauthException */ - public function authorize($userId, $userType) + public function convertToAccess() { - if (!$this->getId() || !$this->getConsumerId()) { - throw new OauthException('Token is not ready to be authorized'); - } - if ($this->getAuthorized()) { - throw new OauthException('Token is already authorized'); - } - if (self::USER_TYPE_ADMIN == $userType) { - $this->setAdminId($userId); - } elseif (self::USER_TYPE_CUSTOMER == $userType) { - $this->setCustomerId($userId); - } else { - throw new OauthException('User type is unknown'); + if (self::TYPE_REQUEST != $this->getType()) { + throw new OauthException('Cannot convert to access token due to token is not request type'); } - - $this->setVerifier($this->_oauthHelper->generateVerifier()); - $this->setAuthorized(1); - $this->save(); - - $this->getResource()->cleanOldAuthorizedTokensExcept($this); - - return $this; + return $this->saveAccessToken(UserContextInterface::USER_TYPE_INTEGRATION); } /** - * Convert token to access type + * Create access token for a admin * + * @param int $userId * @return $this - * @throws OauthException */ - public function convertToAccess() + public function createAdminToken($userId) { - if (self::TYPE_REQUEST != $this->getType()) { - throw new OauthException('Cannot convert to access token due to token is not request type'); - } - - $this->setType(self::TYPE_ACCESS); - $this->setToken($this->_oauthHelper->generateToken()); - $this->setSecret($this->_oauthHelper->generateTokenSecret()); - $this->save(); + $this->setAdminId($userId); + return $this->saveAccessToken(UserContextInterface::USER_TYPE_ADMIN); + } - return $this; + /** + * Create access token for a customer + * + * @param int $userId + * @return $this + */ + public function createCustomerToken($userId) + { + $this->setCustomerId($userId); + return $this->saveAccessToken(UserContextInterface::USER_TYPE_CUSTOMER, $userId); } /** @@ -271,28 +252,12 @@ class Token extends \Magento\Framework\Model\AbstractModel 'callback_url' => $callbackUrl ) ); + $this->validate(); $this->save(); return $this; } - /** - * Get OAuth user type - * - * @return string - * @throws OauthException - */ - public function getUserType() - { - if ($this->getAdminId()) { - return self::USER_TYPE_ADMIN; - } elseif ($this->getCustomerId()) { - return self::USER_TYPE_CUSTOMER; - } else { - throw new OauthException('User type is unknown'); - } - } - /** * Get string representation of token * @@ -312,8 +277,6 @@ class Token extends \Magento\Framework\Model\AbstractModel */ protected function _beforeSave() { - $this->validate(); - if ($this->isObjectNew() && null === $this->getCreatedAt()) { $this->setCreatedAt($this->_dateTime->now()); } @@ -365,39 +328,78 @@ class Token extends \Magento\Framework\Model\AbstractModel } /** - * Get Token Consumer + * Return the token's verifier. * - * @return \Magento\Integration\Model\Oauth\Consumer + * @return string */ - public function getConsumer() + public function getVerifier() { - if (!$this->getData('consumer')) { - $consumer = $this->_consumerFactory->create()->load($this->getConsumerId()); - $this->setData('consumer', $consumer); - } + return $this->getData('verifier'); + } - return $this->getData('consumer'); + /** + * Generate and save access token for a given user type + * + * @param int $userType + * @return $this + */ + protected function saveAccessToken($userType) + { + $this->setUserType($userType); + $this->setType(self::TYPE_ACCESS); + $this->setToken($this->_oauthHelper->generateToken()); + $this->setSecret($this->_oauthHelper->generateTokenSecret()); + return $this->save(); } /** - * Return the token's verifier. + * Get token by consumer and user type * - * @return string + * @param int $consumerId + * @param int $userType + * @return $this */ - public function getVerifier() + public function loadByConsumerIdAndUserType($consumerId, $userType) { - return $this->getData('verifier'); + $tokenData = $this->getResource()->selectTokenByConsumerIdAndUserType($consumerId, $userType); + $this->setData($tokenData ? $tokenData : []); + return $this; + } + + /** + * Get token by admin id + * + * @param int $adminId + * @return $this + */ + public function loadByAdminId($adminId) + { + $tokenData = $this->getResource()->selectTokenByAdminId($adminId); + $this->setData($tokenData ? $tokenData : []); + return $this; } /** - * Set the token's verifier. + * Get token by admin id * - * @param string $verifier + * @param int $customerId * @return $this */ - public function setVerifier($verifier) + public function loadByCustomerId($customerId) { - $this->setData('verifier', $verifier); + $tokenData = $this->getResource()->selectTokenByCustomerId($customerId); + $this->setData($tokenData ? $tokenData : []); return $this; } + + /** + * Load token data by token. + * + * @param string $token + * @return $this + */ + public function loadByToken($token) + { + return $this->load($token, 'token'); + } } diff --git a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php index 8ca3ff82b52..1ac01035d50 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php +++ b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php @@ -21,9 +21,12 @@ * @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\Integration\Model\Oauth\Token; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\Oauth\TokenProviderInterface; +use Magento\Integration\Model\Oauth\Token; class Provider implements TokenProviderInterface { @@ -47,22 +50,30 @@ class Provider implements TokenProviderInterface */ protected $_date; + /** + * @var Token + */ + protected $token; + /** * @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory * @param \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory * @param \Magento\Integration\Helper\Oauth\Data $dataHelper * @param \Magento\Framework\Stdlib\DateTime\DateTime $date + * @param Token $token */ public function __construct( \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory, \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory, \Magento\Integration\Helper\Oauth\Data $dataHelper, - \Magento\Framework\Stdlib\DateTime\DateTime $date + \Magento\Framework\Stdlib\DateTime\DateTime $date, + Token $token ) { $this->_consumerFactory = $consumerFactory; $this->_tokenFactory = $tokenFactory; $this->_dataHelper = $dataHelper; $this->_date = $date; + $this->token = $token; } /** @@ -86,8 +97,8 @@ class Provider implements TokenProviderInterface */ public function createRequestToken($consumer) { - $token = $this->getTokenByConsumerId($consumer->getId()); - if ($token->getType() != \Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER) { + $token = $this->getIntegrationTokenByConsumerId($consumer->getId()); + if ($token->getType() != Token::TYPE_VERIFIER) { throw new \Magento\Framework\Oauth\Exception( 'Cannot create request token because consumer token is not a verifier token' ); @@ -111,7 +122,7 @@ class Provider implements TokenProviderInterface // The pre-auth token has a value of "request" in the type when it is requested and created initially. // In this flow (token flow) the token has to be of type "request" else its marked as reused. - if (\Magento\Integration\Model\Oauth\Token::TYPE_REQUEST != $token->getType()) { + if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is already being used' ); @@ -128,8 +139,8 @@ class Provider implements TokenProviderInterface public function getAccessToken($consumer) { /** TODO: log the request token in dev mode since its not persisted. */ - $token = $this->getTokenByConsumerId($consumer->getId()); - if (\Magento\Integration\Model\Oauth\Token::TYPE_REQUEST != $token->getType()) { + $token = $this->getIntegrationTokenByConsumerId($consumer->getId()); + if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Cannot get access token because consumer token is not a request token' ); @@ -150,7 +161,7 @@ class Provider implements TokenProviderInterface 'Token is not associated with the specified consumer' ); } - if (\Magento\Integration\Model\Oauth\Token::TYPE_ACCESS != $token->getType()) { + if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is not an access token' ); @@ -173,7 +184,7 @@ class Provider implements TokenProviderInterface // Make sure a consumer is associated with the token. $this->_getConsumer($token->getConsumerId()); - if (\Magento\Integration\Model\Oauth\Token::TYPE_ACCESS != $token->getType()) { + if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is not an access token' ); @@ -270,7 +281,7 @@ class Provider implements TokenProviderInterface * Load token object and validate it. * * @param string $token - * @return \Magento\Integration\Model\Oauth\Token + * @return Token * @throws \Magento\Framework\Oauth\Exception */ protected function _getToken($token) @@ -296,12 +307,12 @@ class Provider implements TokenProviderInterface * Load token object given a consumer Id. * * @param int $consumerId - The Id of the consumer. - * @return \Magento\Integration\Model\Oauth\Token + * @return Token * @throws \Magento\Framework\Oauth\Exception */ - public function getTokenByConsumerId($consumerId) + public function getIntegrationTokenByConsumerId($consumerId) { - $token = $this->_tokenFactory->create()->load($consumerId, 'consumer_id'); + $token = $this->token->loadByConsumerIdAndUserType($consumerId, UserContextInterface::USER_TYPE_INTEGRATION); if (!$token->getId()) { throw new \Magento\Framework\Oauth\Exception( @@ -316,7 +327,7 @@ class Provider implements TokenProviderInterface /** * Check if token belongs to the same consumer. * - * @param \Magento\Integration\Model\Oauth\Token $token + * @param Token $token * @param \Magento\Framework\Oauth\ConsumerInterface $consumer * @return bool */ diff --git a/app/code/Magento/Integration/Model/Resource/Integration.php b/app/code/Magento/Integration/Model/Resource/Integration.php index 39c9f60bc1a..54f3c460dab 100644 --- a/app/code/Magento/Integration/Model/Resource/Integration.php +++ b/app/code/Magento/Integration/Model/Resource/Integration.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) */ + namespace Magento\Integration\Model\Resource; /** @@ -37,4 +38,20 @@ class Integration extends \Magento\Framework\Model\Resource\Db\AbstractDb { $this->_init('integration', 'integration_id'); } + + /** + * Select token for a given customer. + * + * @param int $consumerId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectActiveIntegrationByConsumerId($consumerId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', $consumerId) + ->where('status = ?', \Magento\Integration\Model\Integration::STATUS_ACTIVE); + return $adapter->fetchRow($select); + } } diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php index 522696ae63e..469f492ac3a 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php @@ -23,6 +23,8 @@ */ namespace Magento\Integration\Model\Resource\Oauth; +use Magento\Authorization\Model\UserContextInterface; + /** * OAuth token resource model */ @@ -116,15 +118,59 @@ class Token extends \Magento\Framework\Model\Resource\Db\AbstractDb public function selectTokenByType($consumerId, $type) { $adapter = $this->_getReadAdapter(); - $select = $adapter->select()->from( - $this->getMainTable() - )->where( - 'consumer_id = ?', - $consumerId - )->where( - 'type = ?', - $type - ); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', $consumerId) + ->where('type = ?', $type); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given consumer and user type. + * + * @param int $consumerId + * @param int $userType + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByConsumerIdAndUserType($consumerId, $userType) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', (int)$consumerId) + ->where('user_type = ?', (int)$userType); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given admin id. + * + * @param int $adminId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByAdminId($adminId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('admin_id = ?', $adminId) + ->where('user_type = ?', UserContextInterface::USER_TYPE_ADMIN); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given customer. + * + * @param int $customerId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByCustomerId($customerId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('customer_id = ?', $customerId) + ->where('user_type = ?', UserContextInterface::USER_TYPE_CUSTOMER); return $adapter->fetchRow($select); } } diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationService.php b/app/code/Magento/Integration/Service/V1/AuthorizationService.php new file mode 100644 index 00000000000..bcbcfdff755 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/AuthorizationService.php @@ -0,0 +1,214 @@ +<?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\Integration\Service\V1; + +use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; +use Magento\Authorization\Model\Resource\Rules\CollectionFactory as RulesCollectionFactory; +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\RoleFactory; +use Magento\Authorization\Model\RulesFactory; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\Acl; +use Magento\Framework\Acl\Builder as AclBuilder; +use Magento\Framework\Acl\RootResource as RootAclResource; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Logger; + +/** + * Service for integration permissions management. + * + * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class AuthorizationService implements AuthorizationServiceInterface +{ + /** + * @var AclBuilder + */ + protected $_aclBuilder; + + /** + * @var RoleFactory + */ + protected $_roleFactory; + + /** + * @var RoleCollectionFactory + */ + protected $_roleCollectionFactory; + + /** + * @var RulesFactory + */ + protected $_rulesFactory; + + /** + * @var RulesCollectionFactory + */ + protected $_rulesCollectionFactory; + + /** + * @var Logger + */ + protected $_logger; + + /** + * @var RootAclResource + */ + protected $_rootAclResource; + + /** + * Initialize dependencies. + * + * @param AclBuilder $aclBuilder + * @param RoleFactory $roleFactory + * @param RoleCollectionFactory $roleCollectionFactory + * @param RulesFactory $rulesFactory + * @param RulesCollectionFactory $rulesCollectionFactory + * @param Logger $logger + * @param RootAclResource $rootAclResource + */ + public function __construct( + AclBuilder $aclBuilder, + RoleFactory $roleFactory, + RoleCollectionFactory $roleCollectionFactory, + RulesFactory $rulesFactory, + RulesCollectionFactory $rulesCollectionFactory, + Logger $logger, + RootAclResource $rootAclResource + ) { + $this->_aclBuilder = $aclBuilder; + $this->_roleFactory = $roleFactory; + $this->_rulesFactory = $rulesFactory; + $this->_rulesCollectionFactory = $rulesCollectionFactory; + $this->_roleCollectionFactory = $roleCollectionFactory; + $this->_logger = $logger; + $this->_rootAclResource = $rootAclResource; + } + + /** + * {@inheritdoc} + */ + public function grantPermissions($integrationId, $resources) + { + try { + $role = $this->_getUserRole($integrationId); + if (!$role) { + $role = $this->_createRole($integrationId); + } + $this->_associateResourcesWithRole($role, $resources); + } catch (\Exception $e) { + $this->_logger->logException($e); + throw new LocalizedException('Error happened while granting permissions. Check exception log for details.'); + } + } + + /** + * {@inheritdoc} + */ + public function grantAllPermissions($integrationId) + { + $this->grantPermissions($integrationId, array($this->_rootAclResource->getId())); + } + + /** + * {@inheritdoc} + */ + public function removePermissions($integrationId) + { + try { + $this->_deleteRole($integrationId); + } catch (\Exception $e) { + $this->_logger->logException($e); + throw new LocalizedException( + 'Error happened while deleting role and permissions. Check exception log for details.' + ); + } + } + + /** + * Create new ACL role. + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role + */ + protected function _createRole($integrationId) + { + $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId; + $role = $this->_roleFactory->create(); + $role->setRoleName($roleName) + ->setUserType(UserContextInterface::USER_TYPE_INTEGRATION) + ->setUserId($integrationId) + ->setRoleType(\Magento\Authorization\Model\Acl\Role\User::ROLE_TYPE) + ->setParentId(0) + ->save(); + return $role; + } + + /** + * Remove integration role. This deletes the cascading permissions + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role + */ + protected function _deleteRole($integrationId) + { + $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId; + $role = $this->_roleFactory->create()->load($roleName, 'role_name'); + return $role->delete(); + } + + /** + * Identify authorization role associated with provided integration. + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role|false Return false in case when no role associated with user was found. + */ + protected function _getUserRole($integrationId) + { + $roleCollection = $this->_roleCollectionFactory->create(); + /** @var Role $role */ + $role = $roleCollection + ->setUserFilter($integrationId, UserContextInterface::USER_TYPE_INTEGRATION) + ->getFirstItem(); + return $role->getId() ? $role : false; + } + + /** + * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. + * + * @param \Magento\Authorization\Model\Role $role + * @param string[] $resources + * @return void + * @throws \LogicException + */ + protected function _associateResourcesWithRole($role, $resources) + { + /** @var \Magento\Authorization\Model\Rules $rules */ + $rules = $this->_rulesFactory->create(); + $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); + } +} diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php b/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php new file mode 100644 index 00000000000..1b7b0438138 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php @@ -0,0 +1,68 @@ +<?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\Integration\Service\V1; + +use Magento\Framework\Exception\LocalizedException; + +/** + * Interface for integration permissions management. + */ +interface AuthorizationServiceInterface +{ + /**#@+ + * Permission type + */ + const PERMISSION_ANONYMOUS = 'anonymous'; + const PERMISSION_SELF = 'self'; + /**#@- */ + + /** + * Grant permissions to user to access the specified resources. + * + * @param int $integrationId + * @param string[] $resources List of resources which should be available to the specified user. + * @return void + * @throws LocalizedException + */ + public function grantPermissions($integrationId, $resources); + + /** + * Grant permissions to the user to access all resources available in the system. + * + * @param int $integrationId + * @return void + * @throws LocalizedException + */ + public function grantAllPermissions($integrationId); + + /** + * Remove role and associated permissions for the specified integration. + * + * @param int $integrationId + * @return void + * @throws LocalizedException + */ + public function removePermissions($integrationId); +} diff --git a/app/code/Magento/Integration/Service/V1/Integration.php b/app/code/Magento/Integration/Service/V1/Integration.php index 9158e6de05f..015a8b0f1ed 100644 --- a/app/code/Magento/Integration/Service/V1/Integration.php +++ b/app/code/Magento/Integration/Service/V1/Integration.php @@ -127,6 +127,15 @@ class Integration implements \Magento\Integration\Service\V1\IntegrationInterfac return $integration; } + /** + * {@inheritdoc} + */ + public function findActiveIntegrationByConsumerId($consumerId) + { + $integration = $this->_integrationFactory->create()->loadActiveIntegrationByConsumerId($consumerId); + return $integration; + } + /** * Check if an integration exists by the name * diff --git a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php b/app/code/Magento/Integration/Service/V1/IntegrationInterface.php index 473d6926dd4..651089a51e5 100644 --- a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php +++ b/app/code/Magento/Integration/Service/V1/IntegrationInterface.php @@ -64,6 +64,14 @@ interface IntegrationInterface */ public function findByConsumerId($consumerId); + /** + * Get the details of an active Integration by consumer_id. + * + * @param int $consumerId + * @return IntegrationModel + */ + public function findActiveIntegrationByConsumerId($consumerId); + /** * Update an Integration. * diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php index 054de2b4013..0456688ad21 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Service/V1/Oauth.php @@ -24,7 +24,7 @@ namespace Magento\Integration\Service\V1; use Magento\Integration\Model\Oauth\Token\Provider as TokenProvider; -use Magento\Integration\Model\Oauth\Token; +use Magento\Integration\Model\Oauth\Token as OauthTokenModel; use Magento\Integration\Model\Oauth\Token\Factory as TokenFactory; use Magento\Integration\Helper\Oauth\Data as IntegrationOauthHelper; use Magento\Framework\Oauth\Helper\Oauth as OauthHelper; @@ -138,7 +138,7 @@ class Oauth implements OauthInterface { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $existingToken = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); + $existingToken = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); if ($existingToken && $clearExistingToken) { $existingToken->delete(); unset($existingToken); @@ -162,8 +162,8 @@ class Oauth implements OauthInterface { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $token = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); - if ($token->getType() != Token::TYPE_ACCESS) { + $token = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); + if ($token->getType() != OauthTokenModel::TYPE_ACCESS) { return false; } } catch (\Exception $e) { @@ -260,11 +260,11 @@ class Oauth implements OauthInterface /** * {@inheritdoc} */ - public function deleteToken($consumerId) + public function deleteIntegrationToken($consumerId) { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $existingToken = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); + $existingToken = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); $existingToken->delete(); return true; } catch (\Exception $e) { diff --git a/app/code/Magento/Integration/Service/V1/OauthInterface.php b/app/code/Magento/Integration/Service/V1/OauthInterface.php index 7a1859b1bd4..c468a2067ab 100644 --- a/app/code/Magento/Integration/Service/V1/OauthInterface.php +++ b/app/code/Magento/Integration/Service/V1/OauthInterface.php @@ -23,7 +23,7 @@ */ namespace Magento\Integration\Service\V1; -use Magento\Integration\Model\Oauth\Token; +use Magento\Integration\Model\Oauth\Token as OauthTokenModel; /** * Integration oAuth Service Interface @@ -59,7 +59,7 @@ interface OauthInterface * Retrieve access token assigned to the consumer. * * @param int $consumerId - * @return Token|bool Return false if no access token is available. + * @return OauthTokenModel|bool Return false if no access token is available. */ public function getAccessToken($consumerId); @@ -108,5 +108,5 @@ interface OauthInterface * @param int $consumerId * @return bool If token was deleted */ - public function deleteToken($consumerId); + public function deleteIntegrationToken($consumerId); } diff --git a/app/code/Magento/Integration/Service/V1/TokenService.php b/app/code/Magento/Integration/Service/V1/TokenService.php new file mode 100644 index 00000000000..0b860f33655 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/TokenService.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\Integration\Service\V1; + +use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; +use Magento\Framework\Exception\AuthenticationException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\LocalizedException; +use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; +use Magento\User\Model\User as UserModel; + +/** + * Class to handle token generation for Admins and Customers + */ +class TokenService implements TokenServiceInterface +{ + /** + * Token Model + * + * @var TokenModelFactory + */ + private $tokenModelFactory; + + /** + * User Model + * + * @var UserModel + */ + private $userModel; + + /** + * Customer Account Service + * + * @var CustomerAccountService + */ + private $customerAccountService; + + /** + * Initialize service + * + * @param TokenModelFactory $tokenModelFactory + * @param UserModel $userModel + * @param CustomerAccountService $customerAccountService + */ + public function __construct( + TokenModelFactory $tokenModelFactory, + UserModel $userModel, + CustomerAccountService $customerAccountService + ) { + $this->tokenModelFactory = $tokenModelFactory; + $this->userModel = $userModel; + $this->customerAccountService = $customerAccountService; + } + + /** + * {@inheritdoc} + */ + public function createAdminAccessToken($username, $password) + { + $this->validateCredentials($username, $password); + try { + $this->userModel->login($username, $password); + if (!$this->userModel->getId()) { + /* + * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent. + * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it. + * Need to make sure that this is refactored once exception handling is updated in Auth Model. + */ + throw new AuthenticationException('Please correct the user name or password.'); + } + } catch (\Magento\Backend\Model\Auth\Exception $e) { + throw new AuthenticationException($e->getMessage(), [], $e); + } catch (\Magento\Framework\Model\Exception $e) { + throw new LocalizedException($e->getMessage(), [], $e); + } + return $this->tokenModelFactory->create()->createAdminToken($this->userModel->getId())->getToken(); + } + + /** + * {@inheritdoc} + */ + public function createCustomerAccessToken($username, $password) + { + $this->validateCredentials($username, $password); + $customerDataObject = $this->customerAccountService->authenticate($username, $password); + return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); + } + + /** + * Validate user credentials + * + * @param string $username + * @param string $password + * @return void + * @throws \Magento\Framework\Exception\InputException + */ + protected function validateCredentials($username, $password) + { + $exception = new InputException(); + if (!is_string($username) || strlen($username) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']); + } + if (!is_string($username) || strlen($password) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']); + } + if ($exception->wasErrorAdded()) { + throw $exception; + } + } +} diff --git a/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php b/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php new file mode 100644 index 00000000000..0f374a7a638 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php @@ -0,0 +1,58 @@ +<?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\Integration\Service\V1; + +use Magento\Framework\Exception\AuthenticationException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\LocalizedException; + +/** + * Interface providing token generation for Admins and Customers + */ +interface TokenServiceInterface +{ + /** + * Create access token for admin given the admin credentials. + * + * @param string $username + * @param string $password + * @return string Token created + * @throws InputException For invalid input + * @throws AuthenticationException + * @throws LocalizedException + */ + public function createAdminAccessToken($username, $password); + + /** + * Create access token for admin given the customer credentials. + * + * @param string $username + * @param string $password + * @return string Token created + * @throws InputException For invalid input + * @throws AuthenticationException + */ + public function createCustomerAccessToken($username, $password); +} diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index 0125d6d2c46..221c3807348 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -2,17 +2,19 @@ "name": "magento/module-integration", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-authorization": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/etc/di.xml b/app/code/Magento/Integration/etc/di.xml index 1557064be5b..b1460317df4 100644 --- a/app/code/Magento/Integration/etc/di.xml +++ b/app/code/Magento/Integration/etc/di.xml @@ -25,10 +25,12 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Integration\Service\V1\IntegrationInterface" type="Magento\Integration\Service\V1\Integration" /> + <preference for="Magento\Integration\Service\V1\AuthorizationServiceInterface" type="Magento\Integration\Service\V1\AuthorizationService" /> <preference for="Magento\Integration\Service\V1\OauthInterface" type="Magento\Integration\Service\V1\Oauth" /> <preference for="Magento\Framework\Oauth\ConsumerInterface" type="Magento\Integration\Model\Oauth\Consumer"/> <preference for="Magento\Framework\Oauth\NonceGeneratorInterface" type="Magento\Integration\Model\Oauth\Nonce\Generator"/> <preference for="Magento\Framework\Oauth\TokenProviderInterface" type="Magento\Integration\Model\Oauth\Token\Provider"/> + <preference for="Magento\Integration\Service\V1\TokenServiceInterface" type="Magento\Integration\Service\V1\TokenService" /> <type name="Magento\Integration\Model\Oauth\Nonce\Generator"> <arguments> <argument name="date" xsi:type="object">Magento\Framework\Stdlib\DateTime\DateTime\Proxy</argument> diff --git a/app/code/Magento/Integration/etc/module.xml b/app/code/Magento/Integration/etc/module.xml index e16c617dce9..eb76e22b29d 100644 --- a/app/code/Magento/Integration/etc/module.xml +++ b/app/code/Magento/Integration/etc/module.xml @@ -24,17 +24,20 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Integration" schema_version="1.0.0.2" active="true"> + <module name="Magento_Integration" schema_version="1.0.0.3" active="true"> <sequence> <module name="Magento_Core"/> <module name="Magento_Store"/> + <module name="Magento_User"/> </sequence> <depends> + <module name="Magento_Authorization"/> <module name="Magento_Store"/> <module name="Magento_Core"/> <module name="Magento_Backend"/> <module name="Magento_Customer"/> <module name="Magento_Theme"/> + <module name="Magento_User"/> </depends> </module> </config> diff --git a/app/code/Magento/Integration/etc/webapi.xml b/app/code/Magento/Integration/etc/webapi.xml new file mode 100644 index 00000000000..2153888cff3 --- /dev/null +++ b/app/code/Magento/Integration/etc/webapi.xml @@ -0,0 +1,40 @@ +<?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) + */ +--> +<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> + <route url="/V1/integration/admin/token" method="POST"> + <service class="Magento\Integration\Service\V1\TokenServiceInterface" method="createAdminAccessToken"/> + <resources> + <resource ref="anonymous"/> + </resources> + </route> + <route url="/V1/integration/customer/token" method="POST"> + <service class="Magento\Integration\Service\V1\TokenServiceInterface" method="createCustomerAccessToken"/> + <resources> + <resource ref="anonymous"/> + </resources> + </route> +</routes> diff --git a/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php b/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php new file mode 100644 index 00000000000..f77a5d32b3c --- /dev/null +++ b/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php @@ -0,0 +1,68 @@ +<?php +/** + * Upgrade script for integration table. + * + * 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) + */ + +/* @var $installer \Magento\Integration\Model\Resource\Setup */ +$installer = $this; + +/* @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */ +$connection = $installer->getConnection(); + +$oauthTokenTable = $installer->getTable('oauth_token'); +$adminTable = $installer->getTable('admin_user'); +$customerTable = $installer->getTable('customer_entity'); + +$connection->addColumn( + $oauthTokenTable, + 'user_type', + array( + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'comment' => 'User type' + ) +); +$connection->modifyColumn( + $oauthTokenTable, + 'consumer_id', + array( + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'unsigned' => true, + 'nullable' => true, + 'comment' => 'Oauth Consumer ID' + ) +); +$connection->addForeignKey( + $installer->getFkName($oauthTokenTable, 'admin_id', $adminTable, 'user_id'), + $oauthTokenTable, + 'admin_id', + $adminTable, + 'user_id' +); +$connection->addForeignKey( + $installer->getFkName($oauthTokenTable, 'admin_id', $customerTable, 'entity_id'), + $oauthTokenTable, + 'customer_id', + $customerTable, + 'entity_id' +); diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index be9d3df13b4..00ec2ff67d6 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-layered-navigation", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml b/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml index a73bba5fcad..d99697645da 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml +++ b/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml @@ -24,5 +24,5 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/layout_single.xsd" label="All One-Column Layout Pages" design_abstraction="page_layout"> - <move element="catalog.leftnav" destination="category.product.list.additional" before="-" /> + <move element="catalog.leftnav" destination="content.top" after="-" /> </layout> diff --git a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml index 77cb12ee001..431a63e830c 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml +++ b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml @@ -31,8 +31,8 @@ ?> <?php $_filters = $this->getActiveFilters() ?> <?php if(!empty($_filters)): ?> -<div class="filter-current" data-count="<?php echo count($_filters); ?>"> - <strong class="block-subtitle filter-current-subtitle"><?php echo __('Currently Shopping by') ?></strong> +<div class="filter-current"> + <strong class="block-subtitle filter-current-subtitle" data-count="<?php echo count($_filters); ?>"><?php echo __('Currently Shopping by') ?></strong> <ol class="items"> <?php foreach ($_filters as $_filter): ?> <li class="item"> diff --git a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml index 6af9a7ed80e..2fb0ffd37cd 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml +++ b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml @@ -34,7 +34,6 @@ <div class="block filter"> <div class="block-title filter-title"> <strong><?php echo __('Shop By') ?></strong> - <span class="block-triger filter-trigger"><?php echo __('Filter') ?> <span class="qty counter"><?php echo count($this->getLayer()->getState()->getActiveFilters()) ?></span></span> </div> <div class="block-content filter-content"> @@ -45,17 +44,20 @@ <a href="<?php echo $this->getClearUrl() ?>" class="action clear filter-clear"><span><?php echo __('Clear All') ?></span></a> </div> <?php endif; ?> - - <strong class="block-subtitle filter-subtitle"><?php echo __('Shopping Options') ?></strong> - - <dl class="filter-options" id="narrow-by-list"> - <?php foreach ($this->getFilters() as $filter): ?> + <?php $wrapOptions = false; ?> + <?php foreach ($this->getFilters() as $filter): ?> + <?php if(!$wrapOptions): ?> + <strong class="block-subtitle filter-subtitle"><?php echo __('Shopping Options') ?></strong> + <dl class="filter-options" id="narrow-by-list"> + <?php $wrapOptions = true; endif; ?> <?php if ($filter->getItemsCount()): ?> <dt class="filter-options-title"><?php echo $this->escapeHtml(__($filter->getName())) ?></dt> <dd class="filter-options-content"><?php echo $this->getChildBlock('renderer')->render($filter); ?></dd> <?php endif; ?> - <?php endforeach; ?> - </dl> + <?php endforeach; ?> + <?php if($wrapOptions): ?> + </dl> + <?php endif; ?> </div> </div> <?php endif; ?> diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index a61e95929ee..5fb3aacf06e 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-log", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 8062806648e..c5a34e64e59 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -24,6 +24,7 @@ namespace Magento\Multishipping\Model\Checkout\Type; use Magento\Customer\Service\V1\CustomerAddressServiceInterface; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Multishipping checkout model @@ -103,6 +104,11 @@ class Multishipping extends \Magento\Framework\Object */ protected $_customerAddressService; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -116,6 +122,7 @@ class Multishipping extends \Magento\Framework\Object * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param \Magento\Multishipping\Helper\Data $helper + * @param OrderSender $orderSender * @param array $data */ public function __construct( @@ -131,6 +138,7 @@ class Multishipping extends \Magento\Framework\Object \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, + OrderSender $orderSender, array $data = array() ) { $this->_eventManager = $eventManager; @@ -145,6 +153,7 @@ class Multishipping extends \Magento\Framework\Object $this->_customerSession = $customerSession; $this->_orderFactory = $orderFactory; $this->_customerAddressService = $customerAddressService; + $this->orderSender = $orderSender; parent::__construct($data); $this->_init(); } @@ -639,7 +648,7 @@ class Multishipping extends \Magento\Framework\Object $order->place(); $order->save(); if ($order->getCanSendNewEmailFlag()) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $orderIds[$order->getId()] = $order->getIncrementId(); } diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 6dee2022083..023416f651c 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-multishipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/etc/adminhtml/acl.xml b/app/code/Magento/Multishipping/etc/acl.xml similarity index 94% rename from app/code/Magento/Multishipping/etc/adminhtml/acl.xml rename to app/code/Magento/Multishipping/etc/acl.xml index 82bdbc1398e..b6cad29cbc1 100644 --- a/app/code/Magento/Multishipping/etc/adminhtml/acl.xml +++ b/app/code/Magento/Multishipping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 1850aa528a4..4bc48b94f69 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-newsletter", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/etc/adminhtml/acl.xml b/app/code/Magento/Newsletter/etc/acl.xml similarity index 96% rename from app/code/Magento/Newsletter/etc/adminhtml/acl.xml rename to app/code/Magento/Newsletter/etc/acl.xml index c8d22e1fd87..d1eb2f175c3 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/acl.xml +++ b/app/code/Magento/Newsletter/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 93acbbb7a28..ec0bfcae4b8 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -2,13 +2,13 @@ "name": "magento/module-offline-payments", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-payment": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-payment": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 417547b6b4d..e35cbbe2196 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-offline-shipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/Controller/Api.php b/app/code/Magento/Ogone/Controller/Api.php index 0a3493b9728..faff1fdefff 100644 --- a/app/code/Magento/Ogone/Controller/Api.php +++ b/app/code/Magento/Ogone/Controller/Api.php @@ -25,6 +25,7 @@ namespace Magento\Ogone\Controller; use Magento\Sales\Model\Order; use Magento\Sales\Model\Order\Payment\Transaction as PaymentTransaction; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Ogone Api Controller @@ -48,19 +49,27 @@ class Api extends \Magento\Framework\App\Action\Action */ protected $_transactionFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\OrderFactory $salesOrderFactory + * @param OrderSender $orderSender */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\DB\TransactionFactory $transactionFactory, - \Magento\Sales\Model\OrderFactory $salesOrderFactory + \Magento\Sales\Model\OrderFactory $salesOrderFactory, + OrderSender $orderSender ) { parent::__construct($context); $this->_transactionFactory = $transactionFactory; $this->_salesOrderFactory = $salesOrderFactory; + $this->orderSender = $orderSender; } /** @@ -248,7 +257,7 @@ class Api extends \Magento\Framework\App\Action\Action $invoice->getOrder()->setIsInProcess(true); $this->_transactionFactory->create()->addObject($invoice)->addObject($invoice->getOrder())->save(); - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } } else { $order->save(); @@ -282,7 +291,7 @@ class Api extends \Magento\Framework\App\Action\Action } else { //to send new order email only when state is pending payment if ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $order->setState( \Magento\Sales\Model\Order::STATE_PROCESSING, @@ -356,7 +365,7 @@ class Api extends \Magento\Framework\App\Action\Action $order->getPayment()->setLastTransId($params['PAYID']); //to send new order email only when state is pending payment if ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); $order->setState( \Magento\Sales\Model\Order::STATE_PROCESSING, \Magento\Ogone\Model\Api::PROCESSING_OGONE_STATUS, diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index 324926c35f2..c32adb17524 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-ogone", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index c0f7ecc263f..1a1968b4da9 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-page-cache", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php index d04c57253fb..f8908adecfe 100644 --- a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php +++ b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php @@ -25,6 +25,8 @@ namespace Magento\PayPalRecurringPayment\Model; use Exception; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * PayPal Recurring Instant Payment Notification processor model */ @@ -42,11 +44,17 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements \Magento\Paypal\M */ protected $_recurringPaymentFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory * @param \Magento\RecurringPayment\Model\PaymentFactory $recurringPaymentFactory + * @param OrderSender $orderSender * @param array $data */ public function __construct( @@ -54,10 +62,12 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements \Magento\Paypal\M \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\RecurringPayment\Model\PaymentFactory $recurringPaymentFactory, + OrderSender $orderSender, array $data = array() ) { parent::__construct($configFactory, $logAdapterFactory, $curlFactory, $data); $this->_recurringPaymentFactory = $recurringPaymentFactory; + $this->orderSender = $orderSender; } /** @@ -171,7 +181,8 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements \Magento\Paypal\M $invoice = $payment->getCreatedInvoice(); if ($invoice) { $message = __('You notified customer about invoice #%1.', $invoice->getIncrementId()); - $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save(); + $this->orderSender->send($order); + $order->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save(); } } catch (\Magento\Framework\Model\Exception $e) { $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true); diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index 61cff656014..8c2e560ad96 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -2,17 +2,18 @@ "name": "magento/module-pay-pal-recurring-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-paypal": "0.1.0-alpha89", - "magento/module-recurring-payment": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-paypal": "0.1.0-alpha90", + "magento/module-recurring-payment": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/etc/module.xml b/app/code/Magento/PayPalRecurringPayment/etc/module.xml index 1a7957cf93b..c0f24a5bf82 100644 --- a/app/code/Magento/PayPalRecurringPayment/etc/module.xml +++ b/app/code/Magento/PayPalRecurringPayment/etc/module.xml @@ -30,6 +30,7 @@ <module name="Magento_Directory"/> <module name="Magento_Payment"/> <module name="Magento_Paypal"/> + <module name="Magento_Sales"/> <module name="Magento_RecurringPayment"/> </depends> </module> diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 789f80d72d5..fce23ae8959 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/etc/adminhtml/acl.xml b/app/code/Magento/Payment/etc/acl.xml similarity index 94% rename from app/code/Magento/Payment/etc/adminhtml/acl.xml rename to app/code/Magento/Payment/etc/acl.xml index c8ad3fd70b7..30c6482acc4 100644 --- a/app/code/Magento/Payment/etc/adminhtml/acl.xml +++ b/app/code/Magento/Payment/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 83bf8599542..e1c9bb83bbd 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -27,6 +27,7 @@ use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Sales\Model\Quote\Address; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Paypal\Model\Config as PaypalConfig; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Wrapper that performs Paypal Express and Checkout communication @@ -280,6 +281,11 @@ class Checkout */ protected $_messageManager; + /** + * @var OrderSender + */ + protected $orderSender; + /** * Set config, session and quote instances * @@ -307,6 +313,7 @@ class Checkout * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param OrderSender $orderSender * @param array $params * @throws \Exception */ @@ -335,6 +342,7 @@ class Checkout \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Message\ManagerInterface $messageManager, + OrderSender $orderSender, $params = array() ) { $this->_customerData = $customerData; @@ -360,6 +368,7 @@ class Checkout $this->_customerDetailsBuilder = $customerDetailsBuilder; $this->_encryptor = $encryptor; $this->_messageManager = $messageManager; + $this->orderSender = $orderSender; $this->_customerSession = isset($params['session']) && $params['session'] instanceof \Magento\Customer\Model\Session ? $params['session'] : $customerSession; @@ -842,7 +851,7 @@ class Checkout case \Magento\Sales\Model\Order::STATE_PROCESSING: case \Magento\Sales\Model\Order::STATE_COMPLETE: case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW: - $order->sendNewOrderEmail(); + $this->orderSender->send($order); break; default: break; diff --git a/app/code/Magento/Paypal/Model/Ipn.php b/app/code/Magento/Paypal/Model/Ipn.php index e871ca462aa..d0d432d53c6 100644 --- a/app/code/Magento/Paypal/Model/Ipn.php +++ b/app/code/Magento/Paypal/Model/Ipn.php @@ -24,6 +24,8 @@ namespace Magento\Paypal\Model; use Exception; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; /** * PayPal Instant Payment Notification processor model @@ -47,12 +49,24 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface */ protected $_paypalInfo; + /** + * @var OrderSender + */ + protected $orderSender; + + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param Info $paypalInfo + * @param OrderSender $orderSender + * @param CreditmemoSender $creditmemoSender * @param array $data */ public function __construct( @@ -61,11 +75,15 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\Sales\Model\OrderFactory $orderFactory, Info $paypalInfo, + OrderSender $orderSender, + CreditmemoSender $creditmemoSender, array $data = array() ) { parent::__construct($configFactory, $logAdapterFactory, $curlFactory, $data); $this->_orderFactory = $orderFactory; $this->_paypalInfo = $paypalInfo; + $this->orderSender = $orderSender; + $this->creditmemoSender = $creditmemoSender; } /** @@ -312,7 +330,8 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface // notify customer $invoice = $payment->getCreatedInvoice(); if ($invoice && !$this->_order->getEmailSent()) { - $this->_order->sendNewOrderEmail()->addStatusHistoryComment( + $this->orderSender->send($this->_order); + $this->_order->addStatusHistoryComment( __('You notified customer about invoice #%1.', $invoice->getIncrementId()) )->setIsCustomerNotified( true @@ -419,7 +438,7 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface ); } if (!$this->_order->getEmailSent()) { - $this->_order->sendNewOrderEmail(); + $this->orderSender->send($this->_order); } $this->_order->save(); } @@ -490,7 +509,7 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface $creditMemo = $payment->getCreatedCreditmemo(); if ($creditMemo) { - $creditMemo->sendEmail(); + $this->creditmemoSender->send($creditMemo); $this->_order->addStatusHistoryComment( __('You notified customer about creditmemo #%1.', $creditMemo->getIncrementId()) )->setIsCustomerNotified( diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 31b9354b080..370bb739c7b 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -23,6 +23,8 @@ */ namespace Magento\Paypal\Model; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * Payflow Link payment gateway model */ @@ -144,6 +146,11 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro */ protected $_websiteFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData @@ -162,6 +169,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Store\Model\WebsiteFactory $websiteFactory + * @param OrderSender $orderSender * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -184,6 +192,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Store\Model\WebsiteFactory $websiteFactory, + OrderSender $orderSender, array $data = array() ) { $this->_requestFactory = $requestFactory; @@ -191,6 +200,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro $this->_orderFactory = $orderFactory; $this->_requestHttp = $requestHttp; $this->_websiteFactory = $websiteFactory; + $this->orderSender = $orderSender; parent::__construct( $eventManager, $paymentData, @@ -389,7 +399,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro try { if ($canSendNewOrderEmail) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save(); } catch (\Exception $e) { diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index cfc787d36f4..cd97fcde61a 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -2,26 +2,26 @@ "name": "magento/module-paypal", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/etc/adminhtml/acl.xml b/app/code/Magento/Paypal/etc/acl.xml similarity index 96% rename from app/code/Magento/Paypal/etc/adminhtml/acl.xml rename to app/code/Magento/Paypal/etc/acl.xml index d0f32046bc4..3dc6a973cf8 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/acl.xml +++ b/app/code/Magento/Paypal/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Paypal/etc/adminhtml/system.xml b/app/code/Magento/Paypal/etc/adminhtml/system.xml index 6f826847aef..838e2e42de0 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/system.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/system.xml @@ -749,7 +749,7 @@ You get paid up front, even though customers have more time to pay. A pre-integrated payment button lets customers pay quickly with Bill Me Later®. <a href="https:/www.paypal.com/webapps/mpp/promotional-financing" target="_blank">Learn More</a>]]> </comment> - <config_path>payment/paypal_express_bml/active</config_path> + <config_path>payment/payflow_express_bml/active</config_path> <requires> <field id="enable_express_checkout"/> </requires> diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 92987b1525f..9f15f4a5107 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-persistent", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Persistent/etc/adminhtml/acl.xml b/app/code/Magento/Persistent/etc/acl.xml similarity index 94% rename from app/code/Magento/Persistent/etc/adminhtml/acl.xml rename to app/code/Magento/Persistent/etc/acl.xml index 986e38739e4..8783b80c14f 100644 --- a/app/code/Magento/Persistent/etc/adminhtml/acl.xml +++ b/app/code/Magento/Persistent/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 478a634fc04..cae86a3d2c9 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-product-alert", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php index f6e988b9c9a..27bd0e404d5 100644 --- a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php +++ b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php @@ -99,10 +99,12 @@ class RecurringPayment extends \Magento\Framework\App\Action\Action { try { $payment = $this->_initPayment(); - $this->_title->add(__('Recurring Billing Payments')); - $this->_title->add(__('Payment #%1', $payment->getReferenceId())); $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); + + $title = __('Recurring Payment #%1', $payment->getReferenceId()); + $this->_view->getLayout()->getBlock('head')->setTitle($title); + $this->_view->renderLayout(); return; } catch (\Magento\Framework\Model\Exception $e) { diff --git a/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php b/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php new file mode 100644 index 00000000000..4c4e54548c6 --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php @@ -0,0 +1,60 @@ +<?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\RecurringPayment\Model\Plugin; + +/** + * Plugin for product attribute tabs + */ +class Tabs +{ + /** @var \Magento\Framework\Module\Manager */ + protected $_moduleManager; + + /** + * @param \Magento\Framework\Module\Manager $moduleManager + */ + public function __construct(\Magento\Framework\Module\Manager $moduleManager) + { + $this->_moduleManager = $moduleManager; + } + + /** + * @param \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject + * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection $result + * + * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetGroupCollection(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject, $result) + { + if (!$this->_moduleManager->isOutputEnabled('Magento_RecurringPayment')) { + foreach ($result as $key => $group) { + if ($group->getAttributeGroupCode() === 'recurring-payment') { + $result->removeItemByKey($key); + } + } + } + return $result; + } +} diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index 98a7df3d23c..1c8a325da56 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-recurring-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php b/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php index 87c94686774..a6d44ef5166 100644 --- a/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php +++ b/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php @@ -35,7 +35,7 @@ $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'is_recur $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'recurring_payment'); $connection = $this->getConnection(); -$adminRuleTable = $this->getTable('admin_rule'); +$adminRuleTable = $this->getTable('authorization_rule'); $connection->update( $adminRuleTable, array('resource_id' => 'Magento_RecurringPayment::recurring_payment'), diff --git a/app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml b/app/code/Magento/RecurringPayment/etc/acl.xml similarity index 94% rename from app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml rename to app/code/Magento/RecurringPayment/etc/acl.xml index 5a259ef64af..a83953dd5bc 100644 --- a/app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml +++ b/app/code/Magento/RecurringPayment/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/RecurringPayment/etc/di.xml b/app/code/Magento/RecurringPayment/etc/di.xml index b2f1aba9663..447db78390f 100644 --- a/app/code/Magento/RecurringPayment/etc/di.xml +++ b/app/code/Magento/RecurringPayment/etc/di.xml @@ -47,5 +47,7 @@ <type name="Magento\Payment\Model\Checks\ZeroTotal"> <plugin name="recurringpayment" type="Magento\RecurringPayment\Model\Plugin\ZeroTotal" /> </type> - + <type name="Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs"> + <plugin name="recurringpayment_product_tab" type="Magento\RecurringPayment\Model\Plugin\Tabs" /> + </type> </config> diff --git a/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml b/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml index f0472591fd0..5bfe9bb7ba8 100644 --- a/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml +++ b/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml @@ -27,11 +27,11 @@ * @see \Magento\RecurringPayment\Block\Catalog\Product\View\Payment */ ?> -<dl class="payment product schedule"> +<dl class="items payment-schedule"> <?php foreach($this->getScheduleInfo() as $term => $definitions): ?> - <dt class="title"><?php echo $this->escapeHtml($term); ?></dt> + <dt class="item-title"><?php echo $this->escapeHtml($term); ?></dt> <?php foreach ($definitions as $definition):?> - <dd class="content"><?php echo $this->escapeHtml($definition)?></dd> + <dd class="item-content"><?php echo $this->escapeHtml($definition)?></dd> <?php endforeach;?> <?php endforeach;?> </dl> diff --git a/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml b/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml index 34a92266f32..6d2199a981f 100644 --- a/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml +++ b/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml @@ -32,9 +32,6 @@ <?php $gridElements = $this->getGridElements(); ?> <?php if ($gridElements): ?> - <?php if ($this->getChildHtml('pager')): ?> - <div class="toolbar recurring-payments-toolbar top"><?php echo $this->getChildHtml('pager'); ?></div> - <?php endif; ?> <div class="table-wrapper recurring-payments"> <table id="<?php echo $this->getGridHtmlId() ?>" class="data table table-recurring-payments"> <caption class="table caption"><?php echo __('Recurring Payments') ?></caption> diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 394f1be72eb..a1ffb433672 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -2,28 +2,28 @@ "name": "magento/module-reports", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-downloadable": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-downloadable": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/adminhtml/acl.xml b/app/code/Magento/Reports/etc/acl.xml similarity index 97% rename from app/code/Magento/Reports/etc/adminhtml/acl.xml rename to app/code/Magento/Reports/etc/acl.xml index 45984f2766e..6c65b81e5eb 100644 --- a/app/code/Magento/Reports/etc/adminhtml/acl.xml +++ b/app/code/Magento/Reports/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml b/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml index 532168f0ba5..595f87c63e8 100644 --- a/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml @@ -45,7 +45,14 @@ $rating = 'short'; <?php echo $this->escapeHtml($item->getName()) ?></a> </strong> - <?php echo $this->getPriceHtml($item, true, '-' . $type) ?> + <?php echo $this->getProductPriceHtml( + $item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> <?php if ($rating): ?> <?php echo $this->getReviewsSummaryHtml($item, $rating) ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml index cd799593dde..3191111afde 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml @@ -62,7 +62,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { <?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?> </a> </strong> - <?php echo $this->getPriceHtml($_product, true, '-widget-compared-'.$suffix) ?> + <?php echo $this->getProductPriceHtml( + $_product, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-widget-compared-' . $suffix + ] + ) ?> <?php if($_product->isSaleable()): ?> <div class="actions"> <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml index 5bda296b6a9..cec10c808cd 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml @@ -68,7 +68,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { <?php echo $this->escapeHtml($_item->getName()) ?> </a> </strong> - <?php echo $this->getPriceHtml($_item, true, '-' . $type) ?> + <?php echo $this->getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> <?php if ($rating): ?> <?php echo $this->getReviewsSummaryHtml($_item, $rating) ?> <?php endif; ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml index 19c06d1021b..49566e2fb98 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml @@ -68,7 +68,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { <?php echo $this->escapeHtml($_item->getName()) ?> </a> </strong> - <?php echo $this->getPriceHtml($_item, true, '-' . $type) ?> + <?php echo $this->getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> <?php if ($rating): ?> <?php echo $this->getReviewsSummaryHtml($_item, $rating) ?> <?php endif; ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml index ccf3b04bbcf..8f9164b5577 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml @@ -69,20 +69,27 @@ if ($exist = $this->getRecentlyViewedProducts()) { <?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?> </a> </strong> - <?php echo $this->getPriceHtml($_product, true, '-widget-viewed-'.$suffix) ?> + <?php echo $this->getProductPriceHtml( + $_product, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-widget-viewed-' . $suffix + ] + ) ?> <div class="product actions"> <?php if($_product->isSaleable()): ?> <div class="primary"> - <?php if ($_product->getTypeInstance()->hasRequiredOptions($_item)): ?> + <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?> <button class="action tocart" - data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}' + data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_product) ?>"}}' type="button" title="<?php echo __('Add to Cart') ?>"> <span><?php echo __('Add to Cart') ?></span> </button> <?php else: ?> <?php $postDataHelper = $this->helper('Magento\Core\Helper\PostData'); - $postData = $postDataHelper->getPostData($this->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]); + $postData = $postDataHelper->getPostData($this->getAddToCartUrl($_product), ['product' => $_product->getEntityId()]); ?> <button type="button" class="action tocart" data-post='<?php echo $postData; ?>'> <span><?php echo __('Add to Cart') ?></span> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_grid.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_grid.phtml index 3ad49828937..9eb0c4aba76 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_grid.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_grid.phtml @@ -70,7 +70,14 @@ if ($exist = $this->getRecentlyViewedProducts()) { <?php echo $this->escapeHtml($_item->getName()) ?> </a> </strong> - <?php echo $this->getPriceHtml($_item, true, '-' . $type) ?> + <?php echo $this->getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> <?php if ($rating): ?> <?php echo $this->getReviewsSummaryHtml($_item, $rating) ?> <?php endif; ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_list.phtml index eeef1f0bbae..764f026b577 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/content/viewed_list.phtml @@ -71,7 +71,14 @@ if ($exist = $this->getRecentlyViewedProducts()) { <?php echo $this->escapeHtml($_item->getName()) ?> </a> </strong> - <?php echo $this->getPriceHtml($_item, true, '-' . $type) ?> + <?php echo $this->getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> <?php if ($rating): ?> <?php echo $this->getReviewsSummaryHtml($_item, $rating) ?> <?php endif; ?> diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index dd412e1c2b5..6ff6189d3f8 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -2,13 +2,13 @@ "name": "magento/module-require-js", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index e5f26494584..17d0c66fe78 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-review", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-newsletter": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-newsletter": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/etc/adminhtml/acl.xml b/app/code/Magento/Review/etc/acl.xml similarity index 94% rename from app/code/Magento/Review/etc/adminhtml/acl.xml rename to app/code/Magento/Review/etc/acl.xml index baab497a5ff..7fc601f5f3a 100644 --- a/app/code/Magento/Review/etc/adminhtml/acl.xml +++ b/app/code/Magento/Review/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml index e7ec66e2754..85c286aa745 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml @@ -23,11 +23,6 @@ */ ?> <?php if( $this->getCollection() && $this->count()): ?> - <?php if ($this->getToolbarHtml()): ?> - <div class="toolbar products-reviews-toolbar top"> - <?php echo $this->getToolbarHtml() ?> - </div> - <?php endif; ?> <div class="table-wrapper reviews"> <table class="data table table-reviews" id="my-reviews-table"> <caption class="table caption"><?php echo __('Product Reviews') ?></caption> diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index a4696099c4e..dcef739b2ff 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -2,23 +2,23 @@ "name": "magento/module-rss", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/etc/adminhtml/acl.xml b/app/code/Magento/Rss/etc/acl.xml similarity index 94% rename from app/code/Magento/Rss/etc/adminhtml/acl.xml rename to app/code/Magento/Rss/etc/acl.xml index b3a7b17e76a..2b86dd15ddb 100644 --- a/app/code/Magento/Rss/etc/adminhtml/acl.xml +++ b/app/code/Magento/Rss/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 665db8299ce..c673316805a 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-rule", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ 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 f33ac4e591a..9de7ad34c38 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php @@ -24,6 +24,8 @@ */ namespace Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; + class Email extends \Magento\Backend\App\Action { /** @@ -45,7 +47,11 @@ class Email extends \Magento\Backend\App\Action if ($creditmemoId) { $creditmemo = $this->_objectManager->create('Magento\Sales\Model\Order\Creditmemo')->load($creditmemoId); if ($creditmemo) { - $creditmemo->sendEmail(); + /** @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( 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 dd60dec7ec3..207cbeefdb1 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php @@ -24,6 +24,8 @@ */ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; +use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; + abstract class Email extends \Magento\Backend\App\Action { /** @@ -41,25 +43,33 @@ abstract class Email extends \Magento\Backend\App\Action */ public function execute() { - if ($invoiceId = $this->getRequest()->getParam('invoice_id')) { - if ($invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId)) { - $invoice->sendEmail(); - $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', - array('order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId) - ); - } + $invoiceId = $this->getRequest()->getParam('invoice_id'); + if (!$invoiceId) { + return; + } + $invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId); + if (!$invoice) { + return; + } + + /** @var InvoiceSender $invoiceSender */ + $invoiceSender = $this->_objectManager->create('Magento\Sales\Model\Order\Email\Sender\InvoiceSender'); + $invoiceSender->send($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', + array('order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId) + ); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php index 161e89acf41..ae8584d6809 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use \Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender; class AddComment extends \Magento\Sales\Controller\Adminhtml\Order { @@ -55,7 +56,11 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Order $comment = trim(strip_tags($data['comment'])); $order->save(); - $order->sendOrderUpdateEmail($notify, $comment); + /** @var OrderCommentSender $orderCommentSender */ + $orderCommentSender = $this->_objectManager + ->create('Magento\Sales\Model\Order\Email\Sender\OrderCommentSender'); + + $orderCommentSender->send($order, $notify, $comment); $this->_view->loadLayout('empty'); $this->_view->renderLayout(); 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 eba5f4c1422..02c9c6ea161 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; use Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; class AddComment extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ class AddComment extends \Magento\Backend\App\Action */ protected $creditmemoLoader; + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + * @param CreditmemoSender $creditmemoSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, + CreditmemoSender $creditmemoSender ) { $this->creditmemoLoader = $creditmemoLoader; + $this->creditmemoSender = $creditmemoSender; parent::__construct($context); } @@ -74,7 +83,8 @@ class AddComment extends \Magento\Backend\App\Action isset($data['is_visible_on_front']) ); $comment->save(); - $creditmemo->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->creditmemoSender->send($creditmemo, !empty($data['is_customer_notified']), $data['comment']); $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('creditmemo_comments')->toHtml(); 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 bc9d8d695b5..11021c94b9f 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php @@ -26,6 +26,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; use \Magento\Sales\Model\Order; use \Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; class Save extends \Magento\Backend\App\Action { @@ -34,15 +35,23 @@ class Save extends \Magento\Backend\App\Action */ protected $creditmemoLoader; + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + * @param CreditmemoSender $creditmemoSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, + CreditmemoSender $creditmemoSender ) { $this->creditmemoLoader = $creditmemoLoader; + $this->creditmemoSender = $creditmemoSender; parent::__construct($context); } @@ -115,7 +124,8 @@ class Save extends \Magento\Backend\App\Action $transactionSave->addObject($creditmemo->getInvoice()); } $transactionSave->save(); - $creditmemo->sendEmail(!empty($data['send_email']), $comment); + $this->creditmemoSender->send($creditmemo, !empty($data['send_email']), $comment); + $this->messageManager->addSuccess(__('You created the credit memo.')); $this->_getSession()->getCommentText(true); $this->_redirect('sales/order/view', array('order_id' => $creditmemo->getOrderId())); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php index d4c23da395d..b5492f4f114 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php @@ -38,7 +38,12 @@ class Email extends \Magento\Sales\Controller\Adminhtml\Order $order = $this->_initOrder(); if ($order) { try { - $order->sendNewOrderEmail(); + /** @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( 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 af6483eebe3..1f715e8a264 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php @@ -26,6 +26,8 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; use Magento\Backend\App\Action; use \Magento\Framework\Model\Exception; +use \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender; +use \Magento\Sales\Model\Order\Invoice; class AddComment extends \Magento\Backend\App\Action { @@ -34,15 +36,23 @@ class AddComment extends \Magento\Backend\App\Action */ protected $invoiceLoader; + /** + * @var InvoiceCommentSender + */ + protected $invoiceCommentSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + * @param InvoiceCommentSender $invoiceCommentSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader, + InvoiceCommentSender $invoiceCommentSender ) { $this->invoiceLoader = $invoiceLoader; + $this->invoiceCommentSender = $invoiceCommentSender; parent::__construct($context); } @@ -68,13 +78,15 @@ class AddComment extends \Magento\Backend\App\Action throw new Exception(__('The Comment Text field cannot be empty.')); } $this->_title->add(__('Invoices')); + /** @var Invoice $invoice */ $invoice = $this->invoiceLoader->load($this->_request); $invoice->addComment( $data['comment'], isset($data['is_customer_notified']), isset($data['is_visible_on_front']) ); - $invoice->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->invoiceCommentSender->send($invoice, !empty($data['is_customer_notified']), $data['comment']); $invoice->save(); $this->_view->loadLayout(); 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 9b08f15f3e8..ac057bc6bea 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php @@ -26,6 +26,9 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; use \Magento\Framework\Model\Exception; use Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; +use \Magento\Sales\Model\Order\Invoice; class Save extends \Magento\Backend\App\Action { @@ -34,15 +37,31 @@ class Save extends \Magento\Backend\App\Action */ protected $invoiceLoader; + /** + * @var InvoiceCommentSender + */ + protected $invoiceCommentSender; + + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + * @param InvoiceCommentSender $invoiceCommentSender + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader, + InvoiceCommentSender $invoiceCommentSender, + ShipmentSender $shipmentSender ) { $this->invoiceLoader = $invoiceLoader; + $this->invoiceCommentSender = $invoiceCommentSender; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -104,6 +123,7 @@ class Save extends \Magento\Backend\App\Action } try { + /** @var Invoice $invoice */ $invoice = $this->invoiceLoader->load($this->_request); if ($invoice) { @@ -164,14 +184,14 @@ class Save extends \Magento\Backend\App\Action $comment = $data['comment_text']; } try { - $invoice->sendEmail(!empty($data['send_email']), $comment); + $this->invoiceCommentSender->send($invoice, !empty($data['send_email']), $comment); } catch (\Exception $e) { $this->_objectManager->get('Magento\Framework\Logger')->logException($e); $this->messageManager->addError(__('We can\'t send the invoice email.')); } if ($shipment) { try { - $shipment->sendEmail(!empty($data['send_email'])); + $this->shipmentSender->send($shipment, !empty($data['send_email'])); } catch (\Exception $e) { $this->_objectManager->get('Magento\Framework\Logger')->logException($e); $this->messageManager->addError(__('We can\'t send the shipment.')); diff --git a/app/code/Magento/Sales/Helper/Data.php b/app/code/Magento/Sales/Helper/Data.php index 73c439cfafe..6a9ebc8661e 100644 --- a/app/code/Magento/Sales/Helper/Data.php +++ b/app/code/Magento/Sales/Helper/Data.php @@ -62,7 +62,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendNewOrderConfirmationEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\OrderIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -88,7 +88,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendOrderCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -103,7 +103,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendNewShipmentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -118,7 +118,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendShipmentCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -133,7 +133,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendNewInvoiceEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -148,7 +148,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendInvoiceCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -163,7 +163,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendNewCreditmemoEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -178,7 +178,7 @@ class Data extends \Magento\Core\Helper\Data public function canSendCreditmemoCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 85b00104523..f28db0b90f9 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -32,6 +32,7 @@ use Magento\Customer\Service\V1\CustomerGroupServiceInterface; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Customer\Model\Metadata\Form as CustomerForm; use Magento\Customer\Service\V1\Data\Address as CustomerAddressDataObject; +use Magento\Sales\Model\Quote\Item; /** * Order create model @@ -202,6 +203,11 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode */ protected $quoteItemUpdater; + /** + * @var \Magento\Framework\Object\Factory + */ + protected $objectFactory; + /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -222,7 +228,8 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param EmailSender $emailSender * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService - * @param \Magento\Sales\Model\Quote\Item\Updater $quoteItemUpdater + * @param Item\Updater $quoteItemUpdater + * @param \Magento\Framework\Object\Factory $objectFactory * @param array $data */ public function __construct( @@ -246,6 +253,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode \Magento\Sales\Model\AdminOrder\EmailSender $emailSender, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\Sales\Model\Quote\Item\Updater $quoteItemUpdater, + \Magento\Framework\Object\Factory $objectFactory, array $data = array() ) { $this->_objectManager = $objectManager; @@ -268,6 +276,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $this->emailSender = $emailSender; $this->stockItemService = $stockItemService; $this->quoteItemUpdater = $quoteItemUpdater; + $this->objectFactory = $objectFactory; parent::__construct($data); } @@ -998,7 +1007,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode try { foreach ($items as $itemId => $info) { if (!empty($info['configured'])) { - $item = $this->getQuote()->updateItem($itemId, $this->_objectManager->create($info)); + $item = $this->getQuote()->updateItem($itemId, $this->objectFactory->create($info)); $info['qty'] = (double)$item->getQty(); } else { $item = $this->getQuote()->getItemById($itemId); @@ -1007,7 +1016,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode } $info['qty'] = (double)$info['qty']; } - $item = $this->quoteItemUpdater->update($item, $info); + $this->quoteItemUpdater->update($item, $info); if ($item && !empty($info['action'])) { $this->moveQuoteItem($item, $info['action'], $item->getQty()); } diff --git a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php index 77c549d6f6c..2bfc9e5c855 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php +++ b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php @@ -26,6 +26,7 @@ namespace Magento\Sales\Model\AdminOrder; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Logger; use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Class EmailSender @@ -33,23 +34,30 @@ use Magento\Sales\Model\Order; class EmailSender { /** - * @var \Magento\Framework\Message\ManagerInterface + * @var ManagerInterface */ protected $messageManager; /** - * @var \Magento\Framework\Logger + * @var Logger */ protected $logger; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param ManagerInterface $messageManager * @param Logger $logger + * @param OrderSender $orderSender */ - public function __construct(ManagerInterface $messageManager, Logger $logger) + public function __construct(ManagerInterface $messageManager, Logger $logger, OrderSender $orderSender) { $this->messageManager = $messageManager; $this->logger = $logger; + $this->orderSender = $orderSender; } /** @@ -62,7 +70,7 @@ class EmailSender public function send(Order $order) { try { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } catch (\Magento\Framework\Mail\Exception $exception) { $this->logger->logException($exception); $this->messageManager->addWarning( diff --git a/app/code/Magento/Sales/Model/Notifier.php b/app/code/Magento/Sales/Model/Notifier.php new file mode 100644 index 00000000000..bbe3ebfa38a --- /dev/null +++ b/app/code/Magento/Sales/Model/Notifier.php @@ -0,0 +1,96 @@ +<?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; +use Magento\Framework\Mail\Exception; + +/** + * Class Notifier + * @package Magento\Sales\Model + */ +class Notifier extends \Magento\Framework\Model\AbstractModel +{ + /** + * @var CollectionFactory + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var OrderSender + */ + protected $orderSender; + + /** + * @param CollectionFactory $historyCollectionFactory + * @param Logger $logger + * @param OrderSender $orderSender + */ + public function __construct( + CollectionFactory $historyCollectionFactory, + Logger $logger, + OrderSender $orderSender + ) { + $this->historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->orderSender = $orderSender; + } + + /** + * Notify user + * + * @param Order $order + * @return bool + * @throws \Magento\Framework\Mail\Exception + */ + public function notify(\Magento\Sales\Model\Order $order) + { + try { + $this->orderSender->send($order); + if (!$order->getEmailSent()) { + return false; + } + $historyItem = $this->historyCollectionFactory->create()->getUnnotifiedForInstance( + $order, + \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME + ); + if ($historyItem) { + $historyItem->setIsCustomerNotified(1); + $historyItem->save(); + } + } catch (Exception $e) { + $this->logger->logException($e); + return false; + } + return true; + } +} diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index aa7f6b06236..8a626144a1e 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -315,33 +315,6 @@ class Order extends \Magento\Sales\Model\AbstractModel { const ENTITY = 'order'; - /** - * XML configuration paths - */ - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/order/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/order/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/order/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/order/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/order/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/order/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/order_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/order_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/order_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/order_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/order_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/order_comment/enabled'; - /** * Order states */ @@ -487,27 +460,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_historyEntityName = self::HISTORY_ENTITY_NAME; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Store\Model\StoreManagerInterface */ @@ -523,11 +475,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_productFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @var \Magento\Sales\Model\Resource\Order\Item\CollectionFactory */ @@ -608,13 +555,9 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param Order\Config $orderConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param Resource\Order\Item\CollectionFactory $orderItemCollectionFactory * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Tax\Model\Calculation $taxCalculation @@ -639,13 +582,9 @@ class Order extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Sales\Model\Resource\Order\Item\CollectionFactory $orderItemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Tax\Model\Calculation $taxCalculation, @@ -665,13 +604,10 @@ class Order extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_storeManager = $storeManager; $this->_orderConfig = $orderConfig; $this->_productFactory = $productFactory; - $this->_transportBuilder = $transportBuilder; + $this->_orderItemCollectionFactory = $orderItemCollectionFactory; $this->_productVisibility = $productVisibility; $this->_taxCalculation = $taxCalculation; @@ -1506,232 +1442,6 @@ class Order extends \Magento\Sales\Model\AbstractModel } } - /** - * Send email with order data - * - * @return $this - */ - public function sendNewOrderEmail() - { - $storeId = $this->getStore()->getId(); - - if (!$this->_salesData->canSendNewOrderEmail($storeId)) { - return $this; - } - - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($this->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($this->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getCustomerName(); - } - - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'billing' => $this->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $this->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - - // Email copies are sent as separated emails if their copy method is 'copy' - if ($copyTo && $copyMethod == 'copy') { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'billing' => $this->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with order update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendOrderUpdateEmail($notifyCustomer = true, $comment = '') - { - $storeId = $this->getStore()->getId(); - - if (!$this->_salesData->canSendOrderCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($this->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'comment' => $comment, - 'billing' => $this->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $this->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is - // 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'comment' => $comment, - 'billing' => $this->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|false - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - /*********************** ADDRESSES ***************************/ /** @@ -2628,13 +2338,4 @@ class Order extends \Magento\Sales\Model\AbstractModel { return $this->getState() === self::STATE_CANCELED; } - - /** - * Protect order delete from not admin scope - * @return $this - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } } diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php new file mode 100644 index 00000000000..13b8b8a5d11 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -0,0 +1,70 @@ +<?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\Address; + +use Magento\Sales\Model\Order\Address; + +/** + * Class Validator + */ +class Validator +{ + /** + * @var array + */ + protected $required = [ + 'parent_id' =>'Parent Order Id', + 'postcode' => 'Zip code', + 'lastname' => 'Last name', + 'street' => 'Street', + 'city' => 'City', + 'email' => 'Email', + 'telephone' => 'Telephone', + 'country_id' => 'Country', + 'firstname' => 'First Name', + 'address_type' => 'Address Type' + ]; + + /** + * + * @param \Magento\Sales\Model\Order\Address $address + * @return array + */ + public function validate(Address $address) + { + $warnings = []; + foreach ($this->required as $code => $label) { + if (!$address->hasData($code)) { + $warnings[] = sprintf('%s is a required field', $label); + } + } + if (!filter_var($address->getEmail(), FILTER_VALIDATE_EMAIL)) { + $warnings[] = 'Email has a wrong format'; + } + if (!filter_var(in_array($address->getAddressType(), [Address::TYPE_BILLING, Address::TYPE_SHIPPING]))) { + $warnings[] = 'Address type doesn\'t match required options'; + } + return $warnings; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index efb987cf10c..98a0c17d3be 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -128,30 +128,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel const STATE_CANCELED = 3; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/creditmemo/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/creditmemo_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/creditmemo_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/creditmemo_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/creditmemo_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/creditmemo_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_REFUND_CREATED = 'refund_created'; @@ -198,27 +174,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel */ protected $_eventObject = 'creditmemo'; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\Order\Creditmemo\Config */ @@ -254,19 +209,11 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Creditmemo\Config $creditmemoConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory @@ -274,7 +221,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -284,9 +230,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Order\Creditmemo\Config $creditmemoConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory, @@ -294,14 +237,10 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_creditmemoConfig = $creditmemoConfig; $this->_orderFactory = $orderFactory; $this->_cmItemCollectionFactory = $cmItemCollectionFactory; @@ -309,7 +248,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel $this->_storeManager = $storeManager; $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -864,253 +802,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel return $this->_comments; } - /** - * Send email with creditmemo data - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewCreditmemoEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with creditmemo update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendCreditmemoCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'creditmemo' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'creditmemo' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - - /** - * @return \Magento\Framework\Model\AbstractModel - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } /** * After save object manipulations diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php new file mode 100644 index 00000000000..af38cf08fa7 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php @@ -0,0 +1,152 @@ +<?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\Email\Container; + +use Magento\Store\Model\StoreManagerInterface; +use Magento\Store\Model\Store; +use Magento\Framework\App\Config\ScopeConfigInterface; + +abstract class Container implements IdentityInterface +{ + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * Core store config + * + * @var ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * @var Store + */ + protected $store; + + /** + * @var string + */ + protected $customerName; + + /** + * @var string + */ + protected $customerEmail; + + /** + * @param ScopeConfigInterface $scopeConfig + * @param StoreManagerInterface $storeManager + */ + public function __construct( + ScopeConfigInterface $scopeConfig, + StoreManagerInterface $storeManager + ) { + $this->scopeConfig = $scopeConfig; + $this->storeManager = $storeManager; + } + /** + * Return store configuration value + * + * @param string $path + * @param int $storeId + * @return mixed + */ + protected function getConfigValue($path, $storeId) + { + return $this->scopeConfig->getValue( + $path, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Set current store + * + * @param Store $store + * @return void + */ + public function setStore(Store $store) + { + $this->store = $store; + } + + /** + * Return store + * + * @return Store + */ + public function getStore() + { + //current store + if ($this->store instanceof Store) { + return $this->store; + } + return $this->storeManager->getStore(); + } + + /** + * Set customer name + * + * @param string $name + * @return void + */ + public function setCustomerName($name) + { + $this->customerName = $name; + } + + /** + * Set customer email + * + * @param string $email + * @return void + */ + public function setCustomerEmail($email) + { + $this->customerEmail = $email; + } + + /** + * Return customer name + * + * @return string + */ + public function getCustomerName() + { + return $this->customerName; + } + + /** + * Return customer email + * + * @return string + */ + public function getCustomerEmail() + { + return $this->customerEmail; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php new file mode 100644 index 00000000000..742acef50bb --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.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\Model\Order\Email\Container; + +class CreditmemoCommentIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo_comment/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo_comment/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo_comment/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo_comment/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/creditmemo_comment/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo_comment/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php new file mode 100644 index 00000000000..b4f72a56626 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.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\Model\Order\Email\Container; + +class CreditmemoIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/creditmemo/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php b/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php new file mode 100644 index 00000000000..953fc2e4826 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.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\Model\Order\Email\Container; + +use \Magento\Store\Model\Store; + +interface IdentityInterface +{ + /** + * @return bool + */ + public function isEnabled(); + + /** + * @return array|bool + */ + public function getEmailCopyTo(); + + /** + * @return mixed + */ + public function getCopyMethod(); + + /** + * @return mixed + */ + public function getGuestTemplateId(); + + /** + * @return mixed + */ + public function getTemplateId(); + + /** + * @return mixed + */ + public function getEmailIdentity(); + + /** + * @return string + */ + public function getCustomerEmail(); + + /** + * @return string + */ + public function getCustomerName(); + + /** + * @return Store + */ + public function getStore(); + + /** + * @param Store $store + * @return mixed + */ + public function setStore(Store $store); + + /** + * @param string $email + * @return mixed + */ + public function setCustomerEmail($email); + + /** + * @param string $name + * @return mixed + */ + public function setCustomerName($name); +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php new file mode 100644 index 00000000000..e78d8980b24 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.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) + */ +namespace Magento\Sales\Model\Order\Email\Container; + +class InvoiceCommentIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice_comment/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice_comment/copy_to'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice_comment/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/invoice_comment/template'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/invoice_comment/identity'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice_comment/enabled'; + + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php new file mode 100644 index 00000000000..74cdbaf12f2 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.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\Model\Order\Email\Container; + +class InvoiceIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/invoice/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/invoice/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php new file mode 100644 index 00000000000..d9efb6d9d8f --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.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) + */ +namespace Magento\Sales\Model\Order\Email\Container; + +class OrderCommentIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/order_comment/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/order_comment/copy_to'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/order_comment/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/order_comment/template'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/order_comment/identity'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/order_comment/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php new file mode 100644 index 00000000000..88f447047f3 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php @@ -0,0 +1,103 @@ +<?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\Email\Container; + +class OrderIdentity extends Container implements IdentityInterface +{ + /** + * Configuration paths + */ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/order/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/order/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/order/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/order/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/order/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/order/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * Return email copy_to list + * + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * Return copy method + * + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * Return guest template id + * + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return template id + * + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return email identity + * + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php new file mode 100644 index 00000000000..8cbec3f6c78 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.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\Model\Order\Email\Container; + +class ShipmentCommentIdentity extends Container implements IdentityInterface +{ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/shipment_comment/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/shipment_comment/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/shipment_comment/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment_comment/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/shipment_comment/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/shipment_comment/enabled'; + + /** + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php new file mode 100644 index 00000000000..768109203d8 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php @@ -0,0 +1,106 @@ +<?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\Email\Container; + +class ShipmentIdentity extends Container implements IdentityInterface +{ + /** + * Configuration paths + */ + const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/shipment/copy_method'; + const XML_PATH_EMAIL_COPY_TO = 'sales_email/shipment/copy_to'; + const XML_PATH_EMAIL_IDENTITY = 'sales_email/shipment/identity'; + const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment/guest_template'; + const XML_PATH_EMAIL_TEMPLATE = 'sales_email/shipment/template'; + const XML_PATH_EMAIL_ENABLED = 'sales_email/shipment/enabled'; + + /** + * Is email enabled + * + * @return bool + */ + public function isEnabled() + { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * Return list of copy_to emails + * + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * Return email copy method + * + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * Return guest template id + * + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return template id + * + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return email identity + * + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Template.php b/app/code/Magento/Sales/Model/Order/Email/Container/Template.php new file mode 100644 index 00000000000..87ed8416bd0 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Template.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\Model\Order\Email\Container; + +class Template +{ + /** + * @var array + */ + protected $vars; + + /** + * @var array + */ + protected $options; + + /** + * @var string + */ + protected $templateId; + + /** + * @var int + */ + protected $id; + + /** + * Set email template variables + * + * @param array $vars + * @return void + */ + public function setTemplateVars(array $vars) + { + $this->vars = $vars; + } + + /** + * Set email template options + * + * @param array $options + * @return void + */ + public function setTemplateOptions(array $options) + { + $this->options = $options; + } + + /** + * Get email template variables + * + * @return array + */ + public function getTemplateVars() + { + return $this->vars; + } + + /** + * Get email template options + * + * @return array + */ + public function getTemplateOptions() + { + return $this->options; + } + + /** + * Set email template id + * + * @param int $id + * @return void + */ + public function setTemplateId($id) + { + $this->id = $id; + } + + /** + * Get email template id + * + * @return int + */ + public function getTemplateId() + { + return $this->id; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/NotifySender.php b/app/code/Magento/Sales/Model/Order/Email/NotifySender.php new file mode 100644 index 00000000000..ecb7ceaf502 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/NotifySender.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\Model\Order\Email; + +use Magento\Sales\Model\Order; + +abstract class NotifySender extends Sender +{ + /** + * Send email to customer + * + * @param Order $order + * @param bool $notify + * @return bool + */ + protected function checkAndSend(Order $order, $notify = true) + { + $this->identityContainer->setStore($order->getStore()); + if (!$this->identityContainer->isEnabled()) { + return false; + } + $this->prepareTemplate($order); + + /** @var SenderBuilder $sender */ + $sender = $this->getSender(); + + if ($notify) { + $sender->send(); + } else { + // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified + $sender->sendCopyTo(); + } + + return true; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender.php b/app/code/Magento/Sales/Model/Order/Email/Sender.php new file mode 100644 index 00000000000..4e9dcf98689 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender.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\Model\Order\Email; + +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\IdentityInterface; + +abstract class Sender +{ + /** + * @var \Magento\Sales\Model\Order\Email\SenderBuilderFactory + */ + protected $senderBuilderFactory; + + /** + * @var Template + */ + protected $templateContainer; + + /** + * @var IdentityInterface + */ + protected $identityContainer; + + /** + * @param Template $templateContainer + * @param IdentityInterface $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + */ + public function __construct( + Template $templateContainer, + IdentityInterface $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory + ) { + $this->templateContainer = $templateContainer; + $this->identityContainer = $identityContainer; + $this->senderBuilderFactory = $senderBuilderFactory; + } + + /** + * @param Order $order + * @return bool + */ + protected function checkAndSend(Order $order) + { + $this->identityContainer->setStore($order->getStore()); + if (!$this->identityContainer->isEnabled()) { + return false; + } + $this->prepareTemplate($order); + + /** @var SenderBuilder $sender */ + $sender = $this->getSender(); + + $sender->send(); + $sender->sendCopyTo(); + + return true; + } + + /** + * @param Order $order + * @return void + */ + protected function prepareTemplate(Order $order) + { + $this->templateContainer->setTemplateOptions($this->getTemplateOptions()); + + if ($order->getCustomerIsGuest()) { + $templateId = $this->identityContainer->getGuestTemplateId(); + $customerName = $order->getBillingAddress()->getName(); + } else { + $templateId = $this->identityContainer->getTemplateId(); + $customerName = $order->getCustomerName(); + } + + $this->identityContainer->setCustomerName($customerName); + $this->identityContainer->setCustomerEmail($order->getCustomerEmail()); + $this->templateContainer->setTemplateId($templateId); + } + + /** + * @return Sender + */ + protected function getSender() + { + return $this->senderBuilderFactory->create( + [ + 'templateContainer' => $this->templateContainer, + 'identityContainer' => $this->identityContainer + ] + ); + } + + /** + * @return array + */ + protected function getTemplateOptions() + { + return [ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => $this->identityContainer->getStore()->getStoreId() + ]; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php new file mode 100644 index 00000000000..87134a908bc --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php @@ -0,0 +1,70 @@ +<?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\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order\Creditmemo; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity; + +class CreditmemoCommentSender extends NotifySender +{ + /** + * @param Template $templateContainer + * @param CreditmemoCommentIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + */ + public function __construct( + Template $templateContainer, + CreditmemoCommentIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + } + + /** + * Send email to customer + * + * @param Creditmemo $creditmemo + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Creditmemo $creditmemo, $notify = true, $comment = '') + { + $order = $creditmemo->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'creditmemo' => $creditmemo, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php new file mode 100644 index 00000000000..c06aa8b344b --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php @@ -0,0 +1,108 @@ +<?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\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order\Creditmemo; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Resource\Order\Creditmemo as CreditmemoResource; +use Magento\Payment\Helper\Data as PaymentHelper; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity; + +class CreditmemoSender extends NotifySender +{ + /** + * @var PaymentHelper + */ + protected $paymentHelper; + + /** + * @var CreditmemoResource + */ + protected $creditmemoResource; + + /** + * @param Template $templateContainer + * @param CreditmemoIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + * @param PaymentHelper $paymentHelper + * @param CreditmemoResource $creditmemoResource + */ + public function __construct( + Template $templateContainer, + CreditmemoIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory, + PaymentHelper $paymentHelper, + CreditmemoResource $creditmemoResource + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + $this->paymentHelper = $paymentHelper; + $this->creditmemoResource = $creditmemoResource; + } + + /** + * Send email to customer + * + * @param Creditmemo $creditmemo + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Creditmemo $creditmemo, $notify = true, $comment = '') + { + $order = $creditmemo->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $creditmemo->getOrder(), + 'invoice' => $creditmemo, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + + $result = $this->checkAndSend($order, $notify); + if ($result) { + $creditmemo->setEmailSent(true); + $this->creditmemoResource->saveAttribute($creditmemo, 'email_sent'); + } + return $result; + } + + /** + * Return payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php new file mode 100644 index 00000000000..68b8db22077 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.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\Model\Order\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Invoice; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity; + +class InvoiceCommentSender extends NotifySender +{ + /** + * @param Template $templateContainer + * @param InvoiceCommentIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + */ + public function __construct( + Template $templateContainer, + InvoiceCommentIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + } + + /** + * Send email to customer + * + * @param Invoice $invoice + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Invoice $invoice, $notify = true, $comment = '') + { + $order = $invoice->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'invoice' => $invoice, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php new file mode 100644 index 00000000000..f1591bd0a01 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php @@ -0,0 +1,107 @@ +<?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\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Invoice; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\InvoiceIdentity; +use Magento\Payment\Helper\Data as PaymentHelper; +use Magento\Sales\Model\Resource\Order\Invoice as InvoiceResource; + +class InvoiceSender extends NotifySender +{ + /** + * @var PaymentHelper + */ + protected $paymentHelper; + + /** + * @var InvoiceResource + */ + protected $invoiceResource; + + /** + * @param Template $templateContainer + * @param InvoiceIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + * @param PaymentHelper $paymentHelper + * @param InvoiceResource $invoiceResource + */ + public function __construct( + Template $templateContainer, + InvoiceIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory, + PaymentHelper $paymentHelper, + InvoiceResource $invoiceResource + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + $this->paymentHelper = $paymentHelper; + $this->invoiceResource = $invoiceResource; + } + + /** + * Send email to customer + * + * @param Invoice $invoice + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Invoice $invoice, $notify = true, $comment = '') + { + $order = $invoice->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'invoice' => $invoice, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + $result = $this->checkAndSend($order, $notify); + if ($result) { + $invoice->setEmailSent(true); + $this->invoiceResource->saveAttribute($invoice, 'email_sent'); + } + return $result; + } + + /** + * Return payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php new file mode 100644 index 00000000000..65210856597 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.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\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity; + +class OrderCommentSender extends NotifySender +{ + /** + * @param Template $templateContainer + * @param OrderCommentIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + */ + public function __construct( + Template $templateContainer, + OrderCommentIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + } + + /** + * Send email to customer + * + * @param Order $order + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Order $order, $notify = true, $comment = '') + { + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php new file mode 100644 index 00000000000..1e413a3a1dd --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.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\Model\Order\Email\Sender; + +use Magento\Sales\Model\Order\Email\Sender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Resource\Order as OrderResource; +use Magento\Payment\Helper\Data as PaymentHelper; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\OrderIdentity; + +class OrderSender extends Sender +{ + /** + * @var PaymentHelper + */ + protected $paymentHelper; + + /** + * @var OrderResource + */ + protected $orderResource; + + /** + * @param Template $templateContainer + * @param OrderIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + * @param PaymentHelper $paymentHelper + * @param OrderResource $orderResource + */ + public function __construct( + Template $templateContainer, + OrderIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory, + PaymentHelper $paymentHelper, + OrderResource $orderResource + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + $this->paymentHelper = $paymentHelper; + $this->orderResource = $orderResource; + } + + /** + * Send email to customer + * + * @param Order $order + * @return bool + */ + public function send(Order $order) + { + $result = $this->checkAndSend($order); + if ($result) { + $order->setEmailSent(true); + $this->orderResource->saveAttribute($order, 'email_sent'); + } + return $result; + } + + /** + * Prepare email template with variables + * + * @param Order $order + * @return void + */ + protected function prepareTemplate(Order $order) + { + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + parent::prepareTemplate($order); + } + + /** + * Get payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php new file mode 100644 index 00000000000..4409c9eee3a --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.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\Model\Order\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Shipment; +use Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity; +use Magento\Sales\Model\Order\Email\Container\Template; + +class ShipmentCommentSender extends NotifySender +{ + /** + * @param Template $templateContainer + * @param ShipmentCommentIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + */ + public function __construct( + Template $templateContainer, + ShipmentCommentIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + } + + /** + * Send email to customer + * + * @param Shipment $shipment + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Shipment $shipment, $notify = true, $comment = '') + { + $order = $shipment->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'shipment' => $shipment, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php new file mode 100644 index 00000000000..1b8380bef97 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php @@ -0,0 +1,107 @@ +<?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\Email\Sender; + +use Magento\Sales\Model\Order\Email\NotifySender; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Shipment; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\ShipmentIdentity; +use Magento\Payment\Helper\Data as PaymentHelper; +use Magento\Sales\Model\Resource\Order\Shipment as ShipmentResource; + +class ShipmentSender extends NotifySender +{ + /** + * @var PaymentHelper + */ + protected $paymentHelper; + + /** + * @var ShipmentResource + */ + protected $shipmentResource; + + /** + * @param Template $templateContainer + * @param ShipmentIdentity $identityContainer + * @param Order\Email\SenderBuilderFactory $senderBuilderFactory + * @param PaymentHelper $paymentHelper + * @param ShipmentResource $shipmentResource + */ + public function __construct( + Template $templateContainer, + ShipmentIdentity $identityContainer, + \Magento\Sales\Model\Order\Email\SenderBuilderFactory $senderBuilderFactory, + PaymentHelper $paymentHelper, + ShipmentResource $shipmentResource + ) { + parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory); + $this->paymentHelper = $paymentHelper; + $this->shipmentResource = $shipmentResource; + } + + /** + * Send email to customer + * + * @param Shipment $shipment + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Shipment $shipment, $notify = true, $comment = '') + { + $order = $shipment->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'shipment' => $shipment, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + $result = $this->checkAndSend($order, $notify); + if ($result) { + $shipment->setEmailSent(true); + $this->shipmentResource->saveAttribute($shipment, 'email_sent'); + } + return $result; + } + + /** + * Get payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php new file mode 100644 index 00000000000..68b02e0d0e5 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php @@ -0,0 +1,122 @@ +<?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\Email; + +use Magento\Sales\Model\Order; +use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Sales\Model\Order\Email\Container\Template; +use Magento\Sales\Model\Order\Email\Container\IdentityInterface; + +class SenderBuilder +{ + /** + * @var Template + */ + protected $templateContainer; + + /** + * @var IdentityInterface + */ + protected $identityContainer; + + /** + * @var TransportBuilder + */ + protected $transportBuilder; + + /** + * @param Template $templateContainer + * @param IdentityInterface $identityContainer + * @param TransportBuilder $transportBuilder + */ + public function __construct( + Template $templateContainer, + IdentityInterface $identityContainer, + TransportBuilder $transportBuilder + ) { + $this->templateContainer = $templateContainer; + $this->identityContainer = $identityContainer; + $this->transportBuilder = $transportBuilder; + } + + /** + * Prepare and send email message + * + * @return void + */ + public function send() + { + $this->configureEmailTemplate(); + + $this->transportBuilder->addTo( + $this->identityContainer->getCustomerEmail(), + $this->identityContainer->getCustomerName() + ); + + $copyTo = $this->identityContainer->getEmailCopyTo(); + + if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') { + foreach ($copyTo as $email) { + $this->transportBuilder->addBcc($email); + } + } + + $transport = $this->transportBuilder->getTransport(); + $transport->sendMessage(); + } + + /** + * Prepare and send copy email message + * + * @return void + */ + public function sendCopyTo() + { + $copyTo = $this->identityContainer->getEmailCopyTo(); + + if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'copy') { + foreach ($copyTo as $email) { + $this->configureEmailTemplate(); + + $this->transportBuilder->addTo($email); + + $transport = $this->transportBuilder->getTransport(); + $transport->sendMessage(); + } + } + } + + /** + * Configure email template + * + * @return void + */ + protected function configureEmailTemplate() + { + $this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId()); + $this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions()); + $this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars()); + $this->transportBuilder->setFrom($this->identityContainer->getEmailIdentity()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index 5bdbc6842e5..f337c613041 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -126,30 +126,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel const NOT_CAPTURE = 'not_capture'; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/invoice/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/invoice/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/invoice_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/invoice_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/invoice_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/invoice_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/invoice_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_INVOICE_CREATED = 'invoice_created'; @@ -208,27 +184,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_wasPayCalled = false; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\Order\Invoice\Config */ @@ -264,19 +219,11 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Invoice\Config $invoiceConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory @@ -284,7 +231,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel * @param \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory * @param Invoice\CommentFactory $invoiceCommentFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -294,9 +240,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Order\Invoice\Config $invoiceConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory, @@ -304,14 +247,10 @@ class Invoice extends \Magento\Sales\Model\AbstractModel \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory, \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory, \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_invoiceConfig = $invoiceConfig; $this->_orderFactory = $orderFactory; $this->_orderResourceFactory = $orderResourceFactory; @@ -319,7 +258,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel $this->_invoiceItemCollectionFactory = $invoiceItemCollectionFactory; $this->_invoiceCommentFactory = $invoiceCommentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -874,254 +812,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel return $this->_comments; } - /** - * Send email with invoice data - * - * @param bool $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewInvoiceEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with invoice update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendInvoiceCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - - /** - * @return \Magento\Framework\Model\AbstractModel - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } - /** * Reset invoice object * diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index eb55571b54c..a4f64eed4dd 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -57,30 +57,6 @@ class Shipment extends \Magento\Sales\Model\AbstractModel { const STATUS_NEW = 1; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/shipment/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/shipment/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/shipment/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/shipment/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/shipment/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/shipment_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/shipment_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/shipment_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/shipment_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/shipment_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_SHIPMENT_CREATED = 'shipment_created'; @@ -135,27 +111,6 @@ class Shipment extends \Magento\Sales\Model\AbstractModel */ protected $_eventObject = 'shipment'; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\OrderFactory */ @@ -181,25 +136,16 @@ class Shipment extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory * @param Shipment\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -209,28 +155,20 @@ class Shipment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory, \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_orderFactory = $orderFactory; $this->_shipmentItemCollectionFactory = $shipmentItemCollectionFactory; $this->_trackCollectionFactory = $trackCollectionFactory; $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -536,246 +474,6 @@ class Shipment extends \Magento\Sales\Model\AbstractModel return $this->_comments; } - /** - * Send email with shipment data - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewShipmentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with shipment update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendShipmentCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - /** * Before object save * diff --git a/app/code/Magento/Sales/Model/Order/Status/History/Validator.php b/app/code/Magento/Sales/Model/Order/Status/History/Validator.php new file mode 100644 index 00000000000..ab9e6785118 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Status/History/Validator.php @@ -0,0 +1,53 @@ +<?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\Status\History; + +use Magento\Sales\Model\Order\Status\History; + +/** + * Class Validator + * @package Magento\Sales\Model\Order\Status\History + */ +class Validator +{ + /** + * @var array + */ + protected $requiredFields = ['parent_id' => 'Order Id']; + + /** + * @param History $history + * @return array + */ + public function validate(History $history) + { + $warnings = []; + foreach ($this->requiredFields as $code => $label) { + if (!$history->hasData($code)) { + $warnings[] = sprintf('%s is a required field', $label); + } + } + return $warnings; + } +} diff --git a/app/code/Magento/Sales/Model/Quote/Address.php b/app/code/Magento/Sales/Model/Quote/Address.php index a638c071f1d..7759ac6c301 100644 --- a/app/code/Magento/Sales/Model/Quote/Address.php +++ b/app/code/Magento/Sales/Model/Quote/Address.php @@ -250,6 +250,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress */ protected $_customerAdressService; + /** + * @var Address\Validator + */ + protected $validator; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -259,18 +264,19 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Sales\Model\Quote\Address\ItemFactory $addressItemFactory + * @param Address\ItemFactory $addressItemFactory * @param \Magento\Sales\Model\Resource\Quote\Address\Item\CollectionFactory $itemCollectionFactory - * @param \Magento\Sales\Model\Quote\Address\RateFactory $addressRateFactory - * @param \Magento\Sales\Model\Quote\Address\RateCollectorInterfaceFactory $rateCollector + * @param Address\RateFactory $addressRateFactory + * @param Address\RateCollectorInterfaceFactory $rateCollector * @param \Magento\Sales\Model\Resource\Quote\Address\Rate\CollectionFactory $rateCollectionFactory - * @param \Magento\Sales\Model\Quote\Address\RateRequestFactory $rateRequestFactory - * @param \Magento\Sales\Model\Quote\Address\Total\CollectorFactory $totalCollectorFactory - * @param \Magento\Sales\Model\Quote\Address\TotalFactory $addressTotalFactory + * @param Address\RateRequestFactory $rateRequestFactory + * @param Address\Total\CollectorFactory $totalCollectorFactory + * @param Address\TotalFactory $addressTotalFactory * @param \Magento\Framework\Object\Copy $objectCopyService - * @param \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory + * @param Address\CarrierFactoryInterface $carrierFactory * @param CustomerAddressBuilder $customerAddressBuilder * @param CustomerAddressServiceInterface $customerAddressService + * @param Address\Validator $validator * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -296,6 +302,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory, CustomerAddressBuilder $customerAddressBuilder, CustomerAddressServiceInterface $customerAddressService, + Address\Validator $validator, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -313,6 +320,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress $this->_carrierFactory = $carrierFactory; $this->_customerAddressBuilder = $customerAddressBuilder; $this->_customerAdressService = $customerAddressService; + $this->validator = $validator; parent::__construct( $context, $registry, @@ -1390,4 +1398,12 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress { return $this->getSubtotal() + $this->getDiscountAmount(); } + + /** + * {@inheritdoc} + */ + protected function _getValidationRulesBeforeSave() + { + return $this->validator; + } } diff --git a/app/code/Magento/Sales/Model/Quote/Address/Validator.php b/app/code/Magento/Sales/Model/Quote/Address/Validator.php new file mode 100644 index 00000000000..e3e5100dd19 --- /dev/null +++ b/app/code/Magento/Sales/Model/Quote/Address/Validator.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\Model\Quote\Address; + +use Zend_Validate_Exception; + +class Validator extends \Magento\Framework\Validator\AbstractValidator +{ + /** + * @var \Magento\Directory\Model\CountryFactory + */ + protected $countryFactory; + + /** + * @param \Magento\Directory\Model\CountryFactory $countryFactory + */ + public function __construct(\Magento\Directory\Model\CountryFactory $countryFactory) + { + $this->countryFactory = $countryFactory; + } + + /** + * Returns true if and only if $value meets the validation requirements + * + * If $value fails validation, then this method returns false, and + * getMessages() will return an array of messages that explain why the + * validation failed. + * + * @param \Magento\Sales\Model\Quote\Address $value + * @return boolean + * @throws Zend_Validate_Exception If validation of $value is impossible + */ + public function isValid($value) + { + $messages = array(); + $email = $value->getEmail(); + if (!empty($email) && !\Zend_Validate::is($email, 'EmailAddress')) { + $messages['invalid_email_format'] = 'Invalid email format'; + } + + $countryId = $value->getCountryId(); + if (!empty($countryId)) { + $country = $this->countryFactory->create(); + $country->load($countryId); + if (!$country->getId()) { + $messages['invalid_country_code'] = 'Invalid country code'; + } + } + + $this->_addMessages($messages); + + return empty($messages); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index dd661f198dc..7bb0070b82c 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -40,22 +40,31 @@ class Address extends AbstractOrder */ protected $_salesResourceFactory; + /** + * @var \Magento\Sales\Model\Order\Address\Validator + */ + protected $_validator; + /** * @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\Resource\Factory $salesResourceFactory + * @param \Magento\Sales\Model\Order\Address\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\Resource\Factory $salesResourceFactory + \Magento\Sales\Model\Resource\Factory $salesResourceFactory, + \Magento\Sales\Model\Order\Address\Validator $validator ) { + $this->_validator = $validator; parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); $this->_salesResourceFactory = $salesResourceFactory; + } /** @@ -91,6 +100,25 @@ class Address extends AbstractOrder return $attributes; } + /** + * 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); + $warnings = $this->_validator->validate($object); + if (!empty($warnings)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save address") . ":\n" . implode("\n", $warnings) + ); + } + return $this; + } + /** * Update related grid table after object save * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php index 87cc3d2f436..ca4f1d4c1e9 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Resource\Order\Status; +use Magento\Sales\Model\Order\Status\History\Validator; + /** * Flat sales order status history resource * @@ -30,6 +32,29 @@ namespace Magento\Sales\Model\Resource\Order\Status; */ class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder { + /** + * @var Validator + */ + protected $validator; + + /** + * @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 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, + Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Event prefix * @@ -46,4 +71,23 @@ class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder { $this->_init('sales_flat_order_status_history', 'entity_id'); } + + /** + * Perform actions before object 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); + $warnings = $this->validator->validate($object); + if (!empty($warnings)) { + throw new \Magento\Framework\Model\Exception( + __('Cannot save comment') . ":\n" . implode("\n", $warnings) + ); + } + return $this; + } } diff --git a/app/code/Magento/Sales/Service/V1/Data/Comment.php b/app/code/Magento/Sales/Service/V1/Data/Comment.php new file mode 100644 index 00000000000..bfe5773e92e --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Comment.php @@ -0,0 +1,99 @@ +<?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 InvoiceComment + */ +class Comment extends DataObject +{ + const ENTITY_ID = 'entity_id'; + const PARENT_ID = 'parent_id'; + const IS_CUSTOMER_NOTIFIED = 'is_customer_notified'; + const IS_VISIBLE_ON_FRONT = 'is_visible_on_front'; + const COMMENT = 'comment'; + 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/Creditmemo.php b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php new file mode 100644 index 00000000000..d43bacf41c2 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php @@ -0,0 +1,753 @@ +<?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 Creditmemo + */ +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'; + + /** + * Returns adjustment + * + * @return float + */ + public function getAdjustment() + { + return $this->_get(self::ADJUSTMENT); + } + + /** + * Returns adjustment_negative + * + * @return float + */ + public function getAdjustmentNegative() + { + return $this->_get(self::ADJUSTMENT_NEGATIVE); + } + + /** + * Returns adjustment_positive + * + * @return float + */ + public function getAdjustmentPositive() + { + return $this->_get(self::ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_adjustment + * + * @return float + */ + public function getBaseAdjustment() + { + return $this->_get(self::BASE_ADJUSTMENT); + } + + /** + * Returns base_adjustment_negative + * + * @return float + */ + public function getBaseAdjustmentNegative() + { + return $this->_get(self::BASE_ADJUSTMENT_NEGATIVE); + } + + /** + * Returns base_adjustment_positive + * + * @return float + */ + public function getBaseAdjustmentPositive() + { + return $this->_get(self::BASE_ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_currency_code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns creditmemo_status + * + * @return int + */ + public function getCreditmemoStatus() + { + return $this->_get(self::CREDITMEMO_STATUS); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns invoice_id + * + * @return int + */ + public function getInvoiceId() + { + return $this->_get(self::INVOICE_ID); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns state + * + * @return int + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns transaction_id + * + * @return string + */ + public function getTransactionId() + { + return $this->_get(self::TRANSACTION_ID); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php new file mode 100644 index 00000000000..26e097b26e1 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php @@ -0,0 +1,122 @@ +<?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/CreditmemoItem.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php new file mode 100644 index 00000000000..6a4a50a1a79 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php @@ -0,0 +1,527 @@ +<?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 CreditmemoItem + */ +class CreditmemoItem 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'; + + /** + * float + */ + const WEEE_TAX_DISPOSITION = 'weee_tax_disposition'; + + /** + * float + */ + const WEEE_TAX_ROW_DISPOSITION = 'weee_tax_row_disposition'; + + /** + * float + */ + const BASE_WEEE_TAX_DISPOSITION = 'base_weee_tax_disposition'; + + /** + * float + */ + const BASE_WEEE_TAX_ROW_DISPOSITION = 'base_weee_tax_row_disposition'; + + /** + * string + */ + const WEEE_TAX_APPLIED = 'weee_tax_applied'; + + /** + * float + */ + const BASE_WEEE_TAX_APPLIED_AMOUNT = 'base_weee_tax_applied_amount'; + + /** + * float + */ + const BASE_WEEE_TAX_APPLIED_ROW_AMNT = 'base_weee_tax_applied_row_amnt'; + + /** + * float + */ + const WEEE_TAX_APPLIED_AMOUNT = 'weee_tax_applied_amount'; + + /** + * float + */ + const WEEE_TAX_APPLIED_ROW_AMOUNT = 'weee_tax_applied_row_amount'; + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_amount + * + * @return float + */ + public function getBaseWeeeTaxAppliedAmount() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_row_amnt + * + * @return float + */ + public function getBaseWeeeTaxAppliedRowAmnt() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_ROW_AMNT); + } + + /** + * Returns base_weee_tax_disposition + * + * @return float + */ + public function getBaseWeeeTaxDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_DISPOSITION); + } + + /** + * Returns base_weee_tax_row_disposition + * + * @return float + */ + public function getBaseWeeeTaxRowDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns weee_tax_applied + * + * @return string + */ + public function getWeeeTaxApplied() + { + return $this->_get(self::WEEE_TAX_APPLIED); + } + + /** + * Returns weee_tax_applied_amount + * + * @return float + */ + public function getWeeeTaxAppliedAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns weee_tax_applied_row_amount + * + * @return float + */ + public function getWeeeTaxAppliedRowAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_ROW_AMOUNT); + } + + /** + * Returns weee_tax_disposition + * + * @return float + */ + public function getWeeeTaxDisposition() + { + return $this->_get(self::WEEE_TAX_DISPOSITION); + } + + /** + * Returns weee_tax_row_disposition + * + * @return float + */ + public function getWeeeTaxRowDisposition() + { + return $this->_get(self::WEEE_TAX_ROW_DISPOSITION); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Invoice.php b/app/code/Magento/Sales/Service/V1/Data/Invoice.php new file mode 100644 index 00000000000..08ed2599cf0 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Invoice.php @@ -0,0 +1,539 @@ +<?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 Invoice + */ +class Invoice extends DataObject +{ + const ENTITY_ID = 'entity_id'; + const STORE_ID = 'store_id'; + const BASE_GRAND_TOTAL = 'base_grand_total'; + const SHIPPING_TAX_AMOUNT = 'shipping_tax_amount'; + const TAX_AMOUNT = 'tax_amount'; + const BASE_TAX_AMOUNT = 'base_tax_amount'; + const STORE_TO_ORDER_RATE = 'store_to_order_rate'; + const BASE_SHIPPING_TAX_AMOUNT = 'base_shipping_tax_amount'; + const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'; + const BASE_TO_ORDER_RATE = 'base_to_order_rate'; + const GRAND_TOTAL = 'grand_total'; + const SHIPPING_AMOUNT = 'shipping_amount'; + const SUBTOTAL_INCL_TAX = 'subtotal_incl_tax'; + const BASE_SUBTOTAL_INCL_TAX = 'base_subtotal_incl_tax'; + const STORE_TO_BASE_RATE = 'store_to_base_rate'; + const BASE_SHIPPING_AMOUNT = 'base_shipping_amount'; + const TOTAL_QTY = 'total_qty'; + const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'; + const SUBTOTAL = 'subtotal'; + const BASE_SUBTOTAL = 'base_subtotal'; + const DISCOUNT_AMOUNT = 'discount_amount'; + const BILLING_ADDRESS_ID = 'billing_address_id'; + const IS_USED_FOR_REFUND = 'is_used_for_refund'; + const ORDER_ID = 'order_id'; + const EMAIL_SENT = 'email_sent'; + const CAN_VOID_FLAG = 'can_void_flag'; + const STATE = 'state'; + const SHIPPING_ADDRESS_ID = 'shipping_address_id'; + const STORE_CURRENCY_CODE = 'store_currency_code'; + const TRANSACTION_ID = 'transaction_id'; + const ORDER_CURRENCY_CODE = 'order_currency_code'; + const BASE_CURRENCY_CODE = 'base_currency_code'; + const GLOBAL_CURRENCY_CODE = 'global_currency_code'; + const INCREMENT_ID = 'increment_id'; + const CREATED_AT = 'created_at'; + const UPDATED_AT = 'updated_at'; + const HIDDEN_TAX_AMOUNT = 'hidden_tax_amount'; + const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; + const SHIPPING_HIDDEN_TAX_AMOUNT = 'shipping_hidden_tax_amount'; + const BASE_SHIPPING_HIDDEN_TAX_AMNT = 'base_shipping_hidden_tax_amnt'; + const SHIPPING_INCL_TAX = 'shipping_incl_tax'; + const BASE_SHIPPING_INCL_TAX = 'base_shipping_incl_tax'; + const BASE_TOTAL_REFUNDED = 'base_total_refunded'; + const DISCOUNT_DESCRIPTION = 'discount_description'; + const ITEMS = 'items'; + const COMMENTS = 'comments'; + + /** + * Returns base_currency_code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_total_refunded + * + * @return float + */ + public function getBaseTotalRefunded() + { + return $this->_get(self::BASE_TOTAL_REFUNDED); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns can_void_flag + * + * @return int + */ + public function getCanVoidFlag() + { + return $this->_get(self::CAN_VOID_FLAG); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns is_used_for_refund + * + * @return int + */ + public function getIsUsedForRefund() + { + return $this->_get(self::IS_USED_FOR_REFUND); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns state + * + * @return int + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns total_qty + * + * @return float + */ + public function getTotalQty() + { + return $this->_get(self::TOTAL_QTY); + } + + /** + * Returns transaction_id + * + * @return string + */ + public function getTransactionId() + { + return $this->_get(self::TRANSACTION_ID); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns invoice items + * + * @return InvoiceItem[] + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } + + /** + * Return invoice comments + * + * @return Comment[] + */ + public function getComments() + { + return $this->_get(self::COMMENTS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php new file mode 100644 index 00000000000..dd3865fe5b9 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php @@ -0,0 +1,392 @@ +<?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 InvoiceItem + */ +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'; + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Order.php b/app/code/Magento/Sales/Service/V1/Data/Order.php new file mode 100644 index 00000000000..7205f8c6618 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Order.php @@ -0,0 +1,1542 @@ +<?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 Order + */ +class Order extends DataObject +{ + const ENTITY_ID = 'entity_id'; + const STATE = 'state'; + const STATUS = 'status'; + const COUPON_CODE = 'coupon_code'; + const PROTECT_CODE = 'protect_code'; + const SHIPPING_DESCRIPTION = 'shipping_description'; + const IS_VIRTUAL = 'is_virtual'; + const STORE_ID = 'store_id'; + const CUSTOMER_ID = 'customer_id'; + const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'; + const BASE_DISCOUNT_CANCELED = 'base_discount_canceled'; + const BASE_DISCOUNT_INVOICED = 'base_discount_invoiced'; + const BASE_DISCOUNT_REFUNDED = 'base_discount_refunded'; + const BASE_GRAND_TOTAL = 'base_grand_total'; + const BASE_SHIPPING_AMOUNT = 'base_shipping_amount'; + const BASE_SHIPPING_CANCELED = 'base_shipping_canceled'; + const BASE_SHIPPING_INVOICED = 'base_shipping_invoiced'; + const BASE_SHIPPING_REFUNDED = 'base_shipping_refunded'; + const BASE_SHIPPING_TAX_AMOUNT = 'base_shipping_tax_amount'; + const BASE_SHIPPING_TAX_REFUNDED = 'base_shipping_tax_refunded'; + const BASE_SUBTOTAL = 'base_subtotal'; + const BASE_SUBTOTAL_CANCELED = 'base_subtotal_canceled'; + const BASE_SUBTOTAL_INVOICED = 'base_subtotal_invoiced'; + const BASE_SUBTOTAL_REFUNDED = 'base_subtotal_refunded'; + const BASE_TAX_AMOUNT = 'base_tax_amount'; + const BASE_TAX_CANCELED = 'base_tax_canceled'; + const BASE_TAX_INVOICED = 'base_tax_invoiced'; + const BASE_TAX_REFUNDED = 'base_tax_refunded'; + const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'; + const BASE_TO_ORDER_RATE = 'base_to_order_rate'; + const BASE_TOTAL_CANCELED = 'base_total_canceled'; + const BASE_TOTAL_INVOICED = 'base_total_invoiced'; + const BASE_TOTAL_INVOICED_COST = 'base_total_invoiced_cost'; + const BASE_TOTAL_OFFLINE_REFUNDED = 'base_total_offline_refunded'; + const BASE_TOTAL_ONLINE_REFUNDED = 'base_total_online_refunded'; + const BASE_TOTAL_PAID = 'base_total_paid'; + const BASE_TOTAL_QTY_ORDERED = 'base_total_qty_ordered'; + const BASE_TOTAL_REFUNDED = 'base_total_refunded'; + const DISCOUNT_AMOUNT = 'discount_amount'; + const DISCOUNT_CANCELED = 'discount_canceled'; + const DISCOUNT_INVOICED = 'discount_invoiced'; + const DISCOUNT_REFUNDED = 'discount_refunded'; + const GRAND_TOTAL = 'grand_total'; + const SHIPPING_AMOUNT = 'shipping_amount'; + const SHIPPING_CANCELED = 'shipping_canceled'; + const SHIPPING_INVOICED = 'shipping_invoiced'; + const SHIPPING_REFUNDED = 'shipping_refunded'; + const SHIPPING_TAX_AMOUNT = 'shipping_tax_amount'; + const SHIPPING_TAX_REFUNDED = 'shipping_tax_refunded'; + const STORE_TO_BASE_RATE = 'store_to_base_rate'; + const STORE_TO_ORDER_RATE = 'store_to_order_rate'; + const SUBTOTAL = 'subtotal'; + const SUBTOTAL_CANCELED = 'subtotal_canceled'; + const SUBTOTAL_INVOICED = 'subtotal_invoiced'; + const SUBTOTAL_REFUNDED = 'subtotal_refunded'; + const TAX_AMOUNT = 'tax_amount'; + const TAX_CANCELED = 'tax_canceled'; + const TAX_INVOICED = 'tax_invoiced'; + const TAX_REFUNDED = 'tax_refunded'; + const TOTAL_CANCELED = 'total_canceled'; + const TOTAL_INVOICED = 'total_invoiced'; + const TOTAL_OFFLINE_REFUNDED = 'total_offline_refunded'; + const TOTAL_ONLINE_REFUNDED = 'total_online_refunded'; + const TOTAL_PAID = 'total_paid'; + const TOTAL_QTY_ORDERED = 'total_qty_ordered'; + const TOTAL_REFUNDED = 'total_refunded'; + const CAN_SHIP_PARTIALLY = 'can_ship_partially'; + const CAN_SHIP_PARTIALLY_ITEM = 'can_ship_partially_item'; + const CUSTOMER_IS_GUEST = 'customer_is_guest'; + const CUSTOMER_NOTE_NOTIFY = 'customer_note_notify'; + const BILLING_ADDRESS_ID = 'billing_address_id'; + const CUSTOMER_GROUP_ID = 'customer_group_id'; + const EDIT_INCREMENT = 'edit_increment'; + const EMAIL_SENT = 'email_sent'; + const FORCED_SHIPMENT_WITH_INVOICE = 'forced_shipment_with_invoice'; + const PAYMENT_AUTH_EXPIRATION = 'payment_auth_expiration'; + const QUOTE_ADDRESS_ID = 'quote_address_id'; + const QUOTE_ID = 'quote_id'; + const SHIPPING_ADDRESS_ID = 'shipping_address_id'; + const ADJUSTMENT_NEGATIVE = 'adjustment_negative'; + const ADJUSTMENT_POSITIVE = 'adjustment_positive'; + const BASE_ADJUSTMENT_NEGATIVE = 'base_adjustment_negative'; + const BASE_ADJUSTMENT_POSITIVE = 'base_adjustment_positive'; + const BASE_SHIPPING_DISCOUNT_AMOUNT = 'base_shipping_discount_amount'; + const BASE_SUBTOTAL_INCL_TAX = 'base_subtotal_incl_tax'; + const BASE_TOTAL_DUE = 'base_total_due'; + const PAYMENT_AUTHORIZATION_AMOUNT = 'payment_authorization_amount'; + const SHIPPING_DISCOUNT_AMOUNT = 'shipping_discount_amount'; + const SUBTOTAL_INCL_TAX = 'subtotal_incl_tax'; + const TOTAL_DUE = 'total_due'; + const WEIGHT = 'weight'; + const CUSTOMER_DOB = 'customer_dob'; + const INCREMENT_ID = 'increment_id'; + const APPLIED_RULE_IDS = 'applied_rule_ids'; + const BASE_CURRENCY_CODE = 'base_currency_code'; + const CUSTOMER_EMAIL = 'customer_email'; + const CUSTOMER_FIRSTNAME = 'customer_firstname'; + const CUSTOMER_LASTNAME = 'customer_lastname'; + const CUSTOMER_MIDDLENAME = 'customer_middlename'; + const CUSTOMER_PREFIX = 'customer_prefix'; + const CUSTOMER_SUFFIX = 'customer_suffix'; + const CUSTOMER_TAXVAT = 'customer_taxvat'; + const DISCOUNT_DESCRIPTION = 'discount_description'; + const EXT_CUSTOMER_ID = 'ext_customer_id'; + const EXT_ORDER_ID = 'ext_order_id'; + const GLOBAL_CURRENCY_CODE = 'global_currency_code'; + const HOLD_BEFORE_STATE = 'hold_before_state'; + const HOLD_BEFORE_STATUS = 'hold_before_status'; + const ORDER_CURRENCY_CODE = 'order_currency_code'; + const ORIGINAL_INCREMENT_ID = 'original_increment_id'; + const RELATION_CHILD_ID = 'relation_child_id'; + const RELATION_CHILD_REAL_ID = 'relation_child_real_id'; + const RELATION_PARENT_ID = 'relation_parent_id'; + const RELATION_PARENT_REAL_ID = 'relation_parent_real_id'; + const REMOTE_IP = 'remote_ip'; + const SHIPPING_METHOD = 'shipping_method'; + const STORE_CURRENCY_CODE = 'store_currency_code'; + const STORE_NAME = 'store_name'; + const X_FORWARDED_FOR = 'x_forwarded_for'; + const CUSTOMER_NOTE = 'customer_note'; + const CREATED_AT = 'created_at'; + const UPDATED_AT = 'updated_at'; + const TOTAL_ITEM_COUNT = 'total_item_count'; + const CUSTOMER_GENDER = 'customer_gender'; + const HIDDEN_TAX_AMOUNT = 'hidden_tax_amount'; + const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; + const SHIPPING_HIDDEN_TAX_AMOUNT = 'shipping_hidden_tax_amount'; + const BASE_SHIPPING_HIDDEN_TAX_AMNT = 'base_shipping_hidden_tax_amnt'; + const HIDDEN_TAX_INVOICED = 'hidden_tax_invoiced'; + const BASE_HIDDEN_TAX_INVOICED = 'base_hidden_tax_invoiced'; + const HIDDEN_TAX_REFUNDED = 'hidden_tax_refunded'; + const BASE_HIDDEN_TAX_REFUNDED = 'base_hidden_tax_refunded'; + const SHIPPING_INCL_TAX = 'shipping_incl_tax'; + const BASE_SHIPPING_INCL_TAX = 'base_shipping_incl_tax'; + const ITEMS = 'items'; + const BILLING_ADDRESS = 'billing_address'; + const SHIPPING_ADDRESS = 'shipping_address'; + const PAYMENTS = 'payments'; + /** + * Returns adjustment_negative + * + * @return float + */ + public function getAdjustmentNegative() + { + return $this->_get(self::ADJUSTMENT_NEGATIVE); + } + + /** + * Returns adjustment_positive + * + * @return float + */ + public function getAdjustmentPositive() + { + return $this->_get(self::ADJUSTMENT_POSITIVE); + } + + /** + * Returns applied_rule_ids + * + * @return string + */ + public function getAppliedRuleIds() + { + return $this->_get(self::APPLIED_RULE_IDS); + } + + /** + * Returns base_adjustment_negative + * + * @return float + */ + public function getBaseAdjustmentNegative() + { + return $this->_get(self::BASE_ADJUSTMENT_NEGATIVE); + } + + /** + * Returns base_adjustment_positive + * + * @return float + */ + public function getBaseAdjustmentPositive() + { + return $this->_get(self::BASE_ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_currency_code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_discount_canceled + * + * @return float + */ + public function getBaseDiscountCanceled() + { + return $this->_get(self::BASE_DISCOUNT_CANCELED); + } + + /** + * Returns base_discount_invoiced + * + * @return float + */ + public function getBaseDiscountInvoiced() + { + return $this->_get(self::BASE_DISCOUNT_INVOICED); + } + + /** + * Returns base_discount_refunded + * + * @return float + */ + public function getBaseDiscountRefunded() + { + return $this->_get(self::BASE_DISCOUNT_REFUNDED); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_hidden_tax_invoiced + * + * @return float + */ + public function getBaseHiddenTaxInvoiced() + { + return $this->_get(self::BASE_HIDDEN_TAX_INVOICED); + } + + /** + * Returns base_hidden_tax_refunded + * + * @return float + */ + public function getBaseHiddenTaxRefunded() + { + return $this->_get(self::BASE_HIDDEN_TAX_REFUNDED); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_canceled + * + * @return float + */ + public function getBaseShippingCanceled() + { + return $this->_get(self::BASE_SHIPPING_CANCELED); + } + + /** + * Returns base_shipping_discount_amount + * + * @return float + */ + public function getBaseShippingDiscountAmount() + { + return $this->_get(self::BASE_SHIPPING_DISCOUNT_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_invoiced + * + * @return float + */ + public function getBaseShippingInvoiced() + { + return $this->_get(self::BASE_SHIPPING_INVOICED); + } + + /** + * Returns base_shipping_refunded + * + * @return float + */ + public function getBaseShippingRefunded() + { + return $this->_get(self::BASE_SHIPPING_REFUNDED); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_shipping_tax_refunded + * + * @return float + */ + public function getBaseShippingTaxRefunded() + { + return $this->_get(self::BASE_SHIPPING_TAX_REFUNDED); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_canceled + * + * @return float + */ + public function getBaseSubtotalCanceled() + { + return $this->_get(self::BASE_SUBTOTAL_CANCELED); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_subtotal_invoiced + * + * @return float + */ + public function getBaseSubtotalInvoiced() + { + return $this->_get(self::BASE_SUBTOTAL_INVOICED); + } + + /** + * Returns base_subtotal_refunded + * + * @return float + */ + public function getBaseSubtotalRefunded() + { + return $this->_get(self::BASE_SUBTOTAL_REFUNDED); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_tax_canceled + * + * @return float + */ + public function getBaseTaxCanceled() + { + return $this->_get(self::BASE_TAX_CANCELED); + } + + /** + * Returns base_tax_invoiced + * + * @return float + */ + public function getBaseTaxInvoiced() + { + return $this->_get(self::BASE_TAX_INVOICED); + } + + /** + * Returns base_tax_refunded + * + * @return float + */ + public function getBaseTaxRefunded() + { + return $this->_get(self::BASE_TAX_REFUNDED); + } + + /** + * Returns base_total_canceled + * + * @return float + */ + public function getBaseTotalCanceled() + { + return $this->_get(self::BASE_TOTAL_CANCELED); + } + + /** + * Returns base_total_due + * + * @return float + */ + public function getBaseTotalDue() + { + return $this->_get(self::BASE_TOTAL_DUE); + } + + /** + * Returns base_total_invoiced + * + * @return float + */ + public function getBaseTotalInvoiced() + { + return $this->_get(self::BASE_TOTAL_INVOICED); + } + + /** + * Returns base_total_invoiced_cost + * + * @return float + */ + public function getBaseTotalInvoicedCost() + { + return $this->_get(self::BASE_TOTAL_INVOICED_COST); + } + + /** + * Returns base_total_offline_refunded + * + * @return float + */ + public function getBaseTotalOfflineRefunded() + { + return $this->_get(self::BASE_TOTAL_OFFLINE_REFUNDED); + } + + /** + * Returns base_total_online_refunded + * + * @return float + */ + public function getBaseTotalOnlineRefunded() + { + return $this->_get(self::BASE_TOTAL_ONLINE_REFUNDED); + } + + /** + * Returns base_total_paid + * + * @return float + */ + public function getBaseTotalPaid() + { + return $this->_get(self::BASE_TOTAL_PAID); + } + + /** + * Returns base_total_qty_ordered + * + * @return float + */ + public function getBaseTotalQtyOrdered() + { + return $this->_get(self::BASE_TOTAL_QTY_ORDERED); + } + + /** + * Returns base_total_refunded + * + * @return float + */ + public function getBaseTotalRefunded() + { + return $this->_get(self::BASE_TOTAL_REFUNDED); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns can_ship_partially + * + * @return int + */ + public function getCanShipPartially() + { + return $this->_get(self::CAN_SHIP_PARTIALLY); + } + + /** + * Returns can_ship_partially_item + * + * @return int + */ + public function getCanShipPartiallyItem() + { + return $this->_get(self::CAN_SHIP_PARTIALLY_ITEM); + } + + /** + * Returns coupon_code + * + * @return string + */ + public function getCouponCode() + { + return $this->_get(self::COUPON_CODE); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns customer_dob + * + * @return string + */ + public function getCustomerDob() + { + return $this->_get(self::CUSTOMER_DOB); + } + + /** + * Returns customer_email + * + * @return string + */ + public function getCustomerEmail() + { + return $this->_get(self::CUSTOMER_EMAIL); + } + + /** + * Returns customer_firstname + * + * @return string + */ + public function getCustomerFirstname() + { + return $this->_get(self::CUSTOMER_FIRSTNAME); + } + + /** + * Returns customer_gender + * + * @return int + */ + public function getCustomerGender() + { + return $this->_get(self::CUSTOMER_GENDER); + } + + /** + * Returns customer_group_id + * + * @return int + */ + public function getCustomerGroupId() + { + return $this->_get(self::CUSTOMER_GROUP_ID); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns customer_is_guest + * + * @return int + */ + public function getCustomerIsGuest() + { + return $this->_get(self::CUSTOMER_IS_GUEST); + } + + /** + * Returns customer_lastname + * + * @return string + */ + public function getCustomerLastname() + { + return $this->_get(self::CUSTOMER_LASTNAME); + } + + /** + * Returns customer_middlename + * + * @return string + */ + public function getCustomerMiddlename() + { + return $this->_get(self::CUSTOMER_MIDDLENAME); + } + + /** + * Returns customer_note + * + * @return string + */ + public function getCustomerNote() + { + return $this->_get(self::CUSTOMER_NOTE); + } + + /** + * Returns customer_note_notify + * + * @return int + */ + public function getCustomerNoteNotify() + { + return $this->_get(self::CUSTOMER_NOTE_NOTIFY); + } + + /** + * Returns customer_prefix + * + * @return string + */ + public function getCustomerPrefix() + { + return $this->_get(self::CUSTOMER_PREFIX); + } + + /** + * Returns customer_suffix + * + * @return string + */ + public function getCustomerSuffix() + { + return $this->_get(self::CUSTOMER_SUFFIX); + } + + /** + * Returns customer_taxvat + * + * @return string + */ + public function getCustomerTaxvat() + { + return $this->_get(self::CUSTOMER_TAXVAT); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_canceled + * + * @return float + */ + public function getDiscountCanceled() + { + return $this->_get(self::DISCOUNT_CANCELED); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns discount_invoiced + * + * @return float + */ + public function getDiscountInvoiced() + { + return $this->_get(self::DISCOUNT_INVOICED); + } + + /** + * Returns discount_refunded + * + * @return float + */ + public function getDiscountRefunded() + { + return $this->_get(self::DISCOUNT_REFUNDED); + } + + /** + * Returns edit_increment + * + * @return int + */ + public function getEditIncrement() + { + return $this->_get(self::EDIT_INCREMENT); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns ext_customer_id + * + * @return string + */ + public function getExtCustomerId() + { + return $this->_get(self::EXT_CUSTOMER_ID); + } + + /** + * Returns ext_order_id + * + * @return string + */ + public function getExtOrderId() + { + return $this->_get(self::EXT_ORDER_ID); + } + + /** + * Returns forced_shipment_with_invoice + * + * @return int + */ + public function getForcedShipmentWithInvoice() + { + return $this->_get(self::FORCED_SHIPMENT_WITH_INVOICE); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns hidden_tax_invoiced + * + * @return float + */ + public function getHiddenTaxInvoiced() + { + return $this->_get(self::HIDDEN_TAX_INVOICED); + } + + /** + * Returns hidden_tax_refunded + * + * @return float + */ + public function getHiddenTaxRefunded() + { + return $this->_get(self::HIDDEN_TAX_REFUNDED); + } + + /** + * Returns hold_before_state + * + * @return string + */ + public function getHoldBeforeState() + { + return $this->_get(self::HOLD_BEFORE_STATE); + } + + /** + * Returns hold_before_status + * + * @return string + */ + public function getHoldBeforeStatus() + { + return $this->_get(self::HOLD_BEFORE_STATUS); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns is_virtual + * + * @return int + */ + public function getIsVirtual() + { + return $this->_get(self::IS_VIRTUAL); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns original_increment_id + * + * @return string + */ + public function getOriginalIncrementId() + { + return $this->_get(self::ORIGINAL_INCREMENT_ID); + } + + /** + * Returns payment_authorization_amount + * + * @return float + */ + public function getPaymentAuthorizationAmount() + { + return $this->_get(self::PAYMENT_AUTHORIZATION_AMOUNT); + } + + /** + * Returns payment_auth_expiration + * + * @return int + */ + public function getPaymentAuthExpiration() + { + return $this->_get(self::PAYMENT_AUTH_EXPIRATION); + } + + /** + * Returns protect_code + * + * @return string + */ + public function getProtectCode() + { + return $this->_get(self::PROTECT_CODE); + } + + /** + * Returns quote_address_id + * + * @return int + */ + public function getQuoteAddressId() + { + return $this->_get(self::QUOTE_ADDRESS_ID); + } + + /** + * Returns quote_id + * + * @return int + */ + public function getQuoteId() + { + return $this->_get(self::QUOTE_ID); + } + + /** + * Returns relation_child_id + * + * @return string + */ + public function getRelationChildId() + { + return $this->_get(self::RELATION_CHILD_ID); + } + + /** + * Returns relation_child_real_id + * + * @return string + */ + public function getRelationChildRealId() + { + return $this->_get(self::RELATION_CHILD_REAL_ID); + } + + /** + * Returns relation_parent_id + * + * @return string + */ + public function getRelationParentId() + { + return $this->_get(self::RELATION_PARENT_ID); + } + + /** + * Returns relation_parent_real_id + * + * @return string + */ + public function getRelationParentRealId() + { + return $this->_get(self::RELATION_PARENT_REAL_ID); + } + + /** + * Returns remote_ip + * + * @return string + */ + public function getRemoteIp() + { + return $this->_get(self::REMOTE_IP); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_canceled + * + * @return float + */ + public function getShippingCanceled() + { + return $this->_get(self::SHIPPING_CANCELED); + } + + /** + * Returns shipping_description + * + * @return string + */ + public function getShippingDescription() + { + return $this->_get(self::SHIPPING_DESCRIPTION); + } + + /** + * Returns shipping_discount_amount + * + * @return float + */ + public function getShippingDiscountAmount() + { + return $this->_get(self::SHIPPING_DISCOUNT_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_invoiced + * + * @return float + */ + public function getShippingInvoiced() + { + return $this->_get(self::SHIPPING_INVOICED); + } + + /** + * Returns shipping_method + * + * @return string + */ + public function getShippingMethod() + { + return $this->_get(self::SHIPPING_METHOD); + } + + /** + * Returns shipping_refunded + * + * @return float + */ + public function getShippingRefunded() + { + return $this->_get(self::SHIPPING_REFUNDED); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns shipping_tax_refunded + * + * @return float + */ + public function getShippingTaxRefunded() + { + return $this->_get(self::SHIPPING_TAX_REFUNDED); + } + + /** + * Returns state + * + * @return string + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns status + * + * @return string + */ + public function getStatus() + { + return $this->_get(self::STATUS); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_name + * + * @return string + */ + public function getStoreName() + { + return $this->_get(self::STORE_NAME); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_canceled + * + * @return float + */ + public function getSubtotalCanceled() + { + return $this->_get(self::SUBTOTAL_CANCELED); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns subtotal_invoiced + * + * @return float + */ + public function getSubtotalInvoiced() + { + return $this->_get(self::SUBTOTAL_INVOICED); + } + + /** + * Returns subtotal_refunded + * + * @return float + */ + public function getSubtotalRefunded() + { + return $this->_get(self::SUBTOTAL_REFUNDED); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns tax_canceled + * + * @return float + */ + public function getTaxCanceled() + { + return $this->_get(self::TAX_CANCELED); + } + + /** + * Returns tax_invoiced + * + * @return float + */ + public function getTaxInvoiced() + { + return $this->_get(self::TAX_INVOICED); + } + + /** + * Returns tax_refunded + * + * @return float + */ + public function getTaxRefunded() + { + return $this->_get(self::TAX_REFUNDED); + } + + /** + * Returns total_canceled + * + * @return float + */ + public function getTotalCanceled() + { + return $this->_get(self::TOTAL_CANCELED); + } + + /** + * Returns total_due + * + * @return float + */ + public function getTotalDue() + { + return $this->_get(self::TOTAL_DUE); + } + + /** + * Returns total_invoiced + * + * @return float + */ + public function getTotalInvoiced() + { + return $this->_get(self::TOTAL_INVOICED); + } + + /** + * Returns total_item_count + * + * @return int + */ + public function getTotalItemCount() + { + return $this->_get(self::TOTAL_ITEM_COUNT); + } + + /** + * Returns total_offline_refunded + * + * @return float + */ + public function getTotalOfflineRefunded() + { + return $this->_get(self::TOTAL_OFFLINE_REFUNDED); + } + + /** + * Returns total_online_refunded + * + * @return float + */ + public function getTotalOnlineRefunded() + { + return $this->_get(self::TOTAL_ONLINE_REFUNDED); + } + + /** + * Returns total_paid + * + * @return float + */ + public function getTotalPaid() + { + return $this->_get(self::TOTAL_PAID); + } + + /** + * Returns total_qty_ordered + * + * @return float + */ + public function getTotalQtyOrdered() + { + return $this->_get(self::TOTAL_QTY_ORDERED); + } + + /** + * Returns total_refunded + * + * @return float + */ + public function getTotalRefunded() + { + return $this->_get(self::TOTAL_REFUNDED); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } + + /** + * Returns x_forwarded_for + * + * @return string + */ + public function getXForwardedFor() + { + return $this->_get(self::X_FORWARDED_FOR); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderItem[] + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderAddress + */ + public function getBillingAddress() + { + return $this->_get(self::BILLING_ADDRESS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderAddress + */ + public function getShippingAddress() + { + return $this->_get(self::SHIPPING_ADDRESS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderPayment[] + */ + public function getPayments() + { + return $this->_get(self::PAYMENTS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php new file mode 100644 index 00000000000..34d413993fd --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php @@ -0,0 +1,422 @@ +<?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 OrderAddress + */ +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'; + + /** + * Returns address_type + * + * @return string + */ + public function getAddressType() + { + return $this->_get(self::ADDRESS_TYPE); + } + + /** + * Returns city + * + * @return string + */ + public function getCity() + { + return $this->_get(self::CITY); + } + + /** + * Returns company + * + * @return string + */ + public function getCompany() + { + return $this->_get(self::COMPANY); + } + + /** + * Returns country_id + * + * @return string + */ + public function getCountryId() + { + return $this->_get(self::COUNTRY_ID); + } + + /** + * Returns customer_address_id + * + * @return int + */ + public function getCustomerAddressId() + { + return $this->_get(self::CUSTOMER_ADDRESS_ID); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns email + * + * @return string + */ + public function getEmail() + { + return $this->_get(self::EMAIL); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns fax + * + * @return string + */ + public function getFax() + { + return $this->_get(self::FAX); + } + + /** + * Returns firstname + * + * @return string + */ + public function getFirstname() + { + return $this->_get(self::FIRSTNAME); + } + + /** + * Returns lastname + * + * @return string + */ + public function getLastname() + { + return $this->_get(self::LASTNAME); + } + + /** + * Returns middlename + * + * @return string + */ + public function getMiddlename() + { + return $this->_get(self::MIDDLENAME); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns postcode + * + * @return string + */ + public function getPostcode() + { + return $this->_get(self::POSTCODE); + } + + /** + * Returns prefix + * + * @return string + */ + public function getPrefix() + { + return $this->_get(self::PREFIX); + } + + /** + * Returns quote_address_id + * + * @return int + */ + public function getQuoteAddressId() + { + return $this->_get(self::QUOTE_ADDRESS_ID); + } + + /** + * Returns region + * + * @return string + */ + public function getRegion() + { + return $this->_get(self::REGION); + } + + /** + * Returns region_id + * + * @return int + */ + public function getRegionId() + { + return $this->_get(self::REGION_ID); + } + + /** + * Returns street + * + * @return string + */ + public function getStreet() + { + return $this->_get(self::STREET); + } + + /** + * Returns suffix + * + * @return string + */ + public function getSuffix() + { + return $this->_get(self::SUFFIX); + } + + /** + * Returns telephone + * + * @return string + */ + public function getTelephone() + { + return $this->_get(self::TELEPHONE); + } + + /** + * Returns vat_id + * + * @return string + */ + public function getVatId() + { + return $this->_get(self::VAT_ID); + } + + /** + * Returns vat_is_valid + * + * @return int + */ + public function getVatIsValid() + { + return $this->_get(self::VAT_IS_VALID); + } + + /** + * Returns vat_request_date + * + * @return string + */ + public function getVatRequestDate() + { + return $this->_get(self::VAT_REQUEST_DATE); + } + + /** + * Returns vat_request_id + * + * @return string + */ + public function getVatRequestId() + { + return $this->_get(self::VAT_REQUEST_ID); + } + + /** + * Returns vat_request_success + * + * @return int + */ + public function getVatRequestSuccess() + { + return $this->_get(self::VAT_REQUEST_SUCCESS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderItem.php b/app/code/Magento/Sales/Service/V1/Data/OrderItem.php new file mode 100644 index 00000000000..7969c2e17b2 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderItem.php @@ -0,0 +1,1167 @@ +<?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 OrderItem + */ +class OrderItem extends DataObject +{ + const ITEM_ID = 'item_id'; + const ORDER_ID = 'order_id'; + const PARENT_ITEM_ID = 'parent_item_id'; + const QUOTE_ITEM_ID = 'quote_item_id'; + const STORE_ID = 'store_id'; + const CREATED_AT = 'created_at'; + const UPDATED_AT = 'updated_at'; + const PRODUCT_ID = 'product_id'; + const PRODUCT_TYPE = 'product_type'; + const PRODUCT_OPTIONS = 'product_options'; + const WEIGHT = 'weight'; + const IS_VIRTUAL = 'is_virtual'; + const SKU = 'sku'; + const NAME = 'name'; + const DESCRIPTION = 'description'; + const APPLIED_RULE_IDS = 'applied_rule_ids'; + const ADDITIONAL_DATA = 'additional_data'; + const IS_QTY_DECIMAL = 'is_qty_decimal'; + const NO_DISCOUNT = 'no_discount'; + const QTY_BACKORDERED = 'qty_backordered'; + const QTY_CANCELED = 'qty_canceled'; + const QTY_INVOICED = 'qty_invoiced'; + const QTY_ORDERED = 'qty_ordered'; + const QTY_REFUNDED = 'qty_refunded'; + const QTY_SHIPPED = 'qty_shipped'; + const BASE_COST = 'base_cost'; + const PRICE = 'price'; + const BASE_PRICE = 'base_price'; + const ORIGINAL_PRICE = 'original_price'; + const BASE_ORIGINAL_PRICE = 'base_original_price'; + const TAX_PERCENT = 'tax_percent'; + const TAX_AMOUNT = 'tax_amount'; + const BASE_TAX_AMOUNT = 'base_tax_amount'; + const TAX_INVOICED = 'tax_invoiced'; + const BASE_TAX_INVOICED = 'base_tax_invoiced'; + const DISCOUNT_PERCENT = 'discount_percent'; + const DISCOUNT_AMOUNT = 'discount_amount'; + const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'; + const DISCOUNT_INVOICED = 'discount_invoiced'; + const BASE_DISCOUNT_INVOICED = 'base_discount_invoiced'; + const AMOUNT_REFUNDED = 'amount_refunded'; + const BASE_AMOUNT_REFUNDED = 'base_amount_refunded'; + const ROW_TOTAL = 'row_total'; + const BASE_ROW_TOTAL = 'base_row_total'; + const ROW_INVOICED = 'row_invoiced'; + const BASE_ROW_INVOICED = 'base_row_invoiced'; + const ROW_WEIGHT = 'row_weight'; + const BASE_TAX_BEFORE_DISCOUNT = 'base_tax_before_discount'; + const TAX_BEFORE_DISCOUNT = 'tax_before_discount'; + const EXT_ORDER_ITEM_ID = 'ext_order_item_id'; + const LOCKED_DO_INVOICE = 'locked_do_invoice'; + const LOCKED_DO_SHIP = 'locked_do_ship'; + const PRICE_INCL_TAX = 'price_incl_tax'; + const BASE_PRICE_INCL_TAX = 'base_price_incl_tax'; + const ROW_TOTAL_INCL_TAX = 'row_total_incl_tax'; + const BASE_ROW_TOTAL_INCL_TAX = 'base_row_total_incl_tax'; + const HIDDEN_TAX_AMOUNT = 'hidden_tax_amount'; + const BASE_HIDDEN_TAX_AMOUNT = 'base_hidden_tax_amount'; + const HIDDEN_TAX_INVOICED = 'hidden_tax_invoiced'; + const BASE_HIDDEN_TAX_INVOICED = 'base_hidden_tax_invoiced'; + const HIDDEN_TAX_REFUNDED = 'hidden_tax_refunded'; + const BASE_HIDDEN_TAX_REFUNDED = 'base_hidden_tax_refunded'; + const IS_NOMINAL = 'is_nominal'; + const TAX_CANCELED = 'tax_canceled'; + const HIDDEN_TAX_CANCELED = 'hidden_tax_canceled'; + const TAX_REFUNDED = 'tax_refunded'; + const BASE_TAX_REFUNDED = 'base_tax_refunded'; + const DISCOUNT_REFUNDED = 'discount_refunded'; + const BASE_DISCOUNT_REFUNDED = 'base_discount_refunded'; + + /** + * int + */ + const GW_ID = 'gw_id'; + + /** + * float + */ + const GW_BASE_PRICE = 'gw_base_price'; + + /** + * float + */ + const GW_PRICE = 'gw_price'; + + /** + * float + */ + const GW_BASE_TAX_AMOUNT = 'gw_base_tax_amount'; + + /** + * float + */ + const GW_TAX_AMOUNT = 'gw_tax_amount'; + + /** + * float + */ + const GW_BASE_PRICE_INVOICED = 'gw_base_price_invoiced'; + + /** + * float + */ + const GW_PRICE_INVOICED = 'gw_price_invoiced'; + + /** + * float + */ + const GW_BASE_TAX_AMOUNT_INVOICED = 'gw_base_tax_amount_invoiced'; + + /** + * float + */ + const GW_TAX_AMOUNT_INVOICED = 'gw_tax_amount_invoiced'; + + /** + * float + */ + const GW_BASE_PRICE_REFUNDED = 'gw_base_price_refunded'; + + /** + * float + */ + const GW_PRICE_REFUNDED = 'gw_price_refunded'; + + /** + * float + */ + const GW_BASE_TAX_AMOUNT_REFUNDED = 'gw_base_tax_amount_refunded'; + + /** + * float + */ + const GW_TAX_AMOUNT_REFUNDED = 'gw_tax_amount_refunded'; + + /** + * int + */ + const FREE_SHIPPING = 'free_shipping'; + + /** + * float + */ + const QTY_RETURNED = 'qty_returned'; + + /** + * int + */ + const EVENT_ID = 'event_id'; + + /** + * float + */ + const BASE_WEEE_TAX_APPLIED_AMOUNT = 'base_weee_tax_applied_amount'; + + /** + * float + */ + const BASE_WEEE_TAX_APPLIED_ROW_AMNT = 'base_weee_tax_applied_row_amnt'; + + /** + * float + */ + const WEEE_TAX_APPLIED_AMOUNT = 'weee_tax_applied_amount'; + + /** + * float + */ + const WEEE_TAX_APPLIED_ROW_AMOUNT = 'weee_tax_applied_row_amount'; + + /** + * string + */ + const WEEE_TAX_APPLIED = 'weee_tax_applied'; + + /** + * float + */ + const WEEE_TAX_DISPOSITION = 'weee_tax_disposition'; + + /** + * float + */ + const WEEE_TAX_ROW_DISPOSITION = 'weee_tax_row_disposition'; + + /** + * float + */ + const BASE_WEEE_TAX_DISPOSITION = 'base_weee_tax_disposition'; + + /** + * float + */ + const BASE_WEEE_TAX_ROW_DISPOSITION = 'base_weee_tax_row_disposition'; + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns amount_refunded + * + * @return float + */ + public function getAmountRefunded() + { + return $this->_get(self::AMOUNT_REFUNDED); + } + + /** + * Returns applied_rule_ids + * + * @return string + */ + public function getAppliedRuleIds() + { + return $this->_get(self::APPLIED_RULE_IDS); + } + + /** + * Returns base_amount_refunded + * + * @return float + */ + public function getBaseAmountRefunded() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_discount_invoiced + * + * @return float + */ + public function getBaseDiscountInvoiced() + { + return $this->_get(self::BASE_DISCOUNT_INVOICED); + } + + /** + * Returns base_discount_refunded + * + * @return float + */ + public function getBaseDiscountRefunded() + { + return $this->_get(self::BASE_DISCOUNT_REFUNDED); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_hidden_tax_invoiced + * + * @return float + */ + public function getBaseHiddenTaxInvoiced() + { + return $this->_get(self::BASE_HIDDEN_TAX_INVOICED); + } + + /** + * Returns base_hidden_tax_refunded + * + * @return float + */ + public function getBaseHiddenTaxRefunded() + { + return $this->_get(self::BASE_HIDDEN_TAX_REFUNDED); + } + + /** + * Returns base_original_price + * + * @return float + */ + public function getBaseOriginalPrice() + { + return $this->_get(self::BASE_ORIGINAL_PRICE); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_invoiced + * + * @return float + */ + public function getBaseRowInvoiced() + { + return $this->_get(self::BASE_ROW_INVOICED); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_tax_before_discount + * + * @return float + */ + public function getBaseTaxBeforeDiscount() + { + return $this->_get(self::BASE_TAX_BEFORE_DISCOUNT); + } + + /** + * Returns base_tax_invoiced + * + * @return float + */ + public function getBaseTaxInvoiced() + { + return $this->_get(self::BASE_TAX_INVOICED); + } + + /** + * Returns base_tax_refunded + * + * @return float + */ + public function getBaseTaxRefunded() + { + return $this->_get(self::BASE_TAX_REFUNDED); + } + + /** + * Returns base_weee_tax_applied_amount + * + * @return float + */ + public function getBaseWeeeTaxAppliedAmount() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_row_amnt + * + * @return float + */ + public function getBaseWeeeTaxAppliedRowAmnt() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_ROW_AMNT); + } + + /** + * Returns base_weee_tax_disposition + * + * @return float + */ + public function getBaseWeeeTaxDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_DISPOSITION); + } + + /** + * Returns base_weee_tax_row_disposition + * + * @return float + */ + public function getBaseWeeeTaxRowDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_invoiced + * + * @return float + */ + public function getDiscountInvoiced() + { + return $this->_get(self::DISCOUNT_INVOICED); + } + + /** + * Returns discount_percent + * + * @return float + */ + public function getDiscountPercent() + { + return $this->_get(self::DISCOUNT_PERCENT); + } + + /** + * Returns discount_refunded + * + * @return float + */ + public function getDiscountRefunded() + { + return $this->_get(self::DISCOUNT_REFUNDED); + } + + /** + * Returns event_id + * + * @return int + */ + public function getEventId() + { + return $this->_get(self::EVENT_ID); + } + + /** + * Returns ext_order_item_id + * + * @return string + */ + public function getExtOrderItemId() + { + return $this->_get(self::EXT_ORDER_ITEM_ID); + } + + /** + * Returns free_shipping + * + * @return int + */ + public function getFreeShipping() + { + return $this->_get(self::FREE_SHIPPING); + } + + /** + * Returns gw_base_price + * + * @return float + */ + public function getGwBasePrice() + { + return $this->_get(self::GW_BASE_PRICE); + } + + /** + * Returns gw_base_price_invoiced + * + * @return float + */ + public function getGwBasePriceInvoiced() + { + return $this->_get(self::GW_BASE_PRICE_INVOICED); + } + + /** + * Returns gw_base_price_refunded + * + * @return float + */ + public function getGwBasePriceRefunded() + { + return $this->_get(self::GW_BASE_PRICE_REFUNDED); + } + + /** + * Returns gw_base_tax_amount + * + * @return float + */ + public function getGwBaseTaxAmount() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT); + } + + /** + * Returns gw_base_tax_amount_invoiced + * + * @return float + */ + public function getGwBaseTaxAmountInvoiced() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT_INVOICED); + } + + /** + * Returns gw_base_tax_amount_refunded + * + * @return float + */ + public function getGwBaseTaxAmountRefunded() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT_REFUNDED); + } + + /** + * Returns gw_id + * + * @return int + */ + public function getGwId() + { + return $this->_get(self::GW_ID); + } + + /** + * Returns gw_price + * + * @return float + */ + public function getGwPrice() + { + return $this->_get(self::GW_PRICE); + } + + /** + * Returns gw_price_invoiced + * + * @return float + */ + public function getGwPriceInvoiced() + { + return $this->_get(self::GW_PRICE_INVOICED); + } + + /** + * Returns gw_price_refunded + * + * @return float + */ + public function getGwPriceRefunded() + { + return $this->_get(self::GW_PRICE_REFUNDED); + } + + /** + * Returns gw_tax_amount + * + * @return float + */ + public function getGwTaxAmount() + { + return $this->_get(self::GW_TAX_AMOUNT); + } + + /** + * Returns gw_tax_amount_invoiced + * + * @return float + */ + public function getGwTaxAmountInvoiced() + { + return $this->_get(self::GW_TAX_AMOUNT_INVOICED); + } + + /** + * Returns gw_tax_amount_refunded + * + * @return float + */ + public function getGwTaxAmountRefunded() + { + return $this->_get(self::GW_TAX_AMOUNT_REFUNDED); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns hidden_tax_canceled + * + * @return float + */ + public function getHiddenTaxCanceled() + { + return $this->_get(self::HIDDEN_TAX_CANCELED); + } + + /** + * Returns hidden_tax_invoiced + * + * @return float + */ + public function getHiddenTaxInvoiced() + { + return $this->_get(self::HIDDEN_TAX_INVOICED); + } + + /** + * Returns hidden_tax_refunded + * + * @return float + */ + public function getHiddenTaxRefunded() + { + return $this->_get(self::HIDDEN_TAX_REFUNDED); + } + + /** + * Returns is_nominal + * + * @return int + */ + public function getIsNominal() + { + return $this->_get(self::IS_NOMINAL); + } + + /** + * Returns is_qty_decimal + * + * @return int + */ + public function getIsQtyDecimal() + { + return $this->_get(self::IS_QTY_DECIMAL); + } + + /** + * Returns is_virtual + * + * @return int + */ + public function getIsVirtual() + { + return $this->_get(self::IS_VIRTUAL); + } + + /** + * Returns item_id + * + * @return int + */ + public function getItemId() + { + return $this->_get(self::ITEM_ID); + } + + /** + * Returns locked_do_invoice + * + * @return int + */ + public function getLockedDoInvoice() + { + return $this->_get(self::LOCKED_DO_INVOICE); + } + + /** + * Returns locked_do_ship + * + * @return int + */ + public function getLockedDoShip() + { + return $this->_get(self::LOCKED_DO_SHIP); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns no_discount + * + * @return int + */ + public function getNoDiscount() + { + return $this->_get(self::NO_DISCOUNT); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns original_price + * + * @return float + */ + public function getOriginalPrice() + { + return $this->_get(self::ORIGINAL_PRICE); + } + + /** + * Returns parent_item_id + * + * @return int + */ + public function getParentItemId() + { + return $this->_get(self::PARENT_ITEM_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns product_options + * + * @return string + */ + public function getProductOptions() + { + return $this->_get(self::PRODUCT_OPTIONS); + } + + /** + * Returns product_type + * + * @return string + */ + public function getProductType() + { + return $this->_get(self::PRODUCT_TYPE); + } + + /** + * Returns qty_backordered + * + * @return float + */ + public function getQtyBackordered() + { + return $this->_get(self::QTY_BACKORDERED); + } + + /** + * Returns qty_canceled + * + * @return float + */ + public function getQtyCanceled() + { + return $this->_get(self::QTY_CANCELED); + } + + /** + * Returns qty_invoiced + * + * @return float + */ + public function getQtyInvoiced() + { + return $this->_get(self::QTY_INVOICED); + } + + /** + * Returns qty_ordered + * + * @return float + */ + public function getQtyOrdered() + { + return $this->_get(self::QTY_ORDERED); + } + + /** + * Returns qty_refunded + * + * @return float + */ + public function getQtyRefunded() + { + return $this->_get(self::QTY_REFUNDED); + } + + /** + * Returns qty_returned + * + * @return float + */ + public function getQtyReturned() + { + return $this->_get(self::QTY_RETURNED); + } + + /** + * Returns qty_shipped + * + * @return float + */ + public function getQtyShipped() + { + return $this->_get(self::QTY_SHIPPED); + } + + /** + * Returns quote_item_id + * + * @return int + */ + public function getQuoteItemId() + { + return $this->_get(self::QUOTE_ITEM_ID); + } + + /** + * Returns row_invoiced + * + * @return float + */ + public function getRowInvoiced() + { + return $this->_get(self::ROW_INVOICED); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns row_weight + * + * @return float + */ + public function getRowWeight() + { + return $this->_get(self::ROW_WEIGHT); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns tax_before_discount + * + * @return float + */ + public function getTaxBeforeDiscount() + { + return $this->_get(self::TAX_BEFORE_DISCOUNT); + } + + /** + * Returns tax_canceled + * + * @return float + */ + public function getTaxCanceled() + { + return $this->_get(self::TAX_CANCELED); + } + + /** + * Returns tax_invoiced + * + * @return float + */ + public function getTaxInvoiced() + { + return $this->_get(self::TAX_INVOICED); + } + + /** + * Returns tax_percent + * + * @return float + */ + public function getTaxPercent() + { + return $this->_get(self::TAX_PERCENT); + } + + /** + * Returns tax_refunded + * + * @return float + */ + public function getTaxRefunded() + { + return $this->_get(self::TAX_REFUNDED); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weee_tax_applied + * + * @return string + */ + public function getWeeeTaxApplied() + { + return $this->_get(self::WEEE_TAX_APPLIED); + } + + /** + * Returns weee_tax_applied_amount + * + * @return float + */ + public function getWeeeTaxAppliedAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns weee_tax_applied_row_amount + * + * @return float + */ + public function getWeeeTaxAppliedRowAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_ROW_AMOUNT); + } + + /** + * Returns weee_tax_disposition + * + * @return float + */ + public function getWeeeTaxDisposition() + { + return $this->_get(self::WEEE_TAX_DISPOSITION); + } + + /** + * Returns weee_tax_row_disposition + * + * @return float + */ + public function getWeeeTaxRowDisposition() + { + return $this->_get(self::WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php new file mode 100644 index 00000000000..38a6e49d4f3 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.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\Service\V1\Data; + +//use Magento\Sales\Model\Order; + +/** + * Class OrderMapper + */ +class OrderMapper +{ + /** + * @var OrderBuilder + */ + protected $orderBuilder; + + /** + * @var OrderItemMapper + */ + protected $orderItemMapper; + + /** + * @var OrderPaymentMapper + */ + protected $orderPaymentMapper; + + /** + * @var OrderAddressMapper + */ + protected $orderAddressMapper; + + /** + * @param OrderBuilder $orderBuilder + * @param OrderItemMapper $orderItemMapper + * @param OrderPaymentMapper $orderPaymentMapper + * @param OrderAddressMapper $orderAddressMapper + */ + public function __construct( + OrderBuilder $orderBuilder, + OrderItemMapper $orderItemMapper, + OrderPaymentMapper $orderPaymentMapper, + OrderAddressMapper $orderAddressMapper + ) { + $this->orderBuilder = $orderBuilder; + $this->orderItemMapper = $orderItemMapper; + $this->orderPaymentMapper = $orderPaymentMapper; + $this->orderAddressMapper = $orderAddressMapper; + } + + /** + * Returns array of items + * + * @param \Magento\Sales\Model\Order $object + * @return OrderItem[] + */ + protected function getItems(\Magento\Sales\Model\Order $object) + { + $items = []; + foreach ($object->getItemsCollection() as $item) { + $items[] = $this->orderItemMapper->extractDto($item); + } + return $items; + } + + /** + * Returns array of payments + * + * @param \Magento\Sales\Model\Order $object + * @return OrderPayment[] + */ + protected function getPayments(\Magento\Sales\Model\Order $object) + { + $payments = []; + foreach ($object->getPaymentsCollection() as $payment) { + $payments[] = $this->orderPaymentMapper->extractDto($payment); + } + return $payments; + } + + /** + * Return billing address + * + * @param \Magento\Sales\Model\Order $object + * @return OrderAddress|null + */ + protected function getBillingAddress(\Magento\Sales\Model\Order $object) + { + $billingAddress = null; + if ($object->getBillingAddress()) { + $billingAddress = $this->orderAddressMapper->extractDto($object->getBillingAddress()); + } + return $billingAddress; + } + + /** + * Returns shipping address + * + * @param \Magento\Sales\Model\Order $object + * @return OrderAddress|null + */ + protected function getShippingAddress(\Magento\Sales\Model\Order $object) + { + $shippingAddress = null; + if ($object->getShippingAddress()) { + $shippingAddress = $this->orderAddressMapper->extractDto($object->getShippingAddress()); + } + return $shippingAddress; + } + + /** + * @param \Magento\Sales\Model\Order $object + * @return \Magento\Framework\Service\Data\AbstractObject + */ + public function extractDto(\Magento\Sales\Model\Order $object) + { + $this->orderBuilder->populateWithArray($object->getData()); + $this->orderBuilder->setItems($this->getItems($object)); + $this->orderBuilder->setPayments($this->getPayments($object)); + $this->orderBuilder->setBillingAddress($this->getBillingAddress($object)); + $this->orderBuilder->setShippingAddress($this->getShippingAddress($object)); + return $this->orderBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php new file mode 100644 index 00000000000..a076f2ab30e --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php @@ -0,0 +1,842 @@ +<?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 OrderPayment + */ +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'; + + /** + * Returns account_status + * + * @return string + */ + public function getAccountStatus() + { + return $this->_get(self::ACCOUNT_STATUS); + } + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns additional_information + * + * @return string + */ + public function getAdditionalInformation() + { + return $this->_get(self::ADDITIONAL_INFORMATION); + } + + /** + * Returns address_status + * + * @return string + */ + public function getAddressStatus() + { + return $this->_get(self::ADDRESS_STATUS); + } + + /** + * Returns amount_authorized + * + * @return float + */ + public function getAmountAuthorized() + { + return $this->_get(self::AMOUNT_AUTHORIZED); + } + + /** + * Returns amount_canceled + * + * @return float + */ + public function getAmountCanceled() + { + return $this->_get(self::AMOUNT_CANCELED); + } + + /** + * Returns amount_ordered + * + * @return float + */ + public function getAmountOrdered() + { + return $this->_get(self::AMOUNT_ORDERED); + } + + /** + * Returns amount_paid + * + * @return float + */ + public function getAmountPaid() + { + return $this->_get(self::AMOUNT_PAID); + } + + /** + * Returns amount_refunded + * + * @return float + */ + public function getAmountRefunded() + { + return $this->_get(self::AMOUNT_REFUNDED); + } + + /** + * Returns anet_trans_method + * + * @return string + */ + public function getAnetTransMethod() + { + return $this->_get(self::ANET_TRANS_METHOD); + } + + /** + * Returns base_amount_authorized + * + * @return float + */ + public function getBaseAmountAuthorized() + { + return $this->_get(self::BASE_AMOUNT_AUTHORIZED); + } + + /** + * Returns base_amount_canceled + * + * @return float + */ + public function getBaseAmountCanceled() + { + return $this->_get(self::BASE_AMOUNT_CANCELED); + } + + /** + * Returns base_amount_ordered + * + * @return float + */ + public function getBaseAmountOrdered() + { + return $this->_get(self::BASE_AMOUNT_ORDERED); + } + + /** + * Returns base_amount_paid + * + * @return float + */ + public function getBaseAmountPaid() + { + return $this->_get(self::BASE_AMOUNT_PAID); + } + + /** + * Returns base_amount_paid_online + * + * @return float + */ + public function getBaseAmountPaidOnline() + { + return $this->_get(self::BASE_AMOUNT_PAID_ONLINE); + } + + /** + * Returns base_amount_refunded + * + * @return float + */ + public function getBaseAmountRefunded() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED); + } + + /** + * Returns base_amount_refunded_online + * + * @return float + */ + public function getBaseAmountRefundedOnline() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED_ONLINE); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_captured + * + * @return float + */ + public function getBaseShippingCaptured() + { + return $this->_get(self::BASE_SHIPPING_CAPTURED); + } + + /** + * Returns base_shipping_refunded + * + * @return float + */ + public function getBaseShippingRefunded() + { + return $this->_get(self::BASE_SHIPPING_REFUNDED); + } + + /** + * Returns cc_approval + * + * @return string + */ + public function getCcApproval() + { + return $this->_get(self::CC_APPROVAL); + } + + /** + * Returns cc_avs_status + * + * @return string + */ + public function getCcAvsStatus() + { + return $this->_get(self::CC_AVS_STATUS); + } + + /** + * Returns cc_cid_status + * + * @return string + */ + public function getCcCidStatus() + { + return $this->_get(self::CC_CID_STATUS); + } + + /** + * Returns cc_debug_request_body + * + * @return string + */ + public function getCcDebugRequestBody() + { + return $this->_get(self::CC_DEBUG_REQUEST_BODY); + } + + /** + * Returns cc_debug_response_body + * + * @return string + */ + public function getCcDebugResponseBody() + { + return $this->_get(self::CC_DEBUG_RESPONSE_BODY); + } + + /** + * Returns cc_debug_response_serialized + * + * @return string + */ + public function getCcDebugResponseSerialized() + { + return $this->_get(self::CC_DEBUG_RESPONSE_SERIALIZED); + } + + /** + * Returns cc_exp_month + * + * @return string + */ + public function getCcExpMonth() + { + return $this->_get(self::CC_EXP_MONTH); + } + + /** + * Returns cc_exp_year + * + * @return string + */ + public function getCcExpYear() + { + return $this->_get(self::CC_EXP_YEAR); + } + + /** + * Returns cc_last4 + * + * @return string + */ + public function getCcLast4() + { + return $this->_get(self::CC_LAST4); + } + + /** + * Returns cc_number_enc + * + * @return string + */ + public function getCcNumberEnc() + { + return $this->_get(self::CC_NUMBER_ENC); + } + + /** + * Returns cc_owner + * + * @return string + */ + public function getCcOwner() + { + return $this->_get(self::CC_OWNER); + } + + /** + * Returns cc_secure_verify + * + * @return string + */ + public function getCcSecureVerify() + { + return $this->_get(self::CC_SECURE_VERIFY); + } + + /** + * Returns cc_ss_issue + * + * @return string + */ + public function getCcSsIssue() + { + return $this->_get(self::CC_SS_ISSUE); + } + + /** + * Returns cc_ss_start_month + * + * @return string + */ + public function getCcSsStartMonth() + { + return $this->_get(self::CC_SS_START_MONTH); + } + + /** + * Returns cc_ss_start_year + * + * @return string + */ + public function getCcSsStartYear() + { + return $this->_get(self::CC_SS_START_YEAR); + } + + /** + * Returns cc_status + * + * @return string + */ + public function getCcStatus() + { + return $this->_get(self::CC_STATUS); + } + + /** + * Returns cc_status_description + * + * @return string + */ + public function getCcStatusDescription() + { + return $this->_get(self::CC_STATUS_DESCRIPTION); + } + + /** + * Returns cc_trans_id + * + * @return string + */ + public function getCcTransId() + { + return $this->_get(self::CC_TRANS_ID); + } + + /** + * Returns cc_type + * + * @return string + */ + public function getCcType() + { + return $this->_get(self::CC_TYPE); + } + + /** + * Returns echeck_account_name + * + * @return string + */ + public function getEcheckAccountName() + { + return $this->_get(self::ECHECK_ACCOUNT_NAME); + } + + /** + * Returns echeck_account_type + * + * @return string + */ + public function getEcheckAccountType() + { + return $this->_get(self::ECHECK_ACCOUNT_TYPE); + } + + /** + * Returns echeck_bank_name + * + * @return string + */ + public function getEcheckBankName() + { + return $this->_get(self::ECHECK_BANK_NAME); + } + + /** + * Returns echeck_routing_number + * + * @return string + */ + public function getEcheckRoutingNumber() + { + return $this->_get(self::ECHECK_ROUTING_NUMBER); + } + + /** + * Returns echeck_type + * + * @return string + */ + public function getEcheckType() + { + return $this->_get(self::ECHECK_TYPE); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns last_trans_id + * + * @return string + */ + public function getLastTransId() + { + return $this->_get(self::LAST_TRANS_ID); + } + + /** + * Returns method + * + * @return string + */ + public function getMethod() + { + return $this->_get(self::METHOD); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns po_number + * + * @return string + */ + public function getPoNumber() + { + return $this->_get(self::PO_NUMBER); + } + + /** + * Returns protection_eligibility + * + * @return string + */ + public function getProtectionEligibility() + { + return $this->_get(self::PROTECTION_ELIGIBILITY); + } + + /** + * Returns quote_payment_id + * + * @return int + */ + public function getQuotePaymentId() + { + return $this->_get(self::QUOTE_PAYMENT_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_captured + * + * @return float + */ + public function getShippingCaptured() + { + return $this->_get(self::SHIPPING_CAPTURED); + } + + /** + * Returns shipping_refunded + * + * @return float + */ + public function getShippingRefunded() + { + return $this->_get(self::SHIPPING_REFUNDED); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php b/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php new file mode 100644 index 00000000000..4e22c6f7bf3 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.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; + +use Magento\Framework\Service\Data\AbstractObject as DataObject; + +/** + * Class OrderStatusHistory + */ +class OrderStatusHistory extends DataObject +{ + const ENTITY_ID = 'entity_id'; + const PARENT_ID = 'parent_id'; + const IS_CUSTOMER_NOTIFIED = 'is_customer_notified'; + const IS_VISIBLE_ON_FRONT = 'is_visible_on_front'; + const COMMENT = 'comment'; + const STATUS = 'status'; + const CREATED_AT = 'created_at'; + const ENTITY_NAME = 'entity_name'; + + /** + * 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 entity_name + * + * @return string + */ + public function getEntityName() + { + return $this->_get(self::ENTITY_NAME); + } + + /** + * 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); + } + + /** + * Returns status + * + * @return string + */ + public function getStatus() + { + return $this->_get(self::STATUS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Shipment.php b/app/code/Magento/Sales/Service/V1/Data/Shipment.php new file mode 100644 index 00000000000..814b6472c93 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Shipment.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\Service\V1\Data; + +use Magento\Framework\Service\Data\AbstractObject as DataObject; + +/** + * Class Shipment + */ +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'; + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns packages + * + * @return string + */ + public function getPackages() + { + return $this->_get(self::PACKAGES); + } + + /** + * Returns shipment_status + * + * @return int + */ + public function getShipmentStatus() + { + return $this->_get(self::SHIPMENT_STATUS); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_label + * + * @return string + */ + public function getShippingLabel() + { + return $this->_get(self::SHIPPING_LABEL); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns total_qty + * + * @return float + */ + public function getTotalQty() + { + return $this->_get(self::TOTAL_QTY); + } + + /** + * Returns total_weight + * + * @return float + */ + public function getTotalWeight() + { + return $this->_get(self::TOTAL_WEIGHT); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php new file mode 100644 index 00000000000..4c5eb9f556a --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php @@ -0,0 +1,213 @@ +<?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 ShipmentItem + */ +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'; + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php new file mode 100644 index 00000000000..5038db1869f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php @@ -0,0 +1,198 @@ +<?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 ShipmentTrack + */ +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'; + + /** + * Returns carrier_code + * + * @return string + */ + public function getCarrierCode() + { + return $this->_get(self::CARRIER_CODE); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns title + * + * @return string + */ + public function getTitle() + { + return $this->_get(self::TITLE); + } + + /** + * Returns track_number + * + * @return string + */ + public function getTrackNumber() + { + return $this->_get(self::TRACK_NUMBER); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php b/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php new file mode 100644 index 00000000000..0ee239faf42 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.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\Sales\Service\V1; + +use Magento\Sales\Model\Order\AddressConverter; +use Magento\Sales\Service\V1\Data\OrderAddress; + +/** + * Class OrderAddressUpdate + */ +class OrderAddressUpdate implements OrderAddressUpdateInterface +{ + /** + * @var AddressConverter + */ + protected $addressConverter; + + /** + * @param AddressConverter $addressConverter + */ + public function __construct( + AddressConverter $addressConverter + ) { + $this->addressConverter = $addressConverter; + } + + /** + * Invoke order address update service + * + * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress + * @return bool + */ + public function invoke(OrderAddress $orderAddress) + { + $orderAddressModel = $this->addressConverter->getModel($orderAddress); + return (bool)$orderAddressModel->save(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php b/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php new file mode 100644 index 00000000000..16237cbe85e --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php @@ -0,0 +1,40 @@ +<?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; + +/** + * 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); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCancel.php b/app/code/Magento/Sales/Service/V1/OrderCancel.php new file mode 100644 index 00000000000..a1fd9a36bd6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCancel.php @@ -0,0 +1,58 @@ +<?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\Model\OrderRepository; +use Magento\Sales\Service\V1\Data\OrderMapper; + +/** + * Class OrderCancel + */ +class OrderCancel implements OrderCancelInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @param OrderRepository $orderRepository + */ + public function __construct(OrderRepository $orderRepository) + { + $this->orderRepository = $orderRepository; + } + + /** + * Invoke getOrder service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->cancel(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php b/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php new file mode 100644 index 00000000000..6fcdae3e147 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php @@ -0,0 +1,39 @@ +<?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; + +/** + * Interface OrderCancelInterface + */ +interface OrderCancelInterface +{ + /** + * Invoke getOrder service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCommentsList.php b/app/code/Magento/Sales/Service/V1/OrderCommentsList.php new file mode 100644 index 00000000000..4d202befae6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCommentsList.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; + +use Magento\Sales\Model\Order\Status\HistoryRepository; +use Magento\Sales\Service\V1\Data\OrderStatusHistoryMapper; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Framework\Service\V1\Data\FilterBuilder; +use Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResultsBuilder; + +/** + * Class OrderCommentsList + */ +class OrderCommentsList implements OrderCommentsListInterface +{ + /** + * @var HistoryRepository + */ + protected $historyRepository; + + /** + * @var OrderStatusHistoryMapper + */ + protected $historyMapper; + + /** + * @var SearchCriteriaBuilder + */ + protected $criteriaBuilder; + + /** + * @var FilterBuilder + */ + protected $filterBuilder; + + /** + * @var OrderStatusHistorySearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param HistoryRepository $historyRepository + * @param OrderStatusHistoryMapper $historyMapper + * @param SearchCriteriaBuilder $criteriaBuilder + * @param FilterBuilder $filterBuilder + * @param OrderStatusHistorySearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + HistoryRepository $historyRepository, + OrderStatusHistoryMapper $historyMapper, + SearchCriteriaBuilder $criteriaBuilder, + FilterBuilder $filterBuilder, + OrderStatusHistorySearchResultsBuilder $searchResultsBuilder + ) { + $this->historyRepository = $historyRepository; + $this->historyMapper = $historyMapper; + $this->criteriaBuilder = $criteriaBuilder; + $this->filterBuilder = $filterBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke OrderCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResults + */ + public function invoke($id) + { + $this->criteriaBuilder->addFilter( + ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + ); + $criteria = $this->criteriaBuilder->create(); + $comments = []; + foreach ($this->historyRepository->find($criteria) as $comment) { + $comments[] = $this->historyMapper->extractDto($comment); + } + return $this->searchResultsBuilder->setItems($comments) + ->setSearchCriteria($criteria) + ->setTotalCount(count($comments)) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php b/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php new file mode 100644 index 00000000000..64de1d90067 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php @@ -0,0 +1,38 @@ +<?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; + +/** + * Interface OrderCommentsListInterface + */ +interface OrderCommentsListInterface +{ + /** + * Invoke OrderCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResults + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderGet.php b/app/code/Magento/Sales/Service/V1/OrderGet.php new file mode 100644 index 00000000000..0fe552bd9d4 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderGet.php @@ -0,0 +1,68 @@ +<?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\Model\OrderRepository; +use Magento\Sales\Service\V1\Data\OrderMapper; + +/** + * Class OrderGet + */ +class OrderGet implements OrderGetInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var OrderMapper + */ + protected $orderMapper; + + /** + * @param OrderRepository $orderRepository + * @param OrderMapper $orderMapper + */ + public function __construct( + OrderRepository $orderRepository, + OrderMapper $orderMapper + ) { + $this->orderRepository = $orderRepository; + $this->orderMapper = $orderMapper; + } + + /** + * Invoke getOrder service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Order + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + $order = $this->orderRepository->get($id); + return $this->orderMapper->extractDto($order); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderGetInterface.php b/app/code/Magento/Sales/Service/V1/OrderGetInterface.php new file mode 100644 index 00000000000..edc166d4782 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderGetInterface.php @@ -0,0 +1,39 @@ +<?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; + +/** + * Interface OrderGetInterface + */ +interface OrderGetInterface +{ + /** + * Invoke getOrder service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Order + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id); +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php b/app/code/Magento/Sales/Service/V1/OrderGetStatus.php similarity index 60% rename from dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php rename to app/code/Magento/Sales/Service/V1/OrderGetStatus.php index 1145c5e71ae..cc7b678f8ff 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueStub.php +++ b/app/code/Magento/Sales/Service/V1/OrderGetStatus.php @@ -21,36 +21,39 @@ * @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\Resource\Product\Option; +namespace Magento\Sales\Service\V1; -class ValueStub extends \Magento\Catalog\Model\Resource\Product\Option\Value +use Magento\Sales\Model\OrderRepository; + +/** + * Class OrderGetStatus + */ +class OrderGetStatus implements OrderGetStatusInterface { /** - * Stub parent constructor + * Order repository + * + * @var OrderRepository */ - public function __construct() - { - $this->_connections = array('read' => new MysqlStub(), 'write' => new MysqlStub()); - } + protected $orderRepository; /** - * Save option value price data - * - * @param \Magento\Framework\Model\AbstractModel $object + * @param OrderRepository $orderRepository */ - public function saveValueTitles(\Magento\Framework\Model\AbstractModel $object) + public function __construct(OrderRepository $orderRepository) { - $this->_saveValueTitles($object); + $this->orderRepository = $orderRepository; } /** - * We should stub to not use db + * Retrieve order status by id * - * @param string $tableName + * @param int $id * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function getTable($tableName) + public function invoke($id) { - return $tableName; + return $this->orderRepository->get($id)->getStatus(); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php b/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php new file mode 100644 index 00000000000..821a64129ae --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php @@ -0,0 +1,40 @@ +<?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; + +/** + * Interface OrderGetStatusInterface + * @package Magento\Sales\Service\V1 + */ +interface OrderGetStatusInterface +{ + /** + * Retrieve order status by id + * + * @param int $id + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderHold.php b/app/code/Magento/Sales/Service/V1/OrderHold.php new file mode 100644 index 00000000000..0f3500d71a6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderHold.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\Model\OrderRepository; + +/** + * Class OrderHold + */ +class OrderHold implements OrderHoldInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @param OrderRepository $orderRepository + */ + public function __construct(OrderRepository $orderRepository) + { + $this->orderRepository = $orderRepository; + } + + /** + * Invoke orderHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->hold(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php b/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php new file mode 100644 index 00000000000..0ba9ba3733c --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php @@ -0,0 +1,39 @@ +<?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; + +/** + * Interface OrderHoldInterface + */ +interface OrderHoldInterface +{ + /** + * Invoke orderHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderList.php b/app/code/Magento/Sales/Service/V1/OrderList.php new file mode 100644 index 00000000000..a8afa33b3df --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderList.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; + +use Magento\Sales\Model\OrderRepository; +use Magento\Sales\Service\V1\Data\OrderMapper; +use Magento\Sales\Service\V1\Data\OrderSearchResultsBuilder; +use Magento\Framework\Service\V1\Data\SearchCriteria; + +/** + * Class OrderList + */ +class OrderList implements OrderListInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var OrderMapper + */ + protected $orderMapper; + + /** + * @var OrderSearchResultsBuilder + */ + protected $searchResultsBuilder; + + /** + * @param OrderRepository $orderRepository + * @param OrderMapper $orderMapper + * @param OrderSearchResultsBuilder $searchResultsBuilder + */ + public function __construct( + OrderRepository $orderRepository, + OrderMapper $orderMapper, + OrderSearchResultsBuilder $searchResultsBuilder + ) { + $this->orderRepository = $orderRepository; + $this->orderMapper = $orderMapper; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke OrderList service + * + * @param SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria) + { + $orders = []; + foreach ($this->orderRepository->find($searchCriteria) as $order) { + $orders[] = $this->orderMapper->extractDto($order); + } + return $this->searchResultsBuilder->setItems($orders) + ->setTotalCount(count($order)) + ->setSearchCriteria($searchCriteria) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderListInterface.php b/app/code/Magento/Sales/Service/V1/OrderListInterface.php new file mode 100644 index 00000000000..508fd35e1f5 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderListInterface.php @@ -0,0 +1,40 @@ +<?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 OrderListInterface + */ +interface OrderListInterface +{ + /** + * Invoke OrderList service + * + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria + * @return \Magento\Catalog\Service\V1\Data\Product\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria); +} diff --git a/app/code/Magento/Webapi/Controller/Login/Anonymous.php b/app/code/Magento/Sales/Service/V1/OrderNotifyUser.php similarity index 54% rename from app/code/Magento/Webapi/Controller/Login/Anonymous.php rename to app/code/Magento/Sales/Service/V1/OrderNotifyUser.php index 2cbfa8ee235..433a3c359a6 100644 --- a/app/code/Magento/Webapi/Controller/Login/Anonymous.php +++ b/app/code/Magento/Sales/Service/V1/OrderNotifyUser.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,41 +21,47 @@ * @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\Login; +namespace Magento\Sales\Service\V1; -use Magento\Authz\Model\UserIdentifier; +use Magento\Sales\Model\OrderRepository; -class Anonymous extends \Magento\Framework\App\Action\Action +/** + * Class OrderNotifyUser + */ +class OrderNotifyUser implements OrderNotifyUserInterface { /** - * @var \Magento\Framework\Session\Generic + * @var OrderRepository */ - protected $session; + protected $orderRepository; /** - * Initialize Login Service - * - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Session\Generic $session + * @var \Magento\Sales\Model\Notifier + */ + protected $notifier; + + /** + * @param OrderRepository $orderRepository + * @param \Magento\Sales\Model\Notifier $notifier */ public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Session\Generic $session + OrderRepository $orderRepository, + \Magento\Sales\Model\Notifier $notifier ) { - parent::__construct($context); - $this->session = $session; + $this->orderRepository = $orderRepository; + $this->notifier = $notifier; } /** - * Initiate a session for unregistered users. Send back the session id. + * Invoke notifyUser service * - * @return void + * @param int $id + * @return bool */ - public function execute() + public function invoke($id) { - $this->session->start('frontend'); - $this->session->setUserId(0); - $this->session->setUserType(UserIdentifier::USER_TYPE_GUEST); - $this->session->regenerateId(true); + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->orderRepository->get($id); + return $this->notifier->notify($order); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php b/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php new file mode 100644 index 00000000000..2ed67edf6cc --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php @@ -0,0 +1,38 @@ +<?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 OrderNotifyUser + */ +interface OrderNotifyUserInterface +{ + /** + * Invoke notifyUser service + * + * @param int $id + * @return bool + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php new file mode 100644 index 00000000000..95188ae734f --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAdd.php @@ -0,0 +1,72 @@ +<?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\Model\OrderRepository; +use Magento\Sales\Model\Order\Status\HistoryConverter; +use Magento\Sales\Service\V1\Data\OrderStatusHistory; + +/** + * Class OrderStatusHistoryAdd + * @package Magento\Sales\Service\V1 + */ +class OrderStatusHistoryAdd implements OrderStatusHistoryAddInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var HistoryConverter + */ + protected $historyConverter; + + /** + * @param OrderRepository $orderRepository + * @param HistoryConverter $historyConverter + */ + public function __construct( + OrderRepository $orderRepository, + HistoryConverter $historyConverter + ) { + $this->orderRepository = $orderRepository; + $this->historyConverter = $historyConverter; + } + + /** + * Invoke service + * + * @param int $id + * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory + * @return bool + */ + public function invoke($id, OrderStatusHistory $statusHistory) + { + $order = $this->orderRepository->get($id); + $order->addStatusHistory($this->historyConverter->getModel($statusHistory)); + $order->save(); + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php new file mode 100644 index 00000000000..d02279df3f8 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php @@ -0,0 +1,42 @@ +<?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\OrderStatusHistory; + +/** + * Interface OrderCommentsAddInterface + * @package Magento\Sales\Service\V1 + */ +interface OrderStatusHistoryAddInterface +{ + /** + * Invoke service + * + * @param int $id + * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory + * @return bool + */ + public function invoke($id, OrderStatusHistory $statusHistory); +} diff --git a/app/code/Magento/Sales/Service/V1/OrderUnHold.php b/app/code/Magento/Sales/Service/V1/OrderUnHold.php new file mode 100644 index 00000000000..d25ace68310 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderUnHold.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\Model\OrderRepository; + +/** + * Class OrderUnHold + */ +class OrderUnHold implements OrderUnHoldInterface +{ + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @param OrderRepository $orderRepository + */ + public function __construct(OrderRepository $orderRepository) + { + $this->orderRepository = $orderRepository; + } + + /** + * Invoke orderUnHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->unhold(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php b/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php new file mode 100644 index 00000000000..720df5f28b4 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php @@ -0,0 +1,39 @@ +<?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; + +/** + * Interface OrderUnHoldInterface + */ +interface OrderUnHoldInterface +{ + /** + * Invoke orderUnHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id); +} diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index 6fe30a6d47a..3fc154834cc 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -2,32 +2,32 @@ "name": "magento/module-sales", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-rss": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-rss": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/etc/adminhtml/acl.xml b/app/code/Magento/Sales/etc/acl.xml similarity index 97% rename from app/code/Magento/Sales/etc/adminhtml/acl.xml rename to app/code/Magento/Sales/etc/acl.xml index b92215e664f..1edf5830afe 100644 --- a/app/code/Magento/Sales/etc/adminhtml/acl.xml +++ b/app/code/Magento/Sales/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 3dbae800e8d..991b5f78ecf 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -24,7 +24,17 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Sales\Model\Resource\Report" shared="false" /> + <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"/> + <type name="Magento\Sales\Model\Resource\Report" shared="false"/> <type name="Magento\Sales\Model\Order\Pdf\Config\Reader"> <arguments> <argument name="fileName" xsi:type="string">pdf.xml</argument> diff --git a/app/code/Magento/Sales/etc/webapi.xml b/app/code/Magento/Sales/etc/webapi.xml new file mode 100644 index 00000000000..fa435cb99b5 --- /dev/null +++ b/app/code/Magento/Sales/etc/webapi.xml @@ -0,0 +1,88 @@ +<?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) + */ +--> +<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"/> + <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"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/orders" method="GET"> + <service class="Magento\Sales\Service\V1\OrderListInterface" method="invoke"/> + <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"/> + <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"/> + <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"/> + <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"/> + <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"/> + <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"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> + <route url="/V1/orders/:id" method="PUT"> + <service class="Magento\Sales\Service\V1\OrderAddressUpdateInterface" method="invoke"/> + <resources> + <resource ref="Magento_Sales::sales" /> + </resources> + </route> +</routes> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml index 66827244033..cc6aec52007 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml @@ -21,8 +21,9 @@ * @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\Adminhtml\Order\Create\Form $this */ ?> -<form id="edit_form" data-order-config="<?php echo $this->getOrderDataJson() ?>" data-load-base-url="<?php echo $this->getLoadBlockUrl() ?>" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data"> +<form id="edit_form" data-order-config='<?php echo $this->getOrderDataJson() ?>' data-load-base-url="<?php echo $this->getLoadBlockUrl() ?>" action="<?php echo $this->getSaveUrl() ?>" method="post" enctype="multipart/form-data"> <?php echo $this->getBlockHtml('formkey')?> <div id="order-message"> <?php echo $this->getChildHtml('message') ?> diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js index b833d6459ae..9edde1d0be6 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js @@ -35,7 +35,7 @@ define([ return; } - config = $el.data('order-config'), + config = $el.data('order-config'); baseUrl = $el.data('load-base-url'); order = new AdminOrder(config); diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index ef588070405..ea69f6635dd 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -25,9 +25,6 @@ <?php $_orders = $this->getOrders(); ?> <?php echo $this->getChildHtml('info');?> <?php if($_orders->getSize()): ?> - <?php if ($this->getPagerHtml()): ?> - <div class="order-products-toolbar toolbar top"><?php echo $this->getPagerHtml(); ?></div> - <?php endif ?> <div class="table-wrapper orders-history"> <table class="data table table-order-items history" id="my-orders-table"> <caption class="table caption"><?php echo __('Orders') ?></caption> diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 5881306da23..5c5e2f7a787 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -2,28 +2,28 @@ "name": "magento/module-sales-rule", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-rule": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-rule": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/SalesRule/etc/adminhtml/acl.xml b/app/code/Magento/SalesRule/etc/acl.xml similarity index 95% rename from app/code/Magento/SalesRule/etc/adminhtml/acl.xml rename to app/code/Magento/SalesRule/etc/acl.xml index b23b3d35206..f11abdd7371 100644 --- a/app/code/Magento/SalesRule/etc/adminhtml/acl.xml +++ b/app/code/Magento/SalesRule/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index ce7c55ff294..2f7f51b67ec 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-sendfriend", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "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 d69935e42ce..6807412a6a5 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class AddComment extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ class AddComment 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 + \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -73,7 +82,8 @@ class AddComment extends \Magento\Backend\App\Action isset($data['is_customer_notified']), isset($data['is_visible_on_front']) ); - $shipment->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->shipmentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']); $shipment->save(); $this->_view->loadLayout(false); 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 13365a26921..62af1f58827 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use \Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class Email extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ 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 + \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -63,7 +72,9 @@ class Email extends \Magento\Backend\App\Action try { $shipment = $this->shipmentLoader->load($this->_request); if ($shipment) { - $shipment->sendEmail(true)->setEmailSent(true)->save(); + $this->shipmentSender->send($shipment, true); + $shipment->save(); + $historyItem = $this->_objectManager->create( 'Magento\Sales\Model\Resource\Order\Status\History\Collection' )->getUnnotifiedForInstance( 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 a8e1ef00367..8bdd3ed7fca 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use \Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class Save extends \Magento\Backend\App\Action { @@ -38,18 +39,26 @@ class Save extends \Magento\Backend\App\Action */ protected $labelGenerator; + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader * @param \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, - \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator + \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; $this->labelGenerator = $labelGenerator; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -128,7 +137,7 @@ class Save extends \Magento\Backend\App\Action $this->_saveShipment($shipment); - $shipment->sendEmail(!empty($data['send_email']), $comment); + $this->shipmentSender->send($shipment, !empty($data['send_email']), $comment); $shipmentCreatedMessage = __('The shipment has been created.'); $labelCreatedMessage = __('You created the shipping label.'); diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 6e53c76cf9d..fc4e89cab74 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -2,24 +2,24 @@ "name": "magento/module-shipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-contact": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-contact": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/etc/adminhtml/acl.xml b/app/code/Magento/Shipping/etc/acl.xml similarity index 94% rename from app/code/Magento/Shipping/etc/adminhtml/acl.xml rename to app/code/Magento/Shipping/etc/acl.xml index 277cd0ce9f7..fd54affe77e 100644 --- a/app/code/Magento/Shipping/etc/adminhtml/acl.xml +++ b/app/code/Magento/Shipping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 8e78eedc06c..11958116c04 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-sitemap", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/etc/adminhtml/acl.xml b/app/code/Magento/Sitemap/etc/acl.xml similarity index 95% rename from app/code/Magento/Sitemap/etc/adminhtml/acl.xml rename to app/code/Magento/Sitemap/etc/acl.xml index 5d5c2b7c7c9..b4684b36496 100644 --- a/app/code/Magento/Sitemap/etc/adminhtml/acl.xml +++ b/app/code/Magento/Sitemap/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index aa8356e9d1a..47e2308ae58 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-store", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-core": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-core": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml b/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml index e076840edbc..19a91b1044d 100644 --- a/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml +++ b/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml @@ -29,19 +29,26 @@ ?> <?php if(count($this->getStores())>1): ?> -<div class="switcher language" data-ui-id="language-switcher"> - <strong class="label"><span><?php echo __('Language') ?></span></strong> - <div class="actions dropdown options"> - <div class="action toggle" id="language-switcher"> +<?php $id = $this->getIdModifier() ? '-' . $this->getIdModifier() : ''?> +<div class="switcher language switcher-language" data-ui-id="language-switcher" id="switcher-language<?php echo $id?>"> + <strong class="label switcher-label"><span><?php echo __('Language') ?></span></strong> + <div class="actions dropdown options switcher-options"> + <div class="action toggle switcher-trigger" id="switcher-language-trigger<?php echo $id?>"> <strong class="view-<?php echo $this->escapeHtml($this->getCurrentStoreCode()) ?>"> <span><?php echo $this->escapeHtml($this->getStoreName()) ?></span> </strong> </div> - <ul class="dropdown" - data-mage-init='{"dropdownDialog":{"appendTo":".switcher.language > .options", "triggerTarget":"#language-switcher", "closeOnMouseLeave": false, "triggerClass":"active", "parentClass":"active", "buttons":null}}'> + <ul class="dropdown switcher-dropdown" + data-mage-init='{"dropdownDialog":{ + "appendTo":"#switcher-language<?php echo $id ?> > .options", + "triggerTarget":"#switcher-language-trigger<?php echo $id ?>", + "closeOnMouseLeave": false, + "triggerClass":"active", + "parentClass":"active", + "buttons":null}}'> <?php foreach ($this->getStores() as $_lang): ?> <?php if($_lang->getId()!=$this->getCurrentStoreId()): ?> - <li class="view-<?php echo $this->escapeHtml($_lang->getCode()); ?>"> + <li class="view-<?php echo $this->escapeHtml($_lang->getCode()); ?> switcher-option"> <a href="#" data-post='<?php echo $this->getTargetStorePostData($_lang); ?>'> <?php echo $this->escapeHtml($_lang->getName()) ?></a> </li> diff --git a/app/code/Magento/Tax/Model/System/Message/Notifications.php b/app/code/Magento/Tax/Model/System/Message/Notifications.php index 8cc3406820f..97df9ccd5f8 100644 --- a/app/code/Magento/Tax/Model/System/Message/Notifications.php +++ b/app/code/Magento/Tax/Model/System/Message/Notifications.php @@ -26,7 +26,7 @@ namespace Magento\Tax\Model\System\Message; /** * Notifications class */ -class Notifications implements \Magento\AdminNotification\Model\System\MessageInterface +class Notifications implements \Magento\Framework\Notification\MessageInterface { /** * Store manager object @@ -93,7 +93,7 @@ class Notifications implements \Magento\AdminNotification\Model\System\MessageIn * Tax Calculation Method Based On 'Total' or 'Row' * and at least one Price Display Settings has 'Including and Excluding Tax' value * - * @param null|int|bool|string|Store $store $store + * @param null|int|bool|string|\Magento\Store\Model\Store $store $store * @return bool */ public function checkDisplaySettings($store = null) @@ -118,7 +118,7 @@ class Notifications implements \Magento\AdminNotification\Model\System\MessageIn * Before Discount / Excluding Tax * Before Discount / Including Tax * - * @param null|int|bool|string|Store $store $store + * @param null|int|bool|string|\Magento\Store\Model\Store $store $store * @return bool */ public function checkDiscountSettings($store = null) diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php index cf268bc0cb9..95620904354 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php @@ -40,14 +40,14 @@ class TaxClassSearchResultsBuilder extends AbstractSearchResultsBuilder * * @param ObjectFactory $objectFactory * @param SearchCriteriaBuilder $searchCriteriaBuilder - * @param TaxClassBuilder $taxClassObjectBuilder + * @param TaxClassBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, SearchCriteriaBuilder $searchCriteriaBuilder, - TaxClassBuilder $taxClassObjectBuilder + TaxClassBuilder $itemObjectBuilder ) { - parent::__construct($objectFactory, $searchCriteriaBuilder, $taxClassObjectBuilder); + parent::__construct($objectFactory, $searchCriteriaBuilder, $itemObjectBuilder); } /** diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php index 4314ccbcef0..6f595b19e2c 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php @@ -40,14 +40,14 @@ class TaxRateSearchResultsBuilder extends AbstractSearchResultsBuilder * * @param ObjectFactory $objectFactory * @param SearchCriteriaBuilder $searchCriteriaBuilder - * @param TaxRateBuilder $taxRateObjectBuilder + * @param TaxRateBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, SearchCriteriaBuilder $searchCriteriaBuilder, - TaxRateBuilder $taxRateObjectBuilder + TaxRateBuilder $itemObjectBuilder ) { - parent::__construct($objectFactory, $searchCriteriaBuilder, $taxRateObjectBuilder); + parent::__construct($objectFactory, $searchCriteriaBuilder, $itemObjectBuilder); } /** diff --git a/app/code/Magento/Tax/Service/V1/TaxRateService.php b/app/code/Magento/Tax/Service/V1/TaxRateService.php index 2c215d528cf..b2ef9054f71 100644 --- a/app/code/Magento/Tax/Service/V1/TaxRateService.php +++ b/app/code/Magento/Tax/Service/V1/TaxRateService.php @@ -42,6 +42,8 @@ use Magento\Tax\Service\V1\Data\TaxRateBuilder; */ class TaxRateService implements TaxRateServiceInterface { + const MESSAGE_TAX_RATE_ID_IS_NOT_ALLOWED = 'id is not expected for this request.'; + /** * Tax rate model and tax rate data object converter * @@ -101,6 +103,9 @@ class TaxRateService implements TaxRateServiceInterface */ public function createTaxRate(TaxRateDataObject $taxRate) { + if ($taxRate->getId()) { + throw new InputException(self::MESSAGE_TAX_RATE_ID_IS_NOT_ALLOWED); + } $rateModel = $this->saveTaxRate($taxRate); return $this->converter->createTaxRateDataObjectFromModel($rateModel); } diff --git a/app/code/Magento/Tax/Service/V1/TaxRuleService.php b/app/code/Magento/Tax/Service/V1/TaxRuleService.php index 02f2855cb7b..468e2c728fb 100644 --- a/app/code/Magento/Tax/Service/V1/TaxRuleService.php +++ b/app/code/Magento/Tax/Service/V1/TaxRuleService.php @@ -25,11 +25,13 @@ namespace Magento\Tax\Service\V1; use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Model\Exception as ModelException; use Magento\Framework\Service\V1\Data\FilterBuilder; use Magento\Framework\Service\V1\Data\Search\FilterGroup; use Magento\Framework\Service\V1\Data\SearchCriteria; use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Tax\Model\ClassModel as TaxClassModel; use Magento\Tax\Model\Calculation\Rule as TaxRuleModel; use Magento\Tax\Model\Calculation\RuleFactory as TaxRuleModelFactory; use Magento\Tax\Model\Calculation\TaxRuleConverter; @@ -85,6 +87,10 @@ class TaxRuleService implements TaxRuleServiceInterface */ protected $searchCriteriaBuilder; + /** + * @var TaxClassService + */ + protected $taxClassService; /** * @param TaxRuleBuilder $taxRuleBuilder * @param TaxRuleConverter $converter @@ -94,6 +100,7 @@ class TaxRuleService implements TaxRuleServiceInterface * @param FilterBuilder $filterBuilder * @param TaxRateServiceInterface $taxRateService * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param TaxClassService $taxClassService */ public function __construct( TaxRuleBuilder $taxRuleBuilder, @@ -103,7 +110,8 @@ class TaxRuleService implements TaxRuleServiceInterface TaxRuleModelFactory $taxRuleModelFactory, FilterBuilder $filterBuilder, TaxRateServiceInterface $taxRateService, - SearchCriteriaBuilder $searchCriteriaBuilder + SearchCriteriaBuilder $searchCriteriaBuilder, + TaxClassService $taxClassService ) { $this->taxRuleBuilder = $taxRuleBuilder; $this->converter = $converter; @@ -113,6 +121,7 @@ class TaxRuleService implements TaxRuleServiceInterface $this->filterBuilder = $filterBuilder; $this->taxRateService = $taxRateService; $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->taxClassService = $taxClassService; } /** @@ -120,6 +129,11 @@ class TaxRuleService implements TaxRuleServiceInterface */ public function createTaxRule(TaxRule $rule) { + // See if a tax rule with that $rule->getId() is specified. If so, throw an exception. + if (!is_null($rule->getId())) { + throw new InputException('TaxRule ID should not be specified.'); + } + $taxRuleModel = $this->saveTaxRule($rule); return $this->converter->createTaxRuleDataObjectFromModel($taxRuleModel); } @@ -365,14 +379,59 @@ class TaxRuleService implements TaxRuleServiceInterface if (!\Zend_Validate::is(trim($rule->getCode()), 'NotEmpty')) { $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxRule::CODE]); } + // customer tax class ids is required if (($rule->getCustomerTaxClassIds() === null) || !$rule->getCustomerTaxClassIds()) { $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxRule::CUSTOMER_TAX_CLASS_IDS]); + } else { // see if the customer tax class ids exist + $customerTaxClassIds = $rule->getCustomerTaxClassIds(); + foreach ($customerTaxClassIds as $customerTaxClassId) { + try { + $taxClass = $this->taxClassService->getTaxClass($customerTaxClassId); + if (is_null($taxClass) || !($taxClass->getClassType() == TaxClassModel::TAX_CLASS_TYPE_CUSTOMER)) { + $exception->addError( + NoSuchEntityException::MESSAGE_SINGLE_FIELD, + [ + 'fieldName' => TaxRule::CUSTOMER_TAX_CLASS_IDS, + 'value' => $customerTaxClassId, + ] + ); + } + } catch (NoSuchEntityException $e) { + $exception->addError( + $e->getRawMessage(), + $e->getParameters() + ); + } + } } + // product tax class ids is required if (($rule->getProductTaxClassIds() === null) || !$rule->getProductTaxClassIds()) { $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxRule::PRODUCT_TAX_CLASS_IDS]); + } else { // see if the product tax class ids exist + $productTaxClassIds = $rule->getProductTaxClassIds(); + foreach ($productTaxClassIds as $productTaxClassId) { + try { + $taxClass = $this->taxClassService->getTaxClass($productTaxClassId); + if (is_null($taxClass) || !($taxClass->getClassType() == TaxClassModel::TAX_CLASS_TYPE_PRODUCT)) { + $exception->addError( + NoSuchEntityException::MESSAGE_SINGLE_FIELD, + [ + 'fieldName' => TaxRule::PRODUCT_TAX_CLASS_IDS, + 'value' => $productTaxClassId, + ] + ); + } + } catch (NoSuchEntityException $e) { + $exception->addError( + $e->getRawMessage(), + $e->getParameters() + ); + } + } } + // tax rate ids is required if (($rule->getTaxRateIds() === null) || !$rule->getTaxRateIds()) { $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxRule::TAX_RATE_IDS]); diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 1e15ed685b8..c8aeb245caa 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -2,26 +2,25 @@ "name": "magento/module-tax", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-configurable-product": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-configurable-product": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/etc/adminhtml/acl.xml b/app/code/Magento/Tax/etc/acl.xml similarity index 95% rename from app/code/Magento/Tax/etc/adminhtml/acl.xml rename to app/code/Magento/Tax/etc/acl.xml index 2f84eb4523a..73edcc94e71 100644 --- a/app/code/Magento/Tax/etc/adminhtml/acl.xml +++ b/app/code/Magento/Tax/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Tax/etc/adminhtml/di.xml b/app/code/Magento/Tax/etc/adminhtml/di.xml index 16e2bb8fa3c..e9f0c198cfb 100644 --- a/app/code/Magento/Tax/etc/adminhtml/di.xml +++ b/app/code/Magento/Tax/etc/adminhtml/di.xml @@ -24,11 +24,11 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\AdminNotification\Model\System\MessageList"> + <type name="Magento\Framework\Notification\MessageList"> <arguments> <argument name="messages" xsi:type="array"> <item name="tax" xsi:type="string">Magento\Tax\Model\System\Message\Notifications</item> </argument> </arguments> </type> -</config> \ No newline at end of file +</config> diff --git a/app/code/Magento/Tax/etc/module.xml b/app/code/Magento/Tax/etc/module.xml index 1d69d97aeef..01f07f004fb 100644 --- a/app/code/Magento/Tax/etc/module.xml +++ b/app/code/Magento/Tax/etc/module.xml @@ -44,7 +44,6 @@ <module name="Magento_Reports"/> <module name="Magento_Theme"/> <module name="Magento_ConfigurableProduct"/> - <module name="Magento_AdminNotification"/> </depends> </module> </config> diff --git a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php index 085c2db5a98..dcaa10f21c2 100644 --- a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php +++ b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.4-1.6.0.5.php @@ -26,7 +26,7 @@ $installer = $this; $connection = $installer->getConnection(); -$adminRuleTable = $installer->getTable('admin_rule'); +$adminRuleTable = $installer->getTable('authorization_rule'); $aclRulesDelete = array( 'Magento_Tax::classes_customer', 'Magento_Tax::classes_product', diff --git a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.5-1.6.0.6.php b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.5-1.6.0.6.php index 580eecb848c..b054b82c416 100644 --- a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.5-1.6.0.6.php +++ b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.5-1.6.0.6.php @@ -28,7 +28,7 @@ $installer = $this; $connection = $installer->getConnection(); -$adminRuleTable = $installer->getTable('admin_rule'); +$adminRuleTable = $installer->getTable('authorization_rule'); $aclRulesDelete = array( 'Magento_Tax::classes_customer', 'Magento_Tax::classes_product', diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 3fbcd123752..d67905d325b 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-theme", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-translation": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-translation": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/etc/adminhtml/acl.xml b/app/code/Magento/Theme/etc/acl.xml similarity index 93% rename from app/code/Magento/Theme/etc/adminhtml/acl.xml rename to app/code/Magento/Theme/etc/acl.xml index a0c5dab927e..9758d483ae3 100644 --- a/app/code/Magento/Theme/etc/adminhtml/acl.xml +++ b/app/code/Magento/Theme/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/block.phtml b/app/code/Magento/Theme/view/frontend/templates/html/block.phtml index 463f95fc6d7..5f1610dd8c1 100644 --- a/app/code/Magento/Theme/view/frontend/templates/html/block.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/html/block.phtml @@ -23,8 +23,8 @@ */ ?> <div class="block <?php echo $this->getBlockCss(); ?>"> - <div class="title"><strong><?php echo $this->getBlockTitle(); ?></strong></div> - <div class="content"> + <div class="block-title <?php echo $this->getBlockCss(); ?>-title"><strong><?php echo $this->getBlockTitle(); ?></strong></div> + <div class="block-content <?php echo $this->getBlockCss(); ?>-content"> <?php echo $this->getChildHtml(); ?> </div> </div> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/collapsible.phtml b/app/code/Magento/Theme/view/frontend/templates/html/collapsible.phtml new file mode 100644 index 00000000000..a8feba22839 --- /dev/null +++ b/app/code/Magento/Theme/view/frontend/templates/html/collapsible.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) + */ +?> + +<div class="block <?php echo $this->getBlockCss(); ?>"> + <div class="title <?php echo $this->getBlockCss();?>-title" data-mage-init='{"toggleAdvanced": {"toggleContainers": "#<?php echo $this->getBlockCss(); ?>", "selectorsToggleClass": "active"}}'> + <strong><?php echo $this->getBlockTitle(); ?></strong> + </div> + <div class="content <?php echo $this->getBlockCss(); ?>-content" id="<?php echo $this->getBlockCss(); ?>"> + <?php echo $this->getChildHtml(); ?> + </div> +</div> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/container.phtml b/app/code/Magento/Theme/view/frontend/templates/html/container.phtml new file mode 100644 index 00000000000..51ad97036bb --- /dev/null +++ b/app/code/Magento/Theme/view/frontend/templates/html/container.phtml @@ -0,0 +1,25 @@ +<?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 echo $this->getChildHtml(); ?> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml index 3da19c109af..3131cc747d5 100644 --- a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml @@ -28,7 +28,7 @@ <?php switch($this->getShowPart()): case 'logo': ?> <?php $storeName = $this->getThemeName() ? $this->getThemeName() : $this->getLogoAlt();?> - <span data-action="toggle-nav" class="action toggle nav"><?php echo __('Toggle Nav') ?></span> + <span data-action="toggle-nav" class="action nav-toggle"><span><?php echo __('Toggle Nav') ?></span></span> <?php if ($this->isHomePage()):?> <strong class="logo"> <img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/sections.phtml b/app/code/Magento/Theme/view/frontend/templates/html/sections.phtml new file mode 100644 index 00000000000..d4c07237e8d --- /dev/null +++ b/app/code/Magento/Theme/view/frontend/templates/html/sections.phtml @@ -0,0 +1,53 @@ +<?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 + +/** +* General template for displaying group of blocks devided into sections +*/ + +$group = $this->getGroupName(); +$groupCss = $this->getGroupCss(); +$groupBehavior = $this->getGroupBehaviour() ? $this->getGroupBehaviour() : '{"tabs":{"openedState":"active"}}'; +?> +<?php if ($detailedInfoGroup = $this->getGroupChildNames($group, 'getChildHtml')):?> + <div class="sections <?php echo $groupCss ?>"> + <?php $layout = $this->getLayout(); ?> + <div class="section-items <?php echo $groupCss ?>-items" data-mage-init='<?php echo $groupBehavior ?>'> + <?php foreach ($detailedInfoGroup as $name):?> + <?php + $html = $layout->renderElement($name); + if (!trim($html) && ($this->getUseForce() != true)) continue; + $alias = $layout->getElementAlias($name); + $label = $this->getChildData($alias, 'title'); + ?> + <div class="section-item-title <?php echo $groupCss ?>-item-title" data-role="collapsible"> + <a class="<?php echo $groupCss ?>-item-switch" data-toggle="switch" href="#<?php echo $alias; ?>"><?php echo $label; ?></a> + </div> + <div class="section-item-content <?php echo $groupCss ?>-item-content" id="<?php echo $alias; ?>" data-role="content"><?php echo $html; ?></div> + <?php endforeach;?> + </div> + </div> +<?php endif; ?> diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index cffec76d78c..400b266e4c5 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-translation", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-core": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-core": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 36a24ede430..19eded9e999 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -2,19 +2,19 @@ "name": "magento/module-ups", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/composer.json b/app/code/Magento/UrlRedirect/composer.json index 30615273b95..6a171dcaeeb 100644 --- a/app/code/Magento/UrlRedirect/composer.json +++ b/app/code/Magento/UrlRedirect/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-url-redirect", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-install": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89" + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-install": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/etc/adminhtml/acl.xml b/app/code/Magento/UrlRedirect/etc/acl.xml similarity index 93% rename from app/code/Magento/UrlRedirect/etc/adminhtml/acl.xml rename to app/code/Magento/UrlRedirect/etc/acl.xml index 8f2d7946e10..ae933a12f82 100644 --- a/app/code/Magento/UrlRedirect/etc/adminhtml/acl.xml +++ b/app/code/Magento/UrlRedirect/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index d8eb8310eda..ddbfb0b1570 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-url-rewrite", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/User/Block/Role/Grid/User.php b/app/code/Magento/User/Block/Role/Grid/User.php index d53d4aea438..df1ce7c73e2 100644 --- a/app/code/Magento/User/Block/Role/Grid/User.php +++ b/app/code/Magento/User/Block/Role/Grid/User.php @@ -40,7 +40,7 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended /** * Factory for user role model * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; @@ -49,12 +49,18 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended */ protected $_jsonEncoder; + /** + * @var \Magento\User\Model\Resource\Role\User\CollectionFactory + */ + protected $_userRolesFactory; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\User\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory + * @param \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory * @param array $data */ public function __construct( @@ -62,13 +68,15 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended \Magento\Backend\Helper\Data $backendHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Framework\Registry $coreRegistry, - \Magento\User\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, + \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory, array $data = [] ) { parent::__construct($context, $backendHelper, $data); $this->_jsonEncoder = $jsonEncoder; $this->_coreRegistry = $coreRegistry; $this->_roleFactory = $roleFactory; + $this->_userRolesFactory = $userRolesFactory; } /** @@ -116,7 +124,7 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended { $roleId = $this->getRequest()->getParam('rid'); $this->_coreRegistry->register('RID', $roleId); - $collection = $this->_roleFactory->create()->getUsersCollection(); + $collection = $this->_userRolesFactory->create(); $this->setCollection($collection); return parent::_prepareCollection(); } diff --git a/app/code/Magento/User/Block/Role/Tab/Edit.php b/app/code/Magento/User/Block/Role/Tab/Edit.php index 91c37d137b6..f17c16b05b5 100644 --- a/app/code/Magento/User/Block/Role/Tab/Edit.php +++ b/app/code/Magento/User/Block/Role/Tab/Edit.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) */ + namespace Magento\User\Block\Role\Tab; /** @@ -45,16 +46,16 @@ class Edit extends \Magento\Backend\Block\Widget\Form implements \Magento\Backen /** * Rules collection factory * - * @var \Magento\User\Model\Resource\Rules\CollectionFactory + * @var \Magento\Authorization\Model\Resource\Rules\CollectionFactory */ protected $_rulesCollectionFactory; /** * Acl builder * - * @var \Magento\Framework\Acl\Builder + * @var \Magento\Authorization\Model\Acl\AclRetriever */ - protected $_aclBuilder; + protected $_aclRetriever; /** * Acl resource provider @@ -69,8 +70,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form implements \Magento\Backen /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Acl\RootResource $rootResource - * @param \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory - * @param \Magento\Framework\Acl\Builder $aclBuilder + * @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory + * @param \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever * @param \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider * @param \Magento\Integration\Helper\Data $integrationData * @param array $data @@ -78,13 +79,13 @@ class Edit extends \Magento\Backend\Block\Widget\Form implements \Magento\Backen public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Acl\RootResource $rootResource, - \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, - \Magento\Framework\Acl\Builder $aclBuilder, + \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, + \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever, \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider, \Magento\Integration\Helper\Data $integrationData, array $data = array() ) { - $this->_aclBuilder = $aclBuilder; + $this->_aclRetriever = $aclRetriever; $this->_rootResource = $rootResource; $this->_rulesCollectionFactory = $rulesCollectionFactory; $this->_aclResourceProvider = $aclResourceProvider; @@ -142,20 +143,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form implements \Magento\Backen parent::_construct(); $rid = $this->_request->getParam('rid', false); - - $acl = $this->_aclBuilder->getAcl(); - $rulesSet = $this->_rulesCollectionFactory->create()->getByRoles($rid)->load(); - - $selectedResourceIds = array(); - - foreach ($rulesSet->getItems() as $item) { - $itemResourceId = $item->getResource_id(); - if ($acl->has($itemResourceId) && $item->getPermission() == 'allow') { - $selectedResourceIds[] = $itemResourceId; - } - } - - $this->setSelectedResources($selectedResourceIds); + $this->setSelectedResources($this->_aclRetriever->getAllowedResourcesByRole($rid)); } /** diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php index 67a6009f18f..92e784062a3 100644 --- a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php +++ b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php @@ -35,7 +35,7 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended protected $_coreRegistry = null; /** - * @var \Magento\User\Model\Resource\Role\CollectionFactory + * @var \Magento\Authorization\Model\Resource\Role\CollectionFactory */ protected $_userRolesFactory; @@ -48,7 +48,7 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder - * @param \Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory + * @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $userRolesFactory * @param \Magento\Framework\Registry $coreRegistry * @param array $data */ @@ -56,7 +56,7 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, - \Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory, + \Magento\Authorization\Model\Resource\Role\CollectionFactory $userRolesFactory, \Magento\Framework\Registry $coreRegistry, array $data = array() ) { diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role.php b/app/code/Magento/User/Controller/Adminhtml/User/Role.php index 43cace81683..0818ab8e192 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Role.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Role.php @@ -23,7 +23,7 @@ */ namespace Magento\User\Controller\Adminhtml\User; -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; class Role extends \Magento\Backend\App\AbstractAction { @@ -37,7 +37,7 @@ class Role extends \Magento\Backend\App\AbstractAction /** * Factory for user role model * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; @@ -51,7 +51,7 @@ class Role extends \Magento\Backend\App\AbstractAction /** * Rules model factory * - * @var \Magento\User\Model\RulesFactory + * @var \Magento\Authorization\Model\RulesFactory */ protected $_rulesFactory; @@ -65,17 +65,17 @@ class Role extends \Magento\Backend\App\AbstractAction /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\User\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory * @param \Magento\User\Model\UserFactory $userFactory - * @param \Magento\User\Model\RulesFactory $rulesFactory + * @param \Magento\Authorization\Model\RulesFactory $rulesFactory * @param \Magento\Backend\Model\Auth\Session $authSession */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\User\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, \Magento\User\Model\UserFactory $userFactory, - \Magento\User\Model\RulesFactory $rulesFactory, + \Magento\Authorization\Model\RulesFactory $rulesFactory, \Magento\Backend\Model\Auth\Session $authSession ) { parent::__construct($context); @@ -105,7 +105,7 @@ class Role extends \Magento\Backend\App\AbstractAction * Initialize role model by passed parameter in request * * @param string $requestVariable - * @return \Magento\User\Model\Role + * @return \Magento\Authorization\Model\Role */ protected function _initRole($requestVariable = 'rid') { diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php b/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php index ffea14b477a..5959b132da9 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php @@ -24,7 +24,8 @@ */ namespace Magento\User\Controller\Adminhtml\User\Role; -use \Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\UserContextInterface; class SaveRole extends \Magento\User\Controller\Adminhtml\User\Role { @@ -98,13 +99,10 @@ class SaveRole extends \Magento\User\Controller\Adminhtml\User\Role try { $roleName = $this->getRequest()->getParam('rolename', false); - $role->setName( - $roleName - )->setPid( - $this->getRequest()->getParam('parent_id', false) - )->setRoleType( - RoleGroup::ROLE_TYPE - ); + $role->setName($roleName) + ->setPid($this->getRequest()->getParam('parent_id', false)) + ->setRoleType(RoleGroup::ROLE_TYPE) + ->setUserType(UserContextInterface::USER_TYPE_ADMIN); $this->_eventManager->dispatch( 'admin_permissions_role_prepare_save', array('object' => $role, 'request' => $this->getRequest()) diff --git a/app/code/Magento/Authz/Model/UserLocator/Admin.php b/app/code/Magento/User/Model/Authorization/AdminSessionUserContext.php similarity index 83% rename from app/code/Magento/Authz/Model/UserLocator/Admin.php rename to app/code/Magento/User/Model/Authorization/AdminSessionUserContext.php index acdc94d2691..98fe4099bc0 100644 --- a/app/code/Magento/Authz/Model/UserLocator/Admin.php +++ b/app/code/Magento/User/Model/Authorization/AdminSessionUserContext.php @@ -21,16 +21,16 @@ * @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\Authz\Model\UserLocator; -use Magento\Authz\Model\UserLocatorInterface; -use Magento\Authz\Model\UserIdentifier; +namespace Magento\User\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; use Magento\Backend\Model\Auth\Session as AdminSession; /** - * Admin user locator. + * Session-based admin user context */ -class Admin implements UserLocatorInterface +class AdminSessionUserContext implements UserContextInterface { /** * @var AdminSession @@ -52,7 +52,7 @@ class Admin implements UserLocatorInterface */ public function getUserId() { - return $this->_adminSession->hasUser() ? (int)$this->_adminSession->getUser()->getId() : 0; + return $this->_adminSession->hasUser() ? (int)$this->_adminSession->getUser()->getId() : null; } /** @@ -60,6 +60,6 @@ class Admin implements UserLocatorInterface */ public function getUserType() { - return UserIdentifier::USER_TYPE_ADMIN; + return UserContextInterface::USER_TYPE_ADMIN; } } diff --git a/app/code/Magento/Authz/Model/UserIdentifier/Factory.php b/app/code/Magento/User/Model/Plugin/AuthorizationRole.php similarity index 57% rename from app/code/Magento/Authz/Model/UserIdentifier/Factory.php rename to app/code/Magento/User/Model/Plugin/AuthorizationRole.php index 906a7d54179..3dff78a3476 100644 --- a/app/code/Magento/Authz/Model/UserIdentifier/Factory.php +++ b/app/code/Magento/User/Model/Plugin/AuthorizationRole.php @@ -21,43 +21,40 @@ * @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\Authz\Model\UserIdentifier; -use Magento\Framework\ObjectManager; -use Magento\Authz\Model\UserIdentifier; +namespace Magento\User\Model\Plugin; + +use Magento\Authorization\Model\Role; /** - * User identifier factory. + * Plugin for authorization role model */ -class Factory +class AuthorizationRole { - /** - * @var \Magento\Framework\ObjectManager - */ - protected $_objectManager; + /** @var \Magento\User\Model\Resource\User */ + protected $userResourceModel; /** * Initialize dependencies * - * @param ObjectManager $objectManager + * @param \Magento\User\Model\Resource\User $userResourceModel */ - public function __construct(ObjectManager $objectManager) + public function __construct(\Magento\User\Model\Resource\User $userResourceModel) { - $this->_objectManager = $objectManager; + $this->userResourceModel = $userResourceModel; } /** - * Create instance of user identifier. + * Update role users ACL. * - * @param string $userType - * @param int $userId - * @return UserIdentifier + * @param Role $subject + * @param Role $result + * @return Role + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function create($userType, $userId = 0) + public function afterSave(Role $subject, Role $result) { - return $this->_objectManager->create( - 'Magento\Authz\Model\UserIdentifier', - array('userType' => $userType, 'userId' => $userId) - ); + $this->userResourceModel->updateRoleUsersAcl($subject); + return $result; } } diff --git a/app/code/Magento/User/Model/Resource/User.php b/app/code/Magento/User/Model/Resource/User.php index 07ca74f8ae8..407eb9a8876 100644 --- a/app/code/Magento/User/Model/Resource/User.php +++ b/app/code/Magento/User/Model/Resource/User.php @@ -23,8 +23,9 @@ */ namespace Magento\User\Model\Resource; -use Magento\User\Model\Acl\Role\Group as RoleGroup; -use Magento\User\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\UserContextInterface; use Magento\User\Model\User as ModelUser; /** @@ -40,7 +41,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Role model * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; @@ -49,24 +50,32 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected $dateTime; + /** + * Users table + * + * @var string + */ + protected $_usersTable; + /** * Construct * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Acl\CacheInterface $aclCache - * @param \Magento\User\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory * @param \Magento\Framework\Stdlib\DateTime $dateTime */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Acl\CacheInterface $aclCache, - \Magento\User\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, \Magento\Framework\Stdlib\DateTime $dateTime ) { parent::__construct($resource); $this->_aclCache = $aclCache; $this->_roleFactory = $roleFactory; $this->dateTime = $dateTime; + $this->_usersTable = $this->getTable('admin_user'); } /** @@ -149,7 +158,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb $adapter = $this->_getReadAdapter(); $select = $adapter->select(); - $select->from($this->getTable('admin_role'))->where('parent_id > :parent_id')->where('user_id = :user_id'); + $select->from($this->getTable('authorization_role'))->where('parent_id > :parent_id')->where('user_id = :user_id'); $binds = array('parent_id' => 0, 'user_id' => $userId); @@ -200,7 +209,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb public function _clearUserRoles(ModelUser $user) { $conditions = array('user_id = ?' => (int)$user->getId()); - $this->_getWriteAdapter()->delete($this->getTable('admin_role'), $conditions); + $this->_getWriteAdapter()->delete($this->getTable('authorization_role'), $conditions); } /** @@ -213,7 +222,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb protected function _createUserRole($parentId, ModelUser $user) { if ($parentId > 0) { - /** @var \Magento\User\Model\Role $parentRole */ + /** @var \Magento\Authorization\Model\Role $parentRole */ $parentRole = $this->_roleFactory->create()->load($parentId); } else { $role = new \Magento\Framework\Object(); @@ -228,12 +237,13 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb 'sort_order' => 0, 'role_type' => RoleUser::ROLE_TYPE, 'user_id' => $user->getId(), + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => $user->getFirstname() ) ); - $insertData = $this->_prepareDataForTable($data, $this->getTable('admin_role')); - $this->_getWriteAdapter()->insert($this->getTable('admin_role'), $insertData); + $insertData = $this->_prepareDataForTable($data, $this->getTable('authorization_role')); + $this->_getWriteAdapter()->insert($this->getTable('authorization_role'), $insertData); $this->_aclCache->clean(); } } @@ -270,7 +280,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb $conditions = array('user_id = ?' => $uid); $adapter->delete($this->getMainTable(), $conditions); - $adapter->delete($this->getTable('admin_role'), $conditions); + $adapter->delete($this->getTable('authorization_role'), $conditions); } catch (\Magento\Framework\Model\Exception $e) { throw $e; return false; @@ -295,7 +305,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb return array(); } - $table = $this->getTable('admin_role'); + $table = $this->getTable('authorization_role'); $adapter = $this->_getReadAdapter(); $select = $adapter->select()->from( @@ -339,7 +349,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb $condition = array('user_id = ?' => (int)$user->getId(), 'parent_id = ?' => (int)$user->getRoleId()); - $dbh->delete($this->getTable('admin_role'), $condition); + $dbh->delete($this->getTable('authorization_role'), $condition); return $this; } @@ -352,7 +362,7 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb public function roleUserExists(\Magento\Framework\Model\AbstractModel $user) { if ($user->getUserId() > 0) { - $roleTable = $this->getTable('admin_role'); + $roleTable = $this->getTable('authorization_role'); $dbh = $this->_getReadAdapter(); @@ -454,4 +464,25 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb return $userIdentity; } + + /** + * Update role users ACL + * + * @param \Magento\Authorization\Model\Role $role + * @return bool + */ + public function updateRoleUsersAcl(\Magento\Authorization\Model\Role $role) + { + $write = $this->_getWriteAdapter(); + $users = $role->getRoleUsers(); + $rowsCount = 0; + + if (sizeof($users) > 0) { + $bind = array('reload_acl_flag' => 1); + $where = array('user_id IN(?)' => $users); + $rowsCount = $write->update($this->_usersTable, $bind, $where); + } + + return $rowsCount > 0; + } } diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index af20e023055..3d33fe05828 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -23,6 +23,9 @@ */ namespace Magento\User\Model; +use Magento\Backend\Model\Auth\Credential\StorageInterface; +use Magento\Framework\Model\AbstractModel; + /** * Admin user model * @@ -54,7 +57,7 @@ namespace Magento\User\Model; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.LongVariable) */ -class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Backend\Model\Auth\Credential\StorageInterface +class User extends AbstractModel implements StorageInterface { /** * Configuration paths for email templates and identities @@ -80,7 +83,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba /** * Admin role * - * @var \Magento\User\Model\Role + * @var \Magento\Authorization\Model\Role */ protected $_role; @@ -115,7 +118,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba /** * Role model factory * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; @@ -145,7 +148,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba * @param \Magento\User\Helper\Data $userData * @param \Magento\Backend\App\ConfigInterface $config * @param \Magento\Framework\Validator\ObjectFactory $validatorObjectFactory - * @param \Magento\User\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -162,7 +165,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba \Magento\User\Helper\Data $userData, \Magento\Backend\App\ConfigInterface $config, \Magento\Framework\Validator\ObjectFactory $validatorObjectFactory, - \Magento\User\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -225,7 +228,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba $this->_config = $objectManager->get('Magento\Backend\App\ConfigInterface'); $this->_registry = $objectManager->get('Magento\Framework\Registry'); $this->_validatorObject = $objectManager->get('Magento\Framework\Validator\ObjectFactory'); - $this->_roleFactory = $objectManager->get('Magento\User\Model\RoleFactory'); + $this->_roleFactory = $objectManager->get('Magento\Authorization\Model\RoleFactory'); $this->_encryptor = $objectManager->get('Magento\Framework\Encryption\EncryptorInterface'); $this->_transportBuilder = $objectManager->get('Magento\Framework\Mail\Template\TransportBuilder'); $this->_storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); @@ -427,7 +430,7 @@ class User extends \Magento\Framework\Model\AbstractModel implements \Magento\Ba /** * Get admin role model * - * @return \Magento\User\Model\Role + * @return \Magento\Authorization\Model\Role */ public function getRole() { diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index 127bbd4d541..e33b3316815 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -2,48 +2,18 @@ "name": "magento/module-user", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-newsletter": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-backup": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-catalog-search": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-contact": "0.1.0-alpha89", - "magento/module-currency-symbol": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-design-editor": "0.1.0-alpha89", - "magento/module-downloadable": "0.1.0-alpha89", - "magento/module-google-shopping": "0.1.0-alpha89", - "magento/module-import-export": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-integration": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-paypal": "0.1.0-alpha89", - "magento/module-persistent": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-rss": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-sitemap": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-authorization": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-integration": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php b/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php deleted file mode 100644 index 0028ffe4e5d..00000000000 --- a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php +++ /dev/null @@ -1,241 +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) - */ - -/** @var $installer \Magento\Framework\Module\Setup */ -$installer = $this; -$installer->startSetup(); - -$map = array( - 'admin/system/config/feed' => 'Find_Feed::config_feed', - 'admin/catalog/feed' => 'Find_Feed::feed', - 'admin/catalog/feed/import_items' => 'Find_Feed::import_items', - 'admin/catalog/feed/import_products' => 'Find_Feed::import_products', - 'admin/system/adminnotification' => 'Magento_AdminNotification::adminnotification', - 'admin/system/adminnotification/remove' => 'Magento_AdminNotification::adminnotification_remove', - 'admin/system/adminnotification/mark_as_read' => 'Magento_AdminNotification::mark_as_read', - 'admin/system/adminnotification/show_list' => 'Magento_AdminNotification::show_list', - 'admin/system/adminnotification/show_toolbar' => 'Magento_AdminNotification::show_toolbar', - 'admin' => 'Magento_Adminhtml::admin', - 'admin/system/config/advanced' => 'Magento_Adminhtml::advanced', - 'all' => 'Magento_Adminhtml::all', - 'admin/system/cache' => 'Magento_Adminhtml::cache', - 'admin/system/config' => 'Magento_Adminhtml::config', - 'admin/system/config/admin' => 'Magento_Adminhtml::config_admin', - 'admin/system/config/design' => 'Magento_Adminhtml::config_design', - 'admin/system/config/general' => 'Magento_Adminhtml::config_general', - 'admin/system/config/system' => 'Magento_Adminhtml::config_system', - 'admin/system/convert' => 'Magento_Adminhtml::convert', - 'admin/system/config/currency' => 'Magento_Adminhtml::currency', - 'admin/system/extensions/custom' => 'Magento_Adminhtml::custom', - 'admin/dashboard' => 'Magento_Adminhtml::dashboard', - 'admin/system/design' => 'Magento_Adminhtml::design', - 'admin/system/config/dev' => 'Magento_Adminhtml::dev', - 'admin/system/email_template' => 'Magento_Email::template', - 'admin/system/extensions' => 'Magento_Adminhtml::extensions', - 'admin/global_search' => 'Magento_Adminhtml::global_search', - 'admin/system/convert/gui' => 'Magento_Adminhtml::gui', - 'admin/system/extensions/local' => 'Magento_Adminhtml::local', - 'admin/system/myaccount' => 'Magento_Adminhtml::myaccount', - 'admin/system/convert/profiles' => 'Magento_Adminhtml::profiles', - 'admin/system/design/schedule' => 'Magento_Adminhtml::schedule', - 'admin/system/config/sendfriend' => 'Magento_Adminhtml::sendfriend', - 'admin/system/store' => 'Magento_Adminhtml::store', - 'admin/system' => 'Magento_Adminhtml::system', - 'admin/system/tools' => 'Magento_Adminhtml::tools', - 'admin/system/config/trans_email' => 'Magento_Adminhtml::trans_email', - 'admin/system/variable' => 'Magento_Adminhtml::variable', - 'admin/system/config/web' => 'Magento_Adminhtml::web', - 'admin/system/tools/backup' => 'Magento_Backup::backup', - 'admin/system/tools/backup/rollback' => 'Magento_Backup::rollback', - 'admin/catalog/attributes/attributes' => 'Magento_Catalog::attributes_attributes', - 'admin/catalog' => 'Magento_Catalog::catalog', - 'admin/catalog/attributes' => 'Magento_Catalog::catalog_attributes', - 'admin/catalog/categories' => 'Magento_Catalog::categories', - 'admin/system/config/catalog' => 'Magento_Catalog::config_catalog', - 'admin/catalog/products' => 'Magento_Catalog::products', - 'admin/catalog/attributes/sets' => 'Magento_Catalog::sets', - 'admin/catalog/update_attributes' => 'Magento_Catalog::update_attributes', - 'admin/catalog/urlrewrite' => 'Magento_Catalog::urlrewrite', - 'admin/system/config/cataloginventory' => 'Magento_CatalogInventory::cataloginventory', - 'admin/promo' => 'Magento_CatalogRule::promo', - 'admin/promo/catalog' => 'Magento_CatalogRule::promo_catalog', - 'admin/catalog/search' => 'Magento_CatalogSearch::search', - 'admin/system/config/checkout' => 'Magento_Checkout::checkout', - 'admin/sales/checkoutagreement' => 'Magento_Checkout::checkoutagreement', - 'admin/cms/block' => 'Magento_Cms::block', - 'admin/cms' => 'Magento_Cms::cms', - 'admin/system/config/cms' => 'Magento_Cms::config_cms', - 'admin/cms/media_gallery' => 'Magento_Cms::media_gallery', - 'admin/cms/page' => 'Magento_Cms::page', - 'admin/cms/page/delete' => 'Magento_Cms::page_delete', - 'admin/cms/page/save' => 'Magento_Cms::save', - 'admin/system/config/contact' => 'Magento_Contact::contact', - 'admin/system/currency/rates' => 'Magento_CurrencySymbol::currency_rates', - 'admin/system/currency/symbols' => 'Magento_CurrencySymbol::symbols', - 'admin/system/currency' => 'Magento_CurrencySymbol::system_currency', - 'admin/system/config/customer' => 'Magento_Customer::config_customer', - 'admin/customer' => 'Magento_Customer::customer', - 'admin/customer/group' => 'Magento_Customer::group', - 'admin/customer/manage' => 'Magento_Customer::manage', - 'admin/customer/online' => 'Magento_Customer::online', - 'admin/system/design/editor' => 'Magento_DesignEditor::editor', - 'admin/system/config/downloadable' => 'Magento_Downloadable::downloadable', - 'admin/system/config/google' => 'Magento_GoogleAnalytic::google', - 'admin/catalog/googleshopping' => 'Magento_GoogleShopping::googleshopping', - 'admin/catalog/googleshopping/items' => 'Magento_GoogleShopping::items', - 'admin/catalog/googleshopping/types' => 'Magento_GoogleShopping::types', - 'admin/system/convert/export' => 'Magento_ImportExport::export', - 'admin/system/convert/import' => 'Magento_ImportExport::import', - 'admin/system/index' => 'Magento_Index::index', - 'admin/newsletter' => 'Magento_Newsletter::admin_newsletter', - 'admin/system/config/newsletter' => 'Magento_Newsletter::newsletter', - 'admin/newsletter/problem' => 'Magento_Newsletter::problem', - 'admin/newsletter/queue' => 'Magento_Newsletter::queue', - 'admin/newsletter/subscriber' => 'Magento_Newsletter::subscriber', - 'admin/newsletter/template' => 'Magento_Newsletter::template', - 'admin/system/config/oauth' => 'Magento_Oauth::oauth', - 'admin/system/config/payment' => 'Magento_Payment::payment', - 'admin/system/config/payment_services' => 'Magento_Payment::payment_services', - 'admin/report/salesroot/paypal_settlement_reports/fetch' => 'Magento_Paypal::fetch', - 'admin/system/config/paypal' => 'Magento_Paypal::paypal', - 'admin/report/salesroot/paypal_settlement_reports' => 'Magento_Paypal::paypal_settlement_reports', - 'admin/report/salesroot/paypal_settlement_reports/view' => 'Magento_Paypal::paypal_settlement_reports_view', - 'admin/system/config/persistent' => 'Magento_Persistent::persistent', - 'admin/cms/poll' => 'Magento_Poll::poll', - 'admin/catalog/reviews_ratings/ratings' => 'Magento_Review::ratings', - 'admin/report/shopcart/abandoned' => 'Magento_Reports::abandoned', - 'admin/report/customers/accounts' => 'Magento_Reports::accounts', - 'admin/report/products/bestsellers' => 'Magento_Reports::bestsellers', - 'admin/report/salesroot/coupons' => 'Magento_Reports::coupons', - 'admin/report/customers' => 'Magento_Reports::customers', - 'admin/report/customers/orders' => 'Magento_Reports::customers_orders', - 'admin/report/products/downloads' => 'Magento_Reports::downloads', - 'admin/report/salesroot/invoiced' => 'Magento_Reports::invoiced', - 'admin/report/products/lowstock' => 'Magento_Reports::lowstock', - 'admin/report/tags/popular' => 'Magento_Reports::popular', - 'admin/report/shopcart/product' => 'Magento_Reports::product', - 'admin/report/salesroot/refunded' => 'Magento_Reports::refunded', - 'admin/report' => 'Magento_Reports::report', - 'admin/report/products' => 'Magento_Reports::report_products', - 'admin/report/search' => 'Magento_Reports::report_search', - 'admin/system/config/reports' => 'Magento_Reports::reports', - 'admin/report/review' => 'Magento_Reports::review', - 'admin/report/review/customer' => 'Magento_Reports::review_customer', - 'admin/report/review/product' => 'Magento_Reports::review_product', - 'admin/report/salesroot' => 'Magento_Reports::salesroot', - 'admin/report/salesroot/sales' => 'Magento_Reports::salesroot_sales', - 'admin/report/salesroot/shipping' => 'Magento_Reports::shipping', - 'admin/report/shopcart' => 'Magento_Reports::shopcart', - 'admin/report/products/sold' => 'Magento_Reports::sold', - 'admin/report/statistics' => 'Magento_Reports::statistics', - 'admin/report/tags' => 'Magento_Reports::tags', - 'admin/report/tags/customer' => 'Magento_Reports::tags_customer', - 'admin/report/tags/product' => 'Magento_Reports::tags_product', - 'admin/report/salesroot/tax' => 'Magento_Reports::tax', - 'admin/report/customers/totals' => 'Magento_Reports::totals', - 'admin/report/products/viewed' => 'Magento_Reports::viewed', - 'admin/catalog/reviews_ratings/reviews/pending' => 'Magento_Review::pending', - 'admin/catalog/reviews_ratings/reviews' => 'Magento_Review::reviews', - 'admin/catalog/reviews_ratings/reviews/all' => 'Magento_Review::reviews_all', - 'admin/catalog/reviews_ratings' => 'Magento_Review::reviews_ratings', - 'admin/system/config/rss' => 'Magento_Rss::rss', - 'admin/sales/order/actions' => 'Magento_Sales::actions', - 'admin/sales/order/actions/edit' => 'Magento_Sales::actions_edit', - 'admin/paypal/billing_agreement/actions/manage' => 'Magento_Paypal::actions_manage', - 'admin/sales/order/actions/view' => 'Magento_Sales::actions_view', - 'admin/paypal/billing_agreement' => 'Magento_Paypal::billing_agreement', - 'admin/paypal/billing_agreement/actions' => 'Magento_Paypal::billing_agreement_actions', - 'admin/paypal/billing_agreement/actions/view' => 'Magento_Paypal::billing_agreement_actions_view', - 'admin/sales/order/actions/cancel' => 'Magento_Sales::cancel', - 'admin/sales/order/actions/capture' => 'Magento_Sales::capture', - 'admin/sales/order/actions/comment' => 'Magento_Sales::comment', - 'admin/system/config/sales' => 'Magento_Sales::config_sales', - 'admin/sales/order/actions/create' => 'Magento_Sales::create', - 'admin/sales/order/actions/creditmemo' => 'Magento_Sales::creditmemo', - 'admin/sales/order/actions/email' => 'Magento_Sales::email', - 'admin/sales/order/actions/emails' => 'Magento_Sales::emails', - 'admin/sales/order/actions/hold' => 'Magento_Sales::hold', - 'admin/sales/order/actions/invoice' => 'Magento_Sales::invoice', - 'admin/system/order_statuses' => 'Magento_Sales::order_statuses', - 'admin/sales/recurringPayment' => 'Magento_Sales::recurring_payment', - 'admin/sales/order/actions/reorder' => 'Magento_Sales::reorder', - 'admin/sales/order/actions/review_payment' => 'Magento_Sales::review_payment', - 'admin/sales' => 'Magento_Sales::sales', - 'admin/sales/creditmemo' => 'Magento_Sales::sales_creditmemo', - 'admin/system/config/sales_email' => 'Magento_Sales::sales_email', - 'admin/sales/invoice' => 'Magento_Sales::sales_invoice', - 'admin/sales/order' => 'Magento_Sales::sales_order', - 'admin/system/config/sales_pdf' => 'Magento_Sales::sales_pdf', - 'admin/sales/order/actions/ship' => 'Magento_Sales::ship', - 'admin/sales/shipment' => 'Magento_Sales::shipment', - 'admin/sales/transactions' => 'Magento_Sales::transactions', - 'admin/sales/transactions/fetch' => 'Magento_Sales::transactions_fetch', - 'admin/sales/order/actions/unhold' => 'Magento_Sales::unhold', - 'admin/sales/billing_agreement/actions/use' => 'Magento_Paypal::use', - 'admin/system/config/promo' => 'Magento_SalesRule::config_promo', - 'admin/promo/quote' => 'Magento_SalesRule::quote', - 'admin/system/config/carriers' => 'Magento_Shipping::carriers', - 'admin/system/config/shipping' => 'Magento_Shipping::config_shipping', - 'admin/system/config/sitemap' => 'Magento_Sitemap::config_sitemap', - 'admin/catalog/sitemap' => 'Magento_Sitemap::sitemap', - 'admin/sales/tax/classes_customer' => 'Magento_Tax::classes_customer', - 'admin/sales/tax/classes_product' => 'Magento_Tax::classes_product', - 'admin/system/config/tax' => 'Magento_Tax::config_tax', - 'admin/sales/tax/import_export' => 'Magento_Tax::import_export', - 'admin/sales/tax/rules' => 'Magento_Tax::rules', - 'admin/sales/tax' => 'Magento_Tax::sales_tax', - 'admin/sales/tax/rates' => 'Magento_Tax::tax_rates', - 'admin/system/acl' => 'Magento_User::acl', - 'admin/system/acl/roles' => 'Magento_User::acl_roles', - 'admin/system/acl/users' => 'Magento_User::acl_users', - 'admin/cms/widget_instance' => 'Magento_Widget::widget_instance', - 'admin/system/config/wishlist' => 'Magento_Wishlist::config_wishlist', - 'admin/xmlconnect/history' => 'Magento_XmlConnect::history', - 'admin/xmlconnect/mobile' => 'Magento_XmlConnect::mobile', - 'admin/xmlconnect/templates' => 'Magento_XmlConnect::templates', - 'admin/xmlconnect' => 'Magento_XmlConnect::xmlconnect', - 'admin/xmlconnect/queue' => 'Magento_XmlConnect::xmlconnect_queue', - 'admin/system/config/facebook' => 'Social_Facebook::facebook' -); - -$tableName = $installer->getTable('admin_rule'); -/** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ -$connection = $installer->getConnection(); - -$select = $connection->select(); -$select->from($tableName, array())->columns(array('resource_id' => 'resource_id'))->group('resource_id'); - -foreach ($connection->fetchCol($select) as $oldKey) { - /** - * If used ACL key is converted previously or we haven't map for specified ACL resource item - * than go to the next item - */ - if (in_array($oldKey, $map) || false == isset($map[$oldKey])) { - continue; - } - - /** Update rule ACL key from xpath format to identifier format */ - $connection->update($tableName, array('resource_id' => $map[$oldKey]), array('resource_id = ?' => $oldKey)); -} -$installer->endSetup(); diff --git a/app/code/Magento/User/etc/adminhtml/acl.xml b/app/code/Magento/User/etc/acl.xml similarity index 94% rename from app/code/Magento/User/etc/adminhtml/acl.xml rename to app/code/Magento/User/etc/acl.xml index a8858235707..aa309efc89c 100644 --- a/app/code/Magento/User/etc/adminhtml/acl.xml +++ b/app/code/Magento/User/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/User/etc/di.xml b/app/code/Magento/User/etc/di.xml index f27e20b7c4f..020e584b91b 100644 --- a/app/code/Magento/User/etc/di.xml +++ b/app/code/Magento/User/etc/di.xml @@ -24,13 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\User\Model\Role" shared="false" /> - <type name="Magento\User\Model\Resource\Rules"> - <arguments> - <argument name="rootResource" xsi:type="object">Magento\Framework\Acl\RootResource\Proxy</argument> - <argument name="aclCache" xsi:type="object">Magento\Framework\Acl\Cache\Proxy</argument> - </arguments> - </type> <type name="Magento\User\Model\Resource\User"> <arguments> <argument name="aclCache" xsi:type="object">Magento\Framework\Acl\Cache\Proxy</argument> @@ -39,14 +32,11 @@ <type name="Magento\Framework\Module\Updater\SetupFactory"> <arguments> <argument name="resourceTypes" xsi:type="array"> - <item name="user_setup" xsi:type="string">Magento\User\Model\Resource\Setup</item> + <item name="user_setup" xsi:type="string">Magento\Framework\Module\Setup</item> </argument> </arguments> </type> - <type name="Magento\Framework\Acl\Builder"> - <arguments> - <argument name="ruleLoader" xsi:type="object">Magento\User\Model\Acl\Loader\Rule</argument> - <argument name="roleLoader" xsi:type="object">Magento\User\Model\Acl\Loader\Role</argument> - </arguments> + <type name="Magento\Authorization\Model\Role"> + <plugin name="updateRoleUsersAcl" type="Magento\User\Model\Plugin\AuthorizationRole" sortOrder="20"/> </type> </config> diff --git a/app/code/Magento/User/etc/module.xml b/app/code/Magento/User/etc/module.xml index a20a3449928..7c4efc0c354 100644 --- a/app/code/Magento/User/etc/module.xml +++ b/app/code/Magento/User/etc/module.xml @@ -29,41 +29,11 @@ <module name="Magento_Backend"/> </sequence> <depends> + <module name="Magento_Authorization"/> <module name="Magento_Store"/> <module name="Magento_Backend"/> <module name="Magento_Core"/> - <module name="Magento_Catalog"/> - <module name="Magento_Cms"/> - <module name="Magento_Newsletter"/> - <module name="Magento_Review"/> - <module name="Magento_AdminNotification"/> - <module name="Magento_Backup"/> - <module name="Magento_CatalogInventory"/> - <module name="Magento_CatalogRule"/> - <module name="Magento_CatalogSearch"/> - <module name="Magento_Checkout"/> - <module name="Magento_Contact"/> - <module name="Magento_CurrencySymbol"/> - <module name="Magento_Customer"/> - <module name="Magento_DesignEditor"/> - <module name="Magento_Downloadable"/> - <module name="Magento_GoogleShopping"/> - <module name="Magento_ImportExport"/> - <module name="Magento_Index"/> <module name="Magento_Integration"/> - <module name="Magento_Payment"/> - <module name="Magento_Paypal"/> - <module name="Magento_Persistent"/> - <module name="Magento_Reports"/> - <module name="Magento_Rss"/> - <module name="Magento_Sales"/> - <module name="Magento_SalesRule"/> - <module name="Magento_Shipping"/> - <module name="Magento_Sitemap"/> - <module name="Magento_Tax"/> - <module name="Magento_Widget"/> - <module name="Magento_Wishlist"/> - <module name="Magento_Email"/> <module name="Magento_Theme"/> </depends> </module> diff --git a/app/code/Magento/User/etc/webapi_rest/di.xml b/app/code/Magento/User/etc/webapi_rest/di.xml new file mode 100644 index 00000000000..b305d85f0f0 --- /dev/null +++ b/app/code/Magento/User/etc/webapi_rest/di.xml @@ -0,0 +1,37 @@ +<?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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Authorization\Model\CompositeUserContext"> + <arguments> + <argument name="userContexts" xsi:type="array"> + <item name="adminSessionUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\User\Model\Authorization\AdminSessionUserContext</item> + <item name="sortOrder" xsi:type="string">30</item> + </item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/User/sql/user_setup/install-1.6.0.0.php b/app/code/Magento/User/sql/user_setup/install-1.6.0.0.php index f62f43a9822..78272f107d2 100644 --- a/app/code/Magento/User/sql/user_setup/install-1.6.0.0.php +++ b/app/code/Magento/User/sql/user_setup/install-1.6.0.0.php @@ -57,132 +57,6 @@ if (!$installer->getConnection()->isTableExists($installer->getTable('admin_asse $installer->getConnection()->createTable($table); } -/** - * Create table 'admin_role' - */ -if (!$installer->getConnection()->isTableExists($installer->getTable('admin_role'))) { - $table = $installer->getConnection()->newTable( - $installer->getTable('admin_role') - )->addColumn( - 'role_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), - 'Role ID' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Parent Role ID' - )->addColumn( - 'tree_level', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Role Tree Level' - )->addColumn( - 'sort_order', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Role Sort Order' - )->addColumn( - 'role_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 1, - array('nullable' => false, 'default' => '0'), - 'Role Type' - )->addColumn( - 'user_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'User ID' - )->addColumn( - 'role_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - array('nullable' => true, 'default' => null), - 'Role Name' - )->addIndex( - $installer->getIdxName('admin_role', array('parent_id', 'sort_order')), - array('parent_id', 'sort_order') - )->addIndex( - $installer->getIdxName('admin_role', array('tree_level')), - array('tree_level') - )->setComment( - 'Admin Role Table' - ); - $installer->getConnection()->createTable($table); -} -/** - * Create table 'admin_rule' - */ -if (!$installer->getConnection()->isTableExists($installer->getTable('admin_rule'))) { - $table = $installer->getConnection()->newTable( - $installer->getTable('admin_rule') - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), - 'Rule ID' - )->addColumn( - 'role_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Role ID' - )->addColumn( - 'resource_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - array('nullable' => true, 'default' => null), - 'Resource ID' - )->addColumn( - 'privileges', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 20, - array('nullable' => true), - 'Privileges' - )->addColumn( - 'assert_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Assert ID' - )->addColumn( - 'role_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 1, - array(), - 'Role Type' - )->addColumn( - 'permission', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 10, - array(), - 'Permission' - )->addIndex( - $installer->getIdxName('admin_rule', array('resource_id', 'role_id')), - array('resource_id', 'role_id') - )->addIndex( - $installer->getIdxName('admin_rule', array('role_id', 'resource_id')), - array('role_id', 'resource_id') - )->addForeignKey( - $installer->getFkName('admin_rule', 'role_id', 'admin_role', 'role_id'), - 'role_id', - $installer->getTable('admin_role'), - 'role_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Admin Rule Table' - ); - $installer->getConnection()->createTable($table); -} - /** * Create table 'admin_user' */ diff --git a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php index 6478b31a12b..61e9fb37c27 100644 --- a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php +++ b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.0-1.6.1.1.php @@ -26,8 +26,6 @@ $installer = $this; $installer->startSetup(); -// Add reset password link token column $installer->getConnection()->dropTable($installer->getTable('admin_assert')); -$installer->getConnection()->dropColumn($installer->getTable('admin_rule'), 'assert_id'); $installer->endSetup(); diff --git a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php deleted file mode 100644 index f25a36f6b6e..00000000000 --- a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.2-1.6.1.3.php +++ /dev/null @@ -1,49 +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) - */ -/** @var $installer \Magento\Framework\Module\Setup */ -$installer = $this; - -$tableName = $installer->getTable('admin_rule'); -/** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ -$connection = $installer->getConnection(); - -$condition = $connection->prepareSqlCondition( - 'resource_id', - array( - array('like' => '%xmlconnect%'), - array( - /** - * Include both old and new identifiers, as depending on install or upgrade process there can be - * either first or second in the database - */ - 'in' => array( - 'admin/system/convert/gui', - 'Magento_Adminhtml::gui', - 'admin/system/convert/profiles', - 'Magento_Adminhtml::profiles' - ) - ) - ) -); -$connection->delete($tableName, $condition); diff --git a/app/code/Magento/User/view/adminhtml/layout/adminhtml_user_role_grid_block.xml b/app/code/Magento/User/view/adminhtml/layout/adminhtml_user_role_grid_block.xml index 077c9f1d62f..636830d2837 100644 --- a/app/code/Magento/User/view/adminhtml/layout/adminhtml_user_role_grid_block.xml +++ b/app/code/Magento/User/view/adminhtml/layout/adminhtml_user_role_grid_block.xml @@ -28,7 +28,7 @@ <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.role.grid" as="grid"> <arguments> <argument name="id" xsi:type="string">roleGrid</argument> - <argument name="dataSource" xsi:type="object">Magento\User\Model\Resource\Role\Grid\Collection</argument> + <argument name="dataSource" xsi:type="object">Magento\Authorization\Model\Resource\Role\Grid\Collection</argument> <argument name="save_parameters_in_session" xsi:type="string">1</argument> <argument name="default_sort" xsi:type="string">role_id</argument> <argument name="default_dir" xsi:type="string">asc</argument> diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index e384ca64a38..373b6e91de3 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-usps", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php index 363a1d2bcda..aabf35eecba 100644 --- a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php +++ b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php @@ -43,7 +43,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements /** * Rules collection factory * - * @var \Magento\User\Model\Resource\Rules\CollectionFactory + * @var \Magento\Authorization\Model\Resource\Rules\CollectionFactory */ protected $_rulesCollectionFactory; @@ -67,7 +67,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Framework\Acl\RootResource $rootResource - * @param \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory + * @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory * @param \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider * @param \Magento\Webapi\Helper\Data $webapiData * @param \Magento\Integration\Helper\Data $integrationData @@ -81,7 +81,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Acl\RootResource $rootResource, - \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, + \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, \Magento\Framework\Acl\Resource\ProviderInterface $aclResourceProvider, \Magento\Webapi\Helper\Data $webapiData, \Magento\Integration\Helper\Data $integrationData, diff --git a/app/code/Magento/Webapi/Controller/Login/Index.php b/app/code/Magento/Webapi/Controller/Login/Index.php deleted file mode 100644 index feee0d07d58..00000000000 --- a/app/code/Magento/Webapi/Controller/Login/Index.php +++ /dev/null @@ -1,129 +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\Webapi\Controller\Login; - -use Magento\Authz\Model\UserIdentifier; -use Magento\Customer\Service\V1\CustomerAccountServiceInterface; -use Magento\Framework\Exception\AuthenticationException; -use Magento\Webapi\Exception; -use Magento\Webapi\Exception as HttpException; - -class Index extends \Magento\Framework\App\Action\Action -{ - /** - * @var \Magento\Framework\Session\Generic - */ - protected $session; - - /** - * @var CustomerAccountServiceInterface - */ - protected $customerAccountService; - - /** - * @var \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory - */ - protected $deserializerFactory; - - /** - * Initialize Login Service - * - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Session\Generic $session - * @param \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory $deserializerFactory - * @param CustomerAccountServiceInterface $customerAccountService - */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Session\Generic $session, - \Magento\Webapi\Controller\Rest\Request\Deserializer\Factory $deserializerFactory, - CustomerAccountServiceInterface $customerAccountService - ) { - parent::__construct($context); - $this->session = $session; - $this->deserializerFactory = $deserializerFactory; - $this->customerAccountService = $customerAccountService; - } - - /** - * Login registered users and initiate a session. Send back the session id. - * - * Expects a POST. ex for JSON {"username":"user@magento.com", "password":"userpassword"} - * - * @return void - */ - public function execute() - { - $contentTypeHeaderValue = $this->getRequest()->getHeader('Content-Type'); - $contentType = $this->getContentType($contentTypeHeaderValue); - $loginData = null; - try { - $loginData = $this->deserializerFactory - ->get($contentType) - ->deserialize($this->getRequest()->getRawBody()); - } catch (Exception $e) { - $this->getResponse()->setHttpResponseCode($e->getCode()); - return; - } - if (!$loginData || $this->getRequest()->getMethod() !== \Magento\Webapi\Model\Rest\Config::HTTP_METHOD_POST) { - $this->getResponse()->setHttpResponseCode(HttpException::HTTP_BAD_REQUEST); - return; - } - $customerData = null; - try { - $customerData = $this->customerAccountService->authenticate($loginData['username'], $loginData['password']); - } catch (AuthenticationException $e) { - $this->getResponse()->setHttpResponseCode(HttpException::HTTP_UNAUTHORIZED); - return; - } - $this->session->start('frontend'); - $this->session->setUserId($customerData->getId()); - $this->session->setUserType(UserIdentifier::USER_TYPE_CUSTOMER); - $this->session->regenerateId(true); - } - - /** - * Get Content-Type value of request given the $header value. - * - * TODO: Remove this method if \Magento\Webapi\Controller\Rest\Request can be injected instead of - * Magento\Framework\App\Request\Http which is injected by core di.xml - * - * @param string $headerValue - * @return string - * @throws \Magento\Webapi\Exception - */ - protected function getContentType($headerValue) - { - if (!preg_match('~^([a-z\d/\-+.]+)(?:; *charset=(.+))?$~Ui', $headerValue, $matches)) { - return null; - } - // request encoding check if it is specified in header - if (isset($matches[2]) && \Magento\Webapi\Controller\Rest\Request::REQUEST_CHARSET != strtolower($matches[2])) { - return null; - } - - return $matches[1]; - } -} diff --git a/app/code/Magento/Webapi/Controller/Request.php b/app/code/Magento/Webapi/Controller/Request.php index 033f11f1dc1..56e8a01f2c3 100644 --- a/app/code/Magento/Webapi/Controller/Request.php +++ b/app/code/Magento/Webapi/Controller/Request.php @@ -50,25 +50,4 @@ class Request extends \Zend_Controller_Request_Http implements \Magento\Framewor /** Remove GET parameters from path */ $this->_pathInfo = preg_replace('#\?.*#', '', $this->_pathInfo); } - - /** - * Set consumer ID. - * - * @param int $consumerId - * @return void - */ - public function setConsumerId($consumerId) - { - $this->_consumerId = $consumerId; - } - - /** - * Get consumer ID. - * - * @return int - */ - public function getConsumerId() - { - return $this->_consumerId; - } } diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index 1eee5ed9e7d..72fee8e4931 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -23,8 +23,8 @@ */ namespace Magento\Webapi\Controller; -use Magento\Authz\Model\UserIdentifier; -use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\AuthorizationException; use Magento\Framework\Service\Data\AbstractObject; use Magento\Framework\Service\Data\Eav\AbstractObject as EavAbstractObject; @@ -33,9 +33,9 @@ use Magento\Webapi\Controller\Rest\Request as RestRequest; use Magento\Webapi\Controller\Rest\Response as RestResponse; use Magento\Webapi\Controller\Rest\Response\PartialResponseProcessor; use Magento\Webapi\Controller\Rest\Router; +use Magento\Webapi\Controller\Rest\Router\Route; use Magento\Webapi\Model\Config\Converter; use Magento\Webapi\Model\PathProcessor; -use Magento\Webapi\Controller\Rest\Router\Route; /** * Front controller for WebAPI REST area. @@ -68,14 +68,8 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface /** @var \Magento\Framework\View\LayoutInterface */ protected $_layout; - /** @var \Magento\Framework\Oauth\OauthInterface */ - protected $_oauthService; - - /** @var \Magento\Framework\Oauth\Helper\Request */ - protected $_oauthHelper; - - /** @var AuthorizationService */ - protected $_authorizationService; + /** @var AuthorizationInterface */ + protected $_authorization; /** @var ServiceArgsSerializer */ protected $_serializer; @@ -101,6 +95,11 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface */ protected $session; + /** + * @var \Magento\Authorization\Model\UserContextInterface + */ + protected $userContext; + /** * Initialize dependencies * @@ -110,15 +109,13 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Framework\Oauth\OauthInterface $oauthService - * @param \Magento\Framework\Oauth\Helper\Request $oauthHelper - * @param AuthorizationService $authorizationService + * @param AuthorizationInterface $authorization * @param ServiceArgsSerializer $serializer * @param ErrorProcessor $errorProcessor * @param PathProcessor $pathProcessor * @param \Magento\Framework\App\AreaList $areaList * @param PartialResponseProcessor $partialResponseProcessor - * @param \Magento\Framework\Session\Generic $session + * @param UserContextInterface $userContext * * TODO: Consider removal of warning suppression * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -130,15 +127,13 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\App\State $appState, \Magento\Framework\View\LayoutInterface $layout, - \Magento\Framework\Oauth\OauthInterface $oauthService, - \Magento\Framework\Oauth\Helper\Request $oauthHelper, - AuthorizationService $authorizationService, + AuthorizationInterface $authorization, ServiceArgsSerializer $serializer, ErrorProcessor $errorProcessor, PathProcessor $pathProcessor, \Magento\Framework\App\AreaList $areaList, PartialResponseProcessor $partialResponseProcessor, - \Magento\Framework\Session\Generic $session + UserContextInterface $userContext ) { $this->_router = $router; $this->_request = $request; @@ -146,15 +141,13 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $this->_objectManager = $objectManager; $this->_appState = $appState; $this->_layout = $layout; - $this->_oauthService = $oauthService; - $this->_oauthHelper = $oauthHelper; - $this->_authorizationService = $authorizationService; + $this->_authorization = $authorization; $this->_serializer = $serializer; $this->_errorProcessor = $errorProcessor; $this->_pathProcessor = $pathProcessor; $this->areaList = $areaList; $this->partialResponseProcessor = $partialResponseProcessor; - $this->session = $session; + $this->userContext = $userContext; } /** @@ -173,8 +166,8 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface if (!$this->_appState->isInstalled()) { throw new \Magento\Webapi\Exception(__('Magento is not yet installed')); } - $this->_checkPermissions(); - $route = $this->_getCurrentRoute(); + $this->checkPermissions(); + $route = $this->getCurrentRoute(); if ($route->isSecure() && !$this->_request->isSecure()) { throw new \Magento\Webapi\Exception(__('Operation allowed only in HTTPS')); } @@ -182,12 +175,12 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $inputData = $this->_request->getRequestData(); $serviceMethodName = $route->getServiceMethod(); $serviceClassName = $route->getServiceClass(); - $inputData = $this->_overrideParams($inputData, $route->getParameters()); + $inputData = $this->overrideParams($inputData, $route->getParameters()); $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData); $service = $this->_objectManager->get($serviceClassName); /** @var \Magento\Framework\Service\Data\AbstractObject $outputData */ $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams); - $outputData = $this->_processServiceOutput($outputData); + $outputData = $this->processServiceOutput($outputData); if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) { $outputData = $this->partialResponseProcessor->filter($outputData); } @@ -211,7 +204,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param mixed $data * @return array|int|string|bool|float Scalar or array of scalars */ - protected function _processServiceOutput($data) + protected function processServiceOutput($data) { if (is_array($data)) { $result = []; @@ -259,13 +252,17 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param array $parameters Contains parameters to replace or default * @return array Data in same format as $inputData with appropriate parameters added or changed */ - protected function _overrideParams(array $inputData, array $parameters) + protected function overrideParams(array $inputData, array $parameters) { foreach ($parameters as $name => $paramData) { if ($paramData[Converter::KEY_FORCE] || !isset($inputData[$name])) { - $value = isset($paramData['source']) && $paramData['source'] == 'session' - ? $this->session->{$paramData['method']}() - : $paramData[Converter::KEY_VALUE]; + if ($paramData[Converter::KEY_VALUE] == '%customer_id%' + && $this->userContext->getUserType() === UserContextInterface::USER_TYPE_CUSTOMER + ) { + $value = $this->userContext->getUserId(); + } else { + $value = $paramData[Converter::KEY_VALUE]; + } $inputData[$name] = $value; } } @@ -277,7 +274,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * * @return Route */ - protected function _getCurrentRoute() + protected function getCurrentRoute() { if (!$this->_route) { $this->_route = $this->_router->match($this->_request); @@ -288,43 +285,31 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface /** * Perform authentication and authorization. * - * Authentication can be based on active customer/guest session or it can be based on OAuth headers. - * * @throws \Magento\Framework\Exception\AuthorizationException * @return void */ - protected function _checkPermissions() + protected function checkPermissions() { - /** - * All mobile clients are expected to pass session cookie along with the request which will allow - * to start session automatically. User ID and user type are initialized when session is created - * during login call. - */ - $userId = $this->session->getUserId(); - $userType = $this->session->getUserType(); - $userIdentifier = null; - $consumerId = null; - if ($userType) { - /** @var \Magento\Authz\Model\UserIdentifier $userIdentifier */ - $userIdentifier = $this->_objectManager->create( - 'Magento\Authz\Model\UserIdentifier', - ['userType' => $userType, 'userId' => $userId] - ); - } else { - $oauthRequest = $this->_oauthHelper->prepareRequest($this->_request); - $consumerId = $this->_oauthService->validateAccessTokenRequest( - $oauthRequest, - $this->_oauthHelper->getRequestUrl($this->_request), - $this->_request->getMethod() - ); - $this->_request->setConsumerId($consumerId); - } - - $route = $this->_getCurrentRoute(); - - if (!$this->_authorizationService->isAllowed($route->getAclResources(), $userIdentifier)) { + $route = $this->getCurrentRoute(); + if (!$this->isAllowed($route->getAclResources())) { $params = ['resources' => implode(', ', $route->getAclResources())]; throw new AuthorizationException(AuthorizationException::NOT_AUTHORIZED, $params); } } + + /** + * Check if all ACL resources are allowed to be accessed by current API user. + * + * @param string[] $aclResources + * @return bool + */ + protected function isAllowed($aclResources) + { + foreach ($aclResources as $resource) { + if (!$this->_authorization->isAllowed($resource)) { + return false; + } + } + return true; + } } diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index 0ec8cb4e573..523e41baa3d 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -66,11 +66,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface /** @var \Magento\Framework\View\LayoutInterface */ protected $_layout; - /** - * @var \Magento\Framework\Oauth\OauthInterface - */ - protected $_oauthService; - /** * @var \Magento\Framework\Locale\ResolverInterface */ @@ -94,7 +89,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface * @param ErrorProcessor $errorProcessor * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Framework\Oauth\OauthInterface $oauthService * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param PathProcessor $pathProcessor * @param \Magento\Framework\App\AreaList $areaList @@ -109,7 +103,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface ErrorProcessor $errorProcessor, \Magento\Framework\App\State $appState, \Magento\Framework\View\LayoutInterface $layout, - \Magento\Framework\Oauth\OauthInterface $oauthService, \Magento\Framework\Locale\ResolverInterface $localeResolver, PathProcessor $pathProcessor, \Magento\Framework\App\AreaList $areaList @@ -120,7 +113,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface $this->_soapServer = $soapServer; $this->_errorProcessor = $errorProcessor; $this->_appState = $appState; - $this->_oauthService = $oauthService; $this->_localeResolver = $localeResolver; $this->_layout = $layout; $this->_pathProcessor = $pathProcessor; @@ -151,8 +143,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST); $this->_setResponseBody($responseBody); } else { - $consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken()); - $this->_request->setConsumerId($consumerId); $this->_soapServer->handle(); } } catch (\Exception $e) { diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php index 2d35e2a4943..7008052b37b 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php @@ -23,7 +23,7 @@ */ namespace Magento\Webapi\Controller\Soap\Request; -use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService; +use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\AuthorizationException; use Magento\Framework\Service\Data\AbstractObject; use Magento\Framework\Service\DataObjectConverter; @@ -52,8 +52,8 @@ class Handler /** @var SoapConfig */ protected $_apiConfig; - /** @var AuthorizationService */ - protected $_authorizationService; + /** @var AuthorizationInterface */ + protected $_authorization; /** @var DataObjectConverter */ protected $_dataObjectConverter; @@ -67,7 +67,7 @@ class Handler * @param SoapRequest $request * @param \Magento\Framework\ObjectManager $objectManager * @param SoapConfig $apiConfig - * @param AuthorizationService $authorizationService + * @param AuthorizationInterface $authorization * @param DataObjectConverter $dataObjectConverter * @param ServiceArgsSerializer $serializer */ @@ -75,14 +75,14 @@ class Handler SoapRequest $request, \Magento\Framework\ObjectManager $objectManager, SoapConfig $apiConfig, - AuthorizationService $authorizationService, + AuthorizationInterface $authorization, DataObjectConverter $dataObjectConverter, ServiceArgsSerializer $serializer ) { $this->_request = $request; $this->_objectManager = $objectManager; $this->_apiConfig = $apiConfig; - $this->_authorizationService = $authorizationService; + $this->_authorization = $authorization; $this->_dataObjectConverter = $dataObjectConverter; $this->_serializer = $serializer; } @@ -110,8 +110,8 @@ class Handler } $isAllowed = false; - foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resources) { - if ($this->_authorizationService->isAllowed($resources)) { + foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resource) { + if ($this->_authorization->isAllowed($resource)) { $isAllowed = true; break; } diff --git a/app/code/Magento/Authz/Model/UserLocator/Guest.php b/app/code/Magento/Webapi/Model/Authorization/GuestUserContext.php similarity index 82% rename from app/code/Magento/Authz/Model/UserLocator/Guest.php rename to app/code/Magento/Webapi/Model/Authorization/GuestUserContext.php index ad93686134c..392a77d7090 100644 --- a/app/code/Magento/Authz/Model/UserLocator/Guest.php +++ b/app/code/Magento/Webapi/Model/Authorization/GuestUserContext.php @@ -21,15 +21,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\Authz\Model\UserLocator; -use Magento\Authz\Model\UserIdentifier; -use Magento\Authz\Model\UserLocatorInterface; +namespace Magento\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; /** - * Guest user locator. + * Guest user context */ -class Guest implements UserLocatorInterface +class GuestUserContext implements UserContextInterface { /** * {@inheritdoc} @@ -44,6 +44,6 @@ class Guest implements UserLocatorInterface */ public function getUserType() { - return UserIdentifier::USER_TYPE_GUEST; + return UserContextInterface::USER_TYPE_GUEST; } } diff --git a/app/code/Magento/Webapi/Model/Authorization/OauthUserContext.php b/app/code/Magento/Webapi/Model/Authorization/OauthUserContext.php new file mode 100644 index 00000000000..b16bc5257a6 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Authorization/OauthUserContext.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\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Integration\Service\V1\Integration as IntegrationService; +use Magento\Webapi\Controller\Request; +use Magento\Framework\Oauth\Helper\Request as OauthRequestHelper; +use Magento\Framework\Oauth\OauthInterface as OauthService; + +/** + * A user context determined by OAuth headers in a HTTP request. + */ +class OauthUserContext implements UserContextInterface +{ + /** + * @var Request + */ + protected $request; + + /** + * @var IntegrationService + */ + protected $integrationService; + + /** + * @var OauthService + */ + protected $oauthService; + + /** + * @var OauthRequestHelper + */ + protected $oauthHelper; + + /** + * @var int + */ + protected $integrationId; + + /** + * Initialize dependencies. + * + * @param Request $request + * @param IntegrationService $integrationService + * @param OauthService $oauthService + * @param OauthRequestHelper $oauthHelper + */ + public function __construct( + Request $request, + IntegrationService $integrationService, + OauthService $oauthService, + OauthRequestHelper $oauthHelper + ) { + $this->request = $request; + $this->integrationService = $integrationService; + $this->oauthService = $oauthService; + $this->oauthHelper = $oauthHelper; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + if ($this->integrationId) { + return $this->integrationId; + } + $oauthRequest = $this->oauthHelper->prepareRequest($this->request); + //If its not a valid Oauth request no further processing is needed + if (empty($oauthRequest)) { + return null; + } + $consumerId = $this->oauthService->validateAccessTokenRequest( + $oauthRequest, + $this->oauthHelper->getRequestUrl($this->request), + $this->request->getMethod() + ); + $integration = $this->integrationService->findActiveIntegrationByConsumerId($consumerId); + return $this->integrationId = ($integration->getId() ? (int)$integration->getId() : null); + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + return UserContextInterface::USER_TYPE_INTEGRATION; + } +} diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php new file mode 100644 index 00000000000..8d3b60ac150 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php @@ -0,0 +1,169 @@ +<?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\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Integration\Model\Oauth\Token; +use Magento\Integration\Model\Oauth\TokenFactory; +use Magento\Integration\Service\V1\Integration as IntegrationService; +use Magento\Webapi\Controller\Request; + +/** + * A user context determined by tokens in a HTTP request Authorization header. + */ +class TokenUserContext implements UserContextInterface +{ + /** + * @var Request + */ + protected $request; + + /** + * @var Token + */ + protected $tokenFactory; + + /** + * @var int + */ + protected $userId; + + /** + * @var string + */ + protected $userType; + + /** + * @var bool + */ + protected $isRequestProcessed; + + /** + * @var IntegrationService + */ + protected $integrationService; + + /** + * Initialize dependencies. + * + * @param Request $request + * @param TokenFactory $tokenFactory + * @param IntegrationService $integrationService + */ + public function __construct( + Request $request, + TokenFactory $tokenFactory, + IntegrationService $integrationService + ) { + $this->request = $request; + $this->tokenFactory = $tokenFactory; + $this->integrationService = $integrationService; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + $this->processRequest(); + return $this->userId; + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + $this->processRequest(); + return $this->userType; + } + + /** + * Finds the bearer token and looks up the value. + * + * @return void + */ + protected function processRequest() + { + if ($this->isRequestProcessed) { + return; + } + + $authorizationHeaderValue = $this->request->getHeader('Authorization'); + if (!$authorizationHeaderValue) { + $this->isRequestProcessed = true; + return; + } + + $headerPieces = explode(" ", $authorizationHeaderValue); + if (count($headerPieces) !== 2) { + $this->isRequestProcessed = true; + return; + } + + $tokenType = strtolower($headerPieces[0]); + if ($tokenType !== 'bearer') { + $this->isRequestProcessed = true; + return; + } + + $bearerToken = $headerPieces[1]; + $token = $this->tokenFactory->create()->loadByToken($bearerToken); + + if (!$token->getId()) { + $this->isRequestProcessed = true; + return; + } + + $this->setUserDataViaToken($token); + $this->isRequestProcessed = true; + } + + /** + * @param Token $token + * @return void + */ + protected function setUserDataViaToken(Token $token) + { + $this->userType = $token->getUserType(); + switch ($this->userType) { + case UserContextInterface::USER_TYPE_INTEGRATION: + $this->userId = $this->integrationService->findByConsumerId($token->getConsumerId())->getId(); + $this->userType = UserContextInterface::USER_TYPE_INTEGRATION; + break; + case UserContextInterface::USER_TYPE_ADMIN: + $this->userId = $token->getAdminId(); + $this->userType = UserContextInterface::USER_TYPE_ADMIN; + break; + case UserContextInterface::USER_TYPE_CUSTOMER: + $this->userId = $token->getCustomerId(); + $this->userType = UserContextInterface::USER_TYPE_CUSTOMER; + break; + default: + /* this is an unknown user type so reset the cached user type */ + $this->userType = null; + } + } +} diff --git a/app/code/Magento/Webapi/Model/Authz/UserLocator.php b/app/code/Magento/Webapi/Model/Authz/UserLocator.php deleted file mode 100644 index ff564b5fde9..00000000000 --- a/app/code/Magento/Webapi/Model/Authz/UserLocator.php +++ /dev/null @@ -1,71 +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\Webapi\Model\Authz; - -use Magento\Authz\Model\UserLocatorInterface; -use Magento\Authz\Model\UserIdentifier; -use Magento\Webapi\Controller\Request; -use Magento\Integration\Model\Integration\Factory as IntegrationFactory; - -/** - * Web API user locator. - */ -class UserLocator implements UserLocatorInterface -{ - /** @var Request */ - protected $_request; - - /** @var IntegrationFactory */ - protected $_integrationFactory; - - /** - * Initialize dependencies. - * - * @param Request $request - * @param IntegrationFactory $integrationFactory - */ - public function __construct(Request $request, IntegrationFactory $integrationFactory) - { - $this->_request = $request; - $this->_integrationFactory = $integrationFactory; - } - - /** - * {@inheritdoc} - */ - public function getUserId() - { - $consumerId = $this->_request->getConsumerId(); - $integration = $this->_integrationFactory->create()->loadByConsumerId($consumerId); - return $integration->getId() ? (int)$integration->getId() : 0; - } - - /** - * {@inheritdoc} - */ - public function getUserType() - { - return UserIdentifier::USER_TYPE_INTEGRATION; - } -} diff --git a/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php b/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php deleted file mode 100644 index 4ec91252cfc..00000000000 --- a/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php +++ /dev/null @@ -1,100 +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\Webapi\Model\Plugin; - -use Magento\Authz\Model\UserIdentifier; -use Magento\Integration\Service\V1\Integration as IntegrationService; -use Magento\Integration\Model\Integration; -use Magento\Framework\Logger; - -/** - * Wrap isAllowed() method from AuthorizationV1 service to avoid checking roles of deactivated integration. - */ -class AuthorizationServiceV1 -{ - /** @var IntegrationService */ - protected $_integrationService; - - /** @var Logger */ - protected $_logger; - - /** @var UserIdentifier */ - protected $_userIdentifier; - - /** - * Inject dependencies. - * - * @param IntegrationService $integrationService - * @param Logger $logger - * @param UserIdentifier $userIdentifier - */ - public function __construct(IntegrationService $integrationService, Logger $logger, UserIdentifier $userIdentifier) - { - $this->_integrationService = $integrationService; - $this->_logger = $logger; - $this->_userIdentifier = $userIdentifier; - } - - /** - * Check whether integration is inactive and don't allow using this integration in this case. - * - * It's ok that we break invocation chain since we're dealing with ACL here - if something is not allowed at any - * point it couldn't be made allowed at some other point. - * - * @param \Magento\Authz\Service\AuthorizationV1 $subject - * @param callable $proceed - * @param mixed $resources - * @param UserIdentifier $userIdentifier - * - * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundIsAllowed( - \Magento\Authz\Service\AuthorizationV1 $subject, - \Closure $proceed, - $resources, - \Magento\Authz\Model\UserIdentifier $userIdentifier = null - ) { - /** @var UserIdentifier $userIdentifierObject */ - $userIdentifierObject = $userIdentifier ?: $this->_userIdentifier; - - if ($userIdentifierObject->getUserType() !== UserIdentifier::USER_TYPE_INTEGRATION) { - return $proceed($resources, $userIdentifier); - } - - try { - $integration = $this->_integrationService->get($userIdentifierObject->getUserId()); - } catch (\Exception $e) { - // Wrong integration ID or DB not reachable or whatever - give up and don't allow just in case - $this->_logger->logException($e); - return false; - } - - if ($integration->getStatus() !== Integration::STATUS_ACTIVE) { - return false; - } - - return $proceed($resources, $userIdentifier); - } -} diff --git a/app/code/Magento/Webapi/Model/Plugin/GuestAuthorization.php b/app/code/Magento/Webapi/Model/Plugin/GuestAuthorization.php new file mode 100644 index 00000000000..9a317952473 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Plugin/GuestAuthorization.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\Webapi\Model\Plugin; + +use Magento\Integration\Service\V1\AuthorizationServiceInterface as AuthorizationService; + +/** + * Plugin around \Magento\Framework\Authorization::isAllowed + * + * Plugin to allow guest users to access resources with anonymous permission + */ +class GuestAuthorization +{ + /** + * Check if resource for which access is needed has anonymous permissions defined in webapi config. + * + * @param \Magento\Framework\Authorization $subject + * @param callable $proceed + * @param string $resource + * @param string $privilege + * @return bool true If resource permission is anonymous, + * to allow any user access without further checks in parent method + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundIsAllowed( + \Magento\Framework\Authorization $subject, + \Closure $proceed, + $resource, + $privilege = null + ) { + if ($resource == AuthorizationService::PERMISSION_ANONYMOUS) { + return true; + } else { + return $proceed($resource, $privilege); + } + } +} diff --git a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php b/app/code/Magento/Webapi/Model/Plugin/Service/V1/Integration.php similarity index 67% rename from app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php rename to app/code/Magento/Webapi/Model/Plugin/Service/V1/Integration.php index 45b2de646e8..ffc78385343 100644 --- a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php +++ b/app/code/Magento/Webapi/Model/Plugin/Service/V1/Integration.php @@ -21,34 +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\Webapi\Model\Plugin; -use Magento\Authz\Model\UserIdentifier; -use Magento\Authz\Model\UserIdentifier\Factory as UserIdentifierFactory; +namespace Magento\Webapi\Model\Plugin\Service\V1; + +use Magento\Authorization\Model\Acl\AclRetriever; +use Magento\Authorization\Model\UserContextInterface; use Magento\Integration\Model\Integration as IntegrationModel; -use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationInterface; +use Magento\Integration\Service\V1\AuthorizationServiceInterface as IntegrationAuthorizationInterface; /** * Plugin for \Magento\Integration\Service\V1\Integration. */ -class IntegrationServiceV1 +class Integration { - /** @var AuthorizationInterface */ - protected $_authzService; + /** @var IntegrationAuthorizationInterface */ + protected $integrationAuthorizationService; - /** @var UserIdentifierFactory */ - protected $_userIdentifierFactory; + /** @var AclRetriever */ + protected $aclRetriever; /** * Initialize dependencies. * - * @param AuthorizationInterface $authzService - * @param UserIdentifierFactory $userIdentifierFactory + * @param IntegrationAuthorizationInterface $integrationAuthorizationService + * @param AclRetriever $aclRetriever */ - public function __construct(AuthorizationInterface $authzService, UserIdentifierFactory $userIdentifierFactory) - { - $this->_authzService = $authzService; - $this->_userIdentifierFactory = $userIdentifierFactory; + public function __construct( + IntegrationAuthorizationInterface $integrationAuthorizationService, + AclRetriever $aclRetriever + ) { + $this->integrationAuthorizationService = $integrationAuthorizationService; + $this->aclRetriever = $aclRetriever; } /** @@ -105,8 +108,13 @@ class IntegrationServiceV1 protected function _addAllowedResources(IntegrationModel $integration) { if ($integration->getId()) { - $userIdentifier = $this->_createUserIdentifier($integration->getId()); - $integration->setData('resource', $this->_authzService->getAllowedResources($userIdentifier)); + $integration->setData( + 'resource', + $this->aclRetriever->getAllowedResourcesByUser( + UserContextInterface::USER_TYPE_INTEGRATION, + (int)$integration->getId() + ) + ); } } @@ -122,32 +130,17 @@ class IntegrationServiceV1 protected function _saveApiPermissions(IntegrationModel $integration) { if ($integration->getId()) { - $userIdentifier = $this->_createUserIdentifier($integration->getId()); if ($integration->getData('all_resources')) { - $this->_authzService->grantAllPermissions($userIdentifier); + $this->integrationAuthorizationService->grantAllPermissions($integration->getId()); } else if (is_array($integration->getData('resource'))) { - $this->_authzService->grantPermissions($userIdentifier, $integration->getData('resource')); + $this->integrationAuthorizationService + ->grantPermissions($integration->getId(), $integration->getData('resource')); } else { - $this->_authzService->grantPermissions($userIdentifier, array()); + $this->integrationAuthorizationService->grantPermissions($integration->getId(), array()); } } } - /** - * Instantiate new user identifier for an integration. - * - * @param int $integrationId - * @return UserIdentifier - */ - protected function _createUserIdentifier($integrationId) - { - $userIdentifier = $this->_userIdentifierFactory->create( - UserIdentifier::USER_TYPE_INTEGRATION, - (int)$integrationId - ); - return $userIdentifier; - } - /** * Process integration resource permissions after the integration is created * @@ -160,11 +153,8 @@ class IntegrationServiceV1 public function afterDelete(\Magento\Integration\Service\V1\Integration $subject, array $integrationData) { //No check needed for integration data since it cannot be empty in the parent invocation - delete - $userIdentifier = $this->_userIdentifierFactory->create( - UserIdentifier::USER_TYPE_INTEGRATION, - (int)$integrationData[IntegrationModel::ID] - ); - $this->_authzService->removePermissions($userIdentifier); + $integrationId = (int)$integrationData[IntegrationModel::ID]; + $this->integrationAuthorizationService->removePermissions($integrationId); return $integrationData; } } diff --git a/app/code/Magento/Webapi/Model/Plugin/Setup.php b/app/code/Magento/Webapi/Model/Plugin/Setup.php index aa7ce338185..f5011eae30d 100644 --- a/app/code/Magento/Webapi/Model/Plugin/Setup.php +++ b/app/code/Magento/Webapi/Model/Plugin/Setup.php @@ -23,9 +23,9 @@ */ namespace Magento\Webapi\Model\Plugin; -use Magento\Authz\Model\UserIdentifier; use Magento\Integration\Model\Integration; use Magento\Webapi\Model\IntegrationConfig; +use Magento\Integration\Service\V1\AuthorizationServiceInterface as IntegrationAuthorizationInterface; /** * Plugin for Magento\Framework\Module\Setup model to manage resource permissions of @@ -48,37 +48,25 @@ class Setup protected $_integrationService; /** - * Authorization service - * - * @var \Magento\Authz\Service\AuthorizationV1 - */ - protected $_authzService; - - /** - * Factory to create UserIdentifier - * - * @var \Magento\Authz\Model\UserIdentifier\Factory + * @var IntegrationAuthorizationInterface */ - protected $_userIdentifierFactory; + protected $integrationAuthorizationService; /** * Construct Setup plugin instance * * @param IntegrationConfig $integrationConfig - * @param \Magento\Authz\Service\AuthorizationV1 $authzService + * @param IntegrationAuthorizationInterface $integrationAuthorizationService * @param \Magento\Integration\Service\V1\IntegrationInterface $integrationService - * @param \Magento\Authz\Model\UserIdentifier\Factory $userIdentifierFactory */ public function __construct( IntegrationConfig $integrationConfig, - \Magento\Authz\Service\AuthorizationV1 $authzService, - \Magento\Integration\Service\V1\IntegrationInterface $integrationService, - \Magento\Authz\Model\UserIdentifier\Factory $userIdentifierFactory + IntegrationAuthorizationInterface $integrationAuthorizationService, + \Magento\Integration\Service\V1\IntegrationInterface $integrationService ) { $this->_integrationConfig = $integrationConfig; - $this->_authzService = $authzService; + $this->integrationAuthorizationService = $integrationAuthorizationService; $this->_integrationService = $integrationService; - $this->_userIdentifierFactory = $userIdentifierFactory; } /** @@ -103,11 +91,10 @@ class Setup if (isset($integrations[$name])) { $integration = $this->_integrationService->findByName($name); if ($integration->getId()) { - $userIdentifier = $this->_userIdentifierFactory->create( - UserIdentifier::USER_TYPE_INTEGRATION, - $integration->getId() + $this->integrationAuthorizationService->grantPermissions( + $integration->getId(), + $integrations[$name]['resources'] ); - $this->_authzService->grantPermissions($userIdentifier, $integrations[$name]['resources']); } } } diff --git a/app/code/Magento/Webapi/Model/WebapiRoleLocator.php b/app/code/Magento/Webapi/Model/WebapiRoleLocator.php new file mode 100644 index 00000000000..7aa122d2a03 --- /dev/null +++ b/app/code/Magento/Webapi/Model/WebapiRoleLocator.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\Webapi\Model; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\Authorization\RoleLocator; +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; + +class WebapiRoleLocator implements RoleLocator +{ + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var RoleCollectionFactory + */ + protected $roleCollectionFactory; + + /** + * Constructs a role locator using the user context. + * + * @param UserContextInterface $userContext + * @param RoleCollectionFactory $roleCollectionFactory + */ + public function __construct( + UserContextInterface $userContext, + RoleCollectionFactory $roleCollectionFactory + ) { + $this->userContext = $userContext; + $this->roleCollectionFactory = $roleCollectionFactory; + } + + /** + * {@inheritdoc} + */ + public function getAclRoleId() + { + $userId = $this->userContext->getUserId(); + $userType = $this->userContext->getUserType(); + + $roleCollection = $this->roleCollectionFactory->create(); + /** @var Role $role */ + $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem(); + + if (!$role->getId()) { + return null; + } + + return $role->getId(); + } +} diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 8d931626342..266cfd75b83 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -2,19 +2,18 @@ "name": "magento/module-webapi", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-integration": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-user": "0.1.0-alpha89", - "magento/module-authz": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-authorization": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-integration": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/etc/di.xml b/app/code/Magento/Webapi/etc/di.xml index d62d987b602..6f433e19756 100644 --- a/app/code/Magento/Webapi/etc/di.xml +++ b/app/code/Magento/Webapi/etc/di.xml @@ -41,7 +41,7 @@ <type name="Magento\Framework\Code\Scanner\DirectoryScanner" shared="false" /> <type name="Magento\Server\Reflection" shared="false" /> <type name="Magento\Integration\Service\V1\Integration"> - <plugin name="webapiIntegrationServiceV1" type="Magento\Webapi\Model\Plugin\IntegrationServiceV1"/> + <plugin name="webapiIntegrationServiceV1" type="Magento\Webapi\Model\Plugin\Service\V1\Integration"/> </type> <type name="Magento\Webapi\Controller\Rest\Request\Deserializer\Factory"> <arguments> diff --git a/app/code/Magento/Webapi/etc/module.xml b/app/code/Magento/Webapi/etc/module.xml index 45b9ec4ab39..7174a4322d2 100644 --- a/app/code/Magento/Webapi/etc/module.xml +++ b/app/code/Magento/Webapi/etc/module.xml @@ -33,12 +33,11 @@ </sequence> <depends> <module name="Magento_Store"/> + <module name="Magento_Authorization"/> <module name="Magento_Core"/> <module name="Magento_Integration"/> <module name="Magento_Backend"/> - <module name="Magento_User"/> - <module name="Magento_Authz"/> - <module name="Magento_Customer"/> + <module name="Magento_User" type="soft"/> </depends> </module> </config> diff --git a/app/code/Magento/Webapi/etc/webapi.xsd b/app/code/Magento/Webapi/etc/webapi.xsd index 9770ae30c07..f95c1e4d946 100644 --- a/app/code/Magento/Webapi/etc/webapi.xsd +++ b/app/code/Magento/Webapi/etc/webapi.xsd @@ -86,8 +86,6 @@ <xs:extension base="xs:string"> <xs:attribute name="name" type="xs:string" use="required"/> <xs:attribute name="force" type="xs:boolean"/> - <xs:attribute name="source" type="xs:string"/> - <xs:attribute name="method" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml index 82dbff2c61a..531736c376f 100644 --- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml @@ -24,12 +24,35 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Authz\Model\UserLocatorInterface" type="Magento\Webapi\Model\Authz\UserLocator"/> - <type name="Magento\Webapi\Model\Authz\UserLocator"> + <preference for="Magento\Authorization\Model\UserContextInterface" type="Magento\Authorization\Model\CompositeUserContext"/> + <type name="Magento\Webapi\Model\Authorization\OauthUserContext"> <arguments> <argument name="request" xsi:type="object">Magento\Webapi\Controller\Rest\Request</argument> </arguments> </type> + <type name="Magento\Framework\Session\Generic"> + <arguments> + <argument name="sessionName" xsi:type="string">frontend</argument> + </arguments> + </type> + <type name="Magento\Authorization\Model\CompositeUserContext"> + <arguments> + <argument name="userContexts" xsi:type="array"> + <item name="tokenUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Webapi\Model\Authorization\TokenUserContext</item> + <item name="sortOrder" xsi:type="string">10</item> + </item> + <item name="oauthUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Webapi\Model\Authorization\OauthUserContext</item> + <item name="sortOrder" xsi:type="string">40</item> + </item> + <item name="guestUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Webapi\Model\Authorization\GuestUserContext</item> + <item name="sortOrder" xsi:type="string">100</item> + </item> + </argument> + </arguments> + </type> <preference for="Magento\Framework\App\FrontControllerInterface" type="Magento\Webapi\Controller\Rest" /> <preference for="Magento\Framework\Model\ActionValidator\RemoveAction" type="Magento\Framework\Model\ActionValidator\RemoveAction\Allowed" /> <type name="Magento\Webapi\Controller\Rest\Router\Route" shared="false" /> @@ -65,15 +88,10 @@ <argument name="response" xsi:type="object">Magento\Webapi\Controller\Rest\Response\Proxy</argument> <argument name="router" xsi:type="object">Magento\Webapi\Controller\Rest\Router\Proxy</argument> <argument name="oauthHelper" xsi:type="object">Magento\Framework\Oauth\Helper\Request\Proxy</argument> - <argument name="authorizationService" xsi:type="object">Magento\Authz\Service\AuthorizationV1Interface\Proxy</argument> </arguments> </type> - <type name="Magento\Authz\Service\AuthorizationV1"> - <plugin name="webapiRestAuthorizationV1" type="Magento\Webapi\Model\Plugin\AuthorizationServiceV1" /> - </type> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> + <preference for="Magento\Framework\Authorization\RoleLocator" type="Magento\Webapi\Model\WebapiRoleLocator" /> + <type name="Magento\Framework\Authorization"> + <plugin name="guestAuthorization" type="Magento\Webapi\Model\Plugin\GuestAuthorization" /> </type> </config> diff --git a/app/code/Magento/Webapi/etc/webapi_soap/di.xml b/app/code/Magento/Webapi/etc/webapi_soap/di.xml index 1c8ce711122..55ab39e818c 100644 --- a/app/code/Magento/Webapi/etc/webapi_soap/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_soap/di.xml @@ -24,12 +24,26 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\Authz\Model\UserLocatorInterface" type="Magento\Webapi\Model\Authz\UserLocator"/> - <type name="Magento\Webapi\Model\Authz\UserLocator"> + <preference for="Magento\Authorization\Model\UserContextInterface" type="Magento\Authorization\Model\CompositeUserContext"/> + <type name="Magento\Webapi\Model\Authorization\OauthUserContext"> <arguments> <argument name="request" xsi:type="object">Magento\Webapi\Controller\Soap\Request</argument> </arguments> </type> + <type name="Magento\Authorization\Model\CompositeUserContext"> + <arguments> + <argument name="userContexts" xsi:type="array"> + <item name="tokenUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Webapi\Model\Authorization\TokenUserContext</item> + <item name="sortOrder" xsi:type="string">10</item> + </item> + <item name="guestUserContext" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Webapi\Model\Authorization\GuestUserContext</item> + <item name="sortOrder" xsi:type="string">100</item> + </item> + </argument> + </arguments> + </type> <preference for="Magento\Framework\App\FrontControllerInterface" type="Magento\Webapi\Controller\Soap" /> <preference for="Magento\Framework\Model\ActionValidator\RemoveAction" type="Magento\Framework\Model\ActionValidator\RemoveAction\Allowed" /> <type name="Magento\Webapi\Controller\Rest\Router\Route" shared="false" /> @@ -39,12 +53,8 @@ <argument name="errorProcessor" xsi:type="object">Magento\Webapi\Controller\ErrorProcessor\Proxy</argument> </arguments> </type> - <type name="Magento\Webapi\Controller\Soap\Request\Handler"> - <arguments> - <argument name="authorizationService" xsi:type="object">Magento\Authz\Service\AuthorizationV1Interface\Proxy</argument> - </arguments> - </type> - <type name="Magento\Authz\Service\AuthorizationV1"> - <plugin name="webapiSoapAuthorizationV1" type="Magento\Webapi\Model\Plugin\AuthorizationServiceV1" /> + <preference for="Magento\Framework\Authorization\RoleLocator" type="Magento\Webapi\Model\WebapiRoleLocator" /> + <type name="Magento\Framework\Authorization"> + <plugin name="guestAuthorization" type="Magento\Webapi\Model\Plugin\GuestAuthorization" /> </type> </config> diff --git a/app/code/Magento/Weee/Block/Sales/Order/Totals.php b/app/code/Magento/Weee/Block/Sales/Order/Totals.php index 2e8a7794dc2..d9e709ada96 100644 --- a/app/code/Magento/Weee/Block/Sales/Order/Totals.php +++ b/app/code/Magento/Weee/Block/Sales/Order/Totals.php @@ -28,19 +28,19 @@ class Totals extends \Magento\Framework\View\Element\Template /** * @var \Magento\Weee\Helper\Data */ - protected $_weeeData; + protected $weeeData; /** - * @param \Magento\Weee\Helper\Data $_weeeData * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Weee\Helper\Data $weeeData * @param array $data */ public function __construct( - \Magento\Weee\Helper\Data $_weeeData, \Magento\Framework\View\Element\Template\Context $context, + \Magento\Weee\Helper\Data $weeeData, array $data = array() ) { - $this->_weeeData = $_weeeData; + $this->weeeData = $weeeData; parent::__construct($context, $data); } @@ -65,7 +65,7 @@ class Totals extends \Magento\Framework\View\Element\Template $items = $this->getSource()->getAllItems(); $store = $this->getSource()->getStore(); - $weeeTotal = $this->_weeeData->getTotalAmounts($items, $store); + $weeeTotal = $this->weeeData->getTotalAmounts($items, $store); if ($weeeTotal) { // Add our total information to the set of other totals $total = new \Magento\Framework\Object( diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index 29650859b10..df204ed3d47 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-weee", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-bundle": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-bundle": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index 35416fd879a..2403b38e284 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-widget", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/etc/adminhtml/acl.xml b/app/code/Magento/Widget/etc/acl.xml similarity index 93% rename from app/code/Magento/Widget/etc/adminhtml/acl.xml rename to app/code/Magento/Widget/etc/acl.xml index a885eca4694..bb1a67686a7 100644 --- a/app/code/Magento/Widget/etc/adminhtml/acl.xml +++ b/app/code/Magento/Widget/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 0316d3b519f..6dd7470f703 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -2,26 +2,26 @@ "name": "magento/module-wishlist", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-bundle": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-grouped-product": "0.1.0-alpha89", - "magento/module-configurable-product": "0.1.0-alpha89", - "magento/module-downloadable": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-bundle": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-grouped-product": "0.1.0-alpha90", + "magento/module-configurable-product": "0.1.0-alpha90", + "magento/module-downloadable": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/etc/adminhtml/acl.xml b/app/code/Magento/Wishlist/etc/acl.xml similarity index 94% rename from app/code/Magento/Wishlist/etc/adminhtml/acl.xml rename to app/code/Magento/Wishlist/etc/acl.xml index cec8e12ff1d..f2562e9a376 100644 --- a/app/code/Magento/Wishlist/etc/adminhtml/acl.xml +++ b/app/code/Magento/Wishlist/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd"> <acl> <resources> <resource id="Magento_Adminhtml::admin"> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_bundle.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_bundle.xml index cdc3975ab1b..ea3f602e1c6 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_bundle.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_bundle.xml @@ -39,7 +39,7 @@ </arguments> </block> <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.bundle" as="addtocart" template="product/view/addtocart.phtml"/> - <block class="Magento\Catalog\Block\Product\View" name="product.info.addto.bundle" as="addto" template="product/view/addto.phtml"/> + <block class="Magento\Wishlist\Block\Item\Configure" name="product.info.addto.bundle" as="addto" template="item/configure/addto.phtml"/> </block> </referenceBlock> <referenceBlock name="product.info.options.wrapper"> diff --git a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js index 886d693c455..6e626c5150e 100644 --- a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js +++ b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js @@ -50,7 +50,10 @@ define([ }, _updateWishlistData: function(event) { var dataToAdd = {}; - dataToAdd[$(event.currentTarget).attr('name')] = $(event.currentTarget).val(); + $(event.handleObj.selector).each(function(index, element){ + dataToAdd[$(element).attr('name')] = $(element).val(); + }); + $('[data-action="add-to-wishlist"]').each(function(index, element) { var params = $(element).data('post'); params.data = $.extend({}, params.data, dataToAdd); diff --git a/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less b/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less index eaaa2648aa3..1687c590088 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Theme/web/css/source/module.less @@ -477,6 +477,9 @@ button { @_dropdown-split-list-min-width: 175px ); vertical-align: middle; + .action-toggle:after { + height: 13px; + } } .page-content { diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 8d5060896f3..e6a1b089950 100644 --- a/app/design/adminhtml/Magento/backend/composer.json +++ b/app/design/adminhtml/Magento/backend/composer.json @@ -2,12 +2,12 @@ "name": "magento/theme-adminhtml-backend", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index e4b8434d1fe..fe67f100a60 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-alpha89</version> + <version>0.1.0-alpha90</version> </theme> diff --git a/app/design/adminhtml/Magento/backend/web/css/source/theme.less b/app/design/adminhtml/Magento/backend/web/css/source/theme.less index 107ec550dca..b5b2a035835 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/theme.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/theme.less @@ -38,13 +38,14 @@ @page-main-action-color: #645D53; @dropdown-split-actions-padding: ''; -@dropdown-split-toggle-actions-padding: 0 5px; +@dropdown-split-toggle-actions-padding: 6px 5px; +@dropdown-split-toggle-icon-font-line-height: 14px; // Default = secondary button -@button-padding: 0 13px; +@button-padding: 6px 13px; @button-font-weight: 500; @button-font-size: 13px; -@button-height: 26px; +@button-line-height: @button-font-size + 1; @button-color: #645D53; @button-background: #f2ebde; @button-border: 1px solid #ada89e; @@ -54,8 +55,8 @@ @button-background-active: @button-background-hover; @button-color-active: ''; @button-border-active: 1px solid #989287; + // Primary button -@button-primary-height: @button-height; @button-primary-background: #007dbd; @button-primary-border: 1px solid #0a6c9f; @button-primary-color: #fff; @@ -84,7 +85,6 @@ // // Grid //-------------------------------------- - @grid-frame-bg: #fff; @grid-controls-border: #989287; 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 2e7073e03ae..9a9d1525db9 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 @@ -97,7 +97,8 @@ } .product-addto-links { > .action { - &:extend(.abstract-action-addto all); + &:extend(.abstract-action-addto-product all); + vertical-align: top; } } } @@ -109,7 +110,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .bundle-options-container { .legend.title { &:extend(.reset-left-margin all); diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/layout/catalog_product_view.xml b/app/design/frontend/Magento/blank/Magento_Catalog/layout/catalog_product_view.xml index de403ef3008..6f19ae1a64b 100644 --- a/app/design/frontend/Magento/blank/Magento_Catalog/layout/catalog_product_view.xml +++ b/app/design/frontend/Magento/blank/Magento_Catalog/layout/catalog_product_view.xml @@ -26,4 +26,5 @@ <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../app/code/Magento/Core/etc/layout_single.xsd"> <move element="page.main.title" destination="product.info.main" before="-"/> + <move element="product.info.media" destination="content" before="product.info.main" /> </layout> 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 8dd6f5343de..687a2d2ed31 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 @@ -24,30 +24,32 @@ @product-grid-items-per-row-layout-default: 2; -@product-grid-items-per-row-layout-1-break-point-0: 3; -@product-grid-items-per-row-layout-1-break-point-1: 4; -@product-grid-items-per-row-layout-1-break-point-2: 5; +@product-grid-items-per-row-layout-1-screen-s: 3; +@product-grid-items-per-row-layout-1-screen-m: 4; +@product-grid-items-per-row-layout-1-screen-l: 5; -@product-grid-items-per-row-layout-2-left-break-point-0: 3; -@product-grid-items-per-row-layout-2-left-break-point-1: 4; -@product-grid-items-per-row-layout-2-left-break-point-2: ''; +@product-grid-items-per-row-layout-2-left-screen-s: 3; +@product-grid-items-per-row-layout-2-left-screen-m: 4; +@product-grid-items-per-row-layout-2-left-screen-l: ''; -@product-grid-items-per-row-layout-2-right-break-point-0: 3; -@product-grid-items-per-row-layout-2-right-break-point-1: 4; -@product-grid-items-per-row-layout-2-right-break-point-2: ''; +@product-grid-items-per-row-layout-2-right-screen-s: 3; +@product-grid-items-per-row-layout-2-right-screen-m: 4; +@product-grid-items-per-row-layout-2-right-screen-l: ''; -@product-grid-items-per-row-layout-3-break-point-0: 3; -@product-grid-items-per-row-layout-3-break-point-1: ''; -@product-grid-items-per-row-layout-3-break-point-2: ''; +@product-grid-items-per-row-layout-3-screen-s: 3; +@product-grid-items-per-row-layout-3-screen-m: ''; +@product-grid-items-per-row-layout-3-screen-l: ''; @product-grid-items-padding: 0 @indent-base @indent-base; -@product-grid-items-margin: 0 0 @indent-l-base; +@product-grid-items-margin: 0 0 @indent-s-base; @product-name-text-decoration: none; @product-name-text-decoration-hover: @link-text-decoration-hover; @toolbar-mode-icon-font-size: 26px; +@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); @@ -111,30 +113,30 @@ .product-item-grid(@_layout-class: false, @product-grid-items-per-row-layout-default); } -.responsive(@break) when (@break = @break-point-0) { +.responsive(@break) when (@break = @screen-s) { .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-break-point-0); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-break-point-0); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-break-point-0); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-break-point-0); + .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 = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-break-point-1); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-break-point-1); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-break-point-1); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-break-point-1); + .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 = @break-point-2) { +.responsive(@break) when (@break = @screen-l) { .products.grid .item.product { - .product-item-grid(@layout-class-1column, @product-grid-items-per-row-layout-1-break-point-2); - .product-item-grid(@layout-class-2columns-left, @product-grid-items-per-row-layout-2-left-break-point-2); - .product-item-grid(@layout-class-2columns-right, @product-grid-items-per-row-layout-2-right-break-point-2); - .product-item-grid(@layout-class-3columns, @product-grid-items-per-row-layout-3-break-point-2); + .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); } } @@ -210,150 +212,61 @@ } } .action { - &.towishlist { - .icon-font( - @icon-wishlist-empty, - @_icon-font-size: 29px, - @_icon-font-color: @text-color-muted, - @_icon-font-text-hide: true, - @_icon-font-vertical-align: middle, - @_icon-font-line-height: normal - ); + &.tocompare { + &:extend(.abstract-actions-addto-gridlist all); } &.tocompare { - .icon-font( - @icon-compare-empty, - @_icon-font-size: 29px, - @_icon-font-color: @text-color-muted, - @_icon-font-text-hide: true, - @_icon-font-vertical-align: middle, - @_icon-font-line-height: normal + .icon-font-symbol( + @icon-compare-empty ); } } } &.wrapper.list { .products.list.items { - .item.product { + .product-item { display: block; margin-bottom: @indent-l-base; - } - .product.photo { - display: block; - } - .details { - text-align: center; - } - .name { - font-size: @font-size-l; - margin-bottom: @indent-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 { - .item.product { + .product-item { display: inline-block; padding: @product-grid-items-padding; margin: @product-grid-items-margin; } - .img.container { + .product-image-container { margin-bottom: @indent-base; } .actions { - > .primary { + > .actions-primary { display: inline-block; + + .actions-secondary { + margin-top: @indent-s-base; + } } } } } - - &.toolbar { - padding: @indent-s-base; - background: @panel-bg; - margin-bottom: @indent-xl-base; - text-align: center; - &:extend(.add-box-sizing all); - .settings, - .pages, - .pager { - margin-bottom: @indent-s-base; - &:last-child { - margin-bottom: 0; - } - } - .modes { - display: inline-block; - margin-right: @indent-base; - margin-bottom: @indent-s-base; - .label { - .visually-hidden(); - } - .mode { - border: 1px solid @border-color-base; - font-weight: @font-weight-base; - color: @text-color-muted; - text-align: center; - width: floor(@toolbar-mode-icon-font-size * @line-height-base); - .icon-text-hide(); - &.active { - background: #e5e5e5; - color: #c7c7c7; - } - } - .mode + .mode { - margin-left: -4px; - border-left: none; - } - .mode.grid { - .icon-font( - @icon-grid, - @_icon-font-size: @toolbar-mode-icon-font-size - ); - } - .mode.list { - .icon-font( - @icon-list, - @_icon-font-size: @toolbar-mode-icon-font-size - ); - } - } - .sorter { - display: inline-block; - select { - .form-element-size(@_width: auto); - } - .action.sort.asc { - .icon-font( - @icon-arrow-down, - @_icon-font-size: 27px, - @_icon-font-color: @text-color-muted - ); - .icon-text-hide(); - } - .action.sort.desc { - .icon-font( - @icon-arrow-up, - @_icon-font-size: 27px, - @_icon-font-color: @text-color-muted - ); - .icon-text-hide(); - } - } - .limiter { - display: inline; - margin-left: @indent-base; - select { - .form-element-size(@_width: auto); - } - .text { - display: none; - } - } - .amount { - display: inline; - } - } } // @@ -443,23 +356,19 @@ } .box-tocart { - display: table; margin: @indent-base 0; .field.qty { - display: table-cell; - vertical-align: bottom; padding-right: 0.75 * @indent-base; } .input-text.qty { + @tocart-input-size: @button-l-line-height + 28px; .form-element-size( - @_width: @button-l-height + 2px, - @_height: @button-l-height + 2px + @_width: @tocart-input-size + 2px, + @_height: @tocart-input-size + 2px ); text-align: center; } .actions { - display: table-cell; - vertical-align: bottom; text-align: center; } .action.tocart { @@ -470,7 +379,8 @@ margin: @indent-base 0; } .action.tocompare { - &:extend(.abstract-action-addto all); + &:extend(.abstract-action-addto-product all); + vertical-align: top; } .product-reviews-summary .reviews-actions { .font-size(@font-size-base); @@ -491,10 +401,47 @@ display: block; } +.ui-dialog-titlebar-close { + .button-as-link(); +} + +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .product-info-main .box-tocart { + .actions { + .action.tocart { + &:extend(.abstract-button-responsive-smaller all); + } + } + } +} + +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { + .product-info-main { + .box-tocart { + display: table; + .field.qty { + display: table-cell; + } + .actions { + display: table-cell; + padding-top: 25px; + text-align: center; + vertical-align: bottom; + } + } + } +} + // // Category page layout //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .product-info-main { float: right; } @@ -551,7 +498,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .product-add-form { &:extend(.revert-field-type-desktop all); } @@ -643,11 +590,11 @@ body.catalog-product-compare-index { } } -.comparison.wrapper { +.table-wrapper.comparison { clear: both; } -.data.comparison { +.table-comparison { table-layout: fixed; .cell.label.remove, @@ -695,16 +642,16 @@ body.catalog-product-compare-index { border-right: 1px solid #e5e5e5; } - .product.photo { + .product-item-photo { text-align: center; display: block; margin: 0 auto 15px; } - .actions, + .product-item-actions, .price-box, .product.rating, - .product.name { + .product-item-name { display: block; margin: 15px 0; } @@ -730,6 +677,13 @@ body.catalog-product-compare-index { &:extend(.remove-button-for-blocks all); } } + .product-item-actions { + > .actions-primary { + + .actions-secondary { + margin-top: @indent-s-base; + } + } + } } .comparison.headings { @@ -767,3 +721,12 @@ body.catalog-product-compare-index { max-width: 178px; } } + +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { + .table-wrapper.comparison { + .table-overflow(); + } +} diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/toolbar.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/toolbar.less new file mode 100644 index 00000000000..fc988c625b7 --- /dev/null +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/toolbar.less @@ -0,0 +1,161 @@ +// /** +// // * 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) +// */ + +@toolbar-mode-icon-font-size: 24px; +@toolbar-element-background: @panel-bg; +@pager-font-weight: @font-weight-bold; + +.page-products .columns { + position: relative; + z-index: 1; + padding-top: 38px; +} + +.toolbar { + &-amount { + display: block; + float: left; + line-height: @toolbar-mode-icon-font-size+2; + padding: 8px 0 0; + margin: 0; + vertical-align: middle; + .products.wrapper ~ .toolbar & { + display: none; + } + } + &-products { + margin-bottom: @indent-xl-base; + text-align: center; + padding: 0 @indent-s-base; + &:extend(.add-clearfix all); + .pages { + display: none; + .products.wrapper ~ & { + display: block; + } + } + .limiter { + display: none; + } + } +} + +.sorter { + float: right; + padding: 4px 0 0; + .products.wrapper ~ .toolbar & { + display: none; + } + &-options { + margin: 0 5px 0 7px; + width: auto; + } + &-action { + .icon-font( + @icon-arrow-down, + @_icon-font-size: 24px, + @_icon-font-color: @text-color-muted + ); + .icon-text-hide(); + &.sort-desc:before { + content: @icon-arrow-down; + } + } +} + +.modes { + display: none; +} + +.limiter { + &-options { + width: auto; + margin: 0 5px 0 7px; + } + &-label { + font-weight: 400; + } + .page-products .toolbar & { + display: none; + } +} + +.responsive(@break) when (@break = @screen-s) { + .page-products .columns { + position: relative; + z-index: 1; + padding-top: 0; + } + .toolbar { + .products.wrapper ~ & .pages { + float: left; + } + } + .modes { + float: left; + display: inline-block; + margin-right: @indent-base; + overflow: hidden; + .products.wrapper ~ .toolbar & { + display: none; + } + &-label { + .visually-hidden; + } + &-mode { + float: left; + border: 1px solid @border-color-base; + font-weight: @font-weight-base; + color: @text-color-muted; + text-align: center; + padding: 7px 10px; + line-height: 1; + border-right: 0; + .icon-text-hide(); + &:not(.active):hover { + background: darken(@toolbar-element-background, 7%); + color: @text-color-muted; + } + &:last-child { + border-right: 1px solid @border-color-base; + } + &.active { + color: @color-primary-light; + } + .icon-font( + @icon-grid, + @_icon-font-size: @toolbar-mode-icon-font-size + ); + } + } + .mode-list { + .icon-font-symbol(@icon-list); + } + .limiter { + float: right; + .products.wrapper ~ .toolbar & { + display: block; + } + } +} diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/widgets.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/widgets.less index 36f7e1a86cb..03b747dd275 100644 --- a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/widgets.less +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/widgets.less @@ -50,7 +50,7 @@ div.widget.category.link { // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .block.widget.new { .pager { text-align: left; diff --git a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/module.less index c524da6c6f3..1a0ae1bbfae 100644 --- a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/module.less @@ -28,9 +28,12 @@ @autocomplete-item-hover: #e8e8e8; @autocomplete-item-amount-color: #999; -.block.search { - .title { - display: none; +.block-search { + margin-bottom: 0; + .block { + &-title { + display: none; + } } .label { .icon-font( @@ -70,7 +73,7 @@ } -.search.autocomplete { +.search-autocomplete { display: none; position: absolute; z-index: 3; @@ -78,6 +81,7 @@ margin-top: -15px; &:extend(.add-box-sizing all); ul { + .list-reset-styles(); li { &:not(:empty) { background: @autocomplete-background; @@ -153,8 +157,8 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { - .block.search { +.responsive(@break) when (@break = @screen-m) { + .block-search { position: relative; float: right; padding-left: 15px; @@ -166,7 +170,7 @@ .control { border-top: 0; margin: 0; - padding: 0; + padding: 0 0 25px; } .nested { display: block; @@ -197,9 +201,10 @@ color: #333; } } + padding: 5px 0; } } - .search.autocomplete { + .search-autocomplete { margin-top: 0; } } diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/cart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/cart.less index a3dbfa00751..3b3d197b82d 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/cart.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/cart.less @@ -198,7 +198,7 @@ } .item { &-actions td { - padding-bottom: 20px; + padding-bottom: 10px; text-align: center; white-space: normal; } @@ -216,13 +216,18 @@ } } } - .action { - &:extend(button all); - .link-as-button(); - margin-left: 10px; - &:first-child { - margin-left: 0; + .actions { + > .action { + &:extend(button all); + .link-as-button(); + margin-left: 10px; + margin-bottom: 10px; + &:first-child { + margin-left: 0; + } } + } + .action { &.help.map { &:extend(.abstract-action-button-as-link all); font-weight: @font-weight-base; @@ -247,12 +252,11 @@ &-item-name { display: inline-block; font-weight: @font-weight-base; - max-width: 130px; overflow: hidden; text-overflow: ellipsis; } } - // Product options + // Product options .cart-item-options { font-size: @font-size-s; margin-top: @indent-s-base; @@ -273,10 +277,11 @@ &.continue { .link-as-button(); .button( - @_button-padding: 0 15px 0 5px, + @_button-padding: 7px 15px 7px 0, @_button-icon-use: true, @_button-font-content: @icon-prev, @_button-icon-font-size: 32px, + @_button-icon-font-line-height: 16px, @_button-icon-font-position: before ); border-radius: 3px; @@ -288,7 +293,8 @@ &.update { .button-icon( @icon-update, - @_icon-font-size: 32px + @_icon-font-size: 32px, + @_icon-font-line-height: 16px ); padding-left: 5px; } @@ -326,7 +332,7 @@ // // Mobile //-------------------------------------- -.responsive-smaller(@break) when (@break = @break-point-1) { +.responsive-smaller(@break) when (@break = @screen-m) { .cart { &.table-wrapper { thead { @@ -371,7 +377,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .cart { &-container { &:extend(.add-clearfix-desktop all); diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/minicart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/minicart.less index 8f6e6f75b93..a9dd73a13a2 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/minicart.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/minicart.less @@ -25,8 +25,7 @@ // // Minicart //-------------------------------------- - -.block.minicart { +.block-minicart { .subtotal { border-top: 1px solid @color-secondary; padding-top: 10px; @@ -49,6 +48,14 @@ text-align: center; font-size: 14px; } + .empty.text { + margin: -10px 0 20px; + text-align: center; + & + .actions { + margin-bottom: 10px; + text-align: center; + } + } > .content > .actions { margin-top: 10px; > .secondary, @@ -62,7 +69,7 @@ .minicart-wrapper { .dropdown( @_toggle-selector: ~".action.showcart", - @_options-selector: ~".block.minicart", + @_options-selector: ~".block-minicart", @_dropdown-toggle-icon-content: @icon-cart, @_dropdown-toggle-active-icon-content: @icon-cart, @_dropdown-list-item-padding: false, @@ -75,8 +82,8 @@ @_icon-font-color-active: @color-primary ); float: right; - .block.minicart { - right: -15px; + .block-minicart { + right: -7px; width: 320px; padding: 15px; > .title { @@ -163,10 +170,9 @@ display: inline-block; height: 26px; line-height: 26px; - margin: 3px 0 0; + margin: 3px 0 0 -5px; max-width: 2em; min-width: 20px; - padding: 0 3px; overflow: hidden; text-align: center; white-space: normal; @@ -211,13 +217,22 @@ } // -// Desktop +// Mobile //-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-xs) { + .minicart-wrapper .block-minicart { + width: 280px; + } +} -.responsive(@break) when (@break = @break-point-1) { +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { .minicart-wrapper { - margin-left: 30px; - .block.minicart { + margin-left: 10px; + .block-minicart { + right: -15px; width: 380px; } } diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module.less index dde2b9b948b..6e6efca1563 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module.less @@ -25,10 +25,11 @@ @import "cart.less"; @import "minicart.less"; +@desctop-form-field-vertical-indent: 29px; + // // One Page Checkout //-------------------------------------- - .opc-wrapper { &:extend(.add-box-sizing all); .css(padding-bottom, @indent-xl-base); @@ -39,9 +40,16 @@ &.allow .step-title { cursor: pointer; } - &.active .step-title { - color: @color-primary-darker; - cursor: default; + &.active { + .step { + &-title { + color: @color-primary-darker; + cursor: default; + } + &-content { + display: block; + } + } } } .step { @@ -59,10 +67,11 @@ border-bottom: @border-width-base solid @border-color-base; } &-content { - padding: 20px 25px 40px; + display: none; + padding: 20px 10px; position: relative; .addresses .control { - margin: 20px 0 30px; + margin: 20px 0; } .fieldset { margin-bottom: 0; @@ -73,6 +82,14 @@ text-align: center; } } + > .field { + margin: @form-field-vertical-indent 0 0; + } + &.address { + .field:first-of-type:not(.additional) { + margin: 0; + } + } } .form { .form-hasrequired(bottom); @@ -82,9 +99,15 @@ > .choice { margin-top: @form-field-vertical-indent; } + .field:not(:first-child) { + margin: 20px 0 0; + } + > .field.choice { + margin: @form-field-vertical-indent 0 0; + } } .actions { - margin-top: 40px; + margin-top: 20px; } } } @@ -106,21 +129,34 @@ &:extend(.abstract-shipping-methods-title all); } .item-content { - margin: 0 0 10px 20px; + margin: 0 0 20px; + .field.choice { + margin: 0 0 10px; + } + .price { + font-weight: @font-weight-bold; + } } .price.box { margin-left: 20px; - .regular .price { + .label + .price { font-weight: @font-weight-bold; } } } .methods-payment { - .content { + .item-title { + font-weight: @font-weight-base; + } + .item-content { margin-bottom: 0; .fieldset { padding: 15px 0; + .field:first-child, + .field.year { + margin-top: 0; + } } .label { font-weight: @font-weight-base; @@ -128,6 +164,13 @@ } } + .opc-payment-additional { + margin: 0 0 5px; + + .opc-payment { + margin: 20px 0 0; + } + } + // Order review .data.table { &:extend(.product-options-list all); @@ -197,7 +240,6 @@ // // Checkout Progress //-------------------------------------- - .opc-block-progress { &:extend(.add-box-sizing all); margin-bottom: @indent-l-base; @@ -255,7 +297,6 @@ // // Checkout Success //-------------------------------------- - .checkout-onepage-success { .page-title { .print { @@ -270,11 +311,40 @@ } } + // -// Desktop +// Mobile //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive-smaller(@break) when (@break = @screen-m) { + .opc-wrapper { + .data.table { + &:extend(.table-vertical-mobile all); + tbody tr { + &:first-child, + &:last-child { + td { + border: 0; + } + } + td:last-child { + border-bottom: @border-width-base solid @border-color-base; + } + .col { + &.qty, + &.price, + &.subtotal { + text-align: left; + } + } + } + } + } +} +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-m) { .checkout-onepage-index .column.main { &:extend(.add-clearfix-desktop all); } @@ -283,17 +353,30 @@ .layout-column(2, 2, @layout-column-checkout-main-width); &:extend(.add-box-sizing-desktop all); .step-content { + padding: 20px 18px 40px; + .addresses .control { + margin-bottom: @desctop-form-field-vertical-indent; + } .form { &:after { text-align: right; } - } - .form:not(.login) .actions-toolbar { - &:extend(.reset-left-margin-desktop all); + &:not(.login) .actions-toolbar { + &:extend(.reset-left-margin-desktop all); + } + > .field.choice, + .fieldset > .field { + margin: @desctop-form-field-vertical-indent 0 0; + } + .fieldset.address { + .field:first-of-type:not(.additional) { + margin: 0; + } + } } .fieldset.login { &:after { - &:extend(.margin-for-forms-desktop all); + &:extend(.margin-for-forms-desktop all); text-align: left; } } @@ -327,7 +410,6 @@ .checkout-onepage-success { .page-title { .print { - display: none; display: inline-block; margin-left: 40px; .font-size(14); diff --git a/app/design/frontend/Magento/blank/Magento_Customer/layout/customer_account.xml b/app/design/frontend/Magento/blank/Magento_Customer/layout/customer_account.xml new file mode 100644 index 00000000000..a31dca5a264 --- /dev/null +++ b/app/design/frontend/Magento/blank/Magento_Customer/layout/customer_account.xml @@ -0,0 +1,64 @@ +<?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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../app/code/Magento/Core/etc/layout_single.xsd"> + <update handle="page_two_columns_left"/> + <referenceBlock name="root"> + <action method="addBodyClass"> + <argument name="class" xsi:type="string">account</argument> + </action> + </referenceBlock> + <referenceContainer name="sidebar.main"> + <block class="Magento\Framework\View\Element\Template" name="customer_account_navigation_block" template="Magento_Theme::html/collapsible.phtml"> + <arguments> + <argument name="block_title" translate="true" xsi:type="string">Account Dashboard</argument> + <argument name="block_css" xsi:type="string">block-account-nav</argument> + </arguments> + <block class="Magento\Framework\View\Element\Html\Links" name="customer_account_navigation" before="-"> + <arguments> + <argument name="css_class" xsi:type="string">nav items</argument> + </arguments> + <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-link"> + <arguments> + <argument name="label" xsi:type="string">Account Dashboard</argument> + <argument name="path" xsi:type="string">customer/account</argument> + </arguments> + </block> + <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-edit-link"> + <arguments> + <argument name="label" xsi:type="string">Account Information</argument> + <argument name="path" xsi:type="string">customer/account/edit</argument> + </arguments> + </block> + <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-address-link"> + <arguments> + <argument name="label" xsi:type="string">Address Book</argument> + <argument name="path" xsi:type="string">customer/address</argument> + </arguments> + </block> + </block> + </block> + </referenceContainer> +</layout> 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 1455462bd7c..a8d69d856e6 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 @@ -128,15 +128,16 @@ } } } - .block.account-nav { + .sidebar .block-account-nav { .css(background, @sidebar-background); - padding: 15px 0; + margin: 0 0 40px; + } + .block-account-nav { .title { - padding: 0 18px; - margin-bottom: 25px; - strong { - .heading(h3); - } + display: none; + } + .content { + padding: 15px 0; } .nav.items { padding: 0; @@ -149,8 +150,7 @@ a, strong { display: block; - padding: 0 18px 0 15px; - line-height: 30px; + padding: 5px 18px 5px 15px; border-left: 3px solid transparent; } a { @@ -161,6 +161,7 @@ } } &.current { + a, strong { .css(color, @account-nav-current-color); .css(border-color, @account-nav-current-border-color); @@ -214,21 +215,95 @@ } } - .control.captcha-image { + .css(margin-top, @indent-s-base); .captcha-img { - float: left; - margin: 0 20px 0 0; + vertical-align: middle; + } +} + +.widget { + img { + max-width: 100%; + } +} + +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .account { + .data.table { + &:extend(.table-vertical-mobile all); + .col.actions { + padding-top: 9px; + padding-bottom: 15px; + &:before { + &:extend(.visually-hidden-mobile all); + } + } + } + .toolbar { + .toolbar-amount, + .limiter, + .pages { + margin-bottom: 25px; + } + } + .block-account-nav { + margin-left: -@layout-width-xs-indent; + 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; + } + strong { + margin: 0; + } + &.active { + .icon-font-symbol( + @_icon-font-content: @icon-prev, + @_icon-font-position: after + ); + } + } + .content { + display: none; + &.active { + display: block; + } + } + } } - .action.reload { - margin: 10px 0 0; + .control.captcha-image { + .captcha-img { + display: block; + .css(margin-bottom, @indent-s-base); + } } } // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .login.container { &:extend(.add-clearfix-desktop all); .block { @@ -336,29 +411,11 @@ .widget { clear: both; } -} -// -// Mobile -//-------------------------------------- -.responsive-smaller(@break) when (@break = @break-point-0) { - .account { - .data.table { - &:extend(.table-vertical-mobile all); - .col.actions { - padding-top: 9px; - padding-bottom: 15px; - &:before { - &:extend(.visually-hidden-mobile all); - } - } - } - .toolbar { - .toolbar-amount, - .limiter, - .pages { - margin-bottom: 25px; - } + .control.captcha-image { + white-space: nowrap; + .captcha-img { + margin: 0 10px 0 0; } } } diff --git a/app/design/frontend/Magento/blank/Magento_GiftMessage/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_GiftMessage/web/css/source/module.less index 43377499ac7..6878cadc320 100644 --- a/app/design/frontend/Magento/blank/Magento_GiftMessage/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_GiftMessage/web/css/source/module.less @@ -25,12 +25,13 @@ .opc-wrapper { .gift-message { > legend { - margin-left: 0; - padding: 0; + .font-size(14); + font-weight: @font-weight-bold; + margin: 20px 0 0; } .field.choice { font-weight: @font-weight-base; - margin: 0 0 20px 20px; + margin: 0 0 20px; &:before { display: none; } @@ -43,10 +44,11 @@ background: @sidebar-background; display: block; margin: 20px 0 0; - padding: 20px 20px 20px 10px; - .order-title { - margin-top: 10px; - margin-bottom: 0; + padding: 20px; + .order-title:not(:first-child), + .extra-options-container { + font-weight: @font-weight-base; + margin: 20px 0 0; } .order-options { margin: 0 0 20px 20px; @@ -78,12 +80,9 @@ } } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .opc-wrapper { .gift-message { - .options-items .order-options { - margin-left: 45px; - } .item { border-bottom: @border-width-base solid @border-color-base; margin-bottom: 20px; @@ -109,11 +108,5 @@ display: block; } } - .extra-options-container { - .price.box { - font-weight: normal; - margin-left: 45px; - } - } } } diff --git a/app/design/frontend/Magento/blank/Magento_Multishipping/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Multishipping/web/css/source/module.less index bbc04cd2f03..4ca592d4e99 100644 --- a/app/design/frontend/Magento/blank/Magento_Multishipping/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Multishipping/web/css/source/module.less @@ -148,7 +148,7 @@ } } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .multicheckout { &.form { .title { diff --git a/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/module.less index 7d6f02d9ec8..cd575fd5926 100644 --- a/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/module.less @@ -77,7 +77,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .block.newsletter { width: 32%; .field { diff --git a/app/design/frontend/Magento/blank/Magento_Paypal/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Paypal/web/css/source/module.less index a577bbb6443..990abb7f1bf 100644 --- a/app/design/frontend/Magento/blank/Magento_Paypal/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Paypal/web/css/source/module.less @@ -25,7 +25,6 @@ // // PayPal checkout button //-------------------------------------- - .paypal { &.after:after { content: "- " attr(data-label) " -"; @@ -42,6 +41,18 @@ } } +.product-info-main, +.block-minicart { + .paypal img { + display: block; + } +} +.product-info-main { + img { + margin: 0 auto; + } +} + .form-new-agreement { .actions-toolbar { &:extend(.reset-left-margin all); diff --git a/app/design/frontend/Magento/blank/Magento_RecurringPayment/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_RecurringPayment/web/css/source/module.less new file mode 100644 index 00000000000..a82b30a271c --- /dev/null +++ b/app/design/frontend/Magento/blank/Magento_RecurringPayment/web/css/source/module.less @@ -0,0 +1,30 @@ +// /** +// // * 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) +// */ + +.payment-schedule { + margin: 20px 0 0; + .item-content { + margin: 0 0 5px; + } +} diff --git a/app/design/frontend/Magento/blank/Magento_Review/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Review/web/css/source/module.less index 694752b2b22..a3e06509ccd 100644 --- a/app/design/frontend/Magento/blank/Magento_Review/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Review/web/css/source/module.less @@ -22,7 +22,6 @@ // * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) // */ - .rating-summary { .mixin-rating-summary(); .rating-result { @@ -42,7 +41,7 @@ } // -// Add reviewblock +// Add review block //-------------------------------------- .block { &.add.review { @@ -88,10 +87,11 @@ } } -.customer.review.view { +.customer-review.view { + margin-bottom: @indent-base; .review.title, - .ratings.summary.items, - .product.details { + .ratings-summary, + .product-details { margin-bottom: @indent-base; } } @@ -127,7 +127,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .product-reviews-summary { .products.wrapper.list & { margin: 0; @@ -180,3 +180,160 @@ } } } + +.review-field-ratings { + .nested { + display: table; + } + .review-field-rating { + display: table-row; + .label, + .control { + display: table-cell; + padding-bottom: @indent-s-base; + vertical-align: top; + } + .label { + padding-top: 6px; + padding-right: @indent-s-base; + } + .control { + padding-top: 2px; + } + } +} + +// +// Review product page +//-------------------------------------- +.review { + &-toolbar { + border-top: 1px solid #c9c9c9; + margin: 0 0 @indent-base; + text-align: center; + &:first-child { + display: none; + } + .pages { + display: block; + text-align: center; + border-bottom: 1px solid #c9c9c9; + padding: @indent-base 0; + } + .limiter { + display: none; + } + } + &-add { + .block-title { + display: none; + } + } + &-form { + .action.submit.primary { + .button-revert-secondary-color(); + } + .actions-toolbar .actions-primary { + } + } + &-fieldset {} + .fieldset &-legend.legend { + &:extend(.reset-left-margin all); + strong { + display: block; + margin-left: 0; + } + margin-bottom: @indent-base; + } + .fieldset &-field-ratings { + > .label { + } + } + &-control-vote label:before, + &-control-vote:before { + } + &-field-rating { + .label { + } + .control { + margin-top: @indent-s-base; + margin-bottom: 1.2*@indent-xl-base; + } + } + &-list { + .block-title strong { + .heading(h2); + } + margin-bottom: @indent-l-base; + } + &-item { + padding: @indent-base 0; + border-bottom: 1px solid #c9c9c9; + margin: 0; + .clearer(); + &:last-child { + border-width: 0; + } + } + &-ratings { + display: table; + max-width: 100%; + margin-bottom: @indent-s-base; + &:extend(.abstract-rating-summary all); + } + &-author { + display: inline; + .review-details-value { + } + } + &-date { + .review-details-label { + } + } + &-title { + .heading(h3); + margin: 0 0 @indent-base; + } + &-content { + margin-bottom: @indent-base; + } +} + +// +// Desktop +//-------------------------------------- +.responsive(@break) when (@break = @screen-s) { + .review { + &-form { + max-width: 500px; + } + + @review-ratings-left: 280px; + &-ratings { + max-width: @review-ratings-left - @indent-xl-base; + float: left; + margin-bottom: 0; + } + &-ratings ~ &-content, + &-ratings ~ &-details { + margin-left: @review-ratings-left; + } + + @reviews-indent-desktop: 30px; + &-toolbar { + margin: 0 0 @reviews-indent-desktop; + .pages { + padding: @reviews-indent-desktop 0; + } + } + .fieldset &-legend.legend { + margin-bottom: @reviews-indent-desktop; + } + &-item { + padding: @reviews-indent-desktop 0; + } + &-title { + margin: 0 0 @reviews-indent-desktop; + } + } +} diff --git a/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/module.less index dd693905d11..f3ceb882267 100644 --- a/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/module.less @@ -172,10 +172,98 @@ } } +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-s) { + .account { + .order-details-items { + .table-order-items { + tbody, + tfoot { + > tr > td { + border: none; + } + } + tbody { + tr { + td:first-child { + padding-top: 15px; + } + td:last-child { + padding-bottom: 15px; + } + } + } + .col { + &.price, + &.subtotal { + .tax, + .incl.tax + .excl.tax, + .weee { + display: inline-block; + } + } + &.name, + &.sku, + &.qty, + &.price, + &.subtotal { + &:before { + content: attr(data-th) ":"; + vertical-align: top; + } + } + &.label { + display: none; + } + .items-qty { + display: inline-block; + } + .item.options { + .font-size(12); + margin: 10px 0 0; + } + } + .options-label + .item-options, + .item-options + .item-options { + &:before { + content: attr(data-th) ":"; + display: block; + font-weight: bold; + } + .col { + .font-size(12); + padding: 0; + &:first-child { + padding-top: 3px; + } + &:last-child { + padding-bottom: 20px; + } + } + } + } + .action.print { + display: none; + } + } + .toolbar { + &:extend(.add-clearfix-desktop all); + .pages { + float: right; + } + .limiter { + clear: both; + } + } + } +} + // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .account { .page-title { .order-actions-toolbar { @@ -199,21 +287,3 @@ } } } - -// -// Mobile -//-------------------------------------- -.responsive-smaller(@break) when (@break = @break-point-0) { - .account { - .order-details-items { - .table-order-items { - tbody, - tfoot { - > tr > td { - border: none; - } - } - } - } - } -} diff --git a/app/design/frontend/Magento/blank/Magento_Sendfriend/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Sendfriend/web/css/source/module.less index a3d7d817800..b74bffe3802 100644 --- a/app/design/frontend/Magento/blank/Magento_Sendfriend/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Sendfriend/web/css/source/module.less @@ -28,6 +28,7 @@ } .action.mailto.friend { + margin-left: -7px; .icon-font( @_icon-font-content: @icon-envelope, @_icon-font-size: 28px, @@ -44,7 +45,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .form.send.friend { &:extend(.add-recipients-desktop all); } diff --git a/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml b/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml index e7f75fe1dac..cf89503fff6 100644 --- a/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml +++ b/app/design/frontend/Magento/blank/Magento_Theme/layout/default.xml @@ -21,7 +21,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) - */ +*/ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../app/code/Magento/Core/etc/layout_single.xsd"> @@ -30,4 +30,42 @@ </referenceContainer> <move element="header.panel" destination="header.panel.wrapper" /> <move element="top.links" destination="header.panel" after="-" /> + + <move element="catalog.topnav" destination="store.menu" before="-" /> + + <referenceContainer name="page_top"> + <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml"> + <arguments> + <argument name="group_name" xsi:type="string">navigation-sections</argument> + <argument name="group_css" xsi:type="string">nav-sections</argument> + </arguments> + <block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml"> + <arguments> + <argument name="title" translate="true" xsi:type="string">Menu</argument> + </arguments> + </block> + <block class="Magento\Framework\View\Element\Text" name="store.links" group="navigation-sections" output="1"> + <arguments> + <argument name="title" translate="true" xsi:type="string">Account</argument> + <argument name="use_force" xsi:type="boolean">true</argument> + <argument name="text" xsi:type="string"><![CDATA[<!-- Account links -->]]></argument> + </arguments> + </block> + <block class="Magento\Framework\View\Element\Template" name="store.settings" group="navigation-sections" template="Magento_Theme::html/container.phtml"> + <arguments> + <argument name="title" translate="true" xsi:type="string">Settings</argument> + </arguments> + <block class="Magento\Store\Block\Switcher" name="store.settings.language" template="switch/languages.phtml"> + <arguments> + <argument name="id_modifier" xsi:type="string">nav</argument> + </arguments> + </block> + <block class="Magento\Directory\Block\Currency" name="store.settings.currency" before="store_language" template="currency.phtml"> + <arguments> + <argument name="id_modifier" xsi:type="string">nav</argument> + </arguments> + </block> + </block> + </block> + </referenceContainer> </layout> diff --git a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module.less b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module.less index f4003fdb502..2d5cf98ca27 100644 --- a/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module.less +++ b/app/design/frontend/Magento/blank/Magento_Theme/web/css/source/module.less @@ -38,6 +38,9 @@ @header-bg-color: false; +@addto-color: @text-color-muted; +@addto-hover-color: @color-primary; + body { .css(background-color, @page-bg-color); } @@ -196,7 +199,7 @@ body { // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .header { &.panel { > .header.links { @@ -254,14 +257,6 @@ body { } } - .page-wrapper { - position: relative; - width: 100%; - float: right; - margin: 0; - .transition(margin .3s ease-out 0); - } - .footer { &.content { .block { 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 fa04146e021..b8b4b04e3b2 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 @@ -31,7 +31,19 @@ .product-info-main, .block-bundle-summary { .action.towishlist { - &:extend(.abstract-action-addto all); + &:extend(.abstract-action-addto-product all); + } +} + +.products.list.items, +.table-comparison { + .action { + &.towishlist { + &:extend(.abstract-actions-addto-gridlist all); + .icon-font-symbol( + @icon-wishlist-empty + ); + } } } diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 629ed93f41a..5542bb6163a 100644 --- a/app/design/frontend/Magento/blank/composer.json +++ b/app/design/frontend/Magento/blank/composer.json @@ -2,12 +2,12 @@ "name": "magento/theme-frontend-blank", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index 70c8d683829..314963981af 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-alpha89</version> + <version>0.1.0-alpha90</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 38fc00f5edd..3aebfd5c2dd 100644 --- a/app/design/frontend/Magento/blank/web/css/source/abstract.less +++ b/app/design/frontend/Magento/blank/web/css/source/abstract.less @@ -71,16 +71,22 @@ .button-responsive(); } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .button-desktop { width: auto; } } +.responsive-smaller(@break) when (@break = @screen-m) { + .abstract-button-responsive-smaller { + .button-responsive(); + } +} + // // Blocks in 2 columns //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .blocks-2columns { width: 48.8%; &:nth-child(odd) { @@ -173,7 +179,7 @@ margin-left: 0; } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .reset-left-margin-desktop { margin-left: 0; } @@ -196,7 +202,7 @@ // // Action with icon remove with text for desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .action-remove-desktop when not (@form-field-type-inline-label-width = false) and not (@form-field-type-inline-label-width = '') { top: 6px; margin-left: @form-field-type-inline-label-width + 50%; @@ -243,7 +249,7 @@ // // Add Recipient for desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .add-recipients-desktop { .recipients { .additional { @@ -258,7 +264,7 @@ // // Margin for forms //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .margin-for-forms-desktop when not (@form-field-type-inline-label-width = false) and not (@form-field-type-inline-label-width = '') { margin-left: @form-field-type-inline-label-width; } @@ -271,12 +277,18 @@ .visually-hidden(); } -.responsive-smaller(@break) when (@break = @break-point-0) { +.responsive-smaller(@break) when (@break = @screen-s) { .visually-hidden-mobile { .visually-hidden(); } } +.responsive-smaller(@break) when (@break = @screen-m) { + .visually-hidden-mobile-m { + .visually-hidden(); + } +} + // // Clearfix //-------------------------------------- @@ -284,13 +296,13 @@ .clearfix(); } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .add-clearfix-desktop { .clearfix(); } } -.responsive-smaller(@break) when (@break = @break-point-0) { +.responsive-smaller(@break) when (@break = @screen-s) { .add-clearfix-mobile { .clearfix(); } @@ -303,7 +315,7 @@ .box-sizing(); } -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .add-box-sizing-desktop { .box-sizing(); } @@ -312,7 +324,7 @@ // // Revert field type //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .revert-field-type-desktop { .fieldset { > .field, @@ -359,11 +371,23 @@ // // Action addto //-------------------------------------- -.abstract-action-addto { +.abstract-action-addto-product { &:extend(.action-link-button all); .button-s(); } +.abstract-actions-addto-gridlist { + .icon-font( + @_icon-font-content: '', + @_icon-font-size: 29px, + @_icon-font-color: @addto-color, + @_icon-font-color-hover: @addto-hover-color, + @_icon-font-text-hide: true, + @_icon-font-vertical-align: middle, + @_icon-font-line-height: 24px + ); +} + // // Large button //-------------------------------------- @@ -405,7 +429,7 @@ // // Vertical Table //-------------------------------------- -.responsive-smaller(@break) when (@break = @break-point-0) { +.responsive-smaller(@break) when (@break = @screen-m) { .table-vertical-mobile { .table-responsive(); tbody > tr { diff --git a/app/design/frontend/Magento/blank/web/css/source/actions-toolbar.less b/app/design/frontend/Magento/blank/web/css/source/actions-toolbar.less index 11bf0c1f149..629a3748202 100644 --- a/app/design/frontend/Magento/blank/web/css/source/actions-toolbar.less +++ b/app/design/frontend/Magento/blank/web/css/source/actions-toolbar.less @@ -43,7 +43,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .actions-toolbar { .actions-toolbar(); > .primary, diff --git a/app/design/frontend/Magento/blank/web/css/source/forms.less b/app/design/frontend/Magento/blank/web/css/source/forms.less index 9b9f437b208..6a0b4f72cda 100644 --- a/app/design/frontend/Magento/blank/web/css/source/forms.less +++ b/app/design/frontend/Magento/blank/web/css/source/forms.less @@ -60,6 +60,13 @@ margin-bottom: 0; } } + &.date { + .control > input { + margin-right: 10px; + min-width: 80px; + width: 25%; + } + } } fieldset.field { border: 0; @@ -71,8 +78,6 @@ div.mage-error[generated] { margin-top: 7px; } -// TEMP - .field .tooltip { .tooltip(right); .tooltip-content { @@ -82,18 +87,21 @@ div.mage-error[generated] { } input:focus ~ .tooltip .tooltip-content, -select:focus ~ .tooltip .tooltip-content { display: block; } +select:focus ~ .tooltip .tooltip-content { + display: block; +} // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .fieldset { .legend { &:extend(.margin-for-forms-desktop all); } > .field { .form-field-type-revert(); + margin: 0 0 29px; } } } 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 8e64a62adb6..18434676bc6 100644 --- a/app/design/frontend/Magento/blank/web/css/source/layout.less +++ b/app/design/frontend/Magento/blank/web/css/source/layout.less @@ -25,7 +25,7 @@ @layout-column-main-sidebar-offset: 2%; @layout-column-additional-sidebar-offset: @layout-column-main-sidebar-offset; -.navigation > ul, +.navigation, .breadcrumbs, .page-header .header.panel, .header.content, @@ -38,20 +38,6 @@ padding-right: @layout-width-xs-indent; } -.page-wrapper { - position: relative; - left: 0; - -webkit-transition: all .25s ease-out; - -moz-transition: all .25s ease-out; - transition: all .25s ease-out; -} - -.page-wrapper.open{ - left: 86%; - -webkit-transition: all .25s ease-on; - -moz-transition: all .25s ease-out; - transition: all .25s ease-out; -} .columns { #layout-columns(); @@ -59,7 +45,6 @@ &:extend(.add-box-sizing all); .mix-flex-flex(@_basis: 100%); .css(padding-bottom, @indent-xl-base); - min-height: 300px; .mix-flex-order(1); } .sidebar-main { @@ -74,27 +59,12 @@ } } -.page-header { - .panel.wrapper { - position: absolute; - top: 0; - left: -86%; - background: #f5f5f5; - height: 100%; - width: 86%; - -webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); - box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); - .panel.header { - padding: 0; - } - } -} // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { - .navigation > ul, +.responsive(@break) when (@break = @screen-m) { + .navigation, .breadcrumbs, .page-header .header.panel, .header.content, @@ -116,6 +86,7 @@ .column.main { #layout-columns > .main(); &:extend(.add-box-sizing-desktop all); + min-height: 300px; } .sidebar-main { @@ -145,19 +116,7 @@ } } - .page-header { - .panel.wrapper { - position: relative; - top: 0; - left: 0; - background: none; - height: auto; - width: auto; - -webkit-box-shadow: none; - box-shadow: none; - .panel.header { - padding: 10px 20px; - } - } + .panel.header { + padding: 10px 20px; } } diff --git a/app/design/frontend/Magento/blank/web/css/source/navigation.less b/app/design/frontend/Magento/blank/web/css/source/navigation.less index 3bbc7113641..d28a20816ea 100644 --- a/app/design/frontend/Magento/blank/web/css/source/navigation.less +++ b/app/design/frontend/Magento/blank/web/css/source/navigation.less @@ -22,18 +22,18 @@ // * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) // */ -html.open { - overflow: hidden; +.panel.header { + .links, + .switcher { + display: none; + } } -body { - .css(background-color, @page-bg-color); - &.open { - overflow: hidden; - } +.nav-sections { + .css(background, @navigation-background); } -.action.toggle.nav { +.nav-toggle { .icon-font( @icon-menu, @_icon-font-size: 28px @@ -48,180 +48,218 @@ body { cursor: pointer; } -.navigation { - .switcher { - display: block; - margin: 0; +// +// Mobile +//-------------------------------------- +@active-nav-indent: 54px; +.responsive-smaller(@break) when (@break = @screen-m) { + .navigation { padding: 0; - &:first-child { - padding-bottom: 0; + .parent .level-top { + position: relative; + .icon-font( + @_icon-font-content: @icon-down, + @_icon-font-size: 42px, + @_icon-font-position: after, + @_icon-font-display: block + ); + &:after { + position: absolute; + right: 7px; + top: -8px; + } + &.ui-state-active { + .icon-font-symbol( + @_icon-font-content: @icon-up, + @_icon-font-position: after + ); + } } - .label { - display: block; - font-weight: @font-weight-base; - .font-size(16); + } + .nav-sections { + overflow: auto; + position: fixed; + top: 0; + height: 100%; + left: -80%; + left: calc(~"-1 * (100% - @{active-nav-indent})"); + width: 80%; + width: calc(~"100% - @{active-nav-indent}"); + .css(transition, left .3s, 1); + + .switcher { + border-top: 1px solid #D1D1D1; + margin: 0; + font-size: 1.6rem; padding: 8px 20px; - } - .options { - display: block; - .action.toggle { - cursor: pointer; + font-weight: 700; + .label { display: block; - position: relative; - padding: 8px 20px; - &:extend(.navigation-icon all); - &.active:after { - content: @icon-prev; - } + margin-bottom: @indent-xs-base; } - ul.dropdown { - display: none; - li { - a { - display: block; - color: @navigation-level0-item-color; - padding: 8px 20px; - text-decoration: none; + &:last-child { + border-bottom: 1px solid #D1D1D1; + } + &-trigger { + strong { + display: inline-block!important; + position: relative; + .icon-font( + @_icon-font-content: @icon-down, + @_icon-font-size: 42px, + @_icon-font-position: after, + @_icon-font-display: block + ); + &:after { + position: absolute; + right: -40px; + top: -18px; } } - } - .ui-dialog { - background: none; - box-shadow: none; - ul.dropdown { - padding: 0; + &.active strong { + .icon-font-symbol( + @_icon-font-content: @icon-up, + @_icon-font-position: after + ); } } - &.active { - ul { - display: block; - } + &-dropdown { + .list-reset-styles(); + padding: @indent-s-base 0; } } - } - &.active { - > .content { - display: block; - } - } - .header.links { - padding: 10px 20px; - li { - display: block; - margin: 0; - a { + .header.links { + .list-reset-styles(); + li { + border-top: 1px solid #D1D1D1; + margin: 0; + font-size: 1.6rem; + &.greet.welcome { + padding: 8px 20px; + font-weight: 700; + } + &:last-child { + border-bottom: 1px solid #D1D1D1; + } + } + a, a:hover + { display: block; - line-height: 35px; + padding: 8px 20px; + font-weight: 700; .css(color, @navigation-level0-item-color); - } - &.welcome { - line-height: 35px; + .css(text-decoration, @navigation-level0-item-text-decoration); } } } - .nav { - .parent { - > a { - position: relative; - &:extend(.navigation-icon all); - &.action.back:after { - content: @icon-prev; - } - } + .nav-before-open { + height: 100%; + width: 100%; + .page-wrapper { + height:100%; + overflow: hidden; + position: relative; + left: 0; + .css(transition, left .3s, 1); + } + body { + overflow: hidden; + height: 100%; + width: 100%; + position: relative; } } -} - -.navigation-tabs { - .data-accordion( - @_accordion-control-color: #333, - @_accordion-control-color-visited: #333, - @_accordion-control-color-hover: #333, - @_accordion-control-color-active: #333, - @_accordion-control-padding-left: 10px, - @_accordion-control-padding-right: 20px, - @_accordion-control-height: 45px, - @_accordion-control-line-height: 45px, - @_accordion-control-bg: #fff, - @_accordion-content-border: none, - @_accordion-control-border-top: none, - @_accordion-control-bg-active: #fff, - @_accordion-content-padding: 0, - @_accordion-content-bg: transparent, - @_accordion-control-margin-bottom: 0, - @_accordion-content-margin: 0 - ); - .item.title { - > .switch { - .icon-font( - @_icon-font-content: @icon-down, - @_icon-font-size: 36px - ); - display: block; + .nav-open { + .page-wrapper { + left: 80%; + left: calc(~"100% - @{active-nav-indent}"); } - &.active { - > .switch:before { - content: @icon-up + .nav-sections { + left: 0; + z-index: 99; + @_shadow: 0 0 5px 0 rgba(50, 50, 50, 0.75); + .css(box-shadow, @_shadow, 1); + } + .nav-toggle { + &:after{ + display: block; + content: ""; + width: 100%; + z-index: 1; + position: fixed; + height: 100%; + top: 0; + right:0; + background: rgba(0,0,0,0.01); } } } - .item.content { - .css(border-bottom, @tab-content-border); - .nav > .level0:first-child { - border-top: none; + .nav-sections { + &-items { + .clearfix(); + position: relative; + z-index: 1; + } + &-item-title { + float: left; + width: 33.33%; + text-align: center; + border: solid darken(@navigation-background,10%); + border-width: 0 0 1px 1px; + .box-sizing(); + padding-top: 24px; + height: 71px; + background: darken(@navigation-background,5%); + &.active { + background: transparent; + border-bottom: 0; + } + } + &-item-content { + .box-sizing(); + .clearfix(); + float: right; + margin-top: 71px; + margin-left: -100%; + width: 100%; + &.active { + display: block; + } + padding: @indent-m-base 0; } } + .main-navigation(); } -.main-navigation(); -.main-navigation-desktop(); - // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { - html.open { - overflow: inherit; +.responsive(@break) when (@break = @screen-m) { + .nav-toggle { + display: none; } - body { - &.open { - overflow: inherit; + .nav-sections { + margin-bottom: @indent-m-base; + &-item-title { + display: none; } - } - .action.toggle.nav { - display: none; - } - .navigation { - margin-bottom: 30px; - padding-left: 20px; - padding-right: 20px; - > ul > .level0 { - > a, - .action.back > a { - text-transform: uppercase; - } + &-item-content { + display: block!important; } - .parent.more { - .parent { - > .submenu { - position: relative; - margin-top: 0; - ul { - margin: 0; - padding-top: 0; - padding-bottom: 0; - border: none; - box-shadow: none; - background: transparent; - &:after, - &:before { - display: none; - } - } - } - } + &-item-content > * { + display: none; + } + &-item-content > .navigation { + display: block; + } + } + .main-navigation-desktop(); + .panel.header { + .links, + .switcher { + display: inline-block; } } } diff --git a/app/design/frontend/Magento/blank/web/css/source/sections.less b/app/design/frontend/Magento/blank/web/css/source/sections.less index a30483dfbb9..709be6f6425 100644 --- a/app/design/frontend/Magento/blank/web/css/source/sections.less +++ b/app/design/frontend/Magento/blank/web/css/source/sections.less @@ -30,7 +30,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .product.data.items { .data-tabs( @_tab-content-border-top-status: true @@ -38,12 +38,11 @@ } } -@media only screen -and (max-width : @break-point-1) { +@media only screen and (max-width: @screen-m) { .product.data.items { .data-accordion(); .data.item { - display: block; + display: block; } } } diff --git a/app/design/frontend/Magento/blank/web/css/source/tables.less b/app/design/frontend/Magento/blank/web/css/source/tables.less index 91e66d34923..2f4d38a359f 100644 --- a/app/design/frontend/Magento/blank/web/css/source/tables.less +++ b/app/design/frontend/Magento/blank/web/css/source/tables.less @@ -23,21 +23,27 @@ // */ .table-wrapper { - .table-overflow(); - position: relative; // to hide unnecessary horizontal scrollbar in Safari > table { .table-caption(@_table-caption-hide: true); } margin-bottom: @indent-base; } +// +// Mobile +//-------------------------------------- +.responsive-smaller(@break) when (@break = @screen-m) { + .table-wrapper { + .table-overflow(); + position: relative; // to hide unnecessary horizontal scrollbar in Safari + } +} + // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { .table-wrapper { - overflow-y: visible; - overflow-x: visible; > table { > thead, > tbody, diff --git a/app/design/frontend/Magento/blank/web/css/source/typography.less b/app/design/frontend/Magento/blank/web/css/source/typography.less index bd6a35d8c19..6f8d309709c 100644 --- a/app/design/frontend/Magento/blank/web/css/source/typography.less +++ b/app/design/frontend/Magento/blank/web/css/source/typography.less @@ -56,7 +56,7 @@ // // Desktop //-------------------------------------- -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { h1 { font-size: @h1-font-size-desktop; } diff --git a/app/design/frontend/Magento/blank/web/js/navigation-menu.js b/app/design/frontend/Magento/blank/web/js/navigation-menu.js index 43028888f99..764371a9aa7 100644 --- a/app/design/frontend/Magento/blank/web/js/navigation-menu.js +++ b/app/design/frontend/Magento/blank/web/js/navigation-menu.js @@ -30,7 +30,6 @@ define([ "mage/terms" ],function($) { 'use strict'; - $.widget('mage.navigationMenu', { options: { itemsContainer: '> ul', @@ -314,7 +313,7 @@ define([ mainContainer: 'body', pageWrapper: '.page-wrapper', openedMenuClass: 'opened', - toggleActionPlaceholder: '.block.search', + toggleActionPlaceholder: '.block-search', itemWithSubmenu: 'li.parent', titleWithSubmenu: 'li.parent > a', submenu: 'li.parent > .submenu', diff --git a/app/design/frontend/Magento/blank/web/js/theme.js b/app/design/frontend/Magento/blank/web/js/theme.js index 8bd0083909d..ac65a67ce49 100644 --- a/app/design/frontend/Magento/blank/web/js/theme.js +++ b/app/design/frontend/Magento/blank/web/js/theme.js @@ -27,6 +27,7 @@ define([ 'use strict'; $(function() { + if ($('body').hasClass('checkout-cart-index')) { if ($('#co-shipping-method-form .fieldset.rates').length > 0 && $('#co-shipping-method-form .fieldset.rates :checked').length === 0 ) { $("#block-shipping").on("collapsiblecreate" ,function() { @@ -39,6 +40,8 @@ define([ container: '.cart-container' }); } + + $( ".panel.header > .header.links" ).clone().appendTo( "#store\\.links" ); }); }); diff --git a/app/design/frontend/Magento/plushe/composer.json b/app/design/frontend/Magento/plushe/composer.json index c4afa8135ce..1e262635487 100644 --- a/app/design/frontend/Magento/plushe/composer.json +++ b/app/design/frontend/Magento/plushe/composer.json @@ -2,13 +2,13 @@ "name": "magento/theme-frontend-plushe", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/theme-frontend-blank": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/theme-frontend-blank": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index 9608883c343..b97568f87d7 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-alpha89</version> + <version>0.1.0-alpha90</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 29222ce9753..78050dd98f9 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-alpha89</version> + <version>0.1.0-alpha90</version> </theme> diff --git a/app/etc/di.xml b/app/etc/di.xml index ce52a337e5e..7ac6f2a8fe9 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -45,6 +45,7 @@ </arguments> </type> <preference for="Magento\Framework\Locale\ConfigInterface" type="Magento\Framework\Locale\Config" /> + <preference for="Magento\Framework\Notification\NotifierInterface" type="Magento\Framework\Notification\NotifierPool" /> <preference for="Magento\Framework\UrlInterface" type="Magento\Framework\Url" /> <preference for="Magento\Framework\Data\Collection\Db\FetchStrategyInterface" type="Magento\Framework\Data\Collection\Db\FetchStrategy\Query" /> <preference for="Magento\Framework\Config\ScopeInterface" type="Magento\Framework\Config\Scope" /> @@ -413,4 +414,25 @@ </arguments> </type> <type name="Magento\Framework\View\Layout\ScheduledStructure" shared="false" /> + + + <virtualType name="Magento\Framework\Search\Config\Reader\Filesystem" type="Magento\Framework\Config\Reader\Filesystem"> + <arguments> + <argument name="fileName" xsi:type="string">search_request.xml</argument> + <argument name="schemaLocator" xsi:type="object">Magento\Framework\Search\Request\Config\SchemaLocator</argument> + <argument name="converter" xsi:type="object">Magento\Framework\Search\Request\Config\Converter</argument> + <argument name="idAttributes" xsi:type="array"> + <item name="/requests/request" xsi:type="string">@name</item> + <item name="/requests/request/queries/query" xsi:type="string">@name</item> + <item name="/requests/request/filters/filter" xsi:type="string">@name</item> + <item name="/requests/request/aggregation/bucket" xsi:type="string">@name</item> + </argument> + </arguments> + </virtualType> + + <type name="Magento\Framework\Search\Request\Config"> + <arguments> + <argument name="reader" xsi:type="object">Magento\Framework\Search\Config\Reader\Filesystem</argument> + </arguments> + </type> </config> diff --git a/app/etc/vendor_path.php b/app/etc/vendor_path.php new file mode 100644 index 00000000000..792612edfa4 --- /dev/null +++ b/app/etc/vendor_path.php @@ -0,0 +1,28 @@ +<?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) + */ + +/** + * Path to Composer vendor directory + */ +return 'vendor'; diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index 369fff12050..f15bf8e8c62 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 4de155f58c0..4353c63040f 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 bffb5ff0a56..0051cd143cf 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 84b08448467..7ec67b4fe37 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 e7cf886210a..3b2dc8f8dac 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 9c92457ab85..fd9d2f8b4fc 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "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 493ff18be0a..c92f93e6234 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-alpha89", + "version": "0.1.0-alpha90", "require": { - "magento/framework": "0.1.0-alpha89", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 2efe02a4907..f1577e2f357 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,181 @@ { - "name": "magento/community-edition", - "description": "eCommerce Platform for Growth (Community Edition)", - "license": ["OSL-3.0", "AFL-3.0"], + "name": "magento/project-community-edition", + "description": "Magento project (Community Edition)", + "type": "project", + "version": "0.1.0-alpha90", "require": { - "php": ">=5.4.0" + "php": "~5.4.11|~5.5.0" }, - "autoload": { - "psr-0": { - "": ["app/code", "lib/internal"] + "require-dev": { + "phpunit/phpunit": "4.1.*" + }, + "replace": { + "magento/module-admin-notification": "self.version", + "magento/module-authorization": "self.version", + "magento/module-authorizenet": "self.version", + "magento/module-backend": "self.version", + "magento/module-backup": "self.version", + "magento/module-bundle": "self.version", + "magento/module-captcha": "self.version", + "magento/module-catalog": "self.version", + "magento/module-catalog-import-export": "self.version", + "magento/module-catalog-inventory": "self.version", + "magento/module-catalog-rule": "self.version", + "magento/module-catalog-search": "self.version", + "magento/module-catalog-url-rewrite": "self.version", + "magento/module-centinel": "self.version", + "magento/module-checkout": "self.version", + "magento/module-checkout-agreements": "self.version", + "magento/module-cms": "self.version", + "magento/module-cms-url-rewrite": "self.version", + "magento/module-configurable-import-export": "self.version", + "magento/module-configurable-product": "self.version", + "magento/module-contact": "self.version", + "magento/module-core": "self.version", + "magento/module-cron": "self.version", + "magento/module-currency-symbol": "self.version", + "magento/module-customer": "self.version", + "magento/module-customer-import-export": "self.version", + "magento/module-design-editor": "self.version", + "magento/module-dhl": "self.version", + "magento/module-directory": "self.version", + "magento/module-downloadable": "self.version", + "magento/module-eav": "self.version", + "magento/module-email": "self.version", + "magento/module-fedex": "self.version", + "magento/module-gift-message": "self.version", + "magento/module-google-adwords": "self.version", + "magento/module-google-analytics": "self.version", + "magento/module-google-optimizer": "self.version", + "magento/module-google-shopping": "self.version", + "magento/module-grouped-import-export": "self.version", + "magento/module-grouped-product": "self.version", + "magento/module-import-export": "self.version", + "magento/module-index": "self.version", + "magento/module-indexer": "self.version", + "magento/module-install": "self.version", + "magento/module-integration": "self.version", + "magento/module-layered-navigation": "self.version", + "magento/module-log": "self.version", + "magento/module-multishipping": "self.version", + "magento/module-newsletter": "self.version", + "magento/module-offline-payments": "self.version", + "magento/module-offline-shipping": "self.version", + "magento/module-ogone": "self.version", + "magento/module-page-cache": "self.version", + "magento/module-pay-pal-recurring-payment": "self.version", + "magento/module-payment": "self.version", + "magento/module-paypal": "self.version", + "magento/module-persistent": "self.version", + "magento/module-product-alert": "self.version", + "magento/module-recurring-payment": "self.version", + "magento/module-reports": "self.version", + "magento/module-require-js": "self.version", + "magento/module-review": "self.version", + "magento/module-rss": "self.version", + "magento/module-rule": "self.version", + "magento/module-sales": "self.version", + "magento/module-sales-rule": "self.version", + "magento/module-sendfriend": "self.version", + "magento/module-shipping": "self.version", + "magento/module-sitemap": "self.version", + "magento/module-store": "self.version", + "magento/module-tax": "self.version", + "magento/module-theme": "self.version", + "magento/module-translation": "self.version", + "magento/module-ups": "self.version", + "magento/module-url-redirect": "self.version", + "magento/module-url-rewrite": "self.version", + "magento/module-user": "self.version", + "magento/module-usps": "self.version", + "magento/module-webapi": "self.version", + "magento/module-weee": "self.version", + "magento/module-widget": "self.version", + "magento/module-wishlist": "self.version", + "magento/theme-adminhtml-backend": "self.version", + "magento/theme-frontend-blank": "self.version", + "magento/theme-frontend-plushe": "self.version", + "magento/language-de_de": "self.version", + "magento/language-en_us": "self.version", + "magento/language-es_es": "self.version", + "magento/language-fr_fr": "self.version", + "magento/language-nl_nl": "self.version", + "magento/language-pt_br": "self.version", + "magento/language-zh_cn": "self.version", + "magento/framework": "self.version", + "zendframework/zend-eventmanager": "2.0.3", + "zendframework/zend-stdlib": "2.0.3", + "zendframework/zend-di": "2.0.3", + "zendframework/zend-escaper": "2.0.3", + "zendframework/zend-i18n": "2.0.3", + "zendframework/zend-server": "2.0.3", + "zendframework/zend-soap": "2.0.3", + "zendframework/zend-uri": "2.0.3", + "zendframework/zend-validator": "2.0.3", + "zendframework/zend-servicemanager": "2.0.3", + "zendframework/zend-code": "2.0.3", + "zendframework/zendframework1": "1.12.0", + "oyejorge/less.php": "1.7.0", + "symfony/yaml": "2.3.x-dev", + "trentrichardson/jquery-timepicker-addon": "1.4.3", + "components/handlebars.js": "1.3.0", + "colinmollenhour/cache-backend-redis": "dev-master#193d377b7fb2e88595578b282fa01a62d1185abc", + "colinmollenhour/credis": "dev-master#f07bbfd4117294f462f0fb19c49221d350bf396f", + "linkorb/jsmin-php": "1.1.2", + "pear/mail_mime-decode": "1.48", + "phpseclib/phpseclib": "0.2.1", + "components/jquery": "1.11.0", + "blueimp/jquery-file-upload": "5.6.14", + "components/jqueryui": "1.10.4", + "twbs/bootstrap": "3.1.0", + "tinymce/tinymce": "3.4.7" + }, + "extra": { + "component_paths": { + "zendframework/zend-eventmanager": "lib/internal/Zend/EventManager", + "zendframework/zend-stdlib": "lib/internal/Zend/Stdlib", + "zendframework/zend-di": "lib/internal/Zend/Di", + "zendframework/zend-escaper": "lib/internal/Zend/Escaper", + "zendframework/zend-i18n": "lib/internal/Zend/I18n", + "zendframework/zend-server": "lib/internal/Zend/Server", + "zendframework/zend-soap": "lib/internal/Zend/Soap", + "zendframework/zend-uri": "lib/internal/Zend/Uri", + "zendframework/zend-validator": "lib/internal/Zend/Validator", + "zendframework/zend-code": "lib/internal/Zend/Code", + "zendframework/zendframework1": [ + "lib/internal/Zend", + "app/code/Zend" + ], + "oyejorge/less.php": "lib/internal/Less", + "symfony/yaml": "lib/internal/Symfony/Component/Yaml", + "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js", + "components/handlebars.js": "lib/web/jquery/handlebars", + "colinmollenhour/cache-backend-redis": "lib/internal/Cm/Cache/Backend/Redis.php", + "colinmollenhour/credis": "lib/internal/Credis", + "linkorb/jsmin-php": "lib/internal/JSMin", + "pear/mail_mime-decode": "lib/internal/PEAR/Mail", + "phpseclib/phpseclib": "lib/internal/phpseclib", + "components/jquery": [ + "lib/web/jquery/jquery.js", + "lib/web/jquery/jquery.min.js", + "lib/web/jquery/jquery-migrate.js", + "lib/web/jquery/jquery-migrate.min.js" + ], + "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader", + "components/jqueryui": [ + "lib/web/jquery/jquery-ui.js", + "lib/web/jquery/jquery-ui.min.js" + ], + "twbs/bootstrap": [ + "lib/web/jquery/jquery.tabs.js", + "lib/web/jquery/jquery.popups.js", + "lib/web/jquery/bootstrap-carousel" + ], + "tinymce/tinymce": "lib/web/tiny_mce" } }, - "minimum-stability": "dev" + "license": [ + "OSL-3.0", + "AFL-3.0" + ] } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 0a4f03536e7..9df2043bbad 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -263,7 +263,7 @@ abstract class Grid extends Block * Perform selected massaction over checked items * * @param array $items - * @param array|string $action + * @param array|string $action [array -> key = value from first select; value => value from subselect] * @param bool $acceptAlert [optional] * @param string $massActionSelection [optional] * @return void diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.php index 455f7dbe322..bf983be1386 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.php @@ -34,25 +34,16 @@ class CatalogProductView extends ParentCatalogProductView { const MCA = 'bundle/catalog/product/view'; - /** - * Custom constructor - * - * @return void - */ - protected function _init() - { - $this->_blocks['bundleViewBlock'] = [ + protected $_blocks = [ + 'bundleViewBlock' => [ 'name' => 'bundleViewBlock', 'class' => 'Magento\Bundle\Test\Block\Catalog\Product\View', 'locator' => '.bundle-options-container', 'strategy' => 'css selector', - ]; - parent::_init(); - } + ], + ]; /** - * Bundle block on frontend - * * @return \Magento\Bundle\Test\Block\Catalog\Product\View */ public function getBundleViewBlock() diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php index 4c91657e1a6..7c077faa5f1 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php @@ -40,6 +40,13 @@ use Magento\Catalog\Test\Fixture\ConfigurableProduct; */ class View extends Block { + /** + * XPath selector for tab + * + * @var string + */ + protected $tabSelector = './/div[@data-role="collapsible" and a[contains(text(),"%s")]]'; + /** * Custom options CSS selector * @@ -166,6 +173,13 @@ class View extends Block */ protected $clickAddToCompare = '.action.tocompare'; + /** + * "Add to Wishlist" button + * + * @var string + */ + protected $addToWishlist = '[data-action="add-to-wishlist"]'; + /** * Get bundle options block * @@ -344,7 +358,7 @@ class View extends Block */ public function getProductOptions() { - $options = array(); + $options = []; for ($i = 2; $i <= 3; $i++) { $options[] = $this->_rootElement->find(".super-attribute-select option:nth-child({$i})")->getText(); } @@ -495,4 +509,25 @@ class View extends Block { $this->_rootElement->find($this->clickAddToCompare, Locator::SELECTOR_CSS)->click(); } + + /** + * Click "Add to Wishlist" button + * + * @return void + */ + public function addToWishlist() + { + $this->_rootElement->find($this->addToWishlist, Locator::SELECTOR_CSS)->click(); + } + + /** + * Select tab on the product page + * + * @param string $name + * @return void + */ + public function selectTab($name) + { + $this->_rootElement->find(sprintf($this->tabSelector, $name), Locator::SELECTOR_XPATH)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCompareItemsLinkIsAbsent.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCompareItemsLinkIsAbsent.php index 6cdcee88fe2..e3cdeb7c790 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCompareItemsLinkIsAbsent.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCompareItemsLinkIsAbsent.php @@ -48,7 +48,7 @@ class AssertProductCompareItemsLinkIsAbsent extends AbstractConstraint public function processAssert(CmsIndex $cmsIndex) { \PHPUnit_Framework_Assert::assertFalse( - $cmsIndex->getLinksBlock()->getQtyInCompareList(), + $cmsIndex->getLinksBlock()->isLinkVisible("Compare Products"), 'The link "Compare Products..." is visible at the top of page.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/TaxClass.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/TaxClass.php index 1783fb091d4..d29a96ea5b9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/TaxClass.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/TaxClass.php @@ -24,8 +24,12 @@ namespace Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Mtf\System\Config; use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\FixtureInterface; +use Mtf\Util\Protocol\CurlInterface; +use Mtf\Util\Protocol\CurlTransport; +use Mtf\Util\Protocol\CurlTransport\BackendDecorator; /** * Class TaxClass @@ -36,12 +40,19 @@ use Mtf\Fixture\FixtureInterface; */ class TaxClass implements FixtureInterface { + /** + * Tax class id + * + * @var int + */ + protected $taxClassId; + /** * Tax class name * * @var string */ - protected $data; + protected $data = 'None'; /** * Tax class fixture @@ -51,6 +62,8 @@ class TaxClass implements FixtureInterface protected $taxClass; /** + * Constructor + * * @param FixtureFactory $fixtureFactory * @param array $params * @param array $data @@ -58,19 +71,48 @@ class TaxClass implements FixtureInterface public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; - /** @var \Magento\Tax\Test\Fixture\TaxClass $taxClass */ - if (isset($data['dataSet']) && $data['dataSet'] !== '-') { - $taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $data['dataSet']]); - $this->taxClass = $taxClass; - $this->data = $taxClass->getClassName(); + if (isset($data['dataSet'])) { + $this->taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $data['dataSet']]); + $this->data = $this->taxClass->getClassName(); + if (!$this->taxClass->hasData('id')) { + $this->taxClass->persist(); + } } if (isset($data['tax_product_class']) && $data['tax_product_class'] instanceof \Magento\Tax\Test\Fixture\TaxClass ) { - $taxClass = $data['tax_product_class']; - $this->taxClass = $taxClass; - $this->data = $taxClass->getClassName(); + $this->taxClass = $data['tax_product_class']; + $this->data = $this->taxClass->getClassName(); + } + if ($this->taxClass->hasData('id')) { + $this->taxClassId = $this->taxClass->getId(); + } else { + $this->setTaxClassId($this->data); + } + } + + /** + * Set tax class id + * + * @param string $taxClassName + * @return void + * @throws \Exception + */ + protected function setTaxClassId($taxClassName) + { + $url = $_ENV['app_backend_url'] . 'tax/rule/new/'; + $curl = new BackendDecorator(new CurlTransport(), new Config); + $curl->addOption(CURLOPT_HEADER, 1); + $curl->write(CurlInterface::POST, $url, '1.0', [], []); + $response = $curl->read(); + $curl->close(); + + preg_match('~<option value="(\d+)".*>' . $taxClassName . '</option>~', $response, $matches); + if (!isset($matches[1]) || empty($matches[1])) { + throw new \Exception('Product tax class id ' . $taxClassName . ' undefined!'); } + + $this->taxClassId = (int)$matches[1]; } /** @@ -87,7 +129,7 @@ class TaxClass implements FixtureInterface * Return prepared data set * * @param string|null $key - * @return mixed + * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -99,7 +141,7 @@ class TaxClass implements FixtureInterface /** * Return data set configuration settings * - * @return string + * @return array */ public function getDataConfig() { @@ -115,4 +157,14 @@ class TaxClass implements FixtureInterface { return $this->taxClass; } + + /** + * Return tax class id + * + * @return int + */ + public function getTaxClassId() + { + return (int)$this->taxClassId; + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogAttributeSet/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogAttributeSet/Curl.php index 86fa3f55a7f..04448e7c104 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogAttributeSet/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogAttributeSet/Curl.php @@ -50,7 +50,7 @@ class Curl extends AbstractCurl implements CatalogAttributeSetInterface * * @var string */ - protected $attributes = '#buildCategoryTree\(this.root,.*?(\[.*\}\]\}\])\);#s'; + protected $attributes = '/buildCategoryTree\(this.root, ([^;]+\}\])\);/s'; /** * Regex for finding attribute set name @@ -176,12 +176,15 @@ class Curl extends AbstractCurl implements CatalogAttributeSetInterface $dataAttribute['groups'][$key][] = $parentAttributes['id']; $dataAttribute['groups'][$key][] = $parentAttributes['text']; $dataAttribute['groups'][$key][] = $key + 1; - foreach ($parentAttributes['children'] as $attribute) { - $dataAttribute['attributes'][$index][] = $attribute['id']; - $dataAttribute['attributes'][$index][] = $parentAttributes['id']; - $dataAttribute['attributes'][$index][] = $index; - $dataAttribute['attributes'][$index][] = $attribute['entity_id']; - $index++; + + if (isset($parentAttributes['children'])) { + foreach ($parentAttributes['children'] as $attribute) { + $dataAttribute['attributes'][$index][] = $attribute['id']; + $dataAttribute['attributes'][$index][] = $parentAttributes['id']; + $dataAttribute['attributes'][$index][] = $index; + $dataAttribute['attributes'][$index][] = $attribute['entity_id']; + $index++; + } } } $dataAttribute['not_attributes'] = []; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php index c9de97be2d1..94226e34082 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -129,6 +129,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface $config = $fixture->getDataConfig(); $prefix = isset($config['input_prefix']) ? $config['input_prefix'] : null; $data = $this->prepareData($fixture, $prefix); + return ['id' => $this->createProduct($data, $config)]; } @@ -147,14 +148,12 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface $fields = $this->replaceMappingData($fixture->getData()); // Getting Tax class id if ($fixture->hasData('tax_class_id')) { - $fields['tax_class_id'] = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClass()->getId(); + $fields['tax_class_id'] = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClassId(); } if (!empty($fields['category_ids'])) { $categoryIds = []; - /** @var InjectableFixture $fixture */ foreach ($fixture->getDataFieldConfig('category_ids')['source']->getCategories() as $category) { - /** @var CatalogCategory $category */ $categoryIds[] = $category->getId(); } $fields['category_ids'] = $categoryIds; @@ -278,7 +277,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface $url = $this->getUrl($config); $curl = new BackendDecorator(new CurlTransport(), new Config); $curl->addOption(CURLOPT_HEADER, 1); - $curl->write(CurlInterface::POST, $url, '1.0', array(), $data); + $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); @@ -298,7 +297,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface */ protected function getUrl(array $config) { - $requestParams = isset($config['create_url_params']) ? $config['create_url_params'] : array(); + $requestParams = isset($config['create_url_params']) ? $config['create_url_params'] : []; $params = ''; foreach ($requestParams as $key => $value) { $params .= $key . '/' . $value . '/'; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php index 8062fd7ff4b..6d2d48f4950 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.php @@ -66,6 +66,7 @@ class CatalogProductSimple extends AbstractRepository 'qty' => 666.0000, 'is_in_stock' => 'In Stock', ], + 'weight' => 1, 'attribute_set_id' => ['dataSet' => 'default'], 'price' => ['value' => 100, 'preset' => '-'], 'website_ids' => ['Main Website'], @@ -79,6 +80,7 @@ class CatalogProductSimple extends AbstractRepository 'qty' => 666.0000, 'is_in_stock' => 'In Stock', ], + 'weight' => 1, 'attribute_set_id' => ['dataSet' => 'default'], 'price' => ['value' => 40, 'preset' => '-'], 'mtf_dataset_name' => '40_dollar_product', @@ -94,6 +96,7 @@ class CatalogProductSimple extends AbstractRepository 'qty' => 666.0000, 'is_in_stock' => 'In Stock', ], + 'weight' => 1, 'price' => ['value' => 100, 'preset' => 'MAGETWO-23036'], 'category_ids' => ['presets' => 'default'], 'mtf_dataset_name' => 'simple_with_category', @@ -107,6 +110,7 @@ class CatalogProductSimple extends AbstractRepository 'qty' => 666.0000, 'is_in_stock' => 'In Stock', ], + 'weight' => 1, 'attribute_set_id' => ['dataSet' => 'default'], 'price' => ['value' => 100, 'preset' => ''], 'category_ids' => ['presets' => 'default_subcategory'], @@ -213,6 +217,7 @@ class CatalogProductSimple extends AbstractRepository 'qty' => 25.0000, 'is_in_stock' => 'In Stock', ], + 'weight' => 1, 'price' => ['value' => 100, 'preset' => '-'], 'website_ids' => ['Main Website'], ]; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest/test.csv index d98cdd09e2a..6252e245405 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest/test.csv @@ -1,6 +1,6 @@ "addCategory";"category/data/parent_id/dataSet";"category/data/name";"category/data/url_key";"category/data/is_active";"category/data/description";"category/data/meta_title";"category/data/include_in_menu";"category/data/display_mode";"category/data/landing_page";"category/data/is_anchor";"category/data/available_product_listing_config";"category/data/available_sort_by/sort_0";"category/data/available_sort_by/sort_1";"category/data/available_sort_by/sort_2";"category/data/default_product_listing_config";"category/data/default_sort_by";"category/data/use_config_price_range";"category/data/layered_navigation_price_step";"category/data/category_products_data/preset";"category/data/category_products/dataSet";"constraint" "addRootCategory";"1";"RootCategory%isolation%";"RootCategory%isolation%";"Yes";"RootCategory Required ";"-";"-";"-";"-";"-";"No";"Position";"Name";"Price";"-";"-";"-";"-";"-";"-";"assertCategorySaveMessage, assertCategoryForm" -"addRootCategory";"1";"RootCategory%isolation%";"RootCategory%isolation%";"Yes";"RootCategory All Fields ";"RootCategory Page Title";"Yes";"Static block and products";"Footer Links";"Yes";"No";"Position";"Name";"Price";"No";"Name";"No";"50";"-";"-";"assertCategorySaveMessage, assertCategoryForm" +"addRootCategory";"1";"RootCategory%isolation%";"RootCategory%isolation%";"Yes";"RootCategory All Fields ";"RootCategory Page Title";"Yes";"Static block and products";"Catalog Events Lister";"Yes";"No";"Position";"Name";"Price";"No";"Name";"No";"50";"-";"-";"assertCategorySaveMessage, assertCategoryForm" "addSubcategory";"default_category";"Subcategory%isolation%";"Subcategory%isolation%";"Yes";"Subcategory Required";"-";"-";"-";"-";"-";"Yes";"-";"-";"-";"-";"-";"-";"-";"-";"-";"assertCategorySaveMessage, assertCategoryForm, assertCategoryPage" "addSubcategory";"default_category";"Subcategory%isolation%";"Subcategory%isolation%";"Yes";"Subcategory For Anchor Subcategory";"-";"Yes";"-";"-";"No";"Yes";"-";"-";"-";"Yes";"-";"Yes";"-";"default";"catalogProductSimple::default,catalogProductSimple::default";"assertCategorySaveMessage, assertCategoryForm, assertCategoryPage, assertCategoryForAssignedProducts" "addSubcategory";"default_category";"Subcategory%isolation%";"Subcategory%isolation%";"Yes";"Anchor Subcategory All Fields";"Subcategory Page Title";"Yes";"Products only";"Catalog Events Lister";"Yes";"No";"Position";"Name";"Price";"No";"Price";"No";"50";"default";"catalogProductSimple::default,catalogProductSimple::default";"assertCategorySaveMessage, assertCategoryForm, assertCategoryPage, assertCategoryForAssignedProducts" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php index 9d26a069dc1..5608bd54009 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.php @@ -53,7 +53,7 @@ class CreateProductAttributeEntityTest extends Injectable * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew * @param CatalogAttributeSet $productTemplate - * @return void + * @return array */ public function testCreateProductAttribute( CatalogProductAttribute $productAttribute, @@ -69,5 +69,6 @@ class CreateProductAttributeEntityTest extends Injectable $attributeIndex->getPageActionsBlock()->addNew(); $attributeNew->getAttributeForm()->fill($productAttribute); $attributeNew->getPageActions()->save(); + return ['attribute' => $productAttribute]; } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php index 2f7301cef9c..d5659735afb 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductsResult.php @@ -133,9 +133,6 @@ class AssertAdvancedSearchProductsResult extends AbstractConstraint $searchData = $searchBlock->getSearchSummaryItems(); $productData = $this->prepareFixtureData($productSearch); foreach ($productData as $key => $data) { - if ($key === 'tax_class' && $data === ['All']) { - continue; - } if (!isset($searchData[$key])) { $errors[] = '- "' . $key . '" not found on the page'; } elseif ($searchData[$key] !== $data) { diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv index 20c355cc0c3..c48e64424e4 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv @@ -1,14 +1,13 @@ -"products/simple_1";"products/simple_2";"productSearch/data/name";"productSearch/data/sku";"productSearch/data/description";"productSearch/data/short_description";"productSearch/data/price/value/price_from";"productSearch/data/price/value/price_to";"productSearch/data/tax_class_id/dataSet";"constraint" -"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;500;"Taxable Goods";"assertAdvancedSearchProductsResult" -"Yes";"-";"abc";"-";"-";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"-";"Yes";"adc_123";"-";"-";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc";"-";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc_dfj";"-";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc";"full";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"-";"Yes";"-";"-";"dfj_full";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"-";"-";"short";"-";"-";"all";"assertAdvancedSearchProductsResult" -"-";"-";"-";"-";"-";"dfj_short";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"Yes";"-";"-";"-";"-";"-";"-";"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"-";"-";"-";50;50;"all";"assertAdvancedSearchProductsResult" -"Yes";"Yes";"-";"-";"-";"-";"-";100;"all";"assertAdvancedSearchProductsResult" -"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;50;"Taxable Goods";"assertAdvancedSearchProductsResult" +"products/simple_1";"products/simple_2";"productSearch/data/name";"productSearch/data/sku";"productSearch/data/description";"productSearch/data/short_description";"productSearch/data/price/value/price_from";"productSearch/data/price/value/price_to";"constraint" +"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;500;"assertAdvancedSearchProductsResult" +"Yes";"-";"abc";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" +"-";"Yes";"adc_123";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" +"Yes";"-";"-";"abc";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" +"Yes";"-";"-";"abc_dfj";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" +"Yes";"-";"-";"abc";"full";"-";"-";"-";"assertAdvancedSearchProductsResult" +"-";"Yes";"-";"-";"dfj_full";"-";"-";"-";"assertAdvancedSearchProductsResult" +"Yes";"-";"-";"-";"-";"short";"-";"-";"assertAdvancedSearchProductsResult" +"-";"-";"-";"-";"-";"dfj_short";"-";"-";"assertAdvancedSearchProductsResult" +"Yes";"-";"-";"-";"-";"-";50;50;"assertAdvancedSearchProductsResult" +"Yes";"Yes";"-";"-";"-";"-";"-";100;"assertAdvancedSearchProductsResult" +"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;50;"assertAdvancedSearchProductsResult" diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index fc3b9146b1c..fdf1e8c4aa5 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -86,7 +86,7 @@ class Cart extends Block * * @var string */ - protected $productQty = './/input[@type="number" and @title="Qty"]'; + protected $productQty = '//input[@type="number" and @title="Qty"]'; /** * Cart item selector @@ -167,7 +167,7 @@ class Cart extends Block */ public function getCartItemOptionsNameByProductName($productName) { - $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart item options"]//dt'; + $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart-item-options"]//dt'; $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); if (!$optionsBlock->isVisible()) { @@ -184,7 +184,7 @@ class Cart extends Block */ public function getCartItemOptionsValueByProductName($productName) { - $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart item options"]//dd'; + $selector = '//tr[string(td/div/strong/a)="' . $productName . '"]//dl[@class="cart-item-options"]//dd'; $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); if (!$optionsBlock->isVisible()) { diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutCart.php index 4629a1b8ef5..d7a4d90841c 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutCart.php @@ -31,9 +31,6 @@ use Mtf\Page\FrontendPage; */ class CheckoutCart extends FrontendPage { - /** - * URL for checkout cart page - */ const MCA = 'checkout/cart'; protected $_blocks = [ diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php index 670f92cb6f6..d3721660c4f 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Handler/CmsPage/Curl.php @@ -67,7 +67,7 @@ class Curl extends Conditions implements CmsPageInterface * * @var string */ - protected $url = 'admin/cms_page/save/active_tab/main_section/'; + protected $url = 'admin/cms_page/save/back/edit/active_tab/content_section/'; /** * Post request for creating a cms page diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Adminhtml/System/Variable/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Adminhtml/System/Variable/FormPageActions.php index 9386d490f9c..781ae0cb154 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Adminhtml/System/Variable/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Adminhtml/System/Variable/FormPageActions.php @@ -45,7 +45,7 @@ class FormPageActions extends AbstractFormPageActions * * @var string */ - protected $storeViewButton = '.store-switcher [data-toggle="dropdown"]'; + protected $storeViewButton = '[data-ui-id="language-switcher"] .toggle'; /** * Store View locator @@ -59,14 +59,19 @@ class FormPageActions extends AbstractFormPageActions * * @param string $storeName * @throws \Exception - * @return void + * @return void|bool */ public function selectStoreView($storeName) { - $this->_rootElement->find($this->storeViewButton)->click(); + $languageSwitcher = $this->_rootElement->find($this->storeViewButton); + if (!$languageSwitcher->isVisible()) { + return false; + } + $languageSwitcher->click(); $selector = sprintf($this->storeView, $storeName); - if ($this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->isVisible()) { - $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->click(); + $storeView = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); + if ($storeView->isVisible()) { + $storeView->click(); } else { throw new \Exception('Store View with name \'' . $storeName . '\' is not visible!'); } diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/TestCase/UpdateCustomVariableEntityTest.php b/dev/tests/functional/tests/app/Magento/Core/Test/TestCase/UpdateCustomVariableEntityTest.php index 1dc357b9fa9..1bc24e83d56 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/TestCase/UpdateCustomVariableEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Core/Test/TestCase/UpdateCustomVariableEntityTest.php @@ -32,7 +32,7 @@ use Magento\Core\Test\Page\Adminhtml\SystemVariableNew; use Magento\Core\Test\Page\Adminhtml\SystemVariableIndex; /** - * Test Creation for CreateCustomVariableEntity + * Test Creation for UpdateCustomVariableEntityTest * * Test Flow: * Preconditions: @@ -51,7 +51,7 @@ use Magento\Core\Test\Page\Adminhtml\SystemVariableIndex; * 9. Perform all assertions. * * @group Variables_(PS) - * @ZephyrId MAGETWO-26241 + * @ZephyrId MAGETWO-26104 */ class UpdateCustomVariableEntityTest extends Injectable { diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Address.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Address.php index 4ee0087a624..864e8d79a45 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Address.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Address.php @@ -44,14 +44,14 @@ class Address extends Block * * @var string */ - protected $shippingAddressBlock = '.shipping address'; + protected $shippingAddressBlock = '.box-address-shipping'; /** * Billing address block selector * * @var string */ - protected $billingAddressBlock = '.billing address'; + protected $billingAddressBlock = '.box-address-billing'; /** * Edit Default Billing Address diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Info.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Info.php index 8a9b81871bc..d02eb863ec2 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Info.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/Dashboard/Info.php @@ -37,7 +37,7 @@ class Info extends Block * * @var string */ - protected $contactInfoEditLink = '.dashboard.info .information a.edit'; + protected $contactInfoEditLink = '.block-dashboard-info .box-information .action.edit'; /** * Click on Contact Information Edit Link diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php index 5efcb572fd4..15d0c013f2a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php @@ -49,6 +49,7 @@ class AssertCustomerDefaultAddresses extends AbstractConstraint */ public function processAssert(CustomerAccountIndex $customerAccountIndex, AddressInjectable $address) { + $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Account Dashboard'); $defaultBillingAddress = explode( "\n", $customerAccountIndex->getDashboardAddress()->getDefaultBillingAddressText() @@ -89,11 +90,9 @@ class AssertCustomerDefaultAddresses extends AbstractConstraint protected function verifyForm(array $pattern, array $address) { $errorMessages = []; - foreach ($pattern as $key => $value) { - if ($value !== $address[$key]) { - $errorMessages[] = "Data in fields is not equal." - . "\nExpected: " . $value - . "\nActual: " . $pattern[$key]; + foreach ($pattern as $value) { + if (!in_array($value, $address)) { + $errorMessages[] = "Data '$value' in fields is not found."; } } return $errorMessages; @@ -109,7 +108,7 @@ class AssertCustomerDefaultAddresses extends AbstractConstraint { $pattern = []; $regionId = $address->getRegionId(); - $region = $regionId ? $regionId: $address->getRegion(); + $region = $regionId ? $regionId : $address->getRegion(); $pattern[] = $address->getFirstname() . " " . $address->getLastname(); $pattern[] = $address->getCompany(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php index 2a61edc9c01..ebbdda84003 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php @@ -63,7 +63,7 @@ class AssertCustomerGroupOnCustomerForm extends AbstractConstraint 'customerInjectable', [ 'dataSet' => 'defaultBackend', - 'data' => ['group_id' => $customerGroup->getCustomerGroupCode()] + 'data' => ['group_id' => ['customerGroup' => $customerGroup]] ] ); $filter = ['email' => $customer->getEmail()]; diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteInGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteInGrid.php new file mode 100644 index 00000000000..72e03178fd1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteInGrid.php @@ -0,0 +1,74 @@ +<?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\Customer\Test\Constraint; + +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertCustomerMassDeleteInGrid + * Check that mass deleted customers availability in Customer Grid + */ +class AssertCustomerMassDeleteInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that customers which haven't been deleted are present in customer grid + * + * @param CustomerIndex $pageCustomerIndex + * @param AssertCustomerInGrid $assertCustomerInGrid + * @param int $customersQtyToDelete + * @param CustomerInjectable[] $customers + * @return void + */ + public function processAssert( + CustomerIndex $pageCustomerIndex, + AssertCustomerInGrid $assertCustomerInGrid, + $customersQtyToDelete, + $customers + ) { + $customers = array_slice($customers, $customersQtyToDelete); + foreach ($customers as $customer) { + $assertCustomerInGrid->processAssert($customer, $pageCustomerIndex); + } + } + + /** + * Text success exist Customer in grid + * + * @return string + */ + public function toString() + { + return 'Customers are present in Customer grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteNotInGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteNotInGrid.php new file mode 100644 index 00000000000..d38d19d905c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteNotInGrid.php @@ -0,0 +1,73 @@ +<?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\Customer\Test\Constraint; + +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertCustomerMassDeleteNotInGrid + * Check that mass deleted customers are not in customer's grid + */ +class AssertCustomerMassDeleteNotInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Asserts that mass deleted customers are not in customer's grid + * + * @param CustomerIndex $customerIndexPage + * @param AssertCustomerNotInGrid $assertCustomerNotInGrid + * @param int $customersQtyToDelete + * @param CustomerInjectable[] $customers + * @return void + */ + public function processAssert( + CustomerIndex $customerIndexPage, + AssertCustomerNotInGrid $assertCustomerNotInGrid, + $customersQtyToDelete, + $customers + ) { + for ($i = 0; $i < $customersQtyToDelete; $i++) { + $assertCustomerNotInGrid->processAssert($customers[$i], $customerIndexPage); + } + } + + /** + * Success message if Customer not in grid + * + * @return string + */ + public function toString() + { + return 'Deleted customers are absent in Customer grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteSuccessMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteSuccessMessage.php new file mode 100644 index 00000000000..846a9749be7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerMassDeleteSuccessMessage.php @@ -0,0 +1,73 @@ +<?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\Customer\Test\Constraint; + +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertCustomerMassDeleteSuccessMessage + * Check that message "A total of "x" record(s) were deleted." is present + */ +class AssertCustomerMassDeleteSuccessMessage extends AbstractConstraint +{ + /** + * Message that appears after deletion via mass actions + */ + const SUCCESS_DELETE_MESSAGE = 'A total of %d record(s) were deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that message "A total of "x" record(s) were deleted." + * + * @param $customersQtyToDelete + * @param CustomerIndex $customerIndexPage + * @return void + */ + public function processAssert($customersQtyToDelete, CustomerIndex $customerIndexPage) + { + \PHPUnit_Framework_Assert::assertEquals( + sprintf(self::SUCCESS_DELETE_MESSAGE, $customersQtyToDelete), + $customerIndexPage->getMessagesBlock()->getSuccessMessages(), + 'Wrong delete message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Mass delete customer message is displayed.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerNotInGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerNotInGrid.php index e1cfd78cab5..4e6f1a91747 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerNotInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerNotInGrid.php @@ -30,6 +30,7 @@ use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; /** * Class AssertCustomerNotInGrid + * Check that customer is not in customer's grid */ class AssertCustomerNotInGrid extends AbstractConstraint { @@ -43,20 +44,18 @@ class AssertCustomerNotInGrid extends AbstractConstraint /** * Asserts that customer is not in customer's grid * - * @param CustomerInjectable $initialCustomer - * @param CustomerIndex $pageCustomerIndex + * @param CustomerInjectable $customer + * @param CustomerIndex $customerIndexPage * @return void */ - public function processAssert(CustomerInjectable $customer, CustomerIndex $customerIndexPage) - { - $filter = [ - 'email' => $customer->getEmail() - ]; - + public function processAssert( + CustomerInjectable $customer, + CustomerIndex $customerIndexPage + ) { $customerIndexPage->open(); \PHPUnit_Framework_Assert::assertFalse( - $customerIndexPage->getCustomerGridBlock()->isRowVisible($filter), - "Customer with email {$filter['email']} is present in Customer grid." + $customerIndexPage->getCustomerGridBlock()->isRowVisible(['email' => $customer->getEmail()]), + 'Customer with email ' . $customer->getEmail() . 'is present in Customer grid.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/AddressInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/AddressInjectable.php index 32fe5165259..93821cb08bd 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/AddressInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/AddressInjectable.php @@ -120,6 +120,14 @@ class AddressInjectable extends InjectableFixture 'input' => 'text', ]; + protected $email = [ + 'attribute_code' => 'email', + 'backend_type' => 'varchar', + 'is_required' => '1', + 'default_value' => '', + 'input' => 'text', + ]; + protected $middlename = [ 'attribute_code' => 'middlename', 'backend_type' => 'varchar', @@ -239,6 +247,11 @@ class AddressInjectable extends InjectableFixture return $this->getData('default_billing'); } + public function getEmail() + { + return $this->getData('email'); + } + public function getCompany() { return $this->getData('company'); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.php index 910c8760105..c0fc89dc738 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.php @@ -52,6 +52,12 @@ class CustomerInjectable extends InjectableFixture 'password_confirmation' => '123123q', ]; + protected $address = [ + 'attribute_code' => 'address', + 'backend_type' => 'virtual', + 'source' => 'Magento\Customer\Test\Fixture\CustomerInjectable\Address' + ]; + protected $confirmation = [ 'attribute_code' => 'confirmation', 'backend_type' => 'varchar', @@ -151,6 +157,7 @@ class CustomerInjectable extends InjectableFixture 'default_value' => '', 'input' => 'select', 'group' => 'account_information', + 'source' => 'Magento\Customer\Test\Fixture\CustomerInjectable\GroupId' ]; protected $lastname = [ @@ -266,6 +273,11 @@ class CustomerInjectable extends InjectableFixture 'group' => null, ]; + public function getAddress() + { + return $this->getData('address'); + } + public function getConfirmation() { return $this->getData('confirmation'); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.xml index 5953126c4a8..57baf42a5bc 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable.xml @@ -30,6 +30,11 @@ <collection>Magento\Customer\Model\Resource\Customer\Collection</collection> <identifier>email</identifier> <fields> + <address> + <attribute_code>address</attribute_code> + <backend_type>virtual</backend_type> + <source>Magento\Customer\Test\Fixture\CustomerInjectable\Address</source> + </address> <confirmation> <attribute_code>confirmation</attribute_code> <backend_type>varchar</backend_type> @@ -118,6 +123,7 @@ <default_value></default_value> <input>select</input> <group>account_information</group> + <source>Magento\Customer\Test\Fixture\CustomerInjectable\GroupId</source> </group_id> <lastname> <attribute_code>lastname</attribute_code> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/Address.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/Address.php new file mode 100644 index 00000000000..652cdaeff05 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/Address.php @@ -0,0 +1,126 @@ +<?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\Customer\Test\Fixture\CustomerInjectable; + +use Mtf\Fixture\FixtureFactory; +use Mtf\Fixture\FixtureInterface; +use Magento\Customer\Test\Fixture\AddressInjectable; + +/** + * Class Address + * Addresses source for customer fixture + */ +class Address implements FixtureInterface +{ + /** + * Source data + * + * @var array + */ + protected $data = []; + + /** + * Source parameters + * + * @var array + */ + protected $params; + + /** + * Customer addresses fixture + * + * @var array + */ + protected $addressesFixture; + + /** + * Source constructor + * + * @param FixtureFactory $fixtureFactory + * @param array $params + * @param array $data + */ + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) + { + $this->params = $params; + + if (isset($data['presets'])) { + $data['presets'] = explode(',', $data['presets']); + foreach ($data['presets'] as $value) { + /** @var AddressInjectable $fixture */ + $addresses = $fixtureFactory->createByCode('addressInjectable', ['dataSet' => $value]); + $this->data[] = $addresses->getData(); + $this->addressesFixture[] = $addresses; + } + } elseif (empty($data['presets']) && !empty($data['addresses'])) { + foreach ($data['addresses'] as $addresses) { + /** @var AddressInjectable $addresses */ + $this->data[] = $addresses->getData(); + $this->addressesFixture[] = $addresses; + } + } + } + + /** + * Persists prepared data into application + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param int|null $key [optional] + * @return array + */ + public function getData($key = null) + { + return isset($this->data[$key]) ? $this->data[$key] : $this->data; + } + + /** + * Return data set configuration settings + * + * @return array + */ + public function getDataConfig() + { + return $this->params; + } + + /** + * Getting addresses fixture + * + * @return array + */ + public function getAddresses() + { + return $this->addressesFixture; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php new file mode 100644 index 00000000000..695bd999815 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Fixture/CustomerInjectable/GroupId.php @@ -0,0 +1,124 @@ +<?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\Customer\Test\Fixture\CustomerInjectable; + +use Mtf\Fixture\FixtureFactory; +use Mtf\Fixture\FixtureInterface; +use Magento\Customer\Test\Fixture\CustomerGroupInjectable; + +/** + * Class GroupId + * Addresses source for customer fixture + */ +class GroupId implements FixtureInterface +{ + /** + * Source data + * + * @var array + */ + protected $data = []; + + /** + * Source parameters + * + * @var array + */ + protected $params; + + /** + * Customer Group fixture + * + * @var array + */ + protected $customerGroupFixture; + + /** + * Source constructor + * + * @param FixtureFactory $fixtureFactory + * @param array $params + * @param array $data + */ + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) + { + $this->params = $params; + if (isset($data['dataSet'])) { + /** @var CustomerGroupInjectable $customerGroup */ + $customerGroup = $fixtureFactory->createByCode('customerGroupInjectable', ['dataSet' => $data['dataSet']]); + if (!$customerGroup->hasData('customer_group_id')) { + $customerGroup->persist(); + } + $this->data = $customerGroup->getCustomerGroupCode(); + $this->customerGroupFixture = $customerGroup; + } + if (isset($data['customerGroup']) && $data['customerGroup'] instanceof CustomerGroupInjectable) { + $this->data = $data['customerGroup']->getCustomerGroupCode(); + $this->customerGroupFixture = $data['customerGroup']; + } + } + + /** + * Persists prepared data into application + * + * @return void + */ + public function persist() + { + // + } + + /** + * Return prepared data set + * + * @param int|null $key [optional] + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getData($key = null) + { + return $this->data; + } + + /** + * Return data set configuration settings + * + * @return array + */ + public function getDataConfig() + { + return $this->params; + } + + /** + * Getting customerGroup fixture + * + * @return array + */ + public function getAddresses() + { + return $this->customerGroupFixture; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerInjectable/Curl.php index ee6b0900557..eae09259a1c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerInjectable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerInjectable/Curl.php @@ -25,12 +25,12 @@ namespace Magento\Customer\Test\Handler\CustomerInjectable; use Mtf\System\Config; -use Mtf\Handler\Curl as AbstractCurl; +use Mtf\Fixture\FixtureInterface; use Mtf\Util\Protocol\CurlInterface; use Mtf\Util\Protocol\CurlTransport; use Mtf\Util\Protocol\CurlTransport\BackendDecorator; -use Mtf\Fixture\FixtureInterface; use Magento\Customer\Test\Fixture\CustomerInjectable; +use Mtf\Handler\Curl as AbstractCurl; /** * Class Curl @@ -38,6 +38,47 @@ use Magento\Customer\Test\Fixture\CustomerInjectable; */ class Curl extends AbstractCurl implements CustomerInjectableInterface { + /** + * Default customer group + */ + const GENERAL_GROUP = 'General'; + + /** + * Mapping values for data + * + * @var array + */ + protected $mappingData = [ + 'group_id' => [ + self::GENERAL_GROUP => 1, + 'Wholesale' => 2, + 'Retailer' => 3 + ], + 'country_id' => [ + 'United States' => 'US' + ], + 'region_id' => [ + 'California' => 12 + ] + ]; + + /** + * Curl mapping data + * + * @var array + */ + protected $curlMapping = [ + 'account' => [ + 'group_id', + 'firstname', + 'lastname', + 'email', + 'dob', + 'taxvat', + 'gender' + ] + ]; + /** * Post request for creating customer in frontend * @@ -47,19 +88,34 @@ class Curl extends AbstractCurl implements CustomerInjectableInterface */ public function persist(FixtureInterface $customer = null) { + $address = []; + $result = []; /** @var CustomerInjectable $customer */ $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; $data = $customer->getData(); - $curl = new CurlTransport(); - $curl->write(CurlInterface::POST, $url, '1.0', array(), $data); + if ($customer->hasData('address')) { + $address = $customer->getAddress(); + unset($data['address']); + } + + $curl = new CurlTransport(); + $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); if (!strpos($response, 'data-ui-id="global-messages-message-success"')) { throw new \Exception("Customer entity creating by curl handler was not successful! Response: $response"); } - return ['id' => $this->getCustomerId($customer->getEmail())]; + $result['id'] = $this->getCustomerId($customer->getEmail()); + $data['customer_id'] = $result['id']; + + if (!empty($address)) { + $data['address'] = $address; + $this->addAddress($data); + } + + return $result; } /** @@ -70,8 +126,7 @@ class Curl extends AbstractCurl implements CustomerInjectableInterface */ protected function getCustomerId($email) { - $filter = ['email' => $email]; - $url = $_ENV['app_backend_url'] . 'customer/index/grid/filter/' . $this->encodeFilter($filter); + $url = $_ENV['app_backend_url'] . 'customer/index/grid/filter/' . $this->encodeFilter(['email' => $email]); $curl = new BackendDecorator(new CurlTransport(), new Config()); $curl->write(CurlInterface::GET, $url, '1.0'); @@ -82,6 +137,75 @@ class Curl extends AbstractCurl implements CustomerInjectableInterface return empty($match[1]) ? null : $match[1]; } + /** + * Add addresses in to customer account + * + * @param array $data + * @return void + * @throws \Exception + */ + protected function addAddress(array $data) + { + $curlData = []; + $url = $_ENV['app_backend_url'] . 'customer/index/save'; + foreach ($data as $key => $value) { + foreach ($this->curlMapping as $prefix => $prefixValues) { + if (in_array($key, $prefixValues)) { + $curlData[$prefix][$key] = $value; + unset($data[$key]); + } + } + } + unset($data['password'], $data['password_confirmation']); + $curlData['account']['group_id'] = isset($curlData['account']['group_id']) + ? $curlData['account']['group_id'] + : self::GENERAL_GROUP; + + $curlData = $this->replaceMappingData(array_merge($curlData, $data)); + $curlData = $this->prepareAddressData($curlData); + + $curl = new BackendDecorator(new CurlTransport(), new Config); + $curl->write(CurlInterface::POST, $url, '1.0', [], $curlData); + $response = $curl->read(); + $curl->close(); + + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception('Failed to assign an address to the customer!'); + } + } + + /** + * Preparing address data for curl + * + * @param array $curlData + * @return array + */ + protected function prepareAddressData(array $curlData) + { + foreach (array_keys($curlData['address']) as $key) { + $curlData['address'][$key]['_deleted'] = ''; + $curlData['address'][$key]['region'] = ''; + if (!is_array($curlData['address'][$key]['street'])) { + $street = $curlData['address'][$key]['street']; + $curlData['address'][$key]['street'] = []; + $curlData['address'][$key]['street'][] = $street; + } + $newKey = '_item' . ($key + 1); + if ($curlData['address'][$key]['default_billing'] === 'Yes') { + unset($curlData['address'][$key]['default_billing']); + $curlData['account']['default_billing'] = $newKey; + } + if ($curlData['address'][$key]['default_shipping'] === 'Yes') { + unset($curlData['address'][$key]['default_shipping']); + $curlData['account']['default_shipping'] = $newKey; + } + $curlData['address'][$newKey] = $curlData['address'][$key]; + unset($curlData['address'][$key]); + } + + return $curlData; + } + /** * Encoded filter parameters * diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php index e4c8cf15c19..a65c8d741a4 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/AddressInjectable.php @@ -33,13 +33,58 @@ use Mtf\Repository\AbstractRepository; class AddressInjectable extends AbstractRepository { /** - * @param array $defaultConfig - * @param array $defaultData + * @param array $defaultConfig [optional] + * @param array $defaultData [optional] * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct(array $defaultConfig = [], array $defaultData = []) { + $this->_data['US_address'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'John.Doe%isolation%@example.com', + 'company' => 'Magento %isolation%', + 'street' => '6161 West Centinela Avenue', + 'city' => 'Culver City', + 'region_id' => 'California', + 'postcode' => '90230', + 'country_id' => 'United States', + 'telephone' => '555-55-555-55', + 'default_billing' => 'Yes', + 'default_shipping' => 'Yes' + ]; + + $this->_data['US_address_default_billing'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'John.Doe%isolation%@example.com', + 'company' => 'Magento %isolation%', + 'street' => '6161 West Centinela Avenue', + 'city' => 'Culver City', + 'region_id' => 'California', + 'postcode' => '90230', + 'country_id' => 'United States', + 'telephone' => '555-55-555-55', + 'default_billing' => 'Yes', + 'default_shipping' => 'No' + ]; + + $this->_data['US_address_default_shipping'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'John.Doe%isolation%@example.com', + 'company' => 'Magento %isolation%', + 'street' => '6161 West Centinela Avenue', + 'city' => 'Culver City', + 'region_id' => 'California', + 'postcode' => '90230', + 'country_id' => 'United States', + 'telephone' => '555-55-555-55', + 'default_billing' => 'Yes', + 'default_shipping' => 'No' + ]; + $this->_data['default_US_address'] = [ 'company' => 'Magento %isolation%', 'street' => '6161 West Centinela Avenue', @@ -51,5 +96,17 @@ class AddressInjectable extends AbstractRepository 'default_billing' => 'Yes', 'default_shipping' => 'Yes', ]; + + $this->_data['US_address_without_email'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'company' => 'Magento %isolation%', + 'street' => '6161 West Centinela Avenue', + 'city' => 'Culver City', + 'region_id' => 'California', + 'postcode' => '90230', + 'country_id' => 'United States', + 'telephone' => '555-55-555-55', + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php index 44d0c2fc12a..0d395afad92 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/CustomerInjectable.php @@ -43,6 +43,7 @@ class CustomerInjectable extends AbstractRepository $this->_data['default'] = [ 'firstname' => 'John', 'lastname' => 'Doe', + 'group_id' => ['dataSet' => 'General'], 'email' => 'JohnDoe_%isolation%@example.com', 'password' => '123123q', 'password_confirmation' => '123123q', @@ -56,13 +57,13 @@ class CustomerInjectable extends AbstractRepository 'password_confirmation' => '123123q', 'dob' => '01/01/1990', 'gender' => 'Male', - 'group_id' => 'General', + 'group_id' => ['dataSet' => 'General'], ]; $this->_data['johndoe_retailer'] = [ 'firstname' => 'John', 'lastname' => 'Doe', - 'group_id' => 'Retailer', + 'group_id' => ['dataSet' => 'Retailer'], 'email' => 'JohnDoe_%isolation%@example.com', 'password' => '123123q', 'password_confirmation' => '123123q', @@ -86,5 +87,15 @@ class CustomerInjectable extends AbstractRepository 'lastname' => 'Doe', 'email' => 'JohnDoe_%isolation%@example.com', ]; + + $this->_data['johndoe_with_addresses'] = [ + 'firstname' => 'John', + 'lastname' => 'Doe', + 'group_id' => ['dataSet' => 'General'], + 'email' => 'JohnDoe_%isolation%@example.com', + 'password' => '123123q', + 'password_confirmation' => '123123q', + 'address' => ['presets' => 'US_address'] + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest/testCreateCustomerBackendEntity.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest/testCreateCustomerBackendEntity.csv index 8dceb84f7e2..47b35a7511a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest/testCreateCustomerBackendEntity.csv +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest/testCreateCustomerBackendEntity.csv @@ -1,4 +1,4 @@ -"customer/data/website_id";"customer/data/group_id";"customer/data/prefix";"customer/data/firstname";"customer/data/middlename";"customer/data/lastname";"customer/data/suffix";"customer/data/email";"customer/data/dob";"customer/data/taxvat";"customer/data/gender";"address/data/firstname";"address/data/lastname";"address/data/street";"address/data/city";"address/data/country_id";"address/data/region_id";"address/data/postcode";"address/data/telephone";"constraint" +"customer/data/website_id";"customer/data/group_id/dataSet";"customer/data/prefix";"customer/data/firstname";"customer/data/middlename";"customer/data/lastname";"customer/data/suffix";"customer/data/email";"customer/data/dob";"customer/data/taxvat";"customer/data/gender";"address/data/firstname";"address/data/lastname";"address/data/street";"address/data/city";"address/data/country_id";"address/data/region_id";"address/data/postcode";"address/data/telephone";"constraint" "Main Website";"General";"-";"John%isolation%";"-";"Doe%isolation%";"-";"JohnDoe%isolation%@example.com";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"assertCustomerSuccessSaveMessage, assertCustomerInGrid, assertCustomerForm" "Admin";"Wholesale";"M";"John%isolation%";"Jack";"Doe%isolation%";"S";"JohnDoe%isolation%@example.com";"3/16/2004";"-";"Male";"-";"-";"-";"-";"-";"-";"-";"-";"assertCustomerSuccessSaveMessage, assertCustomerInGrid, assertCustomerForm" "Main Website";"General";"-";"John%isolation%";"-";"Doe%isolation%";"-";"JohnDoe%isolation%@example.com";"-";"-";"-";"Joe";"Doe";"1 Main Street";"Culver City";"United States";"California";"90230";"3109450345";"assertCustomerSuccessSaveMessage, assertCustomerInGrid, assertCustomerForm" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest/testCreateCustomerGroup.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest/testCreateCustomerGroup.csv index 4fba0855cf1..215d04ed457 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest/testCreateCustomerGroup.csv +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest/testCreateCustomerGroup.csv @@ -1,4 +1,4 @@ "customerGroup/data/tax_class_id/dataSet";"customerGroup/data/customer_group_code";"constraint" "Retail Customer";"GroupName%isolation%";"assertCustomerGroupSuccessSaveMessage, assertCustomerGroupInGrid, assertCustomerGroupOnCustomerForm" -"Retail Customer";"General ";"assertCustomerGroupAlreadyExists, assertCustomerGroupNotInGrid" +"Retail Customer";"General";"assertCustomerGroupAlreadyExists" "customer_tax_class";"GroupName%isolation%";"assertCustomerGroupSuccessSaveMessage, assertCustomerGroupInGrid, assertCustomerGroupOnCustomerForm" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php index 02b14d07ae7..dde5bfc5dfd 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php @@ -25,9 +25,9 @@ namespace Magento\Customer\Test\TestCase; use Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; -use Magento\Customer\Test\Fixture\CustomerInjectable; /** * Test creation for DeleteCustomerBackendEntity @@ -65,10 +65,8 @@ class DeleteCustomerBackendEntityTest extends Injectable * @param CustomerIndexEdit $customerIndexEditPage * @return void */ - public function __inject( - CustomerIndex $customerIndexPage, - CustomerIndexEdit $customerIndexEditPage - ) { + public function __inject(CustomerIndex $customerIndexPage, CustomerIndexEdit $customerIndexEditPage) + { $this->customerIndexPage = $customerIndexPage; $this->customerIndexEditPage = $customerIndexEditPage; } @@ -76,7 +74,7 @@ class DeleteCustomerBackendEntityTest extends Injectable /** * Runs Delete Customer Backend Entity test * - * @param CustomerInjectable $initialCustomer + * @param CustomerInjectable $customer * @return void */ public function testDeleteCustomerBackendEntity(CustomerInjectable $customer) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php new file mode 100644 index 00000000000..e081b8a094f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php @@ -0,0 +1,131 @@ +<?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\Customer\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; + +/** + * Test creation for MassDeleteCustomerBackendEntityTest + * + * Test Flow: + * Preconditions: + * 1. Create X customers + * + * Steps: + * 1. Open backend + * 2. Go to Customers - All Customers + * 3. Select N customers from preconditions + * 4. Select in dropdown "Delete" + * 5. Click Submit button + * 6. Perform all assertions according to dataset + * + * @group Customers_(CS) + * @ZephyrId MAGETWO-26848 + */ +class MassDeleteCustomerBackendEntityTest extends Injectable +{ + /** + * Customer Index page + * + * @var CustomerIndex + */ + protected $customerIndexPage; + + /** + * Customer Index Edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEditPage; + + /** + * Factory for fixture + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Preparing pages for test + * + * @param FixtureFactory $fixtureFactory + * @param CustomerIndex $customerIndexPage + * @param CustomerIndexEdit $customerIndexEditPage + * @return void + */ + public function __inject( + FixtureFactory $fixtureFactory, + CustomerIndex $customerIndexPage, + CustomerIndexEdit $customerIndexEditPage + ) { + $this->fixtureFactory = $fixtureFactory; + $this->customerIndexPage = $customerIndexPage; + $this->customerIndexEditPage = $customerIndexEditPage; + } + + /** + * Runs Delete Customer Backend Entity test + * + * @param int $customersQty + * @param int $customersQtyToDelete + * @return array + */ + public function test($customersQty, $customersQtyToDelete) + { + // Preconditions: + $customers = $this->createCustomers($customersQty); + $deleteCustomers = []; + for ($i = 0; $i < $customersQtyToDelete; $i++) { + $deleteCustomers[] = ['email' => $customers[$i]->getEmail()]; + } + // Steps: + $this->customerIndexPage->open(); + $this->customerIndexPage->getCustomerGridBlock()->massaction($deleteCustomers, 'Delete', true); + + return ['customers' => $customers]; + } + + /** + * Create Customers + * + * @param int $customersQty + * @return CustomerInjectable[] + */ + protected function createCustomers($customersQty) + { + $customers = []; + for ($i = 0; $i < $customersQty; $i++) { + $customer = $this->fixtureFactory->createByCode('customerInjectable', ['dataSet' => 'default']); + $customer->persist(); + $customers[] = $customer; + } + + return $customers; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest/test.csv new file mode 100644 index 00000000000..143904b28df --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest/test.csv @@ -0,0 +1,2 @@ +"customer/dataSet";"customersQty";"customersQtyToDelete";"constraint" +"default";"3";"2";"assertCustomerMassDeleteSuccessMessage, assertCustomerMassDeleteNotInGrid, assertCustomerMassDeleteInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest/testUpdateCustomerBackendEntity.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest/testUpdateCustomerBackendEntity.csv index 6fd1ba7c220..156e27d5ca9 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest/testUpdateCustomerBackendEntity.csv +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest/testUpdateCustomerBackendEntity.csv @@ -1,4 +1,4 @@ -"initialCustomer/dataSet";"customer/data/group_id";"customer/data/prefix";"customer/data/firstname";"customer/data/middlename";"customer/data/lastname";"customer/data/suffix";"customer/data/email";"customer/data/dob";"customer/data/taxvat";"customer/data/gender";"address/data/prefix";"address/data/firstname";"address/data/middlename";"address/data/lastname";"address/data/suffix";"address/data/company";"address/data/street";"address/data/city";"address/data/country_id";"address/data/region_id";"address/data/region";"address/data/postcode";"address/data/telephone";"address/data/fax";"address/data/vat_id";"constraint" +"initialCustomer/dataSet";"customer/data/group_id/dataSet";"customer/data/prefix";"customer/data/firstname";"customer/data/middlename";"customer/data/lastname";"customer/data/suffix";"customer/data/email";"customer/data/dob";"customer/data/taxvat";"customer/data/gender";"address/data/prefix";"address/data/firstname";"address/data/middlename";"address/data/lastname";"address/data/suffix";"address/data/company";"address/data/street";"address/data/city";"address/data/country_id";"address/data/region_id";"address/data/region";"address/data/postcode";"address/data/telephone";"address/data/fax";"address/data/vat_id";"constraint" "default";"Wholesale";"%isolation%Prefix_";"John_%isolation%";"Middle Name %isolation%";"Doe%isolation%";"_Suffix%isolation%";"JohnDoe%isolation%@example.com";1/8/1986;123456789001;"Male";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"assertCustomerSuccessSaveMessage, assertCustomerForm, assertCustomerInGrid" "default";"-";"-";"-";"-";"-";"-";"-";"-";"-";"-";"Prefix%isolation%_";"Doe%isolation%";"Middle Name %isolation%";"Doe%isolation%";"_Suffix%isolation%";"Company%isolation%";"3962 Horner Street";"Dothan";"United States";"Alabama";"-";36303;"334-200-4060";"555-666-777-8910";"U1234567890";"assertCustomerSuccessSaveMessage, assertCustomerForm, assertCustomerInGrid" "default";"Retailer";"%isolation%Prefix_";"Jane_%isolation%";"Jane Middle Name %isolation%";"Doe%isolation%";"_JaneSuffix%isolation%";"Jane%isolation%@example.com";1/12/2000;987654321;"Female";"Prefix%isolation%_";"Doe%isolation%";"Middle Name %isolation%";"Doe%isolation%";"_Suffix%isolation%";"Company%isolation%";"39 Northgate Street";"BICKTON";"United Kingdom";"-";"PINMINNOCH";"KA26 1PF ";"999-777-111-2345";"-";987654321;"assertCustomerSuccessSaveMessage, assertCustomerForm, assertCustomerInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/global/constraint.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/global/constraint.xml index a235bf6c8a7..c82ef107d76 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/global/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/global/constraint.xml @@ -121,4 +121,16 @@ <address class="Magento\Customer\Test\Fixture\AddressInjectable" /> </require> </assertCustomerDefaultAddresses> + <assertCustomerMassDeleteSuccessMessage module="Magento_Customer"> + <severeness>low</severeness> + <require /> + </assertCustomerMassDeleteSuccessMessage> + <assertCustomerMassDeleteNotInGrid module="Magento_Customer"> + <severeness>low</severeness> + <require /> + </assertCustomerMassDeleteNotInGrid> + <assertCustomerMassDeleteInGrid module="Magento_Customer"> + <severeness>low</severeness> + <require /> + </assertCustomerMassDeleteInGrid> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Product/View.php index 768536202e6..f1d585dfc89 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Product/View.php @@ -29,8 +29,8 @@ use Mtf\Block\Block; use Mtf\Client\Element; /** + * Class View * Reviews frontend block - * */ class View extends Block { @@ -41,69 +41,39 @@ class View extends Block */ protected $itemSelector = '.review-items .review-item'; - /** - * Nickname selector - * - * @var string - */ - protected $nicknameSelector = '.review-author .review-details-value'; - - /** - * Title selector - * - * @var string - */ - protected $titleSelector = '.review-title'; - - /** - * Detail selector - * - * @var string - */ - protected $detailSelector = '.review-content'; - /** * Selectors mapping * * @var array */ - protected $selectorsMapping; + protected $selectorsMapping = [ + 'nickname' => '.review-author .review-details-value', + 'title' => '.review-title', + 'detail' => '.review-content', + ]; /** - * {@inheritdoc} - */ - protected function _init() - { - parent::_init(); - $this->selectorsMapping = array( - 'nickname' => $this->nicknameSelector, - 'title' => $this->titleSelector, - 'detail' => $this->detailSelector, - ); - } - - /** - * Get first review item + * Is visible review item * - * @return Element + * @return bool */ - public function getFirstReview() + public function isVisibleReviewItem() { - return $this->_rootElement->find($this->itemSelector); + return $this->_rootElement->find($this->itemSelector)->isVisible(); } /** - * Get selector field for review on product view page + * Get field value for review on product view page * * @param string $field - * @return string - * @throws \Exception + * @return string|null */ - public function getFieldSelector($field) + public function getFieldValue($field) { - if (!isset($this->selectorsMapping[$field])) { - throw new \Exception(sprintf('Selector of field "%s" is not defined', $field)); + if (isset($this->selectorsMapping[$field])) { + return $this->_rootElement->find($this->selectorsMapping[$field])->getText(); } - return $this->selectorsMapping[$field]; + + return null; } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewNotOnProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewNotOnProductPage.php new file mode 100644 index 00000000000..87d9939feb6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewNotOnProductPage.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\Review\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Page\Product\CatalogProductView; + +/** + * Class AssertProductReviewNotOnProductPage + * Assert that product review Not available on product page + */ +class AssertProductReviewNotOnProductPage extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'middle'; + + /** + * Assert that product review Not available on product page + * + * @param CatalogProductView $catalogProductView + * @param ReviewInjectable $reviewInitial + * @return void + */ + public function processAssert(CatalogProductView $catalogProductView, ReviewInjectable $reviewInitial) + { + /** @var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $catalogProductView->init($product); + $catalogProductView->open(); + + $reviewBlock = $catalogProductView->getCustomerReviewBlock(); + $catalogProductView->getViewBlock()->selectTab('Reviews'); + \PHPUnit_Framework_Assert::assertFalse( + $reviewBlock->isVisibleReviewItem(), + 'Error, product review is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Review is not available on the product page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php new file mode 100644 index 00000000000..18d14df9a0a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php @@ -0,0 +1,88 @@ +<?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\Review\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Page\Product\CatalogProductView; + +/** + * Class AssertProductReviewOnProductPage + * Assert that product review available on product page + */ +class AssertProductReviewOnProductPage extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'middle'; + + /** + * Assert that product review available on product page + * + * @param CatalogProductView $catalogProductView + * @param ReviewInjectable $review + * @param ReviewInjectable $reviewInitial + * @return void + */ + public function processAssert( + CatalogProductView $catalogProductView, + ReviewInjectable $review, + ReviewInjectable $reviewInitial + ) { + $errors = []; + /** @var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $catalogProductView->init($product); + $catalogProductView->open(); + + $reviewBlock = $catalogProductView->getCustomerReviewBlock(); + $catalogProductView->getViewBlock()->selectTab('Reviews'); + foreach ($review->getData() as $name => $value) { + $reviewValue = $reviewBlock->getFieldValue($name); + if (($reviewValue !== null) && (0 !== strcasecmp($value, trim($reviewValue)))) { + $errors[] = '- field "' . $name . '" is not equals submitted one, error value "' . $value . '"'; + } + } + + \PHPUnit_Framework_Assert::assertEmpty( + $errors, + 'The Review contains the following errors:' . PHP_EOL . implode(PHP_EOL, $errors) + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Product review is displayed correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Handler/ReviewInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/Review/Test/Handler/ReviewInjectable/Curl.php index 7d5081e94cd..e032a7355a1 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Handler/ReviewInjectable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Handler/ReviewInjectable/Curl.php @@ -24,15 +24,15 @@ namespace Magento\Review\Test\Handler\ReviewInjectable; -use Magento\Backend\Test\Handler\Extractor; -use Magento\Review\Test\Fixture\ReviewInjectable; -use Magento\Review\Test\Fixture\Rating; +use Mtf\System\Config; use Mtf\Fixture\FixtureInterface; -use Mtf\Handler\Curl as AbstractCurl; use Mtf\Util\Protocol\CurlInterface; -use Mtf\Util\Protocol\CurlTransport\BackendDecorator; use Mtf\Util\Protocol\CurlTransport; -use Mtf\System\Config; +use Magento\Review\Test\Fixture\Rating; +use Magento\Backend\Test\Handler\Extractor; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Mtf\Util\Protocol\CurlTransport\BackendDecorator; +use Mtf\Handler\Curl as AbstractCurl; /** * Class Curl @@ -51,7 +51,7 @@ class Curl extends AbstractCurl implements ReviewInjectableInterface 'Pending' => 2, 'Not Approved' => 3 ], - 'stores' => [ + 'select_stores' => [ 'Main Website/Main Website Store/Default Store View' => 1 ] ]; @@ -93,23 +93,33 @@ class Curl extends AbstractCurl implements ReviewInjectableInterface $data = $review->getData(); /* Prepare ratings */ - $sourceRatings = $review->getDataFieldConfig('ratings')['source']; - $ratings = []; - foreach ($data['ratings'] as $rating) { - $ratings[$rating['title']] = $rating['rating']; + if ($review->hasData('ratings')) { + $sourceRatings = $review->getDataFieldConfig('ratings')['source']; + $ratings = []; + foreach ($data['ratings'] as $rating) { + $ratings[$rating['title']] = $rating['rating']; + } + $data['ratings'] = []; + foreach ($sourceRatings->getRatings() as $ratingFixture) { + /** @var Rating $ratingFixture */ + $ratingCode = $ratingFixture->getRatingCode(); + if (isset($ratings[$ratingCode])) { + $ratingOptions = $ratingFixture->getOptions(); + $vote = $ratings[$ratingCode]; + $data['ratings'][$ratingFixture->getRatingId()] = $ratingOptions[$vote]; + } + } } - $data['ratings'] = []; - foreach ($sourceRatings->getRatings() as $ratingFixture) { - /** @var Rating $ratingFixture */ - $ratingCode = $ratingFixture->getRatingCode(); - if (isset($ratings[$ratingCode])) { - $ratingOptions = $ratingFixture->getOptions(); - $vote = $ratings[$ratingCode]; - $data['ratings'][$ratingFixture->getRatingId()] = $ratingOptions[$vote]; + + if ($review->hasData('select_stores')) { + foreach (array_keys($data['select_stores']) as $key) { + if (isset($this->mappingData['select_stores'][$data['select_stores'][$key]])) { + $data['select_stores'][$key] = $this->mappingData['select_stores'][$data['select_stores'][$key]]; + } } } - /* prepare product id */ + /* Prepare product id */ $data['product_id'] = $data['entity_id']; unset($data['entity_id']); @@ -128,6 +138,6 @@ class Curl extends AbstractCurl implements ReviewInjectableInterface $extractor = new Extractor($url, $regex); $match = $extractor->getData(); - return empty($match[1]) ? null : $match[1]; + return empty($match[1]) ? null : (int)$match[1]; } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Repository/ReviewInjectable.php b/dev/tests/functional/tests/app/Magento/Review/Test/Repository/ReviewInjectable.php index 82aa09b530f..84963f8cfd5 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Repository/ReviewInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Repository/ReviewInjectable.php @@ -33,7 +33,8 @@ use Mtf\Repository\AbstractRepository; class ReviewInjectable extends AbstractRepository { /** - * @constructor + * Constructor + * * @param array $defaultConfig * @param array $defaultData * @@ -55,5 +56,14 @@ class ReviewInjectable extends AbstractRepository ], 'entity_id' => ['dataSet' => 'catalogProductSimple::default'] ]; + + $this->_data['frontend_review'] = [ + 'status_id' => 'Pending', + 'select_stores' => ['Main Website/Main Website Store/Default Store View'], + 'nickname' => 'nickname_%isolation%', + 'title' => 'title_%isolation%', + 'detail' => 'review_detail_%isolation%', + 'entity_id' => ['dataSet' => 'catalogProductSimple::default'] + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php new file mode 100644 index 00000000000..59a11b666bf --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php @@ -0,0 +1,99 @@ +<?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\Review\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Review\Test\Page\Adminhtml\ReviewEdit; +use Magento\Review\Test\Page\Adminhtml\ReviewIndex; + +/** + * Test Creation for Moderate ProductReview Entity + * + * Test Flow: + * + * Preconditions: + * 1. Create product + * 2. Create product review + * + * Steps: + * 1. Login to backend + * 2. Open Marketing -> Reviews + * 3. Search and open review created in precondition + * 4. Fill data according to dataset + * 5. Save + * 6. Perform all assertions + * + * @group Reviews_and_Ratings_(MX) + * @ZephyrId MAGETWO-26768 + */ +class ModerateProductReviewEntityTest extends Injectable +{ + /** + * Backend review grid page + * + * @var ReviewIndex + */ + protected $reviewIndex; + + /** + * Backend review edit page + * + * @var ReviewEdit + */ + protected $reviewEdit; + + /** + * Injection pages + * + * @param ReviewIndex $reviewIndex + * @param ReviewEdit $reviewEdit + * @return void + */ + public function __inject(ReviewIndex $reviewIndex, ReviewEdit $reviewEdit) + { + $this->reviewIndex = $reviewIndex; + $this->reviewEdit = $reviewEdit; + } + + /** + * Run moderate product review test + * + * @param ReviewInjectable $reviewInitial + * @param ReviewInjectable $review + * @return void + */ + public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review) + { + // Precondition + $reviewInitial->persist(); + + // Steps + $this->reviewIndex->open(); + $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]); + $this->reviewEdit->getReviewForm()->fill($review); + $this->reviewEdit->getPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest/test.csv new file mode 100644 index 00000000000..e908dfcc980 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest/test.csv @@ -0,0 +1,3 @@ +"reviewInitial/dataSet";"review/data/status_id";"review/data/nickname";"review/data/title";"review/data/detail";"constraint" +"frontend_review";"Approved";"Nick%isolation%";"Title %isolation%";"Details %isolation%";"assertProductReviewBackendSuccessSaveMessage, assertProductReviewInGrid, assertProductReviewOnProductPage" +"frontend_review";"Not Approved";"Nick%isolation%";"Title %isolation%";"Details %isolation%";"assertProductReviewBackendSuccessSaveMessage, assertProductReviewInGrid, assertProductReviewNotOnProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ReviewTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ReviewTest.php index 732a83d475d..8468b20d4ef 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ReviewTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ReviewTest.php @@ -25,15 +25,14 @@ namespace Magento\Review\Test\TestCase; use Mtf\Block\Form; -use Magento\Review\Test\Block\Product\View\Summary; -use Magento\Review\Test\Block\Product\View; -use Magento\Review\Test\Fixture\Review; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; +use Magento\Review\Test\Fixture\Review; +use Magento\Review\Test\Block\Product\View; +use Magento\Review\Test\Block\Product\View\Summary; /** * Product reviews functionality - * */ class ReviewTest extends Functional { @@ -68,7 +67,7 @@ class ReviewTest extends Functional $productPage->open(); $this->verifyNoReviewOnPage($reviewsSummaryBlock); $reviewsSummaryBlock->getAddReviewLink()->click(); - $this->assertFalse($reviewsBlock->getFirstReview()->isVisible(), 'No reviews below the form required'); + $this->assertFalse($reviewsBlock->isVisibleReviewItem(), 'No reviews below the form required'); $reviewForm->fill($reviewFixture); $reviewForm->submit(); @@ -82,7 +81,7 @@ class ReviewTest extends Functional Factory::getApp()->magentoBackendLoginUser(); $backendReviewIndex->open(); - $reviewGrid->searchAndOpen(array('title' => $reviewFixture->getTitle())); + $reviewGrid->searchAndOpen(['title' => $reviewFixture->getTitle()]); $this->assertEquals('Guest', $reviewBackendForm->getPostedBy(), 'Review is not posted by Guest'); $this->assertEquals('Pending', $reviewBackendForm->getStatus(), 'Review is not in Pending status'); $this->assertTrue( @@ -114,7 +113,7 @@ class ReviewTest extends Functional $reviewsBlock = $productPage->getCustomerReviewBlock(); $reviewsSummaryBlock->getViewReviewLink()->click(); $this->assertContains( - sprintf('You\'re reviewing:%s', $productFixture->getName()), + sprintf("You're reviewing:\n%s", $productFixture->getName()), $reviewForm->getLegend()->getText() ); $this->verifyReview($reviewsBlock, $reviewFixture); @@ -154,12 +153,10 @@ class ReviewTest extends Functional */ protected function verifyReview(View $reviewBlock, Review $fixture) { - $reviewItem = $reviewBlock->getFirstReview(); foreach ($fixture->getData('fields') as $field => $data) { - $element = $reviewItem->find($reviewBlock->getFieldSelector($field)); $this->assertEquals( strtolower($data['value']), - strtolower(trim($element->getText())), + strtolower(trim($reviewBlock->getFieldValue($field))), sprintf('Field "%s" is not equals submitted one.', $field) ); } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/etc/global/constraint.xml b/dev/tests/functional/tests/app/Magento/Review/Test/etc/global/constraint.xml index 24f5b1b58bf..c9779ddbf30 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/etc/global/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/etc/global/constraint.xml @@ -72,4 +72,10 @@ <assertProductReviewBackendSuccessSaveMessage module="Magento_Review"> <severeness>middle</severeness> </assertProductReviewBackendSuccessSaveMessage> + <assertProductReviewNotOnProductPage module="Magento_Review"> + <severeness>middle</severeness> + </assertProductReviewNotOnProductPage> + <assertProductReviewOnProductPage module="Magento_Review"> + <severeness>middle</severeness> + </assertProductReviewOnProductPage> </constraint> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php b/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php index 8e891f8a7b4..ac873714ba6 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Block/Switcher.php @@ -35,7 +35,7 @@ class Switcher extends Block * * @var string */ - protected $dropDownButton = '#language-switcher'; + protected $dropDownButton = '#switcher-language-trigger'; /** * Select store diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php index 15416a4c8fc..52a41776a1f 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.php @@ -58,7 +58,7 @@ class Form extends FormInterface * * @var string */ - protected $taxRateBlock = '[class*=tax_rate]'; + protected $taxRateBlock = '[class*="tax_rate"]'; /** * Tax rate form @@ -89,11 +89,11 @@ class Form extends FormInterface protected $optionMaskElement = './/*[contains(@class, "mselect-list-item")]//label/span[text()="%s"]'; /** - * Css selector for Add New button + * XPath selector for "Add New Tax Rate" button * * @var string */ - protected $addNewButton = '.mselect-button-add'; + protected $addNewButton = './/*[contains(@class,"mselect-button-add")]'; /** * Css selector for Add New tax class input @@ -181,10 +181,10 @@ class Form extends FormInterface if (!$option->isVisible()) { $taxRate = $taxRatesFixture[$key]; - /** @var \Magento\Tax\Test\Fixture\TaxRate $taxRate */ - $taxRateBlock->find($this->addNewButton)->click(); + $this->clickAddNewButton($taxRateBlock); $taxRateForm->fill($taxRate); $taxRateForm->saveTaxRate(); + /** @var \Magento\Tax\Test\Fixture\TaxRate $taxRate */ $code = $taxRate->getCode(); $this->waitUntilOptionIsVisible($taxRateBlock, $code); } @@ -203,7 +203,7 @@ class Form extends FormInterface foreach ($taxClasses as $taxClass) { $option = $element->find(sprintf($this->optionMaskElement, $taxClass), Locator::SELECTOR_XPATH); if (!$option->isVisible()) { - $element->find($this->addNewButton)->click(); + $element->find($this->addNewButton, Locator::SELECTOR_XPATH)->click(); $element->find($this->addNewInput)->setValue($taxClass); $element->find($this->saveButton)->click(); $this->waitUntilOptionIsVisible($element, $taxClass); @@ -252,4 +252,21 @@ class Form extends FormInterface $taxRates = $this->_rootElement->find($this->taxRateBlock, Locator::SELECTOR_CSS, 'multiselectlist'); return $taxRates->getAllValues(); } + + /** + * Click 'Add New Tax Rate' button + * + * @param Element $taxRateBlock + * @return void + */ + protected function clickAddNewButton(Element $taxRateBlock) + { + $addNewButton = $this->addNewButton; + $taxRateBlock->waitUntil( + function () use ($taxRateBlock, $addNewButton) { + return $taxRateBlock->find($addNewButton, Locator::SELECTOR_XPATH)->isVisible() ? true : null; + } + ); + $taxRateBlock->find($this->addNewButton, Locator::SELECTOR_XPATH)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.xml index d0df4db97b6..822b87fb110 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/Form.xml @@ -29,15 +29,15 @@ <priority /> <position /> <tax_rate> - <selector>[class*=tax_rate]</selector> + <selector>[class*="tax_rate"]</selector> <input>multiselectlist</input> </tax_rate> <tax_customer_class> - <selector>[class*=tax_customer_class]</selector> + <selector>[class*="tax_customer_class"]</selector> <input>multiselectlist</input> </tax_customer_class> <tax_product_class> - <selector>[class*=tax_product_class]</selector> + <selector>[class*="tax_product_class"]</selector> <input>multiselectlist</input> </tax_product_class> </fields> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php index 6dddfefda14..854afeb3c16 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRateForm.php @@ -88,7 +88,6 @@ class AssertTaxRateForm extends AbstractConstraint } else { unset($data['zip_from'], $data['zip_to']); } - $data['rate'] = number_format($data['rate'], 4); return $data; } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsApplied.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsApplied.php index f319901e801..47c9e56bbf2 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsApplied.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsApplied.php @@ -60,6 +60,7 @@ class AssertTaxRuleIsApplied extends AssertTaxRuleApplying . "\nActual: " . $actualTax; } } + if ($expectedGrandTotal !== $actualGrandTotal) { $errorMessages[] = 'Grand Total is not correct.' . "\nExpected: " . $expectedGrandTotal diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest/testUpdateTaxRate.csv b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest/testUpdateTaxRate.csv index a2d457148db..d744bbd95bb 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest/testUpdateTaxRate.csv +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRateEntityTest/testUpdateTaxRate.csv @@ -4,4 +4,4 @@ "default";"TaxIdentifier%isolation%";"No";"-";"-";"*";"United Kingdom";"*";"777";"assertTaxRateIsInCorrectRange" "withZipRange";"TaxIdentifier%isolation%";"No";"-";"-";"180";"Canada";"*";"25";"assertTaxRateSuccessSaveMessage, assertTaxRateInGrid, assertTaxRateForm" "withZipRange";"TaxIdentifier%isolation%";"Yes";"0";"7800935";"-";"United Kingdom";"*";"0";"assertTaxRateIsInCorrectRange" -"withZipRange";"TaxIdentifier%isolation%";"No";"-";"-";"*";"France";"Val-d'Oise";"0.1";"assertTaxRateSuccessSaveMessage, assertTaxRateInGrid, assertTaxRateForm" \ No newline at end of file +"withZipRange";"TaxIdentifier%isolation%";"No";"-";"-";"*";"France";"Val-d'Oise";"0.1";"assertTaxRateSuccessSaveMessage, assertTaxRateInGrid, assertTaxRateForm" diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php index d35d8a55467..9fd41f76460 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/UpdateTaxRuleEntityTest.php @@ -24,12 +24,12 @@ namespace Magento\Tax\Test\TestCase; -use Magento\Customer\Test\Fixture\AddressInjectable; use Mtf\TestCase\Injectable; use Mtf\Fixture\FixtureFactory; use Magento\Tax\Test\Fixture\TaxRule; use Magento\Tax\Test\Page\Adminhtml\TaxRuleNew; use Magento\Tax\Test\Page\Adminhtml\TaxRuleIndex; +use Magento\Customer\Test\Fixture\AddressInjectable; /** * Test Creation for Update TaxRuleEntity @@ -74,7 +74,7 @@ class UpdateTaxRuleEntityTest extends Injectable */ public function __prepare(FixtureFactory $fixtureFactory) { - $customer = $fixtureFactory->createByCode('customerInjectable', ['dataSet' => 'default']); + $customer = $fixtureFactory->createByCode('customerInjectable', ['dataSet' => 'johndoe_retailer']); $customer->persist(); return ['customer' => $customer]; @@ -87,10 +87,8 @@ class UpdateTaxRuleEntityTest extends Injectable * @param TaxRuleNew $taxRuleNewPage * @return void */ - public function __inject( - TaxRuleIndex $taxRuleIndexPage, - TaxRuleNew $taxRuleNewPage - ) { + public function __inject(TaxRuleIndex $taxRuleIndexPage, TaxRuleNew $taxRuleNewPage) + { $this->taxRuleIndexPage = $taxRuleIndexPage; $this->taxRuleNewPage = $taxRuleNewPage; } @@ -116,11 +114,8 @@ class UpdateTaxRuleEntityTest extends Injectable $initialTaxRule->persist(); // Steps - $filters = [ - 'code' => $initialTaxRule->getCode(), - ]; $this->taxRuleIndexPage->open(); - $this->taxRuleIndexPage->getTaxRuleGrid()->searchAndOpen($filters); + $this->taxRuleIndexPage->getTaxRuleGrid()->searchAndOpen(['code' => $initialTaxRule->getCode()]); $this->taxRuleNewPage->getTaxRuleForm()->fill($taxRule); $this->taxRuleNewPage->getFormPageActions()->save(); } diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php index 5217cc42de3..2b4a18baeea 100644 --- a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php @@ -77,17 +77,14 @@ class Links extends Block /** * Get the number of products added to compare list * - * @return string|bool + * @return string */ public function getQtyInCompareList() { + $this->waitForElementVisible($this->qtyCompareProducts); $compareProductLink = $this->_rootElement->find($this->qtyCompareProducts); - if ($compareProductLink->isVisible()) { - preg_match_all('/^\d+/', $compareProductLink->getText(), $matches); - return $matches[0][0]; - } else { - return false; - } + preg_match_all('/^\d+/', $compareProductLink->getText(), $matches); + return $matches[0][0]; } /** diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Handler/UrlRewrite/Curl.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Handler/UrlRewrite/Curl.php index 53b1b18ae57..f33ecd7dae8 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Handler/UrlRewrite/Curl.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Handler/UrlRewrite/Curl.php @@ -43,7 +43,10 @@ class Curl extends AbstractCurl implements UrlRewriteInterface * @var array */ protected $mappingData = [ - 'store_id' => ['Default Store View' => 1], + 'store_id' => [ + 'Default Store View' => 1, + 'Main Website/Main Website Store/Default Store View' => 1, + ], 'options' => [ 'Temporary (302)' => 'R', 'Permanent (301)' => 'RP', diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Repository/UrlRewrite.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Repository/UrlRewrite.php index 949d11d90aa..44d17464bcb 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Repository/UrlRewrite.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Repository/UrlRewrite.php @@ -48,6 +48,12 @@ class UrlRewrite extends AbstractRepository 'id_path' => ["test%isolation%"] ]; + $this->_data['default_without_target'] = [ + 'request_path' => 'test-test-test%isolation%.html', + 'options' => 'Temporary (302)', + 'store_id' => 'Main Website/Main Website Store/Default Store View', + ]; + $this->_data['custom_rewrite_wishlist'] = [ 'store_id' => 'Main Website/Main Website Store/Default Store View', 'request_path' => 'wishlist/%isolation%', diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/CreateCustomUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/CreateCustomUrlRewriteEntityTest.php index 9816b32dac1..ca87d5cc21b 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/CreateCustomUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/CreateCustomUrlRewriteEntityTest.php @@ -49,7 +49,7 @@ use Magento\UrlRewrite\Test\Page\Adminhtml\UrlrewriteIndex; * 7. Perform all assertions * * @group URL_Rewrites_(PS) - * @ZephyrId MTA-334 + * @ZephyrId MAGETWO-25474 */ class CreateCustomUrlRewriteEntityTest extends Injectable { diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest/testDeleteProductUrlRewrite.csv b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest/testDeleteProductUrlRewrite.csv index 102c7b7f215..4a6a2d83666 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest/testDeleteProductUrlRewrite.csv +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest/testDeleteProductUrlRewrite.csv @@ -1,2 +1,2 @@ "productRedirect/dataSet";"productRedirect/data/id_path/entity";"constraint" -"default";"product/%catalogProductSimple::100_dollar_product%";"assertUrlRewriteDeletedMessage, assertUrlRewriteNotInGrid, assertPageByUrlRewriteIsNotFound" +"default_without_target";"product/%catalogProductSimple::100_dollar_product%";"assertUrlRewriteDeletedMessage, assertUrlRewriteNotInGrid, assertPageByUrlRewriteIsNotFound" diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Fixture/AdminUserRole.xml b/dev/tests/functional/tests/app/Magento/User/Test/Fixture/AdminUserRole.xml index 62ec17b4b56..4884968e5ba 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Fixture/AdminUserRole.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Fixture/AdminUserRole.xml @@ -26,7 +26,7 @@ <fixture class="Magento\User\Test\Fixture\AdminUserRole"> <module>Magento_User</module> <type>flat</type> - <entity_type>admin_role</entity_type> + <entity_type>authorization_role</entity_type> <collection>Magento\User\Model\Resource\Role\User\Collection</collection> <fields> <role_id> diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.php index 239ee6aebd5..74f2144d179 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserEntityTest.php @@ -42,7 +42,7 @@ use Mtf\TestCase\Injectable; * 6. Perform assertions * * @group ACL_(MX) - * @ZephyrId MAGETWO-21338 + * @ZephyrId MAGETWO-23413 */ class CreateAdminUserEntityTest extends Injectable { diff --git a/dev/tests/functional/tests/app/Magento/User/Test/etc/global/fixture.xml b/dev/tests/functional/tests/app/Magento/User/Test/etc/global/fixture.xml index b5ee11b7bb1..ccd925cbfe1 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/etc/global/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/etc/global/fixture.xml @@ -31,7 +31,7 @@ </user> <adminUserRole module="Magento_User"> <type>flat</type> - <entity_type>admin_role</entity_type> + <entity_type>authorization_role</entity_type> <collection>Magento\User\Model\Resource\Role\User\Collection</collection> <fields> <resource_access> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.php new file mode 100644 index 00000000000..cc9b3901e74 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.php @@ -0,0 +1,52 @@ +<?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\Wishlist\Test\Page; + +use Mtf\Page\FrontendPage; + +/** + * Class WishlistIndex + */ +class WishlistIndex extends FrontendPage +{ + const MCA = 'wishlist/index/index'; + + protected $_blocks = [ + 'messagesBlock' => [ + 'name' => 'messagesBlock', + 'class' => 'Magento\Core\Test\Block\Messages', + 'locator' => '.messages', + 'strategy' => 'css selector', + ], + ]; + + /** + * @return \Magento\Core\Test\Block\Messages + */ + public function getMessagesBlock() + { + return $this->getBlockInstance('messagesBlock'); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml new file mode 100644 index 00000000000..78e32fd8375 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml @@ -0,0 +1,33 @@ +<?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 mca="wishlist/index/index" > + <block> + <name>messagesBlock</name> + <class>Magento\Core\Test\Block\Messages</class> + <locator>.messages</locator> + <strategy>css selector</strategy> + </block> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/page.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/page.xml new file mode 100644 index 00000000000..afc4c9a8116 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/page.xml @@ -0,0 +1,31 @@ +<?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> + <wishlistIndex> + <mca>wishlist/index/index</mca> + <class>Magento\Wishlist\Test\Page\WishlistIndex</class> + </wishlistIndex> +</page> diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index a0d14965a78..4a4e97a721f 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -23,6 +23,7 @@ */ namespace Magento\TestFramework; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\App\Filesystem; use Magento\Framework\App\Filesystem\DirectoryList; @@ -468,18 +469,21 @@ class Application ); $user->save(); - /** @var $roleAdmin \Magento\User\Model\Role */ - $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); + /** @var $roleAdmin \Magento\Authorization\Model\Role */ + $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Authorization\Model\Role'); $roleAdmin->load($adminRoleName, 'role_name'); - /** @var $roleUser \Magento\User\Model\Role */ - $roleUser = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); + /** @var $roleUser \Magento\Authorization\Model\Role */ + $roleUser = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Authorization\Model\Role'); $roleUser->setData( array( 'parent_id' => $roleAdmin->getId(), 'tree_level' => $roleAdmin->getTreeLevel() + 1, - 'role_type' => \Magento\User\Model\Acl\Role\User::ROLE_TYPE, + 'role_type' => \Magento\Authorization\Model\Acl\Role\User::ROLE_TYPE, 'user_id' => $user->getId(), + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => $user->getFirstname() ) ); diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php b/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php index b7e653c3b3f..1abce9deaba 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/_files/notifications.php @@ -17,38 +17,40 @@ * 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) */ $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); $mesasge->setSeverity( - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 1' )->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); -$mesasge->setSeverity(\Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR)->setTitle('Unread Major 1')->save(); +$mesasge->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) + ->setTitle('Unread Major 1') + ->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); $mesasge->setSeverity( - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 2' )->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); $mesasge->setSeverity( - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Unread Critical 3' )->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); $mesasge->setSeverity( - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Read Critical 1' )->setIsRead( @@ -56,11 +58,13 @@ $mesasge->setSeverity( )->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); -$mesasge->setSeverity(\Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR)->setTitle('Unread Major 2')->save(); +$mesasge->setSeverity(\Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR) + ->setTitle('Unread Major 2') + ->save(); $mesasge = $om->create('Magento\AdminNotification\Model\Inbox'); $mesasge->setSeverity( - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setTitle( 'Removed Critical 1' )->setIsRemove( diff --git a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/CollectionTest.php similarity index 86% rename from dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/CollectionTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/CollectionTest.php index b31e87ba011..4bafcd86fa6 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/CollectionTest.php @@ -21,7 +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\User\Model\Resource\Role; +namespace Magento\Authorization\Model\Resource\Role; +use Magento\Authorization\Model\UserContextInterface; /** * Role collection test @@ -30,14 +31,14 @@ namespace Magento\User\Model\Resource\Role; class CollectionTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Resource\Role\Collection + * @var \Magento\Authorization\Model\Resource\Role\Collection */ protected $_collection; protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Resource\Role\Collection' + 'Magento\Authorization\Model\Resource\Role\Collection' ); } @@ -45,7 +46,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); $user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); - $this->_collection->setUserFilter($user->getId(), \Magento\Authz\Model\UserIdentifier::USER_TYPE_ADMIN); + $this->_collection->setUserFilter($user->getId(), UserContextInterface::USER_TYPE_ADMIN); $selectQueryStr = $this->_collection->getSelect()->__toString(); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/Grid/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/Grid/CollectionTest.php similarity index 85% rename from dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/Grid/CollectionTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/Grid/CollectionTest.php index 59e0c12527f..9c6b5ebb8e4 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Role/Grid/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Role/Grid/CollectionTest.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\User\Model\Resource\Role\Grid; +namespace Magento\Authorization\Model\Resource\Role\Grid; /** * @magentoAppArea adminhtml @@ -29,14 +29,14 @@ namespace Magento\User\Model\Resource\Role\Grid; class CollectionTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Resource\Role\Grid\Collection + * @var \Magento\Authorization\Model\Resource\Role\Grid\Collection */ private $_collection; protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Resource\Role\Grid\Collection' + 'Magento\Authorization\Model\Resource\Role\Grid\Collection' ); } @@ -44,7 +44,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { $expectedResult = array( array( - 'role_type' => \Magento\User\Model\Acl\Role\Group::ROLE_TYPE, + 'role_type' => \Magento\Authorization\Model\Acl\Role\Group::ROLE_TYPE, 'role_name' => \Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME ) ); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/Resource/RoleTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/RoleTest.php similarity index 90% rename from dev/tests/integration/testsuite/Magento/User/Model/Resource/RoleTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/RoleTest.php index 282b2738fdb..c009c73d301 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/Resource/RoleTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/RoleTest.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\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; /** * Role resource test @@ -32,9 +32,9 @@ class RoleTest extends \PHPUnit_Framework_TestCase { public function testGetRoleUsers() { - $role = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); + $role = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Authorization\Model\Role'); $roleResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Resource\Role' + 'Magento\Authorization\Model\Resource\Role' ); $this->assertEmpty($roleResource->getRoleUsers($role)); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Rules/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Rules/CollectionTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/User/Model/Resource/Rules/CollectionTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Rules/CollectionTest.php index c61adc28cc9..cf296493286 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/Resource/Rules/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/Resource/Rules/CollectionTest.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\User\Model\Resource\Rules; +namespace Magento\Authorization\Model\Resource\Rules; /** * @magentoAppArea adminhtml @@ -29,14 +29,14 @@ namespace Magento\User\Model\Resource\Rules; class CollectionTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Resource\Rules\Collection + * @var \Magento\Authorization\Model\Resource\Rules\Collection */ protected $_collection; protected function setUp() { $this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Resource\Rules\Collection' + 'Magento\Authorization\Model\Resource\Rules\Collection' ); } diff --git a/dev/tests/integration/testsuite/Magento/User/Model/RoleTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php similarity index 80% rename from dev/tests/integration/testsuite/Magento/User/Model/RoleTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.php index f8e6bbd0daa..29e53656ade 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/RoleTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/RoleTest.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\User\Model; +namespace Magento\Authorization\Model; /** * @magentoAppArea adminhtml @@ -29,21 +29,14 @@ namespace Magento\User\Model; class RoleTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Role + * @var \Magento\Authorization\Model\Role */ protected $_model = null; protected function setUp() { - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); - } - - public function testGetUsersCollection() - { - $this->assertInstanceOf( - 'Magento\User\Model\Resource\Role\User\Collection', - $this->_model->getUsersCollection() - ); + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Authorization\Model\Role'); } public function testGetRoleUsers() diff --git a/dev/tests/integration/testsuite/Magento/User/Model/RulesTest.php b/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/User/Model/RulesTest.php rename to dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.php index fd6271449ae..758127827fc 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/RulesTest.php +++ b/dev/tests/integration/testsuite/Magento/Authorization/Model/RulesTest.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\User\Model; +namespace Magento\Authorization\Model; /** * @magentoAppArea adminhtml @@ -29,14 +29,14 @@ namespace Magento\User\Model; class RulesTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Rules + * @var \Magento\Authorization\Model\Rules */ protected $_model; protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Rules' + 'Magento\Authorization\Model\Rules' ); } @@ -67,7 +67,7 @@ class RulesTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\User\Model\Rules::saveRel + * @covers \Magento\Authorization\Model\Rules::saveRel * @magentoDbIsolation enabled */ public function testSetAllowForAllResources() diff --git a/dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test.php b/dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test.php deleted file mode 100644 index 5b8bad590ed..00000000000 --- a/dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test.php +++ /dev/null @@ -1,236 +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\Authz\Service; - -use Magento\Authz\Service\AuthorizationV1Test\UserLocatorStub; -use Magento\Authz\Model\UserIdentifier; - -/** - * Authorization service test. - */ -class AuthorizationV1Test extends \PHPUnit_Framework_TestCase -{ - /** @var AuthorizationV1 */ - protected $_service; - - protected function setUp() - { - parent::setUp(); - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $loggerMock = $this->getMockBuilder('Magento\\Framework\\Logger')->disableOriginalConstructor()->getMock(); - $loggerMock->expects($this->any())->method('logException')->will($this->returnSelf()); - $this->_service = $objectManager->create( - 'Magento\\Authz\\Service\\AuthorizationV1', - array( - 'userIdentifier' => $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION), - 'logger' => $loggerMock - ) - ); - } - - /** - * @param string $userType - * @param string[] $resources - * @magentoDbIsolation enabled - * @dataProvider basicAuthFlowProvider - */ - public function testBasicAuthFlow($userType, $resources) - { - $userIdentifier = $this->_createUserIdentifier($userType); - - /** Preconditions check */ - $this->_ensurePermissionsAreNotGranted($userIdentifier, $resources); - - $this->_service->grantPermissions($userIdentifier, $resources); - - /** Validate that access to the specified resources is granted */ - $this->_ensurePermissionsAreGranted($userIdentifier, $resources); - } - - public function basicAuthFlowProvider() - { - return array( - 'integration' => array( - 'userType' => UserIdentifier::USER_TYPE_INTEGRATION, - 'resources' => array('Magento_Sales::create', 'Magento_Cms::page', 'Magento_Adminhtml::dashboard') - ) - ); - } - - /** - * @param string $userType - * @param string[] $initialResources - * @param string[] $newResources - * @magentoDbIsolation enabled - * @dataProvider changePermissionsProvider - */ - public function testChangePermissions($userType, $initialResources, $newResources) - { - $userIdentifier = $this->_createUserIdentifier($userType); - - $this->_service->grantPermissions($userIdentifier, $initialResources); - /** Preconditions check */ - $this->_ensurePermissionsAreGranted($userIdentifier, $initialResources); - $this->_ensurePermissionsAreNotGranted($userIdentifier, $newResources); - - $this->_service->grantPermissions($userIdentifier, $newResources); - - /** Check the results of permissions change */ - $this->_ensurePermissionsAreGranted($userIdentifier, $newResources); - $this->_ensurePermissionsAreNotGranted($userIdentifier, $initialResources); - } - - public function changePermissionsProvider() - { - return array( - 'integration' => array( - 'userType' => UserIdentifier::USER_TYPE_INTEGRATION, - 'initialResources' => array('Magento_Cms::page', 'Magento_Adminhtml::dashboard'), - 'newResources' => array('Magento_Sales::cancel', 'Magento_Cms::page_delete') - ), - 'integration clear permissions' => array( - 'userType' => UserIdentifier::USER_TYPE_INTEGRATION, - 'initialResources' => array('Magento_Sales::capture', 'Magento_Cms::page_delete'), - 'newResources' => array() - ) - ); - } - - /** - * @magentoDbIsolation enabled - */ - public function testIsAllowedArrayOfResources() - { - $userIdentifier = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION); - $resources = array('Magento_Cms::page', 'Magento_Adminhtml::dashboard'); - $this->_service->grantPermissions($userIdentifier, $resources); - /** Preconditions check */ - $this->_ensurePermissionsAreGranted($userIdentifier, $resources); - - /** Ensure that permissions check to multiple resources at once works as expected */ - $this->assertTrue( - $this->_service->isAllowed($resources, $userIdentifier), - 'Access to multiple resources is expected to be granted, but is prohibited.' - ); - $this->assertFalse( - $this->_service->isAllowed(array_merge($resources, array('invalid_resource')), $userIdentifier), - 'Access is expected to be denied when at least one of the resources is unavailable.' - ); - } - - /** - * @magentoDbIsolation enabled - */ - public function testGetAllowedResources() - { - $userIdentifierA = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION); - $resourcesA = array('Magento_Adminhtml::dashboard', 'Magento_Cms::page'); - $this->_service->grantPermissions($userIdentifierA, $resourcesA); - - $userIdentifierB = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION); - $resourcesB = array('Magento_Cms::block', 'Magento_Sales::cancel'); - $this->_service->grantPermissions($userIdentifierB, $resourcesB); - - /** Preconditions check */ - $this->_ensurePermissionsAreGranted($userIdentifierA, $resourcesA); - $this->_ensurePermissionsAreGranted($userIdentifierB, $resourcesB); - - $this->assertEquals( - $resourcesA, - $this->_service->getAllowedResources($userIdentifierA), - "The list of resources allowed to the user is invalid." - ); - - $this->assertEquals( - $resourcesB, - $this->_service->getAllowedResources($userIdentifierB), - "The list of resources allowed to the user is invalid." - ); - } - - /** - * @expectedException \Magento\Framework\Exception\AuthorizationException - * @expectedMessage The role associated with the specified user cannot be found. - */ - public function testGetAllowedResourcesRoleNotFound() - { - $userIdentifier = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION); - $this->_service->getAllowedResources($userIdentifier); - } - - /** - * @magentoDbIsolation enabled - */ - public function testGrantAllPermissions() - { - $userIdentifier = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION); - $this->_service->grantAllPermissions($userIdentifier); - $this->_ensurePermissionsAreGranted($userIdentifier, array('Magento_Adminhtml::all')); - } - - /** - * Create new User identifier - * - * @param string $userType - * @return UserIdentifier - */ - protected function _createUserIdentifier($userType) - { - $userId = $userType == UserIdentifier::USER_TYPE_GUEST ? 0 : rand(1, 1000); - $userLocatorStub = new UserLocatorStub(); - return new UserIdentifier($userLocatorStub, $userType, $userId); - } - - /** - * Check if user has access to the specified resources. - * - * @param UserIdentifier $userIdentifier - * @param string[] $resources - */ - protected function _ensurePermissionsAreGranted($userIdentifier, $resources) - { - foreach ($resources as $resource) { - $this->assertTrue( - $this->_service->isAllowed($resource, $userIdentifier), - "Access to resource '{$resource}' is prohibited while it is expected to be granted." - ); - } - } - - /** - * Check if access to the specified resources is prohibited to the user. - * - * @param UserIdentifier $userIdentifier - * @param string[] $resources - */ - protected function _ensurePermissionsAreNotGranted($userIdentifier, $resources) - { - foreach ($resources as $resource) { - $this->assertFalse( - $this->_service->isAllowed($resource, $userIdentifier), - "Access to resource '{$resource}' is expected to be prohibited." - ); - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/product.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/product.php index 79c74e8898b..2c0ef102cac 100644 --- a/dev/tests/integration/testsuite/Magento/Bundle/_files/product.php +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/product.php @@ -48,10 +48,17 @@ $product->setTypeId( )->setStatus( \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED )->setStockData( - array('use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1) + ['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1] )->setBundleOptionsData( - array(array('title' => 'Bundle Product Items', 'type' => 'select', 'required' => 1, 'delete' => '')) + [ + [ + 'title' => 'Bundle Product Items', + 'default_title' => 'Bundle Product Items', + 'type' => 'select', 'required' => 1, + 'delete' => '' + ] + ] )->setBundleSelectionsData( - array(array(array('product_id' => 1, 'selection_qty' => 1, 'selection_can_change_qty' => 1, 'delete' => ''))) + [[['product_id' => 1, 'selection_qty' => 1, 'selection_can_change_qty' => 1, 'delete' => '']]] // fixture product )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php new file mode 100644 index 00000000000..c1fa064c728 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.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\Catalog\Model\Resource\Product\Link\Product; + +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Resource\Product\Collection + */ + protected $collection; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Product\Link\Product\Collection' + ); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/products_crosssell.php + */ + public function testAddLinkAttributeToFilterWithResults() + { + $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $link = $om->get('\Magento\Catalog\Model\Product\Link')->useCrossSellLinks(); + $this->collection->setLinkModel($link); + $this->collection->addLinkAttributeToFilter('position', array('from' => 0, 'to' => 2)); + $product = $om->get('Magento\Catalog\Model\Product')->load(2); + $this->collection->setProduct($product); + $this->collection->load(); + $this->assertCount(1, $this->collection->getItems()); + foreach ($this->collection as $item) { + $this->assertGreaterThan(0, $item->getPosition()); + $this->assertLessThan(2, $item->getPosition()); + } + + } + + /** + * @magentoDataFixture Magento/Catalog/_files/products_crosssell.php + */ + public function testAddLinkAttributeToFilterNoResults() + { + $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $link = $om->get('\Magento\Catalog\Model\Product\Link')->useCrossSellLinks(); + $this->collection->setLinkModel($link); + $this->collection->addLinkAttributeToFilter('position', array('from' => 2, 'to' => 3)); + $product = $om->get('Magento\Catalog\Model\Product')->load(2); + $this->collection->setProduct($product); + $this->collection->load(); + $this->assertCount(0, $this->collection->getItems()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/OptionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/OptionTest.php new file mode 100644 index 00000000000..73a93e14abb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Product/OptionTest.php @@ -0,0 +1,214 @@ +<?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\Resource\Product; + +class OptionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Resource\Product + */ + protected $productResource; + + /** + * @var \Magento\Framework\Registry + */ + protected $registry; + + protected function setUp() + { + /** @var \Magento\Catalog\Model\Resource\Product $productResource */ + $this->productResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Catalog\Model\Resource\Product' + ); + } + + + /** + * Data provider for testSaveTitle + * + * @return array + */ + public function saveTitleDataProvider() + { + return [ + [ + [ + [ + 'is_delete' => NULL, + 'previous_type' => 'drop_down', + 'previous_group' => 'select', + 'sort_order' => '0', + 'title' => 'custom option view', + 'type' => 'drop_down', + 'is_require' => '1', + 'values' => [ + [ + 'sort_order' => '0', + 'option_type_id' => '-1', + 'is_delete' => NULL, + 'title' => '1 custom option title second view', + 'price' => '10.00', + 'price_type' => 'fixed', + 'sku' => NULL, + ], + ], + ], + ], + 2, + false, + ], + [ + [ + [ + 'is_delete' => NULL, + 'previous_type' => 'drop_down', + 'previous_group' => 'select', + 'sort_order' => '0', + 'title' => 'custom option view', + 'type' => 'drop_down', + 'is_require' => '1', + 'values' => [ + [ + 'sort_order' => '0', + 'option_type_id' => '-1', + 'is_delete' => NULL, + 'title' => '2 custom option title', + 'price' => '10.00', + 'price_type' => 'fixed', + 'sku' => NULL, + ], + ], + ], + ], + \Magento\Store\Model\Store::DEFAULT_STORE_ID, + true, + ], + ]; + } + + /** + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Store/_files/second_store.php + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * @dataProvider saveTitleDataProvider + */ + public function testSaveTitle($options, $storeId, $result) + { + $productId = 1; + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store->load('fixture_second_store'); + + $title = $options[0]['values'][0]['title']; + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + '\Magento\Catalog\Model\Product' + ); + $product->load($productId); + $product->setStoreIds(array($storeId)); + $product->setProductOptions($options); + $product->setCanSaveCustomOptions(true); + $product->save(); + + $typeTitle = $this->productResource->getTable('catalog_product_option_type_title'); + $typeValue = $this->productResource->getTable('catalog_product_option_type_value'); + $typeOption = $this->productResource->getTable('catalog_product_option'); + + $select = $this->productResource->getReadConnection()->select()->from( + ['t' => $typeTitle], + ['title'] + )->join( + ['ov' => $typeValue], + 't.option_type_id = ov.option_type_id' + )->join( + ['o' => $typeOption], + 'ov.option_id = o.option_id' + )->where( + 'o.product_id = ?', + $productId + )->where( + 't.store_id = ?', + $storeId + )->where( + 't.title = ?', + $title + ); + + $testResult = $this->productResource->getReadConnection()->fetchOne($select); + $this->assertEquals($result, (bool)$testResult); + } + + /** + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Store/_files/second_store.php + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * @dataProvider saveTitleDataProvider + */ + public function testSavePrice($options, $storeId, $result) + { + $productId = 1; + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); + $store->load('fixture_second_store'); + + $price = $options[0]['values'][0]['price']; + $priceType = $options[0]['values'][0]['price_type']; + $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + '\Magento\Catalog\Model\Product' + ); + $product->load($productId); + $product->setStoreIds(array($storeId)); + $product->setProductOptions($options); + $product->setCanSaveCustomOptions(true); + $product->save(); + + $typePrice = $this->productResource->getTable('catalog_product_option_type_price'); + $typeValue = $this->productResource->getTable('catalog_product_option_type_value'); + $typeOption = $this->productResource->getTable('catalog_product_option'); + + $select = $this->productResource->getReadConnection()->select()->from( + ['p' => $typePrice], + ['price', 'price_type'] + )->join( + ['ov' => $typeValue], + 'p.option_type_id = ov.option_type_id' + )->join( + ['o' => $typeOption], + 'ov.option_id = o.option_id' + )->where( + 'o.product_id = ?', + $productId + )->where( + 'p.store_id = ?', + $storeId + )->where( + 'p.price = ?', + $price + )->where( + 'p.price_type = ?', + $priceType + ); + + $testResult = $this->productResource->getReadConnection()->fetchOne($select); + $this->assertEquals($result, (bool)$testResult); + } + +} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 02c95f874ab..7b3cc4b2839 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -401,8 +401,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** Execute SUT */ $result = $this->_model->saveBilling($customerData, $customerAddressId); $validationErrors = array( - '"First Name" is a required value.', - '"First Name" length must be equal or greater than 1 characters.' + '"First Name" is a required value.' ); $this->assertEquals( array('error' => 1, 'message' => $validationErrors), diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address.php index 4ac5510041d..77a38ad0058 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address.php @@ -34,7 +34,7 @@ $quoteShippingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManage $addressService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Customer\Service\V1\CustomerAddressServiceInterface' ); -$quoteShippingAddress->importCustomerAddressData($addressService->getAddressById(1)); +$quoteShippingAddress->importCustomerAddressData($addressService->getAddress(1)); /** @var \Magento\Sales\Model\Quote $quote */ $quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote'); @@ -54,6 +54,10 @@ $quote->setStoreId( $customer->getMode() )->setPasswordHash( $customer->encryptPassword($customer->getPassword()) +)->setReservedOrderId( + 'test_order_1' +)->setEmail( + 'aaa@aaa.com' )->addProduct( $product->load($product->getId()), 2 diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_saved_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_saved_rollback.php new file mode 100644 index 00000000000..2752260a727 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_saved_rollback.php @@ -0,0 +1,30 @@ +<?php +/** + * Rollback for quote_with_address_saved.php fixture. + * + * 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) + */ + +/** @var $objectManager \Magento\TestFramework\ObjectManager */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$quote = $objectManager->create('\Magento\Sales\Model\Quote'); +$quote->load('test_order_1', 'reserved_order_id')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address.php new file mode 100644 index 00000000000..78d04202118 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address.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) + */ +require __DIR__ . '/../../Customer/_files/customer.php'; +require __DIR__ . '/../../Customer/_files/customer_address.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_virtual.php'; + +/** @var \Magento\Sales\Model\Quote\Address $quoteShippingAddress */ +$quoteShippingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Sales\Model\Quote\Address' +); +/** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService */ +$addressService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Customer\Service\V1\CustomerAddressServiceInterface' +); +$quoteShippingAddress->importCustomerAddressData($addressService->getAddress(1)); + +/** @var \Magento\Sales\Model\Quote $quote */ +$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote'); +$quote->setStoreId( + 1 + )->setIsActive( + false + )->setIsMultiShipping( + false + )->assignCustomerWithAddressChange( + $customer + )->setShippingAddress( + $quoteShippingAddress + )->setBillingAddress( + $quoteShippingAddress + )->setCheckoutMethod( + $customer->getMode() + )->setPasswordHash( + $customer->encryptPassword($customer->getPassword()) + )->setReservedOrderId( + 'test_order_with_virtual_product' + )->setEmail( + 'store@example.com' + )->addProduct( + $product->load($product->getId()), + 1 + ); + +$quote->collectTotals()->save(); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address_rollback.php new file mode 100644 index 00000000000..caae33683a1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_virtual_product_and_address_rollback.php @@ -0,0 +1,29 @@ +<?php +/** + * Rollback for quote_with_virtual_product_and_address.php fixture. + * + * 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) + */ +/** @var $objectManager \Magento\TestFramework\ObjectManager */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$quote = $objectManager->create('\Magento\Sales\Model\Quote'); +$quote->load('test_order_with_virtual_product', 'reserved_order_id')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index e6087009180..324101bbcbf 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -1023,11 +1023,8 @@ class IndexTest extends \Magento\Backend\Utility\Controller $this->assertContains('{"error":1,"html_message":', $body); $this->assertContains('Please correct this email address: \"*\".', $body); $this->assertContains('\"First Name\" is a required value.', $body); - $this->assertContains('\"First Name\" length must be equal or greater than 1 characters', $body); $this->assertContains('\"Last Name\" is a required value.', $body); - $this->assertContains('\"Last Name\" length must be equal or greater than 1 characters', $body); $this->assertContains('\"Telephone\" is a required value.', $body); - $this->assertContains('\"Telephone\" length must be equal or greater than 1 characters', $body); $this->assertContains('\"Country\" is a required value.', $body); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_non_default_website_id_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_non_default_website_id_rollback.php new file mode 100644 index 00000000000..8ba99e672e1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_non_default_website_id_rollback.php @@ -0,0 +1,39 @@ +<?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) + */ +include __DIR__ . '/customer_rollback.php'; + +/** @var \Magento\Framework\Registry $registry */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var $website Magento\Store\Model\Website */ +$website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Website'); +$website->load('newwebsite', 'code'); +if ($website->getId()) { + $website->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.4-1.6.1.5.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_rollback.php similarity index 62% rename from app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.4-1.6.1.5.php rename to dev/tests/integration/testsuite/Magento/Customer/_files/customer_rollback.php index 19c515ace76..78ce1428d83 100644 --- a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.4-1.6.1.5.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_rollback.php @@ -22,16 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Framework\Module\Setup */ -$installer = $this; -$installer->startSetup(); +/** @var \Magento\Framework\Registry $registry */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); -$tableName = $installer->getTable('admin_rule'); - -if ($tableName) { - /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ - $connection = $installer->getConnection(); - $connection->delete($tableName, array('resource_id = ?' => 'Magento_Oauth::oauth')); +/** @var $customer \Magento\Customer\Model\Customer*/ +$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Customer'); +$customer->load(1); +if ($customer->getId()) { + $customer->delete(); } -$installer->endSetup(); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_downloadable_product.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_downloadable_product.php index 0c9dcb70629..9a582e4f76a 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_downloadable_product.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_downloadable_product.php @@ -55,7 +55,8 @@ $orderItem->setProductId( ); $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); -$order->addItem( +$order->setCustomerEmail('mail@to.co') + ->addItem( $orderItem )->setIncrementId( '100000001' diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceInterceptor.php b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceInterceptor.php index b02a75c925b..b649edb4a6d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceInterceptor.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Code/_expected/SourceClassWithNamespaceInterceptor.php @@ -70,7 +70,7 @@ class Interceptor extends \Magento\Framework\Code\GeneratorTest\SourceClassWithN public function __sleep() { if (method_exists(get_parent_class($this), '__sleep')) { - return parent::__sleep(); + return array_diff(parent::__sleep(), array('pluginLocator', 'pluginList', 'chain', 'subjectType')); } else { return array_keys(get_class_vars(get_parent_class($this))); } 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 new file mode 100644 index 00000000000..d4f1d813597 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.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) + */ +namespace Magento\Framework\Search\Request\Config; + +class ConverterTest extends \PHPUnit_Framework_TestCase +{ + /** @var Converter */ + protected $object; + + protected function setUp() + { + $this->object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Framework\Search\Request\Config\Converter'); + } + + public function testConvert() + { + $document = new \DOMDocument(); + $document->load(__DIR__ . '../../../_files/search_request.xml'); + $result = $this->object->convert($document); + $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 new file mode 100644 index 00000000000..6a0e2c08cfb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.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) + */ +namespace Magento\Framework\Search\Request; + +class MapperTest extends \PHPUnit_Framework_TestCase +{ + public function testGet() + { + $config = include __DIR__ . '/../_files/search_request_config.php'; + $request = reset($config); + $mapper = $this->object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create( + '\Magento\Framework\Search\Request\Mapper', + [ + 'queries' => $request['queries'], + 'filters' => $request['filters'], + ] + ); + $this->assertInstanceOf( + '\Magento\Framework\Search\Request\QueryInterface', + $mapper->get('suggested_search_container') + ); + } +} \ No newline at end of file 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 new file mode 100644 index 00000000000..e98914a49b9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml @@ -0,0 +1,58 @@ +<?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) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="suggested_search_container" index="product"> + <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%" /> + </query> + + <query xsi:type="filteredQuery" name="fulltext_search_query2"> + <filterReference ref="promoted" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="promoted"> + <filterReference clause="must" ref="price_name" /> + <filterReference clause="should" ref="price_name1" /> + </filter> + <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> + <from>10</from> + <size>10</size> + </request> +</requests> \ No newline at end of file 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 new file mode 100644 index 00000000000..c63f48f3df7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.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) + */ +return [ + "suggested_search_container" => [ + "queries" => [ + "suggested_search_container" => [ + "name" => "suggested_search_container", + "boost" => "2", + "queryReference" => [ + [ + "clause" => "must", + "ref" => "fulltext_search_query" + ], + [ + "clause" => "should", + "ref" => "fulltext_search_query2" + ] + ], + "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", + "match" => [ + [ + "field" => "title", + "value" => "\$request.title", + "boost" => "2" + ], + [ + "field" => "description", + "value" => "%request.description%" + ] + ], + "type" => "matchQuery" + ], + "fulltext_search_query2" => [ + "name" => "fulltext_search_query2", + "filterReference" => [ + [ + "ref" => "promoted" + ] + ], + "type" => "filteredQuery" + ] + ], + "filters" => [ + "promoted" => [ + "name" => "promoted", + "filterReference" => [ + [ + "clause" => "must", + "ref" => "price_name" + ], + [ + "clause" => "should", + "ref" => "price_name1" + ] + ], + "type" => "boolFilter" + ], + "price_name" => [ + "field" => "promoted_boost", + "name" => "price_name", + "from" => "10", + "to" => "100", + "type" => "rangeFilter" + ], + "price_name1" => [ + "name" => "price_name1", + "field" => "price_name", + "value" => "\$name", + "type" => "termFilter" + ] + ], + "from" => "10", + "size" => "10", + "query" => "suggested_search_container", + "index" => "product" + ] +]; \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php index 448451aba61..562b23072a9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -37,6 +37,8 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { + ini_set('session.use_only_cookies', '0'); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Framework\Session\SidResolverInterface $sidResolver */ @@ -56,6 +58,13 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase ); } + public function testSessionUseOnlyCookies() + { + $expectedValue = '1'; + $sessionUseOnlyCookies = ini_get('session.use_only_cookies'); + $this->assertSame($expectedValue, $sessionUseOnlyCookies); + } + public function testGetData() { $this->_model->setData(array('test_key' => 'test_value')); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php new file mode 100644 index 00000000000..aa72cde5eec --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -0,0 +1,232 @@ +<?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\Cookie; + +use Magento\Framework\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test CookieScope + * + */ +class CookieScopeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ObjectManager + */ + private $objectManager; + + public function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + } + + public function testGetSensitiveCookieMetadataEmpty() + { + $cookieScope = $this->createCookieScope(); + + $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + } + + public function testGetPublicCookieMetadataEmpty() + { + $cookieScope = $this->createCookieScope(); + + $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); + } + + public function testGetSensitiveCookieMetadataDefaults() + { + $defaultValues = [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $sensitive = $this->createSensitiveMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => $sensitive, + 'publicCookieMetadata' => null, + 'cookieMetadata' => null + ] + ); + $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + } + + public function testGetPublicCookieMetadataDefaults() + { + $defaultValues = [ + PublicCookieMetadata::KEY_PATH => 'default path', + PublicCookieMetadata::KEY_DOMAIN => 'default domain', + PublicCookieMetadata::KEY_DURATION => 'default duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'default http', + PublicCookieMetadata::KEY_SECURE => 'default secure', + ]; + $public = $this->createPublicMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'publicCookieMetadata' => $public, + ] + ); + + $this->assertEquals($defaultValues, $cookieScope->getPublicCookieMetadata()->__toArray()); + } + + public function testGetCookieMetadataDefaults() + { + $defaultValues = [ + CookieMetadata::KEY_PATH => 'default path', + CookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $cookieMetadata = $this->createCookieMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'deleteCookieMetadata' => $cookieMetadata + ] + ); + $this->assertEquals($defaultValues, $cookieScope->getCookieMetadata()->__toArray()); + } + + public function testGetSensitiveCookieMetadataOverrides() + { + $defaultValues = [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $overrideValues = [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + ]; + $sensitive = $this->createSensitiveMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => $sensitive, + ] + ); + $override = $this->createSensitiveMetadata($overrideValues); + $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + } + + public function testGetPublicCookieMetadataOverrides() + { + $defaultValues = [ + PublicCookieMetadata::KEY_PATH => 'default path', + PublicCookieMetadata::KEY_DOMAIN => 'default domain', + PublicCookieMetadata::KEY_DURATION => 'default duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'default http', + PublicCookieMetadata::KEY_SECURE => 'default secure', + ]; + $overrideValues = [ + PublicCookieMetadata::KEY_PATH => 'override path', + PublicCookieMetadata::KEY_DOMAIN => 'override domain', + PublicCookieMetadata::KEY_DURATION => 'override duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'override http', + PublicCookieMetadata::KEY_SECURE => 'override secure', + ]; + $public = $this->createPublicMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'publicCookieMetadata' => $public, + ] + ); + $override = $this->createPublicMetadata($overrideValues); + + $this->assertEquals($overrideValues, $cookieScope->getPublicCookieMetadata($override)->__toArray()); + } + + public function testGetCookieMetadataOverrides() + { + $defaultValues = [ + CookieMetadata::KEY_PATH => 'default path', + CookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $overrideValues = [ + CookieMetadata::KEY_PATH => 'override path', + CookieMetadata::KEY_DOMAIN => 'override domain', + ]; + $deleteCookieMetadata = $this->createCookieMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'deleteCookieMetadata' => $deleteCookieMetadata + ] + ); + $override = $this->createCookieMetadata($overrideValues); + $this->assertEquals($overrideValues, $cookieScope->getCookieMetadata($override)->__toArray()); + } + + /** + * Creates a CookieScope object with the given parameters. + * + * @param array $params + * @return CookieScope + */ + protected function createCookieScope($params = []) + { + return $this->objectManager->create('Magento\Framework\Stdlib\Cookie\CookieScope', $params); + } + + /** + * Creates a SensitiveCookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return SensitiveCookieMetadata + */ + protected function createSensitiveMetadata($metadata = []) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates a PublicCookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return PublicCookieMetadata + */ + protected function createPublicMetadata($metadata = []) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates a CookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return CookieMetadata + */ + protected function createCookieMetadata($metadata = []) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\CookieMetadata', + ['metadata' => $metadata] + ); + } + +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php new file mode 100644 index 00000000000..703796cb68a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.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\Framework\Stdlib\Cookie; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test PhpCookieManager + * + */ +class PhpCookieManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * Object Manager + * + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + /** + * Cookie Manager + * + * @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager + */ + protected $cookieManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->cookieManager = $this->objectManager->create('Magento\Framework\Stdlib\Cookie\PhpCookieManager'); + } + + public function testGetCookie() + { + $cookieName = 'cookie name'; + $cookieValue = 'cookie value'; + $defaultCookieValue = 'default'; + $_COOKIE[$cookieName] = $cookieValue; + $this->assertEquals( + $defaultCookieValue, + $this->cookieManager->getCookie('unknown cookieName', $defaultCookieValue) + ); + $this->assertEquals($cookieValue, $this->cookieManager->getCookie($cookieName, $defaultCookieValue)); + $this->assertEquals($defaultCookieValue, $this->cookieManager->getCookie(null, $defaultCookieValue)); + $this->assertNull($this->cookieManager->getCookie(null)); + } + + /** + * It is not possible to write integration tests for CookieManager::setSensitiveCookie(). + * PHPUnit the following error when calling the function: + * + * PHPUnit_Framework_Error_Warning : Cannot modify header information - headers already sent + */ + public function testSetSensitiveCookie() + { + } + + /** + * It is not possible to write integration tests for CookieManager::setSensitiveCookie(). + * PHPUnit the following error when calling the function: + * + * PHPUnit_Framework_Error_Warning : Cannot modify header information - headers already sent + */ + public function testSetPublicCookie() + { + } + + /** + * It is not possible to write integration tests for CookieManager::deleteCookie(). + * PHPUnit the following error when calling the function: + * + * PHPUnit_Framework_Error_Warning : Cannot modify header information - headers already sent + */ + public function testDeleteCookie() + { + } +} diff --git a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php index e06738689f4..854aff32a16 100644 --- a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php +++ b/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php @@ -123,7 +123,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $user->getPassword(), 'Original password should not be stored/loaded as is for security reasons.' ); - $this->assertInstanceOf('Magento\User\Model\Role', $user->getRole()); + $this->assertInstanceOf('Magento\Authorization\Model\Role', $user->getRole()); $this->assertEquals(1, $user->getRole()->getId(), 'User has to have admin privileges.'); } diff --git a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php index a9b1342e2eb..07a25b9692f 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -130,14 +130,8 @@ class IntegrationTest extends \Magento\Backend\Utility\Controller $this->_integration = $factory->create()->setName(md5(rand()))->save(); /** Grant permissions to integrations */ - /** @var \Magento\Authz\Model\UserIdentifier\Factory $userIdentifierFactory */ - $userIdentifierFactory = $objectManager->create('Magento\Authz\Model\UserIdentifier\Factory'); - /** @var \Magento\Authz\Service\AuthorizationV1 $authzService */ - $userIdentifier = $userIdentifierFactory->create( - \Magento\Authz\Model\UserIdentifier::USER_TYPE_INTEGRATION, - $this->_integration->getId() - ); - $authzService = $objectManager->create('Magento\Authz\Service\AuthorizationV1'); - $authzService->grantAllPermissions($userIdentifier); + /** @var \Magento\Integration\Service\V1\AuthorizationService $authorizationService */ + $authorizationService = $objectManager->create('Magento\Integration\Service\V1\AuthorizationService'); + $authorizationService->grantAllPermissions($this->_integration->getId()); } } diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php new file mode 100644 index 00000000000..682fd0df059 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.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\Integration\Service\V1; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Integration authorization service test. + */ +class AuthorizationServiceTest extends \PHPUnit_Framework_TestCase +{ + /** @var AuthorizationService */ + protected $_service; + + /** @var \Magento\Framework\Authorization */ + protected $libAuthorization; + + /** @var \Magento\Authorization\Model\UserContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $userContextMock; + + protected function setUp() + { + parent::setUp(); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $loggerMock = $this->getMockBuilder('Magento\\Framework\\Logger')->disableOriginalConstructor()->getMock(); + $loggerMock->expects($this->any())->method('logException')->will($this->returnSelf()); + $this->_service = $objectManager->create( + 'Magento\Integration\Service\V1\AuthorizationService', + array( + 'logger' => $loggerMock + ) + ); + + $this->userContextMock = $this->getMockForAbstractClass('Magento\Authorization\Model\UserContextInterface'); + $this->userContextMock + ->expects($this->any()) + ->method('getUserType') + ->will($this->returnValue(UserContextInterface::USER_TYPE_INTEGRATION)); + $roleLocator = $objectManager->create( + 'Magento\Webapi\Model\WebapiRoleLocator', + ['userContext' => $this->userContextMock] + ); + $this->libAuthorization = $objectManager->create( + 'Magento\Framework\Authorization', + ['roleLocator' => $roleLocator] + ); + } + + /** + * @magentoDbIsolation enabled + */ + public function testGrantPermissions() + { + $integrationId = rand(1, 1000); + $resources = array('Magento_Sales::create', 'Magento_Cms::page', 'Magento_Adminhtml::dashboard'); + /** Preconditions check */ + $this->_ensurePermissionsAreNotGranted($integrationId, $resources); + + $this->_service->grantPermissions($integrationId, $resources); + + /** Validate that access to the specified resources is granted */ + $this->_ensurePermissionsAreGranted($integrationId, $resources); + } + + /** + * @param int $integrationId + * @param string[] $initialResources + * @param string[] $newResources + * @magentoDbIsolation enabled + * @dataProvider changePermissionsProvider + */ + public function testChangePermissions($integrationId, $initialResources, $newResources) + { + $this->_service->grantPermissions($integrationId, $initialResources); + /** Preconditions check */ + $this->_ensurePermissionsAreGranted($integrationId, $initialResources); + $this->_ensurePermissionsAreNotGranted($integrationId, $newResources); + + $this->_service->grantPermissions($integrationId, $newResources); + + /** Check the results of permissions change */ + $this->_ensurePermissionsAreGranted($integrationId, $newResources); + $this->_ensurePermissionsAreNotGranted($integrationId, $initialResources); + } + + public function changePermissionsProvider() + { + return array( + 'integration' => array( + 'integrationId' => rand(1, 1000), + 'initialResources' => array('Magento_Cms::page', 'Magento_Adminhtml::dashboard'), + 'newResources' => array('Magento_Sales::cancel', 'Magento_Cms::page_delete') + ), + 'integration clear permissions' => array( + 'integrationId' => rand(1, 1000), + 'initialResources' => array('Magento_Sales::capture', 'Magento_Cms::page_delete'), + 'newResources' => array() + ) + ); + } + + /** + * @magentoDbIsolation enabled + */ + public function testGrantAllPermissions() + { + $integrationId = rand(1, 1000); + $this->_service->grantAllPermissions($integrationId); + $this->_ensurePermissionsAreGranted($integrationId, array('Magento_Adminhtml::all')); + } + + /** + * Check if user has access to the specified resources. + * + * @param int $integrationId + * @param string[] $resources + */ + protected function _ensurePermissionsAreGranted($integrationId, $resources) + { + $this->userContextMock + ->expects($this->any()) + ->method('getUserId') + ->will($this->returnValue($integrationId)); + foreach ($resources as $resource) { + $this->assertTrue( + $this->libAuthorization->isAllowed($resource), + "Access to resource '{$resource}' is prohibited while it is expected to be granted." + ); + } + } + + /** + * Check if access to the specified resources is prohibited to the user. + * + * @param int $integrationId + * @param string[] $resources + */ + protected function _ensurePermissionsAreNotGranted($integrationId, $resources) + { + $this->userContextMock + ->expects($this->any()) + ->method('getUserId') + ->will($this->returnValue($integrationId)); + foreach ($resources as $resource) { + $this->assertFalse( + $this->libAuthorization->isAllowed($resource), + "Access to resource '{$resource}' is expected to be prohibited." + ); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php new file mode 100644 index 00000000000..d92a18de977 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.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\Integration\Service\V1; + +use Magento\Customer\Service\V1\CustomerAccountService; +use Magento\Framework\Exception\InputException; +use Magento\Integration\Model\Oauth\Token as TokenModel; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\User\Model\User as UserModel; + +/** + * Test class for \Magento\Integration\Service\V1\TokenService. + */ +class TokenServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var TokenServiceInterface + */ + private $tokenService; + + /** + * @var CustomerAccountService + */ + private $customerAccountService; + + /** + * @var TokenModel + */ + private $tokenModel; + + /** + * @var UserModel + */ + private $userModel; + + /** + * Setup TokenService + */ + public function setUp() + { + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + $this->customerAccountService = Bootstrap::getObjectManager()->get( + 'Magento\Customer\Service\V1\CustomerAccountService' + ); + $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); + $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testCreateCustomerAccessToken() + { + $customerUserName = 'customer@example.com'; + $password = 'password'; + $accessToken = $this->tokenService->createCustomerAccessToken($customerUserName, $password); + $customerData = $this->customerAccountService->authenticate($customerUserName, $password); + /** @var $token TokenModel */ + $token = $this->tokenModel->loadByCustomerId($customerData->getId())->getToken(); + $this->assertEquals($accessToken, $token); + } + + /** + * @dataProvider validationDataProvider + */ + public function testCreateCustomerAccessTokenEmptyOrNullCredentials($username, $password) + { + try { + $this->tokenService->createCustomerAccessToken($username, $password); + } catch (InputException $e) { + $this->assertInputExceptionMessages($e); + } + } + + /** + * @expectedException \Magento\Framework\Exception\InvalidEmailOrPasswordException + * @expectedExceptionMessage Invalid login or password. + */ + public function testCreateCustomerAccessTokenInvalidCustomer() + { + $customerUserName = 'invalid'; + $password = 'invalid'; + $this->tokenService->createCustomerAccessToken($customerUserName, $password); + } + + /** + * @magentoDataFixture Magento/User/_files/user_with_role.php + */ + public function testCreateAdminAccessToken() + { + $adminUserNameFromFixture = 'adminUser'; + $accessToken = $this->tokenService->createAdminAccessToken( + $adminUserNameFromFixture, + \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD + ); + $adminUserId = $this->userModel->loadByUsername($adminUserNameFromFixture)->getId(); + /** @var $token TokenModel */ + $token = $this->tokenModel + ->loadByAdminId($adminUserId) + ->getToken(); + $this->assertEquals($accessToken, $token); + } + + /** + * @dataProvider validationDataProvider + */ + public function testCreateAdminAccessTokenEmptyOrNullCredentials($username, $password) + { + try { + $this->tokenService->createAdminAccessToken($username, $password); + } catch (InputException $e) { + $this->assertInputExceptionMessages($e); + } + } + + /** + * @expectedException \Magento\Framework\Exception\AuthenticationException + * @expectedExceptionMessage Please correct the user name or password. + */ + public function testCreateAdminAccessTokenInvalidCustomer() + { + $adminUserName = 'invalid'; + $password = 'invalid'; + $this->tokenService->createAdminAccessToken($adminUserName, $password); + } + + /** + * Provider to test input validation + * + * @return array + */ + public function validationDataProvider() + { + return [ + 'Check for empty credentials' => ['', ''], + 'Check for null credentials' => [null, null] + ]; + } + + /** + * Assert for presence of Input exception messages + * + * @param InputException $e + */ + private function assertInputExceptionMessages($e) + { + $this->assertEquals(InputException::DEFAULT_MESSAGE, $e->getMessage()); + $errors = $e->getErrors(); + $this->assertCount(2, $errors); + $this->assertEquals('username is a required field.', $errors[0]->getLogMessage()); + $this->assertEquals('password is a required field.', $errors[1]->getLogMessage()); + } +} + diff --git a/dev/tests/integration/testsuite/Magento/PayPalRecurringPayment/_files/recurring_payment.php b/dev/tests/integration/testsuite/Magento/PayPalRecurringPayment/_files/recurring_payment.php index 74611d6163e..a9a1c379437 100644 --- a/dev/tests/integration/testsuite/Magento/PayPalRecurringPayment/_files/recurring_payment.php +++ b/dev/tests/integration/testsuite/Magento/PayPalRecurringPayment/_files/recurring_payment.php @@ -46,7 +46,28 @@ $recurringPayment->addData( 'currency_code' => 'USD', 'order_info' => array('base_currency_code' => 'USD'), 'order_item_info' => serialize('item info'), - 'billing_address_info' => serialize('billing address info') + 'billing_address_info' => serialize([ + 'postcode' => '12345', + 'lastname' => 'Co', + 'street' => 'Street', + 'city' => 'City', + 'customer_email' => 'co@co.co', + 'telephone' => 'Telephone', + 'country_id' => 'Country', + 'firstname' => 'Co', + 'address_type' => 'billing' + ]), + 'shipping_address_info' => serialize([ + 'postcode' => '12345', + 'lastname' => 'Co', + 'street' => 'Street', + 'city' => 'City', + 'customer_email' => 'co@co.co', + 'telephone' => 'Telephone', + 'country_id' => 'Country', + 'firstname' => 'Co', + 'address_type' => 'shipping' +]) ) ); $recurringPayment->save(); diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php index 69a1f852b54..62bf4b9360b 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php @@ -84,7 +84,8 @@ class ExpressTest extends \Magento\TestFramework\TestCase\AbstractController * * Note that test does not verify communication during remote calls to PayPal. * - * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php + * @magentoDataFixture Magento/Sales/_files/quote.php + * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testStartActionCustomerToQuote() { diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowTest.php index 3d9fe3b04eb..6466e784c43 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowTest.php @@ -89,7 +89,7 @@ class PayflowTest extends \Magento\TestFramework\TestCase\AbstractController } /** - * @magentoDataFixture Magento/Paypal/_files/quote_payment_payflow.php + * @magentoDataFixture Magento/Sales/_files/order.php * @magentoConfigFixture current_store payment/paypal_payflow/active 1 * @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com */ @@ -104,7 +104,6 @@ class PayflowTest extends \Magento\TestFramework\TestCase\AbstractController $session->setQuoteId($quote->getId()); $session->setPaypalStandardQuoteId($quote->getId())->setLastRealOrderId('100000001'); $this->dispatch('paypal/payflow/cancelpayment'); - $order->load('100000001', 'increment_id'); $this->assertEquals('canceled', $order->getState()); $this->assertEquals($session->getQuote()->getGrandTotal(), $quote->getGrandTotal()); diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowadvancedTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowadvancedTest.php index 0788d288fca..0dd54ddc6ed 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowadvancedTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Controller/PayflowadvancedTest.php @@ -81,7 +81,7 @@ class PayflowadvancedTest extends \Magento\TestFramework\TestCase\AbstractContro } /** - * @magentoDataFixture Magento/Paypal/_files/quote_payment_payflow.php + * @magentoDataFixture Magento/Sales/_files/order.php * @magentoConfigFixture current_store payment/paypal_payflow/active 1 * @magentoConfigFixture current_store paypal/general/business_account merchant_2012050718_biz@example.com */ diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_express.php index 9dffb9c2ce4..5778d5058b4 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_express.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_express.php @@ -28,7 +28,6 @@ $billingAddress = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->c array('data' => $addressData) ); $billingAddress->setAddressType('billing'); - $shippingAddress = clone $billingAddress; $shippingAddress->setId(null)->setAddressType('shipping'); @@ -36,7 +35,9 @@ $payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(' $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS); $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); -$order->setIncrementId( +$order + ->setCustomerEmail('co@co.co') + ->setIncrementId( '100000001' )->setSubtotal( 100 diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_payflowpro.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_payflowpro.php index 5f584aa79bb..f89ce3ec978 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_payflowpro.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_payflowpro.php @@ -36,7 +36,8 @@ $payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(' $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_PAYFLOWPRO); $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); -$order->setIncrementId( +$order->setCustomerEmail('co@co.co') + ->setIncrementId( '100000001' )->setSubtotal( 100 diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_standard.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_standard.php index b3a0c73277a..8f92493d4cc 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/order_standard.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/order_standard.php @@ -36,7 +36,9 @@ $payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(' $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); -$order->setIncrementId( +$order + ->setCustomerEmail('co@co.co') + ->setIncrementId( '100000001' )->setSubtotal( 100 diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php index ac990dde5f7..50f11548e50 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express.php @@ -109,6 +109,8 @@ $quote->getShippingAddress()->setCollectShippingRates(true); $quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); $quote->collectTotals()->save(); +$quote->setCustomerEmail('admin@example.com'); + /** @var $service \Magento\Sales\Model\Service\Quote */ $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Sales\Model\Service\Quote', array('quote' => $quote)); diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php index 852f4ce78d9..b8a57762a80 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_standard.php @@ -117,6 +117,7 @@ $quote->getShippingAddress()->setCollectShippingRates(true); $quote->collectTotals()->save(); $quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); +$quote->setCustomerEmail('admin@example.com'); /** @var $service \Magento\Sales\Model\Service\Quote */ $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AuthorizationMock.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AuthorizationMock.php new file mode 100644 index 00000000000..56d567498f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AuthorizationMock.php @@ -0,0 +1,39 @@ +<?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; + +class AuthorizationMock extends \Magento\Framework\Authorization +{ + /** + * Check current user permission on resource and privilege + * + * @param string $resource + * @param string $privilege + * @return boolean + */ + public function isAllowed($resource, $privilege = null) + { + return $resource == 'Magento_Sales::create' ? false : parent::isAllowed($resource, $privilege); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php index d18c0c11578..ddb3f5860b0 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php @@ -209,18 +209,3 @@ class CreateTest extends \Magento\Backend\Utility\Controller $this->assertEquals('403', $this->getResponse()->getHttpResponseCode()); } } - -class AuthorizationMock extends \Magento\Framework\Authorization -{ - /** - * Check current user permission on resource and privilege - * - * @param string $resource - * @param string $privilege - * @return boolean - */ - public function isAllowed($resource, $privilege = null) - { - return $resource == 'Magento_Sales::create' ? false : parent::isAllowed($resource, $privilege); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressTest.php index c7ba7db89b6..95bde3844a7 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressTest.php @@ -50,9 +50,11 @@ class AddressTest extends \PHPUnit_Framework_TestCase ); $order->loadByIncrementId('100000001'); $this->_model->setOrder($order); - $this->_model->setCustomerAddressData($customerAddressService->getAddress(1)); + $this->_model->setData($customerAddressService->getAddress(1)->__toArray()); + $this->_model->setEmail('co@co.co'); + $this->_model->setAddressType('billing'); + $this->_model->setRegionId(1); $this->_model->save(); $this->assertEquals($order->getId(), $this->_model->getParentId()); - $this->assertEquals($this->_model->getCustomerAddressId(), 1); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php similarity index 72% rename from dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php rename to dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php index a8c1f5a041f..36179a42b36 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php @@ -21,38 +21,45 @@ * @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; +namespace Magento\Sales\Model\Order\Email\Sender; -class CreditmemoTest extends \PHPUnit_Framework_TestCase +use Magento\TestFramework\Helper\Bootstrap; + +class CreditmemoSenderTest extends \PHPUnit_Framework_TestCase { /** * @magentoDataFixture Magento/Sales/_files/order.php */ - public function testSendEmail() + public function testSend() { - \Magento\TestFramework\Helper\Bootstrap::getInstance() + Bootstrap::getInstance() ->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $order = Bootstrap::getObjectManager() ->create('Magento\Sales\Model\Order'); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('customer@example.com'); - $creditmemo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $creditmemo = Bootstrap::getObjectManager()->create( 'Magento\Sales\Model\Order\Creditmemo' ); $creditmemo->setOrder($order); $payment = $order->getPayment(); - $paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $paymentInfoBlock = Bootstrap::getObjectManager()->get( 'Magento\Payment\Helper\Data' )->getInfoBlock( - $payment - ); + $payment + ); $paymentInfoBlock->setArea('invalid-area'); $payment->setBlockMock($paymentInfoBlock); $this->assertEmpty($creditmemo->getEmailSent()); - $creditmemo->sendEmail(true); + + $creditmemoSender = Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender'); + $result = $creditmemoSender->send($creditmemo, true); + + $this->assertTrue($result); $this->assertNotEmpty($creditmemo->getEmailSent()); $this->assertEquals('frontend', $paymentInfoBlock->getArea()); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php similarity index 82% rename from dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php rename to dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php index d24dbfb2061..098dc8cea27 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/InvoiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.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\Model\Order; +namespace Magento\Sales\Model\Order\Email\Sender; -class InvoiceTest extends \PHPUnit_Framework_TestCase +class InvoiceSenderTest extends \PHPUnit_Framework_TestCase { /** * @magentoDataFixture Magento/Sales/_files/order.php */ - public function testSendEmail() + public function testSend() { \Magento\TestFramework\Helper\Bootstrap::getInstance() ->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); @@ -51,8 +51,15 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase $paymentInfoBlock->setArea('invalid-area'); $payment->setBlockMock($paymentInfoBlock); + /** @var InvoiceSender $invoiceSender */ + $invoiceSender = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order\Email\Sender\InvoiceSender'); + + $this->assertEmpty($invoice->getEmailSent()); - $invoice->sendEmail(true); + $result = $invoiceSender->send($invoice, true); + + $this->assertTrue($result); $this->assertNotEmpty($invoice->getEmailSent()); $this->assertEquals('frontend', $paymentInfoBlock->getArea()); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php similarity index 82% rename from dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php rename to dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php index fd79f19b008..9d42a96fcd1 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/OrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.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\Sales\Model\Order; +namespace Magento\Sales\Model\Order\Email\Sender; -class OrderTest extends \PHPUnit_Framework_TestCase +use Magento\TestFramework\Helper\Bootstrap; + +class OrderSenderTest extends \PHPUnit_Framework_TestCase { /** * @magentoDataFixture Magento/Sales/_files/order.php @@ -41,13 +43,19 @@ class OrderTest extends \PHPUnit_Framework_TestCase $paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Payment\Helper\Data' )->getInfoBlock( - $payment - ); + $payment + ); $paymentInfoBlock->setArea('invalid-area'); $payment->setBlockMock($paymentInfoBlock); $this->assertEmpty($order->getEmailSent()); - $order->sendNewOrderEmail(); + + $orderSender = Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order\Email\Sender\OrderSender'); + $result = $orderSender->send($order); + + $this->assertTrue($result); + $this->assertNotEmpty($order->getEmailSent()); $this->assertEquals('frontend', $paymentInfoBlock->getArea()); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php new file mode 100644 index 00000000000..a2866de33df --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php @@ -0,0 +1,99 @@ +<?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\Email\Sender; + +class ShipmentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @magentoDataFixture Magento/Sales/_files/order.php + */ + public function testSend() + { + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State') + ->setAreaCode('frontend'); + $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId('100000001'); + $order->setCustomerEmail('customer@example.com'); + + $shipment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Sales\Model\Order\Shipment' + ); + $shipment->setOrder($order); + + $payment = $order->getPayment(); + $paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Payment\Helper\Data' + )->getInfoBlock( + $payment + ); + $payment->setBlockMock($paymentInfoBlock); + + $this->assertEmpty($shipment->getEmailSent()); + + $orderSender = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order\Email\Sender\ShipmentSender'); + $result = $orderSender->send($shipment, true); + + $this->assertTrue($result); + + $this->assertNotEmpty($shipment->getEmailSent()); + $this->assertEquals('frontend', $paymentInfoBlock->getArea()); + } + + /** + * Check the correctness and stability of set/get packages of shipment + * + * @magentoDataFixture Magento/Sales/_files/order.php + */ + public function testPackages() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager->get('Magento\Framework\App\State')->setAreaCode('frontend'); + $order = $objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId('100000001'); + $order->setCustomerEmail('customer@example.com'); + + $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); + + $packages = array(array('1'), array('2')); + + $shipment->addItem($objectManager->create('Magento\Sales\Model\Order\Shipment\Item')); + $shipment->setPackages($packages); + $this->assertEquals($packages, $shipment->getPackages()); + $shipment->save(); + $shipment->save(); + $shipment->load($shipment->getId()); + $this->assertEquals($packages, $shipment->getPackages()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php index e4b2dab6f47..50b3ca08b23 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php @@ -25,36 +25,6 @@ namespace Magento\Sales\Model\Order; class ShipmentTest extends \PHPUnit_Framework_TestCase { - /** - * @magentoDataFixture Magento/Sales/_files/order.php - */ - public function testSendEmail() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State') - ->setAreaCode('frontend'); - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); - $order->loadByIncrementId('100000001'); - $order->setCustomerEmail('customer@example.com'); - - $shipment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Order\Shipment' - ); - $shipment->setOrder($order); - - $payment = $order->getPayment(); - $paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Payment\Helper\Data' - )->getInfoBlock( - $payment - ); - $payment->setBlockMock($paymentInfoBlock); - - $this->assertEmpty($shipment->getEmailSent()); - $shipment->sendEmail(true); - $this->assertNotEmpty($shipment->getEmailSent()); - $this->assertEquals('frontend', $paymentInfoBlock->getArea()); - } - /** * Check the correctness and stability of set/get packages of shipment * diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php index b6dc3f54709..3e417f80252 100755 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php @@ -168,6 +168,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase private function _prepareQuote($customerIsGuest) { $quoteFixture = $this->_prepareQuoteFixture($customerIsGuest); + $quoteFixture->setCustomerEmail('admin@example.com'); $this->_serviceQuote = Bootstrap::getObjectManager()->create( 'Magento\Sales\Model\Service\Quote', array('quote' => $quoteFixture) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php index 8b346afc80c..4d8d86ba287 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php @@ -84,6 +84,8 @@ $quote->getShippingAddress()->collectShippingRates(); $quote->collectTotals(); $quote->save(); + +$quote->setCustomerEmail('admin@example.com'); /** @var $service \Magento\Sales\Model\Service\Quote */ $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Sales\Model\Service\Quote', diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php index 21023ba2dd5..c7f27e00b37 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php @@ -43,6 +43,8 @@ $order->setIncrementId( 100 )->setBaseSubtotal( 100 +)->setCustomerEmail( + 'admin@example.com' )->setCustomerIsGuest( true )->setBillingAddress( diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php index 39514050b9c..5a66eb4642d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php @@ -80,4 +80,5 @@ $quote->setCustomerIsGuest( ); $quote->getPayment()->setMethod('checkmo'); $quote->setIsMultiShipping('1'); +$quote->collectTotals(); $quote->save(); diff --git a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php similarity index 53% rename from app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php rename to dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php index 3cd477712e4..dec03281299 100644 --- a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.3-1.6.1.4.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php @@ -22,24 +22,24 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Framework\Module\Setup */ -$installer = $this; -$installer->startSetup(); +/** @var \Magento\Framework\Registry $registry */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); -$tableName = $installer->getTable('admin_rule'); +/** @var $quote \Magento\Sales\Model\Quote */ +$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote'); +$quote->load('test01', 'reserved_order_id'); +if ($quote->getId()) { + $quote->delete(); +} -if ($tableName) { - /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ - $connection = $installer->getConnection(); - $remove = array( - 'Magento_Catalog::catalog_attributes', - 'Magento_Cms::cms', - 'Magento_Newsletter::admin_newsletter', - 'Magento_Review::pending', - 'Magento_Review::reviews', - 'Magento_Review::reviews_ratings' - ); - $connection->delete($tableName, array('resource_id IN (?)' => $remove)); +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); +$product->load(1); +if ($product->getId()) { + $product->delete(); } -$installer->endSetup(); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer.php index d9c7c9be93d..f7cb66452fe 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer.php @@ -25,5 +25,10 @@ include __DIR__ . '/quote.php'; include __DIR__ . '/../../../Magento/Customer/_files/customer.php'; -$customerIdFromFixture = 1; -$quote->setCustomerId($customerIdFromFixture)->setCustomerIsGuest(false)->save(); +/** @var $quote \Magento\Sales\Model\Quote */ +$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote'); +$quote->load('test01', 'reserved_order_id'); +/** @var $customer \Magento\Customer\Model\Customer */ +$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Customer'); +$customer->load(1); +$quote->setCustomer($customer)->setCustomerIsGuest(false)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer_rollback.php new file mode 100644 index 00000000000..fe6c6f3de4f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_customer_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) + */ +include __DIR__ . '/quote_rollback.php'; +include __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php'; diff --git a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.4-1.6.1.5.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php similarity index 53% rename from app/code/Magento/User/sql/user_setup/upgrade-1.6.1.4-1.6.1.5.php rename to dev/tests/integration/testsuite/Magento/Store/_files/second_store.php index 93b517fc1e9..bbba87052bf 100644 --- a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.4-1.6.1.5.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php @@ -22,20 +22,29 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer \Magento\Framework\Module\Setup */ -$installer = $this; - -$installer->startSetup(); -$connection = $installer->getConnection(); -$connection->addColumn( - $installer->getTable('admin_role'), - 'user_type', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 16, - 'nullable' => true, - 'comment' => 'User type' - ) +$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); +$websiteId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Store\Model\StoreManagerInterface' +)->getWebsite()->getId(); +$groupId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Store\Model\StoreManagerInterface' +)->getWebsite()->getDefaultGroupId(); +$store->setCode( + 'fixture_second_store' +)->setWebsiteId( + $websiteId +)->setGroupId( + $groupId +)->setName( + 'Fixture Store' +)->setSortOrder( + 10 +)->setIsActive( + 1 ); -$connection->dropColumn($installer->getTable('admin_rule'), 'role_type'); -$installer->endSetup(); +$store->save(); + +/* Refresh stores memory cache */ +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + 'Magento\Store\Model\StoreManagerInterface' +)->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store_rollback.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_rollback.php new file mode 100644 index 00000000000..e17e1df9e27 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_rollback.php @@ -0,0 +1,40 @@ +<?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) + */ +/** @var \Magento\Framework\Registry $registry */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var Magento\Store\Model\Store $store */ +$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); +$store->load('fixture_second_store'); + +if ($store->getId()) { + $store->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php index 0331c269cfb..4584a879340 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php @@ -150,6 +150,25 @@ class TaxRateServiceTest extends \PHPUnit_Framework_TestCase $this->assertEquals($taxData['titles'][0]['value'], $titles[0]->getValue()); } + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage id is not expected for this request. + * @magentoDbIsolation enabled + */ + public function testCreateTaxRateWithId() + { + $invalidTaxData = [ + 'id' => 2, + 'country_id' => 'US', + 'region_id' => '8', + 'percentage_rate' => '8.25', + 'code' => 'US-CA-*-Rate' . rand(), + 'zip_range' => ['from' => 78765, 'to' => 78780] + ]; + $taxRate = $this->taxRateBuilder->populateWithArray($invalidTaxData)->create(); + $this->taxRateService->createTaxRate($taxRate); + } + /** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Code already exists. diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php index b3455a2a334..5b6b780af82 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php @@ -24,6 +24,7 @@ namespace Magento\Tax\Service\V1; +use Magento\Backend\Block\Widget\Grid\Column\Renderer\Input; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\InputException; use Magento\Tax\Service\V1\Data\TaxRule; @@ -134,7 +135,69 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase /** * @magentoDbIsolation enabled */ - public function testCreateTaxRuleInvalid() + public function testCreateTaxRuleSpecifyingId() + { + $taxRuleDataObject = $this->taxRuleBuilder + ->setId(123) + ->setCode('code') + ->setCustomerTaxClassIds([3]) + ->setProductTaxClassIds([2]) + ->setTaxRateIds([2]) + ->setPriority(0) + ->setSortOrder(1) + ->create(); + + try { + $this->taxRuleService->createTaxRule($taxRuleDataObject); + $this->fail('Did not throw expected InputException'); + } catch (InputException $e) { + $this->assertEquals('TaxRule ID should not be specified.', $e->getMessage()); + } + } + + /** + * @magentoDbIsolation enabled + */ + public function testCreateTaxRuleInvalidTaxClassIds() + { + $taxRuleData = [ + TaxRule::CODE => 'code', + // These TaxClassIds exist, but '2' is should be a productTaxClassId and + // '3' should be a customerTaxClassId. See MAGETWO-25683. + TaxRule::CUSTOMER_TAX_CLASS_IDS => [2], + TaxRule::PRODUCT_TAX_CLASS_IDS => [3], + TaxRule::TAX_RATE_IDS => [1], + TaxRule::PRIORITY => 0, + TaxRule::SORT_ORDER => 0, + ]; + // Tax rule data object created + $taxRule = $this->taxRuleBuilder->populateWithArray($taxRuleData)->create(); + + try { + //Tax rule service call + $this->taxRuleService->createTaxRule($taxRule); + $this->fail('Did not throw expected InputException'); + } catch (InputException $e) { + $expectedCustomerTaxClassIdParams = [ + 'fieldName' => $taxRule::CUSTOMER_TAX_CLASS_IDS, + 'value' => 2, + ]; + $expectedProductTaxClassIdParams = [ + 'fieldName' => $taxRule::PRODUCT_TAX_CLASS_IDS, + 'value' => 3, + ]; + + $actualErrors = $e->getErrors(); + $this->assertEquals(2, count($actualErrors)); + $this->assertEquals($expectedCustomerTaxClassIdParams, $actualErrors[0]->getParameters()); + $this->assertEquals($expectedProductTaxClassIdParams, $actualErrors[1]->getParameters()); + } + } + + /** + * @magentoDbIsolation enabled + */ + public function testCreateTaxRuleInvalidSortOrder() { $taxRuleData = [ TaxRule::CODE => 'code', diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php index 3ce2d348603..1f01da3d28a 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php @@ -74,7 +74,7 @@ class AclConfigFilesTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\App\Filesystem' )->getPath( \Magento\Framework\App\Filesystem::APP_DIR - ) . '/*/*/*/etc/adminhtml/acl.xml' + ) . '/*/*/*/etc/acl.xml' ); $dataProviderResult = array(); foreach ($fileList as $file) { diff --git a/dev/tests/integration/testsuite/Magento/User/Block/Role/Tab/EditTest.php b/dev/tests/integration/testsuite/Magento/User/Block/Role/Tab/EditTest.php index 77381b9a7a1..96891e32e73 100644 --- a/dev/tests/integration/testsuite/Magento/User/Block/Role/Tab/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Block/Role/Tab/EditTest.php @@ -35,7 +35,8 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); + $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Authorization\Model\Role'); $roleAdmin->load(\Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, 'role_name'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\App\RequestInterface' diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/RoleTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/RoleTest.php index 98eec131999..f6f57d4d4ba 100644 --- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/RoleTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/RoleTest.php @@ -32,7 +32,8 @@ class RoleTest extends \Magento\Backend\Utility\Controller { public function testEditRoleAction() { - $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\Role'); + $roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Authorization\Model\Role'); $roleAdmin->load(\Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, 'role_name'); $this->getRequest()->setParam('rid', $roleAdmin->getId()); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index c0a11f7ee0a..dc4c4edde26 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -39,7 +39,7 @@ class UserTest extends \PHPUnit_Framework_TestCase protected $_dateTime; /** - * @var \Magento\User\Model\Role + * @var \Magento\Authorization\Model\Role */ protected static $_newRole; @@ -112,7 +112,7 @@ class UserTest extends \PHPUnit_Framework_TestCase public static function roleDataFixture() { self::$_newRole = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\User\Model\Role' + 'Magento\Authorization\Model\Role' ); self::$_newRole->setName('admin_role')->setRoleType('G')->setPid('1'); self::$_newRole->save(); @@ -152,7 +152,7 @@ class UserTest extends \PHPUnit_Framework_TestCase { $this->_model->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $role = $this->_model->getRole(); - $this->assertInstanceOf('Magento\User\Model\Role', $role); + $this->assertInstanceOf('Magento\Authorization\Model\Role', $role); $this->assertEquals(1, $role->getId()); $this->_model->setRoleId(self::$_newRole->getId())->save(); $role = $this->_model->getRole(); diff --git a/dev/tests/integration/testsuite/Magento/User/_files/user_with_role.php b/dev/tests/integration/testsuite/Magento/User/_files/user_with_role.php new file mode 100644 index 00000000000..f8304bfed7d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/User/_files/user_with_role.php @@ -0,0 +1,42 @@ +<?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) + */ + +/** + * Create an admin user with an assigned role + */ + +/** @var $model \Magento\User\Model\User */ +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); +$model->setFirstname("John") + ->setLastname("Doe") + ->setUsername('adminUser') + ->setPassword(\Magento\TestFramework\Bootstrap::ADMIN_PASSWORD) + ->setEmail('adminUser@example.com') + ->setRoleType('G') + ->setResourceId('Magento_Adminhtml::all') + ->setPrivileges("") + ->setAssertId(0) + ->setRoleId(1) + ->setPermission('allow'); +$model->save(); diff --git a/dev/tests/static/framework/Magento/TestFramework/Inspection/WordsFinder.php b/dev/tests/static/framework/Magento/TestFramework/Inspection/WordsFinder.php index eb91500f561..822fcf1e7c8 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Inspection/WordsFinder.php +++ b/dev/tests/static/framework/Magento/TestFramework/Inspection/WordsFinder.php @@ -67,7 +67,7 @@ class WordsFinder if (!is_dir($baseDir)) { throw new \Magento\TestFramework\Inspection\Exception("Base directory {$baseDir} does not exist"); } - $this->_baseDir = realpath($baseDir); + $this->_baseDir = str_replace('\\', '/', realpath($baseDir)); // Load config files if (!is_array($configFiles)) { @@ -81,7 +81,7 @@ class WordsFinder $basePath = $this->_baseDir . '/'; $basePathLen = strlen($basePath); foreach ($configFiles as $configFile) { - $configFile = realpath($configFile); + $configFile = str_replace('\\', '/', realpath($configFile)); if (strncmp($basePath, $configFile, $basePathLen) === 0) { // File is inside base dir $this->_whitelist[$this->_getRelPath($configFile)] = array(); diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php index c8523dae746..5aabe6c1bab 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php @@ -292,7 +292,7 @@ class Classes */ public static function isAutogenerated($className) { - if (preg_match('/.*\\\\[a-zA-Z0-9]{1,}(Factory|Proxy)$/', $className)) { + if (preg_match('/.*\\\\[a-zA-Z0-9]{1,}(Factory|Proxy|SearchResults)$/', $className)) { return true; } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index 2173e3ef6ea..6ed35e3e3b9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -230,6 +230,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $filePath = preg_replace($patterns, $replacements, $file); $className = substr($filePath, 0, -4); if (class_exists($className)) { + $file = str_replace('\\', DIRECTORY_SEPARATOR, $file); $classes[$file] = $className; } } @@ -339,8 +340,20 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $autoloader, $generatorIo, array( + \Magento\Framework\Service\Code\Generator\SearchResultsBuilder::ENTITY_TYPE + => 'Magento\Framework\Service\Code\Generator\SearchResultsBuilder', \Magento\Framework\ObjectManager\Code\Generator\Factory::ENTITY_TYPE - => 'Magento\Framework\ObjectManager\Code\Generator\Factory' + => 'Magento\Framework\ObjectManager\Code\Generator\Factory', + \Magento\Framework\ObjectManager\Code\Generator\Repository::ENTITY_TYPE + => 'Magento\Framework\ObjectManager\Code\Generator\Repository', + \Magento\Framework\ObjectManager\Code\Generator\Converter::ENTITY_TYPE + => 'Magento\Framework\ObjectManager\Code\Generator\Converter', + \Magento\Framework\Service\Code\Generator\Mapper::ENTITY_TYPE + => 'Magento\Framework\Service\Code\Generator\Mapper', + \Magento\Framework\Service\Code\Generator\Builder::ENTITY_TYPE + => 'Magento\Framework\Service\Code\Generator\Builder', + \Magento\Framework\Service\Code\Generator\SearchResults::ENTITY_TYPE + => 'Magento\Framework\Service\Code\Generator\SearchResults' ) ); $autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); 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 new file mode 100644 index 00000000000..df0577ac49d --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php @@ -0,0 +1,148 @@ +<?php +/** + * Test search_request.xsd and xml files. + * + * 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\Test\Integrity\Magento\Framework\Search; + +class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig +{ + /** + * Returns the name of the XSD file to be used to validate the XML + * + * @return string + */ + protected function _getXsd() + { + return '/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd'; + } + + /** + * Returns the name of the XSD file to be used to validate partial XML + * + * @return string + */ + protected function _getFileXsd() + { + return '/lib/internal/Magento/Framework/Search/etc/search_request.xsd'; + } + + /** + * The location of a single valid complete xml file + * + * @return string + */ + protected function _getKnownValidXml() + { + return __DIR__ . '/_files/valid.xml'; + } + + /** + * The location of a single known invalid complete xml file + * + * @return string + */ + protected function _getKnownInvalidXml() + { + return __DIR__ . '/_files/invalid.xml'; + } + + /** + * The location of a single known valid partial xml file + * + * @return string + */ + protected function _getKnownValidPartialXml() + { + return __DIR__ . '/_files/valid_partial.xml'; + } + + /** + * @param null $expectedErrors + */ + public function testSchemaUsingInvalidXml($expectedErrors = null) + { + $expectedErrors = array_filter( + explode( + "\n", + " +Element 'from': This element is not expected. Expected is ( filters ). +No match found for key-sequence ['sugegsted_search_container'] of keyref 'requestQueryReference'. +Element 'queryReference': No match found for key-sequence ['fulltext_search_query4'] of keyref 'queryReference'. +" + ) + ); + parent::testSchemaUsingInvalidXml($expectedErrors); + } + + /** + * @param null $expectedErrors + */ + public function testFileSchemaUsingInvalidXml($expectedErrors = null) + { + $expectedErrors = array_filter( + explode( + "\n", + " +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. +Element 'filter': The attribute 'value' is required but missing. +Element 'filterReference': The attribute 'clause' is required but missing. +Element 'filterReference': The attribute 'ref' is required but missing. +Element 'bucket': Missing child element(s). Expected is ( metrics ). +Element 'metric', attribute 'type': [facet 'enumeration'] " . + "The value 'sumasdasd' is not an element of the set {'sum', 'count', 'min', 'max'}. +Element 'metric', attribute 'type': 'sumasdasd' is not a valid value of the local atomic type. +Element 'bucket': Missing child element(s). Expected is ( ranges ). +Element 'request': Missing child element(s). Expected is ( from )." + ) + ); + parent::testFileSchemaUsingInvalidXml($expectedErrors); + } + + /** + * Returns the name of the xml files to validate + * + * @return string + */ + protected function _getXmlName() + { + return 'search_request.xml'; + } + + /** + * The location of a single known invalid partial xml file + * + * @return string + */ + protected function _getKnownInvalidPartialXml() + { + return __DIR__ . '/_files/invalid_partial.xml'; + } + + public function testSchemaUsingValidXml() + { + parent::testSchemaUsingValidXml(); + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid.xml new file mode 100644 index 00000000000..b11a17478f9 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid.xml @@ -0,0 +1,36 @@ +<?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) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="sugegsted_search_container" index="product"> + <queries> + <query xsi:type="boolQuery" name="suggested_search_container_dd" boost="2"> + <queryReference clause="not" ref="fulltext_search_query4" /> + </query> + </queries> + <from>10</from> + <size>10</size> + </request> +</requests> 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 new file mode 100644 index 00000000000..6dffe42beca --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/invalid_partial.xml @@ -0,0 +1,72 @@ +<?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) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="sugested_search_container" index="product"> + <queries> + <query xsi:type="boolQuery" name="sugested_search_container" boost="2"> + <queryReference clause="not" ref="fulltext_search_query" /> + </query> + + <query xsi:type="boolQuery" name="suggested_search_container_dd" boost="2"> + <queryReference clause="not" 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%" /> + </query> + + <query xsi:type="filteredQuery" name="promoted_documents_boost"> + <queryReference /> + </query> + + <query xsi:type="filteredQuery" name="promoted_documents_boost2"> + <filterReference /> + </query> + </queries> + <filters> + <filter xsi:type="termFilter" name="promoted_documents_boost" /> + <filter xsi:type="rangeFilter" field="promoted" name="price_name" from="10" to="100" /> + <filter xsi:type="boolFilter" name="price_name1"> + <filterReference clause="must" ref="price_name" /> + <filterReference /> + <filterReference clause="must" ref="price_name" /> + </filter> + <filter xsi:type="termFilter" name="promoted_boost" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" field="promoted" name="price" from="10" to="100" /> + </filters> + <aggregation> + <bucket xsi:type="termBucket" name="category_bucket" field="category"> + + </bucket> + <bucket xsi:type="rangeBucket" name="price_bucket" field="price"> + <metrics> + <metric type="sumasdasd" /> + </metrics> + </bucket> + </aggregation> + </request> +</requests> 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 new file mode 100644 index 00000000000..090a3c76b9a --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid.xml @@ -0,0 +1,116 @@ +<?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) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="sugegsted_search_container_1" index="product_1"> + <queries> + <query xsi:type="boolQuery" name="sugegsted_search_container_1" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + <queryReference clause="should" ref="promoted_documents_boost" /> + <queryReference clause="not" ref="query_reference" /> + </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%" /> + </query> + + <query xsi:type="filteredQuery" name="promoted_documents_boost"> + <queryReference ref="fulltext_search_query" /> + </query> + + <query xsi:type="filteredQuery" name="query_reference"> + <filterReference ref="price" /> + </query> + </queries> + <filters> + <filter xsi:type="termFilter" name="promoted_documents_boost" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" field="promoted" name="price_name" from="10" to="100" /> + <filter xsi:type="boolFilter" name="price_name_bool"> + <filterReference clause="must" ref="promoted_boost" /> + <filterReference clause="should" ref="promoted_documents_boost" /> + <filterReference clause="not" ref="price_name" /> + </filter> + <filter xsi:type="termFilter" name="promoted_boost" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" field="promoted" name="price" from="10" to="100" /> + </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> + <request query="sugegsted_search_container_2" index="product_2"> + <queries> + <query xsi:type="boolQuery" name="sugegsted_search_container_2" boost="2"> + <queryReference clause="not" ref="fulltext_search_query_c_2" /> + </query> + <query xsi:type="matchQuery" name="fulltext_search_query_c_2" boost="5"> + <match field="title" value="%request.title%" boost="2" /> + <match field="description" value="%request.description%" /> + </query> + </queries> + <filters> + <filter xsi:type="rangeFilter" field="promoted" name="price_filter" from="10" to="100" /> + </filters> + <aggregation> + <bucket xsi:type="termBucket" name="category_bucket" field="category"> + <metrics> + <metric type="sum" /> + </metrics> + </bucket> + <bucket xsi:type="rangeBucket" name="price_bucket" field="price"> + <metrics> + <metric type="sum" /> + </metrics> + <ranges> + <range from="" to="50" /> + </ranges> + </bucket> + </aggregation> + <from>0</from> + <size>10</size> + </request> +</requests> \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid_partial.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid_partial.xml new file mode 100644 index 00000000000..1f5530a779c --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/_files/valid_partial.xml @@ -0,0 +1,88 @@ +<?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) + */ +--> +<requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <request query="sugested_search_container_1" index="product_1"> + <queries> + <query xsi:type="boolQuery" name="sugested_search_container" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + <queryReference clause="should" ref="suggested_search_container_dd" /> + </query> + + <query xsi:type="boolQuery" name="suggested_search_container_dd" boost="2"> + <queryReference clause="not" 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%" /> + </query> + + <query xsi:type="filteredQuery" name="promoted_documents_boost"> + <queryReference ref="fulltext_search_query" /> + </query> + + <query xsi:type="filteredQuery" name="promoted_documents_boost2"> + <filterReference ref="promoted_documents_filter" /> + </query> + </queries> + <filters> + <filter xsi:type="termFilter" name="promoted_documents_filter" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" field="promoted" name="price_name" from="10" to="100" /> + <filter xsi:type="boolFilter" name="price_name1"> + <filterReference clause="must" ref="promoted_boost" /> + <filterReference clause="must" ref="price" /> + <filterReference clause="must" ref="promoted_documents_filter" /> + </filter> + <filter xsi:type="termFilter" name="promoted_boost" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" field="promoted" name="price" from="10" to="100" /> + </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> +</requests> \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index 01d38633d5c..7f88901174c 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -12,6 +12,7 @@ dev/tests/unit/testsuite/Magento/Framework/Code/_files/app/code/Magento/SomeModu dev/tests/unit/testsuite/Magento/Framework/Code/_files/app/code/Magento/SomeModule/Model/Six/Test.php dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Reader/_files/ConfigDomMock.php dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/Sample.php +dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/Sample.php dev/tools/Magento/Tools/I18n/Zend/Exception.php dev/tools/Magento/Tools/I18n/Zend/Console/Getopt/Exception.php dev/tools/Magento/Tools/I18n/Zend/Console/Getopt.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php index 54ed037558e..2c1e544dcbe 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php @@ -23,8 +23,8 @@ */ return array( 'admin_assert' => 'Magento_Adminhtml', - 'admin_role' => 'Magento_Adminhtml', - 'admin_rule' => 'Magento_Adminhtml', + 'authorization_role' => 'Magento_Authorization', + 'authorization_rule' => 'Magento_Authorization', 'admin_user' => 'Magento_Adminhtml', 'adminnotification_inbox' => 'Magento_AdminNotification', 'catalog_category_entity_datetime' => 'Magento_Catalog', 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 9bc2ac19e07..9cae16d7795 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 @@ -31,9 +31,9 @@ return array( array('Mage_Admin_Model_Acl_Role'), array('Mage_Admin_Model_Acl_Resource', 'Magento\Framework\Acl\Resource'), array('Mage_Admin_Model_Acl_Role_Registry', 'Magento\Framework\Acl\Role\Registry'), - array('Mage_Admin_Model_Acl_Role_Generic', 'Magento\User\Model\Acl\Role\Generic'), - array('Mage_Admin_Model_Acl_Role_Group', 'Magento\User\Model\Acl\Role\Group'), - array('Mage_Admin_Model_Acl_Role_User', 'Magento\User\Model\Acl\Role\User'), + array('Mage_Admin_Model_Acl_Role_Generic', 'Magento\Authorization\Model\Acl\Role\Generic'), + array('Mage_Admin_Model_Acl_Role_Group', 'Magento\Authorization\Model\Acl\Role\Group'), + array('Mage_Admin_Model_Acl_Role_User', 'Magento\Authorization\Model\Acl\Role\User'), array('Mage_Admin_Model_Resource_Acl', 'Magento\User\Model\Resource\Acl'), array('Mage_Admin_Model_Observer'), array('Mage_Admin_Model_Session', 'Magento\Backend\Model\Auth\Session'), @@ -43,17 +43,20 @@ return array( array('Mage_Admin_Model_Config'), array('Mage_Admin_Model_Resource_User', 'Magento\User\Model\Resource\User'), array('Mage_Admin_Model_Resource_User_Collection', 'Magento\User\Model\Resource\User\Collection'), - array('Mage_Admin_Model_Role', 'Magento\User\Model\Role'), - array('Mage_Admin_Model_Roles', 'Magento\User\Model\Roles'), - array('Mage_Admin_Model_Rules', 'Magento\User\Model\Rules'), - array('Mage_Admin_Model_Resource_Role', 'Magento\User\Model\Resource\Role'), + array('Mage_Admin_Model_Role', 'Magento\Authorization\Model\Role'), + array('Mage_Admin_Model_Roles', 'Magento\Authorization\Model\Roles'), + array('Mage_Admin_Model_Rules', 'Magento\Authorization\Model\Rules'), + array('Mage_Admin_Model_Resource_Role', 'Magento\Authorization\Model\Resource\Role'), array('Mage_Admin_Model_Resource_Roles', 'Magento\User\Model\Resource\Roles'), - array('Mage_Admin_Model_Resource_Rules', 'Magento\User\Model\Resource\Rules'), - array('Mage_Admin_Model_Resource_Role_Collection', 'Magento\User\Model\Resource\Role\Collection'), + array('Mage_Admin_Model_Resource_Rules', 'Magento\Authorization\Model\Resource\Rules'), + array('Mage_Admin_Model_Resource_Role_Collection', 'Magento\Authorization\Model\Resource\Role\Collection'), array('Mage_Admin_Model_Resource_Roles_Collection', 'Magento\User\Model\Resource\Roles\Collection'), array('Mage_Admin_Model_Resource_Roles_User_Collection', 'Magento\User\Model\Resource\Roles\User\Collection'), - array('Mage_Admin_Model_Resource_Rules_Collection', 'Magento\User\Model\Resource\Rules\Collection'), - array('Mage_Admin_Model_Resource_Permissions_Collection', 'Magento\User\Model\Resource\Permissions\Collection'), + array('Mage_Admin_Model_Resource_Rules_Collection', 'Magento\Authorization\Model\Resource\Rules\Collection'), + array( + 'Mage_Admin_Model_Resource_Permissions_Collection', + 'Magento\Authorization\Model\Resource\Permissions\Collection' + ), array('Mage_Adminhtml_Block_Abstract', 'Magento\Backend\Block\AbstractBlock'), array('Mage_Adminhtml_Block_Backup_Grid'), array('Mage_Adminhtml_Block_Cache_Grid'), @@ -599,7 +602,8 @@ return array( array('Mage_Adminhtml_Model_System_Config_Source_Store', 'Magento\Backend\Model\Config\Source\Store'), array('Mage_Adminhtml_Model_System_Config_Source_Website', 'Magento\Backend\Model\Config\Source\Website'), array('Mage_Adminhtml_Model_System_Config_Source_Yesno', 'Magento\Backend\Model\Config\Source\Yesno'), - array('Mage_Adminhtml_Model_System_Config_Source_Yesnocustom', + array( + 'Mage_Adminhtml_Model_System_Config_Source_Yesnocustom', 'Magento\Backend\Model\Config\Source\Yesnocustom' ), array('Mage_Adminhtml_Model_System_Store', 'Magento\Store\Model\System\Store'), @@ -696,7 +700,8 @@ return array( 'Magento\ConfigurableProduct\Block\Product\View\Type\Configurable' ), array( - 'Magento\Catalog\Block\Layer\Filter\AbstractFilter', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\Catalog\Block\Layer\Filter\AbstractFilter', + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' ), array('Magento\Catalog\Block\Layer\Filter\Attribute', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer'), array('Magento\Catalog\Block\Layer\Filter\Category', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer'), @@ -721,10 +726,12 @@ return array( 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' ), array( - 'Magento\Search\Block\Catalog\Layer\Filter\Decimal', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\Search\Block\Catalog\Layer\Filter\Decimal', + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' ), array( - 'Magento\Search\Block\Catalog\Layer\Filter\Price', 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' + 'Magento\Search\Block\Catalog\Layer\Filter\Price', + 'Magento\LayeredNavigation\Block\Navigation\FilterRenderer' ), array( 'Magento\Search\Block\Catalogsearch\Layer\Filter\Attribute', @@ -1427,12 +1434,15 @@ return array( ), array('Magento\Core\Model\Design\FileResolution\StrategyPool'), array('Magento\Framework\View\Design\FileResolution\StrategyPool'), - array('Magento\Core\Model\Layout\File','Magento\Framework\View\File'), - array('Magento\Core\Model\Layout\File\Factory','Magento\Framework\View\File\Factory'), - array('Magento\Core\Model\Layout\File\FileList\Factory','Magento\Framework\View\File\FileList\Factory'), - array('Magento\Core\Model\Layout\File\ListFile','Magento\Framework\View\File\FileList'), - array('Magento\Core\Model\Layout\File\Source\Aggregated','Magento\Framework\View\Layout\File\Collector\Aggregated'), - array('Magento\Core\Model\Layout\File\Source\Base','Magento\Framework\View\Layout\File\Source\Base'), + array('Magento\Core\Model\Layout\File', 'Magento\Framework\View\File'), + array('Magento\Core\Model\Layout\File\Factory', 'Magento\Framework\View\File\Factory'), + array('Magento\Core\Model\Layout\File\FileList\Factory', 'Magento\Framework\View\File\FileList\Factory'), + array('Magento\Core\Model\Layout\File\ListFile', 'Magento\Framework\View\File\FileList'), + array( + 'Magento\Core\Model\Layout\File\Source\Aggregated', + 'Magento\Framework\View\Layout\File\Collector\Aggregated' + ), + array('Magento\Core\Model\Layout\File\Source\Base', 'Magento\Framework\View\Layout\File\Source\Base'), array( 'Magento\Core\Model\Layout\File\Source\Decorator\ModuleDependency', 'Magento\Framework\View\File\Collector\Decorator\ModuleDependency' @@ -2338,9 +2348,9 @@ return array( ['Magento\BaseScopeInterface', 'Magento\Framework\App\ScopeInterface'], ['Magento\BaseScopeResolverInterface', 'Magento\Framework\App\ScopeResolverInterface'], ['Magento\Framework\Locale\ScopeConfigInterface'], - ['Magento\Core\Model\Module\Output\Config','Magento\Framework\Module\Output\Config'], - ['Magento\Core\Model\Resource\Setup\Context','Magento\Framework\Module\Setup\Context'], - ['Magento\Core\Model\Resource\Setup\Migration','Magento\Framework\Module\Setup\Migration'], + ['Magento\Core\Model\Module\Output\Config', 'Magento\Framework\Module\Output\Config'], + ['Magento\Core\Model\Resource\Setup\Context', 'Magento\Framework\Module\Setup\Context'], + ['Magento\Core\Model\Resource\Setup\Migration', 'Magento\Framework\Module\Setup\Migration'], ['Magento\Core\Model\Resource\Setup\Generic'], ['Magento\Newsletter\Model\Resource\Setup'], ['Magento\SalesRule\Model\Resource\Setup'], @@ -2441,8 +2451,6 @@ return array( ['Magento\AclFactory', 'Magento\Framework\AclFactory'], ['Magento\AppInterface', 'Magento\Framework\AppInterface'], ['Magento\Archive', 'Magento\Framework\Archive'], - ['Magento\Authorization', 'Magento\Framework\Authorization'], - ['Magento\AuthorizationInterface', 'Magento\Framework\AuthorizationInterface'], ['Magento\Event', 'Magento\Framework\Event'], ['Magento\EventFactory', 'Magento\Framework\EventFactory'], ['Magento\Exception', 'Magento\Framework\Exception'], @@ -2573,7 +2581,10 @@ return array( ['Magento\Framework\View\Url', 'Magento\Framework\View\Asset\Repository'], ['Magento\Less\File\Source\Base', 'Magento\Framework\View\File\Collector\Base'], ['Magento\Less\File\Source\Theme', 'Magento\Framework\View\File\Collector\ThemeModular'], - ['Magento\Framework\View\Layout\File\FileList\CollateInterface', 'Magento\Framework\View\File\FileList\CollateInterface'], + [ + 'Magento\Framework\View\Layout\File\FileList\CollateInterface', + 'Magento\Framework\View\File\FileList\CollateInterface' + ], ['Magento\Framework\View\Layout\File\FileList\Collator', 'Magento\Framework\View\File\FileList\Collator'], ['Magento\Framework\View\Layout\File\FileList\Factory', 'Magento\Framework\View\File\FileList\Factory'], [ @@ -2699,4 +2710,26 @@ return array( ['Magento\Catalog\Helper\Product\Price'], ['Magento\Tax\Model\Config\Source\TaxClass\Product', 'Magento\Tax\Model\TaxClass\Source\Product'], ['Magento\Tax\Model\Config\Source\TaxClass\Customer', 'Magento\Tax\Model\TaxClass\Source\Customer'], + ['Magento\AdminNotification\Model\System\MessageInterface', 'Magento\Framework\Notification\MessageInterface'], + ['Magento\AdminNotification\Model\System\MessageList', 'Magento\Framework\Notification\MessageList'], + [ + 'Magento\CatalogImportExport\Model\Import\Product\Type\Configurable', + 'Magento\ConfigurableImportExport\Model\Import\Product\Type\Configurable' + ], + [ + 'Magento\CatalogImportExport\Model\Export\Product\Type\Configurable', + 'Magento\ConfigurableImportExport\Model\Export\Product\Type\Configurable' + ], + [ + 'Magento\CatalogImportExport\Model\Export\RowCustomizer', + 'Magento\ConfigurableImportExport\Model\Export\RowCustomizer' + ], + [ + 'Magento\CatalogImportExport\Model\Export\Product\Type\Grouped', + 'Magento\GroupedImportExport\Model\Export\Product\Type\Grouped' + ], + [ + 'Magento\CatalogImportExport\Model\Import\Product\Type\Grouped', + 'Magento\GroupedImportExport\Model\Import\Product\Type\Grouped' + ], ); 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 837c22f270a..46a5a6a397b 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 @@ -1802,5 +1802,17 @@ return array( ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Observer'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Resource\Stock\Status'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Stock\Status'], - ['getDeleteUrl','\Magento\Checkout\Block\Cart\Item\Renderer'], + ['getPriceHtml', '\Magento\Catalog\Block\Product\AbstractProduct', '\Magento\Catalog\Block\Product\AbstractProduct::getProductPriceHtml'], + ['getDeleteUrl', '\Magento\Checkout\Block\Cart\Item\Renderer'], + ['sendNewOrderEmail', 'Magento\Sales\Model\Order'], + ['_getEmails', 'Magento\Sales\Model\Order'], + ['_getEmails', 'Magento\Sales\Model\Order\Creditmemo'], + ['sendUpdateEmail', 'Magento\Sales\Model\Order\Creditmemo'], + ['sendEmail', 'Magento\Sales\Model\Order\Creditmemo'], + ['sendEmail', 'Magento\Sales\Model\Order\Invoice'], + ['sendUpdateEmail', 'Magento\Sales\Model\Order\Invoice'], + ['_getEmails', 'Magento\Sales\Model\Order\Invoice'], + ['sendEmail', 'Magento\Sales\Model\Order\Shipment'], + ['sendUpdateEmail', 'Magento\Sales\Model\Order\Shipment'], + ['_getEmails', 'Magento\Sales\Model\Order\Shipment'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php index a5d35beee4a..cc3cf20cf0f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php @@ -37,7 +37,6 @@ return [ ['Magento\Acl', 'Magento\Framework\Acl'], ['Magento\Archive', 'Magento\Framework\Archive'], ['Magento\Session', 'Magento\Framework\Session'], - ['Magento\Authorization', 'Magento\Framework\Authorization'], ['Magento\Cache', 'Magento\Framework\Cache'], ['Magento\ObjectManager', 'Magento\Framework\ObjectManager'], ['Magento\Exception', 'Magento\Framework\Exception'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php index 453ffd8bc7c..9b23819278f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_paths.php @@ -71,11 +71,6 @@ return [ ], ['/dev/tests/unit/testsuite/Magento/Session', '/dev/tests/unit/testsuite/Magento/Framework/Session'], ['/lib/Magento/Authorization', '/lib/Magento/Framework/Authorization'], - [ - '/dev/tests/integration/testsuite/Magento/Authorization', - '/dev/tests/integration/testsuite/Magento/Framework/Authorization' - ], - ['/dev/tests/unit/testsuite/Magento/Authorization', '/dev/tests/unit/testsuite/Magento/Framework/Authorization'], ['/lib/Magento/Cache', '/lib/Magento/Framework/Cache'], ['/dev/tests/integration/testsuite/Magento/Cache', '/dev/tests/integration/testsuite/Magento/Framework/Cache'], ['/dev/tests/unit/testsuite/Magento/Cache', '/dev/tests/unit/testsuite/Magento/Framework/Cache'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/words_ce.xml b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/words_ce.xml index 201c6973285..1abee450ecf 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/words_ce.xml +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/words_ce.xml @@ -51,7 +51,7 @@ <path>CHANGELOG.md</path> </item> <item> - <path>CHANGELOG_CE.md</path> + <path>dev/build/publication/extra_files/ce/CHANGELOG.md</path> </item> <item> <path>app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php</path> diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt index ef94888aee5..9db36d76f0a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt @@ -31,8 +31,6 @@ dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeStyleTest/phpcs/input dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeStyleTest/phpcs/expected dev/tests/static/testsuite/Magento/Test/Legacy/_files -dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php -dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/_files 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 139b4d8797a..5838cc49d92 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 @@ -43,6 +43,7 @@ Magento/CatalogImportExport/Model/Export Magento/CatalogImportExport/Model/Import Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab Magento/Checkout/Block/Onepage +Magento/Checkout/Service/V1/Data/Cart Magento/Cms/Block/Adminhtml/Page/Edit Magento/Core/Model/Design/Backend Magento/Core/Model/Layout/File/Source/Override @@ -122,4 +123,5 @@ Magento/Dhl/Model Magento/Shipping/Model Magento/Catalog/Service/V1/Category Magento/UrlRedirect/Model -setup \ No newline at end of file +setup +Magento/Sales/Service/V1/Data \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt index 63ed5b003a1..7edeaf58e05 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt @@ -35,6 +35,7 @@ app/code/Magento/Checkout/Block/Link.php app/code/Magento/Cms/Block/Adminhtml/Page/Edit/Tab/Design.php app/code/Magento/Cms/Controller/Router.php app/code/Magento/Cms/Model/Template/FilterProvider.php +app/code/Magento/ConfigurableImportExport app/code/Magento/ConfigurableProduct app/code/Magento/Core/data app/code/Magento/Core/Model/Design.php @@ -67,6 +68,7 @@ app/code/Magento/Eav/Model/Cache/Type.php app/code/Magento/GiftMessage/Model/Plugin app/code/Magento/GoogleShopping/Block/SiteVerification.php app/code/Magento/GoogleShopping/Model/AttributeFactory.php +app/code/Magento/GroupedImportExport app/code/Magento/GroupedProduct/Service app/code/Magento/Eav/Model/Entity/Attribute/Config app/code/Magento/Eav/Model/Entity/Attribute/Config.php @@ -141,4 +143,5 @@ lib/internal/Magento/Framework/Url/SecurityInfoInterface.php lib/internal/Magento/Framework/View lib/internal/Magento/Framework/App/AbstractShell.php lib/internal/Magento/Framework/Locale/Validator.php +lib/internal/Magento/Framework/Notification lib/internal/Magento/Framework/App/Config diff --git a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php index 5a2ff33df0f..4998f10e590 100644 --- a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php @@ -236,7 +236,7 @@ class ObjectManager $argClassName = null; $defaultValue = null; - if (isset($arguments[$parameterName])) { + if (array_key_exists($parameterName, $arguments)) { $constructArguments[$parameterName] = $arguments[$parameterName]; continue; } diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php index 81a55c740fa..4caf84c382a 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php @@ -119,7 +119,7 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase public function testGetSeverity() { $this->assertEquals( - \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL, + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL, $this->_model->getSeverity(), 'Invalid message severity type' ); diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/ErrorTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/ErrorTest.php index 161e105aaf2..d06b97451ad 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/ErrorTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/ErrorTest.php @@ -104,7 +104,7 @@ class ErrorTest extends \PHPUnit_Framework_TestCase public function testGetSeverity() { - $severity = \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + $severity = \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; $this->assertEquals($severity, $this->_model->getSeverity()); } } diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/SuccessTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/SuccessTest.php index 610e9e5acd3..e685559a543 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/SuccessTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/Media/Synchronization/SuccessTest.php @@ -113,7 +113,7 @@ class SuccessTest extends \PHPUnit_Framework_TestCase public function testGetSeverity() { - $severity = \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + $severity = \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; $this->assertEquals($severity, $this->_model->getSeverity()); } } diff --git a/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/AclRetrieverTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/AclRetrieverTest.php new file mode 100644 index 00000000000..a23208ca123 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/AclRetrieverTest.php @@ -0,0 +1,191 @@ +<?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\Authorization\Model\Acl; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\Resource\Role\Collection as RoleCollection; +use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; +use Magento\Authorization\Model\Resource\Rules\Collection as RulesCollection; +use Magento\Authorization\Model\Resource\Rules\CollectionFactory as RulesCollectionFactory; + +class AclRetrieverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AclRetriever + */ + protected $aclRetriever; + + /** @var \PHPUnit_Framework_MockObject_MockObject|Role $roleMock */ + protected $roleMock; + + protected function setup() + { + $this->aclRetriever = $this->createAclRetriever(); + } + + public function testGetAllowedResourcesByUserTypeGuest() + { + $expectedResources = ['anonymous']; + $allowedResources = $this->aclRetriever->getAllowedResourcesByUser(UserContextInterface::USER_TYPE_GUEST, null); + $this->assertEquals( + $expectedResources, + $allowedResources, + 'Allowed resources for guests should be \'anonymous\'.' + ); + } + + public function testGetAllowedResourcesByUserTypeCustomer() + { + $expectedResources = ['self']; + $allowedResources = $this->aclRetriever->getAllowedResourcesByUser( + UserContextInterface::USER_TYPE_CUSTOMER, + null + ); + $this->assertEquals( + $expectedResources, + $allowedResources, + 'Allowed resources for customers should be \'self\'.' + ); + + } + + /** + * @expectedException \Magento\Framework\Exception\AuthorizationException + * @expectedExceptionMessage The role associated with the specified user cannot be found. + */ + public function testGetAllowedResourcesByUserRoleNotFound() + { + $this->roleMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + $this->aclRetriever->getAllowedResourcesByUser(UserContextInterface::USER_TYPE_INTEGRATION, null); + } + + public function testGetAllowedResourcesByUser() + { + $this->roleMock->expects($this->any())->method('getId')->will($this->returnValue(1)); + $expectedResources = ['Magento_Adminhtml::dashboard', 'Magento_Cms::page']; + $this->assertEquals( + $expectedResources, + $this->aclRetriever->getAllowedResourcesByUser(UserContextInterface::USER_TYPE_INTEGRATION, 1) + ); + } + + protected function createAclRetriever() + { + $this->roleMock = $this->getMock( + 'Magento\Authorization\Model\Role', + array('getId', '__wakeup'), + array(), + '', + false + ); + + /** @var \PHPUnit_Framework_MockObject_MockObject|RoleCollection $roleCollectionMock */ + $roleCollectionMock = $this->getMock( + 'Magento\Authorization\Model\Resource\Role\Collection', + array('setUserFilter', 'getFirstItem'), + array(), + '', + false + ); + $roleCollectionMock->expects($this->any())->method('setUserFilter')->will($this->returnSelf()); + $roleCollectionMock->expects($this->any())->method('getFirstItem')->will($this->returnValue($this->roleMock)); + + /** @var \PHPUnit_Framework_MockObject_MockObject|RoleCollectionFactory $roleCollectionFactoryMock */ + $roleCollectionFactoryMock = $this->getMock( + 'Magento\Authorization\Model\Resource\Role\CollectionFactory', + array('create'), + array(), + '', + false + ); + $roleCollectionFactoryMock->expects($this->any())->method('create')->will( + $this->returnValue($roleCollectionMock) + ); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\Rules $rulesMock1 */ + $rulesMock1 = $this->getMock( + 'Magento\Authorization\Model\Rules', + array('getResourceId', '__wakeup'), + array(), + '', + false + ); + $rulesMock1->expects($this->any())->method('getResourceId')->will( + $this->returnValue('Magento_Adminhtml::dashboard') + ); + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\Rules $rulesMock1 */ + $rulesMock2 = $this->getMock( + 'Magento\Authorization\Model\Rules', + array('getResourceId', '__wakeup'), + array(), + '', + false + ); + $rulesMock2->expects($this->any())->method('getResourceId')->will($this->returnValue('Magento_Cms::page')); + + /** @var \PHPUnit_Framework_MockObject_MockObject|RulesCollection $rulesCollectionMock */ + $rulesCollectionMock = $this->getMock( + 'Magento\Authorization\Model\Resource\Rules\Collection', + array('getByRoles', 'load', 'getItems'), + array(), + '', + false + ); + $rulesCollectionMock->expects($this->any())->method('getByRoles')->will($this->returnSelf()); + $rulesCollectionMock->expects($this->any())->method('load')->will($this->returnSelf()); + $rulesCollectionMock->expects($this->any())->method('getItems')->will( + $this->returnValue([$rulesMock1, $rulesMock2]) + ); + + /** @var \PHPUnit_Framework_MockObject_MockObject|RulesCollectionFactory $rulesCollectionFactoryMock */ + $rulesCollectionFactoryMock = $this->getMock( + 'Magento\Authorization\Model\Resource\Rules\CollectionFactory', + array('create'), + array(), + '', + false + ); + $rulesCollectionFactoryMock->expects($this->any())->method('create')->will( + $this->returnValue($rulesCollectionMock) + ); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Acl $aclMock */ + $aclMock = $this->getMock('Magento\Framework\Acl', array('has', 'isAllowed'), array(), '', false); + $aclMock->expects($this->any())->method('has')->will($this->returnValue(true)); + $aclMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Acl\Builder $aclBuilderMock */ + $aclBuilderMock = $this->getMock('Magento\Framework\Acl\Builder', array('getAcl'), array(), '', false); + $aclBuilderMock->expects($this->any())->method('getAcl')->will($this->returnValue($aclMock)); + + return new AclRetriever( + $aclBuilderMock, + $roleCollectionFactoryMock, + $rulesCollectionFactoryMock, + $this->getMock('Magento\Framework\Logger', array(), array(), '', false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RoleTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RoleTest.php similarity index 92% rename from dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RoleTest.php rename to dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RoleTest.php index 0edc5b235ba..dc86153dd9f 100644 --- a/dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RoleTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RoleTest.php @@ -21,12 +21,12 @@ * @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\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; class RoleTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Acl\Loader\Role + * @var \Magento\Authorization\Model\Acl\Loader\Role */ protected $_model; @@ -54,14 +54,14 @@ class RoleTest extends \PHPUnit_Framework_TestCase { $this->_resourceMock = $this->getMock('Magento\Framework\App\Resource', array(), array(), '', false, false); $this->_groupFactoryMock = $this->getMock( - 'Magento\User\Model\Acl\Role\GroupFactory', + 'Magento\Authorization\Model\Acl\Role\GroupFactory', array('create'), array(), '', false ); $this->_roleFactoryMock = $this->getMock( - 'Magento\User\Model\Acl\Role\UserFactory', + 'Magento\Authorization\Model\Acl\Role\UserFactory', array('create'), array(), '', @@ -73,7 +73,7 @@ class RoleTest extends \PHPUnit_Framework_TestCase )->method( 'getTableName' )->with( - $this->equalTo('admin_role') + $this->equalTo('authorization_role') )->will( $this->returnArgument(1) ); @@ -93,7 +93,7 @@ class RoleTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_adapterMock) ); - $this->_model = new \Magento\User\Model\Acl\Loader\Role( + $this->_model = new \Magento\Authorization\Model\Acl\Loader\Role( $this->_groupFactoryMock, $this->_roleFactoryMock, $this->_resourceMock diff --git a/dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RuleTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RuleTest.php similarity index 92% rename from dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RuleTest.php rename to dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RuleTest.php index e592d04d4ce..46f6bdbbb42 100644 --- a/dev/tests/unit/testsuite/Magento/User/Model/Acl/Loader/RuleTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/Acl/Loader/RuleTest.php @@ -21,12 +21,12 @@ * @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\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; class RuleTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\User\Model\Acl\Loader\Rule + * @var \Magento\Authorization\Model\Acl\Loader\Rule */ protected $_model; @@ -44,7 +44,10 @@ class RuleTest extends \PHPUnit_Framework_TestCase { $this->_resourceMock = $this->getMock('Magento\Framework\App\Resource', array(), array(), '', false, false); $this->_rootResourceMock = new \Magento\Framework\Acl\RootResource('Magento_Adminhtml::all'); - $this->_model = new \Magento\User\Model\Acl\Loader\Rule($this->_rootResourceMock, $this->_resourceMock); + $this->_model = new \Magento\Authorization\Model\Acl\Loader\Rule( + $this->_rootResourceMock, + $this->_resourceMock + ); } public function testPopulateAcl() diff --git a/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php new file mode 100644 index 00000000000..2033b7d3282 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php @@ -0,0 +1,199 @@ +<?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\Authorization\Model; + +class CompositeUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeUserContext + */ + protected $_model; + + protected function setUp() + { + $this->_model = new CompositeUserContext(); + } + + public function testConstructor() + { + $userContextMock = $this->createUserContextMock(); + $contexts = [ + [ + 'sortOrder' => 10, + 'type' => $userContextMock + ] + ]; + $model = new CompositeUserContext($contexts); + $this->verifyUserContextIsAdded($model, $userContextMock); + } + + public function testGetUserId() + { + $expectedUserId = 1; + $expectedUserType = 'Customer'; + $userContextMock = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserId', 'getUserType'])->getMock(); + $userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($expectedUserId)); + $userContextMock->expects($this->any())->method('getUserType')->will($this->returnValue($expectedUserType)); + $contexts = [ + [ + 'sortOrder' => 10, + 'type' => $userContextMock + ] + ]; + $this->_model = new CompositeUserContext($contexts); + $actualUserId = $this->_model->getUserId(); + $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); + } + + public function testGetUserType() + { + $expectedUserId = 1; + $expectedUserType = 'Customer'; + $userContextMock = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserId', 'getUserType'])->getMock(); + $userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($expectedUserId)); + $userContextMock->expects($this->any())->method('getUserType')->will($this->returnValue($expectedUserType)); + $contexts = [ + [ + 'sortOrder' => 10, + 'type' => $userContextMock + ] + ]; + $this->_model = new CompositeUserContext($contexts); + $actualUserType = $this->_model->getUserType(); + $this->assertEquals($expectedUserType, $actualUserType, 'User Type is defined incorrectly.'); + } + + public function testUserContextCaching() + { + $expectedUserId = 1; + $expectedUserType = 'Customer'; + $userContextMock = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserId', 'getUserType'])->getMock(); + $userContextMock->expects($this->exactly(3))->method('getUserType') + ->will($this->returnValue($expectedUserType)); + $userContextMock->expects($this->exactly(3))->method('getUserId') + ->will($this->returnValue($expectedUserId)); + $contexts = [ + [ + 'sortOrder' => 10, + 'type' => $userContextMock + ] + ]; + $this->_model = new CompositeUserContext($contexts); + $this->_model->getUserId(); + $this->_model->getUserId(); + $this->_model->getUserType(); + $this->_model->getUserType(); + } + + public function testEmptyUserContext() + { + $expectedUserId = null; + $userContextMock = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserId'])->getMock(); + $userContextMock->expects($this->any())->method('getUserId') + ->will($this->returnValue($expectedUserId)); + $contexts = [ + [ + 'sortOrder' => 10, + 'type' => $userContextMock + ] + ]; + $this->_model = new CompositeUserContext($contexts); + $actualUserId = $this->_model->getUserId(); + $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); + } + + public function testUserContextOrder() + { + $expectedUserId = null; + $userContextMock1 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserType'])->getMock(); + $userContextMock1->expects($this->once())->method('getUserType')->will($this->returnValue(null)); + + $userContextMock2 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserType'])->getMock(); + $userContextMock2->expects($this->once())->method('getUserType')->will($this->returnValue(null)); + + $expectedUserType = 'Customer'; + $expectedUserId = 1234; + $userContextMock3 = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserType', 'getUserId'])->getMock(); + $userContextMock3->expects($this->once())->method('getUserType')->will($this->returnValue($expectedUserType)); + $userContextMock3->expects($this->exactly(2))->method('getUserId')->will($this->returnValue($expectedUserId)); + + $contexts = [ + [ + 'sortOrder' => 20, + 'type' => $userContextMock1 + ], + [ + 'sortOrder' => 30, + 'type' => $userContextMock3, + ], + [ + 'sortOrder' => 10, + 'type' => $userContextMock2 + ], + ]; + $this->_model = new CompositeUserContext($contexts); + $actualUserId = $this->_model->getUserId(); + $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); + } + + /** + * @param int|null $userId + * @param string|null $userType + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createUserContextMock($userId = null, $userType = null) + { + $useContextMock = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor()->setMethods(['getUserId', 'getUserType'])->getMock(); + if (!is_null($userId) && !is_null($userType)) { + $useContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($userId)); + $useContextMock->expects($this->any())->method('getUserType')->will($this->returnValue($userType)); + } + return $useContextMock; + } + + /** + * @param CompositeUserContext $model + * @param CompositeUserContext $userContextMock + */ + protected function verifyUserContextIsAdded($model, $userContextMock) + { + $userContext = new \ReflectionProperty( + 'Magento\Authorization\Model\CompositeUserContext', + 'userContexts' + ); + $userContext->setAccessible(true); + $values = $userContext->getValue($model); + $this->assertCount(1, $values, 'User context is not registered.'); + $this->assertEquals($userContextMock, $values[0], 'User context is registered incorrectly.'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Authorizenet/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Authorizenet/Helper/DataTest.php new file mode 100644 index 00000000000..3a168e9a37f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Authorizenet/Helper/DataTest.php @@ -0,0 +1,119 @@ +<?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\Authorizenet\Helper; + +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * Last 4 digit of cc + */ + const LAST4 = 1111; + + /** + * Transaction ID + */ + const TRID = '2217041665'; + + /** + * @var Data + */ + protected $_model; + + protected function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_model = $helper->getObject('Magento\Authorizenet\Helper\Data'); + } + + /** + * @param $type + * @param $amount + * @param $exception + * @param $additionalMessage + * @param $expected + * @dataProvider getMessagesParamDataProvider + */ + public function testGetTransactionMessage($type, $amount, $exception, $additionalMessage, $expected) + { + $currency = $this->getMock('Magento\Directory\Model\Currency', ['formatTxt', '__wakeup'], [], '', false); + $currency->expects($this->any()) + ->method('formatTxt') + ->will($this->returnValue($amount)); + $order = $this->getMock('Magento\Sales\Model\Order', ['getBaseCurrency', '__wakeup'], [], '', false); + $order->expects($this->any()) + ->method('getBaseCurrency') + ->will($this->returnValue($currency)); + $payment = $this->getMock('Magento\Payment\Model\Info', ['getOrder', '__wakeup'], [], '', false); + $payment->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($order)); + $card = new \Magento\Framework\Object(['cc_last4' => self::LAST4]); + $message = $this->_model->getTransactionMessage( + $payment, + $type, + self::TRID, + $card, + $amount, + $exception, + $additionalMessage + ); + + $this->assertEquals($expected, $message); + } + + /** + * @return array + */ + public function getMessagesParamDataProvider() + { + $amount = 12.30; + $additionalMessage = 'Addition message.'; + return [ + [ + 'AUTH_ONLY', + $amount, + false, + $additionalMessage, + 'Credit Card: xxxx-' . self::LAST4 . ' amount 12.3 authorize - successful. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. Addition message.' + ], + [ + 'AUTH_CAPTURE', + $amount, + 'some exception', + false, + 'Credit Card: xxxx-' . self::LAST4 . ' amount 12.3 authorize and capture - failed. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. some exception' + ], + [ + 'CREDIT', + false, + false, + $additionalMessage, + 'Credit Card: xxxx-' . self::LAST4 . ' refund - successful. ' + . 'Authorize.Net Transaction ID ' . self::TRID . '. Addition message.' + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Authz/Model/UserIdentifierTest.php b/dev/tests/unit/testsuite/Magento/Authz/Model/UserIdentifierTest.php deleted file mode 100644 index 0feffb08438..00000000000 --- a/dev/tests/unit/testsuite/Magento/Authz/Model/UserIdentifierTest.php +++ /dev/null @@ -1,92 +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\Authz\Model; - -use Magento\Authz\Model\UserIdentifier; - -/** - * Tests for User identifier. - */ -class UserIdentifierTest extends \PHPUnit_Framework_TestCase -{ - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_userLocatorMock; - - protected function setUp() - { - parent::setUp(); - $this->_userLocatorMock = $this->getMock( - 'Magento\Authz\Model\UserLocatorInterface', - array('getUserId', 'getUserType') - ); - } - - /** - * @param string $userType - * @param int $userId - * @dataProvider constructProvider - */ - public function testConstruct($userType, $userId) - { - $context = new UserIdentifier($this->_userLocatorMock, $userType, $userId); - $this->assertEquals($userId, $context->getUserId()); - $this->assertEquals($userType, $context->getUserType()); - } - - /** - * @param string $userType - * @param int $userId - * @param string $exceptionMessage - * @dataProvider constructProviderInvalidData - */ - public function testConstructInvalidData($userType, $userId, $exceptionMessage) - { - $this->setExpectedException('\LogicException', $exceptionMessage); - new UserIdentifier($this->_userLocatorMock, $userType, $userId); - } - - public function constructProvider() - { - return array( - array(UserIdentifier::USER_TYPE_GUEST, 0), - array(UserIdentifier::USER_TYPE_CUSTOMER, 1), - array(UserIdentifier::USER_TYPE_ADMIN, 2), - array(UserIdentifier::USER_TYPE_INTEGRATION, 3) - ); - } - - public function constructProviderInvalidData() - { - return array( - array( - 'InvalidUserType', - 1, - 'Invalid user type: \'InvalidUserType\'. Allowed types: Guest, Customer, Admin, Integration' - ), - array(UserIdentifier::USER_TYPE_CUSTOMER, -1, 'Invalid user ID: \'-1\''), - array(UserIdentifier::USER_TYPE_ADMIN, 'InvalidUserId', 'Invalid user ID: \'InvalidUserId\''), - array(UserIdentifier::USER_TYPE_GUEST, 3, 'Guest user must not have user ID set.') - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Authz/Service/AuthorizationV1Test.php b/dev/tests/unit/testsuite/Magento/Authz/Service/AuthorizationV1Test.php deleted file mode 100644 index 6a6ed9da8dc..00000000000 --- a/dev/tests/unit/testsuite/Magento/Authz/Service/AuthorizationV1Test.php +++ /dev/null @@ -1,91 +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\Authz\Service; - -use Magento\Authz\Model\UserIdentifier; -use Magento\User\Model\Role; - -class AuthorizationV1Test extends \PHPUnit_Framework_TestCase -{ - /** @var AuthorizationV1 */ - protected $_authzService; - - protected function setUp() - { - /** @var \PHPUnit_Framework_MockObject_MockObject|Role $roleMock */ - $roleMock = $this->getMock('Magento\User\Model\Role', array('load', 'delete', '__wakeup'), array(), '', false); - $roleMock->expects($this->any())->method('load')->will($this->returnSelf()); - $roleMock->expects($this->any())->method('delete')->will($this->returnSelf()); - - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\User\Model\RoleFactory $roleFactoryMock */ - $roleFactoryMock = $this->getMock('Magento\User\Model\RoleFactory', array('create'), array(), '', false); - $roleFactoryMock->expects($this->any())->method('create')->will($this->returnValue($roleMock)); - - $this->_authzService = new AuthorizationV1( - $this->getMock('Magento\Framework\Acl\Builder', array(), array(), '', false), - $this->getMock('Magento\Authz\Model\UserIdentifier', array(), array(), '', false), - $roleFactoryMock, - $this->getMock('Magento\User\Model\Resource\Role\CollectionFactory', array(), array(), '', false), - $this->getMock('Magento\User\Model\RulesFactory', array(), array(), '', false), - $this->getMock('Magento\User\Model\Resource\Rules\CollectionFactory', array(), array(), '', false), - $this->getMock('Magento\Framework\Logger', array(), array(), '', false), - $this->getMock('Magento\Framework\Acl\RootResource', array(), array(), '', false) - ); - } - - public function testRemovePermissions() - { - $this->_authzService->removePermissions($this->_getUserIdentifierMock(UserIdentifier::USER_TYPE_INTEGRATION)); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage No such entity with userType = Admin - */ - public function testRemovePermissionsException() - { - // Wrong user identifier type - $this->_authzService->removePermissions($this->_getUserIdentifierMock(UserIdentifier::USER_TYPE_ADMIN)); - } - - /** - * @param string $getUserTypeValue - * @return UserIdentifier|\PHPUnit_Framework_MockObject_MockObject - */ - protected function _getUserIdentifierMock($getUserTypeValue) - { - /** @var UserIdentifier|\PHPUnit_Framework_MockObject_MockObject $userIdentiferMock */ - $userIdentiferMock = $this->getMock( - 'Magento\Authz\Model\UserIdentifier', - array('getUserType', 'getUserId'), - array(), - '', - false - ); - - $userIdentiferMock->expects($this->any())->method('getUserType')->will($this->returnValue($getUserTypeValue)); - - return $userIdentiferMock; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/SessionTest.php index 2e4218d795f..00a936d0dce 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/SessionTest.php @@ -42,7 +42,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - include __DIR__ . '/_files/session_backend_mock.php'; + require_once __DIR__ . '/../../_files/session_backend_mock.php'; $requestMock = $helper->getObject('Magento\Framework\App\Request\Http'); $helper->getObject('Magento\Backend\Model\Session', array('request' => $requestMock)); $this->assertTrue(self::$sessionStart); diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/PriceBackendTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/PriceBackendTest.php index 6f306983a2d..ee66c981ddf 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/PriceBackendTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/PriceBackendTest.php @@ -24,7 +24,6 @@ namespace Magento\Bundle\Model\Plugin; - use Magento\Bundle\Model\Product\Price; use Magento\Catalog\Model\Product\Type; use Magento\TestFramework\Helper\ObjectManager; diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php index 58dcca446fc..5b8e693b8bd 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/WriteServiceTest.php @@ -521,6 +521,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $bundle->expects($this->once())->method('dropAllUnneededSelections')->with(3, array()); $bundle->expects($this->once())->method('saveProductRelations')->with(3, array()); + //Params come in lowercase to method $this->assertTrue($this->service->removeChild($productSku, $optionId, $childSku)); } diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php new file mode 100644 index 00000000000..0a6a3a975d1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/ReadServiceTest.php @@ -0,0 +1,217 @@ +<?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\Bundle\Service\V1\Product\Option; + +use Magento\TestFramework\Helper\ObjectManager; + +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\Option\ReadService + */ + private $model; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\OptionConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionConverter; + + /** + * @var \Magento\Bundle\Model\Product\Type|\PHPUnit_Framework_MockObject_MockObject + */ + private $productType; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Model\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionModel; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $option; + + /** + * @var \Magento\Bundle\Model\Resource\Option\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionCollection; + + public function setUp() + { + $objectManager = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productType = $this->getMockBuilder('Magento\Bundle\Model\Product\Type') + ->setMethods(['getOptionsCollection']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['__wakeup', 'getTypeId', 'getTypeInstance']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionModel = $this->getMockBuilder('Magento\Bundle\Model\Option') + ->setMethods(['__wakeup', 'getId']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Option\Collection') + ->setMethods(['setIdFilter', 'getFirstItem']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionConverter = $this->getMockBuilder('\Magento\Bundle\Service\V1\Data\Product\OptionConverter') + ->setMethods(['createDataFromModel']) + ->disableOriginalConstructor() + ->getMock(); + + $this->option = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->setMethods(['getId']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $objectManager->getObject( + 'Magento\Bundle\Service\V1\Product\Option\ReadService', + [ + 'optionConverter' => $this->optionConverter, + 'productRepository' => $this->productRepository, + 'type' => $this->productType + ] + ); + } + + public function testGet() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionConverter->expects($this->once())->method('createDataFromModel') + ->with($this->equalTo($this->optionModel), $this->equalTo($this->product)) + ->will($this->returnValue($this->option)); + + $this->optionModel->expects($this->once())->method('getId')->will($this->returnValue($optionId)); + + $this->assertEquals($this->option, $this->model->get($productSku, $optionId)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testGetNoSuchEntityException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionModel->expects($this->once())->method('getId'); + + $this->model->get($productSku, $optionId); + } + + public function testGetList() + { + $productSku = 'oneSku'; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue([$this->optionModel])); + + $this->optionConverter->expects($this->once())->method('createDataFromModel') + ->with($this->equalTo($this->optionModel), $this->equalTo($this->product)) + ->will($this->returnValue($this->option)); + + $this->assertEquals([$this->option], $this->model->getList($productSku)); + } + + /** + * @expectedException \Magento\Webapi\Exception + * @expectedExceptionCode 403 + */ + public function testGetListWebApiException() + { + $productSku = 'oneSku'; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)); + + $this->model->getList($productSku); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceTest.php new file mode 100644 index 00000000000..eef50926fb9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceTest.php @@ -0,0 +1,87 @@ +<?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\Bundle\Service\V1\Product\Option\Type; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Bundle\Service\V1\Data\Product\Option\Type; + +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\Option\Type\ReadService + */ + private $model; + + /** + * @var \Magento\Bundle\Model\Source\Option\Type|\PHPUnit_Framework_MockObject_MockObject + */ + private $typeModel; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option\TypeConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $typeConverter; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option\Type|\PHPUnit_Framework_MockObject_MockObject + */ + private $type; + + public function setUp() + { + $objectManager = new ObjectManager($this); + + $this->typeModel = $this->getMockBuilder('Magento\Bundle\Model\Source\Option\Type') + ->setMethods(['toOptionArray']) + ->disableOriginalConstructor() + ->getMock(); + + $this->typeConverter = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option\TypeConverter') + ->setMethods(['createDataFromModel']) + ->disableOriginalConstructor() + ->getMock(); + + $this->type = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option\Type') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $objectManager->getObject( + 'Magento\Bundle\Service\V1\Product\Option\Type\ReadService', + ['type' => $this->typeModel, 'typeConverter' => $this->typeConverter] + ); + } + + public function testGetTypes() + { + $label = 'someLabel'; + $value = 'someValue'; + $this->typeModel->expects($this->once())->method('toOptionArray') + ->will($this->returnValue([['label' => $label, 'value' => $value]])); + + $this->typeConverter->expects($this->once())->method('createDataFromModel') + ->will($this->returnValue($this->type)); + + $this->assertEquals([$this->type], $this->model->getTypes()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/WriteServiceTest.php new file mode 100644 index 00000000000..c772618a812 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Option/WriteServiceTest.php @@ -0,0 +1,393 @@ +<?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\Bundle\Service\V1\Product\Option; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class WriteServiceTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class WriteServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\Option\WriteService + */ + private $model; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\OptionConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionConverter; + + /** + * @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $storeManager; + + /** + * @var \Magento\Bundle\Model\Product\Type|\PHPUnit_Framework_MockObject_MockObject + */ + private $productType; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Model\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionModel; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $option; + + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + private $store; + + /** + * @var \Magento\Bundle\Model\Resource\Option\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionCollection; + + public function setUp() + { + $objectManager = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->store = $this->getMockBuilder('Magento\Store\Model\Store') + ->setMethods(['getId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->setMethods(['getStore']) + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); + + $this->optionConverter = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\OptionConverter') + ->setMethods(['createModelFromData', 'createDataFromModel', 'getModelFromData']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productType = $this->getMockBuilder('Magento\Bundle\Model\Product\Type') + ->setMethods(['getOptionsCollection']) + ->disableOriginalConstructor() + ->getMock(); + + $this->option = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['__wakeup', 'getTypeId', 'getSku']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionModel = $this->getMockBuilder('Magento\Bundle\Model\Option') + ->setMethods(['__wakeup', 'getId', 'delete', 'setStoreId', 'save']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Option\Collection') + ->setMethods(['setIdFilter', 'getFirstItem']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $objectManager->getObject( + 'Magento\Bundle\Service\V1\Product\Option\WriteService', + [ + 'productRepository' => $this->productRepository, + 'type' => $this->productType, + 'storeManager' => $this->storeManager, + 'optionConverter' => $this->optionConverter + ] + ); + } + + public function testAdd() + { + $productSku = 'oneSku'; + $optionId = 33; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $storeId = 1; + $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->optionModel->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId)); + $this->optionModel->expects($this->once())->method('save'); + + $this->optionConverter->expects($this->once())->method('createModelFromData') + ->with($this->equalTo($this->option), $this->equalTo($this->product)) + ->will($this->returnValue($this->optionModel)); + $this->optionModel->expects($this->once())->method('getId') + ->will($this->returnValue($optionId)); + + $this->assertEquals($optionId, $this->model->add($productSku, $this->option)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testAddCouldNotSaveException() + { + $productSku = 'oneSku'; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $storeId = 1; + $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->optionModel->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId)); + $this->optionModel->expects($this->once())->method('save')->will( + $this->returnCallback( + function () { + throw new \Exception(); + } + ) + ); + + $this->optionConverter->expects($this->once())->method('createModelFromData') + ->with($this->equalTo($this->option), $this->equalTo($this->product)) + ->will($this->returnValue($this->optionModel)); + + $this->assertEquals($this->option, $this->model->add($productSku, $this->option)); + } + + public function testUpdate() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $storeId = 1; + $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->optionModel->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId)); + $this->optionModel->expects($this->once())->method('getId')->will($this->returnValue($optionId)); + $this->optionModel->expects($this->once())->method('save'); + + $this->optionConverter->expects($this->once())->method('getModelFromData') + ->with($this->equalTo($this->option), $this->equalTo($this->optionModel)) + ->will($this->returnValue($this->optionModel)); + + $this->assertTrue($this->model->update($productSku, $optionId, $this->option)); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testUpdateCouldNotSaveException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $storeId = 1; + $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->optionModel->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId)); + $this->optionModel->expects($this->once())->method('getId')->will($this->returnValue($optionId)); + $this->optionModel->expects($this->once())->method('save')->will( + $this->returnCallback( + function () { + throw new \Exception(); + } + ) + ); + + $this->optionConverter->expects($this->once())->method('getModelFromData') + ->with($this->equalTo($this->option), $this->equalTo($this->optionModel)) + ->will($this->returnValue($this->optionModel)); + + $this->assertTrue($this->model->update($productSku, $optionId, $this->option)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testUpdateNoSuchEntityException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $this->optionConverter->expects($this->once())->method('getModelFromData') + ->with($this->equalTo($this->option), $this->equalTo($this->optionModel)) + ->will($this->returnValue($this->optionModel)); + + $this->optionModel->expects($this->once())->method('getId'); + + $this->model->update($productSku, $optionId, $this->option); + } + + public function testRemove() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $this->optionModel->expects($this->once())->method('getId')->will($this->returnValue($optionId)); + $this->optionModel->expects($this->once())->method('delete'); + + $this->assertTrue($this->model->remove($productSku, $optionId)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testRemoveNoSuchEntityException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + + $this->productType->expects($this->once())->method('getOptionsCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->optionCollection)); + + $this->optionCollection->expects($this->once())->method('setIdFilter') + ->with($this->equalTo($optionId)); + $this->optionCollection->expects($this->once())->method('getFirstItem') + ->will($this->returnValue($this->optionModel)); + + $this->optionModel->expects($this->once())->method('getId'); + + $this->model->remove($productSku, $optionId); + } + + /** + * @expectedException \Magento\Webapi\Exception + * @expectedExceptionCode 403 + */ + public function testRemoveWebApiException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)); + $this->product->expects($this->once())->method('getSku') + ->will($this->returnValue($productSku)); + + $this->model->remove($productSku, $optionId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php index 2faacb4ec04..4c7620a2bb5 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php @@ -118,20 +118,26 @@ class HelperTest extends \PHPUnit_Framework_TestCase '', false ); + } - $this->websiteMock->expects($this->once())->method('getId')->will($this->returnValue($this->websiteId)); + /** + * @covers Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testInitialize() + { + $this->websiteMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($this->websiteId)); - $this->storeMock->expects($this->once())->method('getWebsite')->will($this->returnValue($this->websiteMock)); + $this->storeMock->expects($this->once()) + ->method('getWebsite') + ->will($this->returnValue($this->websiteMock)); - $this->storeManagerMock->expects( - $this->once() - )->method( - 'getStore' - )->with( - true - )->will( - $this->returnValue($this->storeMock) - ); + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->with(true) + ->will($this->returnValue($this->storeMock)); $this->jsHelperMock = $this->getMock('\Magento\Backend\Helper\Js', [], [], '', false); $this->helper = new Helper( @@ -141,13 +147,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase $this->productLinksMock, $this->jsHelperMock ); - } - /** - * @covers Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize - */ - public function testInitialize() - { $productData = array( 'stock_data' => array('stock_data'), 'url_key_create_redirect' => true, @@ -156,92 +156,142 @@ class HelperTest extends \PHPUnit_Framework_TestCase $useDefaults = array('attributeCode1', 'attributeCode2'); - $this->requestMock->expects( - $this->at(0) - )->method( - 'getPost' - )->with( - 'product' - )->will( - $this->returnValue($productData) - ); - - $this->requestMock->expects( - $this->at(1) - )->method( - 'getPost' - )->with( - 'use_default' - )->will( - $this->returnValue($useDefaults) - ); - - $this->requestMock->expects( - $this->at(3) - )->method( - 'getPost' - )->with( - 'affect_product_custom_options' - )->will( - $this->returnValue(true) - ); - - $this->stockFilterMock->expects( - $this->once() - )->method( - 'filter' - )->with( - array('stock_data') - )->will( - $this->returnValue(array('stock_data')) - ); - - $this->storeManagerMock->expects($this->once())->method('hasSingleStore')->will($this->returnValue(true)); - - $this->productLinksMock->expects( - $this->once() - )->method( - 'initializeLinks' - )->with( - $this->productMock - )->will( - $this->returnValue($this->productMock) - ); - - $this->productMock->expects( - $this->once() - )->method( - 'isLockedAttribute' - )->with( - 'media' - )->will( - $this->returnValue(true) - ); - - $this->productMock->expects($this->once())->method('unlockAttribute')->with('media'); - - $this->productMock->expects($this->once())->method('lockAttribute')->with('media'); + $this->requestMock->expects($this->at(0)) + ->method('getPost') + ->with('product') + ->will($this->returnValue($productData)); + + $this->requestMock->expects($this->at(1)) + ->method('getPost') + ->with('use_default') + ->will($this->returnValue($useDefaults)); + + $this->requestMock->expects($this->at(3)) + ->method('getPost') + ->with('options_use_default') + ->will($this->returnValue(true)); + + $this->requestMock->expects($this->at(4)) + ->method('getPost') + ->with('affect_product_custom_options') + ->will($this->returnValue(true)); + + $this->stockFilterMock->expects($this->once()) + ->method('filter') + ->with(array('stock_data')) + ->will($this->returnValue(array('stock_data'))); + + $this->storeManagerMock->expects($this->once()) + ->method('hasSingleStore') + ->will($this->returnValue(true)); + + $this->productLinksMock->expects($this->once()) + ->method('initializeLinks') + ->with($this->productMock) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once()) + ->method('isLockedAttribute') + ->with('media') + ->will($this->returnValue(true)); + + $this->productMock->expects($this->once()) + ->method('unlockAttribute') + ->with('media'); + + $this->productMock->expects($this->once()) + ->method('lockAttribute') + ->with('media'); $productData['category_ids'] = array(); $productData['website_ids'] = array(); - $this->productMock->expects($this->once())->method('addData')->with($productData); + $this->productMock->expects($this->once()) + ->method('addData') + ->with($productData); - $this->productMock->expects($this->once())->method('getId')->will($this->returnValue(true)); + $this->productMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(true)); - $this->productMock->expects($this->once())->method('setWebsiteIds')->with(array($this->websiteId)); + $this->productMock->expects($this->once()) + ->method('setWebsiteIds') + ->with(array($this->websiteId)); - $this->productMock->expects($this->at(6))->method('setData')->with('save_rewrites_history', true); + $this->productMock->expects($this->at(6)) + ->method('setData') + ->with('save_rewrites_history', true); - $this->productMock->expects($this->at(7))->method('setData')->with('attributeCode1', false); + $this->productMock->expects($this->at(7)) + ->method('setData') + ->with('attributeCode1', false); - $this->productMock->expects($this->at(8))->method('setData')->with('attributeCode2', false); + $this->productMock->expects($this->at(8)) + ->method('setData') + ->with('attributeCode2', false); - $this->productMock->expects($this->any())->method('getOptionsReadOnly')->will($this->returnValue(false)); + $this->productMock->expects($this->any()) + ->method('getOptionsReadOnly') + ->will($this->returnValue(false)); - $this->productMock->expects($this->once())->method('setProductOptions')->with($productData['options']); + $this->productMock->expects($this->once()) + ->method('setProductOptions') + ->with($productData['options']); - $this->productMock->expects($this->once())->method('setCanSaveCustomOptions')->with(true); + $this->productMock->expects($this->once()) + ->method('setCanSaveCustomOptions') + ->with(true); $this->assertEquals($this->productMock, $this->helper->initialize($this->productMock)); } + + /** + * Data provider for testMergeProductOptions + * + * @return array + */ + public function mergeProductOptionsDataProvider() + { + return [ + [ + null, + [], + [], + ], + [ + ['key' => 'val'], + null, + ['key' => 'val'], + ], + [ + ['key' => ['key' => 'val']], + ['key' => ['key' => 'val2' , 'key2' => 'val2']], + ['key' => ['key' => 'val2' , 'key2' => 'val2']], + ], + [ + ['key' => ['key' => 'val', 'another_key' => 'another_value']], + ['key' => ['key' => 'val2' , 'key2' => 'val2']], + ['key' => ['key' => 'val2' , 'another_key' => 'another_value', 'key2' => 'val2', ]], + ], + ]; + } + + /** + * @param array $productOptions + * @param array $defaultOptions + * @param array $expectedResults + * @dataProvider mergeProductOptionsDataProvider + */ + public function testMergeProductOptions($productOptions, $defaultOptions, $expectedResults) + { + $this->jsHelperMock = $this->getMock('\Magento\Backend\Helper\Js', [], [], '', false); + $this->helper = new Helper( + $this->requestMock, + $this->storeManagerMock, + $this->stockFilterMock, + $this->productLinksMock, + $this->jsHelperMock + ); + $result = $this->helper->mergeProductOptions($productOptions, $defaultOptions); + $this->assertEquals($expectedResults, $result); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Validator/DefaultValidatorTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Validator/DefaultValidatorTest.php index 5df12e54d03..03309c1df6d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Validator/DefaultValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Option/Validator/DefaultValidatorTest.php @@ -63,50 +63,119 @@ class DefaultValidatorTest extends \PHPUnit_Framework_TestCase ], ]; $configMock->expects($this->once())->method('getAll')->will($this->returnValue($config)); - $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup']; - $this->valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); $this->validator = new \Magento\Catalog\Model\Product\Option\Validator\DefaultValidator( $configMock, $priceConfigMock ); } - public function testIsValidSuccess() + /** + * Data provider for testIsValidSuccess + * @return array + */ + public function isValidTitleDataProvider() { - $this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title')); - $this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1')); - $this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed')); - $this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10)); - $this->assertTrue($this->validator->isValid($this->valueMock)); - $this->assertEmpty($this->validator->getMessages()); + $mess = ['option required fields' => 'Missed values for option required fields']; + return [ + ['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\Object(['store_id' => 1]), [], true], + ['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\Object(['store_id' => 0]), [], true], + [null, 'name 1.1', 'fixed', 10, new \Magento\Framework\Object(['store_id' => 1]), [], true], + [null, 'name 1.1', 'fixed', 10, new \Magento\Framework\Object(['store_id' => 0]), $mess, false], + ]; } - public function testIsValidFail() + /** + * @param $title + * @param $type + * @param $priceType + * @param $price + * @param $product + * @param $messages + * @param $result + * @dataProvider isValidTitleDataProvider + */ + public function testIsValidTitle($title, $type, $priceType, $price, $product, $messages, $result) { - $this->valueMock->expects($this->once())->method('getTitle'); - $this->valueMock->expects($this->once())->method('getType'); - $this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('some_new_value')); - $this->valueMock->expects($this->never())->method('getPrice'); + $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; + $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); + $valueMock->expects($this->any())->method('getType')->will($this->returnValue($type)); + $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); + $valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price)); + $valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); + $this->assertEquals($result, $this->validator->isValid($valueMock)); + $this->assertEquals($messages, $this->validator->getMessages()); + } + + /** + * Data provider for testIsValidFail + * + * @return array + */ + public function isValidFailDataProvider() + { + return [ + [new \Magento\Framework\Object(['store_id' => 1])], + [new \Magento\Framework\Object(['store_id' => 0])], + ]; + } + + /** + * @param $product + * @dataProvider isValidFailDataProvider + */ + public function testIsValidFail($product) + { + $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; + $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); + $valueMock->expects($this->once())->method('getTitle'); + $valueMock->expects($this->any())->method('getType'); + $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('some_new_value')); + $valueMock->expects($this->never())->method('getPrice'); $messages = [ 'option required fields' => 'Missed values for option required fields', 'option type' => 'Invalid option type', 'option values' => 'Invalid option value' ]; - $this->assertFalse($this->validator->isValid($this->valueMock)); + $this->assertFalse($this->validator->isValid($valueMock)); $this->assertEquals($messages, $this->validator->getMessages()); } - public function testValidationNegativePrice() + /** + * Data provider for testValidationNegativePrice + * @return array + */ + public function validationNegativePriceDataProvider() + { + return [ + ['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\Object(['store_id' => 1])], + ['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\Object(['store_id' => 0])], + ]; + } + + /** + * @param $title + * @param $type + * @param $priceType + * @param $price + * @param $product + * @dataProvider validationNegativePriceDataProvider + */ + public function testValidationNegativePrice($title, $type, $priceType, $price, $product) { - $this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title')); - $this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1')); - $this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed')); - $this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(-12)); + $methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct']; + $valueMock = $this->getMock('Magento\Catalog\Model\Product\Option', $methods, [], '', false); + $valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title)); + $valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type)); + $valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType)); + $valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price)); + $valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product)); $messages = [ 'option values' => 'Invalid option value' ]; - $this->assertFalse($this->validator->isValid($this->valueMock)); + $this->assertFalse($this->validator->isValid($valueMock)); $this->assertEquals($messages, $this->validator->getMessages()); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php deleted file mode 100644 index 2d1f39eda73..00000000000 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php +++ /dev/null @@ -1,71 +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\Catalog\Model\Resource\Product\Option; - -class ValueTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Catalog\Model\Resource\Product\Option\ValueStub - */ - protected $_object; - - /** - * Option value title data - * - * @var array - */ - public static $valueTitleData = array( - 'id' => 2, - 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, - 'scope' => array('title' => 1) - ); - - protected function setUp() - { - $this->_object = new \Magento\Catalog\Model\Resource\Product\Option\ValueStub(); - } - - protected function tearDown() - { - unset($this->_object); - } - - /** - * Test that there is no notice in _saveValueTitles() - * - * @covers \Magento\Catalog\Model\Resource\Product\Option\Value::_saveValueTitles - */ - public function testSaveValueTitles() - { - $object = new Stub( - $this->getMock('Magento\Framework\Model\Context', array(), array(), '', false), - $this->getMock('Magento\Framework\Registry', array(), array(), '', false), - null, - null, - self::$valueTitleData - ); - - $this->_object->saveValueTitles($object); - } -} 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 71140ba25c9..5d173eb2e4c 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 @@ -24,9 +24,8 @@ namespace Magento\Catalog\Service\V1\Category\ProductLinks; use Magento\Catalog\Model\Category; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductConverterFactory; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLinkBuilder; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLinkBuilder; use Magento\TestFramework\Helper\ObjectManager; class ReadServiceTest extends \PHPUnit_Framework_TestCase @@ -68,12 +67,12 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $categoryFactory->expects($this->any())->method('create') ->will($this->returnValue($this->category)); - $this->productLink = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink') + $this->productLink = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Category\ProductLink') ->disableOriginalConstructor() ->getMock(); $this->productLinkBuilder = $this->getMockBuilder( - 'Magento\Catalog\Service\V1\Data\Eav\Category\ProductLinkBuilder' + 'Magento\Catalog\Service\V1\Data\Category\ProductLinkBuilder' ) ->disableOriginalConstructor() ->getMock(); @@ -96,7 +95,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $productId = $categoryId + 6; $productSku = "sku{$productId}"; - $productDto = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink') + $productDto = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Category\ProductLink') ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceTest.php index d04bae14a25..24c0ede6ee0 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceTest.php @@ -48,7 +48,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase private $categoryLoader; /** - * @var \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Service\V1\Data\Category\ProductLink|\PHPUnit_Framework_MockObject_MockObject */ private $productLink; @@ -56,7 +56,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $objectManager = new ObjectManager($this); - $this->productLink = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink') + $this->productLink = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Category\ProductLink') ->setMethods(['getSku', 'getPosition']) ->disableOriginalConstructor() ->getMock(); 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 d55e5e3af5c..7668158e810 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 @@ -138,9 +138,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedException \Magento\Framework\Exception\StateException */ - public function testDeleteCouldNotSaveException() + public function testDeleteStateException() { $id = 3; $this->category->expects($this->once())->method('getId')->will($this->returnValue($id)); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php index e4d32357803..469d333c07f 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/Category/TreeTest.php @@ -173,6 +173,8 @@ class TreeTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $builder->expects($this->any())->method('setActive')->with($this->equalTo(true)) ->will($this->returnSelf()); + $builder->expects($this->any())->method('setProductCount')->with(4) + ->will($this->returnSelf()); $builder->expects($this->any())->method('setChildren')->will($this->returnSelf()); $builder->expects($this->any())->method('create')->will($this->returnValue([])); @@ -187,7 +189,8 @@ class TreeTest extends \PHPUnit_Framework_TestCase 'getName', 'getPosition', 'getLevel', - 'getIsActive' + 'getIsActive', + 'getProductCount' ] ) ->getMock(); @@ -200,6 +203,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase $node->expects($this->any())->method('getPosition')->will($this->returnValue($currentLevel)); $node->expects($this->any())->method('getLevel')->will($this->returnValue($currentLevel)); $node->expects($this->any())->method('getIsActive')->will($this->returnValue(true)); + $node->expects($this->any())->method('getProductCount')->will($this->returnValue(4)); $this->tree->getTree($node, $depth, $currentLevel); } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.php new file mode 100644 index 00000000000..8dc87b47f2f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/ReadServiceTest.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\Checkout\Service\V1\Address\Billing; + +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ReadService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + protected function setUp() + { + $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); + + $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); + } + + public function testGetAddress() + { + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue(11)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once())->method('load') + ->with('cartId', '11')->will($this->returnValue($quoteMock)); + + $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); + + $this->converterMock->expects($this->once())->method('convertModelToDataObject') + ->with($addressMock)->will($this->returnValue('BillingAddress')); + + $this->assertEquals('BillingAddress', $this->service->getAddress('cartId')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php new file mode 100644 index 00000000000..64bb4c6ffab --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Billing/WriteServiceTest.php @@ -0,0 +1,170 @@ +<?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\Checkout\Service\V1\Address\Billing; + +class WriteServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var WriteService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->addressFactoryMock = $this->getMock( + '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false + ); + + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteAddressMock = $this->getMock( + '\Magento\Sales\Model\Quote\Address', + ['getCustomerId', 'load', 'getData', 'setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeup'], + [], + '', + false + ); + $this->addressFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + + $this->validatorMock = $this->getMock( + '\Magento\Checkout\Service\V1\Address\Validator', [], [], '', false + ); + + $this->converterMock = $this->getMock( + '\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false + ); + + $this->service = $this->objectManager->getObject( + '\Magento\Checkout\Service\V1\Address\Billing\WriteService', + [ + 'quoteLoader' => $this->quoteLoaderMock, + 'storeManager' => $this->storeManagerMock, + 'quoteAddressFactory' => $this->addressFactoryMock, + 'addressValidator' => $this->validatorMock, + 'addressConverter' => $this->converterMock, + ] + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expected ExceptionMessage error123 + */ + public function testSetAddressValidationFailed() + { + $storeId = 323; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once()) + ->method('load') + ->with('cartId', $storeId) + ->will($this->returnValue($quoteMock)); + + $this->validatorMock->expects($this->once())->method('validate') + ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error123'))); + + $this->service->setAddress('cartId', null); + } + + public function testSetAddress() + { + $storeId = 323; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once()) + ->method('load') + ->with('cartId', $storeId) + ->will($this->returnValue($quoteMock)); + + /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ + $addressDataBuilder = $this->objectManager->getObject('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ + $addressData = $addressDataBuilder->setId(454)->create(); + + $this->validatorMock->expects($this->once())->method('validate') + ->with($addressData) + ->will($this->returnValue(true)); + + $this->converterMock->expects($this->once())->method('convertDataObjectToModel') + ->with($addressData, $this->quoteAddressMock) + ->will($this->returnValue($this->quoteAddressMock)); + + $quoteMock->expects($this->once())->method('setBillingAddress')->with($this->quoteAddressMock); + $quoteMock->expects($this->once())->method('setDataChanges')->with(true); + $quoteMock->expects($this->once())->method('save'); + $addressId = 1; + $billingAddressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $billingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $quoteMock->expects($this->once())->method('getBillingAddress') + ->will($this->returnValue($billingAddressMock)); + + $this->assertEquals($addressId, $this->service->setAddress('cartId', $addressData)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.php new file mode 100644 index 00000000000..69ebcdeb324 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ConverterTest.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\Checkout\Service\V1\Address; + +use \Magento\Checkout\Service\V1\Data\Cart\Address; +use \Magento\Checkout\Service\V1\Data\Cart\Address\Region; +use \Magento\Framework\Service\Data\Eav\AttributeValue; + +class ConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Converter + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressBuilderMock; + + protected function setUp() + { + $this->addressBuilderMock = $this->getMock( + '\Magento\Checkout\Service\V1\Data\Cart\AddressBuilder', [], [], '', false + ); + + $this->model = new Converter($this->addressBuilderMock); + } + + public function testConvertModelToDataObject() + { + $addressMockMethods = [ + 'getCountryId', 'getId', 'getCustomerId', 'getRegion', 'getRegionId', 'getRegionCode', + 'getStreet', 'getCompany', 'getTelephone', 'getFax', 'getPostcode', 'getFirstname', 'getMiddlename', + 'getLastname', 'getPrefix', 'getSuffix', 'getEmail', 'getVatId', 'getCustomField', 'getCity', '__wakeup' + ]; + $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', $addressMockMethods, [], '', false); + + $addressMock->expects($this->atLeastOnce())->method('getCountryId')->will($this->returnValue(1)); + $addressMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); + $addressMock->expects($this->atLeastOnce())->method('getCustomerId')->will($this->returnValue(3)); + $addressMock->expects($this->atLeastOnce())->method('getRegion')->will($this->returnValue('Alabama')); + $addressMock->expects($this->atLeastOnce())->method('getRegionId')->will($this->returnValue(4)); + $addressMock->expects($this->atLeastOnce())->method('getRegionCode')->will($this->returnValue('aa')); + $addressMock->expects($this->atLeastOnce())->method('getStreet')->will($this->returnValue('street')); + $addressMock->expects($this->atLeastOnce())->method('getCompany')->will($this->returnValue('company')); + $addressMock->expects($this->atLeastOnce())->method('getTelephone')->will($this->returnValue('123-123')); + $addressMock->expects($this->atLeastOnce())->method('getFax')->will($this->returnValue('234-234')); + $addressMock->expects($this->atLeastOnce())->method('getPostcode')->will($this->returnValue('80010')); + $addressMock->expects($this->atLeastOnce())->method('getCity')->will($this->returnValue('Town')); + $addressMock->expects($this->atLeastOnce())->method('getFirstname')->will($this->returnValue('Vasya')); + $addressMock->expects($this->atLeastOnce())->method('getMiddlename')->will($this->returnValue('Vasya')); + $addressMock->expects($this->atLeastOnce())->method('getLastname')->will($this->returnValue('Pupkin')); + $addressMock->expects($this->atLeastOnce())->method('getPrefix')->will($this->returnValue('prefix')); + $addressMock->expects($this->atLeastOnce())->method('getSuffix')->will($this->returnValue('suffix')); + $addressMock->expects($this->atLeastOnce())->method('getEmail')->will($this->returnValue('aaa@aaa.com')); + $addressMock->expects($this->atLeastOnce())->method('getVatId')->will($this->returnValue(5)); + $addressMock->expects($this->atLeastOnce())->method('getCustomField')->will($this->returnValue('custom_value')); + + $testData = [ + Address::KEY_COUNTRY_ID => 1, + Address::KEY_ID => 2, + Address::KEY_CUSTOMER_ID => 3, + Address::KEY_REGION => [ + Region::KEY_REGION => 'Alabama', + Region::KEY_REGION_ID => 4, + Region::KEY_REGION_CODE => 'aa', + ], + Address::KEY_STREET => 'street', + Address::KEY_COMPANY => 'company', + Address::KEY_TELEPHONE => '123-123', + Address::KEY_FAX => '234-234', + Address::KEY_POSTCODE => '80010', + Address::KEY_CITY => 'Town', + Address::KEY_FIRSTNAME => 'Vasya', + Address::KEY_LASTNAME => 'Pupkin', + Address::KEY_MIDDLENAME => 'Vasya', + Address::KEY_PREFIX => 'prefix', + Address::KEY_SUFFIX => 'suffix', + Address::KEY_EMAIL => 'aaa@aaa.com', + Address::KEY_VAT_ID => 5, + Address::CUSTOM_ATTRIBUTES_KEY => [['attribute_code' => 'custom_field', 'value' => 'custom_value']] + ]; + + $this->addressBuilderMock->expects($this->any())->method('getCustomAttributesCodes')->will( + $this->returnValue(array('custom_field')) + ); + $this->addressBuilderMock->expects($this->once())->method('populateWithArray')->with($testData)->will( + $this->returnValue($this->addressBuilderMock) + ); + $this->addressBuilderMock->expects($this->once())->method('create')->will( + $this->returnValue('Expected value') + ); + + $this->assertEquals('Expected value', $this->model->convertModelToDataObject($addressMock)); + } + + public function testConvertDataObjectToModel() + { + $dataObjectMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Address', [], [], '', false); + $methods = ['setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeUp']; + $addressMock = $this->getMock('Magento\Sales\Model\Quote\Address', $methods, [], '', false); + $attributeValueMock = $this->getMock('\Magento\Framework\Service\Data\Eav\AttributeValue', [], [], '', false); + $attributeValueMock->expects($this->once())->method('getAttributeCode')->will($this->returnValue('value_code')); + $attributeValueMock->expects($this->once())->method('getValue')->will($this->returnValue('value')); + + $addressData = [ + 'some_code' => 'some_value' + ]; + $regionMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Address\Region', [], [], '', false); + + $dataObjectMock->expects($this->once())->method('__toArray')->will($this->returnValue($addressData)); + $valueMap = [ + [$addressData, null], + ['attribute_value', 'value'] + ]; + $addressMock->expects($this->any())->method('setData')->will($this->returnValueMap($valueMap)); + $dataObjectMock + ->expects($this->once()) + ->method('getCustomAttributes') + ->will($this->returnValue([$attributeValueMock])); + $dataObjectMock->expects($this->once())->method('getStreet')->will($this->returnValue('street')); + $addressMock->expects($this->once())->method('setStreet')->with('street'); + $dataObjectMock->expects($this->any())->method('getRegion')->will($this->returnValue($regionMock)); + $regionMock->expects($this->once())->method('getRegionId')->will($this->returnValue('regionId')); + $regionMock->expects($this->once())->method('getRegion')->will($this->returnValue('region')); + $addressMock->expects($this->once())->method('setRegionId')->with('regionId'); + $addressMock->expects($this->once())->method('setRegion')->with('region'); + $this->model->convertDataObjectToModel($dataObjectMock, $addressMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php new file mode 100644 index 00000000000..9c9f4f83871 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/ReadServiceTest.php @@ -0,0 +1,96 @@ +<?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\Checkout\Service\V1\Address\Shipping; + +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ReadService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + protected function setUp() + { + $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); + + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->any())->method('getId')->will($this->returnValue(123)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); + } + + public function testGetAddress() + { + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once())->method('load')->with('cartId', '123')->will( + $this->returnValue($quoteMock) + ); + + $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($addressMock)); + $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(false)); + + $this->converterMock->expects($this->once())->method('convertModelToDataObject') + ->with($addressMock)->will($this->returnValue('ShippingAddress')); + + $this->assertEquals('ShippingAddress', $this->service->getAddress('cartId')); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable + */ + public function testGetAddressOfQuoteWithVirtualProducts() + { + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once())->method('load')->with('cartId', '123')->will( + $this->returnValue($quoteMock) + ); + + $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue(true)); + $quoteMock->expects($this->never())->method('getShippingAddress'); + + $this->service->getAddress('cartId'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php new file mode 100644 index 00000000000..f51418ace43 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/Shipping/WriteServiceTest.php @@ -0,0 +1,205 @@ +<?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\Checkout\Service\V1\Address\Shipping; + +class WriteServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var WriteService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $converterMock; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->addressFactoryMock = $this->getMock( + '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false + ); + + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteAddressMock = $this->getMock( + '\Magento\Sales\Model\Quote\Address', + ['getCustomerId', 'load', 'getData', 'setData', 'setStreet', 'setRegionId', 'setRegion', '__wakeup'], + [], + '', + false + ); + $this->addressFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + + $this->validatorMock = $this->getMock( + '\Magento\Checkout\Service\V1\Address\Validator', [], [], '', false + ); + + $this->converterMock = $this->getMock( + '\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false + ); + + $this->service = $this->objectManager->getObject( + '\Magento\Checkout\Service\V1\Address\Shipping\WriteService', + [ + 'quoteLoader' => $this->quoteLoaderMock, + 'storeManager' => $this->storeManagerMock, + 'quoteAddressFactory' => $this->addressFactoryMock, + 'addressValidator' => $this->validatorMock, + 'addressConverter' => $this->converterMock, + ] + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expected ExceptionMessage error345 + */ + public function testSetAddressValidationFailed() + { + $storeId = 554; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once()) + ->method('load') + ->with('cart654', $storeId) + ->will($this->returnValue($quoteMock)); + + $this->validatorMock->expects($this->once())->method('validate') + ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error345'))); + + $this->service->setAddress('cart654', null); + } + + public function testSetAddress() + { + $storeId = 323; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once()) + ->method('load') + ->with('cart867', $storeId) + ->will($this->returnValue($quoteMock)); + $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); + + /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ + $addressDataBuilder = $this->objectManager->getObject('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + + /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ + $addressData = $addressDataBuilder->setId(356)->create(); + + $this->validatorMock->expects($this->once())->method('validate') + ->with($addressData) + ->will($this->returnValue(true)); + + $this->converterMock->expects($this->once())->method('convertDataObjectToModel') + ->with($addressData, $this->quoteAddressMock) + ->will($this->returnValue($this->quoteAddressMock)); + + $quoteMock->expects($this->once())->method('setShippingAddress')->with($this->quoteAddressMock); + $quoteMock->expects($this->once())->method('setDataChanges')->with(true); + $quoteMock->expects($this->once())->method('save'); + + $addressId = 1; + $shippingAddressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $shippingAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $quoteMock->expects($this->once())->method('getShippingAddress') + ->will($this->returnValue($shippingAddressMock)); + + $this->assertEquals($addressId, $this->service->setAddress('cart867', $addressData)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable + */ + public function testSetAddressForVirtualProduct() + { + $storeId = 323; + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once()) + ->method('load') + ->with('cart867', $storeId) + ->will($this->returnValue($quoteMock)); + $quoteMock->expects($this->once())->method('isVirtual')->will($this->returnValue(true)); + + /** @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder $addressDataBuilder */ + $addressDataBuilder = $this->objectManager->getObject('Magento\Checkout\Service\V1\Data\Cart\AddressBuilder'); + + /** @var \Magento\Checkout\Service\V1\Data\Cart\Address $addressData */ + $addressData = $addressDataBuilder->setId(356)->create(); + + $this->validatorMock->expects($this->never())->method('validate'); + + $quoteMock->expects($this->never())->method('setShippingAddress'); + $quoteMock->expects($this->never())->method('save'); + + $this->service->setAddress('cart867', $addressData); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.php new file mode 100644 index 00000000000..7b81d325859 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Address/ValidatorTest.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\Checkout\Service\V1\Address; + +use \Magento\Checkout\Service\V1\Data\Cart\Address; +use \Magento\Checkout\Service\V1\Data\Cart\Address\Region; + +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Checkout\Service\V1\Address\Validator + */ + protected $model; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $addressFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressMock; + + /** + * @var \Magento\Checkout\Service\V1\Data\Cart\AddressBuilder + */ + protected $addressDataBuilder; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + public function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->addressFactoryMock = $this->getMock( + '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false + ); + $this->quoteAddressMock = $this->getMock( + '\Magento\Sales\Model\Quote\Address', + ['getCustomerId', 'load', 'getId', '__wakeup'], + [], + '', + false + ); + $this->customerFactoryMock = $this->getMock( + '\Magento\Customer\Model\CustomerFactory', ['create', '__wakeup'], [], '', false) + ; + $this->customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + + $this->addressDataBuilder = $this->objectManager->getObject( + '\Magento\Checkout\Service\V1\Data\Cart\AddressBuilder' + ); + + $this->model = $this->objectManager->getObject( + '\Magento\Checkout\Service\V1\Address\Validator', + [ + 'quoteAddressFactory' => $this->addressFactoryMock, + 'customerFactory' => $this->customerFactoryMock, + ] + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Invalid customer id 100 + */ + public function testValidateInvalidCustomer() + { + $customerId = 100; + + $this->customerFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->customerMock)); + + $this->customerMock->expects($this->once())->method('load')->with($customerId); + $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + + $addressData = $this->addressDataBuilder + ->setCustomerId($customerId) + ->setCompany('eBay Inc') + ->create(); + $this->model->validate($addressData); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Invalid address id 101 + */ + public function testValidateInvalidAddress() + { + $this->customerFactoryMock->expects($this->never())->method('create'); + $this->customerMock->expects($this->never())->method('load'); + + $this->addressFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + + + $addressData = $this->addressDataBuilder + ->setId(101) + ->setCompany('eBay Inc') + ->create(); + $this->model->validate($addressData); + } + + /** + * Neither customer id used nor address id exists + */ + public function testValidateNewAddress() + { + $this->customerFactoryMock->expects($this->never())->method('create'); + $this->addressFactoryMock->expects($this->never())->method('create'); + + $addressData = $this->addressDataBuilder->setCompany('eBay Inc')->create(); + $this->assertTrue($this->model->validate($addressData)); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Address with id 100 belongs to another customer + */ + public function testValidateWithAddressOfOtherCustomer() + { + $addressCustomer = 100; + $addressId = 100; + + /** Address data object */ + $addressData = $this->addressDataBuilder + ->setId($addressId) + ->setCompany('eBay Inc') + ->setCustomerId($addressCustomer) + ->create(); + + /** Customer mock */ + $this->customerFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->customerMock)); + + $this->customerMock->expects($this->once())->method('load')->with($addressCustomer); + $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue($addressCustomer)); + + /** Quote address mock */ + $this->addressFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + + $this->quoteAddressMock->expects($this->once())->method('load')->with($addressId); + $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $this->quoteAddressMock->expects($this->any())->method('getCustomerId') + ->will($this->returnValue(10)); + + /** Validate */ + $this->model->validate($addressData); + } + + + public function testValidateWithValidAddress() + { + $addressCustomer = 100; + $addressId = 100; + + /** Address data object */ + $addressData = $this->addressDataBuilder + ->setId($addressId) + ->setCompany('eBay Inc') + ->setCustomerId($addressCustomer) + ->create(); + + /** Customer mock */ + $this->customerFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->customerMock)); + + $this->customerMock->expects($this->once())->method('load')->with($addressCustomer); + $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue($addressCustomer)); + + /** Quote address mock */ + $this->addressFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + + $this->quoteAddressMock->expects($this->once())->method('load')->with($addressId); + $this->quoteAddressMock->expects($this->once())->method('getId')->will($this->returnValue($addressId)); + $this->quoteAddressMock->expects($this->any())->method('getCustomerId') + ->will($this->returnValue($addressCustomer)); + + /** Validate */ + $this->model->validate($addressData); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php new file mode 100644 index 00000000000..063530e44c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/ReadServiceTest.php @@ -0,0 +1,380 @@ +<?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\Checkout\Service\V1\Cart; + +use \Magento\Checkout\Service\V1\Data\Cart; +use \Magento\Checkout\Service\V1\Data\Cart\Totals; +use \Magento\Checkout\Service\V1\Data\Cart\Customer; +use \Magento\Framework\Service\V1\Data\SearchCriteria; +use \Magento\Checkout\Service\V1\Data\Cart\Currency; + +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ReadService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteCollectionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cartBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $totalsBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $currencyBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteFactoryMock = + $this->getMock('\Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); + $methods = [ + 'getId', 'getStoreId', 'getCreatedAt', 'getUpdatedAt', 'getConvertedAt', + 'getIsActive', 'getIsVirtual', 'getItemsCount', 'getItemsQty', 'getCheckoutMethod', 'getReservedOrderId', + 'getOrigOrderId', 'getBaseGrandTotal', 'getBaseSubtotal', 'getSubtotal', 'getBaseSubtotalWithDiscount', + 'getSubtotalWithDiscount', 'getCustomerId', 'getCustomerEmail', 'getCustomerGroupId', + 'getCustomerTaxClassId', 'getCustomerPrefix', 'getCustomerFirstname', 'getCustomerMiddlename', + 'getCustomerLastname', 'getCustomerSuffix', 'getCustomerDob', 'getCustomerNote', 'getCustomerNoteNotify', + 'getCustomerIsGuest', 'getCustomerGender', 'getCustomerTaxvat', '__wakeup', 'load', 'getGrandTotal', + 'getGlobalCurrencyCode', 'getBaseCurrencyCode', 'getStoreCurrencyCode', 'getQuoteCurrencyCode', + 'getStoreToBaseRate', 'getStoreToQuoteRate', 'getBaseToGlobalRate', 'getBaseToQuoteRate', + ]; + $this->quoteMock = $this->getMock('\Magento\Sales\Model\Quote', $methods, [], '', false); + $this->quoteCollectionMock = $objectManager->getCollectionMock( + '\Magento\Sales\Model\Resource\Quote\Collection', [$this->quoteMock]); + $this->cartBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\CartBuilder', [], [], '', false); + $this->searchResultsBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\CartSearchResultsBuilder', [], [], '', false); + $this->totalsBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder', [], [], '', false); + $this->customerBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CustomerBuilder', [], [], '', false); + $this->currencyBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CurrencyBuilder', [], [], '', false); + + $this->service = new ReadService( + $this->quoteFactoryMock, + $this->quoteCollectionMock, + $this->cartBuilderMock, + $this->searchResultsBuilderMock, + $this->totalsBuilderMock, + $this->customerBuilderMock, + $this->currencyBuilderMock + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage There is no cart with provided ID. + */ + public function testGetCartWithNoSuchEntityException() + { + $cartId = 12; + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(13)); + $this->cartBuilderMock->expects($this->never())->method('populateWithArray'); + + $this->service->getCart($cartId); + } + + public function testGetCartSuccess() + { + $cartId = 12; + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->any())->method('getId')->will($this->returnValue($cartId)); + $this->cartBuilderMock->expects($this->once())->method('populateWithArray'); + $this->totalsBuilderMock->expects($this->once())->method('populateWithArray'); + $this->customerBuilderMock->expects($this->once())->method('populateWithArray'); + $this->currencyBuilderMock->expects($this->once())->method('populateWithArray'); + $this->cartBuilderMock->expects($this->once())->method('setCustomer'); + $this->cartBuilderMock->expects($this->once())->method('setTotals'); + $this->cartBuilderMock->expects($this->once())->method('setCurrency'); + $this->cartBuilderMock->expects($this->once())->method('create'); + + $this->service->getCart($cartId); + } + + /** + * @param int $direction + * @param string $expected + * @dataProvider getCartListSuccessDataProvider + */ + public function testGetCartListSuccess($direction, $expected) + { + $searchResult = $this->getMock('\Magento\Checkout\Service\V1\Data\CartSearchResults', [], [], '', false); + $searchCriteriaMock = $this->getMock('\Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + $totalMock = $this->getMock('Magento\Sales\Model\Order\Total', [], [], '', false); + $cartMock = $this->getMock('Magento\Payment\Model\Cart', [], [], '', false); + $currencyMock = $this->getMock('Magento\Checkout\Service\V1\Data\Cart\Currency', [], [], '', false); + $this->searchResultsBuilderMock + ->expects($this->once()) + ->method('setSearchCriteria') + ->will($this->returnValue($searchCriteriaMock)); + $filterGroupMock = $this->getMock('\Magento\Framework\Service\V1\Data\Search\FilterGroup', [], [], '', false); + $searchCriteriaMock + ->expects($this->any()) + ->method('getFilterGroups') + ->will($this->returnValue([$filterGroupMock])); + $filterMock = $this->getMock('\Magento\Framework\Service\V1\Data\Filter', [], [], '', false); + $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); + $filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id')); + $filterMock->expects($this->any())->method('getConditionType')->will($this->returnValue('eq')); + $filterMock->expects($this->once())->method('getValue')->will($this->returnValue('filter_value')); + $this->quoteCollectionMock + ->expects($this->once()) + ->method('addFieldToFilter') + ->with(['store_id'], [0 => ['eq' => 'filter_value']]); + + $this->quoteCollectionMock->expects($this->once())->method('getSize')->will($this->returnValue(10)); + $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(10); + + $searchCriteriaMock + ->expects($this->once()) + ->method('getSortOrders') + ->will($this->returnValue(['id' => $direction])); + $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('entity_id', $expected); + $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1)); + $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10)); + $this->getTotalData(); + $this->getCartData(); + $this->getCustomerData(); + $this->setCurrencyDataExpectations(); + $this->currencyBuilderMock->expects($this->once())->method('create')->will($this->returnValue($currencyMock)); + $this->cartBuilderMock->expects($this->once())->method('setCurrency')->with($currencyMock); + + $this->customerBuilderMock->expects($this->once())->method('create')->will($this->returnValue($customerMock)); + $this->cartBuilderMock->expects($this->once())->method('setCustomer')->with($customerMock); + $this->totalsBuilderMock->expects($this->once())->method('create')->will($this->returnValue($totalMock)); + $this->cartBuilderMock->expects($this->once())->method('setTotals')->will($this->returnValue($totalMock)); + $this->cartBuilderMock->expects($this->once())->method('create')->will($this->returnValue($cartMock)); + $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$cartMock]); + $this->searchResultsBuilderMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($searchResult)); + $this->assertEquals($searchResult, $this->service->getCartList($searchCriteriaMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Field 'any_value' cannot be used for search. + */ + public function testGetCartListWithNotExistingField() + { + $searchCriteriaMock = $this->getMock('\Magento\Framework\Service\V1\Data\SearchCriteria', [], [], '', false); + $this->searchResultsBuilderMock + ->expects($this->once()) + ->method('setSearchCriteria') + ->will($this->returnValue($searchCriteriaMock)); + + $filterGroupMock = $this->getMock('\Magento\Framework\Service\V1\Data\Search\FilterGroup', [], [], '', false); + $searchCriteriaMock + ->expects($this->any()) + ->method('getFilterGroups') + ->will($this->returnValue([$filterGroupMock])); + $filterMock = $this->getMock('\Magento\Framework\Service\V1\Data\Filter', [], [], '', false); + $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock])); + $filterMock->expects($this->once())->method('getField')->will($this->returnValue('any_value')); + $filterMock->expects($this->never())->method('getConditionType'); + $this->service->getCartList($searchCriteriaMock); + } + + public function getCartListSuccessDataProvider() + { + return [ + 'asc' => [SearchCriteria::SORT_ASC, 'ASC'], + 'desc' => [SearchCriteria::SORT_DESC, 'DESC'] + ]; + } + + protected function getCartData() + { + $expected = [ + Cart::ID => 10, + Cart::STORE_ID => 1, + Cart::CREATED_AT => '2014-04-02 12:28:50', + Cart::UPDATED_AT => '2014-04-02 12:28:50', + Cart::CONVERTED_AT => '2014-04-02 12:28:50', + Cart::IS_ACTIVE => true, + Cart::IS_VIRTUAL => false, + Cart::ITEMS_COUNT => 10, + Cart::ITEMS_QUANTITY => 15, + Cart::CHECKOUT_METHOD => 'check mo', + Cart::RESERVED_ORDER_ID => 'order_id', + Cart::ORIG_ORDER_ID => 'orig_order_id' + ]; + $expectedMethods = [ + 'getId' => 10, + 'getStoreId' => 1, + 'getCreatedAt' => '2014-04-02 12:28:50', + 'getUpdatedAt' => '2014-04-02 12:28:50', + 'getConvertedAt' => '2014-04-02 12:28:50', + 'getIsActive' => true, + 'getIsVirtual' => false, + 'getItemsCount' => 10, + 'getItemsQty' => 15, + 'getCheckoutMethod' => 'check mo', + 'getReservedOrderId' => 'order_id', + 'getOrigOrderId' => 'orig_order_id' + ]; + foreach ($expectedMethods as $method => $value) { + $this->quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); + } + $this->cartBuilderMock->expects($this->once())->method('populateWithArray')->with($expected); + } + + protected function getTotalData() + { + $expected = [ + Totals::BASE_GRAND_TOTAL => 100, + Totals::GRAND_TOTAL => 150, + Totals::BASE_SUBTOTAL => 150, + Totals::SUBTOTAL => 150, + Totals::BASE_SUBTOTAL_WITH_DISCOUNT => 120, + Totals::SUBTOTAL_WITH_DISCOUNT => 120, + ]; + $expectedMethods = [ + 'getBaseGrandTotal' => 100, + 'getGrandTotal' => 150, + 'getBaseSubtotal' => 150, + 'getSubtotal' => 150, + 'getBaseSubtotalWithDiscount' => 120, + 'getSubtotalWithDiscount' => 120 + ]; + foreach ($expectedMethods as $method => $value) { + $this->quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); + } + $this->totalsBuilderMock->expects($this->once())->method('populateWithArray')->with($expected); + } + + protected function getCustomerData() + { + $expected = [ + Customer::ID => 10, + Customer::EMAIL => 'customer@example.com', + Customer::GROUP_ID => '4', + Customer::TAX_CLASS_ID => 10, + Customer::PREFIX => 'prefix_', + Customer::FIRST_NAME => 'First Name', + Customer::MIDDLE_NAME => 'Middle Name', + Customer::LAST_NAME => 'Last Name', + Customer::SUFFIX => 'suffix', + Customer::DOB => '1/1/1989', + Customer::NOTE => 'customer_note', + Customer::NOTE_NOTIFY => 'note_notify', + Customer::IS_GUEST => false, + Customer::GENDER => 'male', + Customer::TAXVAT => 'taxvat', + ]; + $expectedMethods = [ + 'getCustomerId' => 10, + 'getCustomerEmail' => 'customer@example.com', + 'getCustomerGroupId' => 4, + 'getCustomerTaxClassId' => 10, + 'getCustomerPrefix' => 'prefix_', + 'getCustomerFirstname' => 'First Name', + 'getCustomerMiddlename' => 'Middle Name', + 'getCustomerLastname' => 'Last Name', + 'getCustomerSuffix' => 'suffix', + 'getCustomerDob' => '1/1/1989', + 'getCustomerNote' => 'customer_note', + 'getCustomerNoteNotify' => 'note_notify', + 'getCustomerIsGuest' => false, + 'getCustomerGender' => 'male', + 'getCustomerTaxvat' => 'taxvat', + ]; + foreach ($expectedMethods as $method => $value) { + $this->quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); + } + $this->customerBuilderMock->expects($this->once())->method('populateWithArray')->with($expected); + } + + protected function setCurrencyDataExpectations() + { + $expected = [ + Currency::GLOBAL_CURRENCY_CODE => 'USD', + Currency::BASE_CURRENCY_CODE => 'EUR', + Currency::STORE_CURRENCY_CODE => 'USD', + Currency::QUOTE_CURRENCY_CODE => 'EUR', + Currency::STORE_TO_BASE_RATE => 1, + Currency::STORE_TO_QUOTE_RATE => 2, + Currency::BASE_TO_GLOBAL_RATE => 3, + Currency::BASE_TO_QUOTE_RATE => 4, + ]; + $expectedMethods = [ + 'getGlobalCurrencyCode' => 'USD', + 'getBaseCurrencyCode' => 'EUR', + 'getStoreCurrencyCode' => 'USD', + 'getQuoteCurrencyCode' => 'EUR', + 'getStoreToBaseRate' => 1, + 'getStoreToQuoteRate' => 2, + 'getBaseToGlobalRate' => 3, + 'getBaseToQuoteRate' => 4, + ]; + foreach ($expectedMethods as $method => $value) { + $this->quoteMock->expects($this->once())->method($method)->will($this->returnValue($value)); + } + $this->currencyBuilderMock->expects($this->once())->method('populateWithArray')->with($expected); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php new file mode 100644 index 00000000000..cdfe50596c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php @@ -0,0 +1,268 @@ +<?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\Checkout\Service\V1\Cart; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Framework\Exception\CouldNotSaveException; + +class WriteServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Checkout\Service\V1\Cart\WriteService + */ + protected $service; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $customerRegistryMock; + + public function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->quoteFactoryMock = $this->getMock( + '\Magento\Sales\Model\QuoteFactory', ['create', '__wakeup'], [], '', false + ); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + + $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->quoteMock = + $this->getMock('\Magento\Sales\Model\Quote', + [ + 'setStoreId', + 'save', + 'load', + 'getId', + 'getStoreId', + 'getCustomerId', + 'setCustomer', + 'setCustomerIsGuest', + '__wakeup' + ], + [], '', false); + + $this->customerRegistryMock = + $this->getMock('\Magento\Customer\Model\CustomerRegistry', [], [], '', false); + $this->service = $this->objectManager->getObject( + '\Magento\Checkout\Service\V1\Cart\WriteService', + [ + 'quoteFactory' => $this->quoteFactoryMock, + 'storeManager' => $this->storeManagerMock, + 'customerRegistry' => $this->customerRegistryMock + ] + ); + } + + public function testCreate() + { + $storeId = 345; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); + $this->quoteMock->expects($this->once())->method('save'); + + $this->service->create(); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Cannot create quote + */ + public function testCreateWithException() + { + $storeId = 345; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('setStoreId')->with($storeId); + $this->quoteMock->expects($this->once())->method('save') + ->will($this->throwException(new CouldNotSaveException('Cannot create quote'))); + + $this->service->create(); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage There is no cart with provided ID. + */ + public function testAssignCustomerNoSuchEntityExceptionByCartId() + { + $cartId = 956; + $customerId = 125; + $storeId = 12; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(33)); + $customerRegistryMock = + $this->getMock('\Magento\Customer\Model\CustomerRegistry', [], [], '', false); + $customerRegistryMock->expects($this->never())->method('retrieve'); + + $this->service->assignCustomer($cartId, $customerId); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage There is no cart with provided ID. + */ + public function testAssignCustomerNoSuchEntityExceptionByStoreId() + { + $cartId = 956; + $customerId = 125; + $storeId = 12; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); + $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(99)); + + $this->customerRegistryMock->expects($this->never())->method('retrieve'); + + $this->service->assignCustomer($cartId, $customerId); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Cannot assign customer to the given cart. The cart belongs to different store. + */ + public function testAssignCustomerStateExceptionWithStoreId() + { + $cartId = 956; + $customerId = 125; + $storeId = 12; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); + $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); + $customerMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([11])); + + $this->service->assignCustomer($cartId, $customerId); + } + + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage Cannot assign customer to the given cart. The cart is not anonymous. + */ + public function testAssignCustomerStateExceptionWithCustomerId() + { + $cartId = 956; + $customerId = 125; + $storeId = 12; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); + $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); + $customerMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); + $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId)); + $this->quoteMock->expects($this->never())->method('setCustomer'); + + $this->service->assignCustomer($cartId, $customerId); + } + + public function testAssignCustomer() + { + $cartId = 956; + $customerId = 125; + $storeId = 12; + + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId)); + $this->quoteFactoryMock->expects($this->at(0))->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('load')->with($cartId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue($cartId)); + $this->quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId)); + $customerMock = $this->getMock('\Magento\Customer\Model\Customer', [], [], '', false); + $this->customerRegistryMock->expects($this->once()) + ->method('retrieve')->with($customerId)->will($this->returnValue($customerMock)); + + $customerQuoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $customerQuoteMock->expects($this->once())->method('loadByCustomer')->with($customerMock) + ->will($this->returnSelf()); + $this->quoteFactoryMock->expects($this->at(1))->method('create')->will($this->returnValue($customerQuoteMock)); + + $customerMock->expects($this->once())->method('getSharedStoreIds')->will($this->returnValue([$storeId])); + $this->quoteMock->expects($this->once())->method('getCustomerId')->will($this->returnValue(false)); + $this->quoteMock->expects($this->once()) + ->method('setCustomer')->with($customerMock)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('setCustomerIsGuest')->with(0)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('save')->will($this->returnValue($this->quoteMock)); + + $this->assertTrue($this->service->assignCustomer($cartId, $customerId)); + } + +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.php new file mode 100644 index 00000000000..990691411db --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/ReaderServiceTest.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\Checkout\Service\V1\Item; + +use \Magento\Checkout\Service\V1\Data\Cart\Item as Item; + +class ReaderServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ReadService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + protected function setUp() + { + $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->itemBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ItemBuilder', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->service = new ReadService($this->quoteLoaderMock, $this->itemBuilderMock, $this->storeManagerMock); + } + + public function testGetList() + { + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); + $storeMock->expects($this->once())->method('getId')->will($this->returnValue(11)); + $quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->quoteLoaderMock->expects($this->once())->method('load') + ->with(33, 11) + ->will($this->returnValue($quoteMock)); + $itemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', + ['getSku', 'getName', 'getPrice', 'getQty', 'getProductType', '__wakeup'], [], '', false); + $quoteMock->expects($this->any())->method('getAllItems')->will($this->returnValue(array($itemMock))); + $itemMock->expects($this->any())->method('getSku')->will($this->returnValue('prd_SKU')); + $itemMock->expects($this->any())->method('getName')->will($this->returnValue('prd_NAME')); + $itemMock->expects($this->any())->method('getPrice')->will($this->returnValue(100.15)); + $itemMock->expects($this->any())->method('getQty')->will($this->returnValue(16)); + $itemMock->expects($this->any())->method('getProductType')->will($this->returnValue('simple')); + $testData = [ + Item::SKU => 'prd_SKU', + Item::NAME => 'prd_NAME', + Item::PRICE => 100.15, + Item::QTY => 16, + Item::TYPE => 'simple', + ]; + $this->itemBuilderMock->expects($this->once()) + ->method('populateWithArray') + ->with($testData) + ->will($this->returnValue($this->itemBuilderMock)); + $this->itemBuilderMock->expects($this->once())->method('create')->will($this->returnValue('Expected value')); + + $this->assertEquals(array('Expected value'), $this->service->getList(33)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php new file mode 100644 index 00000000000..ca0628c1f6d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Item/WriteServiceTest.php @@ -0,0 +1,332 @@ +<?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\Checkout\Service\V1\Item; + +class WriteServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var WriteService + */ + protected $service; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productLoaderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $dataMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteItemMock; + + protected function setUp() + { + $this->quoteLoaderMock = + $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); + $this->itemBuilderMock = + $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ItemBuilder', [], [], '', false); + $this->productLoaderMock = + $this->getMock('\Magento\Catalog\Service\V1\Product\ProductLoader', [], [], '', false); + $this->storeManagerMock = + $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->dataMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\Item', [], [], '', false); + $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); + $this->quoteMock = $this->getMock('\Magento\Sales\Model\Quote', [], [], '', false); + $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', [], [], '', false); + + $this->service = new WriteService($this->quoteLoaderMock, $this->itemBuilderMock, + $this->productLoaderMock, $this->storeManagerMock); + } + + /** + * @param null|string|bool|int|float $value + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Invalid value of + * @dataProvider addItemWithInvalidQtyDataProvider + */ + public function testAddItemWithInvalidQty($value) + { + $cartId = 12; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue($value)); + $this->storeManagerMock->expects($this->never())->method('getStore'); + + $this->service->addItem($cartId, $this->dataMock); + } + + public function addItemWithInvalidQtyDataProvider() + { + return array( + array('string'), + array(0), + array(''), + array(null), + array(-12), + array(false), + array(-13.1), + ); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Could not add item to quote + */ + public function testAddItemCouldNotSaveException() + { + $cartId = 13; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once())->method('load') + ->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->dataMock->expects($this->once())->method('getSku')->will($this->returnValue('product_sku')); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with('product_sku')->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $exceptionMessage = 'Could not add item to quote'; + $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $this->quoteMock->expects($this->once())->method('save')->will($this->throwException($exception)); + + $this->service->addItem($cartId, $this->dataMock); + } + + public function testAddItem() + { + $cartId = 13; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->productMock)); + $this->dataMock->expects($this->once())->method('getSku'); + $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('save'); + + $this->assertTrue($this->service->addItem($cartId, $this->dataMock)); + } + + /** + * @param null|string|bool|int|float $value + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage Invalid value of + * @dataProvider updateItemWithInvalidQtyDataProvider + */ + public function testUpdateItemWithInvalidQty($value) + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue($value)); + $this->storeManagerMock->expects($this->never())->method('getStore'); + $this->service->updateItem($cartId, $itemSku, $this->dataMock); + } + + public function updateItemWithInvalidQtyDataProvider() + { + return array( + array('string'), + array(0), + array(''), + array(null), + array(-12), + array(false), + array(-13.1), + ); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Cart 11 doesn't contain product item_sku + */ + public function testUpdateItemWithInvalidQuoteItem() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue(false)); + $this->quoteItemMock->expects($this->never())->method('setData'); + + $this->service->updateItem($cartId, $itemSku, $this->dataMock); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Could not update quote item + */ + public function testUpdateItemWithCouldNotSaveException() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue($this->quoteItemMock)); + $this->quoteItemMock->expects($this->once())->method('setData')->with('qty', 12); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $exceptionMessage = 'Could not update quote item'; + $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $this->quoteMock->expects($this->once())->method('save')->will($this->throwException($exception)); + + $this->service->updateItem($cartId, $itemSku, $this->dataMock); + } + + public function testUpdateItem() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12)); + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue($this->quoteItemMock)); + $this->quoteItemMock->expects($this->once())->method('setData')->with('qty', 12); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('save')->will($this->returnValue($this->quoteMock)); + + $this->assertTrue($this->service->updateItem($cartId, $itemSku, $this->dataMock)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Cart 11 doesn't contain product item_sku + */ + public function testRemoveItemWithInvalidQuoteItem() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue(false)); + $this->quoteMock->expects($this->never())->method('removeItem'); + + $this->service->removeItem($cartId, $itemSku, $this->dataMock); + } + + /** + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @expectedExceptionMessage Could not remove item from quote + */ + public function testRemoveItemWithCouldNotSaveException() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue($this->quoteItemMock)); + $this->quoteItemMock->expects($this->once())->method('getId')->will($this->returnValue(33)); + $this->quoteMock->expects($this->once()) + ->method('removeItem')->with(33)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $exceptionMessage = 'Could not remove item from quote'; + $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $this->quoteMock->expects($this->once())->method('save')->will($this->throwException($exception)); + + $this->service->removeItem($cartId, $itemSku, $this->dataMock); + } + + public function testRemoveItem() + { + $cartId = 11; + $itemSku = 'item_sku'; + $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); + $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue(0)); + $this->quoteLoaderMock->expects($this->once()) + ->method('load')->with($cartId, 0)->will($this->returnValue($this->quoteMock)); + $this->productLoaderMock->expects($this->once()) + ->method('load')->with($itemSku)->will($this->returnValue($this->productMock)); + $this->quoteMock->expects($this->once()) + ->method('getItemByProduct')->with($this->productMock)->will($this->returnValue($this->quoteItemMock)); + $this->quoteMock->expects($this->once())->method('removeItem'); + $this->quoteItemMock->expects($this->once())->method('getId'); + $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('save')->will($this->returnValue($this->quoteMock)); + + $this->assertTrue($this->service->removeItem($cartId, $itemSku, $this->dataMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.php new file mode 100644 index 00000000000..68e2bd150cd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/QuoteLoaderTest.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\Checkout\Service\V1; + +class QuoteLoaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var QuoteLoader + */ + protected $quoteLoader; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteMock; + + protected function setUp() + { + $this->quoteFactoryMock = $this->getMock('\Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); + $this->quoteMock = + $this->getMock('\Magento\Sales\Model\Quote', ['setStoreId', 'load', 'getId', '__wakeup'], [], '', false); + $this->quoteLoader = new QuoteLoader($this->quoteFactoryMock); + } + + public function testLoadWithId() + { + $storeId = 1; + $cartId = 45; + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('setStoreId')->with($storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('load')->with($cartId); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(33)); + + $this->assertEquals($this->quoteMock, $this->quoteLoader->load($cartId, $storeId)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage No such entity with cartId = 34 + */ + public function testLoadWithoutId() + { + $storeId = 12; + $cartId = 34; + $this->quoteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once()) + ->method('setStoreId')->with($storeId)->will($this->returnValue($this->quoteMock)); + $this->quoteMock->expects($this->once())->method('load')->with($cartId); + $this->quoteMock->expects($this->once())->method('getId')->will($this->returnValue(false)); + $this->quoteLoader->load($cartId, $storeId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Export/RowCustomizerTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableImportExport/Model/Export/RowCustomizerTest.php similarity index 97% rename from dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Export/RowCustomizerTest.php rename to dev/tests/unit/testsuite/Magento/ConfigurableImportExport/Model/Export/RowCustomizerTest.php index 87b43a19e22..a4ee610edb8 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Export/RowCustomizerTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableImportExport/Model/Export/RowCustomizerTest.php @@ -21,12 +21,12 @@ * @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\Export; +namespace Magento\ConfigurableImportExport\Model\Export; class RowCustomizerTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\CatalogImportExport\Model\Export\RowCustomizer + * @var \Magento\ConfigurableImportExport\Model\Export\RowCustomizer */ protected $_model; @@ -44,7 +44,7 @@ class RowCustomizerTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_model = new \Magento\CatalogImportExport\Model\Export\RowCustomizer; + $this->_model = new \Magento\ConfigurableImportExport\Model\Export\RowCustomizer; } public function testPrepareData() 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 new file mode 100644 index 00000000000..4595b470f15 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Data/OptionConverterTest.php @@ -0,0 +1,185 @@ +<?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\Service\V1\Data; + +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory; +use Magento\TestFramework\Helper\ObjectManager; + +class OptionConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionConverter + */ + private $converter; + + /** + * @var Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + private $configurableAttribute; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $option; + + /** + * @var AttributeFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeFactory; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option\ValueConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $valueConverter; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option\Value|\PHPUnit_Framework_MockObject_MockObject + */ + private $value; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->configurableAttribute = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute' + ) + ->setMethods( + [ + 'setData', + 'getData', + 'addData', + '__wakeup', + 'getId', + 'setId', + 'getAttributeId', + 'setAttributeId', + 'setValues', + ] + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->option = $this->getMockBuilder('Magento\ConfigurableProduct\Service\V1\Data\Option') + ->setMethods(['__toArray', 'getValues']) + ->disableOriginalConstructor() + ->getMock(); + + $this->valueConverter = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Service\V1\Data\Option\ValueConverter' + ) + ->setMethods(['convertArrayFromData']) + ->disableOriginalConstructor() + ->getMock(); + + $this->value = $this->getMockBuilder('Magento\ConfigurableProduct\Service\V1\Data\Option\Value') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeFactory = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->attributeFactory->expects($this->any())->method('create') + ->will($this->returnValue($this->configurableAttribute)); + + $this->converter = $helper->getObject( + 'Magento\ConfigurableProduct\Service\V1\Data\OptionConverter', + ['attributeFactory' => $this->attributeFactory, 'valueConverter' => $this->valueConverter] + ); + } + + public function testConvertFromModel() + { + $converterMock = $this->getMockBuilder('Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getData', 'getLabel', '__sleep', '__wakeup', 'getProductAttribute']) + ->getMock(); + + $productAttribute = $this->getMockBuilder('Magento\Catalog\Model\Resource\Eav\Attribute') + ->disableOriginalConstructor() + ->setMethods(['getFrontend', '__wakeup']) + ->getMock(); + + $frontend = $this->getMockBuilder('Magento\Eav\Model\Entity\Attribute\Frontend\DefaultFrontend') + ->disableOriginalConstructor() + ->setMethods(['getInputType']) + ->getMock(); + + $productAttribute->expects($this->any())->method('getFrontend')->will($this->returnValue($frontend)); + $frontend->expects($this->once())->method('getInputType')->will($this->returnValue('select')); + + $prices = ['value_index' => 1, 'pricing_value' => 12, 'is_percent' => true]; + $converterMock->expects($this->at(0))->method('getData')->with('prices')->will($this->returnValue([$prices])); + $converterMock->expects($this->once())->method('getId')->will($this->returnValue(1)); + $converterMock->expects($this->at(2))->method('getData')->with('attribute_id')->will($this->returnValue(2)); + $converterMock->expects($this->once())->method('getLabel')->will($this->returnValue('Test Label')); + $converterMock->expects($this->any())->method('getProductAttribute') + ->will($this->returnValue($productAttribute)); + $converterMock->expects($this->at(5))->method('getData')->with('position')->will($this->returnValue(3)); + $converterMock->expects($this->at(6))->method('getData')->with('use_default')->will($this->returnValue(true)); + + /** @var \Magento\ConfigurableProduct\Service\V1\Data\Option $option */ + $option = $this->converter->convertFromModel($converterMock); + + $this->assertEquals(1, $option->getId()); + $this->assertEquals(2, $option->getAttributeId()); + $this->assertEquals('Test Label', $option->getLabel()); + $this->assertEquals(3, $option->getPosition()); + + /** @var \Magento\ConfigurableProduct\Service\V1\Data\Option\Value $value */ + $value = \current($option->getValues()); + $this->assertEquals(1, $value->getIndex()); + $this->assertEquals(12, $value->getPrice()); + $this->assertEquals(true, $value->isPercent()); + } + + public function testGetModelFromData() + { + $data = ['data']; + $id = 33; + $this->configurableAttribute->expects($this->any())->method('getData')->will($this->returnValue($data)); + $this->configurableAttribute->expects($this->once())->method('setData')->with($this->equalTo($data)); + $this->configurableAttribute->expects($this->once())->method('addData')->with($this->equalTo($data)); + $this->configurableAttribute->expects($this->any())->method('getId')->will($this->returnValue($id)); + $this->configurableAttribute->expects($this->once())->method('setId')->with($this->equalTo($id)); + $this->configurableAttribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($id)); + $this->configurableAttribute->expects($this->once())->method('setAttributeId')->with($this->equalTo($id)); + $this->configurableAttribute->expects($this->any())->method('getValues')->will($this->returnValue($data)); + $this->configurableAttribute->expects($this->any())->method('setValues')->with($this->equalTo($data)); + + $this->option->expects($this->any())->method('getValues')->will($this->returnValue([$this->value])); + $this->option->expects($this->any())->method('__toArray')->will($this->returnValue($data)); + + $this->valueConverter->expects($this->any())->method('convertArrayFromData') + ->with($this->equalTo($this->value)) + ->will($this->returnValue($data[0])); + + $result = $this->converter->getModelFromData($this->option, $this->configurableAttribute); + $this->assertEquals($this->configurableAttribute, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceTest.php new file mode 100644 index 00000000000..eb4b4cfb53c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceTest.php @@ -0,0 +1,307 @@ +<?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\Service\V1\Product\Option; + +use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType; +use Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute as ResourceAttribute; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute; +use Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class ReadServiceTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ReadServiceTest extends \PHPUnit_Framework_TestCase +{ + const TYPE_FIELD_NAME = 'frontend_input'; + const ATTRIBUTE_ID_FIELD_NAME = 'product_super_attribute_id'; + const OPTION_TYPE = 'select'; + /** + * @var \Magento\Catalog\Model\Resource\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + private $eavAttribute; + /** + * @var ResourceAttribute|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeResource; + /** + * @var \Magento\ConfigurableProduct\Service\V1\Product\Option\ReadService + */ + private $model; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionConverter; + + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable|\PHPUnit_Framework_MockObject_MockObject + */ + private $productType; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + private $option; + + /** + * @var Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $configurableAttributeCollection; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $metadata; + /** + * @var \Magento\Catalog\Model\System\Config\Source\Inputtype|\PHPUnit_Framework_MockObject_MockObject + */ + private $inputType; + + public function setUp() + { + $objectManager = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productType = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable' + ) + ->setMethods(['getConfigurableAttributeCollection']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['__wakeup', 'getTypeId']) + ->disableOriginalConstructor() + ->getMock(); + + $this->option = $this->getMockBuilder('Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute') + ->setMethods(['__wakeup', 'getId', 'getProductAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->eavAttribute = $this->getMockBuilder('Magento\Catalog\Model\Resource\Eav\Attribute') + ->setMethods(['getData', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeResource = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute' + ) + ->setMethods(['getIdFieldName', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->configurableAttributeCollection = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection' + ) + ->setMethods(['getResource', 'addFieldToFilter', 'getFirstItem']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionConverter = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Service\V1\Data\OptionConverter' + ) + ->setMethods(['convertFromModel']) + ->disableOriginalConstructor() + ->getMock(); + + $this->metadata = $this->getMockBuilder('\Magento\ConfigurableProduct\Service\V1\Data\Option') + ->disableOriginalConstructor() + ->getMock(); + + $this->inputType = $this->getMockBuilder('Magento\Catalog\Model\System\Config\Source\Inputtype') + ->setMethods(['toOptionArray']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $objectManager->getObject( + 'Magento\ConfigurableProduct\Service\V1\Product\Option\ReadService', + [ + 'productRepository' => $this->productRepository, + 'optionConverter' => $this->optionConverter, + 'configurableType' => $this->productType, + 'inputType' => $this->inputType, + ] + ); + } + + public function testGetList() + { + $productSku = 'oneSku'; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->productType->expects($this->once())->method('getConfigurableAttributeCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue([$this->option])); + + $this->optionConverter->expects($this->once())->method('convertFromModel') + ->with($this->equalTo($this->option)) + ->will($this->returnValue($this->metadata)); + + $this->assertEquals([$this->metadata], $this->model->getList($productSku)); + } + + public function testGet() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->productType->expects($this->once())->method('getConfigurableAttributeCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->configurableAttributeCollection)); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with(self::ATTRIBUTE_ID_FIELD_NAME, $optionId); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('getFirstItem') + ->will($this->returnValue($this->option)); + + $this->option->expects($this->once()) + ->method('getId') + ->will($this->returnValue($optionId)); + + $this->attributeResource->expects($this->once()) + ->method('getIdFieldName') + ->will($this->returnValue(self::ATTRIBUTE_ID_FIELD_NAME)); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('getResource') + ->will($this->returnValue($this->attributeResource)); + + $this->optionConverter->expects($this->once())->method('convertFromModel') + ->with($this->equalTo($this->option)) + ->will($this->returnValue($this->metadata)); + + $this->assertEquals($this->metadata, $this->model->get($productSku, $optionId)); + } + + public function testGetTypes() + { + $optionArray = array( + array('value' => 'multiselect', 'label' => __('Multiple Select')), + array('value' => 'select', 'label' => __('Dropdown')) + ); + $expectedResult = ['multiselect', 'select']; + + $this->inputType->expects($this->once()) + ->method('toOptionArray') + ->will($this->returnValue($optionArray)); + $this->assertEquals($expectedResult, $this->model->getTypes()); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + * @expectedExceptionMessage Requested option doesn't exist: 3 + */ + public function testGetNoSuchEntityException() + { + $productSku = 'oneSku'; + $optionId = 3; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->productType->expects($this->once())->method('getConfigurableAttributeCollection') + ->with($this->equalTo($this->product)) + ->will($this->returnValue($this->configurableAttributeCollection)); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('addFieldToFilter') + ->with(self::ATTRIBUTE_ID_FIELD_NAME, $optionId) + ->will($this->returnSelf()); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('getFirstItem') + ->will($this->returnValue($this->option)); + + $this->option->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + + $this->attributeResource->expects($this->once()) + ->method('getIdFieldName') + ->will($this->returnValue(self::ATTRIBUTE_ID_FIELD_NAME)); + + $this->configurableAttributeCollection->expects($this->once()) + ->method('getResource') + ->will($this->returnValue($this->attributeResource)); + + $this->model->get($productSku, $optionId); + } + + /** + * @expectedException \Magento\Webapi\Exception + * @expectedExceptionCode 403 + * @expectedExceptionMessage Only implemented for configurable product: oneSku + */ + public function testGetListWebApiException() + { + $productSku = 'oneSku'; + + $this->productRepository->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->product)); + + $this->product->expects($this->once())->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)); + + $this->model->getList($productSku); + } +} 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 new file mode 100644 index 00000000000..4d73a7f4038 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php @@ -0,0 +1,426 @@ +<?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\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\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 +{ + /** @var ObjectManager */ + protected $objectManager; + + /** + * @var ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productRepositoryMock; + + /** + * @var ConfigurableAttributeFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $confAttributeFactoryMock; + + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfigMock; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionBuilder + */ + protected $optionBuilder; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Product\Option\WriteService + */ + protected $writeService; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $productMock; + + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable|\PHPUnit_Framework_MockObject_MockObject + */ + private $productTypeMock; + + /** + * @var Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeCollectionMock; + + /** + * @var Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeMock; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionMock; + + /** + * @var \Magento\ConfigurableProduct\Service\V1\Data\OptionConverter|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionConverterMock; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->productRepositoryMock = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->disableOriginalConstructor()->setMethods(['get'])->getMock(); + + $this->confAttributeFactoryMock = $this + ->getMockBuilder('Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory') + ->disableOriginalConstructor()->setMethods(['create'])->getMock(); + + $this->eavConfigMock = $this + ->getMockBuilder('Magento\Eav\Model\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup', 'getId']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productTypeMock = $this->getMockBuilder('Magento\ConfigurableProduct\Model\Product\Type\Configurable') + ->setMethods(['getConfigurableAttributeCollection']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionConverterMock = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Service\V1\Data\OptionConverter' + ) + ->setMethods(['getModelFromData', 'convertFromModel', 'convertArrayFromData']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionMock = $this->getMockBuilder('Magento\ConfigurableProduct\Service\V1\Data\Option') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeCollectionMock = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection' + ) + ->setMethods(['getItemById']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeMock = $this->getMockBuilder( + 'Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute' + ) + ->setMethods(['delete', '__wakeup', 'load', 'save', 'getId', 'getProductId']) + ->disableOriginalConstructor() + ->getMock(); + + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $storeManagerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue(new \Magento\Framework\Object())); + + $this->writeService = $this->objectManager->getObject( + 'Magento\ConfigurableProduct\Service\V1\Product\Option\WriteService', + [ + 'productRepository' => $this->productRepositoryMock, + 'configurableAttributeFactory' => $this->confAttributeFactoryMock, + 'eavConfig' => $this->eavConfigMock, + 'storeManager' => $storeManagerMock, + 'productType' => $this->productTypeMock, + 'optionConverter' => $this->optionConverterMock + ] + ); + + $this->optionBuilder = $this->objectManager + ->getObject('Magento\ConfigurableProduct\Service\V1\Data\OptionBuilder'); + } + + /** + * Add configurable option test + */ + public function testAdd() + { + $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(3))->method('getId')->will($this->returnValue(1)); + + $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); + } + + /** + * Invalid product type check + * + * @expectedException \InvalidArgumentException + */ + public function testAddInvalidProductType() + { + $productSku = 'test_sku'; + $option = $this->getOption(); + + $productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $productMock->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + $this->productRepositoryMock->expects($this->any()) + ->method('get') + ->will($this->returnValue($productMock)); + + $this->writeService->add($productSku, $option); + } + + public function testUpdate() + { + $productSku = 'productSku'; + $optionId = 3; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + $this->productMock->expects($this->any())->method('getId') + ->will($this->returnValue($optionId)); + + $this->confAttributeFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->attributeMock)); + + $this->attributeMock->expects($this->once())->method('load')->with($this->equalTo($optionId)); + $this->attributeMock->expects($this->any())->method('getId')->will($this->returnValue($optionId)); + $this->attributeMock->expects($this->any())->method('getProductId')->will($this->returnValue($optionId)); + $this->attributeMock->expects($this->any())->method('save'); + + $this->optionConverterMock->expects($this->once())->method('getModelFromData') + ->with($this->equalTo($this->optionMock), $this->equalTo($this->attributeMock)) + ->will($this->returnValue($this->attributeMock)); + + $this->writeService->update($productSku, $optionId, $this->optionMock); + } + + /** + * #@expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testUpdateCouldNotSaveException() + { + $productSku = 'productSku'; + $optionId = 3; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + $this->productMock->expects($this->any())->method('getId') + ->will($this->returnValue($optionId)); + + $this->confAttributeFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->attributeMock)); + + $this->attributeMock->expects($this->once())->method('load')->with($this->equalTo($optionId)); + $this->attributeMock->expects($this->any())->method('getId')->will($this->returnValue($optionId)); + $this->attributeMock->expects($this->any())->method('getProductId')->will($this->returnValue($optionId)); + $this->attributeMock->expects($this->any())->method('save') + ->will( + $this->returnCallback( + function () { + throw new \Exception(); + } + ) + ); + + $this->optionConverterMock->expects($this->once())->method('getModelFromData') + ->with($this->equalTo($this->optionMock), $this->equalTo($this->attributeMock)) + ->will($this->returnValue($this->attributeMock)); + + $this->writeService->update($productSku, $optionId, $this->optionMock); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testUpdateNoSuchEntityException() + { + $productSku = 'productSku'; + $optionId = 3; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->confAttributeFactoryMock->expects($this->once())->method('create') + ->will($this->returnValue($this->attributeMock)); + + $this->attributeMock->expects($this->once())->method('load')->with($this->equalTo($optionId)); + $this->attributeMock->expects($this->any())->method('getId')->will($this->returnValue(0)); + + $this->writeService->update($productSku, $optionId, $this->optionMock); + } + + public function testRemove() + { + $productSku = 'productSku'; + $optionId = 3; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->productTypeMock->expects($this->once())->method('getConfigurableAttributeCollection') + ->with($this->equalTo($this->productMock)) + ->will($this->returnValue($this->attributeCollectionMock)); + + $this->attributeCollectionMock->expects($this->once())->method('getItemById') + ->with($this->equalTo($optionId)) + ->will($this->returnValue($this->attributeMock)); + + $this->attributeMock->expects($this->once())->method('delete'); + + $this->assertTrue($this->writeService->remove($productSku, $optionId)); + } + + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testRemoveNoSuchEntityException() + { + $productSku = 'productSku'; + $optionId = 3; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ConfigurableType::TYPE_CODE)); + + $this->productTypeMock->expects($this->once())->method('getConfigurableAttributeCollection') + ->with($this->equalTo($this->productMock)) + ->will($this->returnValue($this->attributeCollectionMock)); + + $this->attributeCollectionMock->expects($this->once())->method('getItemById') + ->with($this->equalTo($optionId)) + ->will($this->returnValue(null)); + + $this->writeService->remove($productSku, $optionId); + } + + /** + * @expectedException \Magento\Webapi\Exception + */ + public function testRemoveWebApiException() + { + $productSku = 'productSku'; + + $this->productRepositoryMock->expects($this->once())->method('get') + ->with($this->equalTo($productSku)) + ->will($this->returnValue($this->productMock)); + + $this->productMock->expects($this->once())->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_SIMPLE)); + $this->productMock->expects($this->once())->method('getSku') + ->will($this->returnValue($productSku)); + + $this->writeService->remove($productSku, 3); + } + + /** + * Return instance of option for configurable product + * + * @return \Magento\Framework\Service\Data\AbstractObject + */ + private function getOption() + { + $data = [ + Option::ID => 1, + Option::ATTRIBUTE_ID => 2, + Option::LABEL => 'Test Label', + Option::POSITION => 1, + Option::USE_DEFAULT => true, + Option::VALUES => [ + [ + 'index' => 1, + 'price' => 12, + 'percent' => true + ] + ] + ]; + + return $this->optionBuilder->populateWithArray($data)->create(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/ReadServiceTest.php index 6e3c86f6679..bd338f156f5 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/ReadServiceTest.php @@ -117,8 +117,8 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase 'value' => '14', 'label' => 'dd', 'price' => [ - 'value_index' => 14, - 'pricing_value' => 10, + 'index' => 14, + 'price' => 10, ], ], ], @@ -134,7 +134,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(100)); $configurableAttribute = $this->getMockBuilder( - 'Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute' + 'Magento\ConfigurableProduct\Service\V1\Data\Option' ) ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Authorization/CustomerSessionUserContextTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Authorization/CustomerSessionUserContextTest.php new file mode 100644 index 00000000000..44d35a342dc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Authorization/CustomerSessionUserContextTest.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\Customer\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Tests Magento\Customer\Model\Authorization\CustomerSessionUserContext + */ +class CustomerSessionUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Customer\Model\Authorization\CustomerSessionUserContext + */ + protected $customerSessionUserContext; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMock(); + + $this->customerSessionUserContext = $this->objectManager->getObject( + 'Magento\Customer\Model\Authorization\CustomerSessionUserContext', + ['customerSession' => $this->customerSession] + ); + } + + public function testGetUserIdExist() + { + $userId = 1; + $this->setupUserId($userId); + $this->assertEquals($userId, $this->customerSessionUserContext->getUserId()); + } + + public function testGetUserIdDoesNotExist() + { + $userId = null; + $this->setupUserId($userId); + $this->assertEquals($userId, $this->customerSessionUserContext->getUserId()); + } + + public function testGetUserType() + { + $this->assertEquals(UserContextInterface::USER_TYPE_CUSTOMER, $this->customerSessionUserContext->getUserType()); + } + + /** + * @param int|null $userId + * @return void + */ + public function setupUserId($userId) + { + $this->customerSession->expects($this->once()) + ->method('getId') + ->will($this->returnValue($userId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php new file mode 100644 index 00000000000..9736c734575 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.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\Fedex\Model; + +use Magento\Framework\Object; + +class CarrierTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $_helper; + + /** + * @var \Magento\Fedex\Model\Carrier + */ + protected $_model; + + /** + * @return void + */ + public function setUp() + { + $scopeConfig = $this->getMock( + 'Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag', 'getValue'], + [], + '', + false + ); + $scopeConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); + $scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('ServiceType')); + $country = $this->getMock( + 'Magento\Directory\Model\Country', + ['load', 'getIso2Code', '__wakeup'], + [], + '', + false + ); + $country->expects($this->any())->method('load')->will($this->returnSelf()); + $countryFactory = $this->getMock('Magento\Directory\Model\CountryFactory', ['create'], [], '', false); + $countryFactory->expects($this->any())->method('create')->will($this->returnValue($country)); + + $rate = $this->getMock('Magento\Shipping\Model\Rate\Result', ['getError'], [], '', false); + $rateFactory = $this->getMock('Magento\Shipping\Model\Rate\ResultFactory', ['create'], [], '', false); + $rateFactory->expects($this->any())->method('create')->will($this->returnValue($rate)); + + $store = $this->getMock('Magento\Store\Model\Store', ['getBaseCurrencyCode', '__wakeup'], [], '', false); + $storeManager = $this->getMock( + 'Magento\Store\Model\StoreManagerInterface', + [ + 'getStore', + 'setIsSingleStoreModeAllowed', + 'hasSingleStore', + 'isSingleStoreMode', + 'getStores', + 'getWebsite', + 'getWebsites', + 'reinitStores', + 'getDefaultStoreView', + 'getGroup', + 'getGroups', + 'clearWebsiteCache', + 'setCurrentStore' + ], + [], + '', + false + ); + $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); + $rateMethod = $this->getMock( + 'Magento\Sales\Model\Quote\Address\RateResult\Method', + null, + ['storeManager' => $storeManager] + ); + $rateMethodFactory = $this->getMock( + 'Magento\Sales\Model\Quote\Address\RateResult\MethodFactory', + ['create'], + [], + '', + false + ); + $rateMethodFactory->expects($this->any())->method('create')->will($this->returnValue($rateMethod)); + $this->_model = $this->getMock( + 'Magento\Fedex\Model\Carrier', + ['_getCachedQuotes', '_debug'], + [ + 'scopeConfig' => $scopeConfig, + 'rateErrorFactory' => + $this->getMock('Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory', [], [], '', false), + 'logAdapterFactory' => $this->getMock('Magento\Framework\Logger\AdapterFactory', [], [], '', false), + 'xmlElFactory' => $this->getMock('Magento\Shipping\Model\Simplexml\ElementFactory', [], [], '', false), + 'rateFactory' => $rateFactory, + 'rateMethodFactory' => $rateMethodFactory, + 'trackFactory' => $this->getMock('Magento\Shipping\Model\Tracking\ResultFactory', [], [], '', false), + 'trackErrorFactory' => + $this->getMock('Magento\Shipping\Model\Tracking\Result\ErrorFactory', [], [], '', false), + 'trackStatusFactory' => + $this->getMock('Magento\Shipping\Model\Tracking\Result\StatusFactory', [], [], '', false), + 'regionFactory' => $this->getMock('Magento\Directory\Model\RegionFactory', [], [], '', false), + 'countryFactory' => $countryFactory, + 'currencyFactory' => $this->getMock('Magento\Directory\Model\CurrencyFactory', [], [], '', false), + 'directoryData' => $this->getMock('Magento\Directory\Helper\Data', [], [], '', false), + 'stockItemService' => + $this->getMock('Magento\CatalogInventory\Service\V1\StockItemService', [], [], '', false), + 'logger' => $this->getMock('Magento\Framework\Logger', [], [], '', false), + 'storeManager' => $storeManager, + 'configReader' => $this->getMock('Magento\Framework\Module\Dir\Reader', [], [], '', false), + 'productCollectionFactory' => + $this->getMock('Magento\Catalog\Model\Resource\Product\CollectionFactory', [], [], '', false), + 'data' => [] + ] + ); + } + + /** + * @dataProvider collectRatesDataProvider + */ + public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) + { + // @codingStandardsIgnoreStart + $netAmount = new \Magento\Framework\Object([]); + $netAmount->Amount = $amount; + + $totalNetCharge = new \Magento\Framework\Object([]); + $totalNetCharge->TotalNetCharge = $netAmount; + $totalNetCharge->RateType = $rateType; + + $ratedShipmentDetail = new \Magento\Framework\Object([]); + $ratedShipmentDetail->ShipmentRateDetail = $totalNetCharge; + + $rate = new \Magento\Framework\Object([]); + $rate->ServiceType = 'ServiceType'; + $rate->RatedShipmentDetails = [$ratedShipmentDetail]; + + $response = new \Magento\Framework\Object([]); + $response->HighestSeverity = 'SUCCESS'; + $response->RateReplyDetails = $rate; + + $this->_model->expects($this->any())->method('_getCachedQuotes')->will( + $this->returnValue(serialize($response)) + ); + $request = $this->getMock('Magento\Sales\Model\Quote\Address\RateRequest', [], [], '', false); + foreach ($this->_model->collectRates($request)->getAllRates() as $allRates) { + $this->assertEquals($expected, $allRates->getData('cost')); + } + // @codingStandardsIgnoreEnd + } + + public function collectRatesDataProvider() + { + return [ + [10.0, 'RATED_ACCOUNT_PACKAGE', 10], + [11.50, 'PAYOR_ACCOUNT_PACKAGE', 11.5], + [100.01, 'RATED_ACCOUNT_SHIPMENT', 100.01], + [32.2, 'PAYOR_ACCOUNT_SHIPMENT', 32.2], + [15.0, 'RATED_LIST_PACKAGE', 15], + [123.25, 'PAYOR_LIST_PACKAGE', 123.25], + [12.12, 'RATED_LIST_SHIPMENT', 12.12], + [38.9, 'PAYOR_LIST_SHIPMENT', 38.9], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/_files/valid_events.xml b/dev/tests/unit/testsuite/Magento/Framework/Event/Config/_files/valid_events.xml index b5f4d134f8b..19d6744073e 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/_files/valid_events.xml +++ b/dev/tests/unit/testsuite/Magento/Framework/Event/Config/_files/valid_events.xml @@ -24,10 +24,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> - <event name="admin_roles_load_after"> + <event name="authorization_roles_load_after"> <observer name="observer_name" instance="Some_Test_Value" method="addDataAfterRoleLoad" disabled="false" shared="true"/> </event> - <event name="admin_roles_save_before"> + <event name="authorization_roles_save_before"> <observer name="second_name" instance="Some_Test_Value_Two" method="setDataBeforeRoleSave" /> </event> </config> diff --git a/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierListTest.php b/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierListTest.php new file mode 100644 index 00000000000..afbfa92a04b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierListTest.php @@ -0,0 +1,74 @@ +<?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\Notification; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class NotifierListTest extends \PHPUnit_Framework_TestCase +{ + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ + protected $objectManager; + + protected function setUp() + { + $this->objectManager = $this->getMock('Magento\Framework\ObjectManager'); + $this->objectManagerHelper = new ObjectManagerHelper($this); + } + + public function testAsArraySuccess() + { + $notifier1 = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); + $notifier2 = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); + $notifierList = $this->objectManagerHelper->getObject( + 'Magento\Framework\Notification\NotifierList', + [ + 'objectManager' => $this->objectManager, + 'notifiers' => [$notifier1, $notifier2] + ] + ); + $this->setExpectedException('InvalidArgumentException'); + $result = $notifierList->asArray(); + foreach ($result as $notifier) { + $this->assertInstanceOf('Magento\Framework\Notification\NotifierInterface', $notifier); + } + } + + public function testAsArrayException() + { + $notifierCorrect = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierPool'); + $notifierIncorrect = $this->objectManagerHelper->getObject('Magento\Framework\Notification\NotifierList'); + $notifierList = $this->objectManagerHelper->getObject( + 'Magento\Framework\Notification\NotifierList', + [ + 'objectManager' => $this->objectManager, + 'notifiers' => [$notifierCorrect, $notifierIncorrect] + ] + ); + $this->setExpectedException('InvalidArgumentException'); + $notifierList->asArray(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierPoolTest.php b/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierPoolTest.php new file mode 100644 index 00000000000..bc66e1191ed --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Notification/NotifierPoolTest.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\Framework\Notification; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class NotifierPoolTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Framework\Notification\NotifierPool */ + protected $notifierPool; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \Magento\Framework\Notification\NotifierList|\PHPUnit_Framework_MockObject_MockObject */ + protected $notifierList; + + /** + * @var \Magento\Framework\Notification\NotifierPool[]|\PHPUnit_Framework_MockObject_MockObject[] + */ + protected $notifiers; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $notifier1 = $this->getMock('Magento\Framework\Notification\NotifierPool', [], [], '', false); + $notifier2 = $this->getMock('Magento\Framework\Notification\NotifierPool', [], [], '', false); + $this->notifiers = [$notifier1, $notifier2]; + $this->notifierList = $this->getMock('Magento\Framework\Notification\NotifierList', [], [], '', false); + $this->notifierList->expects($this->any())->method('asArray')->will($this->returnValue($this->notifiers)); + $this->notifierPool = $this->objectManagerHelper->getObject( + 'Magento\Framework\Notification\NotifierPool', + [ + 'notifierList' => $this->notifierList + ] + ); + } + + public function testAdd() + { + $severity = \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL; + $title = 'title'; + $description = 'desc'; + foreach ($this->notifiers as $notifier) { + $notifier->expects($this->once())->method('add')->with($severity, $title, $description); + } + $this->notifierPool->add($severity, $title, $description); + } + + public function testAddCritical() + { + $title = 'title'; + $description = 'desc'; + foreach ($this->notifiers as $notifier) { + $notifier->expects($this->once())->method('addCritical')->with($title, $description); + } + $this->notifierPool->addCritical($title, $description); + } + + public function testAddMajor() + { + $title = 'title'; + $description = 'desc'; + foreach ($this->notifiers as $notifier) { + $notifier->expects($this->once())->method('addMajor')->with($title, $description); + } + $this->notifierPool->addMajor($title, $description); + } + + public function testAddMinor() + { + $title = 'title'; + $description = 'desc'; + foreach ($this->notifiers as $notifier) { + $notifier->expects($this->once())->method('addMinor')->with($title, $description); + } + $this->notifierPool->addMinor($title, $description); + } + + public function testAddNotice() + { + $title = 'title'; + $description = 'desc'; + foreach ($this->notifiers as $notifier) { + $notifier->expects($this->once())->method('addNotice')->with($title, $description); + } + $this->notifierPool->addNotice($title, $description); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/ConverterTest.php new file mode 100644 index 00000000000..167a36251d3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/ConverterTest.php @@ -0,0 +1,152 @@ +<?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\ObjectManager\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class ConverterTest + * @package Magento\Framework\ObjectManager\Code\Generator + */ +class ConverterTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\SampleConverter'; + + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + 'Magento\Framework\ObjectManager\Code\Generator\Converter', + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = 'SampleConverter.php'; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addProperties') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setClassDocBlock') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/GenerateRepositoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/GenerateRepositoryTest.php new file mode 100644 index 00000000000..1254703f3a3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/GenerateRepositoryTest.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\Framework\ObjectManager\Code\Generator; + +/** + * Class RepositoryTest + */ +class GenerateRepositoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * test setUp + */ + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + '\Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + require_once __DIR__ . '/_files/Sample.php'; + $model = $this->getMock( + 'Magento\Framework\ObjectManager\Code\Generator\Repository', + [ + '_validateData' + ], + [ + '\Magento\Framework\ObjectManager\Code\Generator\Sample', + null, + $this->ioObjectMock, + null, + null + ] + ); + $sampleRepositoryCode = file_get_contents(__DIR__ . '/_files/SampleRepository.txt'); + + $this->ioObjectMock->expects($this->once()) + ->method('getResultFileName') + ->with('\Magento\Framework\ObjectManager\Code\Generator\SampleRepository') + ->will($this->returnValue('SampleRepository.php')); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with( + $this->equalTo('SampleRepository.php'), + $this->equalTo($sampleRepositoryCode) + ); + + $model->expects($this->once())->method('_validateData')->will($this->returnValue(true)); + $this->assertTrue($model->generate()); + } + + /** + * test protected _validateData() + */ + public function testValidateData() + { + $sourceClassName = 'Magento_Module_Controller_Index'; + $resultClassName = 'Magento_Module_Controller'; + + $includePathMock = $this->getMockBuilder('Magento\Framework\Autoload\IncludePath') + ->disableOriginalConstructor() + ->setMethods(['getFile']) + ->getMock(); + $includePathMock->expects($this->at(0)) + ->method('getFile') + ->with($sourceClassName) + ->will($this->returnValue(true)); + $includePathMock->expects($this->at(1)) + ->method('getFile') + ->with($resultClassName) + ->will($this->returnValue(false)); + + $repository = new Repository( + null, null, null, null, $includePathMock + ); + $repository->init($sourceClassName, $resultClassName); + $this->assertFalse($repository->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/RepositoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/RepositoryTest.php new file mode 100644 index 00000000000..f6b61de9581 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/RepositoryTest.php @@ -0,0 +1,155 @@ +<?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\ObjectManager\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class RepositoryTest + */ +class RepositoryTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\SampleRepository'; + const GENERATOR_CLASS_NAME = 'Magento\Framework\ObjectManager\Code\Generator\Repository'; + const OUTPUT_FILE_NAME = 'SampleConverter.php'; + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + self::GENERATOR_CLASS_NAME, + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = self::OUTPUT_FILE_NAME; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addProperties') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setClassDocBlock') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} 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 new file mode 100644 index 00000000000..2d4340d4155 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Code/Generator/_files/SampleRepository.txt @@ -0,0 +1,98 @@ +namespace \Magento\Framework\ObjectManager\Code\Generator; + +/** + * Repository class for \Magento\Framework\ObjectManager\Code\Generator\Sample + */ +class SampleRepository +{ + /** + * sampleFactory + * + * @var \Magento\Framework\ObjectManager\Code\Generator\SampleFactory + */ + protected $sampleFactory = null; + + /** + * Collection Factory + * + * @var + * \Magento\Framework\ObjectManager\Resource\Code\Generator\Sample\CollectionFactory + */ + protected $sampleCollectionFactory = null; + + /** + * Magento\Framework\ObjectManager\Code\Generator\Sample[] + * + * @var array + */ + protected $registry = array(); + + /** + * Repository constructor + * + * @param \Magento\Framework\ObjectManager\Code\Generator\Sample $sampleFactory + * @param + * \Magento\Framework\ObjectManager\Resource\Code\Generator\Sample\CollectionFactory + * $sampleCollectionFactory + */ + public function __construct(\Magento\Framework\ObjectManager\Code\Generator\SampleFactory $sampleFactory, \Magento\Framework\ObjectManager\Resource\Code\Generator\Sample\CollectionFactory $sampleCollectionFactory) + { + $this->sampleFactory = $sampleFactory; + $this->sampleCollectionFactory = $sampleCollectionFactory; + } + + /** + * load entity + * + * @param int $id + * @return \Magento\Framework\ObjectManager\Code\Generator\Sample + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function get($id) + { + if (!$id) { + throw new \Magento\Framework\Exception\NoSuchEntityException('Requested product doesn\'t exist'); + } + if (!isset($this->registry[$id])) { + $this->registry[$id] = $this->sampleFactory->create()->load($id); + } + return $this->registry[$id]; + } + + /** + * Register entity + * + * @param \Magento\Framework\ObjectManager\Code\Generator\Sample $object + * @return \Magento\Framework\ObjectManager\Code\Generator\SampleRepository + */ + public function register(\Magento\Framework\ObjectManager\Code\Generator\Sample $object) + { + if ($object->getId() && !isset($this->registry[$object->getId()])) { + $object->load($object->getId()); + $this->registry[$object->getId()] = $object; + } + return $this; + } + + /** + * Find entities by criteria + * + * @param \Magento\Framework\Service\V1\Data\SearchCriteria $criteria + * @return \Magento\Framework\ObjectManager\Code\Generator\Sample[] + */ + public function find(\Magento\Framework\Service\V1\Data\SearchCriteria $criteria) + { + $collection = $this->sampleCollectionFactory->create(); + foreach($criteria->getFilterGroups() as $filterGroup) { + foreach ($filterGroup->getFilters() as $filter) { + $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq'; + $collection->addFieldToFilter($filter->getField(), [$condition => $filter->getValue()]); + } + } + foreach ($collection as $object) { + $this->register($object); + } + $objectIds = $collection->getAllIds(); + return array_intersect_key($this->registry, array_flip($objectIds)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php new file mode 100644 index 00000000000..2369f366626 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.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\Framework\Search; + +use Magento\TestFramework\Helper\ObjectManager; + +class RequestFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\RequestFactory + */ + private $factory; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + + /** + * @var \Magento\Framework\Search\Request\Config|\PHPUnit_Framework_MockObject_MockObject + */ + private $config; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') + ->setMethods(['create', 'get', 'configure']) + ->disableOriginalConstructor() + ->getMock(); + + $this->config = $this->getMockBuilder('Magento\Framework\Search\Request\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->factory = $helper->getObject( + '\Magento\Framework\Search\RequestFactory', + [ + 'objectManager' => $this->objectManager, + 'config' => $this->config + ] + ); + } + + public function testCreate() + { + $requestName = 'request'; + $bindValues = [':str' => 'rpl']; + $configData = [ + 'queries' => ':str', + 'filters' => 'f', + 'query' => 'q', + 'index' => 'i', + 'from' => 1, + 'size' => 15 + ]; + $mappedQuery = $configData['query'] . 'Mapped'; + $this->config->expects($this->once())->method('get')->with($this->equalTo($requestName)) + ->will($this->returnValue($configData)); + + /** @var \Magento\Framework\Search\Request\Mapper|\PHPUnit_Framework_MockObject_MockObject $mapper */ + $mapper = $this->getMockBuilder('Magento\Framework\Search\Request\Mapper') + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\Framework\Search\Request|\PHPUnit_Framework_MockObject_MockObject $request */ + $request = $this->getMockBuilder('Magento\Framework\Search\Request') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager->expects($this->at(0))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request\Mapper'), + $this->equalTo( + [ + 'objectManager' => $this->objectManager, + 'queries' => $bindValues[':str'], + 'filters' => $configData['filters'] + ] + ) + ) + ->will($this->returnValue($mapper)); + $this->objectManager->expects($this->at(1))->method('create') + ->with( + $this->equalTo('Magento\Framework\Search\Request'), + $this->equalTo( + [ + 'name' => $configData['query'], + 'indexName' => $configData['index'], + 'from' => $configData['from'], + 'size' => $configData['size'], + 'query' => $mappedQuery, + 'buckets' => [], + ] + ) + ) + ->will($this->returnValue($request)); + + $mapper->expects($this->once())->method('get')->with($this->equalTo($configData['query'])) + ->will($this->returnValue($mappedQuery)); + + $this->assertEquals($request, $this->factory->create($requestName, $bindValues)); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testCreateInvalidArgumentException() + { + $requestName = 'rn'; + $this->config->expects($this->once())->method('get')->with($this->equalTo($requestName)) + ->will($this->returnValue(null)); + + $this->factory->create($requestName); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/BuilderTest.php new file mode 100644 index 00000000000..61c9b5cf360 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/BuilderTest.php @@ -0,0 +1,156 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class BuilderTest + */ +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SampleBuilder'; + const GENERATOR_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Builder'; + const OUTPUT_FILE_NAME = 'SampleBuilder.php'; + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + require_once __DIR__ . '/_files/Sample.php'; + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + self::GENERATOR_CLASS_NAME, + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = self::OUTPUT_FILE_NAME; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addProperties') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setClassDocBlock') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateBuilderTest.php new file mode 100644 index 00000000000..59033b46115 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateBuilderTest.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\Framework\Service\Code\Generator; + +/** + * Class BuilderTest + */ +class GenerateBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * Prepare test env + */ + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + '\Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + } + + /** + * generate repository class + */ + public function testGenerate() + { + require_once __DIR__ . '/_files/Sample.php'; + $model = $this->getMock( + 'Magento\Framework\Service\Code\Generator\Builder', + [ + '_validateData' + ], + [ + '\Magento\Framework\Service\Code\Generator\Sample', + null, + $this->ioObjectMock, + null, + null + ] + ); + $sampleBuilderCode = file_get_contents(__DIR__ . '/_files/SampleBuilder.txt'); + $this->ioObjectMock->expects($this->once()) + ->method('getResultFileName') + ->with('\Magento\Framework\Service\Code\Generator\SampleBuilder') + ->will($this->returnValue('SampleBuilder.php')); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with('SampleBuilder.php', $sampleBuilderCode); + + $model->expects($this->once()) + ->method('_validateData') + ->will($this->returnValue(true)); + $this->assertTrue($model->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateMapperTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateMapperTest.php new file mode 100644 index 00000000000..0effd4a0c81 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateMapperTest.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\Framework\Service\Code\Generator; + +/** + * Class MapperTest + */ +class GenerateMapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * Prepare test env + */ + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + '\Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + } + + /** + * Create mock for class \Magento\Framework\Code\Generator\Io + */ + public function testGenerate() + { + require_once __DIR__ . '/_files/Sample.php'; + $model = $this->getMock( + 'Magento\Framework\Service\Code\Generator\Mapper', + [ + '_validateData' + ], + [ + '\Magento\Framework\Service\Code\Generator\Sample', + null, + $this->ioObjectMock, + null, + null + ] + ); + $sampleMapperCode = file_get_contents(__DIR__ . '/_files/SampleMapper.txt'); + $this->ioObjectMock->expects($this->once()) + ->method('getResultFileName') + ->with('\Magento\Framework\Service\Code\Generator\SampleMapper') + ->will($this->returnValue('SampleMapper.php')); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with('SampleMapper.php', $sampleMapperCode); + + $model->expects($this->once()) + ->method('_validateData') + ->will($this->returnValue(true)); + $this->assertTrue($model->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsBuilderTest.php new file mode 100644 index 00000000000..4af404ba580 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsBuilderTest.php @@ -0,0 +1,85 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Service\Code\Generator\SearchResultsBuilder; + +/** + * Class SearchResultBuilderTest + */ +class GenerateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * Create mock for class \Magento\Framework\Code\Generator\Io + */ + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + '\Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + } + + /** + * generate SearchResultBuilder class + */ + public function testGenerate() + { + require_once __DIR__ . '/_files/Sample.php'; + $model = $this->getMock( + 'Magento\Framework\Service\Code\Generator\SearchResultsBuilder', + [ + '_validateData' + ], + [ + '\Magento\Framework\Service\Code\Generator\Sample', + null, + $this->ioObjectMock, + null, + null + ] + ); + $sampleSearchResultBuilderCode = file_get_contents(__DIR__ . '/_files/SampleSearchResultsBuilder.txt'); + $this->ioObjectMock->expects($this->once()) + ->method('getResultFileName') + ->with('\Magento\Framework\Service\Code\Generator\SampleSearchResultsBuilder') + ->will($this->returnValue('SampleSearchResultsBuilder.php')); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with('SampleSearchResultsBuilder.php', $sampleSearchResultBuilderCode); + + $model->expects($this->once()) + ->method('_validateData') + ->will($this->returnValue(true)); + $this->assertTrue($model->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsTest.php new file mode 100644 index 00000000000..a2d0c66423e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/GenerateSearchResultsTest.php @@ -0,0 +1,85 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Service\Code\Generator\SearchResults; + +/** + * Class SearchResultTest + */ +class GenerateSearchResultsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * Create mock for class \Magento\Framework\Code\Generator\Io + */ + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + '\Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + } + + /** + * Generate SearchResult class + */ + public function testGenerate() + { + require_once __DIR__ . '/_files/Sample.php'; + $model = $this->getMock( + 'Magento\Framework\Service\Code\Generator\SearchResults', + [ + '_validateData' + ], + [ + '\Magento\Framework\Service\Code\Generator\Sample', + null, + $this->ioObjectMock, + null, + null + ] + ); + $sampleSearchResultBuilderCode = file_get_contents(__DIR__ . '/_files/SampleSearchResults.txt'); + $this->ioObjectMock->expects($this->once()) + ->method('getResultFileName') + ->with('\Magento\Framework\Service\Code\Generator\SampleSearchResults') + ->will($this->returnValue('SampleSearchResults.php')); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with('SampleSearchResults.php', $sampleSearchResultBuilderCode); + + $model->expects($this->once()) + ->method('_validateData') + ->will($this->returnValue(true)); + $this->assertTrue($model->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/MapperTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/MapperTest.php new file mode 100644 index 00000000000..66207b268d7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/MapperTest.php @@ -0,0 +1,155 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class MapperTest + */ +class MapperTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SampleMapper'; + const GENERATOR_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Mapper'; + const OUTPUT_FILE_NAME = 'SampleMapper.php'; + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + self::GENERATOR_CLASS_NAME, + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = self::OUTPUT_FILE_NAME; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addProperties') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setClassDocBlock') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsBuilderTest.php new file mode 100644 index 00000000000..eebadd7f6ab --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsBuilderTest.php @@ -0,0 +1,157 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class MapperTest + */ +class SearchResultsBuilderTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SampleSearchResultsBuilder'; + const GENERATOR_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SearchResultsBuilder'; + const OUTPUT_FILE_NAME = 'SampleSearchResultsBuilder.php'; + + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + self::GENERATOR_CLASS_NAME, + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = self::OUTPUT_FILE_NAME; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setExtendedClass') + ->with(SearchResultsBuilder::SEARCH_RESULT_BUILDER) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setClassDocBlock') + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsTest.php new file mode 100644 index 00000000000..c27513612f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/SearchResultsTest.php @@ -0,0 +1,155 @@ +<?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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\Io; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Class MapperTest + */ +class SearchResultsTest extends \PHPUnit_Framework_TestCase +{ + const SOURCE_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\Sample'; + const RESULT_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SampleSearchResults'; + const GENERATOR_CLASS_NAME = 'Magento\Framework\Service\Code\Generator\SearchResults'; + const OUTPUT_FILE_NAME = 'SampleSearchResults.php'; + + /** + * @var Io | \PHPUnit_Framework_MockObject_MockObject + */ + protected $ioObjectMock; + + /** + * @var \Magento\Framework\Code\Generator\EntityAbstract + */ + protected $generator; + + /** + * @var \Magento\Framework\Autoload\IncludePath | \PHPUnit_Framework_MockObject_MockObject + */ + protected $autoloaderMock; + + /** + * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject + */ + protected $classGenerator; + + protected function setUp() + { + $this->ioObjectMock = $this->getMock( + 'Magento\Framework\Code\Generator\Io', + [], + [], + '', + false + ); + $this->autoloaderMock = $this->getMock( + 'Magento\Framework\Autoload\IncludePath', + [], + [], + '', + false + ); + $this->classGenerator = $this->getMock( + 'Magento\Framework\Code\Generator\CodeGenerator\Zend', + [], + [], + '', + false + ); + + $objectManager = new ObjectManager($this); + $this->generator = $objectManager->getObject( + self::GENERATOR_CLASS_NAME, + [ + 'sourceClassName' => self::SOURCE_CLASS_NAME, + 'resultClassName' => self::RESULT_CLASS_NAME, + 'ioObject' => $this->ioObjectMock, + 'classGenerator' => $this->classGenerator, + 'autoLoader' => $this->autoloaderMock + ] + ); + } + + /** + * generate repository name + */ + public function testGenerate() + { + $generatedCode = 'Generated code'; + $sourceFileName = 'Sample.php'; + $resultFileName = self::OUTPUT_FILE_NAME; + + //Mocking _validateData call + $this->autoloaderMock->expects($this->at(0)) + ->method('getFile') + ->with(self::SOURCE_CLASS_NAME) + ->will($this->returnValue($sourceFileName)); + $this->autoloaderMock->expects($this->at(1)) + ->method('getFile') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(false)); + + $this->ioObjectMock->expects($this->once()) + ->method('makeGenerationDirectory') + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('makeResultFileDirectory') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue(true)); + $this->ioObjectMock->expects($this->once()) + ->method('fileExists') + ->with($resultFileName) + ->will($this->returnValue(false)); + + //Mocking _generateCode call + $this->classGenerator->expects($this->once()) + ->method('setName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('setExtendedClass') + ->with(SearchResults::SEARCH_RESULT) + ->will($this->returnSelf()); + $this->classGenerator->expects($this->once()) + ->method('addMethods') + ->will($this->returnSelf()); + + $this->classGenerator->expects($this->once()) + ->method('generate') + ->will($this->returnValue($generatedCode)); + + //Mocking generation + $this->ioObjectMock->expects($this->any()) + ->method('getResultFileName') + ->with(self::RESULT_CLASS_NAME) + ->will($this->returnValue($resultFileName)); + $this->ioObjectMock->expects($this->once()) + ->method('writeResultFile') + ->with($resultFileName, $generatedCode); + + $this->assertTrue($this->generator->generate()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/Sample.php b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/Sample.php new file mode 100644 index 00000000000..5c68f84fb31 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/Sample.php @@ -0,0 +1,44 @@ +<?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\Service\Code\Generator; + +/** + * Class Sample for Proxy and Factory generation + */ +class Sample +{ + /** + * @var array + */ + protected $messages = array(); + + /** + * @return array + */ + public function getMessages() + { + return $this->messages; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleBuilder.txt b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleBuilder.txt new file mode 100644 index 00000000000..c6c952b7600 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleBuilder.txt @@ -0,0 +1,15 @@ +namespace \Magento\Framework\Service\Code\Generator; + +/** + * Builder class for \Magento\Framework\Service\Code\Generator\Sample + */ +class SampleBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +{ + /** + * {@inheritdoc} + */ + public function setMessages($messages) + { + $this->_set(\Magento\Framework\Service\Code\Generator\Sample::MESSAGES, $messages); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleMapper.txt b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleMapper.txt new file mode 100644 index 00000000000..6c0f698e38c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleMapper.txt @@ -0,0 +1,43 @@ +namespace \Magento\Framework\Service\Code\Generator; + +/** + * Mapper class for \Magento\Framework\Service\Code\Generator\Sample + */ +class SampleMapper +{ + /** + * sampleBuilder + * + * @var \Magento\Framework\Service\Code\Generator\SampleBuilder + */ + protected $sampleBuilder = null; + + /** + * Magento\Framework\Service\Code\Generator\Sample[] + * + * @var array + */ + protected $registry = array(); + + /** + * Mapper constructor + * + * @param \Magento\Framework\Service\Code\Generator\Sample $sampleBuilder + */ + public function __construct(\Magento\Framework\Service\Code\Generator\SampleBuilder $sampleBuilder) + { + $this->sampleBuilder = $sampleBuilder; + } + + /** + * Extract data object from model + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return \Magento\Framework\Service\Code\Generator\Sample + */ + public function extractDto(\Magento\Framework\Model\AbstractModel $object) + { + $this->sampleBuilder->populateWithArray($object->getData()); + return $this->sampleBuilder->create(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResults.txt b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResults.txt new file mode 100644 index 00000000000..e98e4d3a8dc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResults.txt @@ -0,0 +1,14 @@ +namespace \Magento\Framework\Service\Code\Generator; + +class SampleSearchResults extends \Magento\Framework\Service\V1\Data\SearchResults +{ + /** + * Returns array of items + * + * @return \Magento\Framework\Service\Code\Generator\Sample[] + */ + public function getItems() + { + return parent::getItems(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResultsBuilder.txt b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResultsBuilder.txt new file mode 100644 index 00000000000..e6e0a47c1ed --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Service/Code/Generator/_files/SampleSearchResultsBuilder.txt @@ -0,0 +1,17 @@ +namespace \Magento\Framework\Service\Code\Generator; + +/** + * SearchResultsBuilder class for \Magento\Framework\Service\Code\Generator\Sample + */ +class SampleSearchResultsBuilder extends \Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder +{ + /** + * SearchResultsBuilder constructor + * + * @param + */ + public function __construct(\Magento\Framework\Service\Data\ObjectFactory $objectFactory, \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Service\Code\Generator\SampleBuilder $itemObjectBuilder) + { + parent::__construct($objectFactory, $searchCriteriaBuilder, $itemObjectBuilder); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php new file mode 100644 index 00000000000..1b7e52ee164 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.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) + */ +// @codingStandardsIgnoreStart +namespace { + $mockPHPFunctions = false; +} + +namespace Magento\Framework\Session { + // @codingStandardsIgnoreEnd + + /** + * Mock ini_set global function + * + * @param string $varName + * @param string $newValue + * @return bool|string + */ + function ini_set($varName, $newValue) + { + global $mockPHPFunctions; + if ($mockPHPFunctions) { + SessionManagerTest::$isIniSetInvoked = true; + SessionManagerTest::assertSame(SessionManagerTest::SESSION_USE_ONLY_COOKIES, $varName); + SessionManagerTest::assertSame(SessionManagerTest::SESSION_USE_ONLY_COOKIES_ENABLE, $newValue); + return true; + } + return call_user_func_array('\ini_set', func_get_args()); + } + + /** + * Mock session_regenerate_id to fail if false is passed + * + * @param bool $var + * @return bool + */ + function session_regenerate_id($var) + { + global $mockPHPFunctions; + if ($mockPHPFunctions) { + SessionManagerTest::assertTrue($var); + return true; + } + return call_user_func_array('\session_regenerate_id', func_get_args()); + } + + + /** + * Test SessionManager + * + */ + class SessionManagerTest extends \PHPUnit_Framework_TestCase + { + const SESSION_USE_ONLY_COOKIES = 'session.use_only_cookies'; + const SESSION_USE_ONLY_COOKIES_ENABLE = '1'; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + private $objectManager; + + /** + * @var \Magento\Framework\Session\SessionManager + */ + private $sessionManager; + + /** + * @var \Magento\Framework\Session\Config\ConfigInterface | \PHPUnit_Framework_MockObject_MockObject + */ + private $mockSessionConfig; + + /** + * @var bool + */ + public static $isIniSetInvoked; + + public function setUp() + { + global $mockPHPFunctions; + $mockPHPFunctions = true; + $this->mockSessionConfig = $this->getMockBuilder('\Magento\Framework\Session\Config\ConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $arguments = ['sessionConfig' => $this->mockSessionConfig]; + $this->sessionManager = $this->objectManager->getObject( + 'Magento\Framework\Session\SessionManager', + $arguments + ); + } + + public function testSessionManagerConstructor() + { + self::$isIniSetInvoked = false; + $this->objectManager->getObject('Magento\Framework\Session\SessionManager'); + $this->assertTrue(SessionManagerTest::$isIniSetInvoked); + } + + /** + * @runInSeparateProcess + */ + public function testRegenerateId() + { + require_once __DIR__ . '/../../_files/session_backend_mock.php'; + + $this->mockSessionConfig->expects($this->once()) + ->method('getUseCookies') + ->will($this->returnValue(false)); + $this->assertSame($this->sessionManager, $this->sessionManager->regenerateId()); + } + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php new file mode 100644 index 00000000000..6122770c291 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -0,0 +1,309 @@ +<?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\Cookie; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Test CookieScope + * + * @coversDefaultClass Magento\Framework\Stdlib\Cookie\CookieScope + */ +class CookieScopeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ObjectManager + */ + private $objectManager; + + private $defaultScopeParams; + + public function setUp() + { + $this->objectManager = new ObjectManager($this); + $cookieMetadataFactory = $this + ->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory') + ->disableOriginalConstructor()->getMock(); + $cookieMetadataFactory->expects($this->any()) + ->method('createSensitiveCookieMetadata') + ->will($this->returnCallback([$this, 'createSensitiveMetadata'])); + $cookieMetadataFactory->expects($this->any()) + ->method('createPublicCookieMetadata') + ->will($this->returnCallback([$this, 'createPublicMetadata'])); + $cookieMetadataFactory->expects($this->any()) + ->method('createCookieMetadata') + ->will($this->returnCallback([$this, 'createCookieMetadata'])); + $this->defaultScopeParams = [ + 'cookieMetadataFactory' => $cookieMetadataFactory + ]; + } + + /** + * @covers ::getSensitiveCookieMetadata + */ + public function testGetSensitiveCookieMetadataEmpty() + { + $cookieScope = $this->createCookieScope(); + + $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + } + + /** + * @covers ::getPublicCookieMetadata + */ + public function testGetPublicCookieMetadataEmpty() + { + $cookieScope = $this->createCookieScope(); + + $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); + } + + /** + * @covers ::getCookieMetadata + */ + public function testGetCookieMetadataEmpty() + { + $cookieScope = $this->createCookieScope(); + + $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata + */ + public function testGetSensitiveCookieMetadataDefaults() + { + $defaultValues = [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $sensitive = $this->createSensitiveMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => $sensitive, + 'publicCookieMetadata' => null, + 'deleteCookieMetadata' => null + ] + ); + + $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); + $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); + $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata ::getCookieMetadata + */ + public function testGetPublicCookieMetadataDefaults() + { + $defaultValues = [ + PublicCookieMetadata::KEY_PATH => 'default path', + PublicCookieMetadata::KEY_DOMAIN => 'default domain', + PublicCookieMetadata::KEY_DURATION => 'default duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'default http', + PublicCookieMetadata::KEY_SECURE => 'default secure', + ]; + $public = $this->createPublicMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => null, + 'publicCookieMetadata' => $public, + 'deleteCookieMetadata' => null + ] + ); + + $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); + $this->assertEquals($defaultValues, $cookieScope->getPublicCookieMetadata()->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata ::getCookieMetadata + */ + public function testGetCookieMetadataDefaults() + { + $defaultValues = [ + CookieMetadata::KEY_PATH => 'default path', + CookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $cookieMetadata = $this->createCookieMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => null, + 'publicCookieMetadata' => null, + 'deleteCookieMetadata' => $cookieMetadata + ] + ); + + $this->assertEquals($defaultValues, $cookieScope->getCookieMetadata()->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata ::getCookieMetadata + */ + public function testGetSensitiveCookieMetadataOverrides() + { + $defaultValues = [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $overrideValues = [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + ]; + $sensitive = $this->createSensitiveMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => $sensitive, + 'publicCookieMetadata' => null, + 'deleteCookieMetadata' => null + ] + ); + $override = $this->createSensitiveMetadata($overrideValues); + + $this->assertEmpty($cookieScope->getPublicCookieMetadata($this->createPublicMetadata())->__toArray()); + $this->assertEmpty($cookieScope->getCookieMetadata($this->createCookieMetadata())->__toArray()); + $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata ::getCookieMetadata + */ + public function testGetPublicCookieMetadataOverrides() + { + $defaultValues = [ + PublicCookieMetadata::KEY_PATH => 'default path', + PublicCookieMetadata::KEY_DOMAIN => 'default domain', + PublicCookieMetadata::KEY_DURATION => 'default duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'default http', + PublicCookieMetadata::KEY_SECURE => 'default secure', + ]; + $overrideValues = [ + PublicCookieMetadata::KEY_PATH => 'override path', + PublicCookieMetadata::KEY_DOMAIN => 'override domain', + PublicCookieMetadata::KEY_DURATION => 'override duration', + PublicCookieMetadata::KEY_HTTP_ONLY => 'override http', + PublicCookieMetadata::KEY_SECURE => 'override secure', + ]; + $public = $this->createPublicMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => null, + 'publicCookieMetadata' => $public, + 'cookieMetadata' => null + ] + ); + $override = $this->createPublicMetadata($overrideValues); + $this->assertEquals($overrideValues, $cookieScope->getPublicCookieMetadata($override)->__toArray()); + } + + /** + * @covers ::createSensitiveMetadata ::getPublicCookieMetadata ::getCookieMetadata + */ + public function testGetCookieMetadataOverrides() + { + $defaultValues = [ + CookieMetadata::KEY_PATH => 'default path', + CookieMetadata::KEY_DOMAIN => 'default domain', + ]; + $overrideValues = [ + CookieMetadata::KEY_PATH => 'override path', + CookieMetadata::KEY_DOMAIN => 'override domain', + ]; + $cookieMeta = $this->createCookieMetadata($defaultValues); + $cookieScope = $this->createCookieScope( + [ + 'sensitiveCookieMetadata' => null, + 'publicCookieMetadata' => null, + 'deleteCookieMetadata' => $cookieMeta + ] + ); + $override = $this->createCookieMetadata($overrideValues); + + $this->assertEquals( + [], + $cookieScope->getSensitiveCookieMetadata($this->createSensitiveMetadata())->__toArray() + ); + $this->assertEquals( + [], + $cookieScope->getPublicCookieMetadata($this->createPublicMetadata())->__toArray() + ); + $this->assertEquals($overrideValues, $cookieScope->getCookieMetadata($override)->__toArray()); + } + + /** + * Creates a CookieScope object with the given parameters. + * + * @param array $params + * @return CookieScope + */ + protected function createCookieScope($params = []) + { + $params = array_merge($this->defaultScopeParams, $params); + return $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieScope', $params); + } + + /** + * Creates a SensitiveCookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return SensitiveCookieMetadata + */ + public function createSensitiveMetadata($metadata = []) + { + return $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates a PublicCookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return PublicCookieMetadata + */ + public function createPublicMetadata($metadata = []) + { + return $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates a CookieMetadata object with provided metadata values. + * + * @param array $metadata + * @return CookieMetadata + */ + public function createCookieMetadata($metadata = []) + { + return $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\CookieMetadata', + ['metadata' => $metadata] + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php new file mode 100644 index 00000000000..9859a781e29 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php @@ -0,0 +1,782 @@ +<?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) + */ + +// @codingStandardsIgnoreStart +namespace { + $mockTranslateSetCookie = false; +} + +namespace Magento\Framework\Stdlib\Cookie { + // @codingStandardsIgnoreEnd + use Magento\Framework\Exception\InputException; + + /** + * Mock global setcookie function + * + * @param string $name + * @param string $value + * @param int $expiry + * @param string $path + * @param string $domain + * @param bool $secure + * @param bool $httpOnly + * @return bool + */ + function setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly) + { + global $mockTranslateSetCookie; + + if (isset($mockTranslateSetCookie) && $mockTranslateSetCookie === true) { + PhpCookieManagerTest::$isSetCookieInvoked = true; + return PhpCookieManagerTest::assertCookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly); + } else { + + return call_user_func_array(__FUNCTION__, func_get_args()); + } + } + + /** + * Test PhpCookieManager + * + */ + class PhpCookieManagerTest extends \PHPUnit_Framework_TestCase + { + const COOKIE_NAME = 'cookie_name'; + const SENSITIVE_COOKIE_NAME_NO_METADATA = 'sensitive_cookie_name_no_metadata'; + const SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH = 'sensitive_cookie_name_no_domain_no_path'; + const SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH = 'sensitive_cookie_name_with_domain_and_path'; + const PUBLIC_COOKIE_NAME_NO_METADATA = 'public_cookie_name_no_metadata'; + const PUBLIC_COOKIE_NAME_DEFAULT_VALUES = 'public_cookie_name_default_values'; + const PUBLIC_COOKIE_NAME_SOME_FIELDS_SET = 'public_cookie_name_some_fields_set'; + const MAX_COOKIE_SIZE_TEST_NAME = 'max_cookie_size_test_name'; + const MAX_NUM_COOKIE_TEST_NAME = 'max_num_cookie_test_name'; + const DELETE_COOKIE_NAME = 'delete_cookie_name'; + const DELETE_COOKIE_NAME_NO_METADATA = 'delete_cookie_name_no_metadata'; + const EXCEPTION_COOKIE_NAME = 'exception_cookie_name'; + const COOKIE_VALUE = 'cookie_value'; + const COOKIE_SECURE = true; + const COOKIE_NOT_SECURE = false; + const COOKIE_HTTP_ONLY = true; + const COOKIE_NOT_HTTP_ONLY = false; + const COOKIE_EXPIRE_END_OF_SESSION = 0; + const MAX_NUM_COOKIES = 20; + const MAX_COOKIE_SIZE = 4096; + + /** + * Mapping from constant names to functions that handle the assertions. + */ + static $functionTestAssertionMapping = [ + self::DELETE_COOKIE_NAME => 'self::assertDeleteCookie', + self::DELETE_COOKIE_NAME_NO_METADATA => 'self::assertDeleteCookieWithNoMetadata', + self::SENSITIVE_COOKIE_NAME_NO_METADATA => 'self::assertSensitiveCookieWithNoMetaData', + self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH => 'self::assertSensitiveCookieNoDomainNoPath', + self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH => 'self::assertSensitiveCookieWithDomainAndPath', + self::PUBLIC_COOKIE_NAME_NO_METADATA => 'self::assertPublicCookieWithNoMetaData', + self::PUBLIC_COOKIE_NAME_DEFAULT_VALUES => 'self::assertPublicCookieWithDefaultValues', + self::PUBLIC_COOKIE_NAME_NO_METADATA => 'self::assertPublicCookieWithNoMetaData', + self::PUBLIC_COOKIE_NAME_DEFAULT_VALUES => 'self::assertPublicCookieWithDefaultValues', + self::PUBLIC_COOKIE_NAME_SOME_FIELDS_SET => 'self::assertPublicCookieWithSomeFieldSet', + self::MAX_COOKIE_SIZE_TEST_NAME => 'self::assertCookieSize', + ]; + + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * Cookie Manager + * + * @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager + */ + protected $cookieManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\Cookie\CookieScope + */ + protected $scopeMock; + + /** + * @var bool + */ + public static $isSetCookieInvoked; + + protected function setUp() + { + global $mockTranslateSetCookie; + $mockTranslateSetCookie = true; + self::$isSetCookieInvoked = false; + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->scopeMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieScope') + ->setMethods(['getPublicCookieMetadata', 'getCookieMetadata', 'getSensitiveCookieMetadata']) + ->disableOriginalConstructor() + ->getMock(); + $this->cookieManager = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PhpCookieManager', + ['scope' => $this->scopeMock] + ); + } + + public function testGetCookie() + { + $_COOKIE[self::COOKIE_NAME] = self::COOKIE_VALUE; + $defaultCookieValue = 'default'; + $this->assertEquals( + $defaultCookieValue, + $this->cookieManager->getCookie('unknownCookieName', $defaultCookieValue) + ); + $this->assertEquals( + self::COOKIE_VALUE, + $this->cookieManager->getCookie(self::COOKIE_NAME, $defaultCookieValue) + ); + $this->assertEquals($defaultCookieValue, $this->cookieManager->getCookie(null, $defaultCookieValue)); + $this->assertNull($this->cookieManager->getCookie(null)); + } + + public function testDeleteCookie() + { + self::$isSetCookieInvoked = false; + $_COOKIE[self::DELETE_COOKIE_NAME] = self::COOKIE_VALUE; + + /** @var \Magento\Framework\Stdlib\Cookie\CookieMetaData $cookieMetadata */ + $cookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\CookieMetaData', + [ + 'metadata' => [ + 'domain' => 'magento.url', + 'path' => '/backend', + ] + ] + ); + + $this->scopeMock->expects($this->once()) + ->method('getCookieMetadata') + ->with($cookieMetadata) + ->will( + $this->returnValue($cookieMetadata) + ); + + $this->assertEquals(self::COOKIE_VALUE, $this->cookieManager->getCookie(self::DELETE_COOKIE_NAME)); + $this->cookieManager->deleteCookie(self::DELETE_COOKIE_NAME, $cookieMetadata); + $this->assertNull($this->cookieManager->getCookie(self::DELETE_COOKIE_NAME)); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testDeleteCookieWithNoCookieMetadata() + { + self::$isSetCookieInvoked = false; + $_COOKIE[self::DELETE_COOKIE_NAME_NO_METADATA] = self::COOKIE_VALUE; + + $cookieMetadata = $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieMetaData'); + $this->scopeMock->expects($this->once()) + ->method('getCookieMetadata') + ->with() + ->will( + $this->returnValue($cookieMetadata) + ); + + $this->assertEquals( + self::COOKIE_VALUE, + $this->cookieManager->getCookie(self::DELETE_COOKIE_NAME_NO_METADATA) + ); + $this->cookieManager->deleteCookie(self::DELETE_COOKIE_NAME_NO_METADATA); + $this->assertNull($this->cookieManager->getCookie(self::DELETE_COOKIE_NAME_NO_METADATA)); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testDeleteCookieWithFailureToSendException() + { + self::$isSetCookieInvoked = false; + $_COOKIE[self::EXCEPTION_COOKIE_NAME] = self::COOKIE_VALUE; + + $cookieMetadata = $this->objectManager->getObject('Magento\Framework\Stdlib\Cookie\CookieMetaData'); + $this->scopeMock->expects($this->once()) + ->method('getCookieMetadata') + ->with() + ->will( + $this->returnValue($cookieMetadata) + ); + + try { + $this->cookieManager->deleteCookie(self::EXCEPTION_COOKIE_NAME, $cookieMetadata); + $this->fail('Expected exception not thrown.'); + } catch (FailureToSendException $fse) { + $this->assertTrue(self::$isSetCookieInvoked); + $this->assertSame( + 'Unable to delete the cookie with cookieName = exception_cookie_name', + $fse->getMessage() + ); + } + } + + public function testSetSensitiveCookieNoMetadata() + { + self::$isSetCookieInvoked = false; + /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ + $sensitiveCookieMetadata = $this->objectManager + ->getObject('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata'); + + $this->scopeMock->expects($this->once()) + ->method('getSensitiveCookieMetadata') + ->with() + ->will( + $this->returnValue($sensitiveCookieMetadata) + ); + + $this->cookieManager->setSensitiveCookie( + self::SENSITIVE_COOKIE_NAME_NO_METADATA, + 'cookie_value' + ); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetSensitiveCookieNullDomainAndPath() + { + self::$isSetCookieInvoked = false; + /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ + $sensitiveCookieMetadata = $this->objectManager + ->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'metadata' => [ + 'domain' => null, + 'path' => null, + ], + ] + ); + + + + $this->scopeMock->expects($this->once()) + ->method('getSensitiveCookieMetadata') + ->with($sensitiveCookieMetadata) + ->will( + $this->returnValue($sensitiveCookieMetadata) + ); + + $this->cookieManager->setSensitiveCookie( + self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH, + 'cookie_value', + $sensitiveCookieMetadata + ); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetSensitiveCookieWithPathAndDomain() + { + self::$isSetCookieInvoked = false; + /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ + $sensitiveCookieMetadata = $this->objectManager + ->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'metadata' => [ + 'domain' => 'magento.url', + 'path' => '/backend', + ], + ] + ); + + $this->scopeMock->expects($this->once()) + ->method('getSensitiveCookieMetadata') + ->with($sensitiveCookieMetadata) + ->will( + $this->returnValue($sensitiveCookieMetadata) + ); + $this->cookieManager->setSensitiveCookie( + self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH, + 'cookie_value', + $sensitiveCookieMetadata + ); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetPublicCookieNoMetadata() + { + self::$isSetCookieInvoked = false; + /** @var PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + ); + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadata) + ); + + $this->cookieManager->setPublicCookie( + self::PUBLIC_COOKIE_NAME_NO_METADATA, + 'cookie_value' + ); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetPublicCookieDefaultValues() + { + /** @var PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [ + 'metadata' => [ + 'domain' => null, + 'path' => null, + 'secure' => false, + 'http_only' => false, + ], + ] + ); + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with($publicCookieMetadata) + ->will( + $this->returnValue($publicCookieMetadata) + ); + + $this->cookieManager->setPublicCookie( + self::PUBLIC_COOKIE_NAME_DEFAULT_VALUES, + 'cookie_value', + $publicCookieMetadata + ); + + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetPublicCookieSomeFieldsSet() + { + self::$isSetCookieInvoked = false; + /** @var PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [ + 'metadata' => [ + 'domain' => 'magento.url', + 'path' => '/backend', + 'http_only' => true, + ], + ] + ); + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with($publicCookieMetadata) + ->will( + $this->returnValue($publicCookieMetadata) + ); + + $this->cookieManager->setPublicCookie( + self::PUBLIC_COOKIE_NAME_SOME_FIELDS_SET, + 'cookie_value', + $publicCookieMetadata + ); + $this->assertTrue(self::$isSetCookieInvoked); + } + + public function testSetCookieBadName() + { + /** @var \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [ + 'metadata' => [ + 'domain' => null, + 'path' => null, + 'secure' => false, + 'http_only' => false, + ], + ] + ); + + $badCookieName = ''; + $cookieValue = 'some_value'; + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadata) + ); + + try { + $this->cookieManager->setPublicCookie( + $badCookieName, + $cookieValue, + $publicCookieMetadata + ); + $this->fail('Failed to throw exception of bad cookie name'); + } catch (InputException $e) { + $this->assertEquals( + 'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014', + $e->getMessage() + ); + } + } + + public function testSetCookieSizeTooLarge() + { + /** @var PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [ + 'metadata' => [ + 'domain' => null, + 'path' => null, + 'secure' => false, + 'http_only' => false, + 'duration' => 3600, + ], + ] + ); + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadata) + ); + + $cookieValue = ''; + for ($i = 0; $i < self::MAX_COOKIE_SIZE + 1; $i++) { + $cookieValue = $cookieValue . 'a'; + } + + + try { + $this->cookieManager->setPublicCookie( + self::MAX_COOKIE_SIZE_TEST_NAME, + $cookieValue, + $publicCookieMetadata + ); + $this->fail('Failed to throw exception of excess cookie size.'); + } catch (CookieSizeLimitReachedException $e) { + $this->assertEquals( + "Unable to send the cookie. Size of 'max_cookie_size_test_name' is 4123 bytes.", + $e->getMessage() + ); + } + } + + public function testSetTooManyCookies() + { + /** @var PublicCookieMetadata $publicCookieMetadata */ + $publicCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + ); + + $cookieValue = 'some_value'; + + // Set self::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE. + for ($i = count($_COOKIE); $i < self::MAX_NUM_COOKIES; $i++) { + $_COOKIE['test_cookie_' . $i] = 'some_value'; + } + + $this->scopeMock->expects($this->once()) + ->method('getPublicCookieMetadata') + ->with() + ->will( + $this->returnValue($publicCookieMetadata) + ); + + try { + $this->cookieManager->setPublicCookie( + self::MAX_COOKIE_SIZE_TEST_NAME, + $cookieValue, + $publicCookieMetadata + ); + $this->fail('Failed to throw exception of too many cookies.'); + } catch (CookieSizeLimitReachedException $e) { + $this->assertEquals( + 'Unable to send the cookie. Maximum number of cookies would be exceeded.', + $e->getMessage() + ); + } + } + + /** + * Assert public, sensitive and delete cookie + * + * Suppressing UnusedFormalParameter, since PHPMD doesn't detect the callback call. + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public static function assertCookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly) + { + if (self::EXCEPTION_COOKIE_NAME == $name) { + return false; + } elseif (isset(self::$functionTestAssertionMapping[$name])) { + call_user_func_array(self::$functionTestAssertionMapping[$name], func_get_args()); + } else { + self::fail('Non-tested case in mock setcookie()'); + } + return true; + } + + /** + * Assert delete cookie + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertDeleteCookie( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::DELETE_COOKIE_NAME, $name); + self::assertEquals('', $value); + self::assertEquals($expiry, PhpCookieManager::EXPIRE_NOW_TIME); + self::assertFalse($secure); + self::assertFalse($httpOnly); + self::assertEquals('magento.url', $domain); + self::assertEquals('/backend', $path); + } + + /** + * Assert delete cookie with no meta data + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertDeleteCookieWithNoMetadata( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::DELETE_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals('', $value); + self::assertEquals($expiry, PhpCookieManager::EXPIRE_NOW_TIME); + self::assertFalse($secure); + self::assertFalse($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + /** + * Assert sensitive cookie with no meta data + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertSensitiveCookieWithNoMetaData( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertTrue($secure); + self::assertTrue($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + /** + * Assert sensitive cookie with no domain and path + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertSensitiveCookieNoDomainNoPath( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertTrue($secure); + self::assertTrue($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + /** + * Assert sensitive cookie with domain and path + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertSensitiveCookieWithDomainAndPath( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertTrue($secure); + self::assertTrue($httpOnly); + self::assertEquals('magento.url', $domain); + self::assertEquals('/backend', $path); + } + + /** + * Assert public cookie with no metadata + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertPublicCookieWithNoMetaData( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::PUBLIC_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(self::COOKIE_EXPIRE_END_OF_SESSION, $expiry); + self::assertFalse($secure); + self::assertFalse($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + /** + * Assert public cookie with no domain and path + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertPublicCookieWithNoDomainNoPath( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::PUBLIC_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertTrue($secure); + self::assertTrue($httpOnly); + self::assertEquals('magento.url', $domain); + self::assertEquals('/backend', $path); + } + + /** + * Assert public cookie with default values + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertPublicCookieWithDefaultValues( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::PUBLIC_COOKIE_NAME_DEFAULT_VALUES, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(self::COOKIE_EXPIRE_END_OF_SESSION, $expiry); + self::assertFalse($secure); + self::assertFalse($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + /** + * Assert public cookie with no field set + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertPublicCookieWithSomeFieldSet( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::PUBLIC_COOKIE_NAME_SOME_FIELDS_SET, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(self::COOKIE_EXPIRE_END_OF_SESSION, $expiry); + self::assertFalse($secure); + self::assertTrue($httpOnly); + self::assertEquals('magento.url', $domain); + self::assertEquals('/backend', $path); + } + + /** + * Assert cookie size + * + * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + */ + private static function assertCookieSize( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::MAX_COOKIE_SIZE_TEST_NAME, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(self::COOKIE_EXPIRE_END_OF_SESSION, $expiry); + self::assertFalse($secure); + self::assertFalse($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + + public function tearDown() + { + global $mockTranslateSetCookie; + $mockTranslateSetCookie = false; + } + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php new file mode 100644 index 00000000000..a9bc0f038ec --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PublicCookieMetadataTest.php @@ -0,0 +1,72 @@ +<?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\Cookie; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Test PublicCookieMetadata + * + */ +class PublicCookieMetadataTest extends \PHPUnit_Framework_TestCase +{ + /** @var PublicCookieMetadata */ + private $publicCookieMetadata; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->publicCookieMetadata = $objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata' + ); + } + + /** + * @param String $setMethodName + * @param String $getMethodName + * @param String $expectedValue + * @dataProvider getMethodData + */ + + public function testGetters($setMethodName, $getMethodName, $expectedValue) + { + $this->publicCookieMetadata->$setMethodName($expectedValue); + $this->assertSame($expectedValue, $this->publicCookieMetadata->$getMethodName()); + } + + /** + * @return array + */ + public function getMethodData() + { + return [ + "getDomain" => ["setDomain", 'getDomain', "example.com"], + "getPath" => ["setPath", 'getPath', "path"], + "getDuration" => ["setDuration", 'getDuration', 125], + "getHttpOnly" => ["setHttpOnly", 'getHttpOnly', true], + "getSecure" => ["setSecure", 'getSecure', true] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php new file mode 100644 index 00000000000..ce9c1b8e4f0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php @@ -0,0 +1,68 @@ +<?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\Cookie; + +use Magento\TestFramework\Helper\ObjectManager; + +/** + * Test SensitiveCookieMetaData + * + */ +class SensitiveCookieMetadataTest extends \PHPUnit_Framework_TestCase +{ + /** @var SensitiveCookieMetadata */ + private $sensitiveCookieMetadata; + + public function setUp() + { + $objectManager = new ObjectManager($this); + $this->sensitiveCookieMetadata = $objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata' + ); + } + + /** + * @param String $setMethodName + * @param String $getMethodName + * @param String $expectedValue + * @dataProvider getMethodData + */ + + public function testGetters($setMethodName, $getMethodName, $expectedValue) + { + $this->sensitiveCookieMetadata->$setMethodName($expectedValue); + $this->assertSame($expectedValue, $this->sensitiveCookieMetadata->$getMethodName()); + } + + /** + * @return array + */ + public function getMethodData() + { + return [ + "getDomain" => ["setDomain", 'getDomain', "example.com"], + "getPath" => ["setPath", 'getPath', "path"] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Validator/ExceptionTest.php b/dev/tests/unit/testsuite/Magento/Framework/Validator/ExceptionTest.php index 7c3fca468fe..16ba57eb90f 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Validator/ExceptionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Validator/ExceptionTest.php @@ -24,6 +24,8 @@ namespace Magento\Framework\Validator; +use \Magento\Framework\Exception\InputException; + /** * Test case for \Magento\Framework\Validator\ValidatorException */ @@ -36,7 +38,12 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase { $expectedMessage = 'error1' . PHP_EOL . 'error2' . PHP_EOL . 'error3'; $messages = array('field1' => array('error1', 'error2'), 'field2' => array('error3')); - $exception = new \Magento\Framework\Validator\ValidatorException($messages); + $exception = new \Magento\Framework\Validator\ValidatorException( + InputException::DEFAULT_MESSAGE, + [], + null, + $messages + ); $this->assertEquals($expectedMessage, $exception->getMessage()); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php index da7825859eb..5a675e46df1 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php @@ -63,7 +63,12 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase 'CaPSed BLOCK NAME', array('cAp$Ed PaRaM1', 'caPs2', 'bUT-TOn') ), - array(' data-ui-id="block-0-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20" ', '!block!', range(0, 20)) + array( + ' data-ui-id="capsed-block-name-cap-ed-param1-caps2-but-ton-but-ton" ', + 'CaPSed BLOCK NAME', + array('cAp$Ed PaRaM1', 'caPs2', 'bUT-TOn', 'bUT-TOn') + ), + array(' data-ui-id="block-0-1-2-3-4" ', '!block!', range(0, 5)) ); } diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.php new file mode 100644 index 00000000000..92d2ca223a7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAddTest.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\GoogleShopping\Controller\Adminhtml\Googleshopping\Items; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class MassAddTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\MassAdd */ + protected $controller; + + /** + * @var \Magento\GoogleShopping\Model\Flag + */ + protected $flag; + + /** + * @var array + */ + protected $controllerArguments; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $notificationInterface; + + protected function setUp() + { + $this->notificationInterface = $this->getMock('Magento\Framework\Notification\NotifierInterface'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->controllerArguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\MassAdd', + [ + 'notifier' => $this->notificationInterface + ] + ); + $this->flag = $this->getMockBuilder('Magento\GoogleShopping\Model\Flag')->disableOriginalConstructor() + ->setMethods(array('loadSelf', '__sleep', '__wakeup', 'isLocked', 'lock', 'unlock'))->getMock(); + $this->flag->expects($this->once())->method('loadSelf')->will($this->returnSelf()); + $this->flag->expects($this->once())->method('isLocked')->will($this->returnValue(false)); + + $store = $this->getMockBuilder('\Magento\Store\Model\Store')->disableOriginalConstructor() + ->setMethods(array('getId', '__sleep', '__wakeup'))->getMock(); + $store->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); + + $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); + + $this->controllerArguments['context']->getObjectManager() + ->expects($this->at(0))->method('get')->with('Magento\GoogleShopping\Model\Flag') + ->will($this->returnValue($this->flag)); + $this->controllerArguments['context']->getObjectManager() + ->expects($this->at(1))->method('get')->with('Magento\Store\Model\StoreManagerInterface') + ->will($this->returnValue($storeManager)); + + $this->controller = $this->objectManagerHelper->getObject( + 'Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\MassAdd', + $this->controllerArguments + ); + } + + public function testExecuteWithException() + { + $this->flag->expects($this->once())->method('lock') + ->will($this->throwException(new \Exception('Test exception'))); + + $logger = $this->getMockBuilder('Magento\Framework\Logger')->setMethods(array('logException')) + ->disableOriginalConstructor()->getMock(); + $this->controllerArguments['context']->getObjectManager() + ->expects($this->at(2))->method('get')->with('Magento\Framework\Logger') + ->will($this->returnValue($logger)); + + $this->controller->execute(); + } + + public function testExecute() + { + $massOperations = $this->getMockBuilder('Magento\GoogleShopping\Model\MassOperations') + ->disableOriginalConstructor()->setMethods(array('setFlag', 'addProducts'))->getMock(); + $massOperations->expects($this->once())->method('setFlag')->will($this->returnSelf()); + $massOperations->expects($this->once())->method('addProducts')->will($this->returnSelf()); + + $this->controllerArguments['context']->getObjectManager()->expects($this->once())->method('create') + ->with('Magento\GoogleShopping\Model\MassOperations') + ->will($this->returnValue($massOperations)); + + $this->controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/RefreshTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/RefreshTest.php new file mode 100644 index 00000000000..62fe8912634 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/RefreshTest.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\GoogleShopping\Controller\Adminhtml\Googleshopping\Items; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class RefreshTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\Refresh + */ + protected $controller; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\GoogleShopping\Model\Flag + */ + protected $flag; + + /** + * @var array + */ + protected $controllerArguments; + + /** + * @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $notificationInterface; + + protected function setUp() + { + $this->notificationInterface = $this->getMock('Magento\Framework\Notification\NotifierInterface'); + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->controllerArguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\Refresh', + [ + 'notifier' => $this->notificationInterface + ] + ); + + $this->flag = $this->getMockBuilder('Magento\GoogleShopping\Model\Flag')->disableOriginalConstructor() + ->setMethods(array('loadSelf', '__sleep', '__wakeup', 'isLocked', 'lock', 'unlock'))->getMock(); + $this->flag->expects($this->once())->method('loadSelf')->will($this->returnSelf()); + $this->flag->expects($this->once())->method('isLocked')->will($this->returnValue(false)); + $this->flag->expects($this->once())->method('unlock')->will($this->returnSelf()); + + /** @var \PHPUnit_Framework_MockObject_MockObject $objectMananger */ + $objectMananger = $this->controllerArguments['context']->getObjectManager(); + $objectMananger->expects($this->at(0))->method('get')->with('Magento\GoogleShopping\Model\Flag') + ->will($this->returnValue($this->flag)); + + $this->controller = $this->objectManagerHelper->getObject( + 'Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items\Refresh', + $this->controllerArguments + ); + } + + public function testExecuteWithException() + { + $this->flag->expects($this->once())->method('lock') + ->will($this->throwException(new \Exception('Test exception'))); + + $logger = $this->getMockBuilder('Magento\Framework\Logger')->setMethods(array('logException')) + ->disableOriginalConstructor()->getMock(); + $this->controllerArguments['context']->getObjectManager()->expects($this->at(1))->method('get') + ->with('Magento\Framework\Logger') + ->will($this->returnValue($logger)); + + $this->controller->execute(); + } + + public function testExecute() + { + $massOperations = $this->getMockBuilder('Magento\GoogleShopping\Model\MassOperations') + ->disableOriginalConstructor()->setMethods(array('setFlag', 'synchronizeItems'))->getMock(); + $massOperations->expects($this->once())->method('setFlag')->will($this->returnSelf()); + $massOperations->expects($this->once())->method('synchronizeItems')->will($this->returnSelf()); + + $this->controllerArguments['context']->getObjectManager()->expects($this->once())->method('create') + ->with('Magento\GoogleShopping\Model\MassOperations') + ->will($this->returnValue($massOperations)); + + $this->controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php new file mode 100644 index 00000000000..abc62510be2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php @@ -0,0 +1,193 @@ +<?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\GoogleShopping\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class MassOperationsTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\GoogleShopping\Model\MassOperations */ + protected $massOperations; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $collectionFactory; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $itemFactory; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $productFactory; + + /** @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $notificationInterface; + + /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $storeManagerInterface; + + /** @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject */ + protected $logger; + + /** @var \Magento\GoogleShopping\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $googleShoppingHelper; + + /** @var \Magento\GoogleShopping\Helper\Category|\PHPUnit_Framework_MockObject_MockObject */ + protected $googleShoppingCategoryHelper; + + protected function setUp() + { + $this->collectionFactory = $this->getMockBuilder( + 'Magento\GoogleShopping\Model\Resource\Item\CollectionFactory' + )->disableOriginalConstructor()->setMethods(array('create'))->getMock(); + + $this->itemFactory = $this->getMock('Magento\GoogleShopping\Model\ItemFactory'); + $this->productFactory = $this->getMock('Magento\Catalog\Model\ProductFactory'); + $this->notificationInterface = $this->getMock('Magento\Framework\Notification\NotifierInterface'); + $this->storeManagerInterface = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->logger = $this->getMock('Magento\Framework\Logger', [], [], '', false); + $this->googleShoppingHelper = $this->getMock('Magento\GoogleShopping\Helper\Data', [], [], '', false); + $this->googleShoppingCategoryHelper = $this->getMock('Magento\GoogleShopping\Helper\Category'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->massOperations = $this->objectManagerHelper->getObject( + 'Magento\GoogleShopping\Model\MassOperations', + [ + 'collectionFactory' => $this->collectionFactory, + 'itemFactory' => $this->itemFactory, + 'productFactory' => $this->productFactory, + 'notifier' => $this->notificationInterface, + 'storeManager' => $this->storeManagerInterface, + 'logger' => $this->logger, + 'gleShoppingData' => $this->googleShoppingHelper, + 'gleShoppingCategory' => $this->googleShoppingCategoryHelper + ] + ); + } + + public function testSynchronizeItems() + { + $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') + ->disableOriginalConstructor()->setMethods(array('count', 'addFieldToFilter', 'getIterator'))->getMock(); + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + $collection->expects($this->once())->method('count')->will($this->returnValue(1)); + + $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock(); + $iterator = new \ArrayIterator([$item]); + $collection->expects($this->once())->method('getIterator')->will($this->returnValue($iterator)); + + $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); + + $this->notificationInterface->expects($this->once())->method('addNotice') + ->with( + 'Product synchronization with Google Shopping completed', + 'A total of 0 items(s) have been deleted; a total of 1 items(s) have been updated.' + )->will($this->returnSelf()); + + $this->massOperations->synchronizeItems(array(1)); + } + + public function testSynchronizeItemsWithException() + { + $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') + ->disableOriginalConstructor()->setMethods(array('count', 'addFieldToFilter', 'getIterator'))->getMock(); + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + $collection->expects($this->once())->method('count')->will($this->returnValue(1)); + + $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock(); + $item->expects($this->once())->method('save')->will($this->throwException(new \Exception('Test exception'))); + + $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + ->setMethods(array('getName', '__sleep', '__wakeup'))->getMock(); + $product->expects($this->once())->method('getName')->will($this->returnValue('Product Name')); + + $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); + $iterator = new \ArrayIterator([$item]); + $collection->expects($this->once())->method('getIterator')->will($this->returnValue($iterator)); + + $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); + + $this->notificationInterface->expects($this->once())->method('addMajor') + ->with( + 'Errors happened during synchronization with Google Shopping', + array('We cannot update 1 items.', 'The item "Product Name" hasn\'t been updated.') + )->will($this->returnSelf()); + $this->massOperations->synchronizeItems(array(1)); + } + + public function testDeleteItems() + { + $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock(); + $item->expects($this->once())->method('deleteItem')->will($this->returnSelf()); + $item->expects($this->once())->method('delete')->will($this->returnSelf()); + + $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') + ->disableOriginalConstructor()->setMethods(array('count', 'addFieldToFilter', 'getIterator'))->getMock(); + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + $collection->expects($this->once())->method('count')->will($this->returnValue(1)); + $collection->expects($this->once())->method('getIterator') + ->will($this->returnValue(new \ArrayIterator([$item]))); + + $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); + + $this->notificationInterface->expects($this->once())->method('addNotice') + ->with( + 'Google Shopping item removal process succeded', + 'Total of 1 items(s) have been removed from Google Shopping.' + )->will($this->returnSelf()); + + $this->massOperations->deleteItems(array(1)); + } + + public function testDeleteItemsWitException() + { + $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + ->setMethods(array('getName', '__sleep', '__wakeup'))->getMock(); + $product->expects($this->once())->method('getName')->will($this->returnValue('Product Name')); + + $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock(); + $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); + $item->expects($this->once())->method('deleteItem') + ->will($this->throwException(new \Exception('Test exception'))); + + $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') + ->disableOriginalConstructor()->setMethods(array('count', 'addFieldToFilter', 'getIterator'))->getMock(); + $collection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf()); + $collection->expects($this->once())->method('count')->will($this->returnValue(1)); + $collection->expects($this->once())->method('getIterator') + ->will($this->returnValue(new \ArrayIterator([$item]))); + + $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($collection)); + + $this->notificationInterface->expects($this->once())->method('addMajor') + ->with( + 'Errors happened while deleting items from Google Shopping', + array('The item "Product Name" hasn\'t been deleted.') + )->will($this->returnSelf()); + $this->massOperations->deleteItems(array(1)); + + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ObserverTest.php new file mode 100644 index 00000000000..f58cef3015c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ObserverTest.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\GoogleShopping\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\GoogleShopping\Model\Observer */ + protected $observer; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $collectionFactory; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $massOperationsFactory; + + /** @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $notificationInterface; + + /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $scopeConfigInterface; + + /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $managerInterface; + + /** @var \Magento\GoogleShopping\Model\Flag|\PHPUnit_Framework_MockObject_MockObject */ + protected $flag; + + protected function setUp() + { + $this->collectionFactory = $this->getMock('Magento\GoogleShopping\Model\Resource\Item\CollectionFactory'); + $this->massOperationsFactory = $this->getMock('Magento\GoogleShopping\Model\MassOperationsFactory'); + $this->notificationInterface = $this->getMock('Magento\Framework\Notification\NotifierInterface'); + $this->scopeConfigInterface = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->managerInterface = $this->getMock('Magento\Framework\Message\ManagerInterface'); + $this->flag = $this->getMockBuilder('Magento\GoogleShopping\Model\Flag') + ->setMethods(['loadSelf', 'isExpired', 'unlock', '__sleep', '__wakeup']) + ->disableOriginalConstructor()->getMock(); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->observer = $this->objectManagerHelper->getObject( + 'Magento\GoogleShopping\Model\Observer', + [ + 'collectionFactory' => $this->collectionFactory, + 'operationsFactory' => $this->massOperationsFactory, + 'notifier' => $this->notificationInterface, + 'scopeConfig' => $this->scopeConfigInterface, + 'messageManager' => $this->managerInterface, + 'flag' => $this->flag + ] + ); + } + + public function testCheckSynchronizationOperations() + { + $this->flag->expects($this->once())->method('loadSelf')->will($this->returnSelf()); + $this->flag->expects($this->once())->method('isExpired')->will($this->returnValue(true)); + $observer = $this->objectManagerHelper->getObject('\Magento\Framework\Event\Observer'); + $this->notificationInterface->expects($this->once())->method('addMajor') + ->with( + 'Google Shopping operation has expired.', + 'One or more google shopping synchronization operations failed because of timeout.' + )->will($this->returnSelf()); + $this->observer->checkSynchronizationOperations($observer); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/Integration/TokensDialogTest.php b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/Integration/TokensDialogTest.php index ac2641b635e..54192a1a5ff 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/Integration/TokensDialogTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/Integration/TokensDialogTest.php @@ -98,7 +98,7 @@ class TokensDialogTest extends \Magento\Integration\Controller\Adminhtml\Integra $this->returnValue($this->_getIntegrationModelMock()) ); - $this->_oauthSvcMock->expects($this->once())->method('deleteToken'); + $this->_oauthSvcMock->expects($this->once())->method('deleteIntegrationToken'); $this->_oauthSvcMock->expects($this->once())->method('postToConsumer'); $this->_messageManager->expects($this->once())->method('addNotice'); diff --git a/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php b/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php index 027c684f910..6464cf29a30 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php @@ -112,6 +112,8 @@ class OauthTest extends \PHPUnit_Framework_TestCase 'getConsumerId', 'convertToAccess', 'getRevoked', + 'getResource', + 'loadByConsumerIdAndUserType', '__wakeup' ) ) @@ -139,7 +141,8 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_consumerFactory, $this->_tokenFactory, $this->_dataHelperMock, - $this->_dateMock + $this->_dateMock, + $this->_tokenMock ); $this->_oauth = new \Magento\Framework\Oauth\Oauth( $this->_oauthHelperMock, @@ -401,6 +404,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenMock->expects($this->any())->method('getVerifier')->will($this->returnValue($verifier)); $this->_tokenMock->expects($this->any())->method('convertToAccess')->will($this->returnSelf()); $this->_tokenMock->expects($this->any())->method('getRevoked')->will($this->returnValue($isRevoked)); + $this->_tokenMock->expects($this->any())->method('loadByConsumerIdAndUserType')->will($this->returnSelf()); } /** diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.php new file mode 100644 index 00000000000..4e9b2a4e8bc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AuthorizationServiceTest.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\Integration\Service\V1; + +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\UserContextInterface; + +class AuthorizationServiceTest extends \PHPUnit_Framework_TestCase +{ + /** @var \PHPUnit_Framework_MockObject_MockObject|Role */ + protected $roleMock; + + /** @var AuthorizationService */ + protected $integrationAuthorizationService; + + protected function setUp() + { + $this->roleMock = $this->getMock( + 'Magento\Authorization\Model\Role', + array('load', 'delete', '__wakeup'), + array(), + '', + false + ); + $this->roleMock->expects($this->any())->method('load')->will($this->returnSelf()); + $this->roleMock->expects($this->any())->method('delete')->will($this->returnSelf()); + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\RoleFactory $roleFactoryMock */ + $roleFactoryMock = $this->getMock( + 'Magento\Authorization\Model\RoleFactory', + array('create'), + array(), + '', + false + ); + $roleFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->roleMock)); + + $this->integrationAuthorizationService = new AuthorizationService( + $this->getMock('Magento\Framework\Acl\Builder', array(), array(), '', false), + $roleFactoryMock, + $this->getMock('Magento\Authorization\Model\Resource\Role\CollectionFactory', array(), array(), '', false), + $this->getMock('Magento\Authorization\Model\RulesFactory', array(), array(), '', false), + $this->getMock('Magento\Authorization\Model\Resource\Rules\CollectionFactory', array(), array(), '', false), + $this->getMock('Magento\Framework\Logger', array(), array(), '', false), + $this->getMock('Magento\Framework\Acl\RootResource', array(), array(), '', false) + ); + } + + public function testRemovePermissions() + { + $integrationId = 22; + $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId; + $this->roleMock->expects($this->once())->method('load')->with($roleName)->will($this->returnSelf()); + $this->integrationAuthorizationService->removePermissions($integrationId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/IntegrationTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/IntegrationTest.php index 6199dc10aa7..99ab443c989 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/IntegrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/IntegrationTest.php @@ -94,9 +94,6 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_integrationMock) ); - $userIdentifierFactory = $this->getMockBuilder( - 'Magento\Authz\Model\UserIdentifier\Factory' - )->disableOriginalConstructor()->getMock(); $oauthConsumerHelper = $this->getMockBuilder( 'Magento\Integration\Service\V1\Oauth' )->disableOriginalConstructor()->getMock(); @@ -111,10 +108,6 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase $this->returnValue($oauthConsumer) ); $oauthConsumerHelper->expects($this->any())->method('loadConsumer')->will($this->returnValue($oauthConsumer)); - $userIdentifier = $this->getMockBuilder( - 'Magento\Authz\Model\UserIdentifier' - )->disableOriginalConstructor()->getMock(); - $userIdentifierFactory->expects($this->any())->method('create')->will($this->returnValue($userIdentifier)); $this->_service = new \Magento\Integration\Service\V1\Integration( $this->_integrationFactory, diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php index 2f6ca070d83..199ccae56c8 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php @@ -177,7 +177,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); @@ -214,7 +214,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); @@ -239,7 +239,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->throwException( new \Magento\Framework\Oauth\Exception( @@ -353,14 +353,14 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); $this->_tokenMock->expects($this->once())->method('delete'); - $this->assertTrue($this->_service->deleteToken(self::VALUE_CONSUMER_ID)); + $this->assertTrue($this->_service->deleteIntegrationToken(self::VALUE_CONSUMER_ID)); } public function testDeleteTokenNegative() @@ -378,14 +378,14 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); $this->_tokenMock->expects($this->never())->method('delete'); - $this->assertFalse($this->_service->deleteToken(null)); + $this->assertFalse($this->_service->deleteIntegrationToken(null)); } public function testGetAccessTokenNoAccess() @@ -403,7 +403,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); @@ -428,7 +428,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_tokenProviderMock->expects( $this->any() )->method( - 'getTokenByConsumerId' + 'getIntegrationTokenByConsumerId' )->will( $this->returnValue($this->_tokenMock) ); diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Plugin/TabsTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Plugin/TabsTest.php new file mode 100644 index 00000000000..ac9a2fd6d95 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Model/Plugin/TabsTest.php @@ -0,0 +1,73 @@ +<?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\RecurringPayment\Model\Plugin; + +class TabsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @param $collection \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection + * @param $isOutputEnabled bool + * @param $size int + * + * @dataProvider getGroupCollectionDataProvider + */ + public function testAfterGetGroupCollection($collection, $isOutputEnabled, $size) + { + $moduleManager = $this->getMock('Magento\Framework\Module\Manager', [], [], '', false); + $moduleManager->expects($this->once()) + ->method('isOutputEnabled') + ->with('Magento_RecurringPayment') + ->will($this->returnValue($isOutputEnabled) + ); + + $subject = $this->getMock('Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs', [], [], '', false); + $object = new \Magento\RecurringPayment\Model\Plugin\Tabs($moduleManager); + + $collection = $object->afterGetGroupCollection($subject, $collection); + $this->assertEquals($collection->getSize(), $size); + } + + public function getGroupCollectionDataProvider() + { + $item1 = new \Magento\Framework\Object(['attribute_group_code' => 'recurring-payment']); + $item2 = new \Magento\Framework\Object(['attribute_group_code' => 'data1']); + $item3 = new \Magento\Framework\Object(['attribute_group_code' => 'data2']); + + $collection1 = new \Magento\Framework\Data\Collection( + $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false) + ); + $collection1->addItem($item1); + $collection1->addItem($item2); + + $collection2 = clone $collection1; + + $collection3 = new \Magento\Framework\Data\Collection( + $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false) + ); + $collection3->addItem($item2); + $collection3->addItem($item3); + + return [[$collection1, true, 2], [$collection2, false, 1], [$collection3, false, 2]]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php index 1d7625239cb..433b70301f7 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php @@ -143,11 +143,13 @@ class DataTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getScopeConfigValue - * @return void */ public function testCanSendNewOrderConfirmationEmail($scopeConfigValue) { - $this->setupScopeConfigIsSetFlag(\Magento\Sales\Model\Order::XML_PATH_EMAIL_ENABLED, $scopeConfigValue); + $this->setupScopeConfigIsSetFlag( + \Magento\Sales\Model\Order\Email\Container\OrderIdentity::XML_PATH_EMAIL_ENABLED, + $scopeConfigValue + ); $this->assertEquals($scopeConfigValue, $this->helper->canSendNewOrderConfirmationEmail($this->storeMock)); } @@ -158,7 +160,10 @@ class DataTest extends \PHPUnit_Framework_TestCase */ public function testCanSendNewOrderEmail($scopeConfigValue) { - $this->setupScopeConfigIsSetFlag(\Magento\Sales\Model\Order::XML_PATH_EMAIL_ENABLED, $scopeConfigValue); + $this->setupScopeConfigIsSetFlag( + \Magento\Sales\Model\Order\Email\Container\OrderIdentity::XML_PATH_EMAIL_ENABLED, + $scopeConfigValue + ); $this->assertEquals($scopeConfigValue, $this->helper->canSendNewOrderEmail($this->storeMock)); } @@ -170,7 +175,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testCanSendOrderCommentEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -184,7 +189,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testCanSendNewShipmentEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -198,7 +203,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testCanSendShipmentCommentEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -207,12 +212,11 @@ class DataTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getScopeConfigValue - * @return void */ public function testCanSendNewInvoiceEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -221,12 +225,11 @@ class DataTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getScopeConfigValue - * @return void */ public function testCanSendInvoiceCommentEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -240,7 +243,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testCanSendNewCreditmemoEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); @@ -254,7 +257,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testCanSendCreditmemoCommentEmail($scopeConfigValue) { $this->setupScopeConfigIsSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity::XML_PATH_EMAIL_ENABLED, $scopeConfigValue ); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php index 539dbabda3f..3112c42692d 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -50,6 +50,11 @@ class CreateTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Sales\Model\Quote\Item\Updater|\PHPUnit_Framework_MockObject_MockObject */ protected $itemUpdater; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectFactory; + protected function setUp() { $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); @@ -71,8 +76,8 @@ class CreateTest extends \PHPUnit_Framework_TestCase ); $this->formFactoryMock = $this->getMock( 'Magento\Customer\Model\Metadata\FormFactory', - array(), - array(), + ['create'], + [], '', false ); @@ -88,6 +93,11 @@ class CreateTest extends \PHPUnit_Framework_TestCase $this->itemUpdater = $this->getMock('Magento\Sales\Model\Quote\Item\Updater', array(), array(), '', false); + $this->objectFactory = $this->getMockBuilder('\Magento\Framework\Object\Factory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $objectManagerHelper = new ObjectManagerHelper($this); $this->adminOrderCreate = $objectManagerHelper->getObject( 'Magento\Sales\Model\AdminOrder\Create', @@ -107,7 +117,8 @@ class CreateTest extends \PHPUnit_Framework_TestCase 'customerBuilder' => $this->customerBuilderMock, 'customerHelper' => $customerHelperMock, 'customerGroupService' => $this->customerGroupServiceMock, - 'quoteItemUpdater' => $this->itemUpdater + 'quoteItemUpdater' => $this->itemUpdater, + 'objectFactory' => $this->objectFactory ) ); } @@ -224,7 +235,8 @@ class CreateTest extends \PHPUnit_Framework_TestCase $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); $this->itemUpdater->expects($this->once()) ->method('update') - ->with($this->equalTo($itemMock), $this->equalTo($items[1])); + ->with($this->equalTo($itemMock), $this->equalTo($items[1])) + ->will($this->returnSelf()); $this->adminOrderCreate->setRecollect(false); $this->adminOrderCreate->updateQuoteItems($items); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/EmailSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/EmailSenderTest.php index 8899af9c455..dc27b688da9 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/EmailSenderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/EmailSenderTest.php @@ -45,6 +45,11 @@ class EmailSenderTest extends \PHPUnit_Framework_TestCase */ protected $emailSender; + /** + * @var \Magento\Sales\Model\Order\Email\Sender\OrderSender + */ + protected $orderSenderMock; + protected function setUp() { $this->messageManagerMock = $this->getMock( @@ -68,20 +73,28 @@ class EmailSenderTest extends \PHPUnit_Framework_TestCase '', false ); - $this->emailSender = new EmailSender($this->messageManagerMock, $this->loggerMock); + $this->orderSenderMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Sender\OrderSender', + [], + [], + '', + false + ); + + $this->emailSender = new EmailSender($this->messageManagerMock, $this->loggerMock, $this->orderSenderMock); } public function testSendSuccess() { - $this->orderMock->expects($this->once()) - ->method('sendNewOrderEmail'); + $this->orderSenderMock->expects($this->once()) + ->method('send'); $this->assertTrue($this->emailSender->send($this->orderMock)); } public function testSendFailure() { - $this->orderMock->expects($this->once()) - ->method('sendNewOrderEmail') + $this->orderSenderMock->expects($this->once()) + ->method('send') ->will($this->throwException(new \Magento\Framework\Mail\Exception('test message'))); $this->messageManagerMock->expects($this->once()) ->method('addWarning'); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.php new file mode 100644 index 00000000000..efc875255ce --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/NotifierTest.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; + +use Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory; +use Magento\Framework\Mail\Exception; + +/** + * Class NotifierTest + */ +class NotifierTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CollectionFactory |\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyCollectionFactory; + + /** + * @var \Magento\Sales\Model\Notifier + */ + protected $notifier; + + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $order; + + /** + * @var \Magento\Framework\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager |\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderSenderMock; + + public function setUp() + { + $this->historyCollectionFactory = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->order = $this->getMock( + 'Magento\Sales\Model\Order', + ['__wakeUp', 'getEmailSent'], + [], + '', + false + ); + $this->orderSenderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender\OrderSender', + ['send'], + [], + '', + false + ); + $this->loggerMock = $this->getMock( + 'Magento\Framework\Logger', + ['logException'], + [], + '', + false + ); + $this->notifier = new Notifier( + $this->historyCollectionFactory, + $this->loggerMock, + $this->orderSenderMock + ); + } + + /** + * 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->order, \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME) + ->will($this->returnValue($historyItem)); + $this->order->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(true)); + $this->historyCollectionFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($historyCollection)); + + $this->orderSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->order)); + + $this->assertTrue($this->notifier->notify($this->order)); + } + + /** + * Test case when email has not been sent + */ + public function testNotifyFail() + { + $this->order->expects($this->once()) + ->method('getEmailSent') + ->will($this->returnValue(false)); + $this->assertFalse($this->notifier->notify($this->order)); + } + + /** + * Test case when Mail Exception has been thrown + */ + public function testNotifyException() + { + $exception = new Exception('Email has not been sent'); + $this->orderSenderMock->expects($this->once()) + ->method('send') + ->with($this->equalTo($this->order)) + ->will($this->throwException($exception)); + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with($this->equalTo($exception)); + $this->assertFalse($this->notifier->notify($this->order)); + } +} 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 new file mode 100644 index 00000000000..f2de0967f52 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Address/ValidatorTest.php @@ -0,0 +1,124 @@ +<?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\Address; + +/** + * Class ValidatorTest + */ +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Address\Validator + */ + protected $validator; + + /** + * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressMock; + + /** + * Mock order address model + */ + public function setUp() + { + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + ['hasData', 'getEmail', 'getAddressType', '__wakeup'], + [], + '', + false + ); + $this->validator = new \Magento\Sales\Model\Order\Address\Validator(); + } + + /** + * @param $addressData + * @param $expectedWarnings + * @dataProvider providerAddressData + */ + public function testValidate($addressData, $email, $addressType, $expectedWarnings) + { + $this->addressMock->expects($this->any()) + ->method('hasData') + ->will($this->returnValueMap($addressData)); + $this->addressMock->expects($this->once()) + ->method('getEmail') + ->will($this->returnValue($email)); + $this->addressMock->expects($this->once()) + ->method('getAddressType') + ->will($this->returnValue($addressType)); + $actualWarnings = $this->validator->validate($this->addressMock); + $this->assertEquals($expectedWarnings, $actualWarnings); + } + + /** + * Provides address data for tests + * + * @return array + */ + public function providerAddressData() + { + return [ + [ + [ + ['parent_id', true], + ['postcode', true], + ['lastname', true], + ['street', true], + ['city', true], + ['email', true], + ['telephone', true], + ['country_id', true], + ['firstname', true], + ['address_type', true], + ], + 'co@co.co', + 'billing', + [] + ], + [ + [ + ['parent_id', true], + ['postcode', true], + ['lastname', true], + ['street', false], + ['city', true], + ['email', true], + ['telephone', true], + ['country_id', true], + ['firstname', true], + ['address_type', true], + ], + 'co.co.co', + 'coco-shipping', + [ + 'Street is a required field', + 'Email has a wrong format', + 'Address type doesn\'t match required options' + ] + ] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php new file mode 100644 index 00000000000..40df95b36e0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class CreditmemoCommentIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new CreditmemoCommentIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentityTest.php new file mode 100644 index 00000000000..ecc74e1b9c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class CreditmemoIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new CreditmemoIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentityTest.php new file mode 100644 index 00000000000..420b5f951f0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class InvoiceCommentIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new InvoiceCommentIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceIdentityTest.php new file mode 100644 index 00000000000..e05985e0687 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/InvoiceIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class InvoiceIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new InvoiceIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentityTest.php new file mode 100644 index 00000000000..5aa8adb9d51 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class OrderCommentIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new OrderCommentIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderIdentityTest.php new file mode 100644 index 00000000000..1b02572af57 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/OrderIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class OrderIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\OrderIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new OrderIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentityTest.php new file mode 100644 index 00000000000..20d89ac2108 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class ShipmentCommentIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new ShipmentCommentIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentIdentityTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentIdentityTest.php new file mode 100644 index 00000000000..e4258a8a544 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/ShipmentIdentityTest.php @@ -0,0 +1,222 @@ +<?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\Email\Container; + +class ShipmentIdentityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity + */ + protected $identity; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigInterfaceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + protected $storeId; + + protected function setUp() + { + $this->scopeConfigInterfaceMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Stub\ScopeConfigInterfaceMock', + [], + [], + '', + false + ); + $this->storeManagerMock = $this->getMock( + '\Magento\Store\Model\Storage\DefaultStorage', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->storeId = 999999999999; + $this->storeMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue($this->storeId)); + + $this->identity = new ShipmentIdentity($this->scopeConfigInterfaceMock, $this->storeManagerMock); + } + + public function testIsEnabledTrue() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('isSetFlag') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_ENABLED), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(true)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->isEnabled(); + $this->assertTrue($result); + } + + public function testGetEmailCopyTo() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value,test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + + public function testGetEmailCopyToEmptyResult() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue(null)); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertFalse($result); + } + + public function testCopyMethod() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_COPY_METHOD), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('copy_method')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getCopyMethod(); + $this->assertEquals('copy_method', $result); + } + + public function testGuestTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_GUEST_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getGuestTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testTemplateId() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_TEMPLATE), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('template_id')); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getTemplateId(); + $this->assertEquals('template_id', $result); + } + + public function testSetStore() + { + $this->identity->setStore($this->storeMock); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testGetStoreFromStoreManager() + { + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $result = $this->identity->getStore(); + $this->assertEquals($this->storeMock, $result); + } + + public function testSetCustomerEmail() + { + $this->identity->setCustomerEmail('email'); + $result = $this->identity->getCustomerEmail(); + $this->assertEquals('email', $result); + } + + public function testSetCusomerName() + { + $this->identity->setCustomerName('name'); + $result = $this->identity->getCustomerName(); + $this->assertEquals('name', $result); + } + + public function testGetEmailIdentity() + { + $emailIdentity = 'test@example.com'; + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_IDENTITY), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue($emailIdentity)); + + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailIdentity(); + $this->assertEquals($emailIdentity, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/Stub/ScopeConfigInterfaceMock.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/Stub/ScopeConfigInterfaceMock.php new file mode 100644 index 00000000000..cb1c05fb5e2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/Stub/ScopeConfigInterfaceMock.php @@ -0,0 +1,39 @@ +<?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\Email\Container\Stub; + +use Magento\Framework\App\Config\ScopeConfigInterface; + +class ScopeConfigInterfaceMock implements ScopeConfigInterface +{ + public function getValue($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeCode = null) + { + return; + } + + public function isSetFlag($path, $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, $scopeCode = null) + { + return; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/TemplateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/TemplateTest.php new file mode 100644 index 00000000000..e3a2af5fa70 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Container/TemplateTest.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\Model\Order\Email\Container; + +class TemplateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Container\Template + */ + protected $template; + + protected function setUp() + { + $this->template = new Template(); + } + + public function testSetTemplateId() + { + $templateId = 'test_template_id'; + $this->template->setTemplateId($templateId); + $result = $this->template->getTemplateId(); + $this->assertEquals($templateId, $result); + } + + public function testSetTemplateOptions() + { + $templateOptions = ['opt1', 'opt2']; + $this->template->setTemplateOptions($templateOptions); + $result = $this->template->getTemplateOptions(); + $this->assertEquals($templateOptions, $result); + } + + public function testSetTemplateVars() + { + $templateVars = ['opt1', 'opt2']; + $this->template->setTemplateVars($templateVars); + $result = $this->template->getTemplateVars(); + $this->assertEquals($templateVars, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php new file mode 100644 index 00000000000..2f92489627a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php @@ -0,0 +1,238 @@ +<?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\Email\Sender; + +class CreditmemoCommentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->creditmemoMock = $this->getMock( + '\Magento\Sales\Model\Order\Creditmemo', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->creditmemoMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->creditmemoMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + $this->sender = new CreditmemoCommentSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->creditmemoMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'creditmemo' => $this->creditmemoMock, + 'comment' => $comment, + 'billing' => $billingAddress, + 'store' => $this->storeMock + ] + ) + ); + + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->creditmemoMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'creditmemo' => $this->creditmemoMock, + 'billing' => $billingAddress, + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->creditmemoMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php new file mode 100644 index 00000000000..b9c50ebcba9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/CreditmemoSenderTest.php @@ -0,0 +1,283 @@ +<?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\Email\Sender; + +class CreditmemoSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\CreditmemoSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentHelper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoResource; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false); + $this->paymentHelper->expects($this->any()) + ->method('getInfoBlockHtml') + ->will($this->returnValue('payment')); + + $this->creditmemoResource = $this->getMock( + '\Magento\Sales\Model\Resource\Order\Creditmemo', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $this->creditmemoMock = $this->getMock( + '\Magento\Sales\Model\Order\Creditmemo', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->creditmemoMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->creditmemoMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + $this->sender = new CreditmemoSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock, + $this->paymentHelper, + $this->creditmemoResource + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->creditmemoMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->creditmemoMock, + 'comment' => $comment, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'store' => $this->storeMock + ] + ) + ); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->creditmemoMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->creditmemoMock, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->creditmemoMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSenderTest.php new file mode 100644 index 00000000000..6ba32da12f8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSenderTest.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\Model\Order\Email\Sender; + +class InvoiceCommentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + $this->paymentHelper = $this->getMock( + '\Magento\Payment\Helper\Data', + ['getInfoBlockHtml'], + [], + '', + false + ); + + $this->invoiceResource = $this->getMock( + '\Magento\Sales\Model\Resource\Order\Invoice', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->invoiceMock = $this->getMock( + '\Magento\Sales\Model\Order\Invoice', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->invoiceMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->invoiceMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + + $this->sender = new InvoiceCommentSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->invoiceMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->invoiceMock, + 'comment' => $comment, + 'billing' => $billingAddress, + 'store' => $this->storeMock + ] + ) + ); + + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->invoiceMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->invoiceMock, + 'billing' => $billingAddress, + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->invoiceMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php new file mode 100644 index 00000000000..f310de15e61 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/InvoiceSenderTest.php @@ -0,0 +1,284 @@ +<?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\Email\Sender; + +class InvoiceSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\InvoiceSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentHelper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceResource; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false); + $this->paymentHelper->expects($this->any()) + ->method('getInfoBlockHtml') + ->will($this->returnValue('payment')); + + $this->invoiceResource = $this->getMock( + '\Magento\Sales\Model\Resource\Order\Invoice', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\InvoiceIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $this->invoiceMock = $this->getMock( + '\Magento\Sales\Model\Order\Invoice', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->invoiceMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->invoiceMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + $this->sender = new InvoiceSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock, + $this->paymentHelper, + $this->invoiceResource + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->invoiceMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->invoiceMock, + 'comment' => $comment, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'store' => $this->storeMock + ] + ) + ); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->invoiceMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'invoice' => $this->invoiceMock, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->invoiceMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderCommentSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderCommentSenderTest.php new file mode 100644 index 00000000000..7c11c6aa137 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderCommentSenderTest.php @@ -0,0 +1,169 @@ +<?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\Email\Sender; + +class OrderCommentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->sender = new OrderCommentSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->orderMock); + $this->assertFalse($result); + } + + public function testSendTrue() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'billing' => $billingAddress, + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->orderMock, true, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php new file mode 100644 index 00000000000..9b143ffdb9a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/OrderSenderTest.php @@ -0,0 +1,275 @@ +<?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\Email\Sender; + +class OrderSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\OrderSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentHelper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderResource; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + $this->paymentHelper = $this->getMock( + '\Magento\Payment\Helper\Data', + ['getInfoBlockHtml'], + [], + '', + false + ); + $this->paymentHelper->expects($this->any()) + ->method('getInfoBlockHtml') + ->will($this->returnValue('payment')); + + $this->orderResource = $this->getMock( + '\Magento\Sales\Model\Resource\Order', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\OrderIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->sender = new OrderSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock, + $this->paymentHelper, + $this->orderResource + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->orderMock); + $this->assertFalse($result); + } + + public function testSendTrueForCustomer() + { + $billingAddress = 'billing_address'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->orderMock); + $this->assertTrue($result); + } + + public function testSendTrueForGuest() + { + $billingAddress = $this->getMock( + '\Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + + $billingAddress->expects($this->any()) + ->method('getName') + ->will($this->returnValue('name')); + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->orderMock); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSenderTest.php new file mode 100644 index 00000000000..af8a158e544 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSenderTest.php @@ -0,0 +1,237 @@ +<?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\Email\Sender; + +class ShipmentCommentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\ShipmentCommentSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->shipmentMock = $this->getMock( + '\Magento\Sales\Model\Order\Shipment', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->shipmentMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->shipmentMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + $this->sender = new ShipmentCommentSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->shipmentMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'shipment' => $this->shipmentMock, + 'billing' => $billingAddress, + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->shipmentMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'shipment' => $this->shipmentMock, + 'billing' => $billingAddress, + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->shipmentMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php new file mode 100644 index 00000000000..26f0f663e59 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Sender/ShipmentSenderTest.php @@ -0,0 +1,284 @@ +<?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\Email\Sender; + +class ShipmentSenderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Order\Email\Sender\ShipmentSender + */ + protected $sender; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $senderBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $paymentHelper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentResource; + + protected function setUp() + { + $this->senderBuilderFactoryMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\SenderBuilderFactory', + ['create'], + [], + '', + false + ); + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['setTemplateVars'], + [], + '', + false + ); + $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false); + $this->paymentHelper->expects($this->any()) + ->method('getInfoBlockHtml') + ->will($this->returnValue('payment')); + + $this->shipmentResource = $this->getMock( + '\Magento\Sales\Model\Resource\Order\Shipment', + [], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity', + ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'], + [], + '', + false + ); + $this->identityContainerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->orderMock = $this->getMock( + '\Magento\Sales\Model\Order', + [ + 'getStore', 'getBillingAddress', 'getPayment', + '__wakeup', 'getCustomerIsGuest', 'getCustomerName', + 'getCustomerEmail' + ], + [], + '', + false + ); + + $this->orderMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + $this->shipmentMock = $this->getMock( + '\Magento\Sales\Model\Order\Shipment', + ['getStore', '__wakeup', 'getOrder'], + [], + '', + false + ); + $this->shipmentMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + $this->shipmentMock->expects($this->any()) + ->method('getOrder') + ->will($this->returnValue($this->orderMock)); + + $this->sender = new ShipmentSender( + $this->templateContainerMock, + $this->identityContainerMock, + $this->senderBuilderFactoryMock, + $this->paymentHelper, + $this->shipmentResource + ); + } + + public function testSendFalse() + { + $result = $this->sender->send($this->shipmentMock); + $this->assertFalse($result); + } + + public function testSendTrueWithCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'shipment' => $this->shipmentMock, + 'comment' => $comment, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'store' => $this->storeMock + ] + ) + ); + $paymentInfoMock = $this->getMock( + '\Magento\Payment\Model\Info', + [], + [], + '', + false + ); + $this->orderMock->expects($this->once()) + ->method('getPayment') + ->will($this->returnValue($paymentInfoMock)); + + + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->once()) + ->method('send'); + $senderMock->expects($this->never()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->shipmentMock, true, $comment); + $this->assertTrue($result); + } + + public function testSendTrueWithoutCustomerCopy() + { + $billingAddress = 'billing_address'; + $comment = 'comment_test'; + + $this->orderMock->expects($this->once()) + ->method('getCustomerIsGuest') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue($billingAddress)); + + $this->identityContainerMock->expects($this->once()) + ->method('isEnabled') + ->will($this->returnValue(true)); + $this->templateContainerMock->expects($this->once()) + ->method('setTemplateVars') + ->with( + $this->equalTo( + [ + 'order' => $this->orderMock, + 'shipment' => $this->shipmentMock, + 'billing' => $billingAddress, + 'payment_html' => 'payment', + 'comment' => $comment, + 'store' => $this->storeMock + ] + ) + ); + $senderMock = $this->getMock( + 'Magento\Sales\Model\Order\Email\Sender', + ['send', 'sendCopyTo'], + [], + '', + false + ); + $senderMock->expects($this->never()) + ->method('send'); + $senderMock->expects($this->once()) + ->method('sendCopyTo'); + + $this->senderBuilderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($senderMock)); + + $result = $this->sender->send($this->shipmentMock, false, $comment); + $this->assertTrue($result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/SenderBuilderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/SenderBuilderTest.php new file mode 100644 index 00000000000..71bd41c4738 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/SenderBuilderTest.php @@ -0,0 +1,194 @@ +<?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\Email; + +class SenderBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var SenderBuilder + */ + protected $senderBuilder; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $identityContainerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $transportBuilder; + + protected function setUp() + { + $templateId = 'test_template_id'; + $templateOptions = ['option1', 'option2']; + $templateVars = ['var1', 'var2']; + $emailIdentity = 'email_identity_test'; + $emailCopyTo = ['example@mail.com']; + + $this->templateContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\Template', + ['getTemplateVars', 'getTemplateOptions', 'getTemplateId'], + [], + '', + false + ); + + $this->storeMock = $this->getMock( + '\Magento\Store\Model\Store', + ['getStoreId', '__wakeup'], + [], + '', + false + ); + + $this->identityContainerMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity', + [ + 'getEmailIdentity', 'getCustomerEmail', + 'getCustomerName', 'getTemplateOptions', 'getEmailCopyTo', + 'getCopyMethod' + ], + [], + '', + false + ); + + $this->transportBuilder = $this->getMock( + '\Magento\Framework\Mail\Template\TransportBuilder', + [ + 'addTo', 'addBcc', 'getTransport', + 'setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', + 'setFrom', + ], + [], + '', + false + ); + + $this->templateContainerMock->expects($this->once()) + ->method('getTemplateId') + ->will($this->returnValue($templateId)); + $this->transportBuilder->expects($this->once()) + ->method('setTemplateIdentifier') + ->with($this->equalTo($templateId)); + $this->templateContainerMock->expects($this->once()) + ->method('getTemplateOptions') + ->will($this->returnValue($templateOptions)); + $this->transportBuilder->expects($this->once()) + ->method('setTemplateOptions') + ->with($this->equalTo($templateOptions)); + $this->templateContainerMock->expects($this->once()) + ->method('getTemplateVars') + ->will($this->returnValue($templateVars)); + $this->transportBuilder->expects($this->once()) + ->method('setTemplateVars') + ->with($this->equalTo($templateVars)); + + $this->identityContainerMock->expects($this->once()) + ->method('getEmailIdentity') + ->will($this->returnValue($emailIdentity)); + $this->transportBuilder->expects($this->once()) + ->method('setFrom') + ->with($this->equalTo($emailIdentity)); + + $this->identityContainerMock->expects($this->once()) + ->method('getEmailCopyTo') + ->will($this->returnValue($emailCopyTo)); + + $this->senderBuilder = new SenderBuilder( + $this->templateContainerMock, + $this->identityContainerMock, + $this->transportBuilder + ); + } + + public function testSend() + { + $customerName = 'test_name'; + $customerEmail = 'test_email'; + $transportMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Stub\TransportInterfaceMock', + [], + [], + '', + false + ); + + $this->identityContainerMock->expects($this->once()) + ->method('getEmailCopyTo') + ->will($this->returnValue(['example@mail.com'])); + $this->identityContainerMock->expects($this->once()) + ->method('getCopyMethod') + ->will($this->returnValue('bcc')); + $this->identityContainerMock->expects($this->once()) + ->method('getCustomerEmail') + ->will($this->returnValue($customerEmail)); + $this->identityContainerMock->expects($this->once()) + ->method('getCustomerName') + ->will($this->returnValue($customerName)); + $this->transportBuilder->expects($this->once()) + ->method('addTo') + ->with($this->equalTo($customerEmail), $this->equalTo($customerName)); + + $this->transportBuilder->expects($this->once()) + ->method('getTransport') + ->will($this->returnValue($transportMock)); + + $this->senderBuilder->send(); + } + + public function testSendCopyTo() + { + $transportMock = $this->getMock( + '\Magento\Sales\Model\Order\Email\Stub\TransportInterfaceMock', + [], + [], + '', + false + ); + $this->identityContainerMock->expects($this->once()) + ->method('getCopyMethod') + ->will($this->returnValue('copy')); + $this->identityContainerMock->expects($this->never()) + ->method('getCustomerEmail'); + $this->identityContainerMock->expects($this->never()) + ->method('getCustomerName'); + $this->transportBuilder->expects($this->once()) + ->method('addTo') + ->with($this->equalTo('example@mail.com')); + + $this->transportBuilder->expects($this->once()) + ->method('getTransport') + ->will($this->returnValue($transportMock)); + + $this->senderBuilder->sendCopyTo(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Stub/TransportInterfaceMock.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Stub/TransportInterfaceMock.php new file mode 100644 index 00000000000..e7ea8c616d9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Email/Stub/TransportInterfaceMock.php @@ -0,0 +1,39 @@ +<?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\Email\Stub; + +use \Magento\Framework\Mail\TransportInterface; + +class TransportInterfaceMock implements TransportInterface +{ + /** + * Mock of send a mail using transport + * + * @return void + */ + public function sendMessage() + { + return; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Status/History/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Status/History/ValidatorTest.php new file mode 100644 index 00000000000..5d87a68cc91 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Status/History/ValidatorTest.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\Model\Order\Status\History; + +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + public function testValidate() + { + $history = $this->getMock('Magento\Sales\Model\Order\Status\History', ['hasData'], [], '', false); + $history->expects($this->any()) + ->method('hasData') + ->will($this->returnValue(true)); + $validator = new Validator(); + $this->assertEmpty($validator->validate($history)); + } + + public function testValidateNegative() + { + $history = $this->getMock('Magento\Sales\Model\Order\Status\History', ['hasData'], [], '', false); + $history->expects($this->any()) + ->method('hasData') + ->with('parent_id') + ->will($this->returnValue(false)); + $validator = new Validator(); + $this->assertEquals(['Order Id is a required field'], $validator->validate($history)); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/ValidatorTest.php new file mode 100644 index 00000000000..a831dc5cb34 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Address/ValidatorTest.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\Model\Quote\Address; + +class ValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Validator + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $factoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $countryMock; + + protected function setUp() + { + $this->factoryMock = $this->getMock('\Magento\Directory\Model\CountryFactory', [], [], '', false); + $this->countryMock = $this->getMock('\Magento\Directory\Model\Country', [], [], '', false); + $this->itemMock = $this->getMock( + '\Magento\Sales\Model\Quote\Address', + ['getCountryId', 'getEmail'], + [], + '', + false + ); + $this->factoryMock->expects($this->any())->method('create')->will($this->returnValue($this->countryMock)); + $this->model = new Validator($this->factoryMock); + } + + public function testValidateWithEmptyObject() + { + $this->itemMock->expects($this->once())->method('getEmail')->will($this->returnValue(null)); + $this->itemMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + $this->assertTrue($this->model->isValid($this->itemMock)); + $this->assertEmpty($this->model->getMessages()); + } + + public function testValidateWithInvalidEmail() + { + $this->itemMock->expects($this->once())->method('getEmail')->will($this->returnValue('invalid_email')); + $this->itemMock->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + $this->assertFalse($this->model->isValid($this->itemMock)); + $messages = ['invalid_email_format' => 'Invalid email format']; + $this->assertEquals($messages, $this->model->getMessages()); + } + + public function testValidateWithInvalidCountryId() + { + $this->itemMock->expects($this->once())->method('getEmail')->will($this->returnValue(null)); + $this->itemMock->expects($this->once())->method('getCountryId')->will($this->returnValue(100)); + + $this->countryMock->expects($this->once())->method('load')->with(100); + $this->countryMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + + $this->assertFalse($this->model->isValid($this->itemMock)); + $messages = ['invalid_country_code' => 'Invalid country code']; + $this->assertEquals($messages, $this->model->getMessages()); + } + + public function testValidateWithInvalidData() + { + $this->itemMock->expects($this->once())->method('getEmail')->will($this->returnValue('invalid_email')); + $this->itemMock->expects($this->once())->method('getCountryId')->will($this->returnValue(100)); + + $this->countryMock->expects($this->once())->method('load')->with(100); + $this->countryMock->expects($this->once())->method('getId')->will($this->returnValue(null)); + + $this->assertFalse($this->model->isValid($this->itemMock)); + $messages = [ + 'invalid_email_format' => 'Invalid email format', + 'invalid_country_code' => 'Invalid country code' + ]; + $this->assertEquals($messages, $this->model->getMessages()); + } + + public function testValidateWithValidData() + { + $this->itemMock->expects($this->once())->method('getEmail')->will($this->returnValue('test@example.com')); + $this->itemMock->expects($this->once())->method('getCountryId')->will($this->returnValue(100)); + + $this->countryMock->expects($this->once())->method('load')->with(100); + $this->countryMock->expects($this->once())->method('getId')->will($this->returnValue(100)); + + $this->assertTrue($this->model->isValid($this->itemMock)); + $this->assertEmpty($this->model->getMessages()); + } +} 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 new file mode 100644 index 00000000000..400ece2cc9a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php @@ -0,0 +1,137 @@ +<?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; + +/** + * Class AddressTest + */ +class AddressTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Address + */ + protected $addressResource; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Address\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + /** + * + */ + public function setUp() + { + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + 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\Address\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + $this->addressResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Address', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + + } + + /** + * test _beforeSaveMethod via save() + */ + public function testSave() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->addressMock)) + ->will($this->returnValue([])); + $this->addressResource->save($this->addressMock); + $this->assertTrue(true); + } + + /** + * test _beforeSaveMethod via save() with failed validation + * + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save address: + */ + public function testSaveValidationFailed() + { + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($this->equalTo($this->addressMock)) + ->will($this->returnValue(['warning message'])); + $this->addressResource->save($this->addressMock); + $this->assertTrue(true); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php new file mode 100644 index 00000000000..10be5797615 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php @@ -0,0 +1,141 @@ +<?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; + +/** + * Class HistoryTest + * @package Magento\Sales\Model\Resource\Order\Status + */ +class HistoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Status\History + */ + protected $historyResource; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Sales\Model\Order\Status\History|\PHPUnit_Framework_MockObject_MockObject + */ + protected $historyMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Sales\Model\Order\Status\History\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validatorMock; + + + public function setUp() + { + $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\Status\History\Validator', + [], + [], + '', + false + ); + $this->appResourceMock->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('insert'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + $this->historyResource = $objectManager->getObject( + 'Magento\Sales\Model\Resource\Order\Status\History', + [ + 'resource' => $this->appResourceMock, + 'validator' => $this->validatorMock + ] + ); + + } + + /** + * test _beforeSaveMethod via save() + */ + public function testSave() + { + $historyMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + [], + [], + '', + false + ); + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($historyMock) + ->will($this->returnValue([])); + $this->historyResource->save($historyMock); + } + + /** + * test _beforeSaveMethod via save() + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Cannot save comment: + */ + public function testValidate() + { + $historyMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + [], + [], + '', + false + ); + $this->validatorMock->expects($this->once()) + ->method('validate') + ->with($historyMock) + ->will($this->returnValue(['Some warnings'])); + $this->assertEquals($this->historyResource, $this->historyResource->save($historyMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CommentTest.php new file mode 100644 index 00000000000..4e12d0d0cb1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CommentTest.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\Service\V1\Data; + +class CommentTest 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\Comment($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\Comment($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\Comment($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\Comment($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\Comment($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\Comment($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } +} 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 new file mode 100644 index 00000000000..66c692cffbf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoCommentTest.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\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/CreditmemoItemTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoItemTest.php new file mode 100644 index 00000000000..32e30f5984b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoItemTest.php @@ -0,0 +1,555 @@ +<?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 CreditmemoItemTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdditionalData() + { + $data = ['additional_data' => 'test_value_additional_data']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_additional_data', $object->getAdditionalData()); + } + + public function testGetBaseCost() + { + $data = ['base_cost' => 'test_value_base_cost']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_cost', $object->getBaseCost()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBasePrice() + { + $data = ['base_price' => 'test_value_base_price']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price', $object->getBasePrice()); + } + + public function testGetBasePriceInclTax() + { + $data = ['base_price_incl_tax' => 'test_value_base_price_incl_tax']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price_incl_tax', $object->getBasePriceInclTax()); + } + + public function testGetBaseRowTotal() + { + $data = ['base_row_total' => 'test_value_base_row_total']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total', $object->getBaseRowTotal()); + } + + public function testGetBaseRowTotalInclTax() + { + $data = ['base_row_total_incl_tax' => 'test_value_base_row_total_incl_tax']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total_incl_tax', $object->getBaseRowTotalInclTax()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetBaseWeeeTaxAppliedAmount() + { + $data = ['base_weee_tax_applied_amount' => 'test_value_base_weee_tax_applied_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_applied_amount', $object->getBaseWeeeTaxAppliedAmount()); + } + + public function testGetBaseWeeeTaxAppliedRowAmnt() + { + $data = ['base_weee_tax_applied_row_amnt' => 'test_value_base_weee_tax_applied_row_amnt']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_applied_row_amnt', $object->getBaseWeeeTaxAppliedRowAmnt()); + } + + public function testGetBaseWeeeTaxDisposition() + { + $data = ['base_weee_tax_disposition' => 'test_value_base_weee_tax_disposition']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_disposition', $object->getBaseWeeeTaxDisposition()); + } + + public function testGetBaseWeeeTaxRowDisposition() + { + $data = ['base_weee_tax_row_disposition' => 'test_value_base_weee_tax_row_disposition']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_row_disposition', $object->getBaseWeeeTaxRowDisposition()); + } + + public function testGetDescription() + { + $data = ['description' => 'test_value_description']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_description', $object->getDescription()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_amount', $object->getDiscountAmount()); + } + + 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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetName() + { + $data = ['name' => 'test_value_name']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_name', $object->getName()); + } + + public function testGetOrderItemId() + { + $data = ['order_item_id' => 'test_value_order_item_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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_order_item_id', $object->getOrderItemId()); + } + + 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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetPrice() + { + $data = ['price' => 'test_value_price']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_price', $object->getPrice()); + } + + public function testGetPriceInclTax() + { + $data = ['price_incl_tax' => 'test_value_price_incl_tax']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_price_incl_tax', $object->getPriceInclTax()); + } + + public function testGetProductId() + { + $data = ['product_id' => 'test_value_product_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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_id', $object->getProductId()); + } + + public function testGetQty() + { + $data = ['qty' => 'test_value_qty']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty', $object->getQty()); + } + + public function testGetRowTotal() + { + $data = ['row_total' => 'test_value_row_total']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total', $object->getRowTotal()); + } + + public function testGetRowTotalInclTax() + { + $data = ['row_total_incl_tax' => 'test_value_row_total_incl_tax']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total_incl_tax', $object->getRowTotalInclTax()); + } + + public function testGetSku() + { + $data = ['sku' => 'test_value_sku']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_sku', $object->getSku()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_amount', $object->getTaxAmount()); + } + + public function testGetWeeeTaxApplied() + { + $data = ['weee_tax_applied' => 'test_value_weee_tax_applied']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied', $object->getWeeeTaxApplied()); + } + + public function testGetWeeeTaxAppliedAmount() + { + $data = ['weee_tax_applied_amount' => 'test_value_weee_tax_applied_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied_amount', $object->getWeeeTaxAppliedAmount()); + } + + public function testGetWeeeTaxAppliedRowAmount() + { + $data = ['weee_tax_applied_row_amount' => 'test_value_weee_tax_applied_row_amount']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied_row_amount', $object->getWeeeTaxAppliedRowAmount()); + } + + public function testGetWeeeTaxDisposition() + { + $data = ['weee_tax_disposition' => 'test_value_weee_tax_disposition']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_disposition', $object->getWeeeTaxDisposition()); + } + + public function testGetWeeeTaxRowDisposition() + { + $data = ['weee_tax_row_disposition' => 'test_value_weee_tax_row_disposition']; + $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\CreditmemoItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_row_disposition', $object->getWeeeTaxRowDisposition()); + } +} 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 new file mode 100644 index 00000000000..cf970c2f404 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/CreditmemoTest.php @@ -0,0 +1,801 @@ +<?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 CreditmemoTest + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @package Magento\Sales\Service\V1\Data + */ +class CreditmemoTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdjustment() + { + $data = ['adjustment' => 'test_value_adjustment']; + $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_adjustment', $object->getAdjustment()); + } + + public function testGetAdjustmentNegative() + { + $data = ['adjustment_negative' => 'test_value_adjustment_negative']; + $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_adjustment_negative', $object->getAdjustmentNegative()); + } + + public function testGetAdjustmentPositive() + { + $data = ['adjustment_positive' => 'test_value_adjustment_positive']; + $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_adjustment_positive', $object->getAdjustmentPositive()); + } + + public function testGetBaseAdjustment() + { + $data = ['base_adjustment' => 'test_value_base_adjustment']; + $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_base_adjustment', $object->getBaseAdjustment()); + } + + public function testGetBaseAdjustmentNegative() + { + $data = ['base_adjustment_negative' => 'test_value_base_adjustment_negative']; + $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_base_adjustment_negative', $object->getBaseAdjustmentNegative()); + } + + public function testGetBaseAdjustmentPositive() + { + $data = ['base_adjustment_positive' => 'test_value_base_adjustment_positive']; + $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_base_adjustment_positive', $object->getBaseAdjustmentPositive()); + } + + public function testGetBaseCurrencyCode() + { + $data = ['base_currency_code' => 'test_value_base_currency_code']; + $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_base_currency_code', $object->getBaseCurrencyCode()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseGrandTotal() + { + $data = ['base_grand_total' => 'test_value_base_grand_total']; + $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_base_grand_total', $object->getBaseGrandTotal()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBaseShippingAmount() + { + $data = ['base_shipping_amount' => 'test_value_base_shipping_amount']; + $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_base_shipping_amount', $object->getBaseShippingAmount()); + } + + public function testGetBaseShippingHiddenTaxAmnt() + { + $data = ['base_shipping_hidden_tax_amnt' => 'test_value_base_shipping_hidden_tax_amnt']; + $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_base_shipping_hidden_tax_amnt', $object->getBaseShippingHiddenTaxAmnt()); + } + + public function testGetBaseShippingInclTax() + { + $data = ['base_shipping_incl_tax' => 'test_value_base_shipping_incl_tax']; + $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_base_shipping_incl_tax', $object->getBaseShippingInclTax()); + } + + public function testGetBaseShippingTaxAmount() + { + $data = ['base_shipping_tax_amount' => 'test_value_base_shipping_tax_amount']; + $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_base_shipping_tax_amount', $object->getBaseShippingTaxAmount()); + } + + public function testGetBaseSubtotal() + { + $data = ['base_subtotal' => 'test_value_base_subtotal']; + $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_base_subtotal', $object->getBaseSubtotal()); + } + + public function testGetBaseSubtotalInclTax() + { + $data = ['base_subtotal_incl_tax' => 'test_value_base_subtotal_incl_tax']; + $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_base_subtotal_incl_tax', $object->getBaseSubtotalInclTax()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetBaseToGlobalRate() + { + $data = ['base_to_global_rate' => 'test_value_base_to_global_rate']; + $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_base_to_global_rate', $object->getBaseToGlobalRate()); + } + + public function testGetBaseToOrderRate() + { + $data = ['base_to_order_rate' => 'test_value_base_to_order_rate']; + $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_base_to_order_rate', $object->getBaseToOrderRate()); + } + + public function testGetBillingAddressId() + { + $data = ['billing_address_id' => 'test_value_billing_address_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_billing_address_id', $object->getBillingAddressId()); + } + + 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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetCreditmemoStatus() + { + $data = ['creditmemo_status' => 'test_value_creditmemo_status']; + $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_creditmemo_status', $object->getCreditmemoStatus()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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_discount_amount', $object->getDiscountAmount()); + } + + public function testGetDiscountDescription() + { + $data = ['discount_description' => 'test_value_discount_description']; + $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_discount_description', $object->getDiscountDescription()); + } + + public function testGetEmailSent() + { + $data = ['email_sent' => 'test_value_email_sent']; + $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_email_sent', $object->getEmailSent()); + } + + 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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetGlobalCurrencyCode() + { + $data = ['global_currency_code' => 'test_value_global_currency_code']; + $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_global_currency_code', $object->getGlobalCurrencyCode()); + } + + public function testGetGrandTotal() + { + $data = ['grand_total' => 'test_value_grand_total']; + $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_grand_total', $object->getGrandTotal()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetIncrementId() + { + $data = ['increment_id' => 'test_value_increment_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_increment_id', $object->getIncrementId()); + } + + public function testGetInvoiceId() + { + $data = ['invoice_id' => 'test_value_invoice_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_invoice_id', $object->getInvoiceId()); + } + + public function testGetOrderCurrencyCode() + { + $data = ['order_currency_code' => 'test_value_order_currency_code']; + $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_order_currency_code', $object->getOrderCurrencyCode()); + } + + public function testGetOrderId() + { + $data = ['order_id' => 'test_value_order_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_order_id', $object->getOrderId()); + } + + public function testGetShippingAddressId() + { + $data = ['shipping_address_id' => 'test_value_shipping_address_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_address_id', $object->getShippingAddressId()); + } + + public function testGetShippingAmount() + { + $data = ['shipping_amount' => 'test_value_shipping_amount']; + $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_shipping_amount', $object->getShippingAmount()); + } + + public function testGetShippingHiddenTaxAmount() + { + $data = ['shipping_hidden_tax_amount' => 'test_value_shipping_hidden_tax_amount']; + $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_shipping_hidden_tax_amount', $object->getShippingHiddenTaxAmount()); + } + + public function testGetShippingInclTax() + { + $data = ['shipping_incl_tax' => 'test_value_shipping_incl_tax']; + $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_shipping_incl_tax', $object->getShippingInclTax()); + } + + public function testGetShippingTaxAmount() + { + $data = ['shipping_tax_amount' => 'test_value_shipping_tax_amount']; + $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_shipping_tax_amount', $object->getShippingTaxAmount()); + } + + public function testGetState() + { + $data = ['state' => 'test_value_state']; + $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_state', $object->getState()); + } + + public function testGetStoreCurrencyCode() + { + $data = ['store_currency_code' => 'test_value_store_currency_code']; + $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_store_currency_code', $object->getStoreCurrencyCode()); + } + + public function testGetStoreId() + { + $data = ['store_id' => 'test_value_store_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_store_id', $object->getStoreId()); + } + + public function testGetStoreToBaseRate() + { + $data = ['store_to_base_rate' => 'test_value_store_to_base_rate']; + $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_store_to_base_rate', $object->getStoreToBaseRate()); + } + + public function testGetStoreToOrderRate() + { + $data = ['store_to_order_rate' => 'test_value_store_to_order_rate']; + $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_store_to_order_rate', $object->getStoreToOrderRate()); + } + + public function testGetSubtotal() + { + $data = ['subtotal' => 'test_value_subtotal']; + $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_subtotal', $object->getSubtotal()); + } + + public function testGetSubtotalInclTax() + { + $data = ['subtotal_incl_tax' => 'test_value_subtotal_incl_tax']; + $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_subtotal_incl_tax', $object->getSubtotalInclTax()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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_tax_amount', $object->getTaxAmount()); + } + + public function testGetTransactionId() + { + $data = ['transaction_id' => 'test_value_transaction_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_transaction_id', $object->getTransactionId()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\Creditmemo($abstractBuilderMock); + + $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceItemTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceItemTest.php new file mode 100644 index 00000000000..c3cdf9a504d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceItemTest.php @@ -0,0 +1,411 @@ +<?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 InvoiceItemTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdditionalData() + { + $data = ['additional_data' => 'test_value_additional_data']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_additional_data', $object->getAdditionalData()); + } + + public function testGetBaseCost() + { + $data = ['base_cost' => 'test_value_base_cost']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_cost', $object->getBaseCost()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBasePrice() + { + $data = ['base_price' => 'test_value_base_price']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price', $object->getBasePrice()); + } + + public function testGetBasePriceInclTax() + { + $data = ['base_price_incl_tax' => 'test_value_base_price_incl_tax']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price_incl_tax', $object->getBasePriceInclTax()); + } + + public function testGetBaseRowTotal() + { + $data = ['base_row_total' => 'test_value_base_row_total']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total', $object->getBaseRowTotal()); + } + + public function testGetBaseRowTotalInclTax() + { + $data = ['base_row_total_incl_tax' => 'test_value_base_row_total_incl_tax']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total_incl_tax', $object->getBaseRowTotalInclTax()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetDescription() + { + $data = ['description' => 'test_value_description']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_description', $object->getDescription()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_amount', $object->getDiscountAmount()); + } + + 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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetName() + { + $data = ['name' => 'test_value_name']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_name', $object->getName()); + } + + public function testGetOrderItemId() + { + $data = ['order_item_id' => 'test_value_order_item_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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_order_item_id', $object->getOrderItemId()); + } + + 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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetPrice() + { + $data = ['price' => 'test_value_price']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_price', $object->getPrice()); + } + + public function testGetPriceInclTax() + { + $data = ['price_incl_tax' => 'test_value_price_incl_tax']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_price_incl_tax', $object->getPriceInclTax()); + } + + public function testGetProductId() + { + $data = ['product_id' => 'test_value_product_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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_id', $object->getProductId()); + } + + public function testGetQty() + { + $data = ['qty' => 'test_value_qty']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty', $object->getQty()); + } + + public function testGetRowTotal() + { + $data = ['row_total' => 'test_value_row_total']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total', $object->getRowTotal()); + } + + public function testGetRowTotalInclTax() + { + $data = ['row_total_incl_tax' => 'test_value_row_total_incl_tax']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total_incl_tax', $object->getRowTotalInclTax()); + } + + public function testGetSku() + { + $data = ['sku' => 'test_value_sku']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_sku', $object->getSku()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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\InvoiceItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_amount', $object->getTaxAmount()); + } +} 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 new file mode 100644 index 00000000000..e05a8f42f9e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/InvoiceTest.php @@ -0,0 +1,769 @@ +<?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 InvoiceTest + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @package Magento\Sales\Service\V1\Data + */ +class InvoiceTest extends \PHPUnit_Framework_TestCase +{ + public function testGetBaseCurrencyCode() + { + $data = ['base_currency_code' => 'test_value_base_currency_code']; + $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_base_currency_code', $object->getBaseCurrencyCode()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseGrandTotal() + { + $data = ['base_grand_total' => 'test_value_base_grand_total']; + $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_base_grand_total', $object->getBaseGrandTotal()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBaseShippingAmount() + { + $data = ['base_shipping_amount' => 'test_value_base_shipping_amount']; + $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_base_shipping_amount', $object->getBaseShippingAmount()); + } + + public function testGetBaseShippingHiddenTaxAmnt() + { + $data = ['base_shipping_hidden_tax_amnt' => 'test_value_base_shipping_hidden_tax_amnt']; + $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_base_shipping_hidden_tax_amnt', $object->getBaseShippingHiddenTaxAmnt()); + } + + public function testGetBaseShippingInclTax() + { + $data = ['base_shipping_incl_tax' => 'test_value_base_shipping_incl_tax']; + $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_base_shipping_incl_tax', $object->getBaseShippingInclTax()); + } + + public function testGetBaseShippingTaxAmount() + { + $data = ['base_shipping_tax_amount' => 'test_value_base_shipping_tax_amount']; + $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_base_shipping_tax_amount', $object->getBaseShippingTaxAmount()); + } + + public function testGetBaseSubtotal() + { + $data = ['base_subtotal' => 'test_value_base_subtotal']; + $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_base_subtotal', $object->getBaseSubtotal()); + } + + public function testGetBaseSubtotalInclTax() + { + $data = ['base_subtotal_incl_tax' => 'test_value_base_subtotal_incl_tax']; + $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_base_subtotal_incl_tax', $object->getBaseSubtotalInclTax()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetBaseTotalRefunded() + { + $data = ['base_total_refunded' => 'test_value_base_total_refunded']; + $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_base_total_refunded', $object->getBaseTotalRefunded()); + } + + public function testGetBaseToGlobalRate() + { + $data = ['base_to_global_rate' => 'test_value_base_to_global_rate']; + $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_base_to_global_rate', $object->getBaseToGlobalRate()); + } + + public function testGetBaseToOrderRate() + { + $data = ['base_to_order_rate' => 'test_value_base_to_order_rate']; + $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_base_to_order_rate', $object->getBaseToOrderRate()); + } + + public function testGetBillingAddressId() + { + $data = ['billing_address_id' => 'test_value_billing_address_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_billing_address_id', $object->getBillingAddressId()); + } + + public function testGetCanVoidFlag() + { + $data = ['can_void_flag' => 'test_value_can_void_flag']; + $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_can_void_flag', $object->getCanVoidFlag()); + } + + 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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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_discount_amount', $object->getDiscountAmount()); + } + + public function testGetDiscountDescription() + { + $data = ['discount_description' => 'test_value_discount_description']; + $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_discount_description', $object->getDiscountDescription()); + } + + public function testGetEmailSent() + { + $data = ['email_sent' => 'test_value_email_sent']; + $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_email_sent', $object->getEmailSent()); + } + + 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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetGlobalCurrencyCode() + { + $data = ['global_currency_code' => 'test_value_global_currency_code']; + $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_global_currency_code', $object->getGlobalCurrencyCode()); + } + + public function testGetGrandTotal() + { + $data = ['grand_total' => 'test_value_grand_total']; + $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_grand_total', $object->getGrandTotal()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetIncrementId() + { + $data = ['increment_id' => 'test_value_increment_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_increment_id', $object->getIncrementId()); + } + + public function testGetIsUsedForRefund() + { + $data = ['is_used_for_refund' => 'test_value_is_used_for_refund']; + $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_is_used_for_refund', $object->getIsUsedForRefund()); + } + + public function testGetOrderCurrencyCode() + { + $data = ['order_currency_code' => 'test_value_order_currency_code']; + $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_order_currency_code', $object->getOrderCurrencyCode()); + } + + public function testGetOrderId() + { + $data = ['order_id' => 'test_value_order_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_order_id', $object->getOrderId()); + } + + public function testGetShippingAddressId() + { + $data = ['shipping_address_id' => 'test_value_shipping_address_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_address_id', $object->getShippingAddressId()); + } + + public function testGetShippingAmount() + { + $data = ['shipping_amount' => 'test_value_shipping_amount']; + $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_shipping_amount', $object->getShippingAmount()); + } + + public function testGetShippingHiddenTaxAmount() + { + $data = ['shipping_hidden_tax_amount' => 'test_value_shipping_hidden_tax_amount']; + $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_shipping_hidden_tax_amount', $object->getShippingHiddenTaxAmount()); + } + + public function testGetShippingInclTax() + { + $data = ['shipping_incl_tax' => 'test_value_shipping_incl_tax']; + $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_shipping_incl_tax', $object->getShippingInclTax()); + } + + public function testGetShippingTaxAmount() + { + $data = ['shipping_tax_amount' => 'test_value_shipping_tax_amount']; + $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_shipping_tax_amount', $object->getShippingTaxAmount()); + } + + public function testGetState() + { + $data = ['state' => 'test_value_state']; + $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_state', $object->getState()); + } + + public function testGetStoreCurrencyCode() + { + $data = ['store_currency_code' => 'test_value_store_currency_code']; + $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_store_currency_code', $object->getStoreCurrencyCode()); + } + + public function testGetStoreId() + { + $data = ['store_id' => 'test_value_store_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_store_id', $object->getStoreId()); + } + + public function testGetStoreToBaseRate() + { + $data = ['store_to_base_rate' => 'test_value_store_to_base_rate']; + $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_store_to_base_rate', $object->getStoreToBaseRate()); + } + + public function testGetStoreToOrderRate() + { + $data = ['store_to_order_rate' => 'test_value_store_to_order_rate']; + $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_store_to_order_rate', $object->getStoreToOrderRate()); + } + + public function testGetSubtotal() + { + $data = ['subtotal' => 'test_value_subtotal']; + $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_subtotal', $object->getSubtotal()); + } + + public function testGetSubtotalInclTax() + { + $data = ['subtotal_incl_tax' => 'test_value_subtotal_incl_tax']; + $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_subtotal_incl_tax', $object->getSubtotalInclTax()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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_tax_amount', $object->getTaxAmount()); + } + + public function testGetTotalQty() + { + $data = ['total_qty' => 'test_value_total_qty']; + $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_total_qty', $object->getTotalQty()); + } + + public function testGetTransactionId() + { + $data = ['transaction_id' => 'test_value_transaction_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\Invoice($abstractBuilderMock); + + $this->assertEquals('test_value_transaction_id', $object->getTransactionId()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\Invoice($abstractBuilderMock); + + $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\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()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderAddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderAddressTest.php new file mode 100644 index 00000000000..3be4a17236e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderAddressTest.php @@ -0,0 +1,443 @@ +<?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 OrderAddressTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAddressType() + { + $data = ['address_type' => 'test_value_address_type']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_address_type', $object->getAddressType()); + } + + public function testGetCity() + { + $data = ['city' => 'test_value_city']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_city', $object->getCity()); + } + + public function testGetCompany() + { + $data = ['company' => 'test_value_company']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_company', $object->getCompany()); + } + + public function testGetCountryId() + { + $data = ['country_id' => 'test_value_country_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_country_id', $object->getCountryId()); + } + + public function testGetCustomerAddressId() + { + $data = ['customer_address_id' => 'test_value_customer_address_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_customer_address_id', $object->getCustomerAddressId()); + } + + public function testGetCustomerId() + { + $data = ['customer_id' => 'test_value_customer_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_customer_id', $object->getCustomerId()); + } + + public function testGetEmail() + { + $data = ['email' => 'test_value_email']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_email', $object->getEmail()); + } + + 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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetFax() + { + $data = ['fax' => 'test_value_fax']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_fax', $object->getFax()); + } + + public function testGetFirstname() + { + $data = ['firstname' => 'test_value_firstname']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_firstname', $object->getFirstname()); + } + + public function testGetLastname() + { + $data = ['lastname' => 'test_value_lastname']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_lastname', $object->getLastname()); + } + + public function testGetMiddlename() + { + $data = ['middlename' => 'test_value_middlename']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_middlename', $object->getMiddlename()); + } + + 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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetPostcode() + { + $data = ['postcode' => 'test_value_postcode']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_postcode', $object->getPostcode()); + } + + public function testGetPrefix() + { + $data = ['prefix' => 'test_value_prefix']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_prefix', $object->getPrefix()); + } + + public function testGetQuoteAddressId() + { + $data = ['quote_address_id' => 'test_value_quote_address_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_quote_address_id', $object->getQuoteAddressId()); + } + + public function testGetRegion() + { + $data = ['region' => 'test_value_region']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_region', $object->getRegion()); + } + + public function testGetRegionId() + { + $data = ['region_id' => 'test_value_region_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_region_id', $object->getRegionId()); + } + + public function testGetStreet() + { + $data = ['street' => 'test_value_street']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_street', $object->getStreet()); + } + + public function testGetSuffix() + { + $data = ['suffix' => 'test_value_suffix']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_suffix', $object->getSuffix()); + } + + public function testGetTelephone() + { + $data = ['telephone' => 'test_value_telephone']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_telephone', $object->getTelephone()); + } + + public function testGetVatId() + { + $data = ['vat_id' => 'test_value_vat_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_vat_id', $object->getVatId()); + } + + public function testGetVatIsValid() + { + $data = ['vat_is_valid' => 'test_value_vat_is_valid']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_vat_is_valid', $object->getVatIsValid()); + } + + public function testGetVatRequestDate() + { + $data = ['vat_request_date' => 'test_value_vat_request_date']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_vat_request_date', $object->getVatRequestDate()); + } + + public function testGetVatRequestId() + { + $data = ['vat_request_id' => 'test_value_vat_request_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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_vat_request_id', $object->getVatRequestId()); + } + + public function testGetVatRequestSuccess() + { + $data = ['vat_request_success' => 'test_value_vat_request_success']; + $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\OrderAddress($abstractBuilderMock); + + $this->assertEquals('test_value_vat_request_success', $object->getVatRequestSuccess()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderItemTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderItemTest.php new file mode 100644 index 00000000000..6e7d555c57a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderItemTest.php @@ -0,0 +1,1537 @@ +<?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 OrderItemTest + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @package Magento\Sales\Service\V1\Data + */ +class OrderItemTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdditionalData() + { + $data = ['additional_data' => 'test_value_additional_data']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_additional_data', $object->getAdditionalData()); + } + + public function testGetAmountRefunded() + { + $data = ['amount_refunded' => 'test_value_amount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_amount_refunded', $object->getAmountRefunded()); + } + + public function testGetAppliedRuleIds() + { + $data = ['applied_rule_ids' => 'test_value_applied_rule_ids']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_applied_rule_ids', $object->getAppliedRuleIds()); + } + + public function testGetBaseAmountRefunded() + { + $data = ['base_amount_refunded' => 'test_value_base_amount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_refunded', $object->getBaseAmountRefunded()); + } + + public function testGetBaseCost() + { + $data = ['base_cost' => 'test_value_base_cost']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_cost', $object->getBaseCost()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseDiscountInvoiced() + { + $data = ['base_discount_invoiced' => 'test_value_base_discount_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_invoiced', $object->getBaseDiscountInvoiced()); + } + + public function testGetBaseDiscountRefunded() + { + $data = ['base_discount_refunded' => 'test_value_base_discount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_refunded', $object->getBaseDiscountRefunded()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBaseHiddenTaxInvoiced() + { + $data = ['base_hidden_tax_invoiced' => 'test_value_base_hidden_tax_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_invoiced', $object->getBaseHiddenTaxInvoiced()); + } + + public function testGetBaseHiddenTaxRefunded() + { + $data = ['base_hidden_tax_refunded' => 'test_value_base_hidden_tax_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_refunded', $object->getBaseHiddenTaxRefunded()); + } + + public function testGetBaseOriginalPrice() + { + $data = ['base_original_price' => 'test_value_base_original_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_original_price', $object->getBaseOriginalPrice()); + } + + public function testGetBasePrice() + { + $data = ['base_price' => 'test_value_base_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price', $object->getBasePrice()); + } + + public function testGetBasePriceInclTax() + { + $data = ['base_price_incl_tax' => 'test_value_base_price_incl_tax']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_price_incl_tax', $object->getBasePriceInclTax()); + } + + public function testGetBaseRowInvoiced() + { + $data = ['base_row_invoiced' => 'test_value_base_row_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_invoiced', $object->getBaseRowInvoiced()); + } + + public function testGetBaseRowTotal() + { + $data = ['base_row_total' => 'test_value_base_row_total']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total', $object->getBaseRowTotal()); + } + + public function testGetBaseRowTotalInclTax() + { + $data = ['base_row_total_incl_tax' => 'test_value_base_row_total_incl_tax']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_row_total_incl_tax', $object->getBaseRowTotalInclTax()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetBaseTaxBeforeDiscount() + { + $data = ['base_tax_before_discount' => 'test_value_base_tax_before_discount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_before_discount', $object->getBaseTaxBeforeDiscount()); + } + + public function testGetBaseTaxInvoiced() + { + $data = ['base_tax_invoiced' => 'test_value_base_tax_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_invoiced', $object->getBaseTaxInvoiced()); + } + + public function testGetBaseTaxRefunded() + { + $data = ['base_tax_refunded' => 'test_value_base_tax_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_refunded', $object->getBaseTaxRefunded()); + } + + public function testGetBaseWeeeTaxAppliedAmount() + { + $data = ['base_weee_tax_applied_amount' => 'test_value_base_weee_tax_applied_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_applied_amount', $object->getBaseWeeeTaxAppliedAmount()); + } + + public function testGetBaseWeeeTaxAppliedRowAmnt() + { + $data = ['base_weee_tax_applied_row_amnt' => 'test_value_base_weee_tax_applied_row_amnt']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_applied_row_amnt', $object->getBaseWeeeTaxAppliedRowAmnt()); + } + + public function testGetBaseWeeeTaxDisposition() + { + $data = ['base_weee_tax_disposition' => 'test_value_base_weee_tax_disposition']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_disposition', $object->getBaseWeeeTaxDisposition()); + } + + public function testGetBaseWeeeTaxRowDisposition() + { + $data = ['base_weee_tax_row_disposition' => 'test_value_base_weee_tax_row_disposition']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_base_weee_tax_row_disposition', $object->getBaseWeeeTaxRowDisposition()); + } + + 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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetDescription() + { + $data = ['description' => 'test_value_description']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_description', $object->getDescription()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_amount', $object->getDiscountAmount()); + } + + public function testGetDiscountInvoiced() + { + $data = ['discount_invoiced' => 'test_value_discount_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_invoiced', $object->getDiscountInvoiced()); + } + + public function testGetDiscountPercent() + { + $data = ['discount_percent' => 'test_value_discount_percent']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_percent', $object->getDiscountPercent()); + } + + public function testGetDiscountRefunded() + { + $data = ['discount_refunded' => 'test_value_discount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_discount_refunded', $object->getDiscountRefunded()); + } + + public function testGetEventId() + { + $data = ['event_id' => 'test_value_event_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_event_id', $object->getEventId()); + } + + public function testGetExtOrderItemId() + { + $data = ['ext_order_item_id' => 'test_value_ext_order_item_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_ext_order_item_id', $object->getExtOrderItemId()); + } + + public function testGetFreeShipping() + { + $data = ['free_shipping' => 'test_value_free_shipping']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_free_shipping', $object->getFreeShipping()); + } + + public function testGetGwBasePrice() + { + $data = ['gw_base_price' => 'test_value_gw_base_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_price', $object->getGwBasePrice()); + } + + public function testGetGwBasePriceInvoiced() + { + $data = ['gw_base_price_invoiced' => 'test_value_gw_base_price_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_price_invoiced', $object->getGwBasePriceInvoiced()); + } + + public function testGetGwBasePriceRefunded() + { + $data = ['gw_base_price_refunded' => 'test_value_gw_base_price_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_price_refunded', $object->getGwBasePriceRefunded()); + } + + public function testGetGwBaseTaxAmount() + { + $data = ['gw_base_tax_amount' => 'test_value_gw_base_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_tax_amount', $object->getGwBaseTaxAmount()); + } + + public function testGetGwBaseTaxAmountInvoiced() + { + $data = ['gw_base_tax_amount_invoiced' => 'test_value_gw_base_tax_amount_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_tax_amount_invoiced', $object->getGwBaseTaxAmountInvoiced()); + } + + public function testGetGwBaseTaxAmountRefunded() + { + $data = ['gw_base_tax_amount_refunded' => 'test_value_gw_base_tax_amount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_base_tax_amount_refunded', $object->getGwBaseTaxAmountRefunded()); + } + + public function testGetGwId() + { + $data = ['gw_id' => 'test_value_gw_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_id', $object->getGwId()); + } + + public function testGetGwPrice() + { + $data = ['gw_price' => 'test_value_gw_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_price', $object->getGwPrice()); + } + + public function testGetGwPriceInvoiced() + { + $data = ['gw_price_invoiced' => 'test_value_gw_price_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_price_invoiced', $object->getGwPriceInvoiced()); + } + + public function testGetGwPriceRefunded() + { + $data = ['gw_price_refunded' => 'test_value_gw_price_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_price_refunded', $object->getGwPriceRefunded()); + } + + public function testGetGwTaxAmount() + { + $data = ['gw_tax_amount' => 'test_value_gw_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_tax_amount', $object->getGwTaxAmount()); + } + + public function testGetGwTaxAmountInvoiced() + { + $data = ['gw_tax_amount_invoiced' => 'test_value_gw_tax_amount_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_tax_amount_invoiced', $object->getGwTaxAmountInvoiced()); + } + + public function testGetGwTaxAmountRefunded() + { + $data = ['gw_tax_amount_refunded' => 'test_value_gw_tax_amount_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_gw_tax_amount_refunded', $object->getGwTaxAmountRefunded()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetHiddenTaxCanceled() + { + $data = ['hidden_tax_canceled' => 'test_value_hidden_tax_canceled']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_canceled', $object->getHiddenTaxCanceled()); + } + + public function testGetHiddenTaxInvoiced() + { + $data = ['hidden_tax_invoiced' => 'test_value_hidden_tax_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_invoiced', $object->getHiddenTaxInvoiced()); + } + + public function testGetHiddenTaxRefunded() + { + $data = ['hidden_tax_refunded' => 'test_value_hidden_tax_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_refunded', $object->getHiddenTaxRefunded()); + } + + public function testGetIsNominal() + { + $data = ['is_nominal' => 'test_value_is_nominal']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_is_nominal', $object->getIsNominal()); + } + + public function testGetIsQtyDecimal() + { + $data = ['is_qty_decimal' => 'test_value_is_qty_decimal']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_is_qty_decimal', $object->getIsQtyDecimal()); + } + + public function testGetIsVirtual() + { + $data = ['is_virtual' => 'test_value_is_virtual']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_is_virtual', $object->getIsVirtual()); + } + + public function testGetItemId() + { + $data = ['item_id' => 'test_value_item_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_item_id', $object->getItemId()); + } + + public function testGetLockedDoInvoice() + { + $data = ['locked_do_invoice' => 'test_value_locked_do_invoice']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_locked_do_invoice', $object->getLockedDoInvoice()); + } + + public function testGetLockedDoShip() + { + $data = ['locked_do_ship' => 'test_value_locked_do_ship']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_locked_do_ship', $object->getLockedDoShip()); + } + + public function testGetName() + { + $data = ['name' => 'test_value_name']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_name', $object->getName()); + } + + public function testGetNoDiscount() + { + $data = ['no_discount' => 'test_value_no_discount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_no_discount', $object->getNoDiscount()); + } + + public function testGetOrderId() + { + $data = ['order_id' => 'test_value_order_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_order_id', $object->getOrderId()); + } + + public function testGetOriginalPrice() + { + $data = ['original_price' => 'test_value_original_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_original_price', $object->getOriginalPrice()); + } + + public function testGetParentItemId() + { + $data = ['parent_item_id' => 'test_value_parent_item_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_parent_item_id', $object->getParentItemId()); + } + + public function testGetPrice() + { + $data = ['price' => 'test_value_price']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_price', $object->getPrice()); + } + + public function testGetPriceInclTax() + { + $data = ['price_incl_tax' => 'test_value_price_incl_tax']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_price_incl_tax', $object->getPriceInclTax()); + } + + public function testGetProductId() + { + $data = ['product_id' => 'test_value_product_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_id', $object->getProductId()); + } + + public function testGetProductOptions() + { + $data = ['product_options' => 'test_value_product_options']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_options', $object->getProductOptions()); + } + + public function testGetProductType() + { + $data = ['product_type' => 'test_value_product_type']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_type', $object->getProductType()); + } + + public function testGetQtyBackordered() + { + $data = ['qty_backordered' => 'test_value_qty_backordered']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_backordered', $object->getQtyBackordered()); + } + + public function testGetQtyCanceled() + { + $data = ['qty_canceled' => 'test_value_qty_canceled']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_canceled', $object->getQtyCanceled()); + } + + public function testGetQtyInvoiced() + { + $data = ['qty_invoiced' => 'test_value_qty_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_invoiced', $object->getQtyInvoiced()); + } + + public function testGetQtyOrdered() + { + $data = ['qty_ordered' => 'test_value_qty_ordered']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_ordered', $object->getQtyOrdered()); + } + + public function testGetQtyRefunded() + { + $data = ['qty_refunded' => 'test_value_qty_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_refunded', $object->getQtyRefunded()); + } + + public function testGetQtyReturned() + { + $data = ['qty_returned' => 'test_value_qty_returned']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_returned', $object->getQtyReturned()); + } + + public function testGetQtyShipped() + { + $data = ['qty_shipped' => 'test_value_qty_shipped']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty_shipped', $object->getQtyShipped()); + } + + public function testGetQuoteItemId() + { + $data = ['quote_item_id' => 'test_value_quote_item_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_quote_item_id', $object->getQuoteItemId()); + } + + public function testGetRowInvoiced() + { + $data = ['row_invoiced' => 'test_value_row_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_invoiced', $object->getRowInvoiced()); + } + + public function testGetRowTotal() + { + $data = ['row_total' => 'test_value_row_total']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total', $object->getRowTotal()); + } + + public function testGetRowTotalInclTax() + { + $data = ['row_total_incl_tax' => 'test_value_row_total_incl_tax']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total_incl_tax', $object->getRowTotalInclTax()); + } + + public function testGetRowWeight() + { + $data = ['row_weight' => 'test_value_row_weight']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_weight', $object->getRowWeight()); + } + + public function testGetSku() + { + $data = ['sku' => 'test_value_sku']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_sku', $object->getSku()); + } + + public function testGetStoreId() + { + $data = ['store_id' => 'test_value_store_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_store_id', $object->getStoreId()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_amount', $object->getTaxAmount()); + } + + public function testGetTaxBeforeDiscount() + { + $data = ['tax_before_discount' => 'test_value_tax_before_discount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_before_discount', $object->getTaxBeforeDiscount()); + } + + public function testGetTaxCanceled() + { + $data = ['tax_canceled' => 'test_value_tax_canceled']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_canceled', $object->getTaxCanceled()); + } + + public function testGetTaxInvoiced() + { + $data = ['tax_invoiced' => 'test_value_tax_invoiced']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_invoiced', $object->getTaxInvoiced()); + } + + public function testGetTaxPercent() + { + $data = ['tax_percent' => 'test_value_tax_percent']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_percent', $object->getTaxPercent()); + } + + public function testGetTaxRefunded() + { + $data = ['tax_refunded' => 'test_value_tax_refunded']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_tax_refunded', $object->getTaxRefunded()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); + } + + public function testGetWeeeTaxApplied() + { + $data = ['weee_tax_applied' => 'test_value_weee_tax_applied']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied', $object->getWeeeTaxApplied()); + } + + public function testGetWeeeTaxAppliedAmount() + { + $data = ['weee_tax_applied_amount' => 'test_value_weee_tax_applied_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied_amount', $object->getWeeeTaxAppliedAmount()); + } + + public function testGetWeeeTaxAppliedRowAmount() + { + $data = ['weee_tax_applied_row_amount' => 'test_value_weee_tax_applied_row_amount']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_applied_row_amount', $object->getWeeeTaxAppliedRowAmount()); + } + + public function testGetWeeeTaxDisposition() + { + $data = ['weee_tax_disposition' => 'test_value_weee_tax_disposition']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_disposition', $object->getWeeeTaxDisposition()); + } + + public function testGetWeeeTaxRowDisposition() + { + $data = ['weee_tax_row_disposition' => 'test_value_weee_tax_row_disposition']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weee_tax_row_disposition', $object->getWeeeTaxRowDisposition()); + } + + public function testGetWeight() + { + $data = ['weight' => 'test_value_weight']; + $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\OrderItem($abstractBuilderMock); + + $this->assertEquals('test_value_weight', $object->getWeight()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderMapperTest.php new file mode 100644 index 00000000000..e7a552ef7a1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderMapperTest.php @@ -0,0 +1,198 @@ +<?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 OrderGetTest + */ +class OrderMapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\Data\OrderMapper + */ + protected $orderMapper; + /** + * @var \Magento\Sales\Service\V1\Data\OrderBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderBuilderMock; + /** + * @var \Magento\Sales\Service\V1\Data\OrderItemMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderItemMapperMock; + /** + * @var \Magento\Sales\Service\V1\Data\OrderPaymentMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderPaymentMapperMock; + /** + * @var \Magento\Sales\Service\V1\Data\OrderAddressMapper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderAddressMapperMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderItemMock; + /** + * @var \Magento\Sales\Model\Order\Payment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderPaymentMock; + /** + * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderAddressMock; + /** + * @var \Magento\Sales\Service\V1\Data\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderBuilder', + ['populateWithArray', 'setItems', 'setPayments', 'setBillingAddress', 'setShippingAddress', 'create'], + [], + '', + false + ); + $this->orderItemMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderItemMapper', + ['extractDto'], + [], + '', + false + ); + $this->orderPaymentMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderPaymentMapper', + ['extractDto'], + [], + '', + false + ); + $this->orderAddressMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderAddressMapper', + ['extractDto'], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->orderItemMock = $this->getMock( + 'Magento\Sales\Model\Order\Item', + [], + [], + '', + false + ); + $this->orderPaymentMock = $this->getMock( + 'Magento\Sales\Model\Order\Payment', + [], + [], + '', + false + ); + $this->orderAddressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + $this->orderMapper = new \Magento\Sales\Service\V1\Data\OrderMapper( + $this->orderBuilderMock, + $this->orderItemMapperMock, + $this->orderPaymentMapperMock, + $this->orderAddressMapperMock + ); + } + + /** + * test order mapper + */ + public function testInvoke() + { + $this->orderMock->expects($this->once()) + ->method('getData') + ->will($this->returnValue(['field-1' => 'value-1'])); + $this->orderMock->expects($this->once()) + ->method('getItemsCollection') + ->will($this->returnValue([$this->orderItemMock])); + $this->orderMock->expects($this->once()) + ->method('getPaymentsCollection') + ->will($this->returnValue([$this->orderPaymentMock])); + $this->orderMock->expects($this->exactly(2)) + ->method('getBillingAddress') + ->will($this->returnValue($this->orderAddressMock)); + $this->orderMock->expects($this->exactly(2)) + ->method('getShippingAddress') + ->will($this->returnValue($this->orderAddressMock)); + $this->orderBuilderMock->expects($this->once()) + ->method('populateWithArray') + ->with($this->equalTo(['field-1' => 'value-1'])) + ->will($this->returnSelf()); + $this->orderItemMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->orderItemMock)) + ->will($this->returnValue('item-1')); + $this->orderPaymentMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->orderPaymentMock)) + ->will($this->returnValue('payment-1')); + $this->orderAddressMapperMock->expects($this->exactly(2)) + ->method('extractDto') + ->with($this->equalTo($this->orderAddressMock)) + ->will($this->returnValue('address-1')); + $this->orderBuilderMock->expects($this->once()) + ->method('setItems') + ->with($this->equalTo(['item-1'])) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setPayments') + ->with($this->equalTo(['payment-1'])) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setBillingAddress') + ->with($this->equalTo('address-1')) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('setShippingAddress') + ->with($this->equalTo('address-1')) + ->will($this->returnSelf()); + $this->orderBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue('data-object-with-order')); + $this->assertEquals('data-object-with-order', $this->orderMapper->extractDto($this->orderMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderPaymentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderPaymentTest.php new file mode 100644 index 00000000000..2915d122dd8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderPaymentTest.php @@ -0,0 +1,897 @@ +<?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 OrderPaymentTest + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @package Magento\Sales\Service\V1\Data + */ +class OrderPaymentTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAccountStatus() + { + $data = ['account_status' => 'test_value_account_status']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_account_status', $object->getAccountStatus()); + } + + public function testGetAdditionalData() + { + $data = ['additional_data' => 'test_value_additional_data']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_additional_data', $object->getAdditionalData()); + } + + public function testGetAdditionalInformation() + { + $data = ['additional_information' => 'test_value_additional_information']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_additional_information', $object->getAdditionalInformation()); + } + + public function testGetAddressStatus() + { + $data = ['address_status' => 'test_value_address_status']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_address_status', $object->getAddressStatus()); + } + + public function testGetAmountAuthorized() + { + $data = ['amount_authorized' => 'test_value_amount_authorized']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_amount_authorized', $object->getAmountAuthorized()); + } + + public function testGetAmountCanceled() + { + $data = ['amount_canceled' => 'test_value_amount_canceled']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_amount_canceled', $object->getAmountCanceled()); + } + + public function testGetAmountOrdered() + { + $data = ['amount_ordered' => 'test_value_amount_ordered']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_amount_ordered', $object->getAmountOrdered()); + } + + public function testGetAmountPaid() + { + $data = ['amount_paid' => 'test_value_amount_paid']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_amount_paid', $object->getAmountPaid()); + } + + public function testGetAmountRefunded() + { + $data = ['amount_refunded' => 'test_value_amount_refunded']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_amount_refunded', $object->getAmountRefunded()); + } + + public function testGetAnetTransMethod() + { + $data = ['anet_trans_method' => 'test_value_anet_trans_method']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_anet_trans_method', $object->getAnetTransMethod()); + } + + public function testGetBaseAmountAuthorized() + { + $data = ['base_amount_authorized' => 'test_value_base_amount_authorized']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_authorized', $object->getBaseAmountAuthorized()); + } + + public function testGetBaseAmountCanceled() + { + $data = ['base_amount_canceled' => 'test_value_base_amount_canceled']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_canceled', $object->getBaseAmountCanceled()); + } + + public function testGetBaseAmountOrdered() + { + $data = ['base_amount_ordered' => 'test_value_base_amount_ordered']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_ordered', $object->getBaseAmountOrdered()); + } + + public function testGetBaseAmountPaid() + { + $data = ['base_amount_paid' => 'test_value_base_amount_paid']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_paid', $object->getBaseAmountPaid()); + } + + public function testGetBaseAmountPaidOnline() + { + $data = ['base_amount_paid_online' => 'test_value_base_amount_paid_online']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_paid_online', $object->getBaseAmountPaidOnline()); + } + + public function testGetBaseAmountRefunded() + { + $data = ['base_amount_refunded' => 'test_value_base_amount_refunded']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_refunded', $object->getBaseAmountRefunded()); + } + + public function testGetBaseAmountRefundedOnline() + { + $data = ['base_amount_refunded_online' => 'test_value_base_amount_refunded_online']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_amount_refunded_online', $object->getBaseAmountRefundedOnline()); + } + + public function testGetBaseShippingAmount() + { + $data = ['base_shipping_amount' => 'test_value_base_shipping_amount']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_amount', $object->getBaseShippingAmount()); + } + + public function testGetBaseShippingCaptured() + { + $data = ['base_shipping_captured' => 'test_value_base_shipping_captured']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_captured', $object->getBaseShippingCaptured()); + } + + public function testGetBaseShippingRefunded() + { + $data = ['base_shipping_refunded' => 'test_value_base_shipping_refunded']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_refunded', $object->getBaseShippingRefunded()); + } + + public function testGetCcApproval() + { + $data = ['cc_approval' => 'test_value_cc_approval']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_approval', $object->getCcApproval()); + } + + public function testGetCcAvsStatus() + { + $data = ['cc_avs_status' => 'test_value_cc_avs_status']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_avs_status', $object->getCcAvsStatus()); + } + + public function testGetCcCidStatus() + { + $data = ['cc_cid_status' => 'test_value_cc_cid_status']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_cid_status', $object->getCcCidStatus()); + } + + public function testGetCcDebugRequestBody() + { + $data = ['cc_debug_request_body' => 'test_value_cc_debug_request_body']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_debug_request_body', $object->getCcDebugRequestBody()); + } + + public function testGetCcDebugResponseBody() + { + $data = ['cc_debug_response_body' => 'test_value_cc_debug_response_body']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_debug_response_body', $object->getCcDebugResponseBody()); + } + + public function testGetCcDebugResponseSerialized() + { + $data = ['cc_debug_response_serialized' => 'test_value_cc_debug_response_serialized']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_debug_response_serialized', $object->getCcDebugResponseSerialized()); + } + + public function testGetCcExpMonth() + { + $data = ['cc_exp_month' => 'test_value_cc_exp_month']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_exp_month', $object->getCcExpMonth()); + } + + public function testGetCcExpYear() + { + $data = ['cc_exp_year' => 'test_value_cc_exp_year']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_exp_year', $object->getCcExpYear()); + } + + public function testGetCcLast4() + { + $data = ['cc_last4' => 'test_value_cc_last4']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_last4', $object->getCcLast4()); + } + + public function testGetCcNumberEnc() + { + $data = ['cc_number_enc' => 'test_value_cc_number_enc']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_number_enc', $object->getCcNumberEnc()); + } + + public function testGetCcOwner() + { + $data = ['cc_owner' => 'test_value_cc_owner']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_owner', $object->getCcOwner()); + } + + public function testGetCcSecureVerify() + { + $data = ['cc_secure_verify' => 'test_value_cc_secure_verify']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_secure_verify', $object->getCcSecureVerify()); + } + + public function testGetCcSsIssue() + { + $data = ['cc_ss_issue' => 'test_value_cc_ss_issue']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_ss_issue', $object->getCcSsIssue()); + } + + public function testGetCcSsStartMonth() + { + $data = ['cc_ss_start_month' => 'test_value_cc_ss_start_month']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_ss_start_month', $object->getCcSsStartMonth()); + } + + public function testGetCcSsStartYear() + { + $data = ['cc_ss_start_year' => 'test_value_cc_ss_start_year']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_ss_start_year', $object->getCcSsStartYear()); + } + + public function testGetCcStatus() + { + $data = ['cc_status' => 'test_value_cc_status']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_status', $object->getCcStatus()); + } + + public function testGetCcStatusDescription() + { + $data = ['cc_status_description' => 'test_value_cc_status_description']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_status_description', $object->getCcStatusDescription()); + } + + public function testGetCcTransId() + { + $data = ['cc_trans_id' => 'test_value_cc_trans_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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_trans_id', $object->getCcTransId()); + } + + public function testGetCcType() + { + $data = ['cc_type' => 'test_value_cc_type']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_cc_type', $object->getCcType()); + } + + public function testGetEcheckAccountName() + { + $data = ['echeck_account_name' => 'test_value_echeck_account_name']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_echeck_account_name', $object->getEcheckAccountName()); + } + + public function testGetEcheckAccountType() + { + $data = ['echeck_account_type' => 'test_value_echeck_account_type']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_echeck_account_type', $object->getEcheckAccountType()); + } + + public function testGetEcheckBankName() + { + $data = ['echeck_bank_name' => 'test_value_echeck_bank_name']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_echeck_bank_name', $object->getEcheckBankName()); + } + + public function testGetEcheckRoutingNumber() + { + $data = ['echeck_routing_number' => 'test_value_echeck_routing_number']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_echeck_routing_number', $object->getEcheckRoutingNumber()); + } + + public function testGetEcheckType() + { + $data = ['echeck_type' => 'test_value_echeck_type']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_echeck_type', $object->getEcheckType()); + } + + 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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetLastTransId() + { + $data = ['last_trans_id' => 'test_value_last_trans_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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_last_trans_id', $object->getLastTransId()); + } + + public function testGetMethod() + { + $data = ['method' => 'test_value_method']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_method', $object->getMethod()); + } + + 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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetPoNumber() + { + $data = ['po_number' => 'test_value_po_number']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_po_number', $object->getPoNumber()); + } + + public function testGetProtectionEligibility() + { + $data = ['protection_eligibility' => 'test_value_protection_eligibility']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_protection_eligibility', $object->getProtectionEligibility()); + } + + public function testGetQuotePaymentId() + { + $data = ['quote_payment_id' => 'test_value_quote_payment_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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_quote_payment_id', $object->getQuotePaymentId()); + } + + public function testGetShippingAmount() + { + $data = ['shipping_amount' => 'test_value_shipping_amount']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_amount', $object->getShippingAmount()); + } + + public function testGetShippingCaptured() + { + $data = ['shipping_captured' => 'test_value_shipping_captured']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_captured', $object->getShippingCaptured()); + } + + public function testGetShippingRefunded() + { + $data = ['shipping_refunded' => 'test_value_shipping_refunded']; + $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\OrderPayment($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_refunded', $object->getShippingRefunded()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderStatusHistoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderStatusHistoryTest.php new file mode 100644 index 00000000000..6b75f014780 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderStatusHistoryTest.php @@ -0,0 +1,155 @@ +<?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 OrderStatusHistoryTest 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\OrderStatusHistory($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\OrderStatusHistory($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\OrderStatusHistory($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetEntityName() + { + $data = ['entity_name' => 'test_value_entity_name']; + $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\OrderStatusHistory($abstractBuilderMock); + + $this->assertEquals('test_value_entity_name', $object->getEntityName()); + } + + 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\OrderStatusHistory($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\OrderStatusHistory($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\OrderStatusHistory($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetStatus() + { + $data = ['status' => 'test_value_status']; + $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\OrderStatusHistory($abstractBuilderMock); + + $this->assertEquals('test_value_status', $object->getStatus()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderTest.php new file mode 100644 index 00000000000..b4707dcaceb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/OrderTest.php @@ -0,0 +1,2242 @@ +<?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 OrderTest + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @package Magento\Sales\Service\V1\Data + */ +class OrderTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdjustmentNegative() + { + $data = ['adjustment_negative' => 'test_value_adjustment_negative']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_adjustment_negative', $object->getAdjustmentNegative()); + } + + public function testGetAdjustmentPositive() + { + $data = ['adjustment_positive' => 'test_value_adjustment_positive']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_adjustment_positive', $object->getAdjustmentPositive()); + } + + public function testGetAppliedRuleIds() + { + $data = ['applied_rule_ids' => 'test_value_applied_rule_ids']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_applied_rule_ids', $object->getAppliedRuleIds()); + } + + public function testGetBaseAdjustmentNegative() + { + $data = ['base_adjustment_negative' => 'test_value_base_adjustment_negative']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_adjustment_negative', $object->getBaseAdjustmentNegative()); + } + + public function testGetBaseAdjustmentPositive() + { + $data = ['base_adjustment_positive' => 'test_value_base_adjustment_positive']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_adjustment_positive', $object->getBaseAdjustmentPositive()); + } + + public function testGetBaseCurrencyCode() + { + $data = ['base_currency_code' => 'test_value_base_currency_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_currency_code', $object->getBaseCurrencyCode()); + } + + public function testGetBaseDiscountAmount() + { + $data = ['base_discount_amount' => 'test_value_base_discount_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_amount', $object->getBaseDiscountAmount()); + } + + public function testGetBaseDiscountCanceled() + { + $data = ['base_discount_canceled' => 'test_value_base_discount_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_canceled', $object->getBaseDiscountCanceled()); + } + + public function testGetBaseDiscountInvoiced() + { + $data = ['base_discount_invoiced' => 'test_value_base_discount_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_invoiced', $object->getBaseDiscountInvoiced()); + } + + public function testGetBaseDiscountRefunded() + { + $data = ['base_discount_refunded' => 'test_value_base_discount_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_discount_refunded', $object->getBaseDiscountRefunded()); + } + + public function testGetBaseGrandTotal() + { + $data = ['base_grand_total' => 'test_value_base_grand_total']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_grand_total', $object->getBaseGrandTotal()); + } + + public function testGetBaseHiddenTaxAmount() + { + $data = ['base_hidden_tax_amount' => 'test_value_base_hidden_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_amount', $object->getBaseHiddenTaxAmount()); + } + + public function testGetBaseHiddenTaxInvoiced() + { + $data = ['base_hidden_tax_invoiced' => 'test_value_base_hidden_tax_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_invoiced', $object->getBaseHiddenTaxInvoiced()); + } + + public function testGetBaseHiddenTaxRefunded() + { + $data = ['base_hidden_tax_refunded' => 'test_value_base_hidden_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_hidden_tax_refunded', $object->getBaseHiddenTaxRefunded()); + } + + public function testGetBaseShippingAmount() + { + $data = ['base_shipping_amount' => 'test_value_base_shipping_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_amount', $object->getBaseShippingAmount()); + } + + public function testGetBaseShippingCanceled() + { + $data = ['base_shipping_canceled' => 'test_value_base_shipping_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_canceled', $object->getBaseShippingCanceled()); + } + + public function testGetBaseShippingDiscountAmount() + { + $data = ['base_shipping_discount_amount' => 'test_value_base_shipping_discount_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_discount_amount', $object->getBaseShippingDiscountAmount()); + } + + public function testGetBaseShippingHiddenTaxAmnt() + { + $data = ['base_shipping_hidden_tax_amnt' => 'test_value_base_shipping_hidden_tax_amnt']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_hidden_tax_amnt', $object->getBaseShippingHiddenTaxAmnt()); + } + + public function testGetBaseShippingInclTax() + { + $data = ['base_shipping_incl_tax' => 'test_value_base_shipping_incl_tax']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_incl_tax', $object->getBaseShippingInclTax()); + } + + public function testGetBaseShippingInvoiced() + { + $data = ['base_shipping_invoiced' => 'test_value_base_shipping_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_invoiced', $object->getBaseShippingInvoiced()); + } + + public function testGetBaseShippingRefunded() + { + $data = ['base_shipping_refunded' => 'test_value_base_shipping_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_refunded', $object->getBaseShippingRefunded()); + } + + public function testGetBaseShippingTaxAmount() + { + $data = ['base_shipping_tax_amount' => 'test_value_base_shipping_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_tax_amount', $object->getBaseShippingTaxAmount()); + } + + public function testGetBaseShippingTaxRefunded() + { + $data = ['base_shipping_tax_refunded' => 'test_value_base_shipping_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_shipping_tax_refunded', $object->getBaseShippingTaxRefunded()); + } + + public function testGetBaseSubtotal() + { + $data = ['base_subtotal' => 'test_value_base_subtotal']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_subtotal', $object->getBaseSubtotal()); + } + + public function testGetBaseSubtotalCanceled() + { + $data = ['base_subtotal_canceled' => 'test_value_base_subtotal_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_subtotal_canceled', $object->getBaseSubtotalCanceled()); + } + + public function testGetBaseSubtotalInclTax() + { + $data = ['base_subtotal_incl_tax' => 'test_value_base_subtotal_incl_tax']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_subtotal_incl_tax', $object->getBaseSubtotalInclTax()); + } + + public function testGetBaseSubtotalInvoiced() + { + $data = ['base_subtotal_invoiced' => 'test_value_base_subtotal_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_subtotal_invoiced', $object->getBaseSubtotalInvoiced()); + } + + public function testGetBaseSubtotalRefunded() + { + $data = ['base_subtotal_refunded' => 'test_value_base_subtotal_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_subtotal_refunded', $object->getBaseSubtotalRefunded()); + } + + public function testGetBaseTaxAmount() + { + $data = ['base_tax_amount' => 'test_value_base_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_amount', $object->getBaseTaxAmount()); + } + + public function testGetBaseTaxCanceled() + { + $data = ['base_tax_canceled' => 'test_value_base_tax_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_canceled', $object->getBaseTaxCanceled()); + } + + public function testGetBaseTaxInvoiced() + { + $data = ['base_tax_invoiced' => 'test_value_base_tax_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_invoiced', $object->getBaseTaxInvoiced()); + } + + public function testGetBaseTaxRefunded() + { + $data = ['base_tax_refunded' => 'test_value_base_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_tax_refunded', $object->getBaseTaxRefunded()); + } + + public function testGetBaseTotalCanceled() + { + $data = ['base_total_canceled' => 'test_value_base_total_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_canceled', $object->getBaseTotalCanceled()); + } + + public function testGetBaseTotalDue() + { + $data = ['base_total_due' => 'test_value_base_total_due']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_due', $object->getBaseTotalDue()); + } + + public function testGetBaseTotalInvoiced() + { + $data = ['base_total_invoiced' => 'test_value_base_total_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_invoiced', $object->getBaseTotalInvoiced()); + } + + public function testGetBaseTotalInvoicedCost() + { + $data = ['base_total_invoiced_cost' => 'test_value_base_total_invoiced_cost']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_invoiced_cost', $object->getBaseTotalInvoicedCost()); + } + + public function testGetBaseTotalOfflineRefunded() + { + $data = ['base_total_offline_refunded' => 'test_value_base_total_offline_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_offline_refunded', $object->getBaseTotalOfflineRefunded()); + } + + public function testGetBaseTotalOnlineRefunded() + { + $data = ['base_total_online_refunded' => 'test_value_base_total_online_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_online_refunded', $object->getBaseTotalOnlineRefunded()); + } + + public function testGetBaseTotalPaid() + { + $data = ['base_total_paid' => 'test_value_base_total_paid']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_paid', $object->getBaseTotalPaid()); + } + + public function testGetBaseTotalQtyOrdered() + { + $data = ['base_total_qty_ordered' => 'test_value_base_total_qty_ordered']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_qty_ordered', $object->getBaseTotalQtyOrdered()); + } + + public function testGetBaseTotalRefunded() + { + $data = ['base_total_refunded' => 'test_value_base_total_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_total_refunded', $object->getBaseTotalRefunded()); + } + + public function testGetBaseToGlobalRate() + { + $data = ['base_to_global_rate' => 'test_value_base_to_global_rate']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_to_global_rate', $object->getBaseToGlobalRate()); + } + + public function testGetBaseToOrderRate() + { + $data = ['base_to_order_rate' => 'test_value_base_to_order_rate']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_base_to_order_rate', $object->getBaseToOrderRate()); + } + + public function testGetBillingAddressId() + { + $data = ['billing_address_id' => 'test_value_billing_address_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_billing_address_id', $object->getBillingAddressId()); + } + + public function testGetCanShipPartially() + { + $data = ['can_ship_partially' => 'test_value_can_ship_partially']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_can_ship_partially', $object->getCanShipPartially()); + } + + public function testGetCanShipPartiallyItem() + { + $data = ['can_ship_partially_item' => 'test_value_can_ship_partially_item']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_can_ship_partially_item', $object->getCanShipPartiallyItem()); + } + + public function testGetCouponCode() + { + $data = ['coupon_code' => 'test_value_coupon_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_coupon_code', $object->getCouponCode()); + } + + 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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetCustomerDob() + { + $data = ['customer_dob' => 'test_value_customer_dob']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_dob', $object->getCustomerDob()); + } + + public function testGetCustomerEmail() + { + $data = ['customer_email' => 'test_value_customer_email']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_email', $object->getCustomerEmail()); + } + + public function testGetCustomerFirstname() + { + $data = ['customer_firstname' => 'test_value_customer_firstname']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_firstname', $object->getCustomerFirstname()); + } + + public function testGetCustomerGender() + { + $data = ['customer_gender' => 'test_value_customer_gender']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_gender', $object->getCustomerGender()); + } + + public function testGetCustomerGroupId() + { + $data = ['customer_group_id' => 'test_value_customer_group_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_group_id', $object->getCustomerGroupId()); + } + + public function testGetCustomerId() + { + $data = ['customer_id' => 'test_value_customer_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_id', $object->getCustomerId()); + } + + public function testGetCustomerIsGuest() + { + $data = ['customer_is_guest' => 'test_value_customer_is_guest']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_is_guest', $object->getCustomerIsGuest()); + } + + public function testGetCustomerLastname() + { + $data = ['customer_lastname' => 'test_value_customer_lastname']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_lastname', $object->getCustomerLastname()); + } + + public function testGetCustomerMiddlename() + { + $data = ['customer_middlename' => 'test_value_customer_middlename']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_middlename', $object->getCustomerMiddlename()); + } + + public function testGetCustomerNote() + { + $data = ['customer_note' => 'test_value_customer_note']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_note', $object->getCustomerNote()); + } + + public function testGetCustomerNoteNotify() + { + $data = ['customer_note_notify' => 'test_value_customer_note_notify']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_note_notify', $object->getCustomerNoteNotify()); + } + + public function testGetCustomerPrefix() + { + $data = ['customer_prefix' => 'test_value_customer_prefix']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_prefix', $object->getCustomerPrefix()); + } + + public function testGetCustomerSuffix() + { + $data = ['customer_suffix' => 'test_value_customer_suffix']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_suffix', $object->getCustomerSuffix()); + } + + public function testGetCustomerTaxvat() + { + $data = ['customer_taxvat' => 'test_value_customer_taxvat']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_customer_taxvat', $object->getCustomerTaxvat()); + } + + public function testGetDiscountAmount() + { + $data = ['discount_amount' => 'test_value_discount_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_discount_amount', $object->getDiscountAmount()); + } + + public function testGetDiscountCanceled() + { + $data = ['discount_canceled' => 'test_value_discount_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_discount_canceled', $object->getDiscountCanceled()); + } + + public function testGetDiscountDescription() + { + $data = ['discount_description' => 'test_value_discount_description']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_discount_description', $object->getDiscountDescription()); + } + + public function testGetDiscountInvoiced() + { + $data = ['discount_invoiced' => 'test_value_discount_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_discount_invoiced', $object->getDiscountInvoiced()); + } + + public function testGetDiscountRefunded() + { + $data = ['discount_refunded' => 'test_value_discount_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_discount_refunded', $object->getDiscountRefunded()); + } + + public function testGetEditIncrement() + { + $data = ['edit_increment' => 'test_value_edit_increment']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_edit_increment', $object->getEditIncrement()); + } + + public function testGetEmailSent() + { + $data = ['email_sent' => 'test_value_email_sent']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_email_sent', $object->getEmailSent()); + } + + 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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetExtCustomerId() + { + $data = ['ext_customer_id' => 'test_value_ext_customer_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_ext_customer_id', $object->getExtCustomerId()); + } + + public function testGetExtOrderId() + { + $data = ['ext_order_id' => 'test_value_ext_order_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_ext_order_id', $object->getExtOrderId()); + } + + public function testGetForcedShipmentWithInvoice() + { + $data = ['forced_shipment_with_invoice' => 'test_value_forced_shipment_with_invoice']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_forced_shipment_with_invoice', $object->getForcedShipmentWithInvoice()); + } + + public function testGetGlobalCurrencyCode() + { + $data = ['global_currency_code' => 'test_value_global_currency_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_global_currency_code', $object->getGlobalCurrencyCode()); + } + + public function testGetGrandTotal() + { + $data = ['grand_total' => 'test_value_grand_total']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_grand_total', $object->getGrandTotal()); + } + + public function testGetHiddenTaxAmount() + { + $data = ['hidden_tax_amount' => 'test_value_hidden_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_amount', $object->getHiddenTaxAmount()); + } + + public function testGetHiddenTaxInvoiced() + { + $data = ['hidden_tax_invoiced' => 'test_value_hidden_tax_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_invoiced', $object->getHiddenTaxInvoiced()); + } + + public function testGetHiddenTaxRefunded() + { + $data = ['hidden_tax_refunded' => 'test_value_hidden_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_hidden_tax_refunded', $object->getHiddenTaxRefunded()); + } + + public function testGetHoldBeforeState() + { + $data = ['hold_before_state' => 'test_value_hold_before_state']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_hold_before_state', $object->getHoldBeforeState()); + } + + public function testGetHoldBeforeStatus() + { + $data = ['hold_before_status' => 'test_value_hold_before_status']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_hold_before_status', $object->getHoldBeforeStatus()); + } + + public function testGetIncrementId() + { + $data = ['increment_id' => 'test_value_increment_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_increment_id', $object->getIncrementId()); + } + + public function testGetIsVirtual() + { + $data = ['is_virtual' => 'test_value_is_virtual']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_is_virtual', $object->getIsVirtual()); + } + + public function testGetOrderCurrencyCode() + { + $data = ['order_currency_code' => 'test_value_order_currency_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_order_currency_code', $object->getOrderCurrencyCode()); + } + + public function testGetOriginalIncrementId() + { + $data = ['original_increment_id' => 'test_value_original_increment_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_original_increment_id', $object->getOriginalIncrementId()); + } + + public function testGetPaymentAuthorizationAmount() + { + $data = ['payment_authorization_amount' => 'test_value_payment_authorization_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_payment_authorization_amount', $object->getPaymentAuthorizationAmount()); + } + + public function testGetPaymentAuthExpiration() + { + $data = ['payment_auth_expiration' => 'test_value_payment_auth_expiration']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_payment_auth_expiration', $object->getPaymentAuthExpiration()); + } + + public function testGetProtectCode() + { + $data = ['protect_code' => 'test_value_protect_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_protect_code', $object->getProtectCode()); + } + + public function testGetQuoteAddressId() + { + $data = ['quote_address_id' => 'test_value_quote_address_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_quote_address_id', $object->getQuoteAddressId()); + } + + public function testGetQuoteId() + { + $data = ['quote_id' => 'test_value_quote_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_quote_id', $object->getQuoteId()); + } + + public function testGetRelationChildId() + { + $data = ['relation_child_id' => 'test_value_relation_child_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_relation_child_id', $object->getRelationChildId()); + } + + public function testGetRelationChildRealId() + { + $data = ['relation_child_real_id' => 'test_value_relation_child_real_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_relation_child_real_id', $object->getRelationChildRealId()); + } + + public function testGetRelationParentId() + { + $data = ['relation_parent_id' => 'test_value_relation_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_relation_parent_id', $object->getRelationParentId()); + } + + public function testGetRelationParentRealId() + { + $data = ['relation_parent_real_id' => 'test_value_relation_parent_real_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_relation_parent_real_id', $object->getRelationParentRealId()); + } + + public function testGetRemoteIp() + { + $data = ['remote_ip' => 'test_value_remote_ip']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_remote_ip', $object->getRemoteIp()); + } + + public function testGetShippingAddressId() + { + $data = ['shipping_address_id' => 'test_value_shipping_address_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_address_id', $object->getShippingAddressId()); + } + + public function testGetShippingAmount() + { + $data = ['shipping_amount' => 'test_value_shipping_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_amount', $object->getShippingAmount()); + } + + public function testGetShippingCanceled() + { + $data = ['shipping_canceled' => 'test_value_shipping_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_canceled', $object->getShippingCanceled()); + } + + public function testGetShippingDescription() + { + $data = ['shipping_description' => 'test_value_shipping_description']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_description', $object->getShippingDescription()); + } + + public function testGetShippingDiscountAmount() + { + $data = ['shipping_discount_amount' => 'test_value_shipping_discount_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_discount_amount', $object->getShippingDiscountAmount()); + } + + public function testGetShippingHiddenTaxAmount() + { + $data = ['shipping_hidden_tax_amount' => 'test_value_shipping_hidden_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_hidden_tax_amount', $object->getShippingHiddenTaxAmount()); + } + + public function testGetShippingInclTax() + { + $data = ['shipping_incl_tax' => 'test_value_shipping_incl_tax']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_incl_tax', $object->getShippingInclTax()); + } + + public function testGetShippingInvoiced() + { + $data = ['shipping_invoiced' => 'test_value_shipping_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_invoiced', $object->getShippingInvoiced()); + } + + public function testGetShippingMethod() + { + $data = ['shipping_method' => 'test_value_shipping_method']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_method', $object->getShippingMethod()); + } + + public function testGetShippingRefunded() + { + $data = ['shipping_refunded' => 'test_value_shipping_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_refunded', $object->getShippingRefunded()); + } + + public function testGetShippingTaxAmount() + { + $data = ['shipping_tax_amount' => 'test_value_shipping_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_tax_amount', $object->getShippingTaxAmount()); + } + + public function testGetShippingTaxRefunded() + { + $data = ['shipping_tax_refunded' => 'test_value_shipping_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_tax_refunded', $object->getShippingTaxRefunded()); + } + + public function testGetState() + { + $data = ['state' => 'test_value_state']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_state', $object->getState()); + } + + public function testGetStatus() + { + $data = ['status' => 'test_value_status']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_status', $object->getStatus()); + } + + public function testGetStoreCurrencyCode() + { + $data = ['store_currency_code' => 'test_value_store_currency_code']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_store_currency_code', $object->getStoreCurrencyCode()); + } + + public function testGetStoreId() + { + $data = ['store_id' => 'test_value_store_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_store_id', $object->getStoreId()); + } + + public function testGetStoreName() + { + $data = ['store_name' => 'test_value_store_name']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_store_name', $object->getStoreName()); + } + + public function testGetStoreToBaseRate() + { + $data = ['store_to_base_rate' => 'test_value_store_to_base_rate']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_store_to_base_rate', $object->getStoreToBaseRate()); + } + + public function testGetStoreToOrderRate() + { + $data = ['store_to_order_rate' => 'test_value_store_to_order_rate']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_store_to_order_rate', $object->getStoreToOrderRate()); + } + + public function testGetSubtotal() + { + $data = ['subtotal' => 'test_value_subtotal']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_subtotal', $object->getSubtotal()); + } + + public function testGetSubtotalCanceled() + { + $data = ['subtotal_canceled' => 'test_value_subtotal_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_subtotal_canceled', $object->getSubtotalCanceled()); + } + + public function testGetSubtotalInclTax() + { + $data = ['subtotal_incl_tax' => 'test_value_subtotal_incl_tax']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_subtotal_incl_tax', $object->getSubtotalInclTax()); + } + + public function testGetSubtotalInvoiced() + { + $data = ['subtotal_invoiced' => 'test_value_subtotal_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_subtotal_invoiced', $object->getSubtotalInvoiced()); + } + + public function testGetSubtotalRefunded() + { + $data = ['subtotal_refunded' => 'test_value_subtotal_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_subtotal_refunded', $object->getSubtotalRefunded()); + } + + public function testGetTaxAmount() + { + $data = ['tax_amount' => 'test_value_tax_amount']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_tax_amount', $object->getTaxAmount()); + } + + public function testGetTaxCanceled() + { + $data = ['tax_canceled' => 'test_value_tax_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_tax_canceled', $object->getTaxCanceled()); + } + + public function testGetTaxInvoiced() + { + $data = ['tax_invoiced' => 'test_value_tax_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_tax_invoiced', $object->getTaxInvoiced()); + } + + public function testGetTaxRefunded() + { + $data = ['tax_refunded' => 'test_value_tax_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_tax_refunded', $object->getTaxRefunded()); + } + + public function testGetTotalCanceled() + { + $data = ['total_canceled' => 'test_value_total_canceled']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_canceled', $object->getTotalCanceled()); + } + + public function testGetTotalDue() + { + $data = ['total_due' => 'test_value_total_due']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_due', $object->getTotalDue()); + } + + public function testGetTotalInvoiced() + { + $data = ['total_invoiced' => 'test_value_total_invoiced']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_invoiced', $object->getTotalInvoiced()); + } + + public function testGetTotalItemCount() + { + $data = ['total_item_count' => 'test_value_total_item_count']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_item_count', $object->getTotalItemCount()); + } + + public function testGetTotalOfflineRefunded() + { + $data = ['total_offline_refunded' => 'test_value_total_offline_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_offline_refunded', $object->getTotalOfflineRefunded()); + } + + public function testGetTotalOnlineRefunded() + { + $data = ['total_online_refunded' => 'test_value_total_online_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_online_refunded', $object->getTotalOnlineRefunded()); + } + + public function testGetTotalPaid() + { + $data = ['total_paid' => 'test_value_total_paid']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_paid', $object->getTotalPaid()); + } + + public function testGetTotalQtyOrdered() + { + $data = ['total_qty_ordered' => 'test_value_total_qty_ordered']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_qty_ordered', $object->getTotalQtyOrdered()); + } + + public function testGetTotalRefunded() + { + $data = ['total_refunded' => 'test_value_total_refunded']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_total_refunded', $object->getTotalRefunded()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); + } + + public function testGetWeight() + { + $data = ['weight' => 'test_value_weight']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_weight', $object->getWeight()); + } + + public function testGetXForwardedFor() + { + $data = ['x_forwarded_for' => 'test_value_x_forwarded_for']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_x_forwarded_for', $object->getXForwardedFor()); + } + + 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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_items', $object->getItems()); + } + + public function testGetBillingAddress() + { + $data = ['billing_address' => 'test_value_billing_address']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_billing_address', $object->getBillingAddress()); + } + + public function testGetShippingAddress() + { + $data = ['shipping_address' => 'test_value_shipping_address']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_address', $object->getShippingAddress()); + } + + public function testGetPayments() + { + $data = ['payments' => 'test_value_payments']; + $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\Order($abstractBuilderMock); + + $this->assertEquals('test_value_payments', $object->getPayments()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentItemTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentItemTest.php new file mode 100644 index 00000000000..35c4c299399 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentItemTest.php @@ -0,0 +1,219 @@ +<?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 ShipmentItemTest extends \PHPUnit_Framework_TestCase +{ + public function testGetAdditionalData() + { + $data = ['additional_data' => 'test_value_additional_data']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_additional_data', $object->getAdditionalData()); + } + + public function testGetDescription() + { + $data = ['description' => 'test_value_description']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_description', $object->getDescription()); + } + + 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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetName() + { + $data = ['name' => 'test_value_name']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_name', $object->getName()); + } + + public function testGetOrderItemId() + { + $data = ['order_item_id' => 'test_value_order_item_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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_order_item_id', $object->getOrderItemId()); + } + + 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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetPrice() + { + $data = ['price' => 'test_value_price']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_price', $object->getPrice()); + } + + public function testGetProductId() + { + $data = ['product_id' => 'test_value_product_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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_product_id', $object->getProductId()); + } + + public function testGetQty() + { + $data = ['qty' => 'test_value_qty']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_qty', $object->getQty()); + } + + public function testGetRowTotal() + { + $data = ['row_total' => 'test_value_row_total']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_row_total', $object->getRowTotal()); + } + + public function testGetSku() + { + $data = ['sku' => 'test_value_sku']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_sku', $object->getSku()); + } + + public function testGetWeight() + { + $data = ['weight' => 'test_value_weight']; + $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\ShipmentItem($abstractBuilderMock); + + $this->assertEquals('test_value_weight', $object->getWeight()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTest.php new file mode 100644 index 00000000000..8830208dfd7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTest.php @@ -0,0 +1,267 @@ +<?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 ShipmentTest extends \PHPUnit_Framework_TestCase +{ + public function testGetBillingAddressId() + { + $data = ['billing_address_id' => 'test_value_billing_address_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_billing_address_id', $object->getBillingAddressId()); + } + + 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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetCustomerId() + { + $data = ['customer_id' => 'test_value_customer_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_customer_id', $object->getCustomerId()); + } + + public function testGetEmailSent() + { + $data = ['email_sent' => 'test_value_email_sent']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_email_sent', $object->getEmailSent()); + } + + 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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetIncrementId() + { + $data = ['increment_id' => 'test_value_increment_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_increment_id', $object->getIncrementId()); + } + + public function testGetOrderId() + { + $data = ['order_id' => 'test_value_order_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_order_id', $object->getOrderId()); + } + + public function testGetPackages() + { + $data = ['packages' => 'test_value_packages']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_packages', $object->getPackages()); + } + + public function testGetShipmentStatus() + { + $data = ['shipment_status' => 'test_value_shipment_status']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_shipment_status', $object->getShipmentStatus()); + } + + public function testGetShippingAddressId() + { + $data = ['shipping_address_id' => 'test_value_shipping_address_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_address_id', $object->getShippingAddressId()); + } + + public function testGetShippingLabel() + { + $data = ['shipping_label' => 'test_value_shipping_label']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_shipping_label', $object->getShippingLabel()); + } + + public function testGetStoreId() + { + $data = ['store_id' => 'test_value_store_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_store_id', $object->getStoreId()); + } + + public function testGetTotalQty() + { + $data = ['total_qty' => 'test_value_total_qty']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_total_qty', $object->getTotalQty()); + } + + public function testGetTotalWeight() + { + $data = ['total_weight' => 'test_value_total_weight']; + $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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_total_weight', $object->getTotalWeight()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\Shipment($abstractBuilderMock); + + $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTrackTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTrackTest.php new file mode 100644 index 00000000000..a23a83674e1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/ShipmentTrackTest.php @@ -0,0 +1,203 @@ +<?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 ShipmentTrackTest extends \PHPUnit_Framework_TestCase +{ + public function testGetCarrierCode() + { + $data = ['carrier_code' => 'test_value_carrier_code']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_carrier_code', $object->getCarrierCode()); + } + + 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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_created_at', $object->getCreatedAt()); + } + + public function testGetDescription() + { + $data = ['description' => 'test_value_description']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_description', $object->getDescription()); + } + + 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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_entity_id', $object->getEntityId()); + } + + public function testGetOrderId() + { + $data = ['order_id' => 'test_value_order_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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_order_id', $object->getOrderId()); + } + + 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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_parent_id', $object->getParentId()); + } + + public function testGetQty() + { + $data = ['qty' => 'test_value_qty']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_qty', $object->getQty()); + } + + public function testGetTitle() + { + $data = ['title' => 'test_value_title']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_title', $object->getTitle()); + } + + public function testGetTrackNumber() + { + $data = ['track_number' => 'test_value_track_number']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_track_number', $object->getTrackNumber()); + } + + public function testGetUpdatedAt() + { + $data = ['updated_at' => 'test_value_updated_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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_updated_at', $object->getUpdatedAt()); + } + + public function testGetWeight() + { + $data = ['weight' => 'test_value_weight']; + $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\ShipmentTrack($abstractBuilderMock); + + $this->assertEquals('test_value_weight', $object->getWeight()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php new file mode 100644 index 00000000000..2f8d6568a64 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php @@ -0,0 +1,85 @@ +<?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 OrderAddressUpdateTest + */ +class OrderAddressUpdateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OrderAddressUpdate + */ + protected $orderAddressUpdate; + + /** + * @var \Magento\Sales\Model\Order\AddressConverter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressConverterMock; + + protected function setUp() + { + $this->addressConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\AddressConverter', + ['getModel'], + [], + '', + false + ); + $this->orderAddressUpdate = new OrderAddressUpdate( + $this->addressConverterMock + ); + } + + /** + * test Order Address Update service + */ + public function testInvoke() + { + $dtoMock = $this->getMock( + '\Magento\Sales\Service\V1\Data\OrderAddress', + [], + [], + '', + false + ); + + $orderAddressModel = $this->getMock( + 'Magento\Sales\Model\Order\Address', + ['save', '__wakeup'], + [], + '', + false + ); + $this->addressConverterMock->expects($this->once()) + ->method('getModel') + ->with($this->equalTo($dtoMock)) + ->will($this->returnValue($orderAddressModel)); + $orderAddressModel->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->orderAddressUpdate->invoke($dtoMock); + + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php new file mode 100644 index 00000000000..b0ba41f3de2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCancelTest.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\Service\V1; + +/** + * Class OrderCancelTest + */ +class OrderCancelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\OrderCancel + */ + protected $orderCancel; + /** + * @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderRepositoryMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->orderCancel = new \Magento\Sales\Service\V1\OrderCancel( + $this->orderRepositoryMock + ); + } + + /** + * test order cancel service + */ + public function testInvoke() + { + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->orderMock)); + $this->orderMock->expects($this->once()) + ->method('cancel') + ->will($this->returnSelf()); + $this->assertTrue($this->orderCancel->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php new file mode 100644 index 00000000000..cea9475a6f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php @@ -0,0 +1,189 @@ +<?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 OrderCommentsListTest + */ +class OrderCommentsListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\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 + */ + protected $searchCriteriaMock; + + protected function setUp() + { + $this->historyRepositoryMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\HistoryRepository', + ['find'], + [], + '', + false + ); + $this->historyMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderStatusHistoryMapper', + ['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\OrderStatusHistorySearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->orderCommentMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\History', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderStatusHistory', + [], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->orderCommentsList = new \Magento\Sales\Service\V1\OrderCommentsList( + $this->historyRepositoryMock, + $this->historyMapperMock, + $this->criteriaBuilderMock, + $this->filterBuilderMock, + $this->searchResultsBuilderMock + ); + + } + + /** + * test order comments list service + */ + public function testInvoke() + { + $orderId = 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($orderId)) + ->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->historyRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->orderCommentMock])); + + $this->historyMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->orderCommentMock)) + ->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->orderCommentsList->invoke($orderId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php new file mode 100644 index 00000000000..a9539a1d941 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.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; + +use Magento\Sales\Service\V1\OrderGetStatus; +use Magento\Sales\Model\OrderRepository; + +/** + * Class OrderGetStatusTest + * @package Magento\Sales\Service\V1 + */ +class OrderGetStatusTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var OrderGetStatus + */ + protected $service; + /** + * @var OrderRepository | \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderRepositoryMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + + $this->service = new \Magento\Sales\Service\V1\OrderGetStatus($this->orderRepositoryMock); + } + + public function testInvoke() + { + $status = 'pending'; + $id = 1; + $orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + ['getStatus'], + [], + '', + false + ); + $orderMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo($id)) + ->will($this->returnValue($orderMock)); + $this->assertEquals($status, $this->service->invoke($id)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.php new file mode 100644 index 00000000000..89ecd2aa47f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderGetTest.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; + +/** + * Class OrderGetTest + */ +class OrderGetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\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 + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + $this->orderMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder', + [], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Order', + [], + [], + '', + false + ); + $this->orderGet = new \Magento\Sales\Service\V1\OrderGet( + $this->orderRepositoryMock, + $this->orderMapperMock + ); + } + + /** + * test order list service + */ + public function testInvoke() + { + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->orderMock)); + $this->orderMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->orderMock)) + ->will($this->returnValue($this->dataObjectMock)); + $this->assertEquals($this->dataObjectMock, $this->orderGet->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php new file mode 100644 index 00000000000..b86fd01e6c8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderHoldTest.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; + +/** + * Class OrderHoldTest + */ +class OrderHoldTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\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() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->orderHold = new \Magento\Sales\Service\V1\OrderHold( + $this->orderRepositoryMock + ); + } + + /** + * test order hold service + */ + public function testInvoke() + { + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->orderMock)); + $this->orderMock->expects($this->once()) + ->method('hold') + ->will($this->returnSelf()); + $this->assertTrue($this->orderHold->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.php new file mode 100644 index 00000000000..386aa8cfe38 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderListTest.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\Service\V1; + +/** + * Class OrderListTest + */ +class OrderListTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\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 + */ + protected $dataObjectMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['find'], + [], + '', + false + ); + $this->orderMapperMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderMapper', + [], + [], + '', + false + ); + $this->searchResultsBuilderMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\OrderSearchResultsBuilder', + ['setItems', 'setSearchCriteria', 'create', 'setTotalCount'], + [], + '', + false + ); + $this->searchCriteriaMock = $this->getMock( + 'Magento\Framework\Service\V1\Data\SearchCriteria', + [], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->dataObjectMock = $this->getMock( + 'Magento\Sales\Service\V1\Data\Order', + [], + [], + '', + false + ); + $this->orderList = new \Magento\Sales\Service\V1\OrderList( + $this->orderRepositoryMock, + $this->orderMapperMock, + $this->searchResultsBuilderMock + ); + } + + /** + * test order list service + */ + public function testInvoke() + { + $this->orderRepositoryMock->expects($this->once()) + ->method('find') + ->with($this->equalTo($this->searchCriteriaMock)) + ->will($this->returnValue([$this->orderMock])); + $this->orderMapperMock->expects($this->once()) + ->method('extractDto') + ->with($this->equalTo($this->orderMock)) + ->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->orderList->invoke($this->searchCriteriaMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.php new file mode 100644 index 00000000000..b18d26e513b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderNotifyUserTest.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\Service\V1; + +/** + * Test Class OrderNotifyUserTest for Order Service + * @package Magento\Sales\Service\V1 + */ +class OrderNotifyUserTest 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); + $order = $this->getMock( + '\Magento\Sales\Model\Order', + ['__wakeup', 'sendNewOrderEmail', 'getEmailSent'], + [], + '', + false + ); + + $service = $objectManager->getObject( + 'Magento\Sales\Service\V1\OrderNotifyUser', + [ + 'orderRepository' => $orderRepository, + 'notifier' => $notifier + ] + ); + $orderRepository->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/OrderStatusHistoryAddTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php new file mode 100644 index 00000000000..58b1901c6b0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php @@ -0,0 +1,96 @@ +<?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\Model\OrderRepository; +use Magento\Sales\Model\Order\Status\HistoryConverter; + +/** + * Class OrderStatusHistoryAddTest + * @package Magento\Sales\Service\V1 + */ +class OrderStatusHistoryAddTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\OrderStatusHistoryAdd + */ + protected $service; + + /** + * @var OrderRepository | \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderRepositoryMock; + + /** + * @var HistoryConverter | \PHPUnit_Framework_MockObject_MockObject + */ + protected $historyConverterMock; + + /** + * SetUp + */ + protected function setUp() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + $this->historyConverterMock = $this->getMock( + 'Magento\Sales\Model\Order\Status\HistoryConverter', + ['getModel'], + [], + '', + false + ); + $this->service = new OrderStatusHistoryAdd( + $this->orderRepositoryMock, + $this->historyConverterMock + ); + } + + public function testInvoke() + { + $id = 1; + + $dataObject = $this->getMock('Magento\Sales\Service\V1\Data\OrderStatusHistory', [], [], '', false); + $model = $this->getMock('Magento\Sales\Model\Order\Status\History', [], [], '', false); + $this->historyConverterMock->expects($this->once()) + ->method('getModel') + ->with($dataObject) + ->will($this->returnValue($model)); + $orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $orderMock->expects($this->once()) + ->method('addStatusHistory') + ->with($model); + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($id) + ->will($this->returnValue($orderMock)); + + $this->assertTrue($this->service->invoke($id, $dataObject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php new file mode 100644 index 00000000000..2c52a1763fc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.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; + +/** + * Class OrderUnHoldTest + */ +class OrderUnHoldTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Service\V1\OrderUnHold + */ + + protected $orderUnHold; + /** + * @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() + { + $this->orderRepositoryMock = $this->getMock( + 'Magento\Sales\Model\OrderRepository', + ['get'], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [], + [], + '', + false + ); + $this->orderUnHold = new \Magento\Sales\Service\V1\OrderUnHold( + $this->orderRepositoryMock + ); + } + + /** + * test order unhold service + */ + public function testInvoke() + { + $this->orderRepositoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(1)) + ->will($this->returnValue($this->orderMock)); + $this->orderMock->expects($this->once()) + ->method('unhold') + ->will($this->returnSelf()); + $this->assertTrue($this->orderUnHold->invoke(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php index 3f78f7a08df..020980e2aae 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRateServiceTest.php @@ -147,6 +147,24 @@ class TaxRateServiceTest extends \PHPUnit_Framework_TestCase } + /** + * @expectedException \Magento\Framework\Exception\InputException + * @expectedExceptionMessage id is not expected for this request. + */ + public function testCreateTaxRateWithId() + { + $taxData = [ + 'id' => 2, + 'country_id' => '', + 'region_id' => '8', + 'percentage_rate' => '8.25', + 'code' => 'US-CA-*-Rate', + 'zip_range' => ['from' => 78765, 'to' => 78780] + ]; + $taxRateDataObject = $this->taxRateBuilder->populateWithArray($taxData)->create(); + $this->taxRateService->createTaxRate($taxRateDataObject); + } + /** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage country_id is a required field. diff --git a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php index a72665c8cf8..cec65a1dc64 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxRuleServiceTest.php @@ -27,6 +27,8 @@ use Magento\Framework\Exception\ErrorMessage; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Tax\Service\V1\Data\TaxRule; +use Magento\Tax\Service\V1\Data\TaxClass; +use Magento\Tax\Model\ClassModel as TaxClassModel; use Magento\TestFramework\Helper\ObjectManager; /** @@ -82,6 +84,11 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase */ private $objectManager; + /** + * @var TaxClassService | \PHPUnit_Framework_MockObject_MockObject + */ + private $taxClassServiceMock; + public function setUp() { $this->objectManager = new ObjectManager($this); @@ -117,6 +124,40 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->taxClassServiceMock = $this->getMockBuilder('\Magento\Tax\Service\V1\TaxClassService') + ->disableOriginalConstructor() + ->getMock(); + + $taxClassBuilder = $this->objectManager->getObject('Magento\Tax\Service\V1\Data\TaxClassBuilder'); + + $customerTaxClassArray = [ + TaxClass::KEY_ID => 3, + TaxClass::KEY_NAME => 'Some Customer Tax Class', + TaxClass::KEY_TYPE => TaxClassModel::TAX_CLASS_TYPE_CUSTOMER, + ]; + + $productTaxClassArray = [ + TaxClass::KEY_ID => 2, + TaxClass::KEY_NAME => 'Some Product Tax Class', + TaxClass::KEY_TYPE => TaxClassModel::TAX_CLASS_TYPE_PRODUCT, + ]; + + $customerTaxClass = $taxClassBuilder->populateWithArray($customerTaxClassArray)->create(); + $productTaxClass = $taxClassBuilder->populateWithArray($productTaxClassArray)->create(); + + $map = [ + [ + 3, $customerTaxClass, + ], + [ + 2, $productTaxClass, + ], + ]; + + $this->taxClassServiceMock->expects($this->any()) + ->method('getTaxClass') + ->will($this->returnValueMap($map)); + $this->taxRuleService = $this->getTaxRuleService($taxRuleResultsBuilder); } @@ -260,7 +301,6 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase { $taxRuleBuilder = $this->objectManager->getObject('Magento\Tax\Service\V1\Data\TaxRuleBuilder'); $taxRule = $taxRuleBuilder - ->setId(2) ->setCode('code') ->setCustomerTaxClassIds([3]) ->setProductTaxClassIds([2]) @@ -283,6 +323,24 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase $this->assertSame($expectedTaxRule, $result); } + /** + * @expectedException \Magento\Framework\Exception\InputException + */ + public function testCreateTaxRuleSpecifyingId() + { + $taxRuleBuilder = $this->objectManager->getObject('Magento\Tax\Service\V1\Data\TaxRuleBuilder'); + $taxRule = $taxRuleBuilder + ->setId(9) + ->setCode('code') + ->setCustomerTaxClassIds([3]) + ->setProductTaxClassIds([2]) + ->setTaxRateIds([2]) + ->setPriority(0) + ->setSortOrder(1) + ->create(); + + $this->taxRuleService->createTaxRule($taxRule); + } /** * @dataProvider createTaxRuleMissingRequiredInfoDataProvider @@ -325,7 +383,6 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase ], 'negative fields' => [ [ - 'id' => 3, 'customer_tax_class_ids' => [3], 'product_tax_class_ids' => [2], 'tax_rate_ids' => [1], @@ -348,7 +405,6 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase { $taxRuleBuilder = $this->objectManager->getObject('Magento\Tax\Service\V1\Data\TaxRuleBuilder'); $taxRule = $taxRuleBuilder - ->setId(2) ->setCode('code') ->setCustomerTaxClassIds([3]) ->setProductTaxClassIds([2]) @@ -367,6 +423,39 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase $this->taxRuleService->createTaxRule($taxRule); } + public function testCreateTaxRuleInvalidTaxClassIds() + { + $taxRuleBuilder = $this->objectManager->getObject('Magento\Tax\Service\V1\Data\TaxRuleBuilder'); + $taxRule = $taxRuleBuilder + ->setCode('code') + ->setCustomerTaxClassIds([2]) + ->setProductTaxClassIds([3]) + ->setTaxRateIds([2]) + ->setPriority(0) + ->setSortOrder(1) + ->create(); + + try { + //Tax rule service call + $this->taxRuleService->createTaxRule($taxRule); + $this->fail('Did not throw expected InputException'); + } catch (InputException $e) { + $expectedCustomerTaxClassIdParams = [ + 'fieldName' => $taxRule::CUSTOMER_TAX_CLASS_IDS, + 'value' => 2, + ]; + $expectedProductTaxClassIdParams = [ + 'fieldName' => $taxRule::PRODUCT_TAX_CLASS_IDS, + 'value' => 3, + ]; + + $actualErrors = $e->getErrors(); + $this->assertEquals(2, count($actualErrors)); + $this->assertEquals($expectedCustomerTaxClassIdParams, $actualErrors[0]->getParameters()); + $this->assertEquals($expectedProductTaxClassIdParams, $actualErrors[1]->getParameters()); + } + } + public function testSearchTaxRulesEmptyResult() { /** @var \PHPUnit_Framework_MockObject_MockObject | @@ -610,7 +699,8 @@ class TaxRuleServiceTest extends \PHPUnit_Framework_TestCase 'taxRuleSearchResultsBuilder' => $taxRuleResultsBuilder, 'filterBuilder' => $this->filterBuilderMock, 'taxRateService' => $this->taxRateServiceMock, - 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock + 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, + 'taxClassService' => $this->taxClassServiceMock ] ); } diff --git a/dev/tests/unit/testsuite/Magento/User/Model/Authorization/AdminSessionUserContextTest.php b/dev/tests/unit/testsuite/Magento/User/Model/Authorization/AdminSessionUserContextTest.php new file mode 100644 index 00000000000..f876da272c3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/User/Model/Authorization/AdminSessionUserContextTest.php @@ -0,0 +1,108 @@ +<?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\User\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Tests Magento\User\Model\Authorization\AdminSessionUserContext + */ +class AdminSessionUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\User\Model\Authorization\AdminSessionUserContext + */ + protected $adminSessionUserContext; + + /** + * @var \Magento\Backend\Model\Auth\Session + */ + protected $adminSession; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->adminSession = $this->getMockBuilder('Magento\Backend\Model\Auth\Session') + ->disableOriginalConstructor() + ->setMethods(['hasUser', 'getUser', 'getId']) + ->getMock(); + + $this->adminSessionUserContext = $this->objectManager->getObject( + 'Magento\User\Model\Authorization\AdminSessionUserContext', + ['adminSession' => $this->adminSession] + ); + } + + public function testGetUserIdExist() + { + $userId = 1; + + $this->setupUserId($userId); + + $this->assertEquals($userId, $this->adminSessionUserContext->getUserId()); + } + + public function testGetUserIdDoesNotExist() + { + $userId = null; + + $this->setupUserId($userId); + + $this->assertEquals($userId, $this->adminSessionUserContext->getUserId()); + } + + public function testGetUserType() + { + $this->assertEquals(UserContextInterface::USER_TYPE_ADMIN, $this->adminSessionUserContext->getUserType()); + } + + /** + * @param int|null $userId + * @return void + */ + public function setupUserId($userId) + { + $this->adminSession->expects($this->once()) + ->method('hasUser') + ->will($this->returnValue($userId)); + + if ($userId) { + + $this->adminSession->expects($this->once()) + ->method('getUser') + ->will($this->returnSelf()); + + $this->adminSession->expects($this->once()) + ->method('getId') + ->will($this->returnValue($userId)); + } + } +} diff --git a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php index d3c9935755e..d1646b52df9 100644 --- a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php @@ -110,7 +110,7 @@ class UserTest extends \PHPUnit_Framework_TestCase array('create') )->getMock(); $roleFactoryMock = $this->getMockBuilder( - 'Magento\User\Model\RoleFactory' + 'Magento\Authorization\Model\RoleFactory' )->disableOriginalConstructor()->setMethods( array('create') )->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php index 21cb30a8561..b3da4eb68bc 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php @@ -23,6 +23,7 @@ */ namespace Magento\Webapi\Controller; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\Exception\AuthorizationException; /** @@ -59,8 +60,8 @@ class RestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Oauth\OauthInterface */ protected $_oauthServiceMock; - /** @var \Magento\Authz\Service\AuthorizationV1Interface */ - protected $_authzServiceMock; + /** @var \Magento\Framework\AuthorizationInterface */ + protected $_authorizationMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -77,6 +78,11 @@ class RestTest extends \PHPUnit_Framework_TestCase */ protected $areaMock; + /** + * @var \Magento\Authorization\Model\UserContextInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $userContextMock; + const SERVICE_METHOD = 'testMethod'; const SERVICE_ID = 'Magento\Webapi\Controller\TestService'; @@ -100,8 +106,10 @@ class RestTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor()->getMock(); $this->_oauthServiceMock = $this->getMockBuilder('\Magento\Framework\Oauth\OauthInterface') ->setMethods(['validateAccessTokenRequest'])->getMockForAbstractClass(); - $this->_authzServiceMock = $this->getMockBuilder('Magento\Authz\Service\AuthorizationV1Interface') + $this->_authorizationMock = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') ->disableOriginalConstructor()->getMock(); + $this->userContextMock = $this->getMockBuilder('Magento\Authorization\Model\UserContextInterface') + ->disableOriginalConstructor()->setMethods(['getUserId'])->getMockForAbstractClass(); } protected function setUp() @@ -129,10 +137,11 @@ class RestTest extends \PHPUnit_Framework_TestCase 'appState' => $this->_appStateMock, 'layout' => $layoutMock, 'oauthService' => $this->_oauthServiceMock, - 'authorizationService' => $this->_authzServiceMock, + 'authorization' => $this->_authorizationMock, 'serializer' => $this->serializerMock, 'errorProcessor' => $errorProcessorMock, - 'areaList' => $this->areaListMock + 'areaList' => $this->areaListMock, + 'userContext' => $this->userContextMock, ] ); // Set default expectations used by all tests @@ -171,9 +180,10 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue([])); $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue($isSecureRoute)); $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue([])); + $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue([])); $this->_requestMock->expects($this->any())->method('isSecure')->will($this->returnValue($isSecureRequest)); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); + $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->serializerMock->expects($this->any())->method('getInputData')->will($this->returnValue([])); $this->_restController->dispatch($this->_requestMock); $this->assertFalse($this->_responseMock->isException()); @@ -198,8 +208,9 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue([])); $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue(true)); + $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); $this->_requestMock->expects($this->any())->method('isSecure')->will($this->returnValue(false)); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); + $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); // Override default prepareResponse. It should never be called in this case $this->_responseMock->expects($this->never())->method('prepareResponse'); @@ -214,7 +225,7 @@ class RestTest extends \PHPUnit_Framework_TestCase public function testAuthorizationFailed() { $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); + $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); $this->_oauthServiceMock->expects( $this->any())->method('validateAccessTokenRequest')->will($this->returnValue('fred') ); @@ -233,15 +244,20 @@ class RestTest extends \PHPUnit_Framework_TestCase * @param array $requestData Data from the request * @param array $parameters Data from config about which parameters to override * @param array $expectedOverriddenParams Result of overriding $requestData when applying rules from $parameters + * @param int $userId The id of the user invoking the request + * @param int $userType The type of user invoking the request * * @dataProvider overrideParmasDataProvider */ - public function testOverrideParams($requestData, $parameters, $expectedOverriddenParams) + public function testOverrideParams($requestData, $parameters, $expectedOverriddenParams, $userId, $userType) { $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue($parameters)); + $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); + $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue($requestData)); + $this->userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($userId)); + $this->userContextMock->expects($this->any())->method('getUserType')->will($this->returnValue($userType)); // serializer should expect overridden params $this->serializerMock->expects($this->once())->method('getInputData') @@ -264,21 +280,43 @@ class RestTest extends \PHPUnit_Framework_TestCase ['Name1' => 'valueIn'], ['Name1' => ['force' => false, 'value' => 'valueOverride']], ['Name1' => 'valueIn'], + 1, + UserContextInterface::USER_TYPE_INTEGRATION, ], 'force true, value present' => [ ['Name1' => 'valueIn'], ['Name1' => ['force' => true, 'value' => 'valueOverride']], - ['Name1' => 'valueOverride'] + ['Name1' => 'valueOverride'], + 1, + UserContextInterface::USER_TYPE_INTEGRATION, ], 'force true, value not present' => [ ['Name1' => 'valueIn'], ['Name2' => ['force' => true, 'value' => 'valueOverride']], - ['Name1' => 'valueIn', 'Name2' => 'valueOverride'] + ['Name1' => 'valueIn', 'Name2' => 'valueOverride'], + 1, + UserContextInterface::USER_TYPE_INTEGRATION, ], 'force false, value not present' => [ ['Name1' => 'valueIn'], ['Name2' => ['force' => false, 'value' => 'valueOverride']], ['Name1' => 'valueIn', 'Name2' => 'valueOverride'], + 1, + UserContextInterface::USER_TYPE_INTEGRATION, + ], + 'force true, value present, override value is %customer_id%' => [ + ['Name1' => 'valueIn'], + ['Name1' => ['force' => true, 'value' => '%customer_id%']], + ['Name1' => '1234'], + 1234, + UserContextInterface::USER_TYPE_CUSTOMER, + ], + 'force true, value present, override value is %customer_id%, not a customer' => [ + ['Name1' => 'valueIn'], + ['Name1' => ['force' => true, 'value' => '%customer_id%']], + ['Name1' => '%customer_id%'], + 1234, + UserContextInterface::USER_TYPE_INTEGRATION, ], ]; } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php index 115ba3b9f75..7addf89fb0e 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php @@ -44,7 +44,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase protected $_requestMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_authzServiceMock; + protected $_authorizationMock; /** @var DataObjectConverter|\PHPUnit_Framework_MockObject_MockObject */ protected $_dataObjectConverter; @@ -62,7 +62,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase ->setMethods(array('getServiceMethodInfo'))->disableOriginalConstructor()->getMock(); $this->_requestMock = $this->getMock('Magento\Webapi\Controller\Soap\Request', [], [], '', false); $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager', [], [], '', false); - $this->_authzServiceMock = $this->getMock('Magento\Authz\Service\AuthorizationV1Interface', [], [], '', false); + $this->_authorizationMock = $this->getMock('Magento\Framework\AuthorizationInterface', [], [], '', false); $this->_dataObjectConverter = $this->getMock( 'Magento\Framework\Service\DataObjectConverter', ['convertStdObjectToArray'], @@ -76,7 +76,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase $this->_requestMock, $this->_objectManagerMock, $this->_apiConfigMock, - $this->_authzServiceMock, + $this->_authorizationMock, $this->_dataObjectConverter, $this->_serializerMock ); @@ -111,7 +111,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase ) ); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); + $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $serviceMock = $this->getMockBuilder($className) ->disableOriginalConstructor() ->setMethods(array($methodName)) diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index 0e6382eda42..a84ec784d38 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -48,9 +48,6 @@ class SoapTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\App\State */ protected $_appStateMock; - /** @var \Magento\Framework\Oauth\Oauth */ - protected $_oauthServiceMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Locale\ResolverInterface */ @@ -99,10 +96,6 @@ class SoapTest extends \PHPUnit_Framework_TestCase $layoutMock = $this->getMock('Magento\Framework\View\LayoutInterface'); - $this->_oauthServiceMock = $this->getMockBuilder('Magento\Framework\Oauth\Oauth') - ->disableOriginalConstructor() - ->getMock(); - $this->_responseMock->expects($this->any())->method('clearHeaders')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setWSDL')->will($this->returnSelf()); $this->_soapServerMock->expects($this->any())->method('setEncoding')->will($this->returnSelf()); @@ -119,7 +112,6 @@ class SoapTest extends \PHPUnit_Framework_TestCase $this->_errorProcessorMock, $this->_appStateMock, $layoutMock, - $this->_oauthServiceMock, $localeResolverMock, $pathProcessorMock, $areaListMock @@ -177,13 +169,6 @@ EXPECTED_MESSAGE; { $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_soapServerMock->expects($this->once())->method('handle'); - $this->_oauthServiceMock->expects( - $this->once() - )->method( - 'validateAccessToken' - )->will( - $this->returnValue(true) - ); $response = $this->_soapController->dispatch($this->_requestMock); $this->assertEquals(200, $response->getHttpResponseCode()); } @@ -247,13 +232,3 @@ EXPECTED_MESSAGE; } } -/** - * The function became available in CLI mode since PHP 5.5.7 which doesn't fit Magento minimal requirement. - * @see http://php.net/manual/en/function.getallheaders.php - * @return array - */ -function getallheaders() -{ - // Mixed case on purpose - return array('authOrization' => 'OAuth access_token'); -} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/GuestUserContextTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/GuestUserContextTest.php new file mode 100644 index 00000000000..0f4b9ac39f2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/GuestUserContextTest.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\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Tests Magento\Webapi\Model\Authorization\GuestUserContext + */ +class GuestUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Webapi\Model\Authorization\GuestUserContext + */ + protected $guestUserContext; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->guestUserContext = $this->objectManager->getObject( + 'Magento\Webapi\Model\Authorization\GuestUserContext' + ); + } + + public function testGetUserId() + { + $this->assertEquals(null, $this->guestUserContext->getUserId()); + } + + public function testGetUserType() + { + $this->assertEquals(UserContextInterface::USER_TYPE_GUEST, $this->guestUserContext->getUserType()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/OauthUserContextTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/OauthUserContextTest.php new file mode 100644 index 00000000000..094b5db72d1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/OauthUserContextTest.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\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Tests \Magento\Webapi\Model\Authorization\OauthUserContext + */ +class OauthUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Webapi\Model\Authorization\OauthUserContext + */ + protected $oauthUserContext; + + /** + * @var \Magento\Webapi\Controller\Request + */ + protected $request; + + /** + * @var \Magento\Framework\Oauth\Helper\Request + */ + protected $oauthRequestHelper; + + /** + * @var \Magento\Integration\Service\V1\Integration + */ + protected $integrationService; + + /** + * @var \Magento\Framework\Oauth\Oauth + */ + protected $oauthService; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->request = $this->getMockBuilder('Magento\Webapi\Controller\Request') + ->disableOriginalConstructor() + ->setMethods(['getConsumerId']) + ->getMock(); + + $this->integrationService = $this->getMockBuilder('Magento\Integration\Service\V1\Integration') + ->disableOriginalConstructor() + ->setMethods(['findActiveIntegrationByConsumerId']) + ->getMock(); + + $this->oauthRequestHelper = $this->getMockBuilder('Magento\Framework\Oauth\Helper\Request') + ->disableOriginalConstructor() + ->setMethods(['prepareRequest']) + ->getMock(); + + $this->oauthService = $this->getMockBuilder('Magento\Framework\Oauth\Oauth') + ->disableOriginalConstructor() + ->setMethods(['validateAccessTokenRequest']) + ->getMock(); + + $this->oauthUserContext = $this->objectManager->getObject( + 'Magento\Webapi\Model\Authorization\OauthUserContext', + [ + 'request' => $this->request, + 'integrationService' => $this->integrationService, + 'oauthService' => $this->oauthService, + 'oauthHelper' => $this->oauthRequestHelper + ] + ); + } + + public function testGetUserType() + { + $this->assertEquals(UserContextInterface::USER_TYPE_INTEGRATION, $this->oauthUserContext->getUserType()); + } + + public function testGetUserIdExist() + { + $integrationId = 12345; + + $this->setupUserId($integrationId, ['oauth_token' => 'asdcfsdvanskdcalkdsjcfljldk']); + + $this->assertEquals($integrationId, $this->oauthUserContext->getUserId()); + } + + public function testGetUserIdDoesNotExist() + { + $integrationId = null; + + $this->setupUserId($integrationId, ['oauth_token' => 'asdcfsdvanskdcalkdsjcfljldk']); + + $this->assertEquals($integrationId, $this->oauthUserContext->getUserId()); + } + + public function testGetUserIdNoOauthInformation() + { + $integrationId = 12345; + + $this->setupUserId($integrationId, []); + + $this->assertEquals(null, $this->oauthUserContext->getUserId()); + } + + /** + * @param int|null $integrationId + * @param array $oauthRequest + * @return void + */ + public function setupUserId($integrationId, $oauthRequest) + { + $integration = $this->getMockBuilder('Magento\Integration\Model\Integration') + ->disableOriginalConstructor() + ->setMethods(['getId', '__wakeup']) + ->getMock(); + + $this->integrationService->expects($this->any()) + ->method('findActiveIntegrationByConsumerId') + ->will($this->returnValue($integration)); + + $this->oauthRequestHelper->expects($this->once()) + ->method('prepareRequest') + ->will($this->returnValue($oauthRequest)); + + $this->oauthService->expects($this->any()) + ->method('validateAccessTokenRequest') + ->will($this->returnValue(1)); + + $integration->expects($this->any()) + ->method('getId') + ->will($this->returnValue($integrationId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/TokenUserContextTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/TokenUserContextTest.php new file mode 100644 index 00000000000..94f162e7d09 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Authorization/TokenUserContextTest.php @@ -0,0 +1,239 @@ +<?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\Webapi\Model\Authorization; + +use Magento\Authorization\Model\UserContextInterface; + +/** + * Tests \Magento\Webapi\Model\Authorization\TokenUserContext + */ +class TokenUserContextTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Webapi\Model\Authorization\TokenUserContext + */ + protected $tokenUserContext; + + /** + * @var \Magento\Integration\Model\Oauth\TokenFactory + */ + protected $tokenFactory; + + /** + * @var \Magento\Integration\Service\V1\Integration + */ + protected $integrationService; + + /** + * @var \Magento\Webapi\Controller\Request + */ + protected $request; + + protected function setUp() + { + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->request = $this->getMockBuilder('Magento\Webapi\Controller\Request') + ->disableOriginalConstructor() + ->setMethods(['getHeader']) + ->getMock(); + + $this->tokenFactory = $this->getMockBuilder('Magento\Integration\Model\Oauth\TokenFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->integrationService = $this->getMockBuilder('Magento\Integration\Service\V1\Integration') + ->disableOriginalConstructor() + ->setMethods(['findByConsumerId']) + ->getMock(); + + $this->tokenUserContext = $this->objectManager->getObject( + 'Magento\Webapi\Model\Authorization\TokenUserContext', + [ + 'request' => $this->request, + 'tokenFactory' => $this->tokenFactory, + 'integrationService' => $this->integrationService + ] + ); + } + + public function testNoAuthorizationHeader() + { + $this->request->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue(null)); + $this->assertNull($this->tokenUserContext->getUserType()); + $this->assertNull($this->tokenUserContext->getUserId()); + } + + public function testNoTokenInHeader() + { + $this->request->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue('Bearer')); + $this->assertNull($this->tokenUserContext->getUserType()); + $this->assertNull($this->tokenUserContext->getUserId()); + } + + public function testNotBearerToken() + { + $this->request->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue('Access')); + $this->assertNull($this->tokenUserContext->getUserType()); + $this->assertNull($this->tokenUserContext->getUserId()); + } + + public function testNoTokenInDatabase() + { + $bearerToken = 'bearer1234'; + + $this->request->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue("Bearer {$bearerToken}")); + + $token = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + ->disableOriginalConstructor() + ->setMethods(['loadByToken', 'getId', '__wakeup']) + ->getMock(); + $this->tokenFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($token)); + $token->expects($this->once()) + ->method('loadByToken') + ->with($bearerToken) + ->will($this->returnSelf()); + $token->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + + $this->assertNull($this->tokenUserContext->getUserType()); + $this->assertNull($this->tokenUserContext->getUserId()); + } + + /** + * @dataProvider getValidTokenData + */ + public function testValidToken($userType, $userId, $expectedUserType, $expectedUserId) + { + $bearerToken = 'bearer1234'; + + $this->request->expects($this->once()) + ->method('getHeader') + ->with('Authorization') + ->will($this->returnValue("Bearer {$bearerToken}")); + + $token = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') + ->disableOriginalConstructor() + ->setMethods(['loadByToken', 'getId', 'getUserType', 'getCustomerId', 'getAdminId', '__wakeup']) + ->getMock(); + $this->tokenFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($token)); + $token->expects($this->once()) + ->method('loadByToken') + ->with($bearerToken) + ->will($this->returnSelf()); + $token->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $token->expects($this->once()) + ->method('getUserType') + ->will($this->returnValue($userType)); + + $integration = $this->getMockBuilder('Magento\Integration\Model\Integration') + ->disableOriginalConstructor() + ->setMethods(['getId', '__wakeup']) + ->getMock(); + + switch($userType) { + case UserContextInterface::USER_TYPE_INTEGRATION: + $integration->expects($this->once()) + ->method('getId') + ->will($this->returnValue($userId)); + $this->integrationService->expects($this->once()) + ->method('findByConsumerId') + ->will($this->returnValue($integration)); + break; + case UserContextInterface::USER_TYPE_ADMIN: + $token->expects($this->once()) + ->method('getAdminId') + ->will($this->returnValue($userId)); + break; + case UserContextInterface::USER_TYPE_CUSTOMER: + $token->expects($this->once()) + ->method('getCustomerId') + ->will($this->returnValue($userId)); + break; + } + + $this->assertEquals($expectedUserType, $this->tokenUserContext->getUserType()); + $this->assertEquals($expectedUserId, $this->tokenUserContext->getUserId()); + + /* check again to make sure that the above methods were only called once */ + $this->assertEquals($expectedUserType, $this->tokenUserContext->getUserType()); + $this->assertEquals($expectedUserId, $this->tokenUserContext->getUserId()); + } + + public function getValidTokenData() + { + return [ + 'admin token' => [ + UserContextInterface::USER_TYPE_ADMIN, + 1234, + UserContextInterface::USER_TYPE_ADMIN, + 1234, + ], + 'customer token' => [ + UserContextInterface::USER_TYPE_CUSTOMER, + 1234, + UserContextInterface::USER_TYPE_CUSTOMER, + 1234, + ], + 'integration token' => [ + UserContextInterface::USER_TYPE_INTEGRATION, + 1234, + UserContextInterface::USER_TYPE_INTEGRATION, + 1234, + ], + 'guest user type' => [ + UserContextInterface::USER_TYPE_GUEST, + 1234, + null, + null, + ] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php index f703703fadd..a96970f7d57 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php @@ -79,9 +79,7 @@ return [ 'parameters' => [ 'id' => [ 'force' => true, - 'source' => 'session', - 'method' => 'getUserId', - 'value' => null, + 'value' => '%customer_id%', ], ], ], diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml index 122d07975bd..b820ab33cde 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml @@ -40,7 +40,7 @@ <resource ref="Magento_Customer::customer_self" /> </resources> <data> - <parameter name="id" force="true" source="session" method="getUserId">null</parameter> + <parameter name="id" force="true">%customer_id%</parameter> </data> </route> <route url="/V1/customers/me" method="PUT" secure="true"> diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/Service/V1/IntegrationTest.php similarity index 52% rename from dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php rename to dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/Service/V1/IntegrationTest.php index ce96df7e150..81c3c698316 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/Service/V1/IntegrationTest.php @@ -21,31 +21,17 @@ * @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\Model\Plugin; +namespace Magento\Webapi\Model\Plugin\Service\V1; -use Magento\Authz\Model\UserIdentifier; use Magento\Integration\Model\Integration; +use Magento\Authorization\Model\Acl\AclRetriever; -class IntegrationServiceV1Test extends \PHPUnit_Framework_TestCase +class IntegrationTest extends \PHPUnit_Framework_TestCase { - /** - * Authorization service mock - * - * @var \Magento\Authz\Service\AuthorizationV1 - */ - protected $authzServiceMock; - - /** - * Mock for UserIdentifier Factory - * - * @var \Magento\Authz\Model\UserIdentifier\Factory - */ - protected $userIdentifierFactoryMock; - /** * API setup plugin * - * @var \Magento\Webapi\Model\Plugin\IntegrationServiceV1 + * @var \Magento\Webapi\Model\Plugin\Service\V1\Integration */ protected $integrationV1Plugin; @@ -54,49 +40,43 @@ class IntegrationServiceV1Test extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** @var AclRetriever */ + protected $aclRetrieverMock; + + /** + * @var \Magento\Integration\Service\V1\AuthorizationServiceInterface + */ + protected $integrationAuthServiceMock; + public function setUp() { - $this->authzServiceMock = $this->getMockBuilder( - '\Magento\Authz\Service\AuthorizationV1' - )->disableOriginalConstructor()->setMethods( - array('removePermissions') - )->getMock(); - $this->userIdentifierFactoryMock = $this->getMockBuilder( - '\Magento\Authz\Model\UserIdentifier\Factory' - )->disableOriginalConstructor()->setMethods( - array('create') - )->getMock(); $this->subjectMock = $this->getMock('Magento\Integration\Service\V1\Integration', array(), array(), '', false); - $this->integrationV1Plugin = new \Magento\Webapi\Model\Plugin\IntegrationServiceV1( - $this->authzServiceMock, - $this->userIdentifierFactoryMock + $this->integrationAuthServiceMock = $this->getMockBuilder( + 'Magento\Integration\Service\V1\AuthorizationServiceInterface' + )->disableOriginalConstructor()->getMock(); + $this->aclRetrieverMock = $this->getMockBuilder('Magento\Authorization\Model\Acl\AclRetriever') + ->disableOriginalConstructor() + ->getMock(); + $this->integrationV1Plugin = new \Magento\Webapi\Model\Plugin\Service\V1\Integration( + $this->integrationAuthServiceMock, + $this->aclRetrieverMock ); } public function testAfterDelete() { + $integrationId = 1; $integrationsData = array( - Integration::ID => 1, + Integration::ID => $integrationId, Integration::NAME => 'TestIntegration1', Integration::EMAIL => 'test-integration1@magento.com', Integration::ENDPOINT => 'http://endpoint.com', Integration::SETUP_TYPE => 1 ); - $userIdentifierMock = $this->getMockBuilder( - '\Magento\Authz\Model\UserIdentifier' - )->disableOriginalConstructor()->getMock(); - $this->authzServiceMock->expects($this->once())->method('removePermissions')->with($userIdentifierMock); - $this->userIdentifierFactoryMock->expects( - $this->at(0) - )->method( - 'create' - )->with( - UserIdentifier::USER_TYPE_INTEGRATION, - 1 - )->will( - $this->returnValue($userIdentifierMock) - ); - $this->authzServiceMock->expects($this->once())->method('removePermissions')->with($userIdentifierMock); + + $this->integrationAuthServiceMock->expects($this->once()) + ->method('removePermissions') + ->with($integrationId); $this->integrationV1Plugin->afterDelete($this->subjectMock, $integrationsData); } } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php index 1a2f385c36e..0bdb4c8574b 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php @@ -23,7 +23,6 @@ */ namespace Magento\Webapi\Model\Plugin; -use Magento\Authz\Model\UserIdentifier; use Magento\Integration\Model\Integration; class SetupTest extends \PHPUnit_Framework_TestCase @@ -45,16 +44,9 @@ class SetupTest extends \PHPUnit_Framework_TestCase /** * Authorization service mock * - * @var \Magento\Authz\Service\AuthorizationV1 + * @var \Magento\Integration\Service\V1\AuthorizationService */ - protected $authzServiceMock; - - /** - * Mock for UserIdentifier Factory - * - * @var \Magento\Authz\Model\UserIdentifier\Factory - */ - protected $userIdentifierFactoryMock; + protected $integrationAuthorizationServiceMock; /** * API setup plugin @@ -82,24 +74,17 @@ class SetupTest extends \PHPUnit_Framework_TestCase array('findByName') )->getMock(); - $this->authzServiceMock = $this->getMockBuilder( - '\Magento\Authz\Service\AuthorizationV1' + $this->integrationAuthorizationServiceMock = $this->getMockBuilder( + '\Magento\Integration\Service\V1\AuthorizationService' )->disableOriginalConstructor()->setMethods( array('grantPermissions') )->getMock(); - $this->userIdentifierFactoryMock = $this->getMockBuilder( - '\Magento\Authz\Model\UserIdentifier\Factory' - )->disableOriginalConstructor()->setMethods( - array('create') - )->getMock(); - $this->subjectMock = $this->getMock('Magento\Integration\Model\Resource\Setup', array(), array(), '', false); $this->apiSetupPlugin = new \Magento\Webapi\Model\Plugin\Setup( $this->integrationConfigMock, - $this->authzServiceMock, - $this->integrationServiceMock, - $this->userIdentifierFactoryMock + $this->integrationAuthorizationServiceMock, + $this->integrationServiceMock ); } @@ -107,8 +92,6 @@ class SetupTest extends \PHPUnit_Framework_TestCase { $this->integrationConfigMock->expects($this->never())->method('getIntegrations'); $this->integrationServiceMock->expects($this->never())->method('findByName'); - $this->authzServiceMock->expects($this->never())->method('grantPermissions'); - $this->userIdentifierFactoryMock->expects($this->never())->method('create'); $this->apiSetupPlugin->afterInitIntegrationProcessing($this->subjectMock, array()); } @@ -137,10 +120,11 @@ class SetupTest extends \PHPUnit_Framework_TestCase ) ) ); + $firstInegrationId = 1; $integrationsData1 = new \Magento\Framework\Object( array( - 'id' => 1, + 'id' => $firstInegrationId, Integration::NAME => 'TestIntegration1', Integration::EMAIL => 'test-integration1@magento.com', Integration::ENDPOINT => 'http://endpoint.com', @@ -148,9 +132,10 @@ class SetupTest extends \PHPUnit_Framework_TestCase ) ); + $secondIntegrationId = 2; $integrationsData2 = new \Magento\Framework\Object( array( - 'id' => 2, + 'id' => $secondIntegrationId, Integration::NAME => 'TestIntegration2', Integration::EMAIL => 'test-integration2@magento.com', Integration::SETUP_TYPE => 1 @@ -177,51 +162,6 @@ class SetupTest extends \PHPUnit_Framework_TestCase $this->returnValue($integrationsData2) ); - $userIdentifierMock1 = $this->getMockBuilder( - '\Magento\Authz\Model\UserIdentifier' - )->disableOriginalConstructor()->getMock(); - $this->userIdentifierFactoryMock->expects( - $this->at(0) - )->method( - 'create' - )->with( - UserIdentifier::USER_TYPE_INTEGRATION, - 1 - )->will( - $this->returnValue($userIdentifierMock1) - ); - - $userIdentifierMock2 = $this->getMockBuilder( - '\Magento\Authz\Model\UserIdentifier' - )->disableOriginalConstructor()->getMock(); - $this->userIdentifierFactoryMock->expects( - $this->at(1) - )->method( - 'create' - )->with( - UserIdentifier::USER_TYPE_INTEGRATION, - 2 - )->will( - $this->returnValue($userIdentifierMock2) - ); - - $this->authzServiceMock->expects( - $this->at(0) - )->method( - 'grantPermissions' - )->with( - $userIdentifierMock1, - $testIntegration1Resource - ); - $this->authzServiceMock->expects( - $this->at(1) - )->method( - 'grantPermissions' - )->with( - $userIdentifierMock2, - $testIntegration2Resource - ); - $this->apiSetupPlugin->afterInitIntegrationProcessing( $this->subjectMock, array('TestIntegration1', 'TestIntegration2') diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/WebapiRoleLocatorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/WebapiRoleLocatorTest.php new file mode 100644 index 00000000000..6e389806d7e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/WebapiRoleLocatorTest.php @@ -0,0 +1,135 @@ +<?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\Webapi\Model; + +use Magento\Authorization\Model\Resource\Role\CollectionFactory as RoleCollectionFactory; +use Magento\Authorization\Model\Resource\Role\Collection as RoleCollection; +use Magento\Authorization\Model\Role; +use Magento\Authorization\Model\UserContextInterface; + +class WebapiRoleLocatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Webapi\Model\WebapiRoleLocator + */ + protected $locator; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * @var UserContextInterface + */ + protected $userContext; + + /** + * @var RoleCollectionFactory + */ + protected $roleCollectionFactory; + + /** + * @var RoleCollection + */ + protected $roleCollection; + + /** + * @var Role + */ + protected $role; + + protected function setUp() + { + $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $userId = 'userId'; + $userType = 'userType'; + + $this->userContext = $this->getMockBuilder('Magento\Authorization\Model\CompositeUserContext') + ->disableOriginalConstructor() + ->setMethods(['getUserId', 'getUserType']) + ->getMock(); + $this->userContext->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($userId)); + $this->userContext->expects($this->once()) + ->method('getUserType') + ->will($this->returnValue($userType)); + + $this->roleCollectionFactory = $this->getMockBuilder( + 'Magento\Authorization\Model\Resource\Role\CollectionFactory' + )->disableOriginalConstructor()->setMethods(['create'])->getMock(); + + $this->roleCollection = $this->getMockBuilder('Magento\Authorization\Model\Resource\Role\Collection') + ->disableOriginalConstructor() + ->setMethods(['setUserFilter', 'getFirstItem']) + ->getMock(); + $this->roleCollectionFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->roleCollection)); + $this->roleCollection->expects($this->once()) + ->method('setUserFilter') + ->with($userId, $userType) + ->will($this->returnValue($this->roleCollection)); + + $this->role = $this->getMockBuilder('Magento\Authorization\Model\Role') + ->disableOriginalConstructor() + ->setMethods(['getId', '__wakeup']) + ->getMock(); + + $this->roleCollection->expects($this->once()) + ->method('getFirstItem') + ->will($this->returnValue($this->role)); + + $this->locator = $this->_objectManager->getObject( + 'Magento\Webapi\Model\WebapiRoleLocator', + [ + 'userContext' => $this->userContext, + 'roleCollectionFactory' => $this->roleCollectionFactory + ] + ); + } + + public function testNoRoleId() + { + $this->role->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + + $this->assertEquals('', $this->locator->getAclRoleId()); + } + + public function testGetAclRoleId() + { + $roleId = 9; + + $this->role->expects($this->exactly(2)) + ->method('getId') + ->will($this->returnValue($roleId)); + + $this->assertEquals($roleId, $this->locator->getAclRoleId()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/_files/session_backend_mock.php b/dev/tests/unit/testsuite/Magento/_files/session_backend_mock.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Backend/Model/_files/session_backend_mock.php rename to dev/tests/unit/testsuite/Magento/_files/session_backend_mock.php diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index 60bfb993046..8c3986a4e45 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -24,6 +24,7 @@ require __DIR__ . '/../../../bootstrap.php'; $rootDir = realpath(__DIR__ . '/../../../../../'); use Magento\Framework\ObjectManager\Code\Generator\Factory; +use Magento\Framework\ObjectManager\Code\Generator\Repository; use Magento\Framework\ObjectManager\Code\Generator\Proxy; use Magento\Tools\Di\Compiler\Log\Log; use Magento\Tools\Di\Compiler\Log\Writer; @@ -31,6 +32,11 @@ use Magento\Tools\Di\Compiler\Directory; use Magento\Tools\Di\Code\Scanner; use Magento\Tools\Di\Definition\Compressor; use Magento\Tools\Di\Definition\Serializer; +use Magento\Framework\Service\Code\Generator\Builder; +use Magento\Framework\Service\Code\Generator\Mapper; +use Magento\Framework\ObjectManager\Code\Generator\Converter; +use Magento\Framework\Service\Code\Generator\SearchResults; +use Magento\Framework\Service\Code\Generator\SearchResultsBuilder; $filePatterns = array('php' => '/.*\.php$/', 'di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'); $codeScanDir = realpath($rootDir . '/app'); @@ -97,10 +103,18 @@ try { array( \Magento\Framework\Interception\Code\Generator\Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', + SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Service\Code\Generator\SearchResultsBuilder', Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', - Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory' + Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', + Builder::ENTITY_TYPE => 'Magento\Framework\Service\Code\Generator\Builder', + Mapper::ENTITY_TYPE => 'Magento\Framework\Service\Code\Generator\Mapper', + Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', + Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', + SearchResults::ENTITY_TYPE => 'Magento\Framework\Service\Code\Generator\SearchResults', ) ); + $autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); + spl_autoload_register(array($autoloader, 'load')); foreach (array('php', 'additional') as $type) { sort($entities[$type]); foreach ($entities[$type] as $entityName) { diff --git a/dev/tools/Magento/Tools/Di/entity_generator.php b/dev/tools/Magento/Tools/Di/entity_generator.php index 0729797407b..21745c00408 100644 --- a/dev/tools/Magento/Tools/Di/entity_generator.php +++ b/dev/tools/Magento/Tools/Di/entity_generator.php @@ -29,6 +29,12 @@ use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Proxy; use Magento\Framework\Interception\Code\Generator\Interceptor; use Magento\Framework\Exception; +use Magento\Framework\Service\Code\Generator\Builder; +use Magento\Framework\Service\Code\Generator\Mapper; +use Magento\Framework\ObjectManager\Code\Generator\Repository; +use Magento\Framework\ObjectManager\Code\Generator\Converter; +use Magento\Framework\Service\Code\Generator\SearchResults; +use Magento\Framework\Service\Code\Generator\SearchResultsBuilder; require __DIR__ . '/../../../../../app/bootstrap.php'; @@ -87,12 +93,24 @@ $generator = new Generator( null, $io, [ + SearchResultsBuilder::ENTITY_TYPE => + 'Magento\Framework\Service\Code\Generator\SearchResultsBuilder', Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', Interceptor::ENTITY_TYPE => - 'Magento\Framework\Interception\Code\Generator\Interceptor' + 'Magento\Framework\Interception\Code\Generator\Interceptor', + Builder::ENTITY_TYPE => + 'Magento\Framework\Service\Code\Generator\Builder', + Mapper::ENTITY_TYPE => + 'Magento\Framework\Service\Code\Generator\Mapper', + Repository::ENTITY_TYPE => + 'Magento\Framework\ObjectManager\Code\Generator\Repository', + Converter::ENTITY_TYPE => + 'Magento\Framework\ObjectManager\Code\Generator\Converter', + SearchResults::ENTITY_TYPE => + 'Magento\Framework\Service\Code\Generator\SearchResults', ] ); diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php index ad701200fc9..66abe867592 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php @@ -30,8 +30,8 @@ return array( 'admin/assert' => 'admin_assert', - 'admin/role' => 'admin_role', - 'admin/rule' => 'admin_rule', + 'admin/role' => 'authorization_role', + 'admin/rule' => 'authorization_rule', 'admin/user' => 'admin_user', 'adminnotification/inbox' => 'adminnotification_inbox', 'amazonpayments/api_debug' => 'amazonpayments_api_debug', diff --git a/lib/internal/Magento/Framework/Acl/Resource/Provider.php b/lib/internal/Magento/Framework/Acl/Resource/Provider.php index 33241737c12..003a23607ff 100644 --- a/lib/internal/Magento/Framework/Acl/Resource/Provider.php +++ b/lib/internal/Magento/Framework/Acl/Resource/Provider.php @@ -50,8 +50,7 @@ class Provider implements ProviderInterface */ public function getAclResources() { - // TODO: As soon as all acl.xml files are moved to global scope, default ('global') scope should be used - $aclResourceConfig = $this->_configReader->read('adminhtml'); + $aclResourceConfig = $this->_configReader->read(); if (!empty($aclResourceConfig['config']['acl']['resources'])) { return $this->_resourceTreeBuilder->build($aclResourceConfig['config']['acl']['resources']); } diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index b3124782474..cf5e5daaa9d 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-alpha89'; + const VERSION = '0.1.0-alpha90'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Authorization/RoleLocator.php b/lib/internal/Magento/Framework/Authorization/RoleLocator.php index ecfa82873b5..8fb144449ae 100644 --- a/lib/internal/Magento/Framework/Authorization/RoleLocator.php +++ b/lib/internal/Magento/Framework/Authorization/RoleLocator.php @@ -32,7 +32,7 @@ interface RoleLocator /** * Retrieve current role * - * @return string + * @return string|null */ public function getAclRoleId(); } diff --git a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php index b85c38054b5..6d1c0e40382 100644 --- a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php +++ b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php @@ -259,8 +259,6 @@ abstract class EntityAbstract $resultClassName = $this->_getResultClassName(); $resultFileName = $this->_ioObject->getResultFileName($resultClassName); - $autoloader = $this->_autoloader; - // @todo the controller handling logic below must be removed when controllers become PSR-0 compliant $controllerSuffix = 'Controller'; $pathParts = explode('_', $sourceClassName); @@ -286,13 +284,13 @@ abstract class EntityAbstract $filePath = stream_resolve_include_path(str_replace('_', '/', $controllerPath) . '.php'); $isSourceClassValid = !empty($filePath); } else { - $isSourceClassValid = $autoloader->getFile($sourceClassName); + $isSourceClassValid = $this->_autoloader->getFile($sourceClassName); } if (!$isSourceClassValid) { $this->_addError('Source class ' . $sourceClassName . ' doesn\'t exist.'); return false; - } elseif ($autoloader->getFile($resultClassName)) { + } elseif ($this->_autoloader->getFile($resultClassName)) { $this->_addError('Result class ' . $resultClassName . ' already exists.'); return false; } elseif (!$this->_ioObject->makeGenerationDirectory()) { diff --git a/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php b/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php index 27caa2b95af..11809449cbf 100644 --- a/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php +++ b/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php @@ -141,8 +141,8 @@ class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract $methods[] = array( 'name' => '__sleep', 'body' => "if (method_exists(get_parent_class(\$this), '__sleep')) {\n" . - " return parent::__sleep();\n" . - "} else {\n" . + " return array_diff(parent::__sleep(), array('pluginLocator', 'pluginList', 'chain', 'subjectType'));" . + "\n} else {\n" . " return array_keys(get_class_vars(get_parent_class(\$this)));\n" . "}\n" ); diff --git a/app/code/Magento/AdminNotification/Model/System/MessageInterface.php b/lib/internal/Magento/Framework/Notification/MessageInterface.php similarity index 88% rename from app/code/Magento/AdminNotification/Model/System/MessageInterface.php rename to lib/internal/Magento/Framework/Notification/MessageInterface.php index 7ab95cca5bc..65f2af1495d 100644 --- a/app/code/Magento/AdminNotification/Model/System/MessageInterface.php +++ b/lib/internal/Magento/Framework/Notification/MessageInterface.php @@ -19,18 +19,28 @@ * 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\AdminNotification\Model\System; +namespace Magento\Framework\Notification; + +/** + * Interface for system messages + * + * Interface MessageInterface + */ interface MessageInterface { const SEVERITY_CRITICAL = 1; const SEVERITY_MAJOR = 2; + const SEVERITY_MINOR = 3; + + const SEVERITY_NOTICE = 4; + /** * Retrieve unique message identity * diff --git a/app/code/Magento/AdminNotification/Model/System/MessageList.php b/lib/internal/Magento/Framework/Notification/MessageList.php similarity index 70% rename from app/code/Magento/AdminNotification/Model/System/MessageList.php rename to lib/internal/Magento/Framework/Notification/MessageList.php index ac86107e988..ac75c22fdfe 100644 --- a/app/code/Magento/AdminNotification/Model/System/MessageList.php +++ b/lib/internal/Magento/Framework/Notification/MessageList.php @@ -17,12 +17,18 @@ * 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\AdminNotification\Model\System; +namespace Magento\Framework\Notification; + +/** + * Class for processing the list of system messages + * + * Class MessageList + */ class MessageList { /** @@ -54,17 +60,24 @@ class MessageList * * @return void * @throws \InvalidArgumentException + * @throws \UnexpectedValueException */ protected function _loadMessages() { - if (!$this->_messages) { - foreach ($this->_messageClasses as $key => $messageClass) { - if (!$messageClass) { - throw new \InvalidArgumentException('Message class for message "' . $key . '" is not set'); - } - $message = $this->_objectManager->get($messageClass); + if (!empty($this->_messages)) { + return; + } + foreach ($this->_messageClasses as $key => $messageClass) { + if (!$messageClass) { + throw new \InvalidArgumentException('Message class for message "' . $key . '" is not set'); + } + $message = $this->_objectManager->get($messageClass); + if ($message instanceof \Magento\Framework\Notification\MessageInterface) { $this->_messages[$message->getIdentity()] = $message; + } else { + throw new \UnexpectedValueException("Message class has to implement the message interface."); } + } } @@ -72,7 +85,7 @@ class MessageList * Retrieve message by * * @param string $identity - * @return null|\Magento\AdminNotification\Model\System\MessageInterface + * @return null|\Magento\Framework\Notification\MessageInterface */ public function getMessageByIdentity($identity) { @@ -83,7 +96,7 @@ class MessageList /** * Retrieve list of all messages * - * @return \Magento\AdminNotification\Model\System\MessageInterface[] + * @return \Magento\Framework\Notification\MessageInterface[] */ public function asArray() { diff --git a/lib/internal/Magento/Framework/Notification/NotifierInterface.php b/lib/internal/Magento/Framework/Notification/NotifierInterface.php new file mode 100644 index 00000000000..a9586e17dd1 --- /dev/null +++ b/lib/internal/Magento/Framework/Notification/NotifierInterface.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\Framework\Notification; + +/** + * Interface for notifiers + * + * Interface NotifierInterface + */ +interface NotifierInterface +{ + /** + * Add new message + * + * @param int $severity + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @throws \Magento\Framework\Model\Exception + * @return $this + */ + public function add($severity, $title, $description, $url = '', $isInternal = true); + + /** + * Add critical severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addCritical($title, $description, $url = '', $isInternal = true); + + /** + * Add major severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addMajor($title, $description, $url = '', $isInternal = true); + + /** + * Add minor severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addMinor($title, $description, $url = '', $isInternal = true); + + /** + * Add notice + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addNotice($title, $description, $url = '', $isInternal = true); +} diff --git a/lib/internal/Magento/Framework/Notification/NotifierList.php b/lib/internal/Magento/Framework/Notification/NotifierList.php new file mode 100644 index 00000000000..404cf748147 --- /dev/null +++ b/lib/internal/Magento/Framework/Notification/NotifierList.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\Framework\Notification; + +/* + * List of registered system notifiers + */ +class NotifierList +{ + /** + * Object manager + * + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * List of notifiers + * + * @var NotifierInterface[]|string[] + */ + protected $notifiers; + + /** + * Whether the list of notifiers is verified (all notifiers should implement NotifierInterface interface) + * + * @var bool + */ + protected $isNotifiersVerified; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + * @param NotifierInterface[]|string[] $notifiers + */ + public function __construct(\Magento\Framework\ObjectManager $objectManager, $notifiers = array()) + { + $this->objectManager = $objectManager; + $this->notifiers = $notifiers; + $this->isNotifiersVerified = false; + } + + /** + * Returning list of notifiers. + * + * @return NotifierInterface[] + * @throws \InvalidArgumentException + */ + public function asArray() + { + if (!$this->isNotifiersVerified) { + $hasErrors = false; + foreach ($this->notifiers as $classIndex => $class) { + $notifier = $this->objectManager->get($class); + if ($notifier instanceof NotifierInterface) { + $this->notifiers[$classIndex] = $notifier; + } else { + $hasErrors = true; + unset($this->notifiers[$classIndex]); + } + } + $this->isNotifiersVerified = true; + if ($hasErrors) { + throw new \InvalidArgumentException('All notifiers should implements NotifierInterface'); + } + } + return $this->notifiers; + } +} diff --git a/lib/internal/Magento/Framework/Notification/NotifierPool.php b/lib/internal/Magento/Framework/Notification/NotifierPool.php new file mode 100644 index 00000000000..4a463225d1b --- /dev/null +++ b/lib/internal/Magento/Framework/Notification/NotifierPool.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\Framework\Notification; + +/** + * Default notifiers. Iterates through all registered notifiers to process message + * + * Class NotifierPool + */ +class NotifierPool implements NotifierInterface +{ + /** + * @var NotifierList + */ + protected $notifierList; + + /** + * @param NotifierList $notifierList + */ + public function __construct(NotifierList $notifierList) + { + $this->notifierList = $notifierList; + } + + /** + * Add new message + * + * @param int $severity + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @throws \Magento\Framework\Model\Exception + * @return $this + */ + public function add($severity, $title, $description, $url = '', $isInternal = true) + { + foreach ($this->notifierList->asArray() as $notifier) { + $notifier->add($severity, $title, $description, $url, $isInternal); + } + return $this; + } + + /** + * Add critical severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addCritical($title, $description, $url = '', $isInternal = true) + { + foreach ($this->notifierList->asArray() as $notifier) { + $notifier->addCritical($title, $description, $url, $isInternal); + } + return $this; + } + + /** + * Add major severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addMajor($title, $description, $url = '', $isInternal = true) + { + foreach ($this->notifierList->asArray() as $notifier) { + $notifier->addMajor($title, $description, $url, $isInternal); + } + return $this; + } + + /** + * Add minor severity message + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addMinor($title, $description, $url = '', $isInternal = true) + { + foreach ($this->notifierList->asArray() as $notifier) { + $notifier->addMinor($title, $description, $url, $isInternal); + } + return $this; + } + + /** + * Add notice + * + * @param string $title + * @param string|string[] $description + * @param string $url + * @param bool $isInternal + * @return $this + */ + public function addNotice($title, $description, $url = '', $isInternal = true) + { + foreach ($this->notifierList->asArray() as $notifier) { + $notifier->addNotice($title, $description, $url, $isInternal); + } + return $this; + } +} diff --git a/lib/internal/Magento/Framework/Oauth/Helper/Request.php b/lib/internal/Magento/Framework/Oauth/Helper/Request.php index 403dceeff52..7b2e5f71bdf 100644 --- a/lib/internal/Magento/Framework/Oauth/Helper/Request.php +++ b/lib/internal/Magento/Framework/Oauth/Helper/Request.php @@ -93,7 +93,9 @@ class Request { $protocolParams = array(); - $this->_processHeader($authHeaderValue, $protocolParams); + if (!$this->_processHeader($authHeaderValue, $protocolParams)) { + return []; + } if ($contentTypeHeader && 0 === strpos($contentTypeHeader, \Zend_Http_Client::ENC_URLENCODED)) { $protocolParamsNotSet = !$protocolParams; @@ -155,7 +157,7 @@ class Request * * @param string $authHeaderValue * @param array &$protocolParams - * @return void + * @return bool true if parameters from oauth headers are processed correctly */ protected function _processHeader($authHeaderValue, &$protocolParams) { @@ -173,7 +175,9 @@ class Request $protocolParams[rawurldecode($nameAndValue[0])] = rawurldecode(trim($nameAndValue[1], '"')); } } + return true; } + return false; } /** diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php new file mode 100644 index 00000000000..b1f6fd1ac5c --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.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\Framework\ObjectManager\Code\Generator; + +/** + * Class Converter + * @package Magento\Framework\ObjectManager\Code\Generator + */ +class Converter extends \Magento\Framework\Code\Generator\EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'converter'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + return [ + [ + 'name' => $this->_getFactoryPropertyName(), + 'visibility' => 'protected', + 'docblock' => [ + 'shortDescription' => $this->_getFactoryPropertyName(), + 'tags' => [ + [ + 'name' => 'var', + 'description' => + $this->_getFactoryClass() + ] + ] + ] + ] + ]; + } + + /** + * Returns factory name + * + * @return string + */ + protected function _getFactoryPropertyName() + { + $parts = explode('\\', $this->_getSourceClassName()); + return lcfirst(end($parts)) . 'Factory'; + } + + /** + * Returns factory class + * + * @return string + */ + protected function _getFactoryClass() + { + return $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Factory'; + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return [ + 'name' => '__construct', + 'parameters' => [ + [ + 'name' => $this->_getFactoryPropertyName(), + 'type' => $this->_getFactoryClass() + ], + ], + 'body' => "\$this->" + . $this->_getFactoryPropertyName() + . " = \$" . $this->_getFactoryPropertyName() . ';', + 'docblock' => [ + 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\\' . $this->_getSourceClassName() + . " \$" . $this->_getFactoryPropertyName() + ] + ] + ] + ]; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + $construct = $this->_getDefaultConstructorDefinition(); + $paramName = 'dataObject'; + $body = 'return $this->' . $this->_getFactoryPropertyName() + . '->create()->setData($' . $paramName .'->__toArray());'; + $getModel = [ + 'name' => 'getModel', + 'parameters' => [ + [ + 'name' => $paramName, + 'type' => '\Magento\Framework\Service\Data\AbstractObject' + ] + ], + 'body' => $body, + 'docblock' => [ + 'shortDescription' => 'Extract data object from model', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Service\Data\AbstractObject $' . $paramName, + ], + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) + ] + ] + ] + ]; + return array($construct, $getModel); + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + if (!parent::_validateData()) { + return false; + } + + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . 'Converter') { + $this->_addError( + 'Invalid Converter class name [' . $resultClassName . ']. Use ' . $sourceClassName . 'Converter' + ); + return false; + } + return true; + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php new file mode 100644 index 00000000000..de3cd6c97bd --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php @@ -0,0 +1,336 @@ +<?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\ObjectManager\Code\Generator; + +/** + * Class Repository + */ +class Repository extends \Magento\Framework\Code\Generator\EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'repository'; + + /** + * No Such Entity Exception + */ + const NO_SUCH_ENTITY_EXCEPTION = '\\Magento\Framework\Exception\NoSuchEntityException'; + const SEARCH_CRITERIA = '\\Magento\Framework\Service\V1\Data\SearchCriteria'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + $properties = [ + [ + 'name' => $this->_getSourceFactoryPropertyName(), + 'visibility' => 'protected', + 'docblock' => [ + 'shortDescription' => $this->_getSourceFactoryPropertyName(), + 'tags' => [ + [ + 'name' => 'var', + 'description' => + $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Factory' + ] + ] + ] + ], + [ + 'name' => $this->_getSourceCollectionFactoryPropertyName(), + 'visibility' => 'protected', + 'docblock' => [ + 'shortDescription' => 'Collection Factory', + 'tags' => [ + [ + 'name' => 'var', + 'description' => + $this->_getCollectionFactoryClassName() + ] + ] + ] + ], + [ + 'name' => 'registry', + 'visibility' => 'protected', + 'defaultValue' => [], + 'docblock' => [ + 'shortDescription' => $this->_getSourceClassName() . '[]', + 'tags' => [ + [ + 'name' => 'var', + 'description' => 'array' + ] + ] + ] + ] + ]; + return $properties; + } + + /** + * Returns source factory property name + * + * @return string + */ + protected function _getSourceFactoryPropertyName() + { + $parts = explode('\\', $this->_getSourceClassName()); + return lcfirst(end($parts)) . 'Factory'; + } + + /** + * Returns source collection factory property name + * @return string + */ + protected function _getSourceCollectionFactoryPropertyName() + { + $parts = explode('\\', $this->_getSourceClassName()); + return lcfirst(end($parts)) . 'CollectionFactory'; + } + + /** + * Returns collection factory class name + * + * @return string + */ + protected function _getCollectionFactoryClassName() + { + $parts = explode('\\', $this->_getSourceClassName()); + $parts = array_reverse($parts); + $className = '\\' . array_pop($parts) . '\\' . array_pop($parts) . '\\' . array_pop($parts) . '\\Resource\\'; + $parts = array_reverse($parts); + return $className . implode('\\', $parts) . '\\CollectionFactory'; + + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return [ + 'name' => '__construct', + 'parameters' => [ + [ + 'name' => $this->_getSourceFactoryPropertyName(), + 'type' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Factory' + ], + [ + 'name' => $this->_getSourceCollectionFactoryPropertyName(), + 'type' => $this->_getCollectionFactoryClassName(), + ], + ], + 'body' => "\$this->" + . $this->_getSourceFactoryPropertyName() + . " = \$" . $this->_getSourceFactoryPropertyName() . ";\n" + . "\$this->" + . $this->_getSourceCollectionFactoryPropertyName() + . " = \$" . $this->_getSourceCollectionFactoryPropertyName() . ";" + , + 'docblock' => [ + 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\\' . $this->_getSourceClassName() + . " \$" . $this->_getSourceFactoryPropertyName() + ], + [ + 'name' => 'param', + 'description' => $this->_getCollectionFactoryClassName() + . " \$" . $this->_getSourceCollectionFactoryPropertyName() + ] + ] + ] + ]; + } + + /** + * Returns get() method + * + * @return string + */ + protected function _getGetMethod() + { + $body = "if (!\$id) {\n" + . " throw new " . self::NO_SUCH_ENTITY_EXCEPTION . "('Requested product doesn\\'t exist');\n" + . "}\n" + . "if (!isset(\$this->registry[\$id])) {\n" + . " \$this->registry[\$id] = \$this->" + . $this->_getSourceFactoryPropertyName() + . "->create()->load(\$id);\n" + . "}\n" + . "return \$this->registry[\$id];"; + return [ + 'name' => 'get', + 'parameters' => [ + [ + 'name' => 'id', + 'type' => 'int' + ] + ], + 'body' => $body, + 'docblock' => [ + 'shortDescription' => 'load entity', + 'tags' => [ + [ + 'name' => 'param', + 'description' => 'int $id' + ], + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()), + ], + [ + 'name' => 'throws', + 'description' => self::NO_SUCH_ENTITY_EXCEPTION, + ] + ] + ] + ]; + } + + /** + * Returns register() method + * + * @return string + */ + protected function _getRegisterMethod() + { + $body = "if (\$object->getId() && !isset(\$this->registry[\$object->getId()])) {\n" + . " \$object->load(\$object->getId());\n" + . " \$this->registry[\$object->getId()] = \$object;\n" + . "}\nreturn \$this;"; + return [ + 'name' => 'register', + 'parameters' => [ + [ + 'name' => 'object', + 'type' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) + ] + ], + 'body' => $body, + 'docblock' => [ + 'shortDescription' => 'Register entity', + 'tags' => [ + [ + 'name' => 'param', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . ' $object' + ], + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getResultClassName()), + ] + ] + ] + ]; + } + + /** + * Returns get() method + * + * @return string + */ + protected function _getFindMethod() + { + $body = "\$collection = \$this->" . $this->_getSourceCollectionFactoryPropertyName() . "->create();\n" + . "foreach(\$criteria->getFilterGroups() as \$filterGroup) {\n" + . " foreach (\$filterGroup->getFilters() as \$filter) {\n" + . " \$condition = \$filter->getConditionType() ? \$filter->getConditionType() : 'eq';\n" + . " \$collection->addFieldToFilter(\$filter->getField(), [\$condition => \$filter->getValue()]);\n" + . " }\n" + . "}\n" + . "foreach (\$collection as \$object) {\n" + . " \$this->register(\$object);\n" + . "}\n" + . "\$objectIds = \$collection->getAllIds();\n" + . "return array_intersect_key(\$this->registry, array_flip(\$objectIds));\n"; + return [ + 'name' => 'find', + 'parameters' => [ + [ + 'name' => 'criteria', + 'type' => self::SEARCH_CRITERIA + ] + ], + 'body' => $body, + 'docblock' => [ + 'shortDescription' => 'Find entities by criteria', + 'tags' => [ + [ + 'name' => 'param', + 'description' => self::SEARCH_CRITERIA . ' $criteria' + ], + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . '[]', + ], + ] + ] + ]; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + return [ + $this->_getDefaultConstructorDefinition(), + $this->_getGetMethod(), + $this->_getRegisterMethod(), + $this->_getFindMethod() + ]; + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . 'Repository') { + $this->_addError( + 'Invalid Factory class name [' . $resultClassName . ']. Use ' . $sourceClassName . 'Repository' + ); + $result = false; + } + } + return $result; + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index 4c9ec38efbf..912c3168469 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -31,6 +31,11 @@ use Magento\Framework\ObjectManager\Definition\Runtime; use Magento\Framework\ObjectManager\Relations; use Magento\Framework\ObjectManager\Code\Generator; use Magento\Framework\Interception\Code\Generator as InterceptionGenerator; +use Magento\Framework\Service\Code\Generator\Builder as BuilderGenerator; +use Magento\Framework\Service\Code\Generator\Mapper as MapperGenerator; +use Magento\Framework\ObjectManager\Code\Generator\Converter as ConverterGenerator; +use Magento\Framework\Service\Code\Generator\SearchResults; +use Magento\Framework\Service\Code\Generator\SearchResultsBuilder; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -121,9 +126,24 @@ class DefinitionFactory $autoloader, $generatorIo, array( - Generator\Factory::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Factory', - Generator\Proxy::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Proxy', - InterceptionGenerator\Interceptor::ENTITY_TYPE => '\Magento\Framework\Interception\Code\Generator\Interceptor' + SearchResultsBuilder::ENTITY_TYPE + => '\Magento\Framework\Service\Code\Generator\SearchResultsBuilder', + Generator\Factory::ENTITY_TYPE + => '\Magento\Framework\ObjectManager\Code\Generator\Factory', + Generator\Proxy::ENTITY_TYPE + => '\Magento\Framework\ObjectManager\Code\Generator\Proxy', + Generator\Repository::ENTITY_TYPE + => '\Magento\Framework\ObjectManager\Code\Generator\Repository', + InterceptionGenerator\Interceptor::ENTITY_TYPE + => '\Magento\Framework\Interception\Code\Generator\Interceptor', + BuilderGenerator::ENTITY_TYPE + => '\Magento\Framework\Service\Code\Generator\Builder', + MapperGenerator::ENTITY_TYPE + => '\Magento\Framework\Service\Code\Generator\Mapper', + SearchResults::ENTITY_TYPE + => '\Magento\Framework\Service\Code\Generator\SearchResults', + ConverterGenerator::ENTITY_TYPE + => '\Magento\Framework\ObjectManager\Code\Generator\Converter', ) ); $autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); diff --git a/lib/internal/Magento/Framework/Search/Request.php b/lib/internal/Magento/Framework/Search/Request.php new file mode 100644 index 00000000000..5bae18e314a --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request.php @@ -0,0 +1,138 @@ +<?php +/** + * Search 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\Framework\Search; + +use Magento\Framework\Search\Request\BucketInterface; +use Magento\Framework\Search\Request\QueryInterface; + +/** + * @codeCoverageIgnore + */ +class Request implements RequestInterface +{ + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $index; + + /** + * @var BucketInterface[] + */ + protected $buckets; + + /** + * Main query which represents the whole query hierarchy + * + * @var QueryInterface + */ + protected $query; + + /** + * @var int|null + */ + protected $from; + + /** + * @var int|null + */ + protected $size; + + /** + * @param string $name + * @param string $indexName + * @param QueryInterface $query + * @param int|null $from + * @param int|null $size + * @param BucketInterface[] $buckets + */ + public function __construct( + $name, + $indexName, + QueryInterface $query, + $from = null, + $size = null, + array $buckets = null + ) { + $this->name = $name; + $this->index = $indexName; + $this->buckets = $buckets; + $this->query = $query; + $this->from = $from; + $this->size = $size; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getIndex() + { + return $this->index; + } + + /** + * {@inheritdoc} + */ + public function getAggregation() + { + return $this->buckets; + } + + /** + * {@inheritdoc} + */ + public function getQuery() + { + return $this->query; + } + + /** + * {@inheritdoc} + */ + public function getFrom() + { + return $this->from; + } + + /** + * {@inheritdoc} + */ + public function getSize() + { + return $this->size; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php new file mode 100644 index 00000000000..705ec8ea551 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php @@ -0,0 +1,72 @@ +<?php +/** + * Range + * + * 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\Aggregation; + +/** + * @SuppressWarnings(PHPMD.ShortVariable) + */ +class Range +{ + /** + * @var int|null + */ + protected $from; + + /** + * @var int|null + */ + protected $to; + + /** + * @param int|null $from + * @param int|null $to + */ + public function __construct($from, $to) + { + $this->from = $from; + $this->to = $to; + } + + /** + * Get From + * + * @return int|null + */ + public function getFrom() + { + return $this->from; + } + + /** + * Get To + * + * @return int|null + */ + public function getTo() + { + return $this->to; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php new file mode 100644 index 00000000000..22028dfe329 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php @@ -0,0 +1,111 @@ +<?php +/** + * Range Buckets + * + * 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\Aggregation; + +use Magento\Framework\Search\Request\BucketInterface; + +class RangeBucket implements BucketInterface +{ + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $field; + + /** + * @var array + */ + protected $metrics; + + /** + * @var Range[] + */ + protected $ranges; + + /** + * @param string $name + * @param string $field + * @param array $metrics + * @param Range[] $ranges + */ + public function __construct($name, $field, array $metrics, array $ranges) + { + $this->name = $name; + $this->field = $field; + $this->metrics = $metrics; + $this->ranges = $ranges; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return BucketInterface::TYPE_RANGE; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * Get Field + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Get Metrics + * + * @return array + */ + public function getMetrics() + { + return $this->metrics; + } + + /** + * Get Ranges + * + * @return Range[] + */ + public function getRanges() + { + return $this->ranges; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php new file mode 100644 index 00000000000..6c4fca13c4d --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php @@ -0,0 +1,94 @@ +<?php +/** + * Term Buckets + * + * 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\Aggregation; + +use Magento\Framework\Search\Request\BucketInterface; + +class TermBucket implements BucketInterface +{ + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $field; + + /** + * @var array + */ + protected $metrics; + + /** + * @param string $name + * @param string $field + * @param array $metrics + */ + public function __construct($name, $field, array $metrics) + { + $this->name = $name; + $this->field = $field; + $this->metrics = $metrics; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return BucketInterface::TYPE_TERM; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * Get Field + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Get Metrics + * + * @return array + */ + public function getMetrics() + { + return $this->metrics; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php new file mode 100644 index 00000000000..8fc0463fe21 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php @@ -0,0 +1,52 @@ +<?php +/** + * Aggregation Bucket Interface + * + * 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; + +interface BucketInterface +{ + /** + * #@+ Bucket Types + */ + const TYPE_TERM = 'term'; + + const TYPE_RANGE = 'range'; + + /**#@-*/ + + /** + * Get Type + * + * @return string + */ + public function getType(); + + /** + * Get Name + * + * @return string + */ + public function getName(); +} diff --git a/lib/internal/Magento/Framework/Search/Request/Config.php b/lib/internal/Magento/Framework/Search/Request/Config.php new file mode 100644 index 00000000000..1bf6a976e66 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Config.php @@ -0,0 +1,40 @@ +<?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 Config extends \Magento\Framework\Config\Data +{ + /** + * @param \Magento\Framework\Config\ReaderInterface $reader + * @param \Magento\Framework\Config\CacheInterface $cache + * @param string $cacheId + */ + public function __construct( + \Magento\Framework\Config\ReaderInterface $reader, + \Magento\Framework\Config\CacheInterface $cache, + $cacheId = 'request_declaration' + ) { + parent::__construct($reader, $cache, $cacheId); + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php new file mode 100644 index 00000000000..87bd3895fbe --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php @@ -0,0 +1,106 @@ +<?php +/** + * Search Request xml converter + * 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\Config; + +class Converter implements \Magento\Framework\Config\ConverterInterface +{ + /** + * Convert config + * + * @param \DOMDocument $source + * @return array + */ + public function convert($source) + { + /** @var \DOMNodeList $requestNodes */ + $requestNodes = $source->getElementsByTagName('request'); + $requests = []; + foreach ($requestNodes as $requestNode) { + $simpleXmlNode = simplexml_import_dom($requestNode); + /** @var \DOMElement $requestNode */ + $name = $requestNode->getAttribute('query'); + $request = $this->mergeAttributes((array)$simpleXmlNode); + $request['queries'] = $this->convertNodes($simpleXmlNode->queries, 'name'); + $request['filters'] = $this->convertNodes($simpleXmlNode->filters, 'name'); + //$request['aggregation'] = $this->convertNodes($simpleXmlNode->aggregation, 'name'); + $requests[$name] = $request; + } + return $requests; + } + + /** + * Merge attributes in node data + * + * @param array $data + * @return array + */ + protected function mergeAttributes($data) + { + if (isset($data['@attributes'])) { + $data = array_merge($data, $data['@attributes']); + unset($data['@attributes']); + } + return $data; + } + + /** + * Deep converting simlexml element to array + * + * @param \SimpleXMLElement $node + * @return array + */ + protected function convertToArray(\SimpleXMLElement $node) + { + return $this->mergeAttributes(json_decode(json_encode($node), true)); + } + + /** + * Convert nodes to array + * + * @param \SimpleXMLElement $nodes + * @param string $name + * @return array + */ + protected function convertNodes(\SimpleXMLElement $nodes, $name) + { + $list = []; + /** @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); + } + } + $type = (string)$node->attributes('xsi', true)['type']; + if (!empty($type)) { + $element['type'] = $type; + } + + $list[$element[$name]] = $element; + } + return $list; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php new file mode 100644 index 00000000000..f76772e36be --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php @@ -0,0 +1,49 @@ +<?php +/** + * Search Request schema locator + * + * 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\Config; + +class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface +{ + /** + * Get path to merged config schema + * + * @return string + */ + public function getSchema() + { + return realpath(__DIR__ . '/../../etc/search_request_merged.xsd'); + } + + /** + * Get path to pre file validation schema + * + * @return null + */ + public function getPerFileSchema() + { + return realpath(__DIR__ . '/../../etc/search_request.xsd'); + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php new file mode 100644 index 00000000000..b83fdf3df44 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php @@ -0,0 +1,116 @@ +<?php +/** + * Bool Filter + * 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\Filter; + +use Magento\Framework\Search\Request\FilterInterface; + +class Bool implements FilterInterface +{ + /** + * @var string + */ + protected $name; + + /** + * Filter names to which result set MUST satisfy + * + * @var array + */ + protected $must = array(); + + /** + * Filter names to which result set SHOULD satisfy + * + * @var array + */ + protected $should = array(); + + /** + * Filter names to which result set MUST NOT satisfy + * + * @var array + */ + protected $mustNot = array(); + + /** + * @param string $name + * @param array $must + * @param array $should + * @param array $not + */ + public function __construct($name, array $must = [], array $should = [], array $not = []) + { + $this->name = $name; + $this->must = $must; + $this->should = $should; + $this->mustNot = $not; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return FilterInterface::TYPE_BOOL; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * Get Must filters + * + * @return array + */ + public function getMust() + { + return $this->must; + } + + /** + * Get Should filters + * + * @return array + */ + public function getShould() + { + return $this->should; + } + + /** + * Get Must Not filters + * + * @return array + */ + public function getMustNot() + { + return $this->mustNot; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Range.php b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php new file mode 100644 index 00000000000..db64a3894f8 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php @@ -0,0 +1,114 @@ +<?php +/** + * Range Filter + * + * 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\Filter; + +use Magento\Framework\Search\Request\FilterInterface; + +/** + * @SuppressWarnings(PHPMD.ShortVariable) + */ +class Range implements FilterInterface +{ + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $field; + + /** + * @var int + */ + protected $from; + + /** + * @var int + */ + protected $to; + + /** + * @param string $name + * @param string $field + * @param int $from + * @param int $to + */ + public function __construct($name, $field, $from, $to) + { + $this->name = $name; + $this->field = $field; + $this->from = $from; + $this->to = $to; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return FilterInterface::TYPE_RANGE; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * Get Field + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Get From + * + * @return int + */ + public function getFrom() + { + return $this->from; + } + + /** + * Get To + * + * @return int + */ + public function getTo() + { + return $this->to; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Term.php b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php new file mode 100644 index 00000000000..1ee1e062838 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php @@ -0,0 +1,94 @@ +<?php +/** + * Term Filter + * + * 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\Filter; + +use Magento\Framework\Search\Request\FilterInterface; + +class Term implements FilterInterface +{ + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $field; + + /** + * @var string + */ + protected $value; + + /** + * @param string $name + * @param string $field + * @param string $value + */ + public function __construct($name, $field, $value) + { + $this->name = $name; + $this->field = $field; + $this->value = $value; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return FilterInterface::TYPE_TERM; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * Get Field + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Get Value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/FilterInterface.php b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php new file mode 100644 index 00000000000..4f7df883ff3 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php @@ -0,0 +1,54 @@ +<?php +/** + * Filter Interface + * + * 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; + +interface FilterInterface +{ + /** + * #@+ Filter Types + */ + const TYPE_TERM = 'termFilter'; + + const TYPE_BOOL = 'boolFilter'; + + const TYPE_RANGE = 'rangeFilter'; + + /**#@-*/ + + /** + * Get Type + * + * @return string + */ + public function getType(); + + /** + * Get Name + * + * @return string + */ + public function getName(); +} diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php new file mode 100644 index 00000000000..a54a217ce80 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.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\Framework\Search\Request; + +use Magento\Framework\Search\Request\Query\Filter; + +class Mapper +{ + /** + * @var array + */ + private $queries; + + /** + * @var array + */ + private $filters; + + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + * @param array $queries + * @param array $filters + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + array $queries, + array $filters = null + ) { + $this->objectManager = $objectManager; + $this->queries = $queries; + $this->filters = $filters; + } + + /** + * Get Query Interface by name + * + * @param string $queryName + * @return QueryInterface + */ + public function get($queryName) + { + return $this->mapQuery($queryName); + } + + /** + * Convert array to Query instance + * + * @param string $queryName + * @throws \Exception + * @return QueryInterface + */ + private function mapQuery($queryName) + { + if (!isset($this->queries[$queryName])) { + throw new \Exception('Query ' . $queryName . ' does not exist'); + } + $query = $this->queries[$queryName]; + switch ($query['type']) { + case QueryInterface::TYPE_MATCH: + $query = $this->objectManager->create( + 'Magento\Framework\Search\Request\Query\Match', + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'matches' => $query['match'] + ] + ); + break; + case QueryInterface::TYPE_FILTER: + if (isset($query['queryReference'][0])) { + $reference = $this->mapQuery($query['queryReference'][0]['ref']); + $referenceType = Filter::REFERENCE_QUERY; + } elseif (isset($query['filterReference'][0])) { + $reference = $this->mapFilter($query['filterReference'][0]['ref']); + $referenceType = Filter::REFERENCE_FILTER; + } else { + throw new \Exception('Reference is not provided'); + } + $query = $this->objectManager->create( + 'Magento\Framework\Search\Request\Query\Filter', + [ + 'name' => $query['name'], + 'boost' => isset($query['boost']) ? $query['boost'] : 1, + 'reference' => $reference, + 'referenceType' => $referenceType + ] + ); + break; + case QueryInterface::TYPE_BOOL: + $aggregatedByType = $this->aggregateQueriesByType($query['queryReference']); + $query = $this->objectManager->create( + 'Magento\Framework\Search\Request\Query\Bool', + array_merge( + ['name' => $query['name'], 'boost' => isset($query['boost']) ? $query['boost'] : 1], + $aggregatedByType + ) + ); + break; + default: + throw new \InvalidArgumentException('Invalid query type'); + } + return $query; + } + + /** + * Aggregate Queries by clause + * + * @param array $data + * @return array + */ + private function aggregateQueriesByType($data) + { + $list = []; + foreach ($data as $value) { + $list[$value['clause']][$value['ref']] = $this->mapQuery($value['ref']); + } + return $list; + } + + /** + * Aggregate Filters by clause + * + * @param array $data + * @return array + */ + private function aggregateFiltersByType($data) + { + $list = []; + foreach ($data as $value) { + $list[$value['clause']][$value['ref']] = $this->mapFilter($value['ref']); + } + return $list; + } + + /** + * Convert array to Filter instance + * + * @param string $filterName + * @throws \Exception + * @return FilterInterface + */ + private function mapFilter($filterName) + { + if (!isset($this->filters[$filterName])) { + throw new \Exception('Filter ' . $filterName . ' does not exist'); + } + $filter = $this->filters[$filterName]; + switch ($filter['type']) { + case FilterInterface::TYPE_TERM: + $filter = $this->objectManager->create( + 'Magento\Framework\Search\Request\Filter\Term', + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'value' => $filter['value'] + ] + ); + break; + case FilterInterface::TYPE_RANGE: + $filter = $this->objectManager->create( + 'Magento\Framework\Search\Request\Filter\Range', + [ + 'name' => $filter['name'], + 'field' => $filter['field'], + 'from' => $filter['from'], + 'to' => $filter['to'] + ] + ); + + break; + case FilterInterface::TYPE_BOOL: + $aggregatedByType = $this->aggregateFiltersByType($filter['filterReference']); + $filter = $this->objectManager->create( + 'Magento\Framework\Search\Request\Filter\Bool', + array_merge( + ['name' => $filter['name']], + $aggregatedByType + ) + ); + break; + default: + throw new \InvalidArgumentException('Invalid filter type'); + } + return $filter; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Bool.php b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php new file mode 100644 index 00000000000..186c96acf9b --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php @@ -0,0 +1,135 @@ +<?php +/** + * Bool Query + * 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\Query; + +use Magento\Framework\Search\Request\QueryInterface; + +class Bool implements QueryInterface +{ + /** + * Boost + * + * @var int|null + */ + protected $boost; + + /** + * Query Name + * + * @var string + */ + protected $name; + + /** + * Query names to which result set SHOULD satisfy + * + * @var array + */ + protected $should = array(); + + /** + * Query names to which result set MUST satisfy + * + * @var array + */ + protected $must = array(); + + /** + * Query names to which result set MUST NOT satisfy + * + * @var array + */ + protected $mustNot = array(); + + /** + * @param string $name + * @param int|null $boost + * @param array $must + * @param array $should + * @param array $not + */ + public function __construct($name, $boost, array $must = [], array $should = [], array $not = []) + { + $this->name = $name; + $this->boost = $boost; + $this->must = $must; + $this->should = $should; + $this->mustNot = $not; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return QueryInterface::TYPE_BOOL; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getBoost() + { + return $this->boost; + } + + /** + * Get Should queries + * + * @return array + */ + public function getShould() + { + return $this->should; + } + + /** + * Get Must queries + * + * @return array + */ + public function getMust() + { + return $this->must; + } + + /** + * Get Must Not queries + * + * @return array + */ + public function getMustNot() + { + return $this->mustNot; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Filter.php b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php new file mode 100644 index 00000000000..480daadb74b --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php @@ -0,0 +1,124 @@ +<?php +/** + * Term Query + * + * 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\Query; + +use Magento\Framework\Search\Request\QueryInterface; + +class Filter implements QueryInterface +{ + /** + * #@+ Reference Types + */ + const REFERENCE_QUERY = 'query'; + + const REFERENCE_FILTER = 'filter'; + + /**#@-*/ + + /** + * @var string + */ + protected $name; + + /** + * Boost + * + * @var int|null + */ + protected $boost; + + /** + * Reference Type + * + * @var string + */ + protected $referenceType; + + /** + * Reference Name + * + * @var string + */ + protected $reference; + + /** + * @param string $name + * @param int|null $boost + * @param string $referenceType + * @param string $reference + */ + public function __construct($name, $boost, $referenceType, $reference) + { + $this->name = $name; + $this->boost = $boost; + $this->referenceType = $referenceType; + $this->reference = $reference; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return QueryInterface::TYPE_FILTER; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getBoost() + { + return $this->boost; + } + + /** + * Get Reference + * + * @return mixed + */ + public function getReference() + { + return $this->reference; + } + + /** + * Get Reference Type + * + * @return string + */ + public function getReferenceType() + { + return $this->referenceType; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Match.php b/lib/internal/Magento/Framework/Search/Request/Query/Match.php new file mode 100644 index 00000000000..da0d3df4849 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/Query/Match.php @@ -0,0 +1,101 @@ +<?php +/** + * Match Query + * + * 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\Query; + +use Magento\Framework\Search\Request\QueryInterface; + +class Match implements QueryInterface +{ + /** + * @var string + */ + protected $name; + + /** + * Boost + * + * @var int|null + */ + protected $boost; + + /** + * Match query array + * Possible structure: + * array( + * ['field' => 'some_field', 'value' => 'some_value', 'boost' => 'some_boost'], + * ['field' => 'some_field', 'value' => 'some_value', 'boost' => 'some_boost'], + * ) + * + * @var array + */ + protected $matches = array(); + + /** + * @param string $name + * @param int|null $boost + * @param array $matches + */ + public function __construct($name, $boost, array $matches) + { + $this->name = $name; + $this->boost = $boost; + $this->matches = $matches; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return QueryInterface::TYPE_MATCH; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getBoost() + { + return $this->boost; + } + + /** + * Get Matches + * + * @return array + */ + public function getMatches() + { + return $this->matches; + } +} diff --git a/lib/internal/Magento/Framework/Search/Request/QueryInterface.php b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php new file mode 100644 index 00000000000..8b709d05717 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php @@ -0,0 +1,61 @@ +<?php +/** + * Query Interface + * + * 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; + +interface QueryInterface +{ + /** + * #@+ Query Types + */ + const TYPE_MATCH = 'matchQuery'; + + const TYPE_BOOL = 'boolQuery'; + + const TYPE_FILTER = 'filteredQuery'; + + /**#@-*/ + + /** + * Get Type + * + * @return string + */ + public function getType(); + + /** + * Get Name + * + * @return string + */ + public function getName(); + + /** + * Get Boost + * + * @return int|null + */ + public function getBoost(); +} diff --git a/lib/internal/Magento/Framework/Search/RequestFactory.php b/lib/internal/Magento/Framework/Search/RequestFactory.php new file mode 100644 index 00000000000..38db68f9dbe --- /dev/null +++ b/lib/internal/Magento/Framework/Search/RequestFactory.php @@ -0,0 +1,119 @@ +<?php +/** + * Search Request Pool + * 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 RequestFactory +{ + const CACHE_PREFIX = 'search_request::'; + + /** + * @var Request\Config + */ + private $config; + + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + /** + * Request Pool constructor + * + * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Framework\Search\Request\Config $config + */ + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\Search\Request\Config $config + ) { + $this->objectManager = $objectManager; + $this->config = $config; + } + + /** + * Create Request instance with specified parameters + * + * @param string $requestName + * @param array $bindValues + * @return \Magento\Framework\Search\Request + * @throws \InvalidArgumentException + */ + public function create($requestName, array $bindValues = array()) + { + $data = $this->config->get($requestName); + if (is_null($data)) { + throw new \InvalidArgumentException("Request name '{$requestName}' doesn't exist."); + } + $data = $this->replaceBinds((array)$data, array_keys($bindValues), array_values($bindValues)); + return $this->convert($data); + } + + /** + * @param string|array $data + * @param string[] $bindKeys + * @param string[] $bindValues + * @return string|array + */ + private function replaceBinds($data, $bindKeys, $bindValues) + { + if (is_scalar($data)) { + return str_replace($bindKeys, $bindValues, $data); + } else { + foreach ($data as $key => $value) { + $data[$key] = $this->replaceBinds($value, $bindKeys, $bindValues); + } + return $data; + } + } + + /** + * Convert array to Request instance + * + * @param array $data + * @return \Magento\Framework\Search\Request + */ + private function convert($data) + { + $mapper = $this->objectManager->create( + 'Magento\Framework\Search\Request\Mapper', + [ + 'objectManager' => $this->objectManager, + 'queries' => $data['queries'], + 'filters' => $data['filters'] + ] + ); + return $this->objectManager->create( + 'Magento\Framework\Search\Request', + [ + 'name' => $data['query'], + 'indexName' => $data['index'], + 'from' => $data['from'], + 'size' => $data['size'], + 'query' => $mapper->get($data['query']), + 'buckets' => [], + ] + ); + } +} diff --git a/lib/internal/Magento/Framework/Search/RequestInterface.php b/lib/internal/Magento/Framework/Search/RequestInterface.php new file mode 100644 index 00000000000..b249646af65 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/RequestInterface.php @@ -0,0 +1,75 @@ +<?php +/** + * Search 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\Framework\Search; + +use Magento\Framework\Search\Request\FilterInterface; +use Magento\Framework\Search\Request\BucketInterface; +use Magento\Framework\Search\Request\QueryInterface; + +interface RequestInterface +{ + /** + * Get Name + * + * @return string + */ + public function getName(); + + /** + * Get Index name + * + * @return string + */ + public function getIndex(); + + /** + * Get Aggregation Buckets + * + * @return BucketInterface[] + */ + public function getAggregation(); + + /** + * Get Main Request Query + * + * @return QueryInterface + */ + public function getQuery(); + + /** + * Get From + * + * @return int|null + */ + public function getFrom(); + + /** + * Get Size + * + * @return int|null + */ + public function getSize(); +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php b/lib/internal/Magento/Framework/Search/Response.php similarity index 88% rename from dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php rename to lib/internal/Magento/Framework/Search/Response.php index 3a0973e8500..d9bd14fbb4d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/Stub.php +++ b/lib/internal/Magento/Framework/Search/Response.php @@ -1,5 +1,7 @@ <?php /** + * Search Response + * * Magento * * NOTICE OF LICENSE @@ -21,8 +23,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\Catalog\Model\Resource\Product\Option; +namespace Magento\Framework\Search; -class Stub extends \Magento\Framework\Model\AbstractModel +class Response implements ResponseInterface { } diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Grouped.php b/lib/internal/Magento/Framework/Search/ResponseInterface.php similarity index 86% rename from app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Grouped.php rename to lib/internal/Magento/Framework/Search/ResponseInterface.php index feda0988b48..9b058362b33 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Grouped.php +++ b/lib/internal/Magento/Framework/Search/ResponseInterface.php @@ -1,6 +1,6 @@ <?php /** - * Export entity of grouped product type + * Search Request * * Magento * @@ -23,8 +23,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\CatalogImportExport\Model\Export\Product\Type; +namespace Magento\Framework\Search; -class Grouped extends AbstractType +interface ResponseInterface { } diff --git a/dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test/UserLocatorStub.php b/lib/internal/Magento/Framework/Search/SearchEngine.php similarity index 75% rename from dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test/UserLocatorStub.php rename to lib/internal/Magento/Framework/Search/SearchEngine.php index 080f7a7e051..7a738edf64f 100644 --- a/dev/tests/integration/testsuite/Magento/Authz/Service/AuthorizationV1Test/UserLocatorStub.php +++ b/lib/internal/Magento/Framework/Search/SearchEngine.php @@ -1,5 +1,7 @@ <?php /** + * Search Engine + * * Magento * * NOTICE OF LICENSE @@ -21,25 +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\Authz\Service\AuthorizationV1Test; - -use Magento\Authz\Model\UserLocatorInterface; +namespace Magento\Framework\Search; -class UserLocatorStub implements UserLocatorInterface +class SearchEngine implements SearchEngineInterface { /** * {@inheritdoc} + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function getUserId() - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function getUserType() + public function search(RequestInterface $request) { - return ''; } } diff --git a/lib/internal/Magento/Framework/Search/SearchEngineInterface.php b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php new file mode 100644 index 00000000000..aab97f19941 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Search Engine interface + * + * 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; + +interface SearchEngineInterface +{ + /** + * Process Search Request + * + * @param RequestInterface $request + * @return ResponseInterface + */ + public function search(RequestInterface $request); +} diff --git a/lib/internal/Magento/Framework/Search/etc/requests.xsd b/lib/internal/Magento/Framework/Search/etc/requests.xsd new file mode 100644 index 00000000000..67d2cfb81dc --- /dev/null +++ b/lib/internal/Magento/Framework/Search/etc/requests.xsd @@ -0,0 +1,276 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> + + <xs:complexType name="request"> + <xs:sequence> + <xs:element type="queries" name="queries" minOccurs="1"> + <xs:key name="queryName"> + <xs:selector xpath="query" /> + <xs:field xpath="@name" /> + </xs:key> + </xs:element> + <xs:element type="filters" name="filters"> + <xs:key name="filterName"> + <xs:selector xpath="filter" /> + <xs:field xpath="@name" /> + </xs:key> + </xs:element> + <xs:element type="aggregation" name="aggregation" > + <xs:key name="aggregationName"> + <xs:selector xpath="bucket" /> + <xs:field xpath="@name" /> + </xs:key> + </xs:element> + <xs:element type="xs:string" name="from" /> + <xs:element type="xs:string" name="size" /> + </xs:sequence> + <xs:attribute type="xs:string" name="query" use="required" /> + <xs:attribute type="xs:string" name="index" use="required" /> + </xs:complexType> + + <xs:attribute name="clause"> + <xs:annotation> + <xs:documentation>Specifies how clauses are to occur in matching documents.</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="must" /> + <xs:enumeration value="should" /> + <xs:enumeration value="not" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + + <!-- Queries Type hierarchy --> + <xs:complexType name="queries"> + <xs:annotation> + <xs:documentation>Definition of queries</xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element type="query" name="query" maxOccurs="unbounded" minOccurs="1" /> + </xs:sequence> + </xs:complexType> + + + <xs:complexType name="query" abstract="true"> + <xs:attribute type="xs:string" name="name" use="required" /> + <xs:attribute type="xs:byte" name="boost" use="optional" default="1" /> + </xs:complexType> + + <xs:complexType name="boolQuery"> + <xs:complexContent> + <xs:extension base="query"> + <xs:sequence> + <xs:element name="queryReference" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="queryReference"> + <xs:attribute ref="clause" use="required" /> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="matchQuery"> + <xs:complexContent> + <xs:extension base="query"> + <xs:sequence> + <xs:element type="match" name="match" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="filteredQuery"> + <xs:complexContent> + <xs:extension base="query"> + <xs:choice minOccurs="1" maxOccurs="1"> + <xs:element type="filterReference" name="filterReference" /> + <xs:element type="queryReference" name="queryReference" /> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + <!-- + Filters Type hierarchy + Example: + <filter xsi:type="termFilter" name="promoted_documents_boost" field="promoted" value="1" /> + <filter xsi:type="rangeFilter" name="price_name" from="10" to="100" /> + <filter xsi:type="boolFilter" name="price_name"> + <filterReference clause="must" name="promoted_documents_filter" /> + </filter + --> + <xs:complexType name="filters"> + <xs:sequence> + <xs:element type="filter" name="filter" maxOccurs="unbounded" minOccurs="0" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="filter" abstract="true"> + <xs:attribute type="xs:string" name="name" use="required" /> + </xs:complexType> + <xs:complexType name="termFilter"> + <xs:complexContent> + <xs:extension base="filter"> + <xs:attribute type="xs:string" name="field" use="required" /> + <xs:attribute type="xs:string" name="value" use="required" /> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="rangeFilter"> + <xs:complexContent> + <xs:extension base="filter"> + <xs:attribute type="xs:string" name="field" use="required" /> + <xs:attribute type="xs:string" name="from" use="required" /> + <xs:attribute type="xs:string" name="to" use="required" /> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="boolFilter"> + <xs:complexContent> + <xs:extension base="filter"> + <xs:sequence> + <xs:element name="filterReference" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="filterReference"> + <xs:attribute ref="clause" use="required" /> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + + <!-- + Buckets Type hierarchy + Example: + <bucket xsi:type="termBucket" name="category_bucket" field="category"> + <bucket xsi:type="rangeBucket" name="price_bucket" field="price"> + --> + <xs:complexType name="bucket" abstract="true"> + <xs:sequence> + <xs:element type="metrics" name="metrics" /> + </xs:sequence> + <xs:attribute type="xs:string" name="name" use="required" /> + <xs:attribute type="xs:string" name="field" use="required" /> + </xs:complexType> + + <xs:complexType name="termBucket"> + <xs:complexContent> + <xs:extension base="bucket"> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="rangeBucket"> + <xs:complexContent> + <xs:extension base="bucket"> + <xs:sequence> + <xs:element type="ranges" name="ranges" minOccurs="1" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="metrics"> + <xs:sequence> + <xs:element type="metric" name="metric" maxOccurs="unbounded" minOccurs="0" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="match"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="field" use="required" /> + <xs:attribute type="xs:string" name="value" use="required" /> + <xs:attribute type="xs:byte" name="boost" use="optional" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="aggregation"> + <xs:choice maxOccurs="unbounded" minOccurs="1"> + <xs:element type="bucket" name="bucket" /> + </xs:choice> + </xs:complexType> + + <xs:complexType name="queryReference"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="ref" use="required" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="filterReference"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="ref" use="required" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="metric"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="type"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="sum" /> + <xs:enumeration value="count" /> + <xs:enumeration value="min" /> + <xs:enumeration value="max" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="ranges"> + <xs:sequence> + <xs:element type="range" name="range" maxOccurs="unbounded" minOccurs="0" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="range"> + <xs:attribute type="xs:string" name="to" use="required" /> + <xs:attribute type="xs:string" name="from" use="required" /> + </xs:complexType> +</xs:schema> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Search/etc/search_request.xsd b/lib/internal/Magento/Framework/Search/etc/search_request.xsd new file mode 100644 index 00000000000..d36bb85bec9 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/etc/search_request.xsd @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> + <xs:include schemaLocation="requests.xsd"/> + + <xs:complexType name="requests"> + <xs:sequence> + <xs:element type="request" name="request" maxOccurs="unbounded"> + <xs:keyref name="queryReference" refer="queryName"> + <xs:selector xpath=".//queryReference"/> + <xs:field xpath="@ref"/> + </xs:keyref> + + <xs:keyref name="filterReference" refer="filterName"> + <xs:selector xpath=".//filterReference"/> + <xs:field xpath="@ref"/> + </xs:keyref> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:element name="requests" type="requests" /> +</xs:schema> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd new file mode 100644 index 00000000000..dfedcfe2742 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> + <xs:include schemaLocation="requests.xsd"/> + <xs:complexType name="requests"> + <xs:sequence> + <xs:element type="request" name="request" maxOccurs="unbounded"> + <xs:keyref name="requestQueryReference" refer="queryName"> + <xs:selector xpath="."/> + <xs:field xpath="@query"/> + </xs:keyref> + <xs:keyref name="queryReference" refer="queryName"> + <xs:selector xpath=".//queryReference"/> + <xs:field xpath="@ref"/> + </xs:keyref> + + <xs:keyref name="filterReference" refer="filterName"> + <xs:selector xpath=".//filterReference"/> + <xs:field xpath="@ref"/> + </xs:keyref> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:element name="requests" type="requests"/> +</xs:schema> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Service/Code/Generator/Builder.php b/lib/internal/Magento/Framework/Service/Code/Generator/Builder.php new file mode 100644 index 00000000000..63cbeb3407b --- /dev/null +++ b/lib/internal/Magento/Framework/Service/Code/Generator/Builder.php @@ -0,0 +1,156 @@ +<?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. + * + * @category Magento + * @package Magento_Code + * @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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\EntityAbstract; +use Zend\Server\Reflection\ReflectionMethod; + +/** + * Class Builder + */ +class Builder extends EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'builder'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + return []; + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return []; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + $methods = []; + $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); + foreach ($publicMethods as $method) { + if (!($method->isConstructor() || + $method->isFinal() || + $method->isStatic() || + $method->isDestructor()) && + !in_array( + $method->getName(), + array('__sleep', '__wakeup', '__clone') + ) + ) { + if (substr($method->getName(), 0, 3) == 'get') { + $methods[] = $this->_getMethodInfo($reflectionClass, $method); + } + + } + } + return $methods; + } + + /** + * Retrieve method info + * + * @param \ReflectionClass $class + * @param \ReflectionMethod $method + * @return array + */ + protected function _getMethodInfo(\ReflectionClass $class, \ReflectionMethod $method) + { + $methodInfo = [ + 'name' => 'set' . substr($method->getName(), 3), + 'parameters' => [ + [ 'name' => lcfirst(substr($method->getName(), 3))] + ], + 'body' => "\$this->_set(" + . '\\' . $class->getName() . "::" + . strtoupper(preg_replace('/(.)([A-Z])/', "$1_$2", substr($method->getName(), 3))) + . ", \$" . lcfirst(substr($method->getName(), 3)) . ");", + 'docblock' => array('shortDescription' => '{@inheritdoc}') + ]; + + return $methodInfo; + } + + /** + * Validate data + * + * @return bool + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . 'Builder') { + $this->_addError( + 'Invalid Builder class name [' . $resultClassName . ']. Use ' . $sourceClassName . 'Builder' + ); + $result = false; + } + } + return $result; + } + + /** + * Generate code + * + * @return string + */ + protected function _generateCode() + { + $this->_classGenerator->setName( + $this->_getResultClassName() + )->addProperties( + $this->_getClassProperties() + )->addMethods( + $this->_getClassMethods() + )->setClassDocBlock( + $this->_getClassDocBlock() + )->setExtendedClass('\\Magento\Framework\Service\Data\AbstractObjectBuilder'); + + return $this->_getGeneratedCode(); + } +} diff --git a/lib/internal/Magento/Framework/Service/Code/Generator/Mapper.php b/lib/internal/Magento/Framework/Service/Code/Generator/Mapper.php new file mode 100644 index 00000000000..c1602fc1e80 --- /dev/null +++ b/lib/internal/Magento/Framework/Service/Code/Generator/Mapper.php @@ -0,0 +1,169 @@ +<?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\Service\Code\Generator; + +/** + * Class Repository + */ +class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'mapper'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + $properties = [ + [ + 'name' => $this->_getSourceBuilderPropertyName(), + 'visibility' => 'protected', + 'docblock' => [ + 'shortDescription' => $this->_getSourceBuilderPropertyName(), + 'tags' => [ + [ + 'name' => 'var', + 'description' => + $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Builder' + ] + ] + ] + ], + [ + 'name' => 'registry', + 'visibility' => 'protected', + 'defaultValue' => [], + 'docblock' => [ + 'shortDescription' => $this->_getSourceClassName() . '[]', + 'tags' => [['name' => 'var', 'description' => 'array']] + ] + ] + ]; + return $properties; + } + + /** + * Returns source factory property Name + * + * @return string + */ + protected function _getSourceBuilderPropertyName() + { + $parts = explode('\\', $this->_getSourceClassName()); + return lcfirst(end($parts)) . 'Builder'; + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return [ + 'name' => '__construct', + 'parameters' => [ + [ + 'name' => $this->_getSourceBuilderPropertyName(), + 'type' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Builder' + ], + ], + 'body' => "\$this->" + . $this->_getSourceBuilderPropertyName() + . " = \$" . $this->_getSourceBuilderPropertyName() . ';', + 'docblock' => [ + 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\\' . $this->_getSourceClassName() + . " \$" . $this->_getSourceBuilderPropertyName() + ] + ] + ] + ]; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + $construct = $this->_getDefaultConstructorDefinition(); + $body = "\$this->" . $this->_getSourceBuilderPropertyName() . "->populateWithArray(\$object->getData());" + . "\nreturn \$this->" . $this->_getSourceBuilderPropertyName() . "->create();"; + $extract = [ + 'name' => 'extractDto', + 'parameters' => [ + [ + 'name' => 'object', + 'type' => '\\Magento\Framework\Model\AbstractModel' + ] + ], + 'body' => $body, + 'docblock' => [ + 'shortDescription' => 'Extract data object from model', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\\Magento\Framework\Model\AbstractModel $object' + ], + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()), + ] + ] + ] + ]; + return [$construct, $extract]; + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . 'Mapper') { + $this->_addError( + 'Invalid Mapper class name [' . $resultClassName . ']. Use ' . $sourceClassName . 'Mapper' + ); + $result = false; + } + } + return $result; + } +} diff --git a/lib/internal/Magento/Framework/Service/Code/Generator/SearchResults.php b/lib/internal/Magento/Framework/Service/Code/Generator/SearchResults.php new file mode 100644 index 00000000000..9b789fcab78 --- /dev/null +++ b/lib/internal/Magento/Framework/Service/Code/Generator/SearchResults.php @@ -0,0 +1,102 @@ +<?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. + * + * @category Magento + * @package Magento_Code + * @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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\EntityAbstract; + +/** + * Class Builder + */ + +class SearchResults extends EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'searchResults'; + + /** + * Search result default class + */ + const SEARCH_RESULT = '\\Magento\Framework\Service\V1\Data\SearchResults'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + return []; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + $getItems = [ + 'name' => 'getItems', + 'parameters' => [], + 'body' => "return parent::getItems();", + 'docblock' => [ + 'shortDescription' => 'Returns array of items', + 'tags' => [ + [ + 'name' => 'return', + 'description' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . '[]', + ] + ] + ] + ]; + return [$getItems]; + } + + /** + * Returns default constructor definition + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return []; + } + + /** + * Generate code + * + * @return string + */ + protected function _generateCode() + { + $this->_classGenerator->setName($this->_getResultClassName()) + ->setExtendedClass(self::SEARCH_RESULT) + ->addMethods($this->_getClassMethods()); + return $this->_getGeneratedCode(); + } +} diff --git a/lib/internal/Magento/Framework/Service/Code/Generator/SearchResultsBuilder.php b/lib/internal/Magento/Framework/Service/Code/Generator/SearchResultsBuilder.php new file mode 100644 index 00000000000..db32f0fbb69 --- /dev/null +++ b/lib/internal/Magento/Framework/Service/Code/Generator/SearchResultsBuilder.php @@ -0,0 +1,139 @@ +<?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. + * + * @category Magento + * @package Magento_Code + * @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\Service\Code\Generator; + +use Magento\Framework\Code\Generator\EntityAbstract; + +/** + * Class Builder + */ +class SearchResultsBuilder extends EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'searchResultsBuilder'; + + /** + * Search result builder abstract class + */ + const SEARCH_RESULT_BUILDER = '\\Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder'; + + /** + * Retrieve class properties + * + * @return array + */ + protected function _getClassProperties() + { + return []; + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + return [ + 'name' => '__construct', + 'parameters' => [ + [ + 'name' => 'objectFactory', + 'type' => '\\Magento\Framework\Service\Data\ObjectFactory' + ], + [ + 'name' => 'searchCriteriaBuilder', + 'type' => '\\Magento\Framework\Service\V1\Data\SearchCriteriaBuilder' + ], + [ + 'name' => 'itemObjectBuilder', + 'type' => $this->_getFullyQualifiedClassName($this->_getSourceClassName()) . 'Builder' + ], + ], + 'body' => "parent::__construct(\$objectFactory, \$searchCriteriaBuilder, \$itemObjectBuilder);", + 'docblock' => [ + 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '' + ] + ] + ] + ]; + } + + /** + * Returns list of methods for class generator + * + * @return array + */ + protected function _getClassMethods() + { + return [$this->_getDefaultConstructorDefinition()]; + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . 'SearchResultsBuilder') { + $this->_addError( + 'Invalid Result class name [' . $resultClassName . ']. Use ' + . $sourceClassName . 'SearchResultsBuilder' + ); + $result = false; + } + } + return $result; + } + + /** + * Generate code + * + * @return string + */ + protected function _generateCode() + { + $this->_classGenerator->setName( + $this->_getResultClassName() + )->addMethods( + $this->_getClassMethods() + )->setClassDocBlock( + $this->_getClassDocBlock() + )->setExtendedClass(self::SEARCH_RESULT_BUILDER); + return $this->_getGeneratedCode(); + } +} diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php index 7470998ee39..4df283272e9 100644 --- a/lib/internal/Magento/Framework/Session/SessionManager.php +++ b/lib/internal/Magento/Framework/Session/SessionManager.php @@ -114,6 +114,9 @@ class SessionManager implements SessionManagerInterface $this->saveHandler = $saveHandler; $this->validator = $validator; $this->storage = $storage; + + // Enable session.use_only_cookies + ini_set('session.use_only_cookies', '1'); } /** @@ -436,15 +439,14 @@ class SessionManager implements SessionManagerInterface /** * Renew session id and update session cookie * - * @param bool $deleteOldSession * @return $this */ - public function regenerateId($deleteOldSession = true) + public function regenerateId() { if (headers_sent()) { return $this; } - session_regenerate_id($deleteOldSession); + session_regenerate_id(true); if ($this->sessionConfig->getUseCookies()) { $this->clearSubDomainSessionCookie(); diff --git a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php index 364e2a48dbb..5a54bf8e8a6 100644 --- a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php +++ b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php @@ -126,10 +126,9 @@ interface SessionManagerInterface /** * Renew session id and update session cookie * - * @param bool $deleteOldSession * @return SessionManagerInterface */ - public function regenerateId($deleteOldSession = true); + public function regenerateId(); /** * Expire the session cookie diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php new file mode 100644 index 00000000000..ad73a649e29 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php @@ -0,0 +1,137 @@ +<?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\Cookie; + +/** + * Class CookieMetadata + * + */ +class CookieMetadata +{ + /**#@+ + * Constant for metadata value key. + */ + const KEY_DOMAIN = 'domain'; + const KEY_PATH = 'path'; + /**#@-*/ + + /** + * Store the metadata in array format to distinguish between null values and no value set. + * + * @var array + */ + private $metadata; + + /** + * @param array $metadata + */ + public function __construct($metadata = []) + { + if (!is_array($metadata)) { + $metadata = []; + } + $this->metadata = $metadata; + } + + /** + * Returns an array representation of this metadata. + * + * If a value has not yet been set then the key will not show up in the array. + * + * @return array + */ + public function __toArray() + { + return $this->metadata; + } + + /** + * Set the domain for the cookie + * + * @param string $domain + * @return $this + */ + public function setDomain($domain) + { + return $this->set(self::KEY_DOMAIN, $domain); + } + + /** + * Get the domain for the cookie + * + * @return string|null + */ + public function getDomain() + { + return $this->get(self::KEY_DOMAIN); + } + + /** + * Set path of the cookie + * + * @param string $path + * @return $this + */ + public function setPath($path) + { + return $this->set(self::KEY_PATH, $path); + } + + /** + * Get the path of the cookie + * + * @return string|null + */ + public function getPath() + { + return $this->get(self::KEY_PATH); + } + + /** + * Get a value from the metadata storage. + * + * @param string $name + * @return int|float|string|bool|null + */ + protected function get($name) + { + if (isset($this->metadata[$name])) { + return $this->metadata[$name]; + } + return null; + } + + /** + * Set a value to the metadata storage. + * + * @param string $name + * @param int|float|string|bool|null $value + * @return $this + */ + protected function set($name, $value) + { + $this->metadata[$name] = $value; + return $this; + } +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php new file mode 100644 index 00000000000..f41a5fdf5f2 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadataFactory.php @@ -0,0 +1,88 @@ +<?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\Cookie; + +use Magento\Framework\ObjectManager; + +/** + * CookieMetadataFactory is used to construct SensitiveCookieMetadata and PublicCookieMetadata objects. + */ +class CookieMetadataFactory +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @param ObjectManager $objectManager + */ + public function __construct(ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Creates a SensitiveCookieMetadata object with the supplied metadata. + * + * @param array $metadata + * @return SensitiveCookieMetadata + */ + public function createSensitiveCookieMetadata($metadata = []) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates a PublicCookieMetadata object with the supplied metadata. + * + * @param array $metadata + * @return PublicCookieMetadata + */ + public function createPublicCookieMetadata($metadata = []) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + ['metadata' => $metadata] + ); + } + + /** + * Creates CookieMetadata object with the supplied metadata. + * + * @param array $metadata + * @return CookieMetadata + */ + public function createCookieMetadata($metadata) + { + return $this->objectManager->create( + 'Magento\Framework\Stdlib\Cookie\CookieMetadata', + ['metadata' => $metadata] + ); + } +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php new file mode 100644 index 00000000000..34640b77f07 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.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\Framework\Stdlib\Cookie; + +/** + * CookieScope is used to store default scope metadata. + */ +class CookieScope +{ + /** + * @var SensitiveCookieMetadata + */ + private $sensitiveCookieMetadata; + + /** + * @var PublicCookieMetadata + */ + private $publicCookieMetadata; + + /** + * @var CookieMetadata + */ + private $cookieMetadata; + + /** + * @var CookieMetadataFactory + */ + private $cookieMetadataFactory; + + + /** + * @param CookieMetadataFactory $cookieMetadataFactory + * @param SensitiveCookieMetadata $sensitiveCookieMetadata + * @param PublicCookieMetadata $publicCookieMetadata + * @param CookieMetadata $deleteCookieMetadata + */ + public function __construct( + CookieMetadataFactory $cookieMetadataFactory, + SensitiveCookieMetadata $sensitiveCookieMetadata = null, + PublicCookieMetadata $publicCookieMetadata = null, + CookieMetadata $deleteCookieMetadata = null + ) { + $this->cookieMetadataFactory = $cookieMetadataFactory; + $this->sensitiveCookieMetadata = $sensitiveCookieMetadata; + $this->publicCookieMetadata = $publicCookieMetadata; + $this->cookieMetadata = $deleteCookieMetadata; + } + + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param SensitiveCookieMetadata|null $override + * @return SensitiveCookieMetadata + */ + public function getSensitiveCookieMetadata(SensitiveCookieMetadata $override = null) + { + if (!is_null($this->sensitiveCookieMetadata)) { + $merged = $this->sensitiveCookieMetadata->__toArray(); + } else { + $merged = []; + } + if (!is_null($override)) { + $merged = array_merge($merged, $override->__toArray()); + } + + return $this->cookieMetadataFactory->createSensitiveCookieMetadata($merged); + } + + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param PublicCookieMetadata|null $override + * @return PublicCookieMetadata + */ + public function getPublicCookieMetadata(PublicCookieMetadata $override = null) + { + if (!is_null($this->publicCookieMetadata)) { + $merged = $this->publicCookieMetadata->__toArray(); + } else { + $merged = []; + } + if (!is_null($override)) { + $merged = array_merge($merged, $override->__toArray()); + } + + return $this->cookieMetadataFactory->createPublicCookieMetadata($merged); + } + + /** + * Merges the input override metadata with any defaults set on this Scope, and then returns a CookieMetadata + * object representing the merged values. + * + * @param CookieMetadata|null $override + * @return CookieMetadata + */ + public function getCookieMetadata(CookieMetadata $override = null) + { + if (!is_null($this->cookieMetadata)) { + $merged = $this->cookieMetadata->__toArray(); + } else { + $merged = []; + } + if (!is_null($override)) { + $merged = array_merge($merged, $override->__toArray()); + } + + return $this->cookieMetadataFactory->createCookieMetadata($merged); + } +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php new file mode 100644 index 00000000000..52150f51ceb --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php @@ -0,0 +1,39 @@ +<?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\Cookie; + +use Magento\Framework\Exception\LocalizedException; + +/** + * CookieSizeLimitReachedException is thrown when detecting that a browser limit, or potential browser limit has been + * reached regarding cookie limits. + * + * Limits can include the amount of data stored in an individual cookie as well as the number of cookies + * set for the domain. + */ +class CookieSizeLimitReachedException extends LocalizedException +{ + +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php new file mode 100644 index 00000000000..a70f38b3399 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php @@ -0,0 +1,36 @@ +<?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\Cookie; + +use Magento\Framework\Exception\LocalizedException; + +/** + * FailureToSendException is thrown when trying to set a cookie but the response has already been sent, making it + * impossible to send any cookie information back to the client. + */ +class FailureToSendException extends LocalizedException +{ + +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php new file mode 100644 index 00000000000..dc5729ccc25 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -0,0 +1,288 @@ +<?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\Cookie; + +use Magento\Framework\Exception\InputException; +use Magento\Framework\Stdlib\CookieManager as CookieManager; + +/** + * CookieManager helps manage the setting, retrieving and deleting of cookies. + * + * To aid in security, the cookie manager will make it possible for the application to indicate if the cookie contains + * sensitive data so that extra protection can be added to the contents of the cookie as well as how the browser + * stores the cookie. + */ +class PhpCookieManager implements CookieManager +{ + /**#@+ + * Constants for Cookie manager. + * RFC 2109 - Page 15 + * http://www.ietf.org/rfc/rfc2109.txt + */ + const MAX_NUM_COOKIES = 20; + const MAX_COOKIE_SIZE = 4096; + const EXPIRE_NOW_TIME = 1; + const EXPIRE_AT_END_OF_SESSION_TIME = 0; + /**#@-*/ + + + /**#@+ + * Constant for metadata array key + */ + const KEY_EXPIRE_TIME = 'expiry'; + /**#@-*/ + + + /** + * @var CookieScope + */ + private $scope; + + /** + * @param CookieScope $scope + */ + public function __construct(CookieScope $scope) + { + $this->scope = $scope; + } + + /** + * Set a value in a private cookie with the given $name $value pairing. + * + * Sensitive cookies cannot be accessed by JS. HttpOnly will always be set to true for these cookies. + * + * @param string $name + * @param string $value + * @param SensitiveCookieMetadata $metadata + * @return void + * @throws FailureToSendException Cookie couldn't be sent to the browser. If this exception isn't thrown, + * there is still no guarantee that the browser received and accepted the cookie. + * @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. + */ + public function setSensitiveCookie($name, $value, SensitiveCookieMetadata $metadata = null) + { + $metadataArray = $this->scope->getSensitiveCookieMetadata($metadata)->__toArray(); + $metadataArray[PublicCookieMetadata::KEY_SECURE] = true; + $metadataArray[PublicCookieMetadata::KEY_HTTP_ONLY] = true; + + $this->setCookie($name, $value, $metadataArray); + } + + /** + * Set a value in a public cookie with the given $name $value pairing. + * + * Public cookies can be accessed by JS. HttpOnly will be set to false by default for these cookies, + * but can be changed to true. + * + * @param string $name + * @param string $value + * @param PublicCookieMetadata $metadata + * @return void + * @throws FailureToSendException If cookie couldn't be sent to the browser. + * @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. + */ + public function setPublicCookie($name, $value, PublicCookieMetadata $metadata = null) + { + $metadataArray = $this->scope->getPublicCookieMetadata($metadata)->__toArray(); + $this->setCookie($name, $value, $metadataArray); + } + + /** + * Set a value in a cookie with the given $name $value pairing. + * + * @param string $name + * @param string $value + * @param array $metadataArray + * @return void + * @throws FailureToSendException If cookie couldn't be sent to the browser. + * @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) + { + $expire = $this->computeExpirationTime($metadataArray); + + $this->checkAbilityToSendCookie($name, $value); + + $phpSetcookieSuccess = setcookie( + $name, + $value, + $expire, + $this->extractValue(CookieMetadata::KEY_PATH, $metadataArray, ''), + $this->extractValue(CookieMetadata::KEY_DOMAIN, $metadataArray, ''), + $this->extractValue(PublicCookieMetadata::KEY_SECURE, $metadataArray, false), + $this->extractValue(PublicCookieMetadata::KEY_HTTP_ONLY, $metadataArray, false) + ); + + if (!$phpSetcookieSuccess) { + + $params['name'] = $name; + if ($value == '') { + throw new FailureToSendException('Unable to delete the cookie with cookieName = %name', $params); + } else { + throw new FailureToSendException('Unable to send the cookie with cookieName = %name', $params); + } + } + } + + /** + * Retrieve the size of a cookie. + * The size of a cookie is determined by the length of 'name=value' portion of the cookie. + * + * @param string $name + * @param string $value + * @return int + */ + private function sizeOfCookie($name, $value) + { + // The constant '1' is the length of the equal sign in 'name=value'. + return strlen($name) + 1 + strlen($value); + } + + /** + * Determines whether or not it is possible to send the cookie, based on the number of cookies that already + * exist and the size of the cookie. + * + * @param string $name + * @param string|null $value + * @return void if it is possible to send the cookie + * @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 checkAbilityToSendCookie($name, $value) + { + if ($name == '' || preg_match("/[=,; \t\r\n\013\014]/", $name)) { + throw new InputException( + 'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014' + ); + } + + $numCookies = count($_COOKIE); + + if (!isset($_COOKIE[$name])) { + $numCookies++; + } + + $sizeOfCookie = $this->sizeOfCookie($name, $value); + + if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) { + throw new CookieSizeLimitReachedException( + 'Unable to send the cookie. Maximum number of cookies would be exceeded.' + ); + } + + if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) { + throw new CookieSizeLimitReachedException( + "Unable to send the cookie. Size of '%name' is %size bytes.", + [ + 'name' => $name, + 'size' => $sizeOfCookie, + ] + ); + } + } + + /** + * Determines the expiration time of a cookie. + * + * @param array $metadataArray + * @return int in seconds since the Unix epoch. + */ + private function computeExpirationTime(array $metadataArray) + { + if (isset($metadataArray[PhpCookieManager::KEY_EXPIRE_TIME]) + && $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME] < time() + ) { + $expireTime = $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME]; + } else { + if (isset($metadataArray[PublicCookieMetadata::KEY_DURATION])) { + $expireTime = $metadataArray[PublicCookieMetadata::KEY_DURATION] + time(); + } else { + $expireTime = PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME; + } + } + + return $expireTime; + } + + /** + * Determines the value to be used as a $parameter. + * If $metadataArray[$parameter] is not set, returns the $defaultValue. + * + * @param string $parameter + * @param array $metadataArray + * @param string|boolean|int|null $defaultValue + * @return string|boolean|int|null + */ + private function extractValue($parameter, array $metadataArray, $defaultValue) + { + if (array_key_exists($parameter, $metadataArray)) { + return $metadataArray[$parameter]; + } else { + return $defaultValue; + } + } + + /** + * Retrieve a value from a cookie. + * + * @param string $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, $default = null) + { + return (isset($_COOKIE[$name])) ? $_COOKIE[$name] : $default; + } + + /** + * Deletes a cookie with the given name. + * + * @param string $name + * @param CookieMetadata $metadata + * @return void + * @throws FailureToSendException If cookie couldn't be sent to the browser. + * If this exception isn't thrown, there is still no guarantee that the browser + * received and accepted the request to delete this cookie. + * @throws InputException If the cookie name is empty or contains invalid characters. + */ + 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. + $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME] = PhpCookieManager::EXPIRE_NOW_TIME; + + $this->checkAbilityToSendCookie($name, ''); + + // cookie value set to empty string to delete from the remote client + $this->setCookie($name, '', $metadataArray); + } +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php new file mode 100644 index 00000000000..ef6089a3f6b --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php @@ -0,0 +1,107 @@ +<?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\Cookie; + +/** + * Class PublicCookieMetadata + * + */ +class PublicCookieMetadata extends CookieMetadata +{ + /**#@+ + * Constant for metadata value key. + */ + const KEY_SECURE = 'secure'; + const KEY_HTTP_ONLY = 'http_only'; + const KEY_DURATION = 'duration'; + /**#@-*/ + + /** + * Set the number of seconds until the cookie expires + * + * The cookie duration can be translated into an expiration date at the time the cookie is sent. + * + * @param int $duration Time in seconds. + * @return $this + */ + public function setDuration($duration) + { + return $this->set(self::KEY_DURATION, $duration); + } + + /** + * Get the number of seconds until the cookie expires + * + * The cookie duration can be translated into an expiration date at the time the cookie is sent. + * + * @return int|null Time in seconds. + */ + public function getDuration() + { + return $this->get(self::KEY_DURATION); + } + + /** + * Set HTTPOnly flag + * + * @param bool $httpOnly + * @return $this + */ + public function setHttpOnly($httpOnly) + { + return $this->set(self::KEY_HTTP_ONLY, $httpOnly); + } + + /** + * Get HTTPOnly flag + * + * @return bool|null + */ + public function getHttpOnly() + { + return $this->get(self::KEY_HTTP_ONLY); + } + + /** + * Set whether the cookie is only available under HTTPS + * + * @param bool $secure + * @return $this + */ + public function setSecure($secure) + { + return $this->set(self::KEY_SECURE, $secure); + } + + /** + * Get whether the cookie is only available under HTTPS + * + * @return bool|null + */ + public function getSecure() + { + return $this->get(self::KEY_SECURE); + } +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php new file mode 100644 index 00000000000..428c4f22b75 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php @@ -0,0 +1,36 @@ +<?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\Cookie; + +/** + * Class SensitiveCookieMetadata + * + * The class has only methods extended from CookieMetadata + * as path and domain are only data to be exposed by SensitiveCookieMetadata + */ +class SensitiveCookieMetadata extends CookieMetadata +{ + +} diff --git a/lib/internal/Magento/Framework/Stdlib/CookieManager.php b/lib/internal/Magento/Framework/Stdlib/CookieManager.php new file mode 100644 index 00000000000..a54c34b3157 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/CookieManager.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\Stdlib; + +use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata; +use Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata; +use Magento\Framework\Stdlib\Cookie\FailureToSendException; +use Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException; +use Magento\Framework\Stdlib\Cookie\CookieMetadata; +use Magento\Framework\Exception\InputException; + +/** + * CookieManager helps manage the setting, retrieving and deleting of cookies. + * + * The cookie manager will make it possible for an application to indicate if a cookie contains sensitive data, + * this will allow extra protection to be added to the contents of the cookie as well sending directives to the browser + * about how the cookie should be stored and whether JavaScript can access the cookie. + */ +interface CookieManager +{ + /** + * Set a value in a private cookie with the given $name $value pairing. + * + * Sensitive cookies cannot be accessed by JS. HttpOnly will always be set to true for these cookies. + * + * @param string $name + * @param string $value + * @param SensitiveCookieMetadata $metadata + * @return void + * @throws FailureToSendException Cookie couldn't be sent to the browser. If this exception isn't thrown, + * there is still no guarantee that the browser received and accepted the cookie. + * @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. + */ + public function setSensitiveCookie($name, $value, SensitiveCookieMetadata $metadata = null); + + /** + * Set a value in a public cookie with the given $name $value pairing. + * + * Public cookies can be accessed by JS. HttpOnly will be set to false by default for these cookies, + * but can be changed to true. + * + * @param string $name + * @param string $value + * @param PublicCookieMetadata $metadata + * @return void + * @throws FailureToSendException If cookie couldn't be sent to the browser. + * @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. + */ + public function setPublicCookie($name, $value, PublicCookieMetadata $metadata = null); + + /** + * Retrieve a value from a cookie. + * + * @param string $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, $default = null); + + + /** + * Deletes a cookie with the given name. + * + * @param string $name + * @param CookieMetadata $metadata + * @return void + * @throws FailureToSendException If cookie couldn't be sent to the browser. + * If this exception isn't thrown, there is still no guarantee that the browser + * received and accepted the request to delete this cookie. + * @throws InputException If the cookie name is empty or contains invalid characters. + */ + public function deleteCookie($name, CookieMetadata $metadata = null); +} diff --git a/lib/internal/Magento/Framework/Validator/ValidatorException.php b/lib/internal/Magento/Framework/Validator/ValidatorException.php index 4434a3a9580..da61cd65ab3 100644 --- a/lib/internal/Magento/Framework/Validator/ValidatorException.php +++ b/lib/internal/Magento/Framework/Validator/ValidatorException.php @@ -25,7 +25,7 @@ */ namespace Magento\Framework\Validator; -class ValidatorException extends \Exception +class ValidatorException extends \Magento\Framework\Exception\InputException { /** * @var array @@ -35,23 +35,32 @@ class ValidatorException extends \Exception /** * Constructor * + * @param string $message + * @param [] $params + * @param \Exception $cause * @param array $messages Validation error messages */ - public function __construct(array $messages = array()) - { - $this->_messages = $messages; - - $message = ''; - foreach ($this->_messages as $propertyMessages) { - foreach ($propertyMessages as $propertyMessage) { - if ($message) { - $message .= PHP_EOL; + public function __construct( + $message = self::DEFAULT_MESSAGE, + $params = [], + \Exception $cause = null, + array $messages = array() + ) { + if (!empty($messages)) { + $this->_messages = $messages; + $message = ''; + foreach ($this->_messages as $propertyMessages) { + foreach ($propertyMessages as $propertyMessage) { + if ($message) { + $message .= PHP_EOL; + } + $message .= $propertyMessage; } - $message .= $propertyMessage; } + } else { + $this->_messages = [$message]; } - - parent::__construct($message); + parent::__construct($message, $params, $cause); } /** diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index 0098ebe4b15..6ad49625459 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -686,11 +686,16 @@ abstract class AbstractBlock extends \Magento\Framework\Object implements BlockI * link/input/container/anything else in template among others. * Function takes an arbitrary amount of parameters. * + * @param string|null $arg1 + * @param string|null $arg2 + * @param string|null $arg3 + * @param string|null $arg4 + * @param string|null $arg5 * @return string */ - public function getUiId() + public function getUiId($arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null) { - return ' data-ui-id="' . call_user_func_array(array($this, 'getJsId'), func_get_args()) . '" '; + return ' data-ui-id="' . $this->getJsId($arg1, $arg2, $arg3, $arg4, $arg5) . '" '; } /** @@ -698,11 +703,32 @@ abstract class AbstractBlock extends \Magento\Framework\Object implements BlockI * * Function takes an arbitrary amount of parameters * + * @param string|null $arg1 + * @param string|null $arg2 + * @param string|null $arg3 + * @param string|null $arg4 + * @param string|null $arg5 * @return string */ - public function getJsId() + public function getJsId($arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null) { - $rawId = $this->_nameInLayout . '-' . implode('-', func_get_args()); + $args = []; + if (!is_null($arg1)) { + $args[] = $arg1; + } + if (!is_null($arg2)) { + $args[] = $arg2; + } + if (!is_null($arg3)) { + $args[] = $arg3; + } + if (!is_null($arg4)) { + $args[] = $arg4; + } + if (!is_null($arg5)) { + $args[] = $arg5; + } + $rawId = $this->_nameInLayout . '-' . implode('-', $args); return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($rawId)), '-'); } diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 9a4f149393c..56b95e3a753 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,9 +2,9 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "require": { - "php": "5.4.*|5.5.*", + "php": "~5.4.11|~5.5.0", "ext-spl": "*", "ext-dom": "*", "ext-simplexml": "*", @@ -13,8 +13,7 @@ "ext-curl": "*", "ext-iconv": "*", "ext-gd": "*", - "lib-libxml": "*", - "magento/magento-composer-installer": "*" + "lib-libxml": "*" }, "suggest": { "ext-imagick": "Use Image Magick >=3.0.0 as an optional alternative image processing library" diff --git a/lib/internal/Zend/Code/Generator/DocBlockGenerator.php b/lib/internal/Zend/Code/Generator/DocBlockGenerator.php index 1473581b7c6..0b506e11e26 100644 --- a/lib/internal/Zend/Code/Generator/DocBlockGenerator.php +++ b/lib/internal/Zend/Code/Generator/DocBlockGenerator.php @@ -69,8 +69,8 @@ class DocBlockGenerator extends AbstractGenerator if ($longDescription !== null) { $this->setLongDescription($longDescription); } - if (is_array($tags) && $tags) { - $this->setTags($tags); + if ($this->tags !== array()) { + $this->setTag($tags); } } diff --git a/lib/internal/Zend/Escaper/composer.json b/lib/internal/Zend/Escaper/composer.json index 7df2296c42d..4aff32b6763 100644 --- a/lib/internal/Zend/Escaper/composer.json +++ b/lib/internal/Zend/Escaper/composer.json @@ -8,7 +8,7 @@ ], "autoload": { "psr-0": { - "Zend\\Escaper": "" + "Zend\\Escaper\\": "" } }, "target-dir": "Zend/Escaper", diff --git a/lib/internal/Zend/I18n/Exception/ExceptionInterface.php b/lib/internal/Zend/I18n/Exception/ExceptionInterface.php index a13a9c0a133..c14266bb0b3 100644 --- a/lib/internal/Zend/I18n/Exception/ExceptionInterface.php +++ b/lib/internal/Zend/I18n/Exception/ExceptionInterface.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ interface ExceptionInterface {} diff --git a/lib/internal/Zend/I18n/Exception/InvalidArgumentException.php b/lib/internal/Zend/I18n/Exception/InvalidArgumentException.php index bdbdf667d95..4389791c006 100644 --- a/lib/internal/Zend/I18n/Exception/InvalidArgumentException.php +++ b/lib/internal/Zend/I18n/Exception/InvalidArgumentException.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface diff --git a/lib/internal/Zend/I18n/Exception/OutOfBoundsException.php b/lib/internal/Zend/I18n/Exception/OutOfBoundsException.php index 8122fc97b6c..53ab98ef1c2 100644 --- a/lib/internal/Zend/I18n/Exception/OutOfBoundsException.php +++ b/lib/internal/Zend/I18n/Exception/OutOfBoundsException.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface diff --git a/lib/internal/Zend/I18n/Exception/ParseException.php b/lib/internal/Zend/I18n/Exception/ParseException.php index 73857be7346..e0fa82a0074 100644 --- a/lib/internal/Zend/I18n/Exception/ParseException.php +++ b/lib/internal/Zend/I18n/Exception/ParseException.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ class ParseException extends RuntimeException implements ExceptionInterface {} diff --git a/lib/internal/Zend/I18n/Exception/RangeException.php b/lib/internal/Zend/I18n/Exception/RangeException.php index a534c972187..7d99da01c64 100644 --- a/lib/internal/Zend/I18n/Exception/RangeException.php +++ b/lib/internal/Zend/I18n/Exception/RangeException.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ class RangeException extends \RangeException implements ExceptionInterface {} diff --git a/lib/internal/Zend/I18n/Exception/RuntimeException.php b/lib/internal/Zend/I18n/Exception/RuntimeException.php index 024d6e55297..4bb5bca8e81 100644 --- a/lib/internal/Zend/I18n/Exception/RuntimeException.php +++ b/lib/internal/Zend/I18n/Exception/RuntimeException.php @@ -13,7 +13,7 @@ namespace Zend\I18n\Exception; /** * @category Zend * @package Zend_I18n - * @subpackage Translator + * @subpackage Exception */ class RuntimeException extends \RuntimeException implements ExceptionInterface {} diff --git a/lib/internal/Zend/I18n/Filter/AbstractLocale.php b/lib/internal/Zend/I18n/Filter/AbstractLocale.php index e74dee77e21..7522546235d 100644 --- a/lib/internal/Zend/I18n/Filter/AbstractLocale.php +++ b/lib/internal/Zend/I18n/Filter/AbstractLocale.php @@ -15,7 +15,8 @@ use Zend\Filter\AbstractFilter; /** * @category Zend - * @package Zend_Filter + * @package Zend_I18n + * @subpackage Filter */ abstract class AbstractLocale extends AbstractFilter { diff --git a/lib/internal/Zend/I18n/Filter/Alnum.php b/lib/internal/Zend/I18n/Filter/Alnum.php index 305e767d6ce..6ec000037b3 100644 --- a/lib/internal/Zend/I18n/Filter/Alnum.php +++ b/lib/internal/Zend/I18n/Filter/Alnum.php @@ -12,11 +12,11 @@ namespace Zend\I18n\Filter; use Locale; use Traversable; -use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Filter + * @package Zend_I18n + * @subpackage Filter */ class Alnum extends AbstractLocale { diff --git a/lib/internal/Zend/I18n/Filter/Alpha.php b/lib/internal/Zend/I18n/Filter/Alpha.php index 8c619305acb..d8929020ffb 100644 --- a/lib/internal/Zend/I18n/Filter/Alpha.php +++ b/lib/internal/Zend/I18n/Filter/Alpha.php @@ -14,7 +14,8 @@ use Locale; /** * @category Zend - * @package Zend_Filter + * @package Zend_I18n + * @subpackage Filter */ class Alpha extends Alnum { diff --git a/lib/internal/Zend/I18n/Filter/NumberFormat.php b/lib/internal/Zend/I18n/Filter/NumberFormat.php index fc26ece3192..594e2159d87 100644 --- a/lib/internal/Zend/I18n/Filter/NumberFormat.php +++ b/lib/internal/Zend/I18n/Filter/NumberFormat.php @@ -15,6 +15,11 @@ use Traversable; use Zend\I18n\Exception; use Zend\Stdlib\ErrorHandler; +/** + * @category Zend + * @package Zend_I18n + * @subpackage Filter + */ class NumberFormat extends AbstractLocale { protected $options = array( diff --git a/lib/internal/Zend/I18n/Translator/TranslatorServiceFactory.php b/lib/internal/Zend/I18n/Translator/TranslatorServiceFactory.php index b2cd93a092e..a6395e745eb 100644 --- a/lib/internal/Zend/I18n/Translator/TranslatorServiceFactory.php +++ b/lib/internal/Zend/I18n/Translator/TranslatorServiceFactory.php @@ -25,7 +25,7 @@ class TranslatorServiceFactory implements FactoryInterface public function createService(ServiceLocatorInterface $serviceLocator) { // Configure the translator - $config = $serviceLocator->get('Configuration'); + $config = $serviceLocator->get('Config'); $trConfig = isset($config['translator']) ? $config['translator'] : array(); $translator = Translator::factory($trConfig); return $translator; diff --git a/lib/internal/Zend/I18n/Validator/Alnum.php b/lib/internal/Zend/I18n/Validator/Alnum.php index ad1dc3d1e1f..1f08ab6ecde 100644 --- a/lib/internal/Zend/I18n/Validator/Alnum.php +++ b/lib/internal/Zend/I18n/Validator/Alnum.php @@ -15,7 +15,8 @@ use Zend\Validator\AbstractValidator; /** * @category Zend - * @package Zend_Validate + * @package Zend_I18n + * @subpackage Validator */ class Alnum extends AbstractValidator { diff --git a/lib/internal/Zend/I18n/Validator/Alpha.php b/lib/internal/Zend/I18n/Validator/Alpha.php index 4dfdd1395f1..53c96adf27b 100644 --- a/lib/internal/Zend/I18n/Validator/Alpha.php +++ b/lib/internal/Zend/I18n/Validator/Alpha.php @@ -11,11 +11,11 @@ namespace Zend\I18n\Validator; use Zend\I18n\Filter\Alpha as AlphaFilter; -use Zend\Validator\AbstractValidator; /** * @category Zend - * @package Zend_Validate + * @package Zend_I18n + * @subpackage Validator */ class Alpha extends Alnum { diff --git a/lib/internal/Zend/I18n/Validator/Float.php b/lib/internal/Zend/I18n/Validator/Float.php index 010a7d8446f..09d70f5a886 100644 --- a/lib/internal/Zend/I18n/Validator/Float.php +++ b/lib/internal/Zend/I18n/Validator/Float.php @@ -19,7 +19,8 @@ use Zend\Validator\Exception; /** * @category Zend - * @package Zend_Validate + * @package Zend_I18n + * @subpackage Validator */ class Float extends AbstractValidator { diff --git a/lib/internal/Zend/I18n/Validator/Int.php b/lib/internal/Zend/I18n/Validator/Int.php index 83a2f91db99..3b7f80a65b2 100644 --- a/lib/internal/Zend/I18n/Validator/Int.php +++ b/lib/internal/Zend/I18n/Validator/Int.php @@ -19,7 +19,8 @@ use Zend\Validator\Exception; /** * @category Zend - * @package Zend_Validate + * @package Zend_I18n + * @subpackage Validator */ class Int extends AbstractValidator { diff --git a/lib/internal/Zend/I18n/Validator/PostCode.php b/lib/internal/Zend/I18n/Validator/PostCode.php index 0f4dfa34e8c..6aad8eafa3d 100644 --- a/lib/internal/Zend/I18n/Validator/PostCode.php +++ b/lib/internal/Zend/I18n/Validator/PostCode.php @@ -19,7 +19,8 @@ use Zend\Validator\Exception; /** * @category Zend - * @package Zend_Validate + * @package Zend_I18n + * @subpackage Validator */ class PostCode extends AbstractValidator { diff --git a/lib/internal/Zend/I18n/View/Helper/AbstractTranslatorHelper.php b/lib/internal/Zend/I18n/View/Helper/AbstractTranslatorHelper.php index f1e9ddb33b4..975d2006d96 100644 --- a/lib/internal/Zend/I18n/View/Helper/AbstractTranslatorHelper.php +++ b/lib/internal/Zend/I18n/View/Helper/AbstractTranslatorHelper.php @@ -16,8 +16,8 @@ use Zend\View\Helper\AbstractHelper; /** * @category Zend - * @package Zend_View - * @subpackage Helper + * @package Zend_I18n + * @subpackage View */ abstract class AbstractTranslatorHelper extends AbstractHelper implements TranslatorAwareInterface diff --git a/lib/internal/Zend/I18n/View/Helper/CurrencyFormat.php b/lib/internal/Zend/I18n/View/Helper/CurrencyFormat.php index 75f7a0949ce..e4ad76f7058 100644 --- a/lib/internal/Zend/I18n/View/Helper/CurrencyFormat.php +++ b/lib/internal/Zend/I18n/View/Helper/CurrencyFormat.php @@ -15,7 +15,7 @@ use NumberFormatter; use Zend\View\Helper\AbstractHelper; /** - * View helper for formatting dates. + * View helper for formatting currency. * * @category Zend * @package Zend_I18n @@ -37,6 +37,13 @@ class CurrencyFormat extends AbstractHelper */ protected $currencyCode; + /** + * If set to true, the currency will be returned with two decimals + * + * @var bool + */ + protected $showDecimals = true; + /** * Formatter instances. * @@ -66,6 +73,28 @@ class CurrencyFormat extends AbstractHelper return $this->currencyCode; } + /** + * Set if the view helper should show two decimals + * + * @param bool $showDecimals + * @return CurrencyFormat + */ + public function setShouldShowDecimals($showDecimals) + { + $this->showDecimals = (bool) $showDecimals; + return $this; + } + + /** + * Get if the view helper should show two decimals + * + * @return bool + */ + public function shouldShowDecimals() + { + return $this->showDecimals; + } + /** * Set locale to use instead of the default. * @@ -97,12 +126,14 @@ class CurrencyFormat extends AbstractHelper * * @param float $number * @param string $currencyCode + * @param bool $showDecimals * @param string $locale * @return string */ public function __invoke( $number, $currencyCode = null, + $showDecimals = null, $locale = null ) { if (null === $locale) { @@ -111,6 +142,9 @@ class CurrencyFormat extends AbstractHelper if (null === $currencyCode) { $currencyCode = $this->getCurrencyCode(); } + if (null !== $showDecimals) { + $this->setShouldShowDecimals($showDecimals); + } $formatterId = md5($locale); @@ -121,6 +155,12 @@ class CurrencyFormat extends AbstractHelper ); } + if ($this->shouldShowDecimals()) { + $this->formatters[$formatterId]->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); + } else { + $this->formatters[$formatterId]->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); + } + return $this->formatters[$formatterId]->formatCurrency( $number, $currencyCode ); diff --git a/lib/internal/Zend/I18n/composer.json b/lib/internal/Zend/I18n/composer.json index c93238275c7..09aa2c98ce5 100644 --- a/lib/internal/Zend/I18n/composer.json +++ b/lib/internal/Zend/I18n/composer.json @@ -8,13 +8,14 @@ ], "autoload": { "psr-0": { - "Zend\\I18n": "" + "Zend\\I18n\\": "" } }, "target-dir": "Zend/I18n", "require": { "php": ">=5.3.3", "ext-intl": "*", + "zendframework/zend-filter": "self.version", "zendframework/zend-stdlib": "self.version" } } diff --git a/lib/internal/Zend/Server/composer.json b/lib/internal/Zend/Server/composer.json index 69400a24eb7..51dbdf540fe 100644 --- a/lib/internal/Zend/Server/composer.json +++ b/lib/internal/Zend/Server/composer.json @@ -8,7 +8,7 @@ ], "autoload": { "psr-0": { - "Zend\\Server": "" + "Zend\\Server\\": "" } }, "target-dir": "Zend/Server", diff --git a/lib/internal/Zend/ServiceManager/AbstractFactoryInterface.php b/lib/internal/Zend/ServiceManager/AbstractFactoryInterface.php new file mode 100644 index 00000000000..6bf8a972044 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/AbstractFactoryInterface.php @@ -0,0 +1,38 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface AbstractFactoryInterface +{ + /** + * Determine if we can create a service with name + * + * @param ServiceLocatorInterface $serviceLocator + * @param $name + * @param $requestedName + * @return bool + */ + public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName); + + /** + * Create service with name + * + * @param ServiceLocatorInterface $serviceLocator + * @param $name + * @param $requestedName + * @return mixed + */ + public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName); +} diff --git a/lib/internal/Zend/ServiceManager/AbstractPluginManager.php b/lib/internal/Zend/ServiceManager/AbstractPluginManager.php new file mode 100644 index 00000000000..61704d45189 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/AbstractPluginManager.php @@ -0,0 +1,222 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * ServiceManager implementation for managing plugins + * + * Automatically registers an initializer which should be used to verify that + * a plugin instance is of a valid type. Additionally, allows plugins to accept + * an array of options for the constructor, which can be used to configure + * the plugin when retrieved. Finally, enables the allowOverride property by + * default to allow registering factories, aliases, and invokables to take + * the place of those provided by the implementing class. + * + * @category Zend + * @package Zend_ServiceManager + */ +abstract class AbstractPluginManager extends ServiceManager implements ServiceLocatorAwareInterface +{ + /** + * Allow overriding by default + * + * @var bool + */ + protected $allowOverride = true; + + /** + * Whether or not to auto-add a class as an invokable class if it exists + * + * @var bool + */ + protected $autoAddInvokableClass = true; + + /** + * Options to use when creating an instance + * + * @var mixed + */ + protected $creationOptions = null; + + /** + * The main service locator + * + * @var ServiceLocatorInterface + */ + protected $serviceLocator; + + /** + * Constructor + * + * Add a default initializer to ensure the plugin is valid after instance + * creation. + * + * @param null|ConfigInterface $configuration + */ + public function __construct(ConfigInterface $configuration = null) + { + parent::__construct($configuration); + $self = $this; + $this->addInitializer(function ($instance) use ($self) { + if ($instance instanceof ServiceLocatorAwareInterface) { + $instance->setServiceLocator($self); + } + if ($instance instanceof ServiceManagerAwareInterface) { + $instance->setServiceManager($self); + } + }); + } + + /** + * Validate the plugin + * + * Checks that the filter loaded is either a valid callback or an instance + * of FilterInterface. + * + * @param mixed $plugin + * @return void + * @throws Exception\RuntimeException if invalid + */ + abstract public function validatePlugin($plugin); + + /** + * Retrieve a service from the manager by name + * + * Allows passing an array of options to use when creating the instance. + * createFromInvokable() will use these and pass them to the instance + * constructor if not null and a non-empty array. + * + * @param string $name + * @param array $options + * @param bool $usePeeringServiceManagers + * @return object + */ + public function get($name, $options = array(), $usePeeringServiceManagers = true) + { + // Allow specifying a class name directly; registers as an invokable class + if (!$this->has($name) && $this->autoAddInvokableClass && class_exists($name)) { + $this->setInvokableClass($name, $name); + } + + $this->creationOptions = $options; + $instance = parent::get($name, $usePeeringServiceManagers); + $this->creationOptions = null; + $this->validatePlugin($instance); + return $instance; + } + + /** + * Register a service with the locator. + * + * Validates that the service object via validatePlugin() prior to + * attempting to register it. + * + * @param string $name + * @param mixed $service + * @param bool $shared + * @return AbstractPluginManager + * @throws Exception\InvalidServiceNameException + */ + public function setService($name, $service, $shared = true) + { + if ($service) { + $this->validatePlugin($service); + } + parent::setService($name, $service, $shared); + return $this; + } + + /** + * Set the main service locator so factories can have access to it to pull deps + * + * @param ServiceLocatorInterface $serviceLocator + * @return AbstractPluginManager + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + return $this; + } + + /** + * Get the main plugin manager. Useful for fetching dependencies from within factories. + * + * @return mixed + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } + + /** + * Attempt to create an instance via an invokable class + * + * Overrides parent implementation by passing $creationOptions to the + * constructor, if non-null. + * + * @param string $canonicalName + * @param string $requestedName + * @return null|\stdClass + * @throws Exception\ServiceNotCreatedException If resolved class does not exist + */ + protected function createFromInvokable($canonicalName, $requestedName) + { + $invokable = $this->invokableClasses[$canonicalName]; + + if (null === $this->creationOptions + || (is_array($this->creationOptions) && empty($this->creationOptions)) + ) { + $instance = new $invokable(); + } else { + $instance = new $invokable($this->creationOptions); + } + + return $instance; + } + + /** + * Attempt to create an instance via a factory class + * + * Overrides parent implementation by passing $creationOptions to the + * constructor, if non-null. + * + * @param string $canonicalName + * @param string $requestedName + * @return mixed + * @throws Exception\ServiceNotCreatedException If factory is not callable + */ + protected function createFromFactory($canonicalName, $requestedName) + { + $factory = $this->factories[$canonicalName]; + if (is_string($factory) && class_exists($factory, true)) { + if (null === $this->creationOptions || (is_array($this->creationOptions) && empty($this->creationOptions))) { + $factory = new $factory(); + } else { + $factory = new $factory($this->creationOptions); + } + + $this->factories[$canonicalName] = $factory; + } + + if ($factory instanceof FactoryInterface) { + $instance = $this->createServiceViaCallback(array($factory, 'createService'), $canonicalName, $requestedName); + } elseif (is_callable($factory)) { + $instance = $this->createServiceViaCallback($factory, $canonicalName, $requestedName); + } else { + throw new Exception\ServiceNotCreatedException(sprintf( + 'While attempting to create %s%s an invalid factory was registered for this instance type.', $canonicalName, ($requestedName ? '(alias: ' . $requestedName . ')' : '') + )); + } + + return $instance; + } + +} diff --git a/lib/internal/Zend/ServiceManager/Config.php b/lib/internal/Zend/ServiceManager/Config.php new file mode 100644 index 00000000000..3ce022ebe09 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Config.php @@ -0,0 +1,155 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +class Config implements ConfigInterface +{ + /** + * @var array + */ + protected $config = array(); + + /** + * Constructor + * + * @param array $config + */ + public function __construct($config = array()) + { + $this->config = $config; + } + + /** + * Get allow override + * + * @return null|bool + */ + public function getAllowOverride() + { + return (isset($this->config['allow_override'])) ? $this->config['allow_override'] : null; + } + + /** + * Get factories + * + * @return array + */ + public function getFactories() + { + return (isset($this->config['factories'])) ? $this->config['factories'] : array(); + } + + /** + * Get abstract factories + * + * @return array + */ + public function getAbstractFactories() + { + return (isset($this->config['abstract_factories'])) ? $this->config['abstract_factories'] : array(); + } + + /** + * Get invokables + * + * @return array + */ + public function getInvokables() + { + return (isset($this->config['invokables'])) ? $this->config['invokables'] : array(); + } + + /** + * Get services + * + * @return array + */ + public function getServices() + { + return (isset($this->config['services'])) ? $this->config['services'] : array(); + } + + /** + * Get aliases + * + * @return array + */ + public function getAliases() + { + return (isset($this->config['aliases'])) ? $this->config['aliases'] : array(); + } + + /** + * Get initializers + * + * @return array + */ + public function getInitializers() + { + return (isset($this->config['initializers'])) ? $this->config['initializers'] : array(); + } + + /** + * Get shared + * + * @return array + */ + public function getShared() + { + return (isset($this->config['shared'])) ? $this->config['shared'] : array(); + } + + /** + * Configure service manager + * + * @param ServiceManager $serviceManager + * @return void + */ + public function configureServiceManager(ServiceManager $serviceManager) + { + if (($allowOverride = $this->getAllowOverride()) !== null) { + $serviceManager->setAllowOverride($allowOverride); + } + + foreach ($this->getFactories() as $name => $factory) { + $serviceManager->setFactory($name, $factory); + } + + foreach ($this->getAbstractFactories() as $factory) { + $serviceManager->addAbstractFactory($factory); + } + + foreach ($this->getInvokables() as $name => $invokable) { + $serviceManager->setInvokableClass($name, $invokable); + } + + foreach ($this->getServices() as $name => $service) { + $serviceManager->setService($name, $service); + } + + foreach ($this->getAliases() as $alias => $nameOrAlias) { + $serviceManager->setAlias($alias, $nameOrAlias); + } + + foreach ($this->getInitializers() as $initializer) { + $serviceManager->addInitializer($initializer); + } + + foreach ($this->getShared() as $name => $isShared) { + $serviceManager->setShared($name, $isShared); + } + } + +} diff --git a/lib/internal/Zend/ServiceManager/ConfigInterface.php b/lib/internal/Zend/ServiceManager/ConfigInterface.php new file mode 100644 index 00000000000..ddbf22d5fcb --- /dev/null +++ b/lib/internal/Zend/ServiceManager/ConfigInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface ConfigInterface +{ + /** + * Configure service manager + * + * @param ServiceManager $serviceManager + * @return void + */ + public function configureServiceManager(ServiceManager $serviceManager); +} diff --git a/lib/internal/Zend/ServiceManager/Di/DiAbstractServiceFactory.php b/lib/internal/Zend/ServiceManager/Di/DiAbstractServiceFactory.php new file mode 100644 index 00000000000..c6e23697408 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Di/DiAbstractServiceFactory.php @@ -0,0 +1,62 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Di; + +use Zend\Di\Di; +use Zend\ServiceManager\AbstractFactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class DiAbstractServiceFactory extends DiServiceFactory implements AbstractFactoryInterface +{ + /** + * Constructor + * + * @param \Zend\Di\Di $di + * @param null|string|\Zend\Di\InstanceManager $useServiceLocator + */ + public function __construct(Di $di, $useServiceLocator = self::USE_SL_NONE) + { + $this->di = $di; + if (in_array($useServiceLocator, array(self::USE_SL_BEFORE_DI, self::USE_SL_AFTER_DI, self::USE_SL_NONE))) { + $this->useServiceLocator = $useServiceLocator; + } + + // since we are using this in a proxy-fashion, localize state + $this->definitions = $this->di->definitions; + $this->instanceManager = $this->di->instanceManager; + } + + /** + * {@inheritDoc} + */ + public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $serviceName, $requestedName) + { + $this->serviceLocator = $serviceLocator; + if ($requestedName) { + return $this->get($requestedName, array(), true); + } else { + return $this->get($serviceName, array(), true); + } + + } + + /** + * {@inheritDoc} + */ + public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + return $this->instanceManager->hasSharedInstance($requestedName) + || $this->instanceManager->hasAlias($requestedName) + || $this->instanceManager->hasConfig($requestedName) + || $this->instanceManager->hasTypePreferences($requestedName) + || $this->definitions->hasClass($requestedName); + } +} diff --git a/lib/internal/Zend/ServiceManager/Di/DiInstanceManagerProxy.php b/lib/internal/Zend/ServiceManager/Di/DiInstanceManagerProxy.php new file mode 100644 index 00000000000..b94b64e8406 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Di/DiInstanceManagerProxy.php @@ -0,0 +1,72 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Di; + +use Zend\Di\InstanceManager as DiInstanceManager; +use Zend\ServiceManager\ServiceLocatorInterface; + +class DiInstanceManagerProxy extends DiInstanceManager +{ + /** + * @var DiInstanceManager + */ + protected $diInstanceManager = null; + + /** + * @var ServiceLocatorInterface + */ + protected $serviceLocator = null; + + /** + * Constructor + * + * @param DiInstanceManager $diInstanceManager + * @param ServiceLocatorInterface $serviceLocator + */ + public function __construct(DiInstanceManager $diInstanceManager, ServiceLocatorInterface $serviceLocator) + { + $this->diInstanceManager = $diInstanceManager; + $this->serviceLocator = $serviceLocator; + + // localize state + $this->aliases = &$diInstanceManager->aliases; + $this->sharedInstances = &$diInstanceManager->sharedInstances; + $this->sharedInstancesWithParams = &$diInstanceManager->sharedInstancesWithParams; + $this->configurations = &$diInstanceManager->configurations; + $this->typePreferences = &$diInstanceManager->typePreferences; + } + + /** + * Determine if we have a shared instance by class or alias + * + * @param $classOrAlias + * @return bool + */ + public function hasSharedInstance($classOrAlias) + { + return ($this->serviceLocator->has($classOrAlias) || $this->diInstanceManager->hasSharedInstance($classOrAlias)); + } + + /** + * Get shared instance + * + * @param $classOrAlias + * @return mixed + */ + public function getSharedInstance($classOrAlias) + { + if ($this->serviceLocator->has($classOrAlias)) { + return $this->serviceLocator->get($classOrAlias); + } else { + return $this->diInstanceManager->getSharedInstance($classOrAlias); + } + } +} diff --git a/lib/internal/Zend/ServiceManager/Di/DiServiceFactory.php b/lib/internal/Zend/ServiceManager/Di/DiServiceFactory.php new file mode 100644 index 00000000000..1443321cf9c --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Di/DiServiceFactory.php @@ -0,0 +1,124 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Di; + +use Zend\Di\Di; +use Zend\Di\Exception\ClassNotFoundException as DiClassNotFoundException; +use Zend\ServiceManager\Exception; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class DiServiceFactory extends Di implements FactoryInterface +{ + /**@#+ + * constants + */ + const USE_SL_BEFORE_DI = 'before'; + const USE_SL_AFTER_DI = 'after'; + const USE_SL_NONE = 'none'; + /**@#-*/ + + /** + * @var \Zend\Di\Di + */ + protected $di = null; + + /** + * @var \Zend\Di\InstanceManager + */ + protected $name = null; + + /** + * @var array + */ + protected $parameters = array(); + + /** + * @var string + */ + protected $useServiceLocator = self::USE_SL_AFTER_DI; + + /** + * @var ServiceLocatorInterface + */ + protected $serviceLocator = null; + + /** + * Constructor + * + * @param \Zend\Di\Di $di + * @param null|\Zend\Di\InstanceManager $name + * @param array $parameters + * @param string $useServiceLocator + */ + public function __construct(Di $di, $name, array $parameters = array(), $useServiceLocator = self::USE_SL_NONE) + { + $this->di = $di; + $this->name = $name; + $this->parameters = $parameters; + if (in_array($useServiceLocator, array(self::USE_SL_BEFORE_DI, self::USE_SL_AFTER_DI, self::USE_SL_NONE))) { + $this->useServiceLocator = $useServiceLocator; + } + + // since we are using this in a proxy-fashion, localize state + $this->definitions = $this->di->definitions; + $this->instanceManager = $this->di->instanceManager; + } + + /** + * Create service + * + * @param ServiceLocatorInterface $serviceLocator + * @return object + */ + public function createService(ServiceLocatorInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + return $this->get($this->name, $this->parameters, true); + } + + /** + * Override, as we want it to use the functionality defined in the proxy + * + * @param string $name + * @param array $params + * @return object + * @throws Exception\ServiceNotFoundException + */ + public function get($name, array $params = array()) + { + // allow this di service to get dependencies from the service locator BEFORE trying di + if ($this->useServiceLocator == self::USE_SL_BEFORE_DI && $this->serviceLocator->has($name)) { + return $this->serviceLocator->get($name); + } + + try { + + $service = parent::get($name, $params); + return $service; + + } catch (DiClassNotFoundException $e) { + + // allow this di service to get dependencies from the service locator AFTER trying di + if ($this->useServiceLocator == self::USE_SL_AFTER_DI && $this->serviceLocator->has($name)) { + return $this->serviceLocator->get($name); + } else { + throw new Exception\ServiceNotFoundException( + sprintf('Service %s was not found in this DI instance', $name), + null, + $e + ); + } + } + + } + +} diff --git a/lib/internal/Zend/ServiceManager/Di/DiServiceInitializer.php b/lib/internal/Zend/ServiceManager/Di/DiServiceInitializer.php new file mode 100644 index 00000000000..ac6e4cae1f7 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Di/DiServiceInitializer.php @@ -0,0 +1,69 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Di; + +use Zend\Di\Di; +use Zend\ServiceManager\Exception; +use Zend\ServiceManager\InitializerInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class DiServiceInitializer extends Di implements InitializerInterface +{ + /** + * @var Di + */ + protected $di = null; + + /** + * @var DiInstanceManagerProxy + */ + protected $diInstanceManagerProxy = null; + + /** + * @var ServiceLocatorInterface + */ + protected $serviceLocator = null; + + /** + * Constructor + * + * @param \Zend\Di\Di $di + * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator + * @param null|DiInstanceManagerProxy $diImProxy + */ + public function __construct(Di $di, ServiceLocatorInterface $serviceLocator, DiInstanceManagerProxy $diImProxy = null) + { + $this->di = $di; + $this->serviceLocator = $serviceLocator; + $this->diInstanceManagerProxy = ($diImProxy) ?: new DiInstanceManagerProxy($di->instanceManager(), $serviceLocator); + } + + /** + * Initialize + * + * @param $instance + * @param ServiceLocatorInterface $serviceLocator + * @throws \Exception + */ + public function initialize($instance, ServiceLocatorInterface $serviceLocator) + { + $instanceManager = $this->di->instanceManager; + $this->di->instanceManager = $this->diInstanceManagerProxy; + try { + $this->di->injectDependencies($instance); + $this->di->instanceManager = $instanceManager; + } catch (\Exception $e) { + $this->di->instanceManager = $instanceManager; + throw $e; + } + } + +} diff --git a/lib/internal/Zend/ServiceManager/Exception/CircularDependencyFoundException.php b/lib/internal/Zend/ServiceManager/Exception/CircularDependencyFoundException.php new file mode 100644 index 00000000000..081474d0460 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/CircularDependencyFoundException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class CircularDependencyFoundException extends RuntimeException +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/ExceptionInterface.php b/lib/internal/Zend/ServiceManager/Exception/ExceptionInterface.php new file mode 100644 index 00000000000..091a8a5c389 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/ExceptionInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +interface ExceptionInterface +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/InvalidArgumentException.php b/lib/internal/Zend/ServiceManager/Exception/InvalidArgumentException.php new file mode 100644 index 00000000000..89c06233459 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/InvalidArgumentException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/InvalidServiceNameException.php b/lib/internal/Zend/ServiceManager/Exception/InvalidServiceNameException.php new file mode 100644 index 00000000000..5ef91655d87 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/InvalidServiceNameException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class InvalidServiceNameException extends RuntimeException +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/RuntimeException.php b/lib/internal/Zend/ServiceManager/Exception/RuntimeException.php new file mode 100644 index 00000000000..ee9046bea7c --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/RuntimeException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class RuntimeException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/ServiceNotCreatedException.php b/lib/internal/Zend/ServiceManager/Exception/ServiceNotCreatedException.php new file mode 100644 index 00000000000..92cfd6085da --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/ServiceNotCreatedException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class ServiceNotCreatedException extends RuntimeException +{ +} diff --git a/lib/internal/Zend/ServiceManager/Exception/ServiceNotFoundException.php b/lib/internal/Zend/ServiceManager/Exception/ServiceNotFoundException.php new file mode 100644 index 00000000000..98854470fc2 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/Exception/ServiceNotFoundException.php @@ -0,0 +1,20 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager\Exception; + +/** + * @category Zend + * @package Zend_ServiceManager + * @subpackage Exception + */ +class ServiceNotFoundException extends InvalidArgumentException +{ +} diff --git a/lib/internal/Zend/ServiceManager/FactoryInterface.php b/lib/internal/Zend/ServiceManager/FactoryInterface.php new file mode 100644 index 00000000000..97b15c624c1 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/FactoryInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface FactoryInterface +{ + /** + * Create service + * + * @param ServiceLocatorInterface $serviceLocator + * @return mixed + */ + public function createService(ServiceLocatorInterface $serviceLocator); +} diff --git a/lib/internal/Zend/ServiceManager/InitializerInterface.php b/lib/internal/Zend/ServiceManager/InitializerInterface.php new file mode 100644 index 00000000000..0de46cc70b3 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/InitializerInterface.php @@ -0,0 +1,29 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface InitializerInterface +{ + /** + * Initialize + * + * @param $instance + * @param ServiceLocatorInterface $serviceLocator + * @return mixed + */ + public function initialize($instance, ServiceLocatorInterface $serviceLocator); +} diff --git a/lib/internal/Zend/ServiceManager/ServiceLocatorAwareInterface.php b/lib/internal/Zend/ServiceManager/ServiceLocatorAwareInterface.php new file mode 100644 index 00000000000..39422f3bd5a --- /dev/null +++ b/lib/internal/Zend/ServiceManager/ServiceLocatorAwareInterface.php @@ -0,0 +1,32 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface ServiceLocatorAwareInterface +{ + /** + * Set service locator + * + * @param ServiceLocatorInterface $serviceLocator + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator); + + /** + * Get service locator + * + * @return ServiceLocatorInterface + */ + public function getServiceLocator(); +} diff --git a/lib/internal/Zend/ServiceManager/ServiceLocatorInterface.php b/lib/internal/Zend/ServiceManager/ServiceLocatorInterface.php new file mode 100644 index 00000000000..539ce305441 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/ServiceLocatorInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * Service locator interface + * + * @category Zend + * @package Zend_ServiceManager + */ +interface ServiceLocatorInterface +{ + /** + * Retrieve a registered instance + * + * @param string $name + * @throws Exception\ServiceNotFoundException + * @return object|array + */ + public function get($name); + + /** + * Check for a registered instance + * + * @param string|array $name + * @return bool + */ + public function has($name); +} diff --git a/lib/internal/Zend/ServiceManager/ServiceManager.php b/lib/internal/Zend/ServiceManager/ServiceManager.php new file mode 100644 index 00000000000..6dfe797b74d --- /dev/null +++ b/lib/internal/Zend/ServiceManager/ServiceManager.php @@ -0,0 +1,960 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +use Closure; +use ReflectionClass; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +class ServiceManager implements ServiceLocatorInterface +{ + + /**@#+ + * Constants + */ + const SCOPE_PARENT = 'parent'; + const SCOPE_CHILD = 'child'; + /**@#-*/ + + /** + * Lookup for canonicalized names. + * + * @var array + */ + protected $canonicalNames = array(); + + /** + * @var bool + */ + protected $allowOverride = false; + + /** + * @var array + */ + protected $invokableClasses = array(); + + /** + * @var string|callable|Closure|FactoryInterface[] + */ + protected $factories = array(); + + /** + * @var AbstractFactoryInterface[] + */ + protected $abstractFactories = array(); + + /** + * @var array + */ + protected $pendingAbstractFactoryRequests = array(); + + /** + * @var array + */ + protected $shared = array(); + + /** + * Registered services and cached values + * + * @var array + */ + protected $instances = array(); + + /** + * @var array + */ + protected $aliases = array(); + + /** + * @var array + */ + protected $initializers = array(); + + /** + * @var ServiceManager[] + */ + protected $peeringServiceManagers = array(); + + /** + * Whether or not to share by default + * + * @var bool + */ + protected $shareByDefault = true; + + /** + * @var bool + */ + protected $retrieveFromPeeringManagerFirst = false; + + /** + * @var bool Track whether not to throw exceptions during create() + */ + protected $throwExceptionInCreate = true; + + /** + * @var array map of characters to be replaced through strtr + */ + protected $canonicalNamesReplacements = array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''); + + /** + * Constructor + * + * @param ConfigInterface $config + */ + public function __construct(ConfigInterface $config = null) + { + if ($config) { + $config->configureServiceManager($this); + } + } + + /** + * Set allow override + * + * @param $allowOverride + * @return ServiceManager + */ + public function setAllowOverride($allowOverride) + { + $this->allowOverride = (bool) $allowOverride; + return $this; + } + + /** + * Get allow override + * + * @return bool + */ + public function getAllowOverride() + { + return $this->allowOverride; + } + + /** + * Set flag indicating whether services are shared by default + * + * @param bool $shareByDefault + * @return ServiceManager + * @throws Exception\RuntimeException if allowOverride is false + */ + public function setShareByDefault($shareByDefault) + { + if ($this->allowOverride === false) { + throw new Exception\RuntimeException(sprintf( + '%s: cannot alter default shared service setting; container is marked immutable (allow_override is false)', + __METHOD__ + )); + } + $this->shareByDefault = (bool) $shareByDefault; + return $this; + } + + /** + * Are services shared by default? + * + * @return bool + */ + public function shareByDefault() + { + return $this->shareByDefault; + } + + /** + * Set throw exceptions in create + * + * @param bool $throwExceptionInCreate + * @return ServiceManager + */ + public function setThrowExceptionInCreate($throwExceptionInCreate) + { + $this->throwExceptionInCreate = $throwExceptionInCreate; + return $this; + } + + /** + * Get throw exceptions in create + * + * @return bool + */ + public function getThrowExceptionInCreate() + { + return $this->throwExceptionInCreate; + } + + /** + * Set flag indicating whether to pull from peering manager before attempting creation + * + * @param bool $retrieveFromPeeringManagerFirst + * @return ServiceManager + */ + public function setRetrieveFromPeeringManagerFirst($retrieveFromPeeringManagerFirst = true) + { + $this->retrieveFromPeeringManagerFirst = (bool) $retrieveFromPeeringManagerFirst; + return $this; + } + + /** + * Should we retrieve from the peering manager prior to attempting to create a service? + * + * @return bool + */ + public function retrieveFromPeeringManagerFirst() + { + return $this->retrieveFromPeeringManagerFirst; + } + + /** + * Set invokable class + * + * @param string $name + * @param string $invokableClass + * @param bool $shared + * @return ServiceManager + * @throws Exception\InvalidServiceNameException + */ + public function setInvokableClass($name, $invokableClass, $shared = true) + { + $cName = $this->canonicalizeName($name); + $rName = $name; + + if ($this->has(array($cName, $rName), false)) { + if ($this->allowOverride === false) { + throw new Exception\InvalidServiceNameException(sprintf( + 'A service by the name or alias "%s" already exists and cannot be overridden; please use an alternate name', + $cName + )); + } + $this->unregisterService($cName); + } + + $this->invokableClasses[$cName] = $invokableClass; + $this->shared[$cName] = (bool) $shared; + + return $this; + } + + /** + * Set factory + * + * @param string $name + * @param string|FactoryInterface|callable $factory + * @param bool $shared + * @return ServiceManager + * @throws Exception\InvalidArgumentException + * @throws Exception\InvalidServiceNameException + */ + public function setFactory($name, $factory, $shared = true) + { + $cName = $this->canonicalizeName($name); + $rName = $name; + + if (!is_string($factory) && !$factory instanceof FactoryInterface && !is_callable($factory)) { + throw new Exception\InvalidArgumentException( + 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' + ); + } + + if ($this->has(array($cName, $rName), false)) { + if ($this->allowOverride === false) { + throw new Exception\InvalidServiceNameException(sprintf( + 'A service by the name or alias "%s" already exists and cannot be overridden, please use an alternate name', + $cName + )); + } + $this->unregisterService($cName); + } + + $this->factories[$cName] = $factory; + $this->shared[$cName] = (bool) $shared; + + return $this; + } + + /** + * Add abstract factory + * + * @param AbstractFactoryInterface|string $factory + * @param bool $topOfStack + * @return ServiceManager + * @throws Exception\InvalidArgumentException if the abstract factory is invalid + */ + public function addAbstractFactory($factory, $topOfStack = true) + { + if (!is_string($factory) && !$factory instanceof AbstractFactoryInterface) { + throw new Exception\InvalidArgumentException( + 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' + ); + } + if (is_string($factory)) { + if (!class_exists($factory, true)) { + throw new Exception\InvalidArgumentException( + 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' + ); + } + $refl = new ReflectionClass($factory); + if (!$refl->implementsInterface(__NAMESPACE__ . '\\AbstractFactoryInterface')) { + throw new Exception\InvalidArgumentException( + 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' + ); + } + } + + if ($topOfStack) { + array_unshift($this->abstractFactories, $factory); + } else { + array_push($this->abstractFactories, $factory); + } + return $this; + } + + /** + * Add initializer + * + * @param callable|InitializerInterface $initializer + * @param bool $topOfStack + * @return ServiceManager + * @throws Exception\InvalidArgumentException + */ + public function addInitializer($initializer, $topOfStack = true) + { + if (!is_callable($initializer) && !$initializer instanceof InitializerInterface) { + if (!is_string($initializer) + || !$this->isSubclassOf($initializer, __NAMESPACE__ . '\InitializerInterface') + ) { + throw new Exception\InvalidArgumentException('$initializer should be callable.'); + } + $initializer = new $initializer; + } + + if ($topOfStack) { + array_unshift($this->initializers, $initializer); + } else { + array_push($this->initializers, $initializer); + } + return $this; + } + + /** + * Register a service with the locator + * + * @param string $name + * @param mixed $service + * @param bool $shared + * @return ServiceManager + * @throws Exception\InvalidServiceNameException + */ + public function setService($name, $service, $shared = true) + { + $cName = $this->canonicalizeName($name); + + if ($this->has($cName, false)) { + if ($this->allowOverride === false) { + throw new Exception\InvalidServiceNameException(sprintf( + '%s: A service by the name "%s" or alias already exists and cannot be overridden, please use an alternate name.', + __METHOD__, + $name + )); + } + $this->unregisterService($cName); + } + + $this->instances[$cName] = $service; + $this->shared[$cName] = (bool) $shared; + return $this; + } + + /** + * @param string $name + * @param bool $isShared + * @return ServiceManager + * @throws Exception\ServiceNotFoundException + */ + public function setShared($name, $isShared) + { + $cName = $this->canonicalizeName($name); + + if ( + !isset($this->invokableClasses[$cName]) + && !isset($this->factories[$cName]) + && !$this->canCreateFromAbstractFactory($cName, $name) + ) { + throw new Exception\ServiceNotFoundException(sprintf( + '%s: A service by the name "%s" was not found and could not be marked as shared', + __METHOD__, + $name + )); + } + + $this->shared[$cName] = (bool) $isShared; + return $this; + } + + /** + * Retrieve a registered instance + * + * @param string $name + * @param bool $usePeeringServiceManagers + * @throws Exception\ServiceNotFoundException + * @return object|array + */ + public function get($name, $usePeeringServiceManagers = true) + { + $cName = $this->canonicalizeName($name); + $rName = $name; + + if ($this->hasAlias($cName)) { + do { + $cName = $this->aliases[$cName]; + } while ($this->hasAlias($cName)); + + if (!$this->has(array($cName, $rName))) { + throw new Exception\ServiceNotFoundException(sprintf( + 'An alias "%s" was requested but no service could be found.', + $name + )); + } + } + + if (isset($this->instances[$cName])) { + return $this->instances[$cName]; + } + + $instance = null; + $retrieveFromPeeringManagerFirst = $this->retrieveFromPeeringManagerFirst(); + + if ($usePeeringServiceManagers && $retrieveFromPeeringManagerFirst) { + $instance = $this->retrieveFromPeeringManager($name); + } + if (!$instance) { + if ($this->canCreate(array($cName, $rName))) { + $instance = $this->create(array($cName, $rName)); + } elseif ($usePeeringServiceManagers && !$retrieveFromPeeringManagerFirst) { + $instance = $this->retrieveFromPeeringManager($name); + } + } + + // Still no instance? raise an exception + if (!$instance && !is_array($instance)) { + throw new Exception\ServiceNotFoundException(sprintf( + '%s was unable to fetch or create an instance for %s', + __METHOD__, + $name + ) + ); + } + + if ($this->shareByDefault() && (!isset($this->shared[$cName]) || $this->shared[$cName] === true) + ) { + $this->instances[$cName] = $instance; + } + + return $instance; + } + + /** + * Create an instance + * + * @param string|array $name + * @return false|object + * @throws Exception\ServiceNotFoundException + * @throws Exception\ServiceNotCreatedException + */ + public function create($name) + { + $instance = false; + + if (is_array($name)) { + list($cName, $rName) = $name; + } else { + $rName = $name; + $cName = $this->canonicalizeName($rName); + } + + + if (isset($this->factories[$cName])) { + $instance = $this->createFromFactory($cName, $rName); + } + + if (!$instance && isset($this->invokableClasses[$cName])) { + $instance = $this->createFromInvokable($cName, $rName); + } + + if (!$instance && $this->canCreateFromAbstractFactory($cName, $rName)) { + $instance = $this->createFromAbstractFactory($cName, $rName); + } + + if ($this->throwExceptionInCreate == true && $instance === false) { + throw new Exception\ServiceNotFoundException(sprintf( + 'No valid instance was found for %s%s', + $cName, + ($rName ? '(alias: ' . $rName . ')' : '') + )); + } + + foreach ($this->initializers as $initializer) { + if ($initializer instanceof InitializerInterface) { + $initializer->initialize($instance, $this); + } elseif (is_object($initializer) && is_callable($initializer)) { + $initializer($instance, $this); + } else { + call_user_func($initializer, $instance, $this); + } + } + + return $instance; + } + + /** + * Determine if we can create an instance. + * + * @param string|array $name + * @param bool $checkAbstractFactories + * @return bool + */ + public function canCreate($name, $checkAbstractFactories = true) + { + if (is_array($name)) { + list($cName, $rName) = $name; + } else { + $rName = $name; + $cName = $this->canonicalizeName($rName); + } + + if ( + isset($this->invokableClasses[$cName]) + || isset($this->factories[$cName]) + || isset($this->aliases[$cName]) + || isset($this->instances[$cName]) + ) { + return true; + } + + if ($checkAbstractFactories && $this->canCreateFromAbstractFactory($cName, $rName)) { + return true; + } + + return false; + } + + /** + * @param string|array $name + * @param bool $checkAbstractFactories + * @param bool $usePeeringServiceManagers + * @return bool + */ + public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = true) + { + if (is_array($name)) { + list($cName, $rName) = $name; + } else { + $rName = $name; + $cName = $this->canonicalizeName($rName); + } + + if ($this->canCreate(array($cName, $rName), $checkAbstractFactories)) { + return true; + } + + if ($usePeeringServiceManagers) { + foreach ($this->peeringServiceManagers as $peeringServiceManager) { + if ($peeringServiceManager->has($rName)) { + return true; + } + } + } + + return false; + } + + /** + * Determine if we can create an instance from an abstract factory. + * + * @param string $cName + * @param string $rName + * @return bool + */ + public function canCreateFromAbstractFactory($cName, $rName) + { + // check abstract factories + foreach ($this->abstractFactories as $index => $abstractFactory) { + // Support string abstract factory class names + if (is_string($abstractFactory) && class_exists($abstractFactory, true)) { + $this->abstractFactory[$index] = $abstractFactory = new $abstractFactory(); + } + + if ( + isset($this->pendingAbstractFactoryRequests[get_class($abstractFactory)]) + && $this->pendingAbstractFactoryRequests[get_class($abstractFactory)] == $rName + ) { + return false; + } + + if ($abstractFactory->canCreateServiceWithName($this, $cName, $rName)) { + return true; + } + } + return false; + } + + /** + * @param string $alias + * @param string $nameOrAlias + * @return ServiceManager + * @throws Exception\ServiceNotFoundException + * @throws Exception\InvalidServiceNameException + */ + public function setAlias($alias, $nameOrAlias) + { + if (!is_string($alias) || !is_string($nameOrAlias)) { + throw new Exception\InvalidServiceNameException('Service or alias names must be strings.'); + } + + $cAlias = $this->canonicalizeName($alias); + $nameOrAlias = $this->canonicalizeName($nameOrAlias); + + if ($alias == '' || $nameOrAlias == '') { + throw new Exception\InvalidServiceNameException('Invalid service name alias'); + } + + if ($this->allowOverride === false && $this->has(array($cAlias, $alias), false)) { + throw new Exception\InvalidServiceNameException('An alias by this name already exists'); + } + + $this->aliases[$cAlias] = $nameOrAlias; + return $this; + } + + /** + * Determine if we have an alias + * + * @param string $alias + * @return bool + */ + public function hasAlias($alias) + { + $alias = $this->canonicalizeName($alias); + return (isset($this->aliases[$alias])); + } + + /** + * Create scoped service manager + * + * @param string $peering + * @return ServiceManager + */ + public function createScopedServiceManager($peering = self::SCOPE_PARENT) + { + $scopedServiceManager = new ServiceManager(); + if ($peering == self::SCOPE_PARENT) { + $scopedServiceManager->peeringServiceManagers[] = $this; + } + if ($peering == self::SCOPE_CHILD) { + $this->peeringServiceManagers[] = $scopedServiceManager; + } + return $scopedServiceManager; + } + + /** + * Add a peering relationship + * + * @param ServiceManager $manager + * @param string $peering + * @return ServiceManager + */ + public function addPeeringServiceManager(ServiceManager $manager, $peering = self::SCOPE_PARENT) + { + if ($peering == self::SCOPE_PARENT) { + $this->peeringServiceManagers[] = $manager; + } + if ($peering == self::SCOPE_CHILD) { + $manager->peeringServiceManagers[] = $this; + } + return $this; + } + + /** + * Canonicalize name + * + * @param string $name + * @return string + */ + protected function canonicalizeName($name) + { + if (isset($this->canonicalNames[$name])) { + return $this->canonicalNames[$name]; + } + + // this is just for performance instead of using str_replace + return $this->canonicalNames[$name] = strtolower(strtr($name, $this->canonicalNamesReplacements)); + } + + /** + * Create service via callback + * + * @param callable $callable + * @param string $cName + * @param string $rName + * @throws Exception\ServiceNotCreatedException + * @throws Exception\ServiceNotFoundException + * @throws Exception\CircularDependencyFoundException + * @return object + */ + protected function createServiceViaCallback($callable, $cName, $rName) + { + static $circularDependencyResolver = array(); + $depKey = spl_object_hash($this) . '-' . $cName; + + if (isset($circularDependencyResolver[$depKey])) { + $circularDependencyResolver = array(); + throw new Exception\CircularDependencyFoundException('Circular dependency for LazyServiceLoader was found for instance ' . $rName); + } + + try { + $circularDependencyResolver[$depKey] = true; + $instance = call_user_func($callable, $this, $cName, $rName); + unset($circularDependencyResolver[$depKey]); + } catch (Exception\ServiceNotFoundException $e) { + unset($circularDependencyResolver[$depKey]); + throw $e; + } catch (\Exception $e) { + unset($circularDependencyResolver[$depKey]); + throw new Exception\ServiceNotCreatedException( + sprintf('An exception was raised while creating "%s"; no instance returned', $rName), + $e->getCode(), + $e + ); + } + if ($instance === null) { + throw new Exception\ServiceNotCreatedException('The factory was called but did not return an instance.'); + } + + return $instance; + } + + /** + * Retrieve a keyed list of all registered services. Handy for debugging! + * + * @return array + */ + public function getRegisteredServices() + { + return array( + 'invokableClasses' => array_keys($this->invokableClasses), + 'factories' => array_keys($this->factories), + 'aliases' => array_keys($this->aliases), + 'instances' => array_keys($this->instances), + ); + } + + /** + * Retrieve a keyed list of all canonical names. Handy for debugging! + * + * @return array + */ + public function getCanonicalNames() + { + return $this->canonicalNames; + } + + /** + * Allows to override the canonical names lookup map with predefined + * values. + * + * @param array $canonicalNames + * @return ServiceManager + */ + public function setCanonicalNames($canonicalNames) + { + $this->canonicalNames = $canonicalNames; + + return $this; + } + + /** + * Attempt to retrieve an instance via a peering manager + * + * @param string $name + * @return mixed + */ + protected function retrieveFromPeeringManager($name) + { + foreach ($this->peeringServiceManagers as $peeringServiceManager) { + if ($peeringServiceManager->has($name)) { + return $peeringServiceManager->get($name); + } + } + return null; + } + + /** + * Attempt to create an instance via an invokable class + * + * @param string $canonicalName + * @param string $requestedName + * @return null|\stdClass + * @throws Exception\ServiceNotFoundException If resolved class does not exist + */ + protected function createFromInvokable($canonicalName, $requestedName) + { + $invokable = $this->invokableClasses[$canonicalName]; + if (!class_exists($invokable)) { + throw new Exception\ServiceNotFoundException(sprintf( + '%s: failed retrieving "%s%s" via invokable class "%s"; class does not exist', + __METHOD__, + $canonicalName, + ($requestedName ? '(alias: ' . $requestedName . ')' : ''), + $invokable + )); + } + $instance = new $invokable; + return $instance; + } + + /** + * Attempt to create an instance via a factory + * + * @param string $canonicalName + * @param string $requestedName + * @return mixed + * @throws Exception\ServiceNotCreatedException If factory is not callable + */ + protected function createFromFactory($canonicalName, $requestedName) + { + $factory = $this->factories[$canonicalName]; + if (is_string($factory) && class_exists($factory, true)) { + $factory = new $factory; + $this->factories[$canonicalName] = $factory; + } + if ($factory instanceof FactoryInterface) { + $instance = $this->createServiceViaCallback(array($factory, 'createService'), $canonicalName, $requestedName); + } elseif (is_callable($factory)) { + $instance = $this->createServiceViaCallback($factory, $canonicalName, $requestedName); + } else { + throw new Exception\ServiceNotCreatedException(sprintf( + 'While attempting to create %s%s an invalid factory was registered for this instance type.', + $canonicalName, + ($requestedName ? '(alias: ' . $requestedName . ')' : '') + )); + } + return $instance; + } + + /** + * Attempt to create an instance via an abstract factory + * + * @param string $canonicalName + * @param string $requestedName + * @return object|null + * @throws Exception\ServiceNotCreatedException If abstract factory is not callable + */ + protected function createFromAbstractFactory($canonicalName, $requestedName) + { + foreach ($this->abstractFactories as $index => $abstractFactory) { + // support factories as strings + if (is_string($abstractFactory) && class_exists($abstractFactory, true)) { + $this->abstractFactories[$index] = $abstractFactory = new $abstractFactory; + } elseif (!$abstractFactory instanceof AbstractFactoryInterface) { + throw new Exception\ServiceNotCreatedException(sprintf( + 'While attempting to create %s%s an abstract factory could not produce a valid instance.', + $canonicalName, + ($requestedName ? '(alias: ' . $requestedName . ')' : '') + )); + } + try { + $this->pendingAbstractFactoryRequests[get_class($abstractFactory)] = $requestedName; + if ($abstractFactory->canCreateServiceWithName($this, $canonicalName, $requestedName)) { + $instance = $this->createServiceViaCallback( + array($abstractFactory, 'createServiceWithName'), + $canonicalName, + $requestedName + ); + unset($this->pendingAbstractFactoryRequests[get_class($abstractFactory)]); + } else { + $instance = false; + } + } catch (\Exception $e) { + unset($this->pendingAbstractFactoryRequests[get_class($abstractFactory)]); + throw new Exception\ServiceNotCreatedException( + sprintf( + 'An abstract factory could not create an instance of %s%s.', + $canonicalName, + ($requestedName ? '(alias: ' . $requestedName . ')' : '') + ), + $e->getCode(), + $e + ); + } + if (is_object($instance)) { + break; + } + } + + return $instance; + } + + /** + * Checks if the object has this class as one of its parents + * + * @see https://bugs.php.net/bug.php?id=53727 + * @see https://github.com/zendframework/zf2/pull/1807 + * + * @param string $className + * @param string $type + * @return bool + */ + protected static function isSubclassOf($className, $type) + { + if (is_subclass_of($className, $type)) { + return true; + } + if (version_compare(PHP_VERSION, '5.3.7', '>=')) { + return false; + } + if (!interface_exists($type)) { + return false; + } + $r = new ReflectionClass($className); + return $r->implementsInterface($type); + } + + /** + * Unregister a service + * + * Called when $allowOverride is true and we detect that a service being + * added to the instance already exists. This will remove the duplicate + * entry, and also any shared flags previously registered. + * + * @param string $canonical + * @return void + */ + protected function unregisterService($canonical) + { + $types = array('invokableClasses', 'factories', 'aliases'); + foreach ($types as $type) { + if (isset($this->{$type}[$canonical])) { + unset($this->{$type}[$canonical]); + break; + } + } + + if (isset($this->instances[$canonical])) { + unset($this->instances[$canonical]); + } + + if (isset($this->shared[$canonical])) { + unset($this->shared[$canonical]); + } + } +} diff --git a/lib/internal/Zend/ServiceManager/ServiceManagerAwareInterface.php b/lib/internal/Zend/ServiceManager/ServiceManagerAwareInterface.php new file mode 100644 index 00000000000..5ea837087f4 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/ServiceManagerAwareInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_ServiceManager + */ + +namespace Zend\ServiceManager; + +/** + * @category Zend + * @package Zend_ServiceManager + */ +interface ServiceManagerAwareInterface +{ + /** + * Set service manager + * + * @param ServiceManager $serviceManager + */ + public function setServiceManager(ServiceManager $serviceManager); +} diff --git a/lib/internal/Zend/ServiceManager/composer.json b/lib/internal/Zend/ServiceManager/composer.json new file mode 100644 index 00000000000..0382d5d5eb1 --- /dev/null +++ b/lib/internal/Zend/ServiceManager/composer.json @@ -0,0 +1,21 @@ +{ + "name": "zendframework/zend-servicemanager", + "description": " ", + "license": "BSD-3-Clause", + "keywords": [ + "zf2", + "servicemanager" + ], + "autoload": { + "psr-0": { + "Zend\\ServiceManager\\": "" + } + }, + "target-dir": "Zend/ServiceManager", + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "zendframework/zend-di": "Zend\\Di component" + } +} \ No newline at end of file diff --git a/lib/internal/Zend/Soap/AutoDiscover.php b/lib/internal/Zend/Soap/AutoDiscover.php index b6af97ff305..f703b990840 100644 --- a/lib/internal/Zend/Soap/AutoDiscover.php +++ b/lib/internal/Zend/Soap/AutoDiscover.php @@ -13,7 +13,6 @@ namespace Zend\Soap; use Zend\Server\Reflection; use Zend\Server\Reflection\AbstractFunction; use Zend\Server\Reflection\Prototype; -use Zend\Server\Reflection\ReflectionParameter; use Zend\Soap\AutoDiscover\DiscoveryStrategy\DiscoveryStrategyInterface as DiscoveryStrategy; use Zend\Soap\AutoDiscover\DiscoveryStrategy\ReflectionDiscovery; use Zend\Soap\Wsdl; @@ -191,7 +190,7 @@ class AutoDiscover ->getShortName(); } else { throw new Exception\RuntimeException( - "No service name given. Call Autodiscover#setServiceName()." + "No service name given. Call Autodiscover::setServiceName()." ); } } @@ -228,7 +227,7 @@ class AutoDiscover public function getUri() { if ($this->uri === null) { - throw new Exception\RuntimeException("Missing uri. You have to explicitly configure the Endpoint Uri by calling AutoDiscover#setUri()."); + throw new Exception\RuntimeException("Missing uri. You have to explicitly configure the Endpoint Uri by calling AutoDiscover::setUri()."); } if (is_string($this->uri)) { $this->uri = Uri\UriFactory::factory($this->uri); diff --git a/lib/internal/Zend/Soap/Client.php b/lib/internal/Zend/Soap/Client.php index 5d137fc2bec..285a29101f7 100644 --- a/lib/internal/Zend/Soap/Client.php +++ b/lib/internal/Zend/Soap/Client.php @@ -858,7 +858,7 @@ class Client implements ServerClient if ($userAgent === null) { $this->user_agent = null; } else { - $this->user_agent = (string)$userAgent; + $this->user_agent = (string) $userAgent; } return $this; } diff --git a/lib/internal/Zend/Soap/Server/DocumentLiteralWrapper.php b/lib/internal/Zend/Soap/Server/DocumentLiteralWrapper.php index 750942840c3..65b887f6f1e 100644 --- a/lib/internal/Zend/Soap/Server/DocumentLiteralWrapper.php +++ b/lib/internal/Zend/Soap/Server/DocumentLiteralWrapper.php @@ -10,7 +10,6 @@ namespace Zend\Soap\Server; -use ReflectionClass; use ReflectionObject; use Zend\Soap\Exception\BadMethodCallException; use Zend\Soap\Exception\UnexpectedValueException; diff --git a/lib/internal/Zend/Soap/composer.json b/lib/internal/Zend/Soap/composer.json index fbf77e9ce41..777a0a5e52d 100644 --- a/lib/internal/Zend/Soap/composer.json +++ b/lib/internal/Zend/Soap/composer.json @@ -8,7 +8,7 @@ ], "autoload": { "psr-0": { - "Zend\\Soap": "" + "Zend\\Soap\\": "" } }, "target-dir": "Zend/Soap", diff --git a/lib/internal/Zend/Uri/composer.json b/lib/internal/Zend/Uri/composer.json index ae5e2cbcf3c..82dedad0438 100644 --- a/lib/internal/Zend/Uri/composer.json +++ b/lib/internal/Zend/Uri/composer.json @@ -8,7 +8,7 @@ ], "autoload": { "psr-0": { - "Zend\\Uri": "" + "Zend\\Uri\\": "" } }, "target-dir": "Zend/Uri", diff --git a/lib/internal/Zend/Validator/AbstractValidator.php b/lib/internal/Zend/Validator/AbstractValidator.php index ce4dee7fb32..ec3244f7234 100644 --- a/lib/internal/Zend/Validator/AbstractValidator.php +++ b/lib/internal/Zend/Validator/AbstractValidator.php @@ -18,7 +18,7 @@ use Zend\Validator\Exception\InvalidArgumentException; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ abstract class AbstractValidator implements TranslatorAwareInterface, diff --git a/lib/internal/Zend/Validator/Barcode.php b/lib/internal/Zend/Validator/Barcode.php index 615d3405f4b..959a119b8f7 100644 --- a/lib/internal/Zend/Validator/Barcode.php +++ b/lib/internal/Zend/Validator/Barcode.php @@ -14,7 +14,7 @@ use Traversable; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Barcode extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Barcode/AbstractAdapter.php b/lib/internal/Zend/Validator/Barcode/AbstractAdapter.php index 860e5420241..3e1f23816f6 100644 --- a/lib/internal/Zend/Validator/Barcode/AbstractAdapter.php +++ b/lib/internal/Zend/Validator/Barcode/AbstractAdapter.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ abstract class AbstractAdapter implements AdapterInterface { diff --git a/lib/internal/Zend/Validator/Barcode/AdapterInterface.php b/lib/internal/Zend/Validator/Barcode/AdapterInterface.php index a2667cd0642..d83b5563a82 100644 --- a/lib/internal/Zend/Validator/Barcode/AdapterInterface.php +++ b/lib/internal/Zend/Validator/Barcode/AdapterInterface.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ interface AdapterInterface { diff --git a/lib/internal/Zend/Validator/Barcode/Codabar.php b/lib/internal/Zend/Validator/Barcode/Codabar.php index 2c52064fdac..a653931dcb7 100644 --- a/lib/internal/Zend/Validator/Barcode/Codabar.php +++ b/lib/internal/Zend/Validator/Barcode/Codabar.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Codabar extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code128.php b/lib/internal/Zend/Validator/Barcode/Code128.php index f97d0f33ec2..e2951ff25f0 100644 --- a/lib/internal/Zend/Validator/Barcode/Code128.php +++ b/lib/internal/Zend/Validator/Barcode/Code128.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code128 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code25.php b/lib/internal/Zend/Validator/Barcode/Code25.php index 22abdef7ee6..634e64d4b3e 100644 --- a/lib/internal/Zend/Validator/Barcode/Code25.php +++ b/lib/internal/Zend/Validator/Barcode/Code25.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code25 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code25interleaved.php b/lib/internal/Zend/Validator/Barcode/Code25interleaved.php index 585bff79dbb..4f41a8079c5 100644 --- a/lib/internal/Zend/Validator/Barcode/Code25interleaved.php +++ b/lib/internal/Zend/Validator/Barcode/Code25interleaved.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code25interleaved extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code39.php b/lib/internal/Zend/Validator/Barcode/Code39.php index fb88000b57e..5e0ce1b092c 100644 --- a/lib/internal/Zend/Validator/Barcode/Code39.php +++ b/lib/internal/Zend/Validator/Barcode/Code39.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code39 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code39ext.php b/lib/internal/Zend/Validator/Barcode/Code39ext.php index b8b5fb3fc12..6fb8a7089d0 100644 --- a/lib/internal/Zend/Validator/Barcode/Code39ext.php +++ b/lib/internal/Zend/Validator/Barcode/Code39ext.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code39ext extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code93.php b/lib/internal/Zend/Validator/Barcode/Code93.php index 524ec049bd4..275c5f953c4 100644 --- a/lib/internal/Zend/Validator/Barcode/Code93.php +++ b/lib/internal/Zend/Validator/Barcode/Code93.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code93 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Code93ext.php b/lib/internal/Zend/Validator/Barcode/Code93ext.php index 3b910d3887b..c06db6e0fd9 100644 --- a/lib/internal/Zend/Validator/Barcode/Code93ext.php +++ b/lib/internal/Zend/Validator/Barcode/Code93ext.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Code93ext extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean12.php b/lib/internal/Zend/Validator/Barcode/Ean12.php index b90d291c81a..f99b2952ef9 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean12.php +++ b/lib/internal/Zend/Validator/Barcode/Ean12.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean12 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean13.php b/lib/internal/Zend/Validator/Barcode/Ean13.php index 5a58ae419ff..94c3294a877 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean13.php +++ b/lib/internal/Zend/Validator/Barcode/Ean13.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean13 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean14.php b/lib/internal/Zend/Validator/Barcode/Ean14.php index 426c604c790..1cf69d1e517 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean14.php +++ b/lib/internal/Zend/Validator/Barcode/Ean14.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean14 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean18.php b/lib/internal/Zend/Validator/Barcode/Ean18.php index 0a1a8acd088..5ad74871354 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean18.php +++ b/lib/internal/Zend/Validator/Barcode/Ean18.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean18 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean2.php b/lib/internal/Zend/Validator/Barcode/Ean2.php index 2dd48d0bc43..7683488af83 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean2.php +++ b/lib/internal/Zend/Validator/Barcode/Ean2.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean2 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean5.php b/lib/internal/Zend/Validator/Barcode/Ean5.php index ec327c41c9a..08003a741d7 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean5.php +++ b/lib/internal/Zend/Validator/Barcode/Ean5.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean5 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Ean8.php b/lib/internal/Zend/Validator/Barcode/Ean8.php index ea0a1453f85..2efe95aa97f 100644 --- a/lib/internal/Zend/Validator/Barcode/Ean8.php +++ b/lib/internal/Zend/Validator/Barcode/Ean8.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ean8 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Gtin12.php b/lib/internal/Zend/Validator/Barcode/Gtin12.php index 2490969bad8..046b6e3bef8 100644 --- a/lib/internal/Zend/Validator/Barcode/Gtin12.php +++ b/lib/internal/Zend/Validator/Barcode/Gtin12.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Gtin12 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Gtin13.php b/lib/internal/Zend/Validator/Barcode/Gtin13.php index cdc233d205a..cc97a4a9c39 100644 --- a/lib/internal/Zend/Validator/Barcode/Gtin13.php +++ b/lib/internal/Zend/Validator/Barcode/Gtin13.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Gtin13 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Gtin14.php b/lib/internal/Zend/Validator/Barcode/Gtin14.php index 9dc9639d672..3e837d32c49 100644 --- a/lib/internal/Zend/Validator/Barcode/Gtin14.php +++ b/lib/internal/Zend/Validator/Barcode/Gtin14.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Gtin14 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Identcode.php b/lib/internal/Zend/Validator/Barcode/Identcode.php index 60ff77fc4c8..e4e8e050f03 100644 --- a/lib/internal/Zend/Validator/Barcode/Identcode.php +++ b/lib/internal/Zend/Validator/Barcode/Identcode.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Identcode extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Intelligentmail.php b/lib/internal/Zend/Validator/Barcode/Intelligentmail.php index 6dd31f001a7..d301605eac1 100644 --- a/lib/internal/Zend/Validator/Barcode/Intelligentmail.php +++ b/lib/internal/Zend/Validator/Barcode/Intelligentmail.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Intelligentmail extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Issn.php b/lib/internal/Zend/Validator/Barcode/Issn.php index d2b0a531e15..283885df60b 100644 --- a/lib/internal/Zend/Validator/Barcode/Issn.php +++ b/lib/internal/Zend/Validator/Barcode/Issn.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Issn extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Itf14.php b/lib/internal/Zend/Validator/Barcode/Itf14.php index 51e6166e2a5..e2fef44b099 100644 --- a/lib/internal/Zend/Validator/Barcode/Itf14.php +++ b/lib/internal/Zend/Validator/Barcode/Itf14.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Itf14 extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Leitcode.php b/lib/internal/Zend/Validator/Barcode/Leitcode.php index 6a069b0c37a..d2f5528fa2d 100644 --- a/lib/internal/Zend/Validator/Barcode/Leitcode.php +++ b/lib/internal/Zend/Validator/Barcode/Leitcode.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Leitcode extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Planet.php b/lib/internal/Zend/Validator/Barcode/Planet.php index 71eb79c492f..041df19ba89 100644 --- a/lib/internal/Zend/Validator/Barcode/Planet.php +++ b/lib/internal/Zend/Validator/Barcode/Planet.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Planet extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Postnet.php b/lib/internal/Zend/Validator/Barcode/Postnet.php index a9a97d5cfd9..b11992672d0 100644 --- a/lib/internal/Zend/Validator/Barcode/Postnet.php +++ b/lib/internal/Zend/Validator/Barcode/Postnet.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Postnet extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Royalmail.php b/lib/internal/Zend/Validator/Barcode/Royalmail.php index 78beea2d6c8..079c670fbe8 100644 --- a/lib/internal/Zend/Validator/Barcode/Royalmail.php +++ b/lib/internal/Zend/Validator/Barcode/Royalmail.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Royalmail extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Sscc.php b/lib/internal/Zend/Validator/Barcode/Sscc.php index 12340343946..56dbbe102ce 100644 --- a/lib/internal/Zend/Validator/Barcode/Sscc.php +++ b/lib/internal/Zend/Validator/Barcode/Sscc.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Sscc extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Upca.php b/lib/internal/Zend/Validator/Barcode/Upca.php index 72edb441621..461af71f0c5 100644 --- a/lib/internal/Zend/Validator/Barcode/Upca.php +++ b/lib/internal/Zend/Validator/Barcode/Upca.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Upca extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Barcode/Upce.php b/lib/internal/Zend/Validator/Barcode/Upce.php index f69dfc2ec3b..57dd4b6898d 100644 --- a/lib/internal/Zend/Validator/Barcode/Upce.php +++ b/lib/internal/Zend/Validator/Barcode/Upce.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Barcode; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Upce extends AbstractAdapter { diff --git a/lib/internal/Zend/Validator/Between.php b/lib/internal/Zend/Validator/Between.php index 9e2c3e78f45..069a4687bc7 100644 --- a/lib/internal/Zend/Validator/Between.php +++ b/lib/internal/Zend/Validator/Between.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Between extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Callback.php b/lib/internal/Zend/Validator/Callback.php index d1dd91cb252..e46e11e0b32 100644 --- a/lib/internal/Zend/Validator/Callback.php +++ b/lib/internal/Zend/Validator/Callback.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Callback extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/CreditCard.php b/lib/internal/Zend/Validator/CreditCard.php index 406a3b445e4..5f6e79d3ee2 100644 --- a/lib/internal/Zend/Validator/CreditCard.php +++ b/lib/internal/Zend/Validator/CreditCard.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class CreditCard extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Date.php b/lib/internal/Zend/Validator/Date.php index c2b12ca54ed..46fcd8956b0 100644 --- a/lib/internal/Zend/Validator/Date.php +++ b/lib/internal/Zend/Validator/Date.php @@ -15,7 +15,7 @@ use Traversable; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Date extends AbstractValidator { @@ -128,7 +128,11 @@ class Date extends AbstractValidator // and still return a DateTime object $errors = DateTime::getLastErrors(); - if (false === $date || $errors['warning_count'] > 0) { + if ($errors['warning_count'] > 0) { + $this->error(self::INVALID_DATE); + return false; + } + if ($date === false) { $this->error(self::INVALID_DATE); return false; } diff --git a/lib/internal/Zend/Validator/DateStep.php b/lib/internal/Zend/Validator/DateStep.php index 84b1b2a4d3a..5cf745e124c 100644 --- a/lib/internal/Zend/Validator/DateStep.php +++ b/lib/internal/Zend/Validator/DateStep.php @@ -19,20 +19,16 @@ use Zend\Validator\Exception; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ -class DateStep extends AbstractValidator +class DateStep extends Date { - const INVALID = 'dateStepInvalid'; - const INVALID_DATE = 'dateStepInvalidDate'; const NOT_STEP = 'dateStepNotStep'; /** * @var array */ protected $messageTemplates = array( - self::INVALID => "Invalid type given. String, integer, array or DateTime expected", - self::INVALID_DATE => "The input does not appear to be a valid date", self::NOT_STEP => "The input is not a valid step" ); @@ -155,28 +151,6 @@ class DateStep extends AbstractValidator return $this->step; } - /** - * Returns the format option - * - * @return string - */ - public function getFormat() - { - return $this->format; - } - - /** - * Sets the format option - * - * @param string $format - * @return DateStep - */ - public function setFormat($format) - { - $this->format = $format; - return $this; - } - /** * Returns the timezone option * @@ -241,13 +215,7 @@ class DateStep extends AbstractValidator */ public function isValid($value) { - if (!is_string($value) - && !is_int($value) - && !($value instanceof DateTime) - ) { - $this->error(self::INVALID); - return false; - } + parent::isValid($value); $this->setValue($value); @@ -258,7 +226,6 @@ class DateStep extends AbstractValidator try { $valueDate = $this->convertToDateTime($value); } catch (Exception\InvalidArgumentException $ex) { - $this->error(self::INVALID_DATE); return false; } @@ -281,7 +248,7 @@ class DateStep extends AbstractValidator foreach ($intervalParts as $key => $value) { if (0 != $value) { $intervalUnit = $key; - $stepValue = (int)$value; + $stepValue = (int) $value; break; } } diff --git a/lib/internal/Zend/Validator/Db/AbstractDb.php b/lib/internal/Zend/Validator/Db/AbstractDb.php index 476aac362ac..dcc7d566d8f 100644 --- a/lib/internal/Zend/Validator/Db/AbstractDb.php +++ b/lib/internal/Zend/Validator/Db/AbstractDb.php @@ -23,7 +23,7 @@ use Zend\Validator\Exception; * Class for Database record validation * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ abstract class AbstractDb extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Db/NoRecordExists.php b/lib/internal/Zend/Validator/Db/NoRecordExists.php index ed42d1f34ba..b2a1ba9c1fd 100644 --- a/lib/internal/Zend/Validator/Db/NoRecordExists.php +++ b/lib/internal/Zend/Validator/Db/NoRecordExists.php @@ -16,7 +16,7 @@ use Zend\Validator\Exception; * Confirms a record does not exist in a table. * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class NoRecordExists extends AbstractDb { diff --git a/lib/internal/Zend/Validator/Db/RecordExists.php b/lib/internal/Zend/Validator/Db/RecordExists.php index 1a0d41ab61d..8a8a68d8a48 100644 --- a/lib/internal/Zend/Validator/Db/RecordExists.php +++ b/lib/internal/Zend/Validator/Db/RecordExists.php @@ -16,7 +16,7 @@ use Zend\Validator\Exception; * Confirms a record exists in a table. * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class RecordExists extends AbstractDb { diff --git a/lib/internal/Zend/Validator/Digits.php b/lib/internal/Zend/Validator/Digits.php index f95cf57ba9a..10043b2a004 100644 --- a/lib/internal/Zend/Validator/Digits.php +++ b/lib/internal/Zend/Validator/Digits.php @@ -14,7 +14,7 @@ use Zend\Filter\Digits as DigitsFilter; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Digits extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/EmailAddress.php b/lib/internal/Zend/Validator/EmailAddress.php index 67a31d9e7f4..03e2fa38f13 100644 --- a/lib/internal/Zend/Validator/EmailAddress.php +++ b/lib/internal/Zend/Validator/EmailAddress.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class EmailAddress extends AbstractValidator { @@ -486,7 +486,7 @@ class EmailAddress extends AbstractValidator } /** - * Defined by Zend_Validate_Interface + * Defined by Zend\Validator\ValidatorInterface * * Returns true if and only if $value is a valid email address * according to RFC2822 diff --git a/lib/internal/Zend/Validator/Exception/ExceptionInterface.php b/lib/internal/Zend/Validator/Exception/ExceptionInterface.php index 3bad3ac22c6..b73a1722de2 100644 --- a/lib/internal/Zend/Validator/Exception/ExceptionInterface.php +++ b/lib/internal/Zend/Validator/Exception/ExceptionInterface.php @@ -12,7 +12,7 @@ namespace Zend\Validator\Exception; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ interface ExceptionInterface {} diff --git a/lib/internal/Zend/Validator/Explode.php b/lib/internal/Zend/Validator/Explode.php index 56c8876c6cc..9d927b597ab 100644 --- a/lib/internal/Zend/Validator/Explode.php +++ b/lib/internal/Zend/Validator/Explode.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Explode extends AbstractValidator { @@ -112,7 +112,7 @@ class Explode extends AbstractValidator } /** - * Defined by Zend_Validate_Interface + * Defined by Zend\Validator\ValidatorInterface * * Returns true if all values validate true * diff --git a/lib/internal/Zend/Validator/File/Count.php b/lib/internal/Zend/Validator/File/Count.php index dbc82dcf2c1..2737f086f96 100644 --- a/lib/internal/Zend/Validator/File/Count.php +++ b/lib/internal/Zend/Validator/File/Count.php @@ -17,7 +17,7 @@ use Zend\Validator\Exception; * Validator for counting all given files * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Count extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/Crc32.php b/lib/internal/Zend/Validator/File/Crc32.php index cf55b005547..2103e15e11f 100644 --- a/lib/internal/Zend/Validator/File/Crc32.php +++ b/lib/internal/Zend/Validator/File/Crc32.php @@ -14,7 +14,7 @@ namespace Zend\Validator\File; * Validator for the crc32 hash of given files * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Crc32 extends Hash { diff --git a/lib/internal/Zend/Validator/File/ExcludeExtension.php b/lib/internal/Zend/Validator/File/ExcludeExtension.php index 57938d94164..0ac8d6e38fd 100644 --- a/lib/internal/Zend/Validator/File/ExcludeExtension.php +++ b/lib/internal/Zend/Validator/File/ExcludeExtension.php @@ -14,7 +14,7 @@ namespace Zend\Validator\File; * Validator for the excluding file extensions * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class ExcludeExtension extends Extension { diff --git a/lib/internal/Zend/Validator/File/ExcludeMimeType.php b/lib/internal/Zend/Validator/File/ExcludeMimeType.php index 62c086ae164..a94124c58cf 100644 --- a/lib/internal/Zend/Validator/File/ExcludeMimeType.php +++ b/lib/internal/Zend/Validator/File/ExcludeMimeType.php @@ -16,7 +16,7 @@ use finfo; * Validator for the mime type of a file * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class ExcludeMimeType extends MimeType { diff --git a/lib/internal/Zend/Validator/File/Exists.php b/lib/internal/Zend/Validator/File/Exists.php index 7631df7e4da..52b47ed0d4c 100644 --- a/lib/internal/Zend/Validator/File/Exists.php +++ b/lib/internal/Zend/Validator/File/Exists.php @@ -17,7 +17,7 @@ use Zend\Validator\Exception; * Validator which checks if the file already exists in the directory * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Exists extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/Extension.php b/lib/internal/Zend/Validator/File/Extension.php index 8b59d503f12..567d35f1db0 100644 --- a/lib/internal/Zend/Validator/File/Extension.php +++ b/lib/internal/Zend/Validator/File/Extension.php @@ -18,7 +18,7 @@ use Zend\Validator\AbstractValidator; * Validator for the file extension of a file * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Extension extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/FilesSize.php b/lib/internal/Zend/Validator/File/FilesSize.php index 511e466eadc..a7be3735efa 100644 --- a/lib/internal/Zend/Validator/File/FilesSize.php +++ b/lib/internal/Zend/Validator/File/FilesSize.php @@ -19,7 +19,7 @@ use Zend\Validator\Exception; * Validator for the size of all files which will be validated in sum * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class FilesSize extends Size { diff --git a/lib/internal/Zend/Validator/File/Hash.php b/lib/internal/Zend/Validator/File/Hash.php index d51efe04d90..b7a56a3f56f 100644 --- a/lib/internal/Zend/Validator/File/Hash.php +++ b/lib/internal/Zend/Validator/File/Hash.php @@ -17,7 +17,7 @@ use Zend\Validator\Exception; * Validator for the hash of given files * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Hash extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/ImageSize.php b/lib/internal/Zend/Validator/File/ImageSize.php index 70dfdc6b4d1..337b49dadad 100644 --- a/lib/internal/Zend/Validator/File/ImageSize.php +++ b/lib/internal/Zend/Validator/File/ImageSize.php @@ -18,7 +18,7 @@ use Zend\Validator\Exception; * Validator for the image size of a image file * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class ImageSize extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/IsCompressed.php b/lib/internal/Zend/Validator/File/IsCompressed.php index 19656492166..3710b375a4c 100644 --- a/lib/internal/Zend/Validator/File/IsCompressed.php +++ b/lib/internal/Zend/Validator/File/IsCompressed.php @@ -17,7 +17,7 @@ use Zend\Stdlib\ArrayUtils; * Validator which checks if the file already exists in the directory * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class IsCompressed extends MimeType { diff --git a/lib/internal/Zend/Validator/File/IsImage.php b/lib/internal/Zend/Validator/File/IsImage.php index 9acb63e3d7b..537ed44ed9c 100644 --- a/lib/internal/Zend/Validator/File/IsImage.php +++ b/lib/internal/Zend/Validator/File/IsImage.php @@ -17,7 +17,7 @@ use Zend\Stdlib\ArrayUtils; * Validator which checks if the file already exists in the directory * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class IsImage extends MimeType { diff --git a/lib/internal/Zend/Validator/File/Md5.php b/lib/internal/Zend/Validator/File/Md5.php index 38bbf4323b8..b32ba53ea15 100644 --- a/lib/internal/Zend/Validator/File/Md5.php +++ b/lib/internal/Zend/Validator/File/Md5.php @@ -14,7 +14,7 @@ namespace Zend\Validator\File; * Validator for the md5 hash of given files * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Md5 extends Hash { diff --git a/lib/internal/Zend/Validator/File/MimeType.php b/lib/internal/Zend/Validator/File/MimeType.php index cc4ffff6428..1f1a536995a 100644 --- a/lib/internal/Zend/Validator/File/MimeType.php +++ b/lib/internal/Zend/Validator/File/MimeType.php @@ -20,7 +20,7 @@ use Zend\Validator\Exception; * Validator for the mime type of a file * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class MimeType extends AbstractValidator { @@ -339,7 +339,7 @@ class MimeType extends AbstractValidator } /** - * Defined by Zend_Validate_Interface + * Defined by Zend\Validator\ValidatorInterface * * Returns true if the mimetype of the file matches the given ones. Also parts * of mimetypes can be checked. If you give for example "image" all image diff --git a/lib/internal/Zend/Validator/File/NotExists.php b/lib/internal/Zend/Validator/File/NotExists.php index 6ffc314807e..ca40f46b874 100644 --- a/lib/internal/Zend/Validator/File/NotExists.php +++ b/lib/internal/Zend/Validator/File/NotExists.php @@ -14,7 +14,7 @@ namespace Zend\Validator\File; * Validator which checks if the destination file does not exist * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class NotExists extends Exists { diff --git a/lib/internal/Zend/Validator/File/Sha1.php b/lib/internal/Zend/Validator/File/Sha1.php index c76a7a7e41d..72e37f16e39 100644 --- a/lib/internal/Zend/Validator/File/Sha1.php +++ b/lib/internal/Zend/Validator/File/Sha1.php @@ -10,13 +10,12 @@ namespace Zend\Validator\File; -use Zend\Validator\Exception; /** * Validator for the sha1 hash of given files * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Sha1 extends Hash { diff --git a/lib/internal/Zend/Validator/File/Size.php b/lib/internal/Zend/Validator/File/Size.php index 858876a39a7..96aae168898 100644 --- a/lib/internal/Zend/Validator/File/Size.php +++ b/lib/internal/Zend/Validator/File/Size.php @@ -18,7 +18,7 @@ use Zend\Validator\Exception; * Validator for the maximum size of a file up to a max of 2GB * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Size extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/Upload.php b/lib/internal/Zend/Validator/File/Upload.php index 59c3846fe39..dc9e55bf6de 100644 --- a/lib/internal/Zend/Validator/File/Upload.php +++ b/lib/internal/Zend/Validator/File/Upload.php @@ -17,7 +17,7 @@ use Zend\Validator\Exception; * Validator for the maximum size of a file up to a max of 2GB * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Upload extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/File/WordCount.php b/lib/internal/Zend/Validator/File/WordCount.php index 48a0fc2cb5d..4587d9ce9d7 100644 --- a/lib/internal/Zend/Validator/File/WordCount.php +++ b/lib/internal/Zend/Validator/File/WordCount.php @@ -14,7 +14,7 @@ namespace Zend\Validator\File; * Validator for counting all words in a file * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class WordCount extends Count { diff --git a/lib/internal/Zend/Validator/GreaterThan.php b/lib/internal/Zend/Validator/GreaterThan.php index 38be082f796..31a3254c06c 100644 --- a/lib/internal/Zend/Validator/GreaterThan.php +++ b/lib/internal/Zend/Validator/GreaterThan.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class GreaterThan extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Hex.php b/lib/internal/Zend/Validator/Hex.php index 8aaf75deb81..320f655ad9e 100644 --- a/lib/internal/Zend/Validator/Hex.php +++ b/lib/internal/Zend/Validator/Hex.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Hex extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Hostname/Biz.php b/lib/internal/Zend/Validator/Hostname/Biz.php index 54b9ea50cc0..365f5a20b2e 100644 --- a/lib/internal/Zend/Validator/Hostname/Biz.php +++ b/lib/internal/Zend/Validator/Hostname/Biz.php @@ -14,7 +14,7 @@ namespace Zend\Validator\Hostname; * Resource file for biz idn validation * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ return array( 1 => '/^[\x{002d}0-9a-zäåæéöøü]{1,63}$/iu', diff --git a/lib/internal/Zend/Validator/Hostname/Cn.php b/lib/internal/Zend/Validator/Hostname/Cn.php index efb14b12615..8552817f157 100644 --- a/lib/internal/Zend/Validator/Hostname/Cn.php +++ b/lib/internal/Zend/Validator/Hostname/Cn.php @@ -14,7 +14,7 @@ namespace Zend\Validator\Hostname; * Resource file for chinese idn validation * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ return array( 1 => '/^[\x{002d}0-9a-z\x{3447}\x{3473}\x{359E}\x{360E}\x{361A}\x{3918}\x{396E}\x{39CF}\x{39D0}' . diff --git a/lib/internal/Zend/Validator/Hostname/Com.php b/lib/internal/Zend/Validator/Hostname/Com.php index 8fe41e0164e..9d7382d5e64 100644 --- a/lib/internal/Zend/Validator/Hostname/Com.php +++ b/lib/internal/Zend/Validator/Hostname/Com.php @@ -14,7 +14,7 @@ namespace Zend\Validator\Hostname; * Resource file for com and net idn validation * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ return array( 1 => '/^[\x{002d}0-9\x{0400}-\x{052f}]{1,63}$/iu', diff --git a/lib/internal/Zend/Validator/Hostname/Jp.php b/lib/internal/Zend/Validator/Hostname/Jp.php index 50a4856dbce..fb31f20644f 100644 --- a/lib/internal/Zend/Validator/Hostname/Jp.php +++ b/lib/internal/Zend/Validator/Hostname/Jp.php @@ -14,7 +14,7 @@ namespace Zend\Validator\Hostname; * Resource file for japanese idn validation * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ return array( 1 => '/^[\x{002d}0-9a-z\x{3005}-\x{3007}\x{3041}-\x{3093}\x{309D}\x{309E}' . diff --git a/lib/internal/Zend/Validator/Iban.php b/lib/internal/Zend/Validator/Iban.php index c7d9e4b716e..2eb30aebd25 100644 --- a/lib/internal/Zend/Validator/Iban.php +++ b/lib/internal/Zend/Validator/Iban.php @@ -19,7 +19,7 @@ use Zend\Validator\Exception; * Validates IBAN Numbers (International Bank Account Numbers) * * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Iban extends AbstractValidator { @@ -226,7 +226,7 @@ class Iban extends AbstractValidator return false; } - $value = strtoupper($value); + $value = str_replace(' ', '', strtoupper($value)); $this->setValue($value); $countryCode = $this->getCountryCode(); diff --git a/lib/internal/Zend/Validator/Identical.php b/lib/internal/Zend/Validator/Identical.php index 20afe737ae5..56550bab1c8 100644 --- a/lib/internal/Zend/Validator/Identical.php +++ b/lib/internal/Zend/Validator/Identical.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Identical extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/InArray.php b/lib/internal/Zend/Validator/InArray.php index 8e89775e3e6..aee741d1df9 100644 --- a/lib/internal/Zend/Validator/InArray.php +++ b/lib/internal/Zend/Validator/InArray.php @@ -15,7 +15,7 @@ use RecursiveIteratorIterator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class InArray extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Ip.php b/lib/internal/Zend/Validator/Ip.php index c64573ede79..24bba30a14b 100644 --- a/lib/internal/Zend/Validator/Ip.php +++ b/lib/internal/Zend/Validator/Ip.php @@ -11,11 +11,10 @@ namespace Zend\Validator; use Traversable; -use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Ip extends AbstractValidator { @@ -184,7 +183,7 @@ class Ip extends AbstractValidator */ static $regex = '/^v([[:xdigit:]]+)\.[[:alnum:]\-\._~!\$&\'\(\)\*\+,;=:]+$/'; - $result = (bool)preg_match($regex, $value, $matches); + $result = (bool) preg_match($regex, $value, $matches); /* * "As such, implementations must not provide the version flag for the diff --git a/lib/internal/Zend/Validator/Isbn.php b/lib/internal/Zend/Validator/Isbn.php index 1550083a9f9..2be59e7d504 100644 --- a/lib/internal/Zend/Validator/Isbn.php +++ b/lib/internal/Zend/Validator/Isbn.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Isbn extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/LessThan.php b/lib/internal/Zend/Validator/LessThan.php index c29a2c3781e..90bcb5f3211 100644 --- a/lib/internal/Zend/Validator/LessThan.php +++ b/lib/internal/Zend/Validator/LessThan.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class LessThan extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/NotEmpty.php b/lib/internal/Zend/Validator/NotEmpty.php index 1c4c379de5f..137cddfd008 100644 --- a/lib/internal/Zend/Validator/NotEmpty.php +++ b/lib/internal/Zend/Validator/NotEmpty.php @@ -15,7 +15,7 @@ use Zend\Stdlib\ArrayUtils; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class NotEmpty extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Regex.php b/lib/internal/Zend/Validator/Regex.php index e4ced1dddf2..c7f9a4ba7bf 100644 --- a/lib/internal/Zend/Validator/Regex.php +++ b/lib/internal/Zend/Validator/Regex.php @@ -16,7 +16,7 @@ use Zend\Stdlib\ErrorHandler; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Regex extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Sitemap/Changefreq.php b/lib/internal/Zend/Validator/Sitemap/Changefreq.php index 66c7c7c9965..c75958425af 100644 --- a/lib/internal/Zend/Validator/Sitemap/Changefreq.php +++ b/lib/internal/Zend/Validator/Sitemap/Changefreq.php @@ -18,7 +18,7 @@ use Zend\Validator\AbstractValidator; * @link http://www.sitemaps.org/protocol.php Sitemaps XML format * * @category Zend - * @package Zend_Validate + * @package Zend_Validator * @subpackage Sitemap */ class Changefreq extends AbstractValidator diff --git a/lib/internal/Zend/Validator/Sitemap/Lastmod.php b/lib/internal/Zend/Validator/Sitemap/Lastmod.php index 8dd46046897..0339a5845e2 100644 --- a/lib/internal/Zend/Validator/Sitemap/Lastmod.php +++ b/lib/internal/Zend/Validator/Sitemap/Lastmod.php @@ -19,7 +19,7 @@ use Zend\Validator\AbstractValidator; * @link http://www.sitemaps.org/protocol.php Sitemaps XML format * * @category Zend - * @package Zend_Validate + * @package Zend_Validator * @subpackage Sitemap */ class Lastmod extends AbstractValidator diff --git a/lib/internal/Zend/Validator/Sitemap/Loc.php b/lib/internal/Zend/Validator/Sitemap/Loc.php index 6a200477ee6..1ae91711c12 100644 --- a/lib/internal/Zend/Validator/Sitemap/Loc.php +++ b/lib/internal/Zend/Validator/Sitemap/Loc.php @@ -20,7 +20,7 @@ use Zend\Validator\AbstractValidator; * * @see Zend\Uri\Uri * @category Zend - * @package Zend_Validate + * @package Zend_Validator * @subpackage Sitemap */ class Loc extends AbstractValidator diff --git a/lib/internal/Zend/Validator/Sitemap/Priority.php b/lib/internal/Zend/Validator/Sitemap/Priority.php index 113069c56ef..5a970d1c6c7 100644 --- a/lib/internal/Zend/Validator/Sitemap/Priority.php +++ b/lib/internal/Zend/Validator/Sitemap/Priority.php @@ -18,7 +18,7 @@ use Zend\Validator\AbstractValidator; * @link http://www.sitemaps.org/protocol.php Sitemaps XML format * * @category Zend - * @package Zend_Validate + * @package Zend_Validator * @subpackage Sitemap */ class Priority extends AbstractValidator diff --git a/lib/internal/Zend/Validator/StaticValidator.php b/lib/internal/Zend/Validator/StaticValidator.php index f7ddaab944e..0d9f0b25b16 100644 --- a/lib/internal/Zend/Validator/StaticValidator.php +++ b/lib/internal/Zend/Validator/StaticValidator.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class StaticValidator { diff --git a/lib/internal/Zend/Validator/Step.php b/lib/internal/Zend/Validator/Step.php index e598607c523..6478ce98c9e 100644 --- a/lib/internal/Zend/Validator/Step.php +++ b/lib/internal/Zend/Validator/Step.php @@ -14,7 +14,7 @@ use Traversable; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Step extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/StringLength.php b/lib/internal/Zend/Validator/StringLength.php index 781182c19e7..1587c2458ea 100644 --- a/lib/internal/Zend/Validator/StringLength.php +++ b/lib/internal/Zend/Validator/StringLength.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class StringLength extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/Uri.php b/lib/internal/Zend/Validator/Uri.php index 59ea3b472b8..6cdc8c8e0fb 100644 --- a/lib/internal/Zend/Validator/Uri.php +++ b/lib/internal/Zend/Validator/Uri.php @@ -17,7 +17,7 @@ use Zend\Validator\Exception\InvalidArgumentException; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ class Uri extends AbstractValidator { diff --git a/lib/internal/Zend/Validator/ValidatorInterface.php b/lib/internal/Zend/Validator/ValidatorInterface.php index 3179e6a7377..145f7535aa4 100644 --- a/lib/internal/Zend/Validator/ValidatorInterface.php +++ b/lib/internal/Zend/Validator/ValidatorInterface.php @@ -12,7 +12,7 @@ namespace Zend\Validator; /** * @category Zend - * @package Zend_Validate + * @package Zend_Validator */ interface ValidatorInterface { diff --git a/lib/internal/Zend/Validator/ValidatorPluginManager.php b/lib/internal/Zend/Validator/ValidatorPluginManager.php index 056486d9de3..cbed58bd5ab 100644 --- a/lib/internal/Zend/Validator/ValidatorPluginManager.php +++ b/lib/internal/Zend/Validator/ValidatorPluginManager.php @@ -89,7 +89,7 @@ class ValidatorPluginManager extends AbstractPluginManager 'greaterthan' => 'Zend\Validator\GreaterThan', 'hex' => 'Zend\Validator\Hex', 'hostname' => 'Zend\Validator\Hostname', - 'iban' => 'Zend\I18n\Validator\Iban', + 'iban' => 'Zend\Validator\Iban', 'identical' => 'Zend\Validator\Identical', 'inarray' => 'Zend\Validator\InArray', 'int' => 'Zend\I18n\Validator\Int', diff --git a/lib/internal/Zend/Validator/composer.json b/lib/internal/Zend/Validator/composer.json index 015a02a2b04..e2a0bffed04 100644 --- a/lib/internal/Zend/Validator/composer.json +++ b/lib/internal/Zend/Validator/composer.json @@ -8,13 +8,14 @@ ], "autoload": { "psr-0": { - "Zend\\Validator": "" + "Zend\\Validator\\": "" } }, "target-dir": "Zend/Validator", "require": { "php": ">=5.3.3", "zendframework/zend-i18n": "self.version", + "zendframework/zend-servicemanager": "self.version", "zendframework/zend-stdlib": "self.version" }, "require-dev": { diff --git a/lib/web/app-config.js b/lib/web/app-config.js index 33624b19c68..2b3bda7d3f6 100644 --- a/lib/web/app-config.js +++ b/lib/web/app-config.js @@ -21,6 +21,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ require.config({ + "waitSeconds":"0", "shim": { "jquery/bootstrap-carousel/jquery.bootstrap-carousel": ["jquery"], // no longer used "jquery/bootstrap-carousel/jquery.bootstrap-transition": ["jquery"], // no longer used diff --git a/lib/web/css/docs/source/actions-toolbar.less b/lib/web/css/docs/source/actions-toolbar.less index 2db4d8c8efa..17dd72fac90 100644 --- a/lib/web/css/docs/source/actions-toolbar.less +++ b/lib/web/css/docs/source/actions-toolbar.less @@ -391,7 +391,7 @@ .actions-toolbar(); } -@media only screen and (max-width : @break-point-1) { +@media only screen and (max-width: @screen-m) { .example-actions-toolbar-12 { .actions-toolbar-clear-floats(); } diff --git a/lib/web/css/docs/source/sections.less b/lib/web/css/docs/source/sections.less index 25304a986d9..e940bddb9ad 100644 --- a/lib/web/css/docs/source/sections.less +++ b/lib/web/css/docs/source/sections.less @@ -523,7 +523,7 @@ } } -@media only screen and (max-width: @break-point-1) { +@media only screen and (max-width: @screen-m) { .example-sections-4 { .data-accordion(); } diff --git a/lib/web/css/docs/source/tables.less b/lib/web/css/docs/source/tables.less index 3044594a5eb..e32732c546c 100644 --- a/lib/web/css/docs/source/tables.less +++ b/lib/web/css/docs/source/tables.less @@ -1456,7 +1456,7 @@ .table-hover(); } -@media only screen and (max-width : @break-point-1) { +@media only screen and (max-width: @screen-m) { .example-table-14 { .table-overflow(); } @@ -1533,7 +1533,7 @@ .table-hover(); } -@media only screen and (max-width : @break-point-1) { +@media only screen and (max-width: @screen-m) { .example-table-15 { .table-responsive( @_table-bg-responsive: #fc0, diff --git a/lib/web/css/source/lib/abstract.less b/lib/web/css/source/lib/abstract.less index ad977b19d1d..ee29be2b227 100644 --- a/lib/web/css/source/lib/abstract.less +++ b/lib/web/css/source/lib/abstract.less @@ -22,7 +22,7 @@ // * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) // */ -.responsive(@break) when (@break = @break-point-1) { +.responsive(@break) when (@break = @screen-m) { ._rwd_width { min-width: 0 !important; max-width: auto !important; @@ -33,5 +33,5 @@ } } -.responsive-smaller(@break) when (@break = @break-point-0) { +.responsive-smaller(@break) when (@break = @screen-s) { } diff --git a/lib/web/css/source/lib/buttons.less b/lib/web/css/source/lib/buttons.less index 6390d4280ed..c004f2c967f 100644 --- a/lib/web/css/source/lib/buttons.less +++ b/lib/web/css/source/lib/buttons.less @@ -32,7 +32,7 @@ @_button-cursor: @button-cursor, // button cursor @_button-display: @button-display, // button display @_button-disabled-opacity: @button-disabled-opacity, // button disabled opacity - @_button-height: @button-height, // button height + @_button-line-height: @button-line-height, // button line height @_button-width: @button-width, // button width @_button-margin: @button-margin, // margins of the button @_button-padding: @button-padding, // paddings of the button @@ -83,7 +83,7 @@ .css(font-family, @_button-font-family); .font-size(@_button-font-size); .css(font-weight, @_button-font-weight); - .css(line-height, @_button-height); + .line-height(@_button-line-height); //-moz-box-sizing: content-box; // fix Firefox button line-height problem .box-sizing(); .css(margin, @_button-margin); @@ -137,25 +137,25 @@ // // Button size -//-------------------------------------- */ +//-------------------------------------- .button-size( - @_button-height: @button-height, + @_button-line-height: @button-line-height, @_button-padding: @button-padding ){ - .css(line-height, @_button-height); + .line-height(@_button-line-height); .css(padding, @_button-padding); } // // Large buttons -//-------------------------------------- */ +//-------------------------------------- .button-l( @_button-l-font-size: @button-l-font-size, - @_button-l-height: @button-l-height, + @_button-l-height: @button-l-line-height, @_button-l-padding: @button-l-padding ) { .button-size( - @_button-height: @_button-l-height, + @_button-line-height: @_button-l-height, @_button-padding: @_button-l-padding ); .font-size(@_button-l-font-size); @@ -163,14 +163,14 @@ // // Small buttons -//-------------------------------------- */ +//-------------------------------------- .button-s( @_button-s-font-size: @button-s-font-size, - @_button-s-height: @button-s-height, + @_button-s-height: @button-s-line-height, @_button-s-padding: @button-s-padding ) { .button-size( - @_button-height: @_button-s-height, + @_button-line-height: @_button-s-height, @_button-padding: @_button-s-padding ); .font-size(@_button-s-font-size); @@ -178,7 +178,7 @@ // // Link as button -//-------------------------------------- */ +//-------------------------------------- .link-as-button() { .css(display, @button-display); text-decoration: none; @@ -191,7 +191,7 @@ // // Button as link -//-------------------------------------- */ +//-------------------------------------- .button-as-link( @_link-color: @link-color, @_link-color-hover: @link-color-hover, @@ -228,14 +228,14 @@ // // Responsive -//-------------------------------------- */ +//-------------------------------------- .button-responsive() { width: 100%; } // // Button reset -//-------------------------------------- */ +//-------------------------------------- .button-reset() { background-image: none; // Reset unusual Firefox-on-Android default style background: none; @@ -269,9 +269,9 @@ // // Button primary -//-------------------------------------- */ +//-------------------------------------- .button-primary( - @_button-height: @button-primary-height, + @_button-line-height: @button-primary-line-height, @_button-width: @button-primary-width, @_button-margin: @button-primary-margin, @_button-padding: @button-primary-padding, @@ -294,7 +294,7 @@ @_button-gradient-direction: @button-primary-gradient-direction ) { .button( - @_button-height: @_button-height, + @_button-line-height: @_button-line-height, @_button-width: @_button-width, @_button-margin: @_button-margin, @_button-padding: @_button-padding, @@ -320,7 +320,7 @@ // // Button revert secondary color -//-------------------------------------- */ +//-------------------------------------- .button-revert-secondary-color( @_button-color: @button-color, @_button-background: @button-background, @@ -352,23 +352,22 @@ // // Button revert secondary size -//-------------------------------------- */ +//-------------------------------------- .button-revert-secondary-size( @_button-font-size: @button-font-size, - @_button-height: @button-height, + @_button-line-height: @button-line-height, @_button-padding: @button-padding ) { .font-size(@_button-font-size); .button-size( - @_button-height: @_button-height, + @_button-line-height: @_button-line-height, @_button-padding: @_button-padding ) } // // Inner buttons mixins -//-------------------------------------- */ - +//-------------------------------------- ._button-icon ( @_button-icon-use: @button-icon-use, @_icon-font-content: @button-font-content, diff --git a/lib/web/css/source/lib/forms.less b/lib/web/css/source/lib/forms.less index abd46c86f4a..15d522129a0 100644 --- a/lib/web/css/source/lib/forms.less +++ b/lib/web/css/source/lib/forms.less @@ -780,24 +780,24 @@ content: " "; height: 1px; float: left; - .css(width, @_type-inline-label-width); .css(padding, @_type-inline-label-padding); + .css(width, @_type-inline-label-width); } .description { .box-sizing(); float: left; + .css(padding, @_type-inline-label-padding); .css(text-align, @_type-inline-label-align); .css(width, @_type-inline-label-width); - .css(padding, @_type-inline-label-padding); } &:not(.choice) { > .label { .box-sizing(); float: left; + .css(margin, @_type-inline-label-margin); + .css(padding, @_type-inline-label-padding); .css(text-align, @_type-inline-label-align); .css(width, @_type-inline-label-width); - .css(padding, @_type-inline-label-padding); - .css(margin, @_type-inline-label-margin); } > .control { float: left; @@ -819,8 +819,6 @@ .css(margin, @_type-block-label-margin); .css(padding, @_type-block-label-padding); } - .control { - } } ._form-field-required( @@ -952,7 +950,7 @@ @_type-block-label-padding: @form-field-type-block-label-padding, @_type-block-label-align: @form-field-type-block-label-align ) when (@_type = inline) and not (@_type = false) { - > .label { + > .label { ._revert-type-inline-label-margin( @_type-inline-label-margin ); diff --git a/lib/web/css/source/lib/icons.less b/lib/web/css/source/lib/icons.less index 057aab40747..dddae1fab03 100644 --- a/lib/web/css/source/lib/icons.less +++ b/lib/web/css/source/lib/icons.less @@ -46,7 +46,7 @@ @_icon-font-text-hide: @icon-font-text-hide, @_icon-font-display: @icon-font-display ) when (@_icon-font-position = before) { - display: @_icon-font-display; + .css(display, @_icon-font-display); text-decoration: none; ._icon-text-hide(@_icon-font-text-hide); @@ -87,7 +87,7 @@ @_icon-font-text-hide: @icon-font-text-hide, @_icon-font-display: @icon-font-display ) when (@_icon-font-position = after) { - display: @_icon-font-display; + .css(display, @_icon-font-display); text-decoration: none; ._icon-text-hide(@_icon-font-text-hide); &:after { diff --git a/lib/web/css/source/lib/messages.less b/lib/web/css/source/lib/messages.less index 69396a5a1a8..aefb43ac46b 100644 --- a/lib/web/css/source/lib/messages.less +++ b/lib/web/css/source/lib/messages.less @@ -29,6 +29,10 @@ @_message-link-color: "message-@{_message-type}-link-color"; @_message-link-color-hover: "message-@{_message-type}-link-color-hover"; @_message-link-color-active: "message-@{_message-type}-link-color-active"; + @_message-icon-top: "message-@{_message-type}-icon-top"; + @_message-icon-right: "message-@{_message-type}-icon-right"; + @_message-icon-bottom: "message-@{_message-type}-icon-bottom"; + @_message-icon-left: "message-@{_message-type}-icon-left"; ._message(); ._message-style( @_message-color: @@_message-color, @@ -87,7 +91,7 @@ @_message-border-style: @message-border-style ) when not (@_message-border-width = 0) and not (@_message-border-width = false) -and not ( @_message-border-style = false) { +and not (@_message-border-style = false) { .css(border, @_message-border-width @_message-border-style); } @@ -99,12 +103,20 @@ and not ( @_message-border-style = false) { @_message-icon: "message-@{_message-type}-icon"; @_message-icon-color: "message-@{_message-type}-icon-color-lateral"; @_message-icon-background: "message-@{_message-type}-icon-background"; + @_message-icon-top: "message-@{_message-type}-icon-top"; + @_message-icon-right: "message-@{_message-type}-icon-right"; + @_message-icon-bottom: "message-@{_message-type}-icon-bottom"; + @_message-icon-left: "message-@{_message-type}-icon-left"; ._message-icon-lateral( - @_message-icon-position, - @@_message-icon, - @@_message-icon-color, - @@_message-icon-background - ); + @_message-icon-position, + @@_message-icon, + @@_message-icon-color, + @@_message-icon-background, + @@_message-icon-top, + @@_message-icon-left, + @@_message-icon-bottom, + @@_message-icon-right + ); } // Messages with inner icon @@ -114,10 +126,18 @@ and not ( @_message-border-style = false) { @_message-icon: "message-@{_message-type}-icon"; @_message-icon-color: "message-@{_message-type}-icon-color-inner"; @_message-icon-background: "message-@{_message-type}-icon-background"; + @_message-icon-top: "message-@{_message-type}-icon-top"; + @_message-icon-right: "message-@{_message-type}-icon-right"; + @_message-icon-bottom: "message-@{_message-type}-icon-bottom"; + @_message-icon-left: "message-@{_message-type}-icon-left"; ._message-icon-inner( @@_message-icon, @@_message-icon-color, - @@_message-icon-background + @@_message-icon-background, + @@_message-icon-top, + @@_message-icon-left, + @@_message-icon-bottom, + @@_message-icon-right ); } @@ -126,7 +146,11 @@ and not ( @_message-border-style = false) { @_message-icon-position, @_message-icon, @_message-icon-color, - @_message-icon-background + @_message-icon-background, + @_message-icon-top, + @_message-icon-left, + @_message-icon-bottom, + @_message-icon-right ) { position: relative; &:before { @@ -153,12 +177,15 @@ and not ( @_message-border-style = false) { @_icon-font: @icon-font, @_icon-font-size: @message-icon-font-size, @_icon-font-line-height: @message-icon-font-line-height, - @_icon-font-color: @_message-icon-color, + @_icon-font-color: @_message-icon-color, @_icon-font-margin: -@message-icon-font-size/2 0 0, @_icon-font-vertical-align: @icon-font-vertical-align ); position: absolute; - top: 50%; + .css(top, @_message-icon-top); + .css(right, @_message-icon-right); + .css(bottom, @_message-icon-bottom); + .css(left, @_message-icon-left); text-align: center; .css(width, @message-icon-lateral-width); } @@ -205,13 +232,13 @@ and not ( @_message-border-style = false) { } ._message-icon-lateral-border-radius( - @_message-icon-position, + @_message-icon-position ) when (@_message-icon-position = left) and not (@message-border-radius = false) and not (@message-border-width = false) { border-radius: (@message-border-radius - @message-border-width) 0 0 (@message-border-radius - @message-border-width); } ._message-icon-lateral-border-radius( - @_message-icon-position, + @_message-icon-position ) when (@_message-icon-position = right) and not (@message-border-radius = false) and not (@message-border-width = false) { border-radius: 0 (@message-border-radius - @message-border-width) (@message-border-radius - @message-border-width) 0; } @@ -219,7 +246,11 @@ and not ( @_message-border-style = false) { ._message-icon-inner( @_message-icon, @_message-icon-color, - @_message-icon-background + @_message-icon-background, + @_message-icon-top, + @_message-icon-left, + @_message-icon-bottom, + @_message-icon-right ) { position: relative; .css(padding-left, @message-icon-inner-padding-left); @@ -234,8 +265,10 @@ and not ( @_message-border-style = false) { @_icon-font-vertical-align: @icon-font-vertical-align ); position: absolute; - left: 0; - top: 50%; + .css(top, @_message-icon-top); + .css(right, @_message-icon-right); + .css(bottom, @_message-icon-bottom); + .css(left, @_message-icon-left); text-align: center; .css(width, @message-icon-inner-padding-left); } diff --git a/lib/web/css/source/lib/navigation.less b/lib/web/css/source/lib/navigation.less index fbdb96fed5f..39fd7092847 100644 --- a/lib/web/css/source/lib/navigation.less +++ b/lib/web/css/source/lib/navigation.less @@ -62,13 +62,6 @@ .navigation { .css(background, @_nav-bg); .css(border, @_nav-border); - display: block; - left: -86%; - top: 180px; - overflow: auto; - position: absolute; - width: 86%; - padding: 10px 0px; .box-sizing(); ul { margin: 0; @@ -126,7 +119,7 @@ } } &.expanded { - display: block !important; + display: block !important; top: 0 !important; } .active > a { @@ -197,133 +190,136 @@ @_submenu-item-color-active: @submenu-desktop-item-color-active, @_submenu-item-text-decoration-active: @submenu-desktop-item-text-decoration-active ) { - .responsive(@break) when (@break = @break-point-1) { - .navigation { - .css(background, @_nav-bg); - .css(border, @_nav-border); - .css(font-size, @_nav-font-size); - .css(font-weight, @_nav-font-weight); - height: inherit; - left: auto; - overflow: inherit; - position: relative; - top: 0; - width: 100%; - z-index: 3; + + .navigation { + .css(background, @_nav-bg); + .css(border, @_nav-border); + .css(font-size, @_nav-font-size); + .css(font-weight, @_nav-font-weight); + height: inherit; + left: auto; + overflow: inherit; + position: relative; + top: 0; + width: 100%; + z-index: 3; + padding: 0; + &:empty { + display: none; + } + ul { + margin-top: 0; + margin-bottom: 0; padding: 0; - &:empty { - display: none; - } - ul { - margin-top: 0; - margin-bottom: 0; - padding: 0; - position: relative; - } - li.level0 { - .css(border-top, none); + position: relative; + } + li.level0 { + .css(border-top, none); + } + .level0 { + display: inline-block; + position: relative; + .css(margin, @_nav-level0-item-margin); + + &:last-child { + margin-right: 0; + padding-right: 0; } - .level0 { - display: inline-block; + > .level-top { + .box-sizing(); + .css(background, @_nav-level0-item-bg); + .css(border, @_nav-level0-item-border); + .css(color, @_nav-level0-item-color); + .css(line-height, @_nav-level0-item-line-height); + .css(padding, @_nav-level0-item-padding); + .css(text-decoration, @_nav-level0-item-text-decoration); position: relative; - .css(margin, @_nav-level0-item-margin); - - &:last-child { - margin-right: 0; - padding-right: 0; + &:hover, &.ui-state-focus { + .css(background, @_nav-level0-item-bg-hover); + .css(border, @_nav-level0-item-border-hover); + .css(color, @_nav-level0-item-color-hover); + .css(text-decoration, @_nav-level0-item-text-decoration-hover); } + } + &.active { > .level-top { - .box-sizing(); - .css(background, @_nav-level0-item-bg); - .css(border, @_nav-level0-item-border); - .css(color, @_nav-level0-item-color); - .css(line-height, @_nav-level0-item-line-height); - .css(padding, @_nav-level0-item-padding); - .css(text-decoration, @_nav-level0-item-text-decoration); - position: relative; + .css(background, @_nav-level0-item-bg-active); + .css(border, @_nav-level0-item-border-active); + .css(color, @_nav-level0-item-color-active); + .css(text-decoration, @_nav-level0-item-text-decoration-active); + } + } + &.parent:hover > .submenu { + overflow: visible !important; + } + .ui-menu { + .css(font-size, @_submenu-font-size); + .css(font-weight, @_submenu-font-weight); + left: 0; + .css(min-width, @_submenu-min-width); + position: absolute; + padding: 0; + margin: 0 !important; + top: 100%; + z-index: 1; + .css(background, @_submenu-bg); + .css(border, @_submenu-border-width @_submenu-border-style @_submenu-border-color); + .css(box-shadow, @_submenu-box-shadow); + .css(padding, @_submenu-padding); + ._submenu-arrow( + @_submenu-arrow, + @_bg: @_submenu-bg, + @_border: @_submenu-border-color, + @_size: @_submenu-arrow-size, + @_left: @_submenu-arrow-left + ); + a { + display: block; + line-height: inherit; + .css(background, @_submenu-item-bg); + .css(border, @_submenu-item-border); + .css(color, @_submenu-item-color); + .css(padding, @_submenu-item-padding); + .css(text-decoration, @_submenu-item-text-decoration); &:hover, &.ui-state-focus { - .css(background, @_nav-level0-item-bg-hover); - .css(border, @_nav-level0-item-border-hover); - .css(color, @_nav-level0-item-color-hover); - .css(text-decoration, @_nav-level0-item-text-decoration-hover); + .css(background, @_submenu-item-bg-hover); + .css(border, @_submenu-item-border-hover); + .css(color, @_submenu-item-color-hover); + .css(text-decoration, @_submenu-item-text-decoration-hover); } } - &.active { - > .level-top { - .css(background, @_nav-level0-item-bg-active); - .css(border, @_nav-level0-item-border-active); - .css(color, @_nav-level0-item-color-active); - .css(text-decoration, @_nav-level0-item-text-decoration-active); - } + .active > a { + .css(background, @_submenu-item-bg-active); + .css(border, @_submenu-item-border-active); + .css(color, @_submenu-item-color-active); + .css(text-decoration, @_submenu-item-text-decoration-active); } - &.parent:hover > .submenu { - overflow: visible !important; + .ui-menu { + top: 0 !important; + left: 100%!important; } - > .ui-menu { - .css(font-size, @_submenu-font-size); - .css(font-weight, @_submenu-font-weight); - left: 0; - .css(min-width, @_submenu-min-width); - position: absolute; - padding: 0; - margin: 0 !important; - top: 100%; - z-index: 1; - .css(background, @_submenu-bg); - .css(border, @_submenu-border-width @_submenu-border-style @_submenu-border-color); - .css(box-shadow, @_submenu-box-shadow); - .css(padding, @_submenu-padding); - ._submenu-arrow( - @_submenu-arrow, - @_bg: @_submenu-bg, - @_border: @_submenu-border-color, - @_size: @_submenu-arrow-size, - @_left: @_submenu-arrow-left - ); - a { - display: block; - line-height: inherit; - .css(background, @_submenu-item-bg); - .css(border, @_submenu-item-border); - .css(color, @_submenu-item-color); - .css(padding, @_submenu-item-padding); - .css(text-decoration, @_submenu-item-text-decoration); - &:hover, &.ui-state-focus { - .css(background, @_submenu-item-bg-hover); - .css(border, @_submenu-item-border-hover); - .css(color, @_submenu-item-color-hover); - .css(text-decoration, @_submenu-item-text-decoration-hover); - } - } - .active > a { - .css(background, @_submenu-item-bg-active); - .css(border, @_submenu-item-border-active); - .css(color, @_submenu-item-color-active); - .css(text-decoration, @_submenu-item-text-decoration-active); - } + } + &.more { + position: relative; + .icon-font( + @icon-pointer-down, + @_icon-font-size: 26px, + @_icon-font-position: after + ); + &:before { + display: none; } - &.more { + &:after { + cursor: pointer; + padding: 8px 12px; position: relative; - .icon-font( - @icon-pointer-down, - @_icon-font-size: 26px, - @_icon-font-position: after - ); - &:before { - display: none; - } - &:after { - cursor: pointer; - padding: 8px 12px; - position: relative; - z-index: 1; - } - &:hover > .submenu { - overflow: visible !important; - } - li { - display: block; - } + z-index: 1; + } + &:hover > .submenu { + overflow: visible !important; + } + li { + display: block; } } } diff --git a/lib/web/css/source/lib/rating.less b/lib/web/css/source/lib/rating.less index 896bc218770..cd972686896 100644 --- a/lib/web/css/source/lib/rating.less +++ b/lib/web/css/source/lib/rating.less @@ -103,6 +103,7 @@ @_icon-color-active: @rating-icon-color-active, @_label-hide: @rating-label-hide ) { + white-space: nowrap; overflow: hidden; ._rating-label-hide(@_label-hide); .rating-result { diff --git a/lib/web/css/source/lib/resets.less b/lib/web/css/source/lib/resets.less index 167ad936816..c630893c3d5 100644 --- a/lib/web/css/source/lib/resets.less +++ b/lib/web/css/source/lib/resets.less @@ -94,7 +94,7 @@ .form-element-all(); address { - font-style: normal + font-style: normal; } } @@ -370,70 +370,70 @@ article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { - margin:0; - padding:0; - border:0; - outline:0; - font-size:100%; - vertical-align:baseline; - background:transparent; + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; } body { - line-height:1; + line-height: 1; } - article,aside,details,figcaption,figure, - footer,header,hgroup,menu,nav,section { - display:block; + article, aside, details, figcaption, figure, + footer, header, hgroup, menu, nav, section { + display: block; } nav ul { - list-style:none; + list-style: none; } blockquote, q { - quotes:none; + quotes: none; } blockquote:before, blockquote:after, q:before, q:after { - content:''; - content:none; + content: ''; + content: none; } a { - margin:0; - padding:0; - font-size:100%; - vertical-align:baseline; - background:transparent; + margin: 0; + padding: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; } ins { - background-color:#ff9; - color:#000; - text-decoration:none; + background-color: #ff9; + color: #000; + text-decoration: none; } mark { - background-color:#ff9; - color:#000; - font-style:italic; - font-weight:bold; + background-color: #ff9; + color: #000; + font-style: italic; + font-weight: bold; } del { text-decoration: line-through; } abbr[title], dfn[title] { - border-bottom:1px dotted; - cursor:help; + border-bottom: 1px dotted; + cursor: help; } table { - border-collapse:collapse; - border-spacing:0; + border-collapse: collapse; + border-spacing: 0; } hr { - display:block; - height:1px; - border:0; - border-top:1px solid #cccccc; - margin:1em 0; - padding:0; + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0; } input, select { - vertical-align:middle; + vertical-align: middle; } } diff --git a/lib/web/css/source/lib/responsive.less b/lib/web/css/source/lib/responsive.less index ac1a4d76ec0..912a240473b 100644 --- a/lib/web/css/source/lib/responsive.less +++ b/lib/web/css/source/lib/responsive.less @@ -23,24 +23,28 @@ // */ // Small screens only -.responsive-smaller(@break-point-0) {} +.responsive-smaller(@screen-s) {} -@media all and (max-width: @break-point-0) { - .responsive-smaller(@break-point-0); +@media all and (max-width: @screen-xs) { + .responsive-smaller(@screen-xs); } -@media all and (max-width: @break-point-1) { - .responsive-smaller(@break-point-1); +@media all and (max-width: @screen-s) { + .responsive-smaller(@screen-s); } -@media all and (min-width: @break-point-0) { - .responsive(@break-point-0); +@media all and (max-width: @screen-m) { + .responsive-smaller(@screen-m); } -@media all and (min-width: @break-point-1) { - .responsive(@break-point-1); +@media all and (min-width: @screen-s) { + .responsive(@screen-s); } -@media all and (min-width: @break-point-2) { - .responsive(@break-point-2); +@media all and (min-width: @screen-m) { + .responsive(@screen-m); +} + +@media all and (min-width: @screen-l) { + .responsive(@screen-l); } diff --git a/lib/web/css/source/lib/typography.less b/lib/web/css/source/lib/typography.less index a49e62d334e..d6962e22dbc 100644 --- a/lib/web/css/source/lib/typography.less +++ b/lib/web/css/source/lib/typography.less @@ -53,6 +53,19 @@ font-size: @sizeValue; } +// Rem line height +.line-height(@heightValue) when not (@heightValue = false) and not (ispercentage(@heightValue)) { + @value: unit(@heightValue); + @remValue: (@value / @font-rem-ratio); + @pxValue: @value; + line-height: ~"@{pxValue}px"; + line-height: ~"@{remValue}rem"; +} + +.line-height(@heightValue) when (ispercentage(@heightValue)) and not (@heightValue = false) { + line-height: @heightValue; +} + .wrap-words() { -ms-word-break: break-all; word-break: break-all; @@ -164,7 +177,6 @@ .margin-vertical-rem(@@_margin-top, @@_margin-bottom); } - // // Base typography //-------------------------------------- diff --git a/lib/web/css/source/lib/variables.less b/lib/web/css/source/lib/variables.less index 1242f524db3..66aec212956 100644 --- a/lib/web/css/source/lib/variables.less +++ b/lib/web/css/source/lib/variables.less @@ -25,7 +25,7 @@ // Typography //-------------------------------------- -// Base +// Base @font-family-sans-serif: 'Helvetica Neue', Helvetica, Arial, sans-serif; @font-family-serif: Georgia, 'Times New Roman', Times, serif; @font-family-monospace: Menlo, Monaco, Consolas, 'Courier New', monospace; @@ -34,10 +34,10 @@ @icon-font-name: 'icons-blank-theme'; @color-primary: #333; -@color-primary-dark: darken(@color-primary, 35%); // #000 +@color-primary-dark: darken(@color-primary, 35%); // #000 @color-primary-darker: darken(@color-primary, 13.5%); // #111 -@color-primary-lighter: lighten(@color-primary, 29%); // #7d7d7d -@color-primary-light: lighten(@color-primary, 45%); // #a6a6a6 +@color-primary-lighter: lighten(@color-primary, 29%); // #7d7d7d +@color-primary-light: lighten(@color-primary, 45%); // #a6a6a6 @color-secondary: #e8e8e8; @color-secondary-light: lighten(@color-secondary, 5%); @page-bg-color: #fff; @@ -55,7 +55,7 @@ @font-size-base: unit((@font-size-root / 100) * 16 * @font-size-base-ratio, px); // Also used in: @loader-text-font-size @font-size-xl: ceil(1.5 * @font-size-base); @font-size-l: ceil(1.25 * @font-size-base); -@font-size-s: ceil(0.85 * @font-size-base); // Also used in: Breadcrumbs and in Small button +@font-size-s: ceil(0.85 * @font-size-base); // Also used in: Breadcrumbs and in Small button @font-size-xs: floor(0.75 * @font-size-base); @font-weight-base: 400; @@ -84,9 +84,7 @@ @border-color-base: darken(@page-bg-color, 18%); @border-width-base: 1px; - -//Links - +// Links @link-color: #1979c3; @link-text-decoration: none; @@ -100,8 +98,8 @@ @link-text-decoration-active: underline; // Lists -@list-color-base: ''; //@text-color -@list-font-size-base: false; //@font-size-base +@list-color-base: ''; // @text-color +@list-font-size-base: false; // @font-size-base @list-margin-top: 0; @list-margin-bottom: @indent-m-base; @list-item-margin-top: 0; @@ -119,12 +117,12 @@ @p-margin-top: 0; @p-margin-bottom: @indent-s-base; -//Headings -@heading-font-family-base: false; //@font-family-base +// Headings +@heading-font-family-base: false; // @font-family-base @heading-font-weight-base: @font-weight-light; @heading-line-height-base: 1.1; -@heading-color-base: false; //@text-color -@heading-font-style-base: false; //@font-style-base +@heading-color-base: false; // @text-color +@heading-font-style-base: false; // @font-style-base @heading-margin-top-base: @indent-base; @heading-margin-bottom-base: @indent-base; @@ -200,9 +198,7 @@ @kbd-color: @color-primary-darker; @kbd-bg: @panel-bg; - // Blockquote - @blockquote-font-size: @font-size-base; @blockquote-font-style: @font-style-emphasis; @blockquote-border-color: @border-color-base; @@ -215,7 +211,6 @@ @cite-font-style: @font-style-base; // Misc - @hr-border-color: @border-color-base; @hr-border-style: solid; @hr-border-width: 1px; @@ -246,7 +241,7 @@ @table-border-width: @border-width-base; @table-border-style: solid; -@table-caption-hide: false; //Default value false, set true to hide caption +@table-caption-hide: false; // Default value false, set true to hide caption @table-caption-font-size: @font-size-l; @table-caption-color: @text-color-intense; @table-caption-font-family: false; @@ -310,25 +305,28 @@ @layout-column-main-width-2-right: @layout-columns-width - @layout-column-right-width; @layout-column-main-width-3: @layout-columns-width - @layout-column-left-width - @layout-column-right-width; -// Checkout columns width +// Checkout columns width @layout-column-checkout-left-width: 3; @layout-column-checkout-main-width: @layout-columns-width - @layout-column-checkout-left-width; // // Responsive //-------------------------------------- + // Settings variables (TO DO: should be global) @use-flex: true; // Use flexbox [true|false] @responsive: true; // Theme is responsive [true|false] -@break-point-0: 600px; // catalog products in a row: (width <= 599) - 2 columns, (600 <= width <= 768) - 3 columns, (768 < width ) - 4 columns -@break-point-1: 768px; // main breakpoint -@break-point-2: 800px; // checkout and catalog 3 columns layout breakpoint +@screen-xxs: 320px; +@screen-xs: 400px; +@screen-s: 640px; +@screen-m: 768px; +@screen-l: 1000px; +@screen-xl: 1440px; // // Navigation variables //-------------------------------------- - @navigation-background: @color-secondary-light; @navigation-border: ''; @navigation-level0-font-size: 16; @@ -365,8 +363,8 @@ @submenu-item-color-active: ''; @submenu-item-text-decoration-active: ''; -// Desktop navigation -@navigation-desktop-background: @color-secondary; +// Desktop navigation +@navigation-desktop-background: @navigation-background; @navigation-desktop-border: ''; @navigation-desktop-font-size: ''; @navigation-desktop-font-weight: @font-weight-bold; @@ -420,15 +418,13 @@ @submenu-desktop-item-color-active: ''; @submenu-desktop-item-text-decoration-active: ''; - - // // Sections variables //-------------------------------------- -// Tabs +// Tabs -// Tabs controls +// Tabs controls @tab-control-font-size: @font-size-base; @tab-control-font-family: @font-family-base; @tab-control-font-weight: @font-weight-semibold; @@ -476,7 +472,7 @@ @tab-content-padding-left: @tab-content-padding-right; @tab-content-padding-bottom: @tab-content-padding-top; -// Accordions variables +// Accordions variables @accordion-control-font-family: @tab-control-font-family; @accordion-control-font-size: @font-size-l; @accordion-control-font-style: @tab-control-font-style; @@ -526,9 +522,9 @@ @button-font-family: @font-family-base; @button-font-size: @font-size-base; @button-font-weight: @font-weight-bold; -@button-height: 30px; +@button-line-height: @font-size-base + 2; @button-margin: 0; -@button-padding: 0 15px; // is set up to false when buttons don't depend of side paddings or have fixed width, Also used in @button-primary-padding +@button-padding: 7px 15px; // is set up to false when buttons don't depend of side paddings or have fixed width, Also used in @button-primary-padding @button-width: ''; // is set up to false when buttons depend of side paddings or to fixed value when needed // Buttons display settings @@ -557,7 +553,7 @@ @button-gradient-end-color-active: false; // Primary button -@button-primary-height: 30px; +@button-primary-line-height: false; @button-primary-width: false; @button-primary-margin: false; @button-primary-padding: @button-padding; @@ -592,7 +588,7 @@ @button-font-content: @icon-settings; @button-icon-font: @icon-font; // Also used in: @popup-icon-font @button-icon-font-size: 22px; // Also used in: @popup-icon-font-size -@button-icon-font-line-height: @icon-font-line-height; // Also used in: @popup-icon-font-line-height +@button-icon-font-line-height: @button-icon-font-size; // Also used in: @popup-icon-font-line-height @button-icon-font-color: inherit; // Also used in: @popup-icon-font-color @button-icon-font-color-hover: inherit; // Also used in: @popup-icon-font-color-hover @button-icon-font-color-active: inherit; // Also used in: @popup-icon-font-color-active @@ -603,12 +599,13 @@ // Large button @button-l-font-size: @font-size-l; -@button-l-padding: 0 17px; -@button-l-height: 50px; +@button-l-line-height: @font-size-l + 4; +@button-l-padding: 14px 17px; + // Small button @button-s-font-size: 11px; -@button-s-padding: 0 8px; -@button-s-height: 22px; +@button-s-line-height: @button-s-font-size + 1; +@button-s-padding: 5px 8px; // // Icons variables @@ -699,6 +696,10 @@ @message-icon-inner-padding-left: 40px; @message-icon-lateral-width: 30px; @message-icon-lateral-arrow-size: 5px; +@message-icon-top: 18px; +@message-icon-right: false; +@message-icon-bottom: false; +@message-icon-left: 0; @message-border-width: false; @message-border-color: false; @@ -716,6 +717,10 @@ @message-info-icon-color-inner: #c07600; @message-info-icon-color-lateral: #fff; @message-info-icon-background: #6f4400; +@message-info-icon-top: @message-icon-top; +@message-info-icon-right: @message-icon-right; +@message-info-icon-bottom: @message-icon-bottom; +@message-info-icon-left: @message-icon-left; // Warning message @message-warning-color: @message-info-color; @@ -728,6 +733,10 @@ @message-warning-icon-color-inner: @message-info-icon-color-inner; @message-warning-icon-color-lateral: @message-info-icon-color-lateral; @message-warning-icon-background: @message-info-icon-background; +@message-warning-icon-top: @message-icon-top; +@message-warning-icon-right: @message-icon-right; +@message-warning-icon-bottom: @message-icon-bottom; +@message-warning-icon-left: @message-icon-left; // Error message @message-error-color: @color-error; @@ -740,6 +749,10 @@ @message-error-icon-color-inner: #b30000; @message-error-icon-color-lateral: #fff; @message-error-icon-background: #b30000; +@message-error-icon-top: @message-icon-top; +@message-error-icon-right: @message-icon-right; +@message-error-icon-bottom: @message-icon-bottom; +@message-error-icon-left: @message-icon-left; // Success message @message-success-color: #006400; @@ -752,6 +765,10 @@ @message-success-icon-color-inner: #006400; @message-success-icon-color-lateral: #fff; @message-success-icon-background: #006400; +@message-success-icon-top: @message-icon-top; +@message-success-icon-right: @message-icon-right; +@message-success-icon-bottom: @message-icon-bottom; +@message-success-icon-left: @message-icon-left; // Notice message @message-notice-color: @message-info-color; @@ -764,6 +781,10 @@ @message-notice-icon-color-inner: @message-info-icon-color-inner; @message-notice-icon-color-lateral: @message-info-icon-color-lateral; @message-notice-icon-background: @message-info-icon-background; +@message-notice-icon-top: @message-icon-top; +@message-notice-icon-right: @message-icon-right; +@message-notice-icon-bottom: @message-icon-bottom; +@message-notice-icon-left: @message-icon-left; // // Tooltips variables @@ -812,6 +833,7 @@ // // Forms variables //-------------------------------------- + // Form elements inputs default variables @form-element-input-type: ''; // input-text, select, textarea, input-radio, input-checkbox @form-element-input-background: #fff; @@ -831,15 +853,18 @@ @form-element-input-font-weight: false; @form-element-input-line-height: @line-height-base; @form-element-input-font-style: false; + // Placeholder @form-element-input-placeholder-color: #c2c2c2; @form-element-input-placeholder-font-style: @form-element-input-font-style; + // Disabled state @form-element-input-disabled-background: @form-element-input-background; @form-element-input-disabled-border: @form-element-input-border; @form-element-input-disabled-opacity: 0.5; @form-element-input-disabled-color: @form-element-input-color; @form-element-input-disabled-font-style: @form-element-input-font-style; + // Focus state @form-element-input-focus-background: @form-element-input-background; @form-element-input-focus-border: @form-element-input-border; @@ -869,15 +894,18 @@ @input-text-font-weight: @form-element-input-font-weight; @input-text-line-height: @form-element-input-line-height; @input-text-font-style: @form-element-input-font-style; + // Placeholder @input-text-placeholder-color: @form-element-input-placeholder-color; @input-text-placeholder-font-style: @form-element-input-placeholder-font-style; + // Disabled state @input-text-disabled-background: @form-element-input-disabled-background; @input-text-disabled-border: @form-element-input-disabled-border; @input-text-disabled-opacity: @form-element-input-disabled-opacity; @input-text-disabled-color: @form-element-input-disabled-color; @input-text-disabled-font-style: @form-element-input-disabled-font-style; + // Focus state @input-text-focus-background: @form-element-input-focus-background; @input-text-focus-border: @form-element-input-focus-border; @@ -901,15 +929,18 @@ @select-font-weight: @form-element-input-font-weight; @select-line-height: @form-element-input-line-height; @select-font-style: @form-element-input-font-style; + // Placeholder @select-placeholder-color: false; @select-placeholder-font-style: false; + // Disabled state @select-disabled-background: @form-element-input-disabled-background; @select-disabled-border: @form-element-input-disabled-border; @select-disabled-opacity: @form-element-input-disabled-opacity; @select-disabled-color: @form-element-input-disabled-color; @select-disabled-font-style: @form-element-input-disabled-font-style; + // Focus state @select-focus-background: @form-element-input-focus-background; @select-focus-border: @form-element-input-focus-border; @@ -933,16 +964,19 @@ @textarea-font-weight: @form-element-input-font-weight; @textarea-line-height: @form-element-input-line-height; @textarea-font-style: @form-element-input-font-style; -@textarea-resize: vertical; //none | both | horizontal | vertical | inherit +@textarea-resize: vertical; // none | both | horizontal | vertical | inherit + // Placeholder @textarea-placeholder-color: @form-element-input-placeholder-color; @textarea-placeholder-font-style: @form-element-input-placeholder-font-style; + // Disabled state @textarea-disabled-background: @form-element-input-disabled-background; @textarea-disabled-border: @form-element-input-disabled-border; @textarea-disabled-opacity: @form-element-input-disabled-opacity; @textarea-disabled-color: @form-element-input-disabled-color; @textarea-disabled-font-style: @form-element-input-disabled-font-style; + // Focus state @textarea-focus-background: @form-element-input-focus-background; @textarea-focus-border: @form-element-input-focus-border; @@ -991,7 +1025,7 @@ // Fieldset @form-fieldset-border: 0; -@form-fieldset-margin: 0 0 40px; //30px 10px 30px 30px +@form-fieldset-margin: 0 0 40px; @form-fieldset-padding: 0; @form-fieldset-legend-color: false; @form-fieldset-legend-font-size: 20px; @@ -999,9 +1033,9 @@ @form-fieldset-legend-font-weight: false; @form-fieldset-legend-font-style: false; @form-fieldset-legend-line-height: 1.2; -@form-fieldset-legend-margin: 0 0 25px 0; //0 0 25px @form-field-type-inline-label-width +@form-fieldset-legend-margin: 0 0 25px; // 0 0 25px @form-field-type-inline-label-width @form-fieldset-legend-padding: 0; -@form-fieldset-legend-width: false; //@form-field-type-inline-control-width +@form-fieldset-legend-width: false; // @form-field-type-inline-control-width // Field @form-field-type: block; //inline @@ -1010,11 +1044,12 @@ @form-field-column: false; @form-field-column-padding: 0 12px 0 0; @form-field-column-number: 2; -@form-field-vertical-indent: 29px; -@form-field-additional-vertical-indent: @form-field-vertical-indent; +@form-field-vertical-indent: 20px; +@form-field-additional-vertical-indent: @form-field-vertical-indent/2; @form-field-type-block-margin: 0 0 @form-field-vertical-indent; @form-field-type-inline-margin: 0 0 @form-field-vertical-indent; -// form field label + +// Form field label @form-field-label-align: false; @form-field-label-color: false; @form-field-label-font-size: false; @@ -1029,9 +1064,11 @@ @form-field-type-block-label-margin: 0 0 5px; @form-field-type-block-label-padding: false; @form-field-type-block-label-align: @form-field-label-align; -// form field control + +// Form field control @form-field-type-inline-control-width: 74.2%; -// form field label asterisk + +// Form field label asterisk @form-field-label-asterisk-color: #e02b27; // also used in: @form-hasrequired-color @form-field-label-asterisk-font-size: @font-size-s; @form-field-label-asterisk-font-family: false; @@ -1039,7 +1076,8 @@ @form-field-label-asterisk-font-style: false; @form-field-label-asterisk-line-height: false; @form-field-label-asterisk-margin: 0 0 0 5px; -// form field note + +// Form field note @form-field-note-color: false; @form-field-note-font-size: @font-size-s; @form-field-note-font-family: false; @@ -1048,7 +1086,8 @@ @form-field-note-font-style: false; @form-field-note-margin: 3px 0 0; @form-field-note-padding: 0; -// form field note icon + +// Form field note icon @form-field-note-icon-font-content: @icon-pointer-up; @form-field-note-icon-font: @icon-font; @form-field-note-icon-font-size: @form-field-note-font-size * 2; @@ -1194,6 +1233,7 @@ // // Dropdowns variables //-------------------------------------- + // Variables simple dropdown @dropdown-actions-padding: false; @dropdown-list-min-width: 100%; // Also used in: @dropdown-split-list-min-width @@ -1232,7 +1272,7 @@ // Variables split dropdown @dropdown-split-actions-padding: 0 5px; -@dropdown-split-toggle-actions-padding: false; +@dropdown-split-toggle-actions-padding: 4px 5px; @dropdown-split-button-actions-padding: false; @dropdown-split-toggle-position: right; // Also used in: @dropdown-split-list-pointer-position @dropdown-split-list-min-width: @dropdown-list-min-width; @@ -1356,7 +1396,7 @@ @breadcrumbs-link-gradient-end-color-active: false; // -// Popups variables +// Popups variables //-------------------------------------- @popup-width: auto; @popup-height: auto; @@ -1396,7 +1436,7 @@ @popup-button-close-position-bottom: ''; @popup-button-close-position-left: ''; -//Actions toolbar variables +// Actions toolbar variables @popup-actions-toolbar-actions-position: @actions-toolbar-actions-position; @popup-actions-toolbar-actions-reverse: @actions-toolbar-actions-reverse; @popup-actions-toolbar-margin: @actions-toolbar-margin; @@ -1408,7 +1448,7 @@ @popup-actions-toolbar-primary-actions-links-margin-top: @actions-toolbar-primary-actions-links-margin-top; @popup-actions-toolbar-secondary-actions-links-margin-top: @actions-toolbar-secondary-actions-links-margin-top; -// Popup Icons variables +// Popup Icons variables @popup-icon-font-content: @icon-remove; @popup-icon-font: @button-icon-font; @popup-icon-font-size: @button-icon-font-size; @@ -1421,7 +1461,7 @@ @popup-icon-font-position: @button-icon-font-position; @popup-icon-font-text-hide: true; -// Window overlay variables +// Window overlay variables @overlay-background: #000; @overlay-opacity: 0.5; @overlay-opacity-old: 50; diff --git a/lib/web/mage/adminhtml/tools.js b/lib/web/mage/adminhtml/tools.js index 8a969fb4271..d080c4c417c 100644 --- a/lib/web/mage/adminhtml/tools.js +++ b/lib/web/mage/adminhtml/tools.js @@ -115,6 +115,18 @@ Event.observe(window, 'load', function() { } }); +function toggleSeveralValueElements(checkbox, containers, excludedElements, checked){ + "use strict"; + if(containers && checkbox){ + if (Object.prototype.toString.call(containers) != '[object Array]') { + containers = [containers]; + } + containers.each(function(container) { + toggleValueElements(checkbox, container, excludedElements, checked); + }); + } +} + function toggleValueElements(checkbox, container, excludedElements, checked){ if(container && checkbox){ var ignoredElements = [checkbox]; @@ -127,7 +139,9 @@ function toggleValueElements(checkbox, container, excludedElements, checked){ } } //var elems = container.select('select', 'input'); - var elems = Element.select(container, ['select', 'input', 'textarea', 'button', 'img']); + var elems = Element.select(container, ['select', 'input', 'textarea', 'button', 'img']).filter(function(el){ + return (el.readAttribute('type') != 'hidden'); + }); var isDisabled = (checked != undefined ? checked : checkbox.checked); elems.each(function (elem) { if (checkByProductPriceType(elem)) { diff --git a/lib/web/mage/menu.js b/lib/web/mage/menu.js index cc8061f60de..a6753de58fb 100644 --- a/lib/web/mage/menu.js +++ b/lib/web/mage/menu.js @@ -48,7 +48,7 @@ define([ if(this.options.responsive === true){ mediaCheck({ - media: '(max-width: 768px)', + media: '(max-width: 640px)', entry: $.proxy(function() { this._toggleMobileMode(); }, this), @@ -64,8 +64,7 @@ define([ _assignControls: function() { this.controls = { toggleBtn: $('[data-action="toggle-nav"]'), - swipeArea: $('.panel.wrapper'), - wrapper: $('.page-wrapper') + swipeArea: $('.nav-sections') }; return this; @@ -80,7 +79,17 @@ define([ }, toggle: function() { - this.controls.wrapper.toggleClass('open'); + if ($('html').hasClass('nav-open')) { + $('html').removeClass('nav-open'); + setTimeout(function() { + $('html').removeClass('nav-before-open'); + },300); + } else { + $('html').addClass('nav-before-open'); + setTimeout(function() { + $('html').addClass('nav-open'); + },42); + } }, //Add class for expanded option @@ -262,7 +271,7 @@ define([ }, _toggleMobileMode: function() { - $(this.element).unbind('mouseenter mouseleave'); + $(this.element).unbind('mouseenter mouseleave'); this._on({ "click .ui-menu-item:has(a)": function( event ) { event.preventDefault(); -- GitLab