From 7ad2dc793641bb9546beeb4450ed3c6aac7c4201 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Mon, 15 Sep 2014 05:40:07 -0700 Subject: [PATCH] 0.1.0-alpha95 * Modularity * Log module became switchable * New switchable module TaxImportExport was created * Sales module improvement: * Performance was improved * Complexity of the order persistence logic was reduced * Unit tests coverage for modules was increased: * Magento\Rule * Magento\Contact * Framework: * Composite and bundle save/load processors were added * Support for the complex custom attributes were added * Generic abstract data objects, that is simple and extensible (supports custom attributes), were created * Search Library: * Approach of matching the fields to table names was implemented * MySQL Adapter Library for Match and Filtered query types was added * Ability to filter queries was added * Response handler for MySQL adapter was added * XML declarations for full-text search were added * Functional tests: * Add Products to Order from Last Ordered Products Section * Add Products to Order from Products in Comparison List Section * Add Products to Order from Recently Compared Products Section * Create Configurable Product * Create Store * Create Website * Delete Product From Customer Wishlist On Backend * Delete Store * Delete Website * Viewed Products Report * Products In Cart Report * Manage Product Review from Customer Page * Mass Assign Customer Group * New Account Report * Update Product Review From Product Page * Update Store * Manage Product Review From Customer Page * Other: * Session.name ini set * Calls to setPublicCookie became more secured * Generating the session ID for sensitive data was added * Fixed bugs: * Placing the order from backend * Redirecting the customer to empty shopping cart instead of displaying credit card iFrame on checkout with for PayPal Payflow Link * Showing the message for multiple shipping address checkout in Authorize partial approval flow * Mess detector failure * flv_player security vulnerability * Calling the inexistent method in cart with shopping cart price rules * Overriding a non-empty custom attribute value with empty value in store view scope * Editing in 'WYSIWYG editor' by clicking "Use Default" checkbox when switched to store view scope * RSS list page vulnerability * Applying the store View title on frontend for configurable attributes * Viewing the uploaded sample in downloadable product * Google Shopping: Problem with publishing products if change value for option 'Update Google Shopping Item when Product is Updated' * Configuration scope of items' InStock status on order cancellation * Creating the new customer in admin * GitHub requests: * #621-- Parse error: syntax error, unexpected T_OBJECT_OPERATOR * #651-- Multishipping checkout add/edit address page issue --- .htaccess | 1 + CHANGELOG.md | 74 +- CONTRIBUTOR_LICENSE_AGREEMENT.html | 131 ++++ app/autoload.php | 23 +- app/bootstrap.php | 47 +- .../Model/System/Message/Baseurl.php | 6 +- .../Magento/AdminNotification/composer.json | 12 +- .../Model/CompositeUserContext.php | 38 +- app/code/Magento/Authorization/composer.json | 6 +- .../Magento/Authorizenet/Helper/Backend.php | 4 +- app/code/Magento/Authorizenet/Helper/Data.php | 6 +- .../Authorizenet/Model/Authorizenet.php | 2 +- .../Magento/Authorizenet/Model/Directpost.php | 6 +- .../Model/Directpost/Observer.php | 6 +- .../Authorizenet/Model/Directpost/Session.php | 6 +- app/code/Magento/Authorizenet/composer.json | 19 +- .../Magento/Authorizenet/etc/adminhtml/di.xml | 5 - .../Magento/Authorizenet/etc/frontend/di.xml | 5 - app/code/Magento/Authorizenet/etc/module.xml | 1 - app/code/Magento/Backend/AdminConfig.php | 13 +- app/code/Magento/Backend/App/Router.php | 9 +- .../Backend/Block/Template/Context.php | 6 +- .../Block/Urlrewrite/Catalog/Edit/Form.php | 6 +- .../Block/Urlrewrite/Cms/Page/Edit/Form.php | 6 +- .../Magento/Backend/Block/Widget/Context.php | 4 +- .../Widget/Grid/Column/Renderer/Currency.php | 6 +- .../Magento/Backend/Helper/Dashboard/Data.php | 4 +- .../Backend/Helper/Dashboard/Order.php | 4 +- app/code/Magento/Backend/Model/Config.php | 6 +- .../Model/Config/Backend/Admin/Observer.php | 4 +- .../Backend/Model/Config/Source/Website.php | 6 +- .../Config/Structure/AbstractElement.php | 6 +- .../Structure/Element/AbstractComposite.php | 4 +- .../Model/Config/Structure/Element/Field.php | 4 +- .../Model/Config/Structure/Element/Group.php | 4 +- .../Config/Structure/Element/Section.php | 4 +- app/code/Magento/Backend/Model/Session.php | 2 +- .../Magento/Backend/Model/Session/Quote.php | 6 +- app/code/Magento/Backend/composer.json | 45 +- app/code/Magento/Backend/etc/adminhtml/di.xml | 6 +- app/code/Magento/Backend/etc/module.xml | 1 - .../Backup/Controller/Adminhtml/Index.php | 6 +- .../Controller/Adminhtml/Index/Create.php | 4 +- .../Controller/Adminhtml/Index/Rollback.php | 4 +- app/code/Magento/Backup/Helper/Data.php | 2 +- app/code/Magento/Backup/Model/Observer.php | 12 +- app/code/Magento/Backup/composer.json | 14 +- .../Bundle/Model/Product/CatalogPrice.php | 6 +- .../Magento/Bundle/Model/Product/Price.php | 4 +- .../Magento/Bundle/Model/Product/Type.php | 6 +- .../Product/{Link/Metadata.php => Link.php} | 18 +- .../MetadataBuilder.php => LinkBuilder.php} | 31 +- ...etadataConverter.php => LinkConverter.php} | 12 +- .../Bundle/Service/V1/Data/Product/Option.php | 12 + .../Service/V1/Data/Product/OptionBuilder.php | 11 + .../V1/Data/Product/OptionConverter.php | 6 +- .../V1/Product/BundleProductLoadProcessor.php | 77 ++ .../V1/Product/BundleProductSaveProcessor.php | 233 ++++++ .../V1/Product/Link/Data/ProductLink.php | 112 --- .../Product/Link/Data/ProductLinkBuilder.php | 144 ---- .../Service/V1/Product/Link/ReadService.php | 14 +- .../V1/Product/Link/ReadServiceInterface.php | 2 +- .../Service/V1/Product/Link/WriteService.php | 16 +- .../V1/Product/Link/WriteServiceInterface.php | 4 +- .../Service/V1/Product/Option/ReadService.php | 47 +- .../V1/Product/Option/WriteService.php | 68 +- app/code/Magento/Bundle/composer.json | 32 +- .../di.xml => Bundle/etc/data_object.xml} | 10 +- app/code/Magento/Bundle/etc/di.xml | 20 + app/code/Magento/Captcha/Helper/Data.php | 6 +- app/code/Magento/Captcha/composer.json | 14 +- .../Block/Adminhtml/Category/Helper/Image.php | 6 +- .../Block/Adminhtml/Helper/Form/Wysiwyg.php | 2 +- .../Adminhtml/Product/Helper/Form/Gallery.php | 6 +- .../Adminhtml/Product/Helper/Form/Price.php | 4 +- .../Block/Product/Compare/ListCompare.php | 14 +- .../Magento/Catalog/Block/Product/Context.php | 4 +- .../Magento/Catalog/Block/Product/Send.php | 9 - .../Magento/Catalog/Block/Product/View.php | 3 +- .../Catalog/Controller/Adminhtml/Category.php | 2 +- .../Controller/Adminhtml/Category/Edit.php | 2 +- .../Controller/Adminhtml/Category/Save.php | 2 +- .../Controller/Adminhtml/Category/Tree.php | 2 +- .../Controller/Adminhtml/Product/Edit.php | 2 +- .../Product/Initialization/Helper.php | 6 +- .../Controller/Adminhtml/Product/Wysiwyg.php | 2 +- .../Catalog/Controller/Category/View.php | 6 +- .../Catalog/Controller/Product/Compare.php | 18 +- .../Controller/Product/Compare/Add.php | 2 +- .../Controller/Product/Compare/Clear.php | 2 +- .../Controller/Product/Compare/Remove.php | 2 +- app/code/Magento/Catalog/Helper/Category.php | 6 +- app/code/Magento/Catalog/Helper/Data.php | 6 +- app/code/Magento/Catalog/Helper/Product.php | 4 +- .../Catalog/Helper/Product/Compare.php | 20 +- .../Catalog/Helper/Product/Composite.php | 6 +- .../Catalog/Helper/Product/Flat/Indexer.php | 6 +- .../Catalog/Helper/Product/Inventory.php | 4 +- .../Magento/Catalog/Model/AbstractModel.php | 6 +- app/code/Magento/Catalog/Model/Category.php | 4 +- app/code/Magento/Catalog/Model/Config.php | 6 +- .../Catalog/Model/Entity/Attribute.php | 4 +- .../Indexer/Category/Flat/AbstractAction.php | 6 +- .../Indexer/Category/Flat/Action/Rows.php | 4 +- .../Category/Product/AbstractAction.php | 6 +- .../AttributeSet/IndexableAttributeFilter.php | 26 +- .../Indexer/Product/Flat/AbstractAction.php | 6 +- .../Indexer/Product/Flat/Action/Eraser.php | 6 +- .../Model/Indexer/Product/Flat/Action/Row.php | 4 +- .../Indexer/Product/Flat/Action/Rows.php | 4 +- .../Indexer/Product/Flat/FlatTableBuilder.php | 6 +- .../Indexer/Product/Price/AbstractAction.php | 6 +- .../Model/Indexer/Product/Price/Observer.php | 6 +- app/code/Magento/Catalog/Model/Layer.php | 6 +- .../Magento/Catalog/Model/Layer/Category.php | 4 +- .../Category/FilterableAttributeList.php | 6 +- .../Catalog/Model/Layer/Category/StateKey.php | 6 +- .../Model/Layer/Filter/AbstractFilter.php | 6 +- .../Catalog/Model/Layer/Filter/Attribute.php | 4 +- .../Catalog/Model/Layer/Filter/Category.php | 4 +- .../Catalog/Model/Layer/Filter/Decimal.php | 4 +- .../Catalog/Model/Layer/Filter/Price.php | 4 +- .../Magento/Catalog/Model/Layer/Search.php | 4 +- .../Model/Layer/Search/CollectionFilter.php | 6 +- .../Layer/Search/FilterableAttributeList.php | 4 +- .../Catalog/Model/Layer/Search/StateKey.php | 4 +- app/code/Magento/Catalog/Model/Observer.php | 6 +- app/code/Magento/Catalog/Model/Product.php | 4 +- .../Product/Attribute/Backend/Groupprice.php | 4 +- .../Backend/Groupprice/AbstractGroupprice.php | 4 +- .../Model/Product/Attribute/Backend/Price.php | 6 +- .../Product/Attribute/Backend/Tierprice.php | 4 +- .../Product/Attribute/Frontend/Image.php | 6 +- .../Attribute/Source/Countryofmanufacture.php | 6 +- .../Catalog/Model/Product/Compare/Item.php | 20 +- .../Model/Product/Compare/ListCompare.php | 14 +- .../Magento/Catalog/Model/Product/Image.php | 6 +- .../Catalog/Model/Product/Media/Config.php | 6 +- .../Catalog/Model/Product/Type/Price.php | 6 +- .../Magento/Catalog/Model/Product/Url.php | 6 +- .../Model/Resource/AbstractResource.php | 6 +- .../Catalog/Model/Resource/Attribute.php | 4 +- .../Catalog/Model/Resource/Category.php | 4 +- .../Category/Attribute/Frontend/Image.php | 6 +- .../Catalog/Model/Resource/Category/Flat.php | 6 +- .../Resource/Category/Flat/Collection.php | 6 +- .../Catalog/Model/Resource/Category/Tree.php | 6 +- .../Collection/AbstractCollection.php | 6 +- .../Magento/Catalog/Model/Resource/Config.php | 6 +- .../Catalog/Model/Resource/Eav/Attribute.php | 4 +- .../Catalog/Model/Resource/Product.php | 4 +- .../Model/Resource/Product/Collection.php | 4 +- .../Product/Compare/Item/Collection.php | 4 +- .../Catalog/Model/Resource/Product/Flat.php | 6 +- .../Resource/Product/Indexer/Eav/Source.php | 8 +- .../Catalog/Model/Resource/Product/Option.php | 6 +- .../Resource/Product/Option/Collection.php | 6 +- .../Model/Resource/Product/Option/Value.php | 6 +- .../Model/Resource/Product/Website.php | 6 +- .../Magento/Catalog/Model/Resource/Url.php | 6 +- .../Magento/Catalog/Model/Template/Filter.php | 6 +- .../Service/V1/Category/Tree/ReadService.php | 6 +- .../Service/V1/Category/WriteService.php | 6 +- .../Catalog/Service/V1/Data/Category/Tree.php | 6 +- .../Catalog/Service/V1/Data/Converter.php | 13 +- .../Catalog/Service/V1/Data/ProductMapper.php | 6 +- .../Product/Attribute/Media/ReadService.php | 6 +- .../Service/V1/Product/GroupPriceService.php | 6 +- .../Product/ProductLoadProcessorComposite.php | 72 ++ .../Product/ProductLoadProcessorInterface.php | 41 + .../Product/ProductSaveProcessorComposite.php | 109 +++ .../Product/ProductSaveProcessorInterface.php | 73 ++ .../Service/V1/Product/TierPriceService.php | 6 +- .../Catalog/Service/V1/ProductService.php | 43 +- app/code/Magento/Catalog/composer.json | 48 +- app/code/Magento/Catalog/etc/adminhtml/di.xml | 5 - app/code/Magento/Catalog/etc/di.xml | 2 + app/code/Magento/Catalog/etc/frontend/di.xml | 5 - .../Model/Export/Product.php | 4 +- .../Model/Import/Product.php | 6 +- .../Model/Import/Product/Option.php | 6 +- .../Magento/CatalogImportExport/composer.json | 20 +- .../Model/Resource/Stock/Item/Collection.php | 6 +- .../Model/Resource/Stock/Status.php | 6 +- .../Magento/CatalogInventory/Model/Stock.php | 6 +- .../CatalogInventory/Model/Stock/Item.php | 6 +- .../CatalogInventory/Model/Stock/Status.php | 6 +- .../Magento/CatalogInventory/composer.json | 20 +- .../CatalogInventory/etc/adminhtml/system.xml | 2 +- .../Magento/CatalogRule/Model/Observer.php | 2 +- .../CatalogRule/Model/Resource/Rule.php | 6 +- app/code/Magento/CatalogRule/Model/Rule.php | 6 +- app/code/Magento/CatalogRule/composer.json | 18 +- .../CatalogSearch/Controller/Result/Index.php | 2 +- .../Magento/CatalogSearch/Helper/Data.php | 4 +- .../Magento/CatalogSearch/Model/Advanced.php | 6 +- .../Model/Indexer/Fulltext/Action/Full.php | 6 +- .../CatalogSearch/Model/Layer/Advanced.php | 4 +- .../Model/Layer/Advanced/CollectionFilter.php | 6 +- .../Advanced/FilterableAttributeList.php | 4 +- .../Magento/CatalogSearch/Model/Query.php | 2 +- .../CatalogSearch/Model/Resource/Advanced.php | 6 +- .../Model/Resource/Advanced/Collection.php | 4 +- .../Model/Resource/Fulltext/Collection.php | 4 +- .../Model/Resource/Query/Collection.php | 6 +- .../Model/Resource/Search/Collection.php | 4 +- app/code/Magento/CatalogSearch/composer.json | 22 +- .../CatalogSearch/etc/adminhtml/di.xml | 1 - app/code/Magento/CatalogSearch/etc/di.xml | 11 + .../Magento/CatalogSearch/etc/frontend/di.xml | 1 - .../CatalogSearch/etc/search_request.xml | 84 ++ .../Magento/CatalogUrlRewrite/Helper/Data.php | 4 +- .../Service/V1/AbstractUrlGenerator.php | 2 +- .../Service/V1/CategoryUrlGenerator.php | 6 +- .../Service/V1/ProductUrlGenerator.php | 2 +- .../Magento/CatalogUrlRewrite/composer.json | 12 +- app/code/Magento/Centinel/composer.json | 14 +- .../Magento/Centinel/etc/adminhtml/di.xml | 1 - app/code/Magento/Centinel/etc/frontend/di.xml | 1 - app/code/Magento/Checkout/Controller/Cart.php | 6 +- .../Magento/Checkout/Controller/Cart/Add.php | 2 +- .../Checkout/Controller/Cart/Index.php | 2 +- .../Checkout/Controller/Onepage/Index.php | 1 + app/code/Magento/Checkout/Helper/Cart.php | 4 +- app/code/Magento/Checkout/Helper/Data.php | 6 +- app/code/Magento/Checkout/Model/Cart.php | 6 +- app/code/Magento/Checkout/Model/Session.php | 9 +- .../Magento/Checkout/Model/Type/Onepage.php | 6 +- .../V1/Address/Billing/ReadService.php | 6 +- .../V1/Address/Billing/WriteService.php | 2 +- .../Checkout/Service/V1/Address/Converter.php | 2 +- .../V1/Address/Shipping/ReadService.php | 6 +- .../V1/Address/Shipping/WriteService.php | 6 +- .../Checkout/Service/V1/Cart/WriteService.php | 6 +- .../Service/V1/Coupon/ReadService.php | 6 +- .../Service/V1/Coupon/WriteService.php | 6 +- .../V1/Data/Cart/ShippingMethodConverter.php | 4 +- .../Service/V1/PaymentMethod/ReadService.php | 2 +- .../Service/V1/PaymentMethod/WriteService.php | 6 +- .../Service/V1/ShippingMethod/ReadService.php | 6 +- .../V1/ShippingMethod/WriteService.php | 6 +- app/code/Magento/Checkout/composer.json | 32 +- app/code/Magento/Checkout/etc/frontend/di.xml | 5 - .../Model/AgreementsProvider.php | 6 +- .../Service/V1/Agreement/ReadService.php | 6 +- .../Magento/CheckoutAgreements/composer.json | 10 +- app/code/Magento/Cms/Block/Block.php | 6 +- app/code/Magento/Cms/Block/Page.php | 6 +- app/code/Magento/Cms/Controller/Router.php | 16 +- app/code/Magento/Cms/Helper/Page.php | 6 +- .../Magento/Cms/Helper/Wysiwyg/Images.php | 6 +- app/code/Magento/Cms/Model/Resource/Block.php | 6 +- app/code/Magento/Cms/Model/Resource/Page.php | 6 +- .../Cms/Model/Resource/Page/Collection.php | 6 +- app/code/Magento/Cms/composer.json | 19 +- .../data-upgrade-1.6.0.0-1.6.0.1.php | 4 - app/code/Magento/Cms/etc/module.xml | 1 - .../Service/V1/CmsPageUrlGenerator.php | 2 +- app/code/Magento/CmsUrlRewrite/composer.json | 7 +- app/code/Magento/CmsUrlRewrite/etc/module.xml | 1 - .../ConfigurableImportExport/composer.json | 14 +- .../SuggestConfigurableAttributes.php | 14 +- .../Model/Product/Type/Configurable.php | 5 + .../Model/Product/Type/Configurable/Price.php | 4 +- .../Model/Product/Type/VariationMatrix.php | 3 +- .../Product/Collection/AssociatedProduct.php | 4 +- .../Product/Type/Configurable/Attribute.php | 6 +- .../Configurable/Attribute/Collection.php | 6 +- .../Pricing/Price/AttributePrice.php | 6 +- .../V1/Product/Option/WriteService.php | 4 +- .../Magento/ConfigurableProduct/composer.json | 32 +- .../ConfigurableProduct/etc/module.xml | 1 - .../catalog/product/edit/super/matrix.phtml | 2 +- app/code/Magento/Contact/Controller/Index.php | 6 +- app/code/Magento/Contact/composer.json | 12 +- app/code/Magento/Core/App/Media.php | 83 +- app/code/Magento/Core/App/Router/Base.php | 16 +- app/code/Magento/Core/Helper/Data.php | 6 +- app/code/Magento/Core/Helper/Url.php | 6 +- app/code/Magento/Core/Model/App/Emulation.php | 6 +- app/code/Magento/Core/Model/Layout/Merge.php | 8 +- .../Magento/Core/Model/Resource/Setup.php | 4 +- .../Magento/Core/Model/Theme/Collection.php | 2 +- .../Magento/Core/Model/Theme/Image/Path.php | 6 +- .../Core/Model/Url/RouteParamsResolver.php | 6 +- .../Magento/Core/Model/Url/ScopeResolver.php | 6 +- app/code/Magento/Core/Model/View/Design.php | 6 +- app/code/Magento/Core/composer.json | 16 +- .../data-upgrade-1.6.0.10-1.6.0.11.php | 14 +- .../data-upgrade-1.6.0.12-1.6.0.13.php | 7 +- app/code/Magento/Core/etc/di.xml | 2 +- app/code/Magento/Core/etc/frontend/di.xml | 5 - .../Cron/Plugin/ApplicationInitializer.php | 68 -- app/code/Magento/Cron/composer.json | 8 +- app/code/Magento/Cron/etc/di.xml | 3 - .../Magento/CurrencySymbol/Helper/Data.php | 4 +- .../Model/System/Currencysymbol.php | 6 +- app/code/Magento/CurrencySymbol/composer.json | 14 +- .../Edit/Renderer/Attribute/Sendemail.php | 2 +- .../Block/Adminhtml/Edit/Tab/View.php | 301 -------- .../Adminhtml/Edit/Tab/View/PersonalInfo.php | 244 ++++++ .../Magento/Customer/Block/Widget/Dob.php | 17 +- .../Magento/Customer/Controller/Account.php | 16 +- .../Customer/Controller/Account/Create.php | 7 +- .../Controller/Account/CreatePost.php | 9 +- .../Customer/Controller/Account/Edit.php | 7 +- .../Customer/Controller/Account/EditPost.php | 7 +- .../Controller/Account/ForgotPasswordPost.php | 5 +- .../Customer/Controller/Account/LoginPost.php | 7 +- .../Adminhtml/Cart/Product/Composite/Cart.php | 2 +- .../Adminhtml/Customer/InvalidateToken.php | 4 +- .../Controller/Adminhtml/Index/Cart.php | 2 +- .../Controller/Adminhtml/Index/Index.php | 1 + app/code/Magento/Customer/Helper/Address.php | 6 +- .../Magento/Customer/Model/Address/Config.php | 6 +- .../Model/Config/Backend/Address/Street.php | 8 +- .../Model/Config/Backend/Show/Customer.php | 6 +- .../Magento/Customer/Model/Config/Share.php | 6 +- app/code/Magento/Customer/Model/Converter.php | 4 +- app/code/Magento/Customer/Model/Customer.php | 6 +- .../Customer/Attribute/Backend/Store.php | 6 +- .../Customer/Attribute/Backend/Website.php | 6 +- .../Customer/Model/CustomerExtractor.php | 6 +- .../Customer/Model/CustomerRegistry.php | 4 +- .../Model/Layout/DepersonalizePlugin.php | 6 +- .../Model/Metadata/Form/AbstractData.php | 11 +- .../Customer/Model/Metadata/Form/Date.php | 34 +- .../Customer/Model/Metadata/Form/File.php | 19 +- .../Customer/Model/Metadata/Form/Image.php | 31 +- .../Customer/Model/Metadata/Form/Text.php | 22 +- .../Customer/CustomersTypeOptions.php | 4 +- .../Customer/Model/Resource/Visitor.php | 55 ++ app/code/Magento/Customer/Model/Session.php | 24 +- .../Customer/Model/Session/Storage.php | 4 +- app/code/Magento/Customer/Model/Visitor.php | 254 ++++++ .../Service/V1/AddressMetadataService.php | 3 +- .../Service/V1/CustomerAccountService.php | 6 +- .../Service/V1/CustomerGroupService.php | 8 +- .../V1/CustomerGroupServiceInterface.php | 2 +- .../Service/V1/CustomerMetadataService.php | 3 +- .../V1/Data/CustomerGroupSearchResults.php} | 18 +- .../CustomerGroupSearchResultsBuilder.php | 75 ++ .../Data/Eav/AttributeMetadataConverter.php | 18 +- app/code/Magento/Customer/composer.json | 39 +- app/code/Magento/Customer/etc/acl.xml | 1 - .../Magento/Customer/etc/adminhtml/di.xml | 5 - .../Magento/Customer/etc/adminhtml/menu.xml | 3 +- .../Magento/Customer/etc/adminhtml/system.xml | 7 - app/code/Magento/Customer/etc/di.xml | 9 + app/code/Magento/Customer/etc/frontend/di.xml | 5 - .../Magento/Customer/etc/frontend/events.xml | 45 ++ app/code/Magento/Customer/etc/module.xml | 1 - .../Magento/Customer/etc/webapi_rest/di.xml | 5 - app/code/Magento/Customer/i18n/de_DE.csv | 5 - app/code/Magento/Customer/i18n/en_US.csv | 5 - app/code/Magento/Customer/i18n/es_ES.csv | 5 - app/code/Magento/Customer/i18n/fr_FR.csv | 5 - app/code/Magento/Customer/i18n/nl_NL.csv | 5 - app/code/Magento/Customer/i18n/pt_BR.csv | 5 - app/code/Magento/Customer/i18n/zh_CN.csv | 5 - .../sql/customer_setup/install-1.6.0.0.php | 22 + .../adminhtml/layout/customer_index_edit.xml | 3 +- .../view/adminhtml/templates/tab/view.phtml | 60 +- .../templates/tab/view/personal_info.phtml | 69 ++ .../Model/Export/Address.php | 4 +- .../Model/Export/Customer.php | 4 +- .../Model/Import/AbstractCustomer.php | 4 +- .../Model/Import/Address.php | 4 +- .../Model/Import/Customer.php | 4 +- .../CustomerImportExport/composer.json | 17 +- .../CustomerImportExport/etc/module.xml | 1 - .../Design/Editor/AssignThemeToStore.php | 4 +- .../Controller/Varien/Router/Standard.php | 7 +- app/code/Magento/DesignEditor/composer.json | 16 +- app/code/Magento/Dhl/Model/Carrier.php | 6 +- app/code/Magento/Dhl/composer.json | 22 +- .../Controller/Currency/SwitchAction.php | 4 +- app/code/Magento/Directory/Helper/Data.php | 6 +- app/code/Magento/Directory/Helper/Url.php | 4 +- app/code/Magento/Directory/Model/Currency.php | 6 +- .../Model/Currency/DefaultLocator.php | 6 +- .../Directory/Model/Currency/Filter.php | 6 +- app/code/Magento/Directory/Model/Observer.php | 6 +- .../Magento/Directory/Model/PriceCurrency.php | 4 +- app/code/Magento/Directory/composer.json | 10 +- .../Product/Edit/Tab/Downloadable/Links.php | 10 +- .../Product/Edit/Tab/Downloadable/Samples.php | 8 +- .../Downloadable/Product/Edit/Link.php | 39 +- .../Downloadable/Product/Edit/Sample.php | 79 ++ .../Downloadable/Model/Resource/Link.php | 6 +- app/code/Magento/Downloadable/composer.json | 32 +- .../Magento/Eav/Model/Entity/Attribute.php | 4 +- .../Entity/Attribute/AbstractAttribute.php | 6 +- .../Model/Entity/Attribute/Backend/Store.php | 6 +- app/code/Magento/Eav/Model/Form.php | 6 +- app/code/Magento/Eav/Model/Form/Fieldset.php | 6 +- .../Model/Resource/Attribute/Collection.php | 6 +- .../Eav/Model/Resource/Entity/Attribute.php | 6 +- .../Entity/Attribute/Option/Collection.php | 6 +- .../Resource/Form/Attribute/Collection.php | 6 +- .../Resource/Form/Fieldset/Collection.php | 4 +- app/code/Magento/Eav/composer.json | 12 +- .../Magento/Email/Model/AbstractTemplate.php | 6 +- .../Magento/Email/Model/BackendTemplate.php | 4 +- app/code/Magento/Email/Model/Template.php | 4 +- .../Magento/Email/Model/Template/Filter.php | 6 +- app/code/Magento/Email/composer.json | 14 +- app/code/Magento/Fedex/Model/Carrier.php | 6 +- app/code/Magento/Fedex/composer.json | 18 +- .../Magento/GiftMessage/Helper/Message.php | 4 +- .../GiftMessage/Service/V1/WriteService.php | 6 +- app/code/Magento/GiftMessage/composer.json | 24 +- app/code/Magento/GoogleAdwords/composer.json | 8 +- .../GoogleAnalytics/Model/Observer.php | 6 +- .../Magento/GoogleAnalytics/composer.json | 8 +- .../Magento/GoogleOptimizer/composer.json | 14 +- .../Adminhtml/Googleshopping/Items.php | 2 +- .../Adminhtml/Googleshopping/Items/Index.php | 2 +- .../Adminhtml/Googleshopping/Types.php | 4 +- .../Magento/GoogleShopping/Helper/Data.php | 6 +- .../GoogleShopping/Model/Attribute/Price.php | 6 +- .../Magento/GoogleShopping/Model/Config.php | 8 +- .../GoogleShopping/Model/MassOperations.php | 6 +- app/code/Magento/GoogleShopping/composer.json | 22 +- .../Magento/GoogleShopping/etc/config.xml | 1 + .../Magento/GroupedImportExport/composer.json | 14 +- .../Model/Product/CatalogPrice.php | 6 +- .../Model/Product/Type/Grouped.php | 6 +- .../Grouped/AssociatedProductsCollection.php | 4 +- app/code/Magento/GroupedProduct/composer.json | 26 +- app/code/Magento/ImportExport/Helper/Data.php | 4 +- .../Model/Export/AbstractEntity.php | 6 +- .../Model/Export/Entity/AbstractEav.php | 4 +- .../Model/Export/Entity/AbstractEntity.php | 6 +- .../Model/Import/Entity/AbstractEav.php | 6 +- app/code/Magento/ImportExport/composer.json | 14 +- app/code/Magento/Index/App/Indexer.php | 9 + app/code/Magento/Index/App/Shell.php | 9 + app/code/Magento/Index/composer.json | 8 +- app/code/Magento/Indexer/App/Indexer.php | 10 + app/code/Magento/Indexer/App/Shell.php | 10 + app/code/Magento/Indexer/composer.json | 8 +- .../Install/App/Action/Plugin/Design.php | 99 --- .../Magento/Install/App/Action/Plugin/Dir.php | 93 --- .../Install/App/Action/Plugin/Install.php | 87 --- app/code/Magento/Install/App/Console.php | 64 +- .../Magento/Install/Controller/Wizard.php | 167 ---- .../Controller/Wizard/AdministratorPost.php | 57 -- .../Install/Controller/Wizard/Config.php | 53 -- .../Install/Controller/Wizard/ConfigPost.php | 65 -- .../Controller/Wizard/DownloadPost.php | 56 -- .../Install/Controller/Wizard/Install.php | 83 -- .../Install/Controller/Wizard/InstallDb.php | 54 -- .../Install/Controller/Wizard/Locale.php | 46 -- app/code/Magento/Install/Model/Installer.php | 40 +- .../Model/Installer/AbstractInstaller.php | 107 --- .../Install/Model/Installer/Config.php | 85 +- .../Install/Model/Installer/Console.php | 246 ++---- .../Magento/Install/Model/Installer/Db.php | 7 +- .../Install/Model/Installer/Db/AbstractDb.php | 2 +- .../Install/Model/Installer/Db/Mysql4.php | 7 +- .../Install/Model/Installer/Filesystem.php | 5 +- .../Magento/Install/Model/Installer/Pear.php | 5 +- .../Magento/Install/Model/Uninstaller.php | 160 ++++ app/code/Magento/Install/composer.json | 14 +- app/code/Magento/Install/etc/di.xml | 13 - app/code/Magento/Install/etc/install/di.xml | 20 - .../Helper/Validator.php} | 43 +- ...TokenService.php => AdminTokenService.php} | 91 +-- ...ace.php => AdminTokenServiceInterface.php} | 16 +- .../Service/V1/CustomerTokenService.php | 110 +++ .../V1/CustomerTokenServiceInterface.php | 52 ++ .../Magento/Integration/Service/V1/Oauth.php | 6 +- app/code/Magento/Integration/composer.json | 18 +- app/code/Magento/Integration/etc/di.xml | 3 +- app/code/Magento/Integration/etc/webapi.xml | 4 +- .../Magento/LayeredNavigation/composer.json | 8 +- app/code/Magento/Log/App/Shell.php | 9 + .../Customer/Edit/Tab/View/Status.php | 163 ++++ .../Block/Adminhtml/Online.php | 4 +- .../Block/Adminhtml/Online/Filter.php | 2 +- .../Adminhtml/Online/Grid/Renderer/Ip.php | 2 +- .../Adminhtml/Online/Grid/Renderer/Type.php | 2 +- .../Adminhtml/Online/Grid/Renderer/Url.php | 3 +- .../Controller/Adminhtml/Online/Index.php | 4 +- app/code/Magento/Log/Model/Aggregation.php | 6 +- app/code/Magento/Log/Model/Cron.php | 6 +- app/code/Magento/Log/Model/Log.php | 16 + .../Magento/Log/Model/Resource/Visitor.php | 15 +- .../Log/Model/Resource/Visitor/Collection.php | 2 +- .../Log/Model/Resource/Visitor/Online.php | 6 +- app/code/Magento/Log/Model/Visitor.php | 301 ++------ app/code/Magento/Log/Model/Visitor/Online.php | 2 +- app/code/Magento/Log/composer.json | 15 +- app/code/Magento/Log/etc/acl.xml | 36 + .../routes.xml => Log/etc/adminhtml/menu.xml} | 12 +- .../{Install => Log}/etc/adminhtml/routes.xml | 4 +- app/code/Magento/Log/etc/adminhtml/system.xml | 9 + app/code/Magento/Log/etc/di.xml | 9 - app/code/Magento/Log/etc/frontend/events.xml | 20 +- app/code/Magento/Log/etc/module.xml | 1 - app/code/Magento/Log/i18n/de_DE.csv | 5 + app/code/Magento/Log/i18n/en_US.csv | 5 + app/code/Magento/Log/i18n/es_ES.csv | 5 + app/code/Magento/Log/i18n/fr_FR.csv | 5 + app/code/Magento/Log/i18n/nl_NL.csv | 5 + app/code/Magento/Log/i18n/pt_BR.csv | 6 + app/code/Magento/Log/i18n/zh_CN.csv | 5 + .../Log/sql/log_setup/install-1.6.0.0.php | 15 +- .../adminhtml/layout/customer_index_edit.xml | 30 + .../layout/customer_online_index.xml | 10 +- .../adminhtml/templates/customer/status.phtml | 41 + .../view/adminhtml/templates/online.phtml | 0 .../Controller/Checkout/Address.php | 11 + .../Model/Checkout/Type/Multishipping.php | 6 +- app/code/Magento/Multishipping/composer.json | 22 +- .../Subscriber/Grid/Filter/Website.php | 6 +- .../Magento/Newsletter/Controller/Manage.php | 6 +- .../Newsletter/Controller/Subscriber.php | 4 +- app/code/Magento/Newsletter/Model/Queue.php | 4 +- .../Magento/Newsletter/Model/Subscriber.php | 6 +- .../Magento/Newsletter/Model/Template.php | 6 +- app/code/Magento/Newsletter/composer.json | 24 +- .../Magento/Newsletter/etc/frontend/di.xml | 5 - .../Magento/OfflinePayments/composer.json | 6 +- .../System/Config/ExportTablerates.php | 6 +- .../Model/Quote/Freeshipping.php | 6 +- .../Model/Resource/Carrier/Tablerate.php | 6 +- .../Magento/OfflineShipping/composer.json | 20 +- app/code/Magento/Ogone/Model/Api.php | 6 +- app/code/Magento/Ogone/composer.json | 12 +- .../Model/App/FrontController/MessageBox.php | 3 +- app/code/Magento/PageCache/composer.json | 8 +- .../PayPalRecurringPayment/composer.json | 16 +- .../Magento/Payment/Model/Method/Free.php | 6 +- app/code/Magento/Payment/composer.json | 14 +- app/code/Magento/Paypal/Model/Config.php | 6 +- app/code/Magento/Paypal/Model/Direct.php | 6 +- app/code/Magento/Paypal/Model/Express.php | 6 +- .../Magento/Paypal/Model/Express/Checkout.php | 17 +- app/code/Magento/Paypal/Model/Hostedpro.php | 4 +- .../Magento/Paypal/Model/Method/Agreement.php | 6 +- app/code/Magento/Paypal/Model/Observer.php | 2 +- .../Magento/Paypal/Model/PayflowExpress.php | 4 +- app/code/Magento/Paypal/Model/Payflowlink.php | 4 +- app/code/Magento/Paypal/Model/Payflowpro.php | 6 +- .../Paypal/Model/Report/Settlement.php | 6 +- app/code/Magento/Paypal/Model/Standard.php | 6 +- .../System/Config/Backend/MerchantCountry.php | 6 +- app/code/Magento/Paypal/composer.json | 30 +- app/code/Magento/Paypal/etc/adminhtml/di.xml | 7 - app/code/Magento/Paypal/etc/frontend/di.xml | 7 - app/code/Magento/Persistent/Helper/Data.php | 4 +- .../Magento/Persistent/Helper/Session.php | 4 +- app/code/Magento/Persistent/Model/Session.php | 46 +- app/code/Magento/Persistent/composer.json | 16 +- .../ProductAlert/Controller/Add/Price.php | 8 +- .../ProductAlert/Controller/Add/Stock.php | 2 +- .../Controller/Unsubscribe/Price.php | 2 +- .../Controller/Unsubscribe/PriceAll.php | 2 +- .../Controller/Unsubscribe/Stock.php | 2 +- .../Controller/Unsubscribe/StockAll.php | 2 +- app/code/Magento/ProductAlert/Helper/Data.php | 4 +- app/code/Magento/ProductAlert/Model/Email.php | 6 +- .../Magento/ProductAlert/Model/Observer.php | 6 +- app/code/Magento/ProductAlert/composer.json | 12 +- .../RecurringPayment/Model/Observer.php | 6 +- .../Magento/RecurringPayment/composer.json | 24 +- app/code/Magento/Reports/Model/Config.php | 6 +- .../Magento/Reports/Model/Event/Observer.php | 20 +- .../Model/Product/Index/AbstractIndex.php | 18 +- .../Reports/Model/Product/Index/Compared.php | 10 +- .../Magento/Reports/Model/Resource/Event.php | 6 +- .../Model/Resource/Order/Collection.php | 6 +- .../Model/Resource/Product/Collection.php | 4 +- .../Index/Collection/AbstractCollection.php | 16 +- .../Resource/Product/Lowstock/Collection.php | 4 +- .../Resource/Review/Customer/Collection.php | 4 +- app/code/Magento/Reports/composer.json | 36 +- app/code/Magento/Reports/etc/adminhtml/di.xml | 5 - app/code/Magento/RequireJs/composer.json | 6 +- .../Compare/ListCompare/Plugin/Review.php | 6 +- .../Controller/Adminhtml/Product/Post.php | 4 +- .../Magento/Review/Controller/Product.php | 6 +- .../Magento/Review/Model/Resource/Rating.php | 6 +- .../Model/Resource/Rating/Collection.php | 6 +- .../Model/Resource/Rating/Grid/Collection.php | 4 +- .../Rating/Option/Vote/Collection.php | 6 +- .../Magento/Review/Model/Resource/Review.php | 6 +- .../Model/Resource/Review/Collection.php | 6 +- .../Resource/Review/Product/Collection.php | 4 +- app/code/Magento/Review/Model/Review.php | 6 +- app/code/Magento/Review/composer.json | 22 +- app/code/Magento/Review/etc/adminhtml/di.xml | 1 - app/code/Magento/Review/etc/frontend/di.xml | 1 - app/code/Magento/Rss/Block/Catalog/Review.php | 6 +- app/code/Magento/Rss/composer.json | 22 +- .../Rss/view/frontend/templates/list.phtml | 2 +- app/code/Magento/Rule/composer.json | 12 +- .../Adminhtml/Order/Create/Save.php | 1 + app/code/Magento/Sales/Helper/Admin.php | 6 +- app/code/Magento/Sales/Helper/Guest.php | 29 +- app/code/Magento/Sales/Helper/Reorder.php | 4 +- .../Magento/Sales/Model/AbstractModel.php | 34 +- .../Magento/Sales/Model/EntityInterface.php | 13 +- app/code/Magento/Sales/Model/Increment.php | 77 ++ app/code/Magento/Sales/Model/Observer.php | 357 --------- .../AggregateSalesReportBestsellersData.php | 77 ++ .../AggregateSalesReportInvoicedData.php | 74 ++ .../AggregateSalesReportOrderData.php | 74 ++ .../AggregateSalesReportRefundedData.php | 77 ++ .../Model/Observer/Backend/CustomerQuote.php | 6 +- .../Model/Observer/CleanExpiredQuotes.php | 108 +++ .../Quote/AddVatRequestParamsOrderComment.php | 99 +++ .../Frontend/Quote/RestoreCustomerGroupId.php | 66 ++ .../Frontend/Quote/SetCanApplyMsrp.php | 71 ++ app/code/Magento/Sales/Model/Order.php | 174 +---- .../Magento/Sales/Model/Order/Creditmemo.php | 20 +- .../Sales/Model/Order/Creditmemo/Comment.php | 6 +- .../Model/Order/Creditmemo/Total/Shipping.php | 6 +- .../Model/Order/Email/Container/Container.php | 2 +- .../Magento/Sales/Model/Order/Invoice.php | 33 +- .../Sales/Model/Order/Invoice/Comment.php | 6 +- .../Magento/Sales/Model/Order/Payment.php | 6 +- .../Sales/Model/Order/Pdf/Creditmemo.php | 6 +- .../Magento/Sales/Model/Order/Pdf/Invoice.php | 6 +- .../Sales/Model/Order/Pdf/Shipment.php | 6 +- .../Magento/Sales/Model/Order/Shipment.php | 15 +- .../Sales/Model/Order/Shipment/Comment.php | 6 +- .../Sales/Model/Order/Shipment/Track.php | 6 +- app/code/Magento/Sales/Model/Order/Status.php | 6 +- .../Sales/Model/Order/Status/History.php | 6 +- app/code/Magento/Sales/Model/Quote.php | 6 +- .../Model/Quote/Address/RateResult/Method.php | 6 +- .../Model/Quote/Address/Total/Collector.php | 4 +- .../Model/Quote/Address/Total/Discount.php | 6 +- .../Sales/Model/Quote/Item/Processor.php | 4 +- .../Magento/Sales/Model/QuoteRepository.php | 6 +- .../Sales/Model/Resource/AbstractGrid.php | 100 +++ .../Sales/Model/Resource/AbstractResource.php | 6 +- .../Sales/Model/Resource/Attribute.php | 154 ++++ .../Collection/AbstractCollection.php | 30 + .../Magento/Sales/Model/Resource/Entity.php | 167 ++++ .../Sales/Model/Resource/GridInterface.php | 45 ++ .../Magento/Sales/Model/Resource/GridPool.php | 73 ++ .../Magento/Sales/Model/Resource/Order.php | 154 ++-- .../Model/Resource/Order/AbstractOrder.php | 479 ------------ .../Sales/Model/Resource/Order/Address.php | 50 +- .../Order/Attribute/Backend/Shipping.php | 3 +- .../Sales/Model/Resource/Order/Creditmemo.php | 61 +- .../Resource/Order/Creditmemo/Comment.php | 18 +- .../Model/Resource/Order/Creditmemo/Grid.php | 108 +++ .../Model/Resource/Order/Creditmemo/Item.php | 2 +- .../Sales/Model/Resource/Order/Grid.php | 102 +++ .../Model/Resource/Order/Handler/Address.php | 95 +++ .../Model/Resource/Order/Handler/State.php | 64 ++ .../Sales/Model/Resource/Order/Invoice.php | 73 +- .../Model/Resource/Order/Invoice/Comment.php | 21 +- .../Model/Resource/Order/Invoice/Grid.php | 102 +++ .../Model/Resource/Order/Invoice/Item.php | 2 +- .../Sales/Model/Resource/Order/Item.php | 6 +- .../Sales/Model/Resource/Order/Payment.php | 25 +- .../Resource/Order/Payment/Transaction.php | 2 +- .../Sales/Model/Resource/Order/Shipment.php | 65 +- .../Model/Resource/Order/Shipment/Comment.php | 18 +- .../Model/Resource/Order/Shipment/Grid.php | 97 +++ .../Model/Resource/Order/Shipment/Item.php | 2 +- .../Model/Resource/Order/Shipment/Track.php | 18 +- .../Model/Resource/Order/Status/History.php | 16 +- .../Sales/Model/Resource/Sale/Collection.php | 4 +- .../Sales/Service/V1/Data/Transaction.php | 2 +- .../Service/V1/Data/TransactionBuilder.php | 20 +- .../Service/V1/Data/TransactionMapper.php | 11 +- app/code/Magento/Sales/composer.json | 42 +- app/code/Magento/Sales/etc/crontab.xml | 12 +- app/code/Magento/Sales/etc/events.xml | 2 +- .../Magento/Sales/etc/frontend/events.xml | 4 +- .../Plugin/QuoteConfigProductAttributes.php | 2 +- .../SalesRule/Model/Quote/Discount.php | 9 +- app/code/Magento/SalesRule/Model/Rule.php | 6 +- .../Magento/SalesRule/Model/Validator.php | 45 +- .../Model/Validator/Pool.php} | 35 +- app/code/Magento/SalesRule/composer.json | 34 +- .../Block/Plugin/Catalog/Product/View.php | 56 ++ .../Magento/Sendfriend/Model/Sendfriend.php | 8 +- .../Model}/Source/Checktype.php | 2 +- app/code/Magento/Sendfriend/composer.json | 14 +- .../Sendfriend/etc/adminhtml/system.xml | 2 +- .../etc/frontend}/di.xml | 6 +- app/code/Magento/Shipping/Helper/Data.php | 6 +- .../Shipping/Model/Order/Pdf/Packaging.php | 6 +- .../Magento/Shipping/Model/Order/Track.php | 4 +- .../Magento/Shipping/Model/Rate/Result.php | 6 +- app/code/Magento/Shipping/Model/Shipping.php | 6 +- .../Shipping/Model/Shipping/Labels.php | 4 +- app/code/Magento/Shipping/composer.json | 26 +- app/code/Magento/Sitemap/Model/Observer.php | 6 +- .../Model/Resource/Catalog/Category.php | 6 +- .../Model/Resource/Catalog/Product.php | 6 +- app/code/Magento/Sitemap/Model/Sitemap.php | 6 +- app/code/Magento/Sitemap/composer.json | 16 +- .../Store/App/Action/Plugin/Context.php | 19 +- .../Store/App/Action/Plugin/StoreCheck.php | 26 +- .../Plugin/DispatchExceptionHandler.php | 80 -- .../Plugin/RequestPreprocessor.php | 16 +- .../Store/App/Request/PathInfoProcessor.php | 6 +- .../Magento/Store/App/Response/Redirect.php | 6 +- app/code/Magento/Store/Helper/Cookie.php | 4 +- .../Store/Model/Config/Reader/Store.php | 6 +- app/code/Magento/Store/Model/Group.php | 6 +- .../Magento/Store/Model/Resolver/Store.php | 9 +- .../Magento/Store/Model/Resolver/Website.php | 11 +- app/code/Magento/Store/Model/Storage/Db.php | 14 +- .../Store/Model/Storage/DefaultStorage.php | 13 +- .../Magento/Store/Model/StorageFactory.php | 74 +- app/code/Magento/Store/Model/Store.php | 102 +-- app/code/Magento/Store/Model/StoreManager.php | 16 +- app/code/Magento/Store/Model/StoresConfig.php | 8 +- app/code/Magento/Store/Model/System/Store.php | 6 +- app/code/Magento/Store/Model/Website.php | 6 +- app/code/Magento/Store/composer.json | 10 +- app/code/Magento/Store/etc/di.xml | 9 +- .../Magento/Tax/Controller/Adminhtml/Rate.php | 31 +- app/code/Magento/Tax/Helper/Data.php | 6 +- app/code/Magento/Tax/Model/Calculation.php | 6 +- .../Tax/Model/Resource/Calculation.php | 6 +- .../Resource/Calculation/Rate/Collection.php | 6 +- .../Model/System/Message/Notifications.php | 6 +- .../Tax/Service/V1/TaxCalculationService.php | 4 +- app/code/Magento/Tax/composer.json | 30 +- app/code/Magento/Tax/etc/acl.xml | 6 - app/code/Magento/Tax/etc/adminhtml/menu.xml | 1 - .../view/adminhtml/layout/tax_rate_block.xml | 27 +- .../view/adminhtml/layout/tax_rule_edit.xml | 1 - .../Adminhtml/Rate/Grid/Renderer/Country.php | 2 +- .../Block/Adminhtml/Rate/ImportExport.php | 2 +- .../Adminhtml/Rate/ImportExportHeader.php | 4 +- .../Controller/Adminhtml/Rate.php | 67 ++ .../Controller/Adminhtml/Rate/ExportCsv.php | 6 +- .../Controller/Adminhtml/Rate/ExportPost.php | 6 +- .../Controller/Adminhtml/Rate/ExportXml.php | 6 +- .../Adminhtml/Rate/ImportExport.php | 10 +- .../Controller/Adminhtml/Rate/ImportPost.php | 8 +- .../Model/Rate/CsvImportHandler.php | 3 +- .../Magento/TaxImportExport/composer.json | 23 + app/code/Magento/TaxImportExport/etc/acl.xml | 38 + .../etc/adminhtml/menu.xml} | 11 +- .../etc/adminhtml}/routes.xml | 8 +- .../Magento/TaxImportExport/etc/module.xml | 38 + .../view/adminhtml/layout/tax_rate_block.xml | 58 ++ .../view/adminhtml/layout/tax_rule_edit.xml | 30 + .../adminhtml/templates/importExport.phtml | 0 .../templates/importExportHeader.phtml | 0 app/code/Magento/Theme/Block/Html/Header.php | 2 +- app/code/Magento/Theme/Model/Config.php | 6 +- .../Theme/Model/Config/Customization.php | 6 +- app/code/Magento/Theme/composer.json | 16 +- .../Translation/Model/Inline/Parser.php | 6 +- .../Translation/Model/Resource/Translate.php | 18 +- app/code/Magento/Translation/composer.json | 10 +- app/code/Magento/Ups/composer.json | 18 +- .../UrlRedirect/Block/Catalog/Edit/Form.php | 6 +- .../UrlRedirect/Block/Cms/Page/Edit/Form.php | 4 +- .../Magento/UrlRedirect/Controller/Router.php | 23 +- .../Model/Resource/UrlRedirect/Collection.php | 6 +- app/code/Magento/UrlRedirect/composer.json | 15 +- app/code/Magento/UrlRedirect/etc/module.xml | 1 - .../App/FrontController/Plugin/UrlRewrite.php | 15 +- .../Model/Resource/UrlRewrite/Collection.php | 6 +- .../Magento/UrlRewrite/Model/UrlRewrite.php | 45 +- app/code/Magento/UrlRewrite/composer.json | 10 +- .../Adminhtml/User/InvalidateToken.php | 4 +- app/code/Magento/User/Model/User.php | 8 +- app/code/Magento/User/composer.json | 15 +- app/code/Magento/User/etc/module.xml | 1 - app/code/Magento/Usps/composer.json | 18 +- app/code/Magento/Webapi/Controller/Rest.php | 80 +- .../Controller/ServiceArgsSerializer.php | 98 ++- app/code/Magento/Webapi/Controller/Soap.php | 30 +- .../Controller/Soap/Request/Handler.php | 16 +- .../Magento/Webapi/Model/PathProcessor.php | 6 +- app/code/Magento/Webapi/Model/Soap/Server.php | 6 +- .../Webapi/Model/Soap/Wsdl/Generator.php | 6 +- app/code/Magento/Webapi/composer.json | 16 +- .../Magento/Webapi/etc/webapi_rest/di.xml | 5 - app/code/Magento/Weee/Helper/Data.php | 6 +- .../Weee/Model/Attribute/Backend/Weee/Tax.php | 6 +- .../Resource/Attribute/Backend/Weee/Tax.php | 6 +- app/code/Magento/Weee/Model/Tax.php | 6 +- app/code/Magento/Weee/composer.json | 24 +- .../Magento/Widget/Model/Template/Filter.php | 4 +- app/code/Magento/Widget/composer.json | 16 +- .../Wishlist/Controller/Index/Send.php | 2 +- app/code/Magento/Wishlist/Helper/Data.php | 6 +- app/code/Magento/Wishlist/Helper/Rss.php | 4 +- app/code/Magento/Wishlist/Model/Item.php | 6 +- .../Model/LocaleQuantityProcessor.php | 13 +- app/code/Magento/Wishlist/Model/Observer.php | 20 +- .../Model/Resource/Item/Collection.php | 6 +- .../Model/Resource/Item/Collection/Grid.php | 4 +- app/code/Magento/Wishlist/Model/Wishlist.php | 40 +- app/code/Magento/Wishlist/composer.json | 32 +- .../Magento/Wishlist/etc/adminhtml/di.xml | 1 - app/code/Magento/Wishlist/etc/frontend/di.xml | 6 - .../adminhtml/Magento/backend/composer.json | 4 +- .../adminhtml/Magento/backend/theme.xml | 2 +- .../frontend/Magento/blank/composer.json | 4 +- app/design/frontend/Magento/blank/theme.xml | 2 +- .../frontend/Magento/plushe/composer.json | 6 +- app/design/frontend/Magento/plushe/theme.xml | 2 +- app/design/install/Magento/basic/theme.xml | 2 +- app/etc/di.xml | 7 +- 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 | 4 +- dev/shell/indexer.php | 17 +- dev/shell/install.php | 39 +- dev/shell/log.php | 17 +- dev/shell/maintenance.php | 77 ++ dev/shell/newindexer.php | 17 +- dev/shell/run_data_fixtures.php | 36 + dev/shell/run_schema_updater.php | 36 + dev/shell/uninstall.php | 49 ++ .../Selenium/Element/LiselectElement.php | 73 -- .../Selenium/Element/LiselectstoreElement.php | 200 +++++ .../Selenium/Element/SuggestElement.php | 20 +- .../lib/Mtf/Util/Generate/Factory.php | 1 + .../lib/Mtf/Util/Generate/TestCase.php | 1 + .../lib/Mtf/Util/Generate/testcase.xml | 178 ++--- .../Test/Block/System/Config/PageActions.php | 19 +- .../System/Store/Edit/Form/GroupForm.php | 19 +- .../System/Store/Edit/Form/StoreForm.xml | 4 +- .../System/Store/Edit/Form/WebsiteForm.php | 19 +- .../System/Store/Edit/Form/WebsiteForm.xml} | 11 +- .../Test/Block/System/Store/StoreGrid.php | 50 +- .../Backend/Test/Block/Widget/FormTabs.php | 0 .../Backend/Test/Block/Widget/Grid.php | 6 +- .../Test/Page/{ => Adminhtml}/Dashboard.xml | 0 .../Test/Page/Adminhtml/DeleteWebsite.xml | 39 + .../Backend/Test/Page/Adminhtml/EditStore.xml | 44 ++ .../Test/Page/Adminhtml/EditWebsite.xml | 39 + .../Test/Page/Adminhtml/NewWebsiteIndex.xml | 39 + .../app/Magento/Backend/Test/etc/page.xml | 25 + .../Test/Block/Catalog/Product/View.php | 64 +- .../Catalog/Product/View/Type/Bundle.php | 268 +++++-- .../Option/{DropDown.php => Dropdown.php} | 4 +- .../Option/{DropDown.xml => Dropdown.xml} | 0 .../AssertBundleItemsOnProductPage.php | 68 +- .../Test/Constraint/AssertBundlePriceType.php | 12 +- .../Test/Constraint/AssertBundlePriceView.php | 2 +- .../Constraint/AssertBundleProductForm.php | 6 +- .../Constraint/AssertBundleProductPage.php | 65 +- ...roductCustomOptionsOnBundleProductPage.php | 20 - .../Magento/Bundle/Test/Fixture/Bundle.php | 22 +- .../Test/Fixture/CatalogProductBundle.php | 7 + .../Test/Fixture/CatalogProductBundle.xml | 6 + .../CatalogProductBundle/CheckoutData.php | 104 ++- .../Test/Page/Product/CatalogProductView.xml | 12 +- .../Test/TestCase/BundleDynamicTest.php | 14 +- .../Bundle/Test/TestCase/BundleFixedTest.php | 14 +- .../CreateBundleProductEntityTest.php | 4 +- .../Bundle/Test/TestCase/EditBundleTest.php | 6 +- .../UpdateBundleProductEntityTest.php | 4 +- .../Adminhtml/Product/Composite/Configure.php | 42 +- .../Product/Edit/AdvancedPricingTab.php | 9 +- .../Tab/ProductDetails/ParentCategoryIds.php | 24 +- .../Product/Edit/Tab/Super/Attribute.php | 141 ---- .../Product/Edit/Tab/Super/Config.php | 212 ----- .../Product/Edit/Tab/Super/Config/Matrix.php | 74 -- .../Product/Edit/Tab/Variations/Search.php | 100 --- .../Adminhtml/Product/FormPageActions.php | 25 +- .../Block/Adminhtml/Product/ProductForm.php | 143 ++-- .../Block/Adminhtml/Product/ProductForm.xml | 18 +- .../Block/Backend/Product/Attribute/Edit.php | 122 --- .../Block/Backend/Product/Attribute/Edit.xml | 53 -- .../Test/Block/Backend/ProductForm.php | 380 --------- .../Test/Block/Backend/ProductForm.xml | 138 ---- .../Block/Product/Compare/ListCompare.php | 2 +- .../Configurable/AffectedAttributeSet.php | 74 -- .../Product/ProductList/BottomToolbar.php | 57 ++ .../{Toolbar.php => TopToolbar.php} | 29 +- .../Catalog/Test/Block/Product/View.php | 169 ++-- .../Test/Block/Product/View/CustomOptions.php | 226 ++---- .../Test/Block/Product/View/CustomOptions.xml | 81 +- ...sertAddedProductAttributeOnProductForm.php | 2 +- .../Test/Constraint/AssertCategoryPage.php | 4 +- ...tAttributeAbsenceInSearchOnProductForm.php | 3 +- ...rtProductAttributeDisplayingOnFrontend.php | 0 ...ssertProductCustomOptionsOnProductPage.php | 45 +- .../Constraint/AssertProductDuplicateForm.php | 13 +- .../Test/Constraint/AssertProductForm.php | 27 +- .../Test/Constraint/AssertProductInCart.php | 57 +- .../Constraint/AssertProductInCategory.php | 2 +- .../Test/Constraint/AssertProductInStock.php | 2 +- ...AssertProductIsNotDisplayingOnFrontend.php | 2 +- .../AssertProductNotVisibleInCategory.php | 2 +- .../Test/Constraint/AssertProductPage.php | 214 ++++-- .../AssertProductSearchableBySku.php | 2 +- ...ssertProductTemplateGroupOnProductForm.php | 8 +- .../AssertProductTemplateOnProductForm.php | 10 +- .../Test/Constraint/AssertProductView.php | 2 +- .../AssertProductVisibleInCategory.php | 2 +- .../AssignedAttributes.php | 9 +- .../Test/Fixture/CatalogProductAttribute.php | 5 + .../Test/Fixture/CatalogProductAttribute.xml | 9 + .../Test/Fixture/CatalogProductSimple.php | 26 +- .../Test/Fixture/CatalogProductSimple.xml | 11 + .../CatalogProductSimple/CheckoutData.php | 72 +- .../Test/Fixture/CatalogProductVirtual.php | 7 +- .../Test/Fixture/CrosssellProducts.php | 3 +- .../Magento/Catalog/Test/Fixture/Product.php | 2 +- .../Catalog/Test/Fixture/ProductAttribute.php | 6 +- .../Catalog/Test/Fixture/SimpleProduct.php | 44 +- .../Handler/CatalogProductAttribute/Curl.php | 6 +- .../Handler/CatalogProductSimple/Curl.php | 7 + .../Test/Handler/CatalogProductSimple/Ui.php | 5 +- .../Catalog/Test/Handler/Ui/CreateProduct.php | 5 +- .../Page/Adminhtml/CatalogProductEdit.xml | 30 +- .../Test/Page/Adminhtml/CatalogProductNew.xml | 35 +- .../Page/Adminhtml/CatalogProductSetAdd.xml | 2 +- .../Page/Adminhtml/CatalogProductSetEdit.xml | 2 +- .../Page/Adminhtml/CatalogProductSetIndex.xml | 2 +- .../Page/Category/CatalogCategoryView.xml | 15 +- .../Repository/CatalogProductAttribute.php | 36 + .../Test/Repository/CatalogProductSimple.php | 1 + .../Catalog/Test/Repository/SimpleProduct.php | 121 +-- .../TestCase/Category/AssignProductTest.php | 2 +- .../TestCase/Product/CreateGroupedTest.php | 2 +- .../TestCase/Product/CreateProductTest.php | 2 +- .../Product/CreateSimpleProductEntityTest.php | 5 +- .../testCreate.csv | 38 +- .../Product/CreateSimpleWithCategoryTest.php | 4 +- ...SimpleWithCustomOptionsAndCategoryTest.php | 14 +- .../Test/TestCase/Product/CreateTest.php | 4 +- .../CreateVirtualProductEntityTest.php | 5 +- .../TestCase/Product/CreateVirtualTest.php | 2 +- .../Product/EditSimpleProductTest.php | 9 +- .../TestCase/Product/UnassignCategoryTest.php | 2 +- .../Product/UpdateSimpleProductEntityTest.php | 5 +- .../UpdateVirtualProductEntityTest.php | 4 +- ...UsedInConfigurableProductAttributeTest.php | 10 +- .../test.csv | 2 +- .../Magento/Catalog/Test/etc/constraint.xml | 5 +- .../app/Magento/Catalog/Test/etc/fixture.xml | 35 - .../AssertAdvancedSearchProductsResult.php | 2 +- .../Constraint/AssertCatalogSearchResult.php | 2 +- .../Test/Page/AdvancedResult.xml | 6 +- .../Test/Page/CatalogsearchResult.xml | 10 +- .../Test/TestCase/AdvancedSearchTest.php | 2 +- .../app/Magento/Checkout/Test/Block/Cart.php | 240 +----- .../Checkout/Test/Block/Cart/CartItem.php | 181 +++++ .../Constraint/AssertPriceInShoppingCart.php | 3 +- .../AssertProductQtyInShoppingCart.php | 3 +- .../AssertSubtotalInShoppingCart.php | 4 +- .../Magento/Cms/Test/Handler/CmsPage/Curl.php | 2 +- .../Product/AffectedAttributeSet.php} | 36 +- .../Product/AffectedAttributeSet.xml} | 0 .../Product/Edit/Tab/Super/Attribute.php | 140 ---- .../Product/Edit/Tab/Super/Config.php | 261 ++----- .../Edit/Tab/Super/Config/Attribute.php | 381 +++++++++ .../Edit/Tab/Super/Config/Attribute.xml} | 33 +- .../Config/Attribute/AttributeSelector.php | 47 ++ .../Super/Config/Attribute/ToggleDropdown.php | 104 +++ .../Product/Edit/Tab/Super/Config/Matrix.php | 152 +++- .../Product/Edit/Tab/Super/Config/Matrix.xml | 22 +- .../Product/Edit/Tab/Super/Matrix.php | 83 -- .../Product/Edit/Tab/Super/Options.php | 77 -- .../Adminhtml/Product/FormPageActions.php | 70 ++ .../Block/Adminhtml/Product/ProductForm.php | 204 ++--- .../Block/Adminhtml/Product/ProductForm.xml | 40 - .../Backend/Product/AffectedAttributeSet.php | 73 -- .../Block/Backend/Product/Attribute/Edit.php | 108 --- .../Block/Backend/Product/Attribute/Edit.xml | 53 -- .../Test/Block/Product/View.php | 125 +++ .../Product/View/ConfigurableOptions.php | 78 ++ ...rtChildProductIsNotDisplayedSeparately.php | 89 +++ .../Constraint/AssertChildProductsInGrid.php | 92 +++ .../Constraint/AssertConfigurableInCart.php | 104 --- .../AssertConfigurableInCategory.php | 124 --- ...AssertConfigurableProductDuplicateForm.php | 80 ++ .../AssertConfigurableProductForm.php | 134 ++-- .../AssertConfigurableProductInCart.php | 77 ++ ...tConfigurableProductInItemsOrderedGrid.php | 68 ++ .../AssertConfigurableProductPage.php | 99 +++ .../Constraint/AssertConfigurableView.php | 115 --- ...ductAttributeAbsenceInVariationsSearch.php | 21 +- .../AssertProductAttributeIsConfigurable.php | 8 +- ...AssertProductConfigurableDuplicateForm.php | 112 --- .../ConfigurableAttributesData.php | 581 -------------- .../Test/Fixture/ConfigurableProduct.php | 267 ++++--- ....php => ConfigurableProductInjectable.php} | 61 +- ....xml => ConfigurableProductInjectable.xml} | 23 +- .../CheckoutData.php | 108 +++ .../ConfigurableAttributesData.php | 726 ++++++++++++++++++ .../CatalogProductConfigurable/Curl.php | 169 ---- ...onfigurableProductInjectableInterface.php} | 6 +- .../ConfigurableProductInjectable/Curl.php | 181 +++++ .../Test/Handler/Curl/CreateConfigurable.php | 22 +- .../Page/Adminhtml/CatalogProductEdit.xml | 0 .../Test/Page/Adminhtml/CatalogProductNew.xml | 17 +- .../Test/Page/Product/CatalogProductView.xml | 36 + .../Test/Repository/ConfigurableProduct.php | 28 +- ....php => ConfigurableProductInjectable.php} | 9 +- .../CreateConfigurableProductEntityTest.php | 101 +++ .../test.csv | 5 + .../Test/TestCase}/CreateConfigurableTest.php | 23 +- .../TestCase}/CreateWithAttributeTest.php | 69 +- .../Test/TestCase}/EditConfigurableTest.php | 8 +- .../Product/CreateConfigurableEntityTest.php | 118 --- .../testCreate.csv | 2 - .../Test/etc/constraint.xml | 69 +- .../ConfigurableProduct/Test/etc/curl/di.xml | 2 +- .../ConfigurableProduct/Test/etc/fixture.xml | 6 +- .../ConfigurableProduct/Test/etc/page.xml | 42 + .../app/Magento/Core/Test/Block/Messages.php | 18 + .../Test/Block/Adminhtml/CustomerGrid.php | 7 + .../Block/Adminhtml/Edit/FormPageActions.php | 30 +- .../AssertMassActionSuccessUpdateMessage.php | 73 ++ .../Fixture/CustomerInjectable/GroupId.php | 2 +- .../Test/Page/Adminhtml/CustomerIndexEdit.xml | 2 +- .../Test/Page/CustomerAccountLogin.php | 87 --- .../Test/Page/CustomerAccountLogin.xml | 39 + .../TestCase/MassAssignCustomerGroupTest.php | 110 +++ .../MassAssignCustomerGroupTest/test.csv | 2 + .../Magento/Customer/Test/etc/constraint.xml | 3 + .../app/Magento/Customer/Test/etc/page.xml | 4 + .../AssertDownloadableDuplicateForm.php | 2 +- .../Fixture/CatalogProductDownloadable.php | 8 +- .../Fixture/CatalogProductDownloadable.xml | 2 + .../Create/LinksPurchasedSeparatelyTest.php | 4 +- .../CreateDownloadableProductEntityTest.php | 4 +- .../UpdateDownloadableProductEntityTest.php | 4 +- .../Constraint/AssertGroupedProductForm.php | 2 +- .../Test/Fixture/CatalogProductGrouped.php | 7 +- .../CreateGroupedProductEntityTest.php | 5 +- .../UpdateGroupedProductEntityTest.php | 4 +- .../Block/Adminhtml/Customer/AccountsGrid.php | 115 +++ .../Review/Products/Viewed/Action.php | 31 +- .../Review/Products/Viewed/Filter.php | 69 ++ .../Review/Products/Viewed/Filter.xml} | 19 +- .../Review/Products/Viewed}/ProductGrid.php | 51 +- .../Block/Adminhtml/Shopcart/Product/Grid.php | 77 ++ .../AssertNewAccountsReportTotalResult.php | 65 ++ .../Constraint/AssertProductInCartResult.php | 70 ++ .../AssertProductViewsReportTotalResult.php | 67 ++ .../Test/Page/Adminhtml/CustomerAccounts.xml | 34 + .../Test/Page/Adminhtml/ProductReportView.xml | 49 ++ .../Page/Adminhtml/ShopCartProductReport.xml | 35 + .../TestCase/NewAccountsReportEntityTest.php | 97 +++ .../NewAccountsReportEntityTest/test.csv | 5 + .../TestCase/ProductsInCartReportEntity.php | 159 ++++ .../ProductsInCartReportEntity/test.csv | 3 + .../ViewedProductsReportEntityTest.php | 150 ++++ .../ViewedProductsReportEntityTest/test.csv | 4 + .../Magento/Reports/Test/etc/constraint.xml | 9 + .../app/Magento/Reports/Test/etc/page.xml | 15 + .../Adminhtml/Customer/Edit/Tab/Reviews.php | 36 + .../Block/Adminhtml/Edit/CustomerForm.xml | 32 + .../Review/Test/Block/Adminhtml/Grid.php | 3 +- .../Adminhtml/Product/Edit/Tab/Reviews.php | 11 +- .../Block/Adminhtml/Product/ProductForm.xml | 32 + .../Test/Block/Adminhtml/ReviewsTab.php | 54 ++ .../AssertProductRatingInProductPage.php | 5 +- .../AssertProductRatingNotInProductPage.php | 6 +- .../Constraint/AssertProductReviewInGrid.php | 27 +- ...ssertProductReviewInGridOnCustomerPage.php | 111 +++ .../AssertProductReviewOnProductPage.php | 13 +- .../Test/Fixture/ReviewInjectable/Ratings.php | 11 +- .../CreateProductRatingEntityTest.php | 3 + .../CreateProductReviewBackendEntityTest.php | 18 +- .../CreateProductReviewFrontendEntityTest.php | 15 +- ...anageProductReviewFromCustomerPageTest.php | 254 ++++++ .../test.csv | 3 + .../MassActionsProductReviewEntityTest.php | 13 +- .../ModerateProductReviewEntityTest.php | 7 +- ...teProductReviewEntityOnProductPageTest.php | 211 +++++ .../test.csv | 2 + .../UpdateProductReviewEntityTest.php | 17 +- .../Magento/Review/Test/etc/constraint.xml | 3 + .../app/Magento/Store/Test/Block/Switcher.php | 35 + .../Test/Constraint/AssertStoreBackend.php | 67 ++ .../Store/Test/Constraint/AssertStoreForm.php | 74 ++ .../Test/Constraint/AssertStoreFrontend.php | 79 ++ .../Test/Constraint/AssertStoreGroupForm.php | 2 +- ...oreGroupSuccessDeleteAndBackupMessages.php | 2 +- .../Test/Constraint/AssertStoreInGrid.php | 70 ++ .../Test/Constraint/AssertStoreNotInGrid.php | 70 ++ .../Constraint/AssertStoreNotOnFrontend.php | 79 ++ ...ertStoreSuccessDeleteAndBackupMessages.php | 78 ++ .../AssertStoreSuccessDeleteMessage.php | 72 ++ .../AssertStoreSuccessSaveMessage.php | 72 ++ .../Test/Constraint/AssertWebsiteForm.php | 81 ++ .../Test/Constraint/AssertWebsiteInGrid.php} | 31 +- .../Constraint/AssertWebsiteNotInGrid.php | 70 ++ .../Constraint/AssertWebsiteOnStoreForm.php | 72 ++ ...tWebsiteSuccessDeleteAndBackupMessages.php | 78 ++ .../AssertWebsiteSuccessDeleteMessage.php | 72 ++ .../AssertWebsiteSuccessSaveMessage.php | 72 ++ .../app/Magento/Store/Test/Fixture/Store.php | 3 +- .../app/Magento/Store/Test/Fixture/Store.xml | 1 + .../Test/Fixture/Store/GroupId.php} | 64 +- .../Magento/Store/Test/Handler/Store/Curl.php | 1 + .../Magento/Store/Test/Repository/Store.php | 9 +- .../Store/Test/Repository/StoreGroup.php | 11 + .../Test/TestCase/CreateStoreEntityTest.php | 92 +++ .../TestCase/CreateStoreEntityTest/test.csv | 4 + .../Test/TestCase/CreateWebsiteEntityTest.php | 91 +++ .../TestCase/CreateWebsiteEntityTest/test.csv | 2 + .../Test/TestCase/DeleteStoreEntityTest.php | 124 +++ .../TestCase/DeleteStoreEntityTest/test.csv | 3 + .../TestCase/DeleteStoreGroupEntityTest.php | 2 +- .../DeleteStoreGroupEntityTest/test.csv | 4 +- .../Test/TestCase/DeleteWebsiteEntityTest.php | 126 +++ .../TestCase/DeleteWebsiteEntityTest/test.csv | 3 + .../Magento/Store/Test/TestCase/StoreTest.php | 4 +- .../Test/TestCase/UpdateStoreEntityTest.php | 96 +++ .../TestCase/UpdateStoreEntityTest/test.csv | 2 + .../TestCase/UpdateStoreGroupEntityTest.php | 2 +- .../Test/TestCase/UpdateWebsiteEntityTest.php | 126 +++ .../TestCase/UpdateWebsiteEntityTest/test.csv | 2 + .../app/Magento/Store/Test/etc/constraint.xml | 54 ++ .../Magento/Theme/Test/Block/Html/Footer.php | 66 ++ .../app/Magento/Theme/Test/Block/Links.php | 7 +- .../AssertUserRoleSalesRestrictedAccess.php | 2 +- .../Constraint/AssertUserSuccessLogOut.php | 2 +- .../Constraint/AssertUserSuccessLogin.php | 2 +- .../TestCase/DeleteAdminUserEntityTest.php | 2 +- .../TestCase/DeleteUserRoleEntityTest.php | 2 +- .../TestCase/UpdateAdminUserEntityTest.php | 2 +- .../UpdateAdminUserRoleEntityTest.php | 2 +- .../app/Magento/User/Test/etc/constraint.xml | 6 +- .../Adminhtml/Customer/Edit/Tab/Wishlist.php | 56 ++ .../Customer/Edit/Tab/Wishlist/Grid.php | 68 ++ .../Block/Adminhtml/Edit/CustomerForm.xml | 32 + .../Wishlist/Test/Block/Customer/Wishlist.php | 54 ++ .../Test/Block/Customer/Wishlist/Items.php | 56 ++ .../AssertProductIsAbsentInWishlist.php | 90 +++ ...oductFromCustomerWishlistOnBackendTest.php | 200 +++++ .../test.csv | 3 + .../Test/TestCase/ShareWishlistEntityTest.php | 18 +- .../Test/etc/{global => }/constraint.xml | 3 + .../functional/utils/generate/factory.php | 12 +- .../Magento/TestFramework/Helper/Eav.php | 2 +- .../TestFramework/ObjectManagerFactory.php | 1 + .../Magento/Backend/AdminConfigTest.php | 32 +- .../Urlrewrite/Catalog/Edit/FormTest.php | 6 +- .../Urlrewrite/Cms/Page/Edit/FormTest.php | 4 +- .../Block/Urlrewrite/Edit/FormTest.php | 2 +- .../BundleProductSaveProcessorTest.php | 215 ++++++ .../Magento/Captcha/Model/ObserverTest.php | 2 +- .../Magento/Catalog/Block/Product/NewTest.php | 2 +- .../Controller/Product/CompareTest.php | 29 +- .../Magento/Catalog/Helper/DataTest.php | 4 +- .../Magento/Catalog/Helper/ImageTest.php | 4 +- .../Magento/Catalog/Model/AbstractTest.php | 4 +- .../Model/Category/CategoryImageTest.php | 4 +- .../Magento/Catalog/Model/CategoryTest.php | 8 +- .../Catalog/Model/Layer/CategoryTest.php | 2 +- .../Product/Attribute/Backend/PriceTest.php | 2 +- .../Attribute/Backend/TierpriceTest.php | 4 +- .../Model/Product/Compare/ListCompareTest.php | 6 +- .../Catalog/Model/ProductExternalTest.php | 2 +- .../Magento/Catalog/Model/ProductTest.php | 2 +- .../Magento/Catalog/_files/products.php | 53 +- .../Catalog/_files/second_product_simple.php | 38 +- .../Catalog/controllers/_files/products.php | 4 +- .../Model/Import/ProductTest.php | 2 +- .../Magento/CatalogSearch/Helper/DataTest.php | 2 +- .../Magento/Centinel/CreateOrderTest.php | 2 +- .../Checkout/Model/Type/OnepageTest.php | 5 +- .../Checkout/_files/discount_10percent.php | 2 +- .../Magento/Cms/Controller/RouterTest.php | 5 +- .../testsuite/Magento/Cms/_files/block.php | 2 +- .../Magento/Core/Model/DesignTest.php | 6 +- .../Core/Model/Resource/Layout/UpdateTest.php | 2 +- .../Magento/Core/Model/View/DesignTest.php | 2 +- .../Magento/Core/_files/design_change.php | 2 +- .../Core/_files/design_change_timezone.php | 2 +- .../Core/_files/second_third_store.php | 2 +- .../testsuite/Magento/Core/_files/store.php | 6 +- .../Block/Adminhtml/Edit/Tab/CartTest.php | 2 +- .../Edit/Tab/View/PersonalInfoTest.php | 276 +++++++ .../Block/Adminhtml/Edit/Tab/ViewTest.php | 161 +--- .../{Log => Customer}/Model/VisitorTest.php | 10 +- .../Service/V1/CustomerAccountServiceTest.php | 4 +- .../Service/V1/CustomerGroupServiceTest.php | 8 +- ...ttribute_user_defined_address_rollback.php | 26 + .../attribute_user_defined_customer.php | 2 + ...tribute_user_defined_customer_rollback.php | 26 + .../Magento/Customer/_files/quote.php | 2 +- .../Model/Export/AddressTest.php | 2 +- .../Model/Export/CustomerTest.php | 2 +- .../Magento/Email/Model/TemplateTest.php | 8 +- .../Magento/Framework/App/FilesystemTest.php | 5 +- .../FrontController/Plugin/InstallTest.php | 92 --- .../Module/Plugin/DbStatusValidatorTest.php | 70 ++ .../ObjectManager/_files/config_merged.xml | 6 +- .../ObjectManager/_files/config_one.xml | 4 +- .../ObjectManager/_files/config_two.xml | 6 +- .../Search/Adapter/Mysql/AdapterTest.php | 324 ++++++++ .../Adapter/Mysql/Builder/Query/MatchTest.php | 72 ++ .../Search/Request/Config/ConverterTest.php | 2 + .../Framework/Search/Request/MapperTest.php | 2 +- .../Framework/Search/_files/products.php | 345 +++++++++ .../Framework/Search/_files/requests.xml | 223 ++++++ .../Search/_files/search_request.xml | 4 +- .../Search/_files/search_request_config.php | 4 +- .../Framework/Session/SessionManagerTest.php | 19 +- .../Stdlib/Cookie/CookieScopeTest.php | 30 +- .../Framework/Translate/InlineTest.php | 6 +- .../Magento/Framework/TranslateTest.php | 2 +- .../Model/Export/AbstractStubEntity.php | 2 +- .../Model/Export/EntityAbstractTest.php | 2 +- .../Magento/Install/Controller/WizardTest.php | 69 -- .../Install/Model/Installer/ConfigTest.php | 100 --- .../Magento/Install/Model/InstallerTest.php | 233 ------ .../Service/V1/AdminTokenServiceTest.php | 130 ++++ ...eTest.php => CustomerTokenServiceTest.php} | 58 +- .../Block/Adminhtml/OnlineTest.php | 6 +- .../Magento/Newsletter/_files/queue.php | 4 +- .../Magento/Newsletter/_files/subscribers.php | 4 +- .../Magento/Payment/Model/ObserverTest.php | 2 +- .../Paypal/Model/Express/CheckoutTest.php | 1 - .../Magento/Paypal/Model/VoidTest.php | 2 +- .../Paypal/_files/quote_payment_express.php | 2 +- .../quote_payment_express_with_customer.php | 2 +- .../Paypal/_files/quote_payment_payflow.php | 2 +- .../Paypal/_files/quote_payment_standard.php | 2 +- .../Magento/Review/_files/customer_review.php | 4 +- .../Review/_files/different_reviews.php | 12 +- .../Magento/Review/_files/review_xss.php | 4 +- .../Magento/Review/_files/reviews.php | 4 +- .../Magento/Rss/Controller/CatalogTest.php | 2 +- .../Magento/Sales/Model/AbstractTest.php | 70 -- .../testsuite/Magento/Sales/_files/order.php | 2 +- .../Sales/_files/order_fixture_store.php | 2 +- .../Magento/Sales/_files/order_info.php | 2 +- .../_files/order_paid_with_payflowpro.php | 2 +- .../testsuite/Magento/Sales/_files/quote.php | 2 +- .../_files/cart_rule_40_percent_off.php | 2 +- .../_files/cart_rule_50_percent_off.php | 2 +- .../Magento/Store/Model/GroupTest.php | 4 +- .../Magento/Store/Model/StoreTest.php | 242 +++--- .../Magento/Store/_files/second_store.php | 6 +- .../Block/Adminhtml/Rate/ImportExportTest.php | 6 +- .../Model/Rate/CsvImportHandlerTest.php | 4 +- .../Rate/_files/correct_rates_import_file.csv | 0 .../rates_import_file_incorrect_country.csv | 0 .../Integrity/Magento/Payment/MethodsTest.php | 8 +- .../Modular/BlockInstantiationTest.php | 2 +- .../Integrity/Modular/TemplateFilesTest.php | 2 +- .../Magento/Theme/Block/Html/FooterTest.php | 2 +- .../Magento/Theme/Block/HtmlTest.php | 2 +- .../Translation/Model/InlineParserTest.php | 2 +- .../UrlRewrite/Model/UrlRewriteTest.php | 22 +- .../Adminhtml/User/InvalidateTokenTest.php | 16 +- .../Webapi/Model/PathProcessorTest.php | 4 +- .../Magento/Webapi/Model/Soap/ServerTest.php | 2 +- .../Magento/TestFramework/Application.php | 92 +-- .../TestFramework/Performance/Bootstrap.php | 65 +- .../TestFramework/Performance/Testsuite.php | 10 - dev/tests/performance/framework/bootstrap.php | 14 +- .../Magento/Test/ApplicationTest.php | 50 +- .../Test/Performance/BootstrapTest.php | 39 +- .../Test/Performance/TestsuiteTest.php | 10 +- .../app_base_dir/dev/shell/uninstall.php | 25 + dev/tests/performance/run_scenarios.php | 13 +- .../catalog_200_categories_80k_products.php | 2 +- .../testsuite/fixtures/sales_100k_orders.php | 2 +- dev/tests/static/framework/bootstrap.php | 3 +- .../Magento/Framework/Search/ConfigTest.php | 1 - .../_files/dependency_test/tables_ce.php | 1 + .../Test/Legacy/_files/obsolete_classes.php | 76 +- .../Test/Legacy/_files/obsolete_methods.php | 12 +- .../Legacy/_files/obsolete_properties.php | 4 +- .../Magento/Test/Php/LiveCodeTest.php | 52 +- .../Test/Php/_files/whitelist/common.txt | 12 +- dev/tests/unit/framework/bootstrap.php | 4 +- .../Model/System/Message/BaseurlTest.php | 2 +- .../Model/CompositeUserContextTest.php | 105 +-- .../Model/Directpost/ObserverTest.php | 2 +- .../Magento/Backend/AdminConfigTest.php | 39 +- .../Grid/Column/Renderer/CurrencyTest.php | 2 +- .../Magento/Backend/Model/ConfigTest.php | 4 +- .../Magento/Backup/Helper/DataTest.php | 6 +- .../Bundle/Model/Product/CatalogPriceTest.php | 2 +- .../Bundle/Model/Product/PriceTest.php | 2 +- .../BundleProductLoadProcessorTest.php | 129 ++++ .../BundleProductSaveProcessorTest.php | 302 ++++++++ .../V1/Product/Link/ReadServiceTest.php | 24 +- .../V1/Product/Link/WriteServiceTest.php | 22 +- .../V1/Product/Option/ReadServiceTest.php | 24 +- .../Product/Initialization/HelperTest.php | 2 +- .../Catalog/Controller/Category/ViewTest.php | 4 +- .../Helper/Product/Flat/IndexerTest.php | 4 +- .../Magento/Catalog/Model/ConfigTest.php | 2 +- .../Product/Flat/Action/EraserTest.php | 2 +- .../Indexer/Product/Flat/Action/RowTest.php | 2 +- .../Indexer/Product/Price/ObserverTest.php | 4 +- .../Price/System/Config/PriceScopeTest.php | 2 +- .../Category/FilterableAttributeListTest.php | 2 +- .../Model/Layer/Category/StateKeyTest.php | 2 +- .../Layer/Search/CollectionFilterTest.php | 2 +- .../Search/FilterableAttributeListTest.php | 2 +- .../Model/Layer/Search/StateKeyTest.php | 2 +- .../Magento/Catalog/Model/LayerTest.php | 4 +- .../Backend/Groupprice/AbstractTest.php | 2 +- .../Product/Attribute/Frontend/ImageTest.php | 4 +- .../Source/CountryofmanufactureTest.php | 4 +- .../Catalog/Model/Product/ImageTest.php | 2 +- .../Magento/Catalog/Model/Product/UrlTest.php | 2 +- .../Magento/Catalog/Model/ProductTest.php | 2 +- .../Catalog/Model/Resource/AbstractTest.php | 2 +- .../Model/Resource/Eav/AttributeTest.php | 2 +- .../Model/Resource/Product/FlatTest.php | 4 +- .../Product/Link/Product/CollectionTest.php | 4 +- .../Product/Option/CollectionTest.php | 2 +- .../Service/V1/Data/Category/TreeTest.php | 4 +- .../Attribute/Media/ReadServiceTest.php | 2 +- .../V1/Product/GroupPriceServiceTest.php | 2 +- .../ProductLoadProcessorCompositeTest.php | 140 ++++ .../ProductSaveProcessorCompositeTest.php | 200 +++++ .../V1/Product/TierPriceServiceTest.php | 2 +- .../Catalog/Service/V1/ProductServiceTest.php | 37 +- .../Model/Import/Product/Type/OptionTest.php | 2 +- .../CatalogInventory/Model/Stock/ItemTest.php | 4 +- .../Magento/CatalogRule/Model/RuleTest.php | 4 +- .../Magento/CatalogSearch/Helper/DataTest.php | 4 +- .../Magento/Checkout/Controller/CartTest.php | 2 +- .../Checkout/Controller/Onepage/IndexTest.php | 217 ++++++ .../Magento/Checkout/Helper/CartTest.php | 4 +- .../Magento/Checkout/Helper/DataTest.php | 8 +- .../Magento/Checkout/Model/SessionTest.php | 4 +- .../Checkout/Model/Type/OnepageTest.php | 4 +- .../V1/Address/Billing/ReadServiceTest.php | 2 +- .../V1/Address/Billing/WriteServiceTest.php | 2 +- .../V1/Address/Shipping/ReadServiceTest.php | 2 +- .../V1/Address/Shipping/WriteServiceTest.php | 2 +- .../Service/V1/Cart/WriteServiceTest.php | 2 +- .../Service/V1/Coupon/ReadServiceTest.php | 2 +- .../Service/V1/Coupon/WriteServiceTest.php | 2 +- .../Data/Cart/ShippingMethodConverterTest.php | 2 +- .../V1/PaymentMethod/ReadServiceTest.php | 2 +- .../V1/PaymentMethod/WriteServiceTest.php | 2 +- .../V1/ShippingMethod/ReadServiceTest.php | 2 +- .../V1/ShippingMethod/WriteServiceTest.php | 2 +- .../Service/V1/Agreement/ReadServiceTest.php | 2 +- .../Model/Product/Type/ConfigurableTest.php | 81 +- .../Pricing/Price/AttributePriceTest.php | 2 +- .../V1/Product/Option/WriteServiceTest.php | 2 +- .../Contact/Controller/Index/IndexTest.php | 136 ++++ .../Contact/Controller/Index/PostTest.php | 254 ++++++ .../Magento/Contact/Controller/IndexTest.php | 98 +++ .../Magento/Contact/Helper/DataTest.php | 138 ++++ .../Model/System/Config/Backend/LinksTest.php | 48 ++ .../FrontController/Plugin/InstallTest.php | 100 --- .../testsuite/Magento/Core/App/MediaTest.php | 47 +- .../Magento/Core/Model/Layout/MergeTest.php | 32 +- .../Core/Model/Url/ScopeResolverTest.php | 2 +- .../Magento/Core/Model/View/DesignTest.php | 2 +- .../Plugin/ApplicationInitializerTest.php | 71 -- .../Block/Adminhtml/Edit/Tab/ViewTest.php | 71 ++ .../Magento/Customer/Block/Widget/DobTest.php | 46 +- .../Controller/Account/CreatePostTest.php | 48 +- .../Controller/Adminhtml/Index/IndexTest.php | 197 +++++ .../Magento/Customer/Helper/AddressTest.php | 4 +- .../Magento/Customer/Model/ConverterTest.php | 4 +- .../Customer/Attribute/Backend/StoreTest.php | 6 +- .../Attribute/Backend/WebsiteTest.php | 6 +- .../Model/Layout/DepersonalizePluginTest.php | 2 +- .../Model/Metadata/Form/AbstractDataTest.php | 18 +- .../Customer/Model/Metadata/Form/DateTest.php | 17 +- .../Magento/Customer/Model/SessionTest.php | 16 - .../Magento/Customer/Model/VisitorTest.php | 182 +++++ .../Service/V1/CustomerAccountServiceTest.php | 4 +- .../Service/V1/CustomerAddressServiceTest.php | 4 +- .../Eav/AttributeMetadataConverterTest.php | 12 +- .../Magento/Directory/Helper/DataTest.php | 2 +- .../Directory/Model/PriceCurrencyTest.php | 2 +- .../Edit/Tab/Downloadable/LinksTest.php | 189 ++++- .../Edit/Tab/Downloadable/SamplesTest.php | 161 +++- .../Downloadable/Product/Edit/LinkTest.php | 261 +++++++ .../Downloadable/Product/Edit/SampleTest.php | 238 ++++++ .../Downloadable/Helper/DownloadTest.php | 9 +- .../Resource/Attribute/CollectionTest.php | 4 +- .../Attribute/Option/CollectionTest.php | 4 +- .../Block/Adminhtml/Template/PreviewTest.php | 4 +- .../Magento/Fedex/Model/CarrierTest.php | 2 +- .../Magento/Framework/App/BootstrapTest.php | 248 ++++++ .../Magento/Framework/App/Cache/StateTest.php | 22 +- .../App/EntryPoint/EntryPointTest.php | 184 ----- .../Framework/App/Error/HandlerTest.php | 175 ----- .../ErrorHandlerTest.php} | 27 +- .../DirectoryList/VerificationTest.php | 4 +- .../Magento/Framework/App/HttpTest.php | 29 +- .../Framework/App/MaintenanceModeTest.php | 168 ++++ .../Framework/App/PageCache/VersionTest.php | 5 + .../Framework/App/Response/HttpTest.php | 14 +- .../App/State/MaintenanceModeTest.php | 96 --- .../Framework/App/StaticResourceTest.php | 16 +- .../Magento/Framework/Backup/MediaTest.php | 6 +- .../Magento/Framework/Backup/NomediaTest.php | 6 +- .../Framework/DB/Adapter/Pdo/MysqlTest.php | 2 +- .../Magento/Framework/DB/SelectTest.php | 60 +- .../Framework/Event/Config/DataTest.php | 73 -- .../Instruction/MagentoImportTest.php | 10 +- .../Magento/Framework/Locale/ListsTest.php | 13 - .../Magento/Framework/LoggerTest.php | 32 +- .../Declaration/Reader/FilesystemTest.php | 4 - .../Magento/Framework/Module/ManagerTest.php | 148 ++-- .../Module/Plugin/DbStatusValidatorTest.php | 198 +++++ .../Magento/Framework/Module/UpdaterTest.php | 142 ++-- .../Mapper/_files/mapped_simple_di_config.php | 2 +- .../Config/Mapper/_files/simple_di_config.xml | 2 +- .../ObjectManager/Helper/CompositeTest.php | 85 ++ .../Search/Adapter/Mysql/AdapterTest.php | 137 ++++ .../Adapter/Mysql/Builder/Query/MatchTest.php | 93 +++ .../Search/Adapter/Mysql/DimensionsTest.php | 154 ++++ .../Mysql/Filter/Builder/RangeTest.php | 157 ++++ .../Adapter/Mysql/Filter/Builder/TermTest.php | 121 +++ .../Adapter/Mysql/Filter/BuilderTest.php | 340 ++++++++ .../Search/Adapter/Mysql/MapperTest.php | 354 +++++++++ .../Adapter/Mysql/ResponseFactoryTest.php | 105 +++ .../Search/Adapter/Mysql/ScoreBuilderTest.php | 68 ++ .../Magento/Framework/Search/DocumentTest.php | 6 +- .../Framework/Search/QueryResponseTest.php | 19 +- .../Framework/Search/RequestFactoryTest.php | 10 +- .../Magento/Framework/Session/ConfigTest.php | 9 - .../Framework/Session/SessionManagerTest.php | 2 +- .../Framework/Simplexml/ConfigTest.php | 2 +- .../Stdlib/Cookie/CookieScopeTest.php | 40 +- .../Stdlib/Cookie/PhpCookieManagerTest.php | 98 ++- .../Cookie/SensitiveCookieMetadataTest.php | 199 ++++- .../Framework/View/Asset/RepositoryTest.php | 19 +- .../Framework/View/Asset/SourceTest.php | 10 +- .../Framework/View/TemplateEngine/PhpTest.php | 6 +- .../Service/V1/WriteServiceTest.php | 2 +- .../Googleshopping/Items/MassAddTest.php | 4 +- .../GoogleShopping/Model/ConfigTest.php | 73 ++ .../Model/MassOperationsTest.php | 4 +- .../Composite/Fieldset/GroupedTest.php | 2 +- .../Model/Product/CatalogPriceTest.php | 2 +- .../Model/Import/Entity/EavAbstractTest.php | 2 +- .../Magento/Index/App/IndexerTest.php | 54 +- .../testsuite/Magento/Index/App/ShellTest.php | 6 + .../Magento/Indexer/App/IndexerTest.php | 36 +- .../Magento/Indexer/App/ShellTest.php | 6 + .../Install/App/Action/Plugin/DirTest.php | 114 --- .../Install/App/Action/Plugin/InstallTest.php | 100 --- .../Magento/Install/App/ConsoleTest.php | 276 ------- .../Install/Controller/Wizard/LocaleTest.php | 301 -------- .../Install/Model/Installer/ConfigTest.php | 159 ---- .../Install/Model/Installer/ConsoleTest.php | 229 ------ .../Install/Model/Installer/Db/Mysql4Test.php | 122 --- .../Magento/Install/Model/InstallerTest.php | 137 ---- .../Integration/Helper/Oauth/ConsumerTest.php | 4 +- .../Service/V1/AdminTokenServiceTest.php | 30 +- ...eTest.php => CustomerTokenServiceTest.php} | 30 +- .../Integration/Service/V1/OauthTest.php | 2 +- .../testsuite/Magento/Log/App/ShellTest.php | 6 + .../Customer/Edit/Tab/View/StatusTest.php | 184 +++++ .../testsuite/Magento/Log/Model/LogTest.php | 102 +++ .../Magento/Log/Model/VisitorTest.php | 150 +++- .../testsuite/Magento/Ogone/Model/ApiTest.php | 2 +- .../App/FrontController/MessageBoxTest.php | 4 + .../Magento/Payment/Model/Method/FreeTest.php | 2 +- .../Paypal/Model/Express/CheckoutTest.php | 167 +++- .../Magento/Paypal/Model/PayflowlinkTest.php | 2 +- .../Magento/Persistent/Model/SessionTest.php | 8 + .../Block/Payment/Related/Orders/GridTest.php | 4 +- .../Review/Block/Customer/RecentTest.php | 4 +- .../Controller/Adminhtml/Product/PostTest.php | 4 +- .../Magento/Review/Model/ReviewTest.php | 4 +- .../Magento/Rss/Block/Catalog/ReviewTest.php | 2 +- .../Magento/Rss/Block/Catalog/SpecialTest.php | 2 +- .../Magento/Rule/Model/ActionFactoryTest.php | 66 ++ .../Rule/Model/Condition/CombineTest.php | 12 +- .../Rule/Model/ConditionFactoryTest.php | 66 ++ .../Rule/Model/Renderer/ActionsTest.php | 78 ++ .../Rule/Model/Renderer/ConditionsTest.php | 78 ++ .../Collection/AbstractCollectionTest.php | 181 +++++ .../testsuite/Magento/Rule/Model/RuleTest.php | 125 +++ .../Magento/Sales/Helper/AdminTest.php | 4 +- .../Magento/Sales/Helper/DataTest.php | 2 +- .../Magento/Sales/Helper/GuestTest.php | 56 +- .../Magento/Sales/Helper/ReorderTest.php | 2 +- .../Magento/Sales/Model/AbstractModelTest.php | 33 +- .../Magento/Sales/Model/IncrementTest.php | 80 ++ ...ggregateSalesReportBestsellersDataTest.php | 113 +++ .../AggregateSalesReportInvoicedDataTest.php | 113 +++ .../AggregateSalesReportOrderDataTest.php | 113 +++ .../AggregateSalesReportRefundedDataTest.php | 113 +++ .../Observer/Backend/CustomerQuoteTest.php | 4 +- .../Model/Observer/CleanExpiredQuotesTest.php | 95 +++ .../AddVatRequestParamsOrderCommentTest.php | 141 ++++ .../Quote/RestoreCustomerGroupIdTest.php | 94 +++ .../Magento/Sales/Model/ObserverTest.php | 456 ----------- .../Sales/Model/Order/CreditmemoTest.php | 8 +- .../Magento/Sales/Model/Order/InvoiceTest.php | 6 + .../Sales/Model/Order/ShipmentTest.php | 31 +- .../Magento/Sales/Model/OrderTest.php | 22 +- .../Sales/Model/Quote/Item/ProcessorTest.php | 2 +- .../Sales/Model/QuoteRepositoryTest.php | 2 +- .../Sales/Model/Resource/AttributeTest.php | 170 ++++ .../Sales/Model/Resource/GridPoolTest.php | 103 +++ .../Model/Resource/Order/AddressTest.php | 27 +- .../Resource/Order/Creditmemo/GridTest.php | 169 ++++ .../Sales/Model/Resource/Order/GridTest.php | 166 ++++ .../Resource/Order/Handler/AddressTest.php | 189 +++++ .../Resource/Order/Handler/StateTest.php | 223 ++++++ .../Model/Resource/Order/Invoice/GridTest.php | 169 ++++ .../Resource/Order/Shipment/GridTest.php | 169 ++++ .../Sales/Model/Resource/OrderTest.php | 215 ++++++ .../Service/V1/Data/TransactionMapperTest.php | 31 +- .../SalesRule/Model/Quote/DiscountTest.php | 15 +- .../SalesRule/Model/Validator/PoolTest.php | 53 ++ .../Magento/SalesRule/Model/ValidatorTest.php | 605 +++++++-------- .../Block/Plugin/Catalog/Product/ViewTest.php | 85 ++ .../Sendfriend/Model/SendfriendTest.php | 2 +- .../Store/App/Action/Plugin/ContextTest.php | 20 +- .../App/Action/Plugin/StoreCheckTest.php | 37 +- .../Plugin/DispatchExceptionHandlerTest.php | 72 -- .../Plugin/RequestPreprocessorTest.php | 25 +- .../Store/App/Response/RedirectTest.php | 2 +- .../Magento/Store/Block/SwitchTest.php | 2 +- .../Store/Model/Config/Reader/StoreTest.php | 2 +- .../Store/Model/Resolver/StoreTest.php | 4 +- .../Store/Model/Resolver/WebsiteTest.php | 4 +- .../Magento/Store/Model/Storage/DbTest.php | 4 +- .../Store/Model/StorageFactoryTest.php | 44 +- .../Magento/Store/Model/StoreManagerTest.php | 2 +- .../Magento/Store/Model/StoreTest.php | 210 +++-- .../Magento/Store/Model/StoresConfigTest.php | 2 +- .../Tax/Model/Resource/CalculationTest.php | 2 +- .../Service/V1/TaxCalculationServiceTest.php | 4 +- .../Theme/Model/Config/CustomizationTest.php | 4 +- .../Magento/Theme/Model/ConfigTest.php | 2 +- .../testsuite/Magento/User/Model/UserTest.php | 4 +- .../Magento/Webapi/Controller/RestTest.php | 61 +- .../Controller/Soap/Request/HandlerTest.php | 2 +- .../Magento/Webapi/Controller/SoapTest.php | 60 +- .../Magento/Webapi/Model/Soap/ServerTest.php | 2 +- .../Webapi/Model/Soap/Wsdl/GeneratorTest.php | 4 +- .../Service/Entity/DataFromArrayTest.php | 5 +- .../Magento/Wishlist/Helper/DataTest.php | 2 +- .../Model/AuthenticationStateTest.php | 14 +- .../Magento/Wishlist/Model/ConfigTest.php | 70 +- .../Magento/Wishlist/Model/ItemTest.php | 282 +++++-- .../Model/LocaleQuantityProcessorTest.php | 88 +++ .../Magento/Wishlist/Model/ObserverTest.php | 332 ++++++++ .../Magento/Wishlist/Model/WishlistTest.php | 303 ++++++++ .../Tools/Dependency/generate/bootstrap.php | 6 +- .../Magento/Tools/Migration/themes_view.php | 7 +- dev/tools/Magento/Tools/View/deploy.php | 1 - dev/tools/bootstrap.php | 1 - index.php | 16 +- .../Magento/Framework/App/Bootstrap.php | 391 ++++++++++ .../Magento/Framework/App/Cache/State.php | 6 +- .../Magento/Framework/App/Config/Element.php | 1 + lib/internal/Magento/Framework/App/Cron.php | 9 + .../Framework/App/EntryPoint/EntryPoint.php | 104 --- .../Magento/Framework/App/Error/Handler.php | 105 --- .../Handler.php => App/ErrorHandler.php} | 56 +- .../Filesystem/DirectoryList/Verification.php | 6 +- lib/internal/Magento/Framework/App/Http.php | 203 ++++- .../Magento/Framework/App/InitException.php | 16 +- .../Magento/Framework/App/MaintenanceMode.php | 140 ++++ .../Framework/App/ObjectManagerFactory.php | 4 +- .../Framework/App/PageCache/Version.php | 3 +- .../Magento/Framework/App/Response/Http.php | 4 +- .../Framework/App/State/MaintenanceMode.php | 87 --- .../Magento/Framework/App/StaticResource.php | 42 +- .../Magento/Framework/AppInterface.php | 15 +- .../Magento/Framework/BootstrapException.php | 33 - lib/internal/Magento/Framework/DB/Select.php | 77 +- .../Magento/Framework/Event/Config/Data.php | 27 - .../Filter/LocalizedToNormalized.php | 11 +- .../Instruction/MagentoImport.php | 12 +- .../Magento/Framework/Locale/Lists.php | 25 +- .../Module/Declaration/Reader/Filesystem.php | 16 +- .../Magento/Framework/Module}/Exception.php | 9 +- .../Module/FrontController/Plugin/Install.php | 81 -- .../Magento/Framework/Module/Manager.php | 55 +- .../Module/Plugin/DbStatusValidator.php | 116 +++ .../Magento/Framework/Module/Updater.php | 70 +- .../ObjectManager/Helper/Composite.php | 70 ++ .../Framework/Search/AbstractKeyValuePair.php | 71 ++ .../Search/Adapter/Mysql/Adapter.php | 48 +- .../Adapter/Mysql/AggregationFactory.php | 7 +- .../Search/Adapter/Mysql/Dimensions.php | 90 +++ .../Search/Adapter/Mysql/DocumentFactory.php | 37 +- .../Search/Adapter/Mysql/Filter/Builder.php | 129 ++++ .../Mysql/Filter/Builder/FilterInterface.php | 35 + .../Adapter/Mysql/Filter/Builder/Range.php | 87 +++ .../Adapter/Mysql/Filter/Builder/Term.php | 59 ++ .../Mysql/Filter/BuilderInterface.php} | 15 +- .../Framework/Search/Adapter/Mysql/Mapper.php | 237 +++++- .../Adapter/Mysql/Query/Builder/Match.php | 59 ++ .../Mysql/Query/Builder/QueryInterface.php | 34 +- .../Search/Adapter/Mysql/ResponseFactory.php | 55 +- .../Search/Adapter/Mysql/ScoreBuilder.php | 116 +++ .../Adapter/Mysql/ScoreBuilderFactory.php | 28 +- .../Framework/Search/AdapterFactory.php | 5 +- .../Framework/Search/AdapterInterface.php | 5 +- .../Magento/Framework/Search/Aggregation.php | 5 +- .../Magento/Framework/Search/Bucket.php | 50 +- .../Magento/Framework/Search/Document.php | 5 +- .../Framework/Search/DocumentField.php | 50 +- .../Framework/Search/EntityMetadata.php | 54 ++ .../Framework/Search/QueryResponse.php | 13 +- .../Magento/Framework/Search/Request.php | 5 +- .../Search/Request/Aggregation/Metric.php | 5 +- .../Search/Request/Aggregation/Range.php | 3 +- .../Request/Aggregation/RangeBucket.php | 5 +- .../Search/Request/Aggregation/TermBucket.php | 5 +- .../Search/Request/BucketInterface.php | 5 +- .../Search/Request/Config/Converter.php | 52 +- .../Search/Request/Config/SchemaLocator.php | 5 +- .../Framework/Search/Request/Dimension.php | 38 +- .../Framework/Search/Request/Filter/Bool.php | 10 +- .../Framework/Search/Request/Filter/Range.php | 3 +- .../Framework/Search/Request/Filter/Term.php | 5 +- .../Search/Request/FilterInterface.php | 5 +- .../Framework/Search/Request/Mapper.php | 18 +- .../Framework/Search/Request/Query/Bool.php | 14 +- .../Framework/Search/Request/Query/Filter.php | 5 +- .../Framework/Search/Request/Query/Match.php | 5 +- .../Search/Request/QueryInterface.php | 5 +- .../Framework/Search/RequestFactory.php | 10 +- .../Framework/Search/RequestInterface.php | 5 +- .../Framework/Search/ResponseInterface.php | 5 +- .../Magento/Framework/Search/SearchEngine.php | 5 +- .../Search/SearchEngineInterface.php | 5 +- .../Magento/Framework/Search/etc/requests.xsd | 10 +- .../Search/etc/search_request_merged.xsd | 7 +- .../Framework/Service/ArrayObjectSearch.php | 78 ++ .../Service/Config/MetadataConfig.php | 2 +- .../Data/AbstractExtensibleObjectBuilder.php | 2 +- .../Data/AbstractSimpleObjectBuilder.php | 4 +- .../Service/Data/AttributeMetadata.php | 20 +- .../Service/ExtensibleDataObjectConverter.php | 9 +- .../Service/SimpleDataObjectConverter.php | 87 ++- .../Magento/Framework/Session/Config.php | 10 +- .../Magento/Framework/Session/Generic.php | 6 +- .../Framework/Session/SessionManager.php | 6 +- .../Session/SessionManagerInterface.php | 3 +- .../Stdlib/Cookie/CookieMetadata.php | 23 + .../Framework/Stdlib/Cookie/CookieScope.php | 2 +- .../Stdlib/Cookie/CookieScopeInterface.php | 58 ++ .../Stdlib/Cookie/PhpCookieManager.php | 17 +- .../Stdlib/Cookie/PublicCookieMetadata.php | 28 - .../Stdlib/Cookie/SensitiveCookieMetadata.php | 54 ++ .../Framework}/StoreManagerInterface.php | 5 +- .../Framework/View/Asset/Repository.php | 12 +- .../Magento/Framework/View/Asset/Source.php | 12 +- .../Framework/View/Design/Theme/Provider.php | 75 -- .../Framework/View/Element/Template.php | 2 +- .../View/Element/Template/Context.php | 8 +- lib/internal/Magento/Framework/composer.json | 2 +- .../tiny_mce/plugins/media/img/flv_player.swf | Bin 11668 -> 0 bytes pub/cron.php | 14 +- pub/errors/default/report.phtml | 4 +- pub/get.php | 15 +- pub/index.php | 19 +- pub/static.php | 8 +- setup/composer.json | 3 +- .../Controller/Install/StartController.php | 67 +- .../Magento/Setup/src/Model/AdminAccount.php | 2 + var/.htaccess | 2 +- 1674 files changed, 36006 insertions(+), 19386 deletions(-) create mode 100644 CONTRIBUTOR_LICENSE_AGREEMENT.html rename app/code/Magento/Bundle/Service/V1/Data/Product/{Link/Metadata.php => Link.php} (85%) rename app/code/Magento/Bundle/Service/V1/Data/Product/{Link/MetadataBuilder.php => LinkBuilder.php} (71%) rename app/code/Magento/Bundle/Service/V1/Data/Product/{Link/MetadataConverter.php => LinkConverter.php} (89%) create mode 100644 app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php create mode 100644 app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php delete mode 100644 app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php delete mode 100644 app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php rename app/code/Magento/{Reports/etc/frontend/di.xml => Bundle/etc/data_object.xml} (76%) create mode 100644 app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php create mode 100644 app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php create mode 100644 app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php create mode 100644 app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php create mode 100644 app/code/Magento/CatalogSearch/etc/search_request.xml delete mode 100644 app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php create mode 100644 app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php create mode 100644 app/code/Magento/Customer/Model/Resource/Visitor.php create mode 100644 app/code/Magento/Customer/Model/Visitor.php rename app/code/Magento/{Install/Controller/Wizard/DownloadAuto.php => Customer/Service/V1/Data/CustomerGroupSearchResults.php} (72%) create mode 100644 app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php create mode 100644 app/code/Magento/Customer/etc/frontend/events.xml create mode 100644 app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml create mode 100644 app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php delete mode 100644 app/code/Magento/Install/App/Action/Plugin/Design.php delete mode 100644 app/code/Magento/Install/App/Action/Plugin/Dir.php delete mode 100644 app/code/Magento/Install/App/Action/Plugin/Install.php delete mode 100644 app/code/Magento/Install/Controller/Wizard.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/AdministratorPost.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/Config.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/ConfigPost.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/DownloadPost.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/Install.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/InstallDb.php delete mode 100644 app/code/Magento/Install/Controller/Wizard/Locale.php delete mode 100644 app/code/Magento/Install/Model/Installer/AbstractInstaller.php create mode 100644 app/code/Magento/Install/Model/Uninstaller.php rename app/code/Magento/{Install/Controller/Wizard/End.php => Integration/Helper/Validator.php} (55%) rename app/code/Magento/Integration/Service/V1/{TokenService.php => AdminTokenService.php} (58%) rename app/code/Magento/Integration/Service/V1/{TokenServiceInterface.php => AdminTokenServiceInterface.php} (78%) create mode 100644 app/code/Magento/Integration/Service/V1/CustomerTokenService.php create mode 100644 app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php create mode 100644 app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php rename app/code/Magento/{Customer => Log}/Block/Adminhtml/Online.php (92%) rename app/code/Magento/{Customer => Log}/Block/Adminhtml/Online/Filter.php (97%) rename app/code/Magento/{Customer => Log}/Block/Adminhtml/Online/Grid/Renderer/Ip.php (95%) rename app/code/Magento/{Customer => Log}/Block/Adminhtml/Online/Grid/Renderer/Type.php (95%) rename app/code/Magento/{Customer => Log}/Block/Adminhtml/Online/Grid/Renderer/Url.php (95%) rename app/code/Magento/{Customer => Log}/Controller/Adminhtml/Online/Index.php (92%) create mode 100644 app/code/Magento/Log/etc/acl.xml rename app/code/Magento/{Install/etc/frontend/routes.xml => Log/etc/adminhtml/menu.xml} (77%) rename app/code/Magento/{Install => Log}/etc/adminhtml/routes.xml (91%) create mode 100644 app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml rename app/code/Magento/{Customer => Log}/view/adminhtml/layout/customer_online_index.xml (95%) create mode 100644 app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml rename app/code/Magento/{Customer => Log}/view/adminhtml/templates/online.phtml (100%) rename dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php => app/code/Magento/Sales/Model/EntityInterface.php (85%) create mode 100644 app/code/Magento/Sales/Model/Increment.php delete mode 100644 app/code/Magento/Sales/Model/Observer.php create mode 100644 app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php create mode 100644 app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php create mode 100644 app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php create mode 100644 app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php create mode 100644 app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php create mode 100644 app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php create mode 100644 app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php create mode 100644 app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php create mode 100644 app/code/Magento/Sales/Model/Resource/AbstractGrid.php create mode 100644 app/code/Magento/Sales/Model/Resource/Attribute.php create mode 100644 app/code/Magento/Sales/Model/Resource/Entity.php create mode 100644 app/code/Magento/Sales/Model/Resource/GridInterface.php create mode 100644 app/code/Magento/Sales/Model/Resource/GridPool.php delete mode 100644 app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Grid.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Handler/State.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php create mode 100644 app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php rename app/code/Magento/{Install/Controller/Index/Index.php => SalesRule/Model/Validator/Pool.php} (62%) create mode 100644 app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php rename app/code/Magento/{Backend/Model/Config => Sendfriend/Model}/Source/Checktype.php (96%) rename app/code/Magento/{Newsletter/etc/adminhtml => Sendfriend/etc/frontend}/di.xml (86%) delete mode 100644 app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php rename app/code/Magento/{Tax => TaxImportExport}/Block/Adminhtml/Rate/Grid/Renderer/Country.php (95%) rename app/code/Magento/{Tax => TaxImportExport}/Block/Adminhtml/Rate/ImportExport.php (96%) rename app/code/Magento/{Tax => TaxImportExport}/Block/Adminhtml/Rate/ImportExportHeader.php (91%) create mode 100644 app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php rename app/code/Magento/{Tax => TaxImportExport}/Controller/Adminhtml/Rate/ExportCsv.php (88%) rename app/code/Magento/{Tax => TaxImportExport}/Controller/Adminhtml/Rate/ExportPost.php (93%) rename app/code/Magento/{Tax => TaxImportExport}/Controller/Adminhtml/Rate/ExportXml.php (88%) rename app/code/Magento/{Tax => TaxImportExport}/Controller/Adminhtml/Rate/ImportExport.php (75%) rename app/code/Magento/{Tax => TaxImportExport}/Controller/Adminhtml/Rate/ImportPost.php (86%) rename app/code/Magento/{Tax => TaxImportExport}/Model/Rate/CsvImportHandler.php (99%) create mode 100644 app/code/Magento/TaxImportExport/composer.json create mode 100644 app/code/Magento/TaxImportExport/etc/acl.xml rename app/code/Magento/{Checkout/etc/adminhtml/di.xml => TaxImportExport/etc/adminhtml/menu.xml} (74%) rename app/code/Magento/{Install/etc/install => TaxImportExport/etc/adminhtml}/routes.xml (89%) create mode 100644 app/code/Magento/TaxImportExport/etc/module.xml create mode 100644 app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml create mode 100644 app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml rename app/code/Magento/{Tax => TaxImportExport}/view/adminhtml/templates/importExport.phtml (100%) rename app/code/Magento/{Tax => TaxImportExport}/view/adminhtml/templates/importExportHeader.phtml (100%) create mode 100644 dev/shell/maintenance.php create mode 100644 dev/shell/run_data_fixtures.php create mode 100644 dev/shell/run_schema_updater.php create mode 100644 dev/shell/uninstall.php delete mode 100644 dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php create mode 100644 dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php rename lib/internal/Magento/Framework/Session/SessionConsole.php => dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php (83%) rename dev/tests/functional/tests/app/Magento/{ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml => Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml} (85%) mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php rename dev/tests/functional/tests/app/Magento/Backend/Test/Page/{ => Adminhtml}/Dashboard.xml (100%) create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml rename dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/{DropDown.php => Dropdown.php} (95%) rename dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/{DropDown.xml => Dropdown.xml} (100%) mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php rename lib/internal/Magento/Framework/Module/UpdaterInterface.php => dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php (74%) delete mode 100755 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php create mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php rename dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/{Toolbar.php => TopToolbar.php} (74%) mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeDisplayingOnFrontend.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php create mode 100755 dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php rename dev/tests/functional/tests/app/Magento/{Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php => ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php} (69%) mode change 100644 => 100755 rename dev/tests/functional/tests/app/Magento/{Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.xml => ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.xml} (100%) mode change 100644 => 100755 delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php rename dev/tests/functional/tests/app/Magento/{Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml => ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml} (60%) mode change 100644 => 100755 create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php delete mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php create mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php rename dev/tests/functional/tests/app/Magento/{Catalog => ConfigurableProduct}/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php (76%) mode change 100755 => 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php rename dev/tests/functional/tests/app/Magento/{Catalog => ConfigurableProduct}/Test/Fixture/ConfigurableProduct.php (59%) mode change 100755 => 100644 rename dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/{CatalogProductConfigurable.php => ConfigurableProductInjectable.php} (92%) rename dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/{CatalogProductConfigurable.xml => ConfigurableProductInjectable.xml} (94%) create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php delete mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php rename dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/{CatalogProductConfigurable/CatalogProductConfigurableInterface.php => ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php} (82%) create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php rename dev/tests/functional/tests/app/Magento/{Catalog => ConfigurableProduct}/Test/Handler/Curl/CreateConfigurable.php (94%) mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductEdit.xml mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml rename dev/tests/functional/tests/app/Magento/{Catalog => ConfigurableProduct}/Test/Repository/ConfigurableProduct.php (88%) mode change 100755 => 100644 rename dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/{CatalogProductConfigurable.php => ConfigurableProductInjectable.php} (91%) create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv rename dev/tests/functional/tests/app/Magento/{Catalog/Test/TestCase/Product => ConfigurableProduct/Test/TestCase}/CreateConfigurableTest.php (88%) rename dev/tests/functional/tests/app/Magento/{Catalog/Test/TestCase/Product/Configurable => ConfigurableProduct/Test/TestCase}/CreateWithAttributeTest.php (76%) mode change 100755 => 100644 rename dev/tests/functional/tests/app/Magento/{Catalog/Test/TestCase/Product/Configurable => ConfigurableProduct/Test/TestCase}/EditConfigurableTest.php (92%) mode change 100755 => 100644 delete mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php delete mode 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv mode change 100644 => 100755 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml create mode 100644 dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml rename lib/internal/Magento/Framework/Error/HandlerInterface.php => dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php (65%) create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php delete mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php rename app/code/Magento/Install/Controller/Wizard/Administrator.php => dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php (67%) create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php rename dev/tests/functional/tests/app/Magento/{ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml => Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml} (77%) rename dev/tests/functional/tests/app/Magento/{Catalog/Test/Block/Backend => Reports/Test/Block/Adminhtml/Review/Products/Viewed}/ProductGrid.php (55%) create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml rename app/code/Magento/Webapi/DeserializationException.php => dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php (81%) create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php rename dev/tests/functional/tests/app/Magento/{ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php => Store/Test/Constraint/AssertWebsiteInGrid.php} (59%) create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php rename dev/tests/functional/tests/app/Magento/{ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php => Store/Test/Fixture/Store/GroupId.php} (61%) create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv rename dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/{global => }/constraint.xml (88%) rename app/code/Magento/Install/Controller/Wizard/LocalePost.php => dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php (63%) create mode 100644 dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php rename app/code/Magento/Install/Controller/Wizard/BeginPost.php => dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php (56%) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php rename dev/tests/integration/testsuite/Magento/{Log => Customer}/Model/VisitorTest.php (91%) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php delete mode 100644 dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml delete mode 100644 dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php rename dev/tests/integration/testsuite/Magento/Integration/Service/V1/{TokenServiceTest.php => CustomerTokenServiceTest.php} (68%) rename dev/tests/integration/testsuite/Magento/{Customer => Log}/Block/Adminhtml/OnlineTest.php (87%) delete mode 100644 dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php rename dev/tests/integration/testsuite/Magento/{Tax => TaxImportExport}/Block/Adminhtml/Rate/ImportExportTest.php (87%) rename dev/tests/integration/testsuite/Magento/{Tax => TaxImportExport}/Model/Rate/CsvImportHandlerTest.php (97%) rename dev/tests/integration/testsuite/Magento/{Tax => TaxImportExport}/Model/Rate/_files/correct_rates_import_file.csv (100%) rename dev/tests/integration/testsuite/Magento/{Tax => TaxImportExport}/Model/Rate/_files/rates_import_file_incorrect_country.csv (100%) create mode 100644 dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php create mode 100644 dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php rename dev/tests/unit/testsuite/Magento/Framework/{Error/HandlerTest.php => App/ErrorHandlerTest.php} (78%) create mode 100644 dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php delete mode 100644 dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php rename dev/tests/unit/testsuite/Magento/Integration/Service/V1/{TokenServiceTest.php => CustomerTokenServiceTest.php} (89%) create mode 100644 dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php rename app/code/Magento/Install/Controller/Wizard/Download.php => dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php (60%) create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php rename app/code/Magento/Install/Controller/Wizard/Begin.php => dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php (60%) create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php rename app/code/Magento/Install/Controller/Wizard/Index.php => dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php (80%) create mode 100644 dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php create mode 100644 lib/internal/Magento/Framework/App/Bootstrap.php delete mode 100644 lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php delete mode 100644 lib/internal/Magento/Framework/App/Error/Handler.php rename lib/internal/Magento/Framework/{Error/Handler.php => App/ErrorHandler.php} (60%) rename dev/tests/unit/testsuite/Magento/Install/App/_files/config.php => lib/internal/Magento/Framework/App/InitException.php (69%) create mode 100644 lib/internal/Magento/Framework/App/MaintenanceMode.php delete mode 100644 lib/internal/Magento/Framework/App/State/MaintenanceMode.php delete mode 100644 lib/internal/Magento/Framework/BootstrapException.php rename dev/tests/unit/testsuite/Magento/_files/errors/report.php => lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php (72%) rename {app/code/Magento/Store/Model => lib/internal/Magento/Framework/Module}/Exception.php (88%) delete mode 100644 lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php create mode 100644 lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php create mode 100644 lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php create mode 100644 lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php rename lib/internal/Magento/Framework/{App/EntryPointInterface.php => Search/Adapter/Mysql/Filter/BuilderInterface.php} (76%) create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php rename app/code/Magento/Install/Controller/Wizard/LocaleChange.php => lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php (60%) create mode 100644 lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php rename app/code/Magento/Sales/Model/Resource/Factory.php => lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php (68%) create mode 100644 lib/internal/Magento/Framework/Search/EntityMetadata.php create mode 100644 lib/internal/Magento/Framework/Service/ArrayObjectSearch.php rename app/code/Magento/Install/Controller/Wizard/DownloadManual.php => lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php (71%) create mode 100644 lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php rename {app/code/Magento/Store/Model => lib/internal/Magento/Framework}/StoreManagerInterface.php (95%) delete mode 100644 lib/internal/Magento/Framework/View/Design/Theme/Provider.php delete mode 100644 lib/web/tiny_mce/plugins/media/img/flv_player.swf diff --git a/.htaccess b/.htaccess index f1ef8719ba1..a0e18f2633d 100644 --- a/.htaccess +++ b/.htaccess @@ -188,3 +188,4 @@ ## http://developer.yahoo.com/performance/rules.html#etags #FileETag none + diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2a7a7293a..d9c1ce2f968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,65 @@ +0.1.0-alpha95 +============= + * Modularity + * Log module became switchable + * New switchable module TaxImportExport was created + * Sales module improvement: + * Performance was improved + * Complexity of the order persistence logic was reduced + * Unit tests coverage for modules was increased: + * Magento\Rule + * Magento\Contact + * Framework: + * Composite and bundle save/load processors were added + * Support for the complex custom attributes were added + * Generic abstract data objects, that is simple and extensible (supports custom attributes), were created  + * Search Library: + * Approach of matching the fields to table names was implemented + * MySQL Adapter Library for Match and Filtered query types was added + * Ability to filter queries was added + * Response handler for MySQL adapter was added + * XML declarations for full-text search were added + * Functional tests: + * Add Products to Order from Last Ordered Products Section + * Add Products to Order from Products in Comparison List Section + * Add Products to Order from Recently Compared Products Section + * Create Configurable Product + * Create Store + * Create Website + * Delete Product From Customer Wishlist On Backend + * Delete Store + * Delete Website + * Viewed Products Report + * Products In Cart Report + * Manage Product Review from Customer Page + * Mass Assign Customer Group + * New Account Report + * Update Product Review From Product Page + * Update Store + * Manage Product Review From Customer Page + * Other: + * Session.name ini set + * Calls to setPublicCookie became more secured + * Generating the session ID for sensitive data was added + *  Fixed bugs: + * Placing the order from backend + * Redirecting the customer to empty shopping cart instead of displaying credit card iFrame on checkout with for PayPal Payflow Link + * Showing the  message for multiple shipping address checkout in Authorize partial approval flow + * Mess detector failure + * flv_player security vulnerability + * Calling the inexistent method in cart with shopping cart price rules + * Overriding a non-empty custom attribute value with empty value in store view scope + * Editing  in 'WYSIWYG editor' by clicking "Use Default" checkbox when switched to store view scope + * RSS list page vulnerability + * Applying the store View title on frontend for configurable attributes + * Viewing the uploaded sample in downloadable product + * Google Shopping: Problem with publishing products if change value for option 'Update Google Shopping Item when Product is Updated' + * Configuration scope of items' InStock status on order cancellation + * Creating the new customer in admin + * GitHub requests: + * #621 -- Parse error: syntax error, unexpected T_OBJECT_OPERATOR + * #651 -- Multishipping checkout add/edit address page issue + 0.1.0-alpha94 ============= * Implemented API services: @@ -15,7 +77,7 @@ * Create Shopping Cart Gift Message service * Create Shopping Cart Totals service * Fixed bugs: - * Fixed an issue where selecting a shipping method in PayPal Express Checkout resulted in a fatal error + * Fixed an issue where selecting a shipping method in PayPal Express Checkout resulted in a fatal error * Fixed an issue where the information displayed on the Payment Information step of Zero Subtotal Checkout was confusing * Fixed a JavaScript error in shipping label * Fixed an issue with wrong layout of the storefront pages @@ -26,20 +88,20 @@ * Fixed an issue where taxes were not applied in the shopping cart after registering customer on the storefront * Fixed an issue where the wrong html markup was generated on My order pages for the WEEE tax * Fixed an issue where the built-in caching did not work on product pages - * Removed the stream resource usage to avoid errors when the allow_url_fopen PHP option is set to Off + * Removed the stream resource usage to avoid errors when the allow_url_fopen PHP option is set to Off * Fixed the New Return page layout on the backend - * Fixed an issue where it was impossible to apply a specific coupon code when the Apply to Shipping Amount option of the Shopping Cart Rule was set to Yes + * Fixed an issue where it was impossible to apply a specific coupon code when the Apply to Shipping Amount option of the Shopping Cart Rule was set to Yes * Removed file paths/content from test case names in data-driven tests - * Fixed an issue where pagination was absent in the Order Status grid + * Fixed an issue where pagination was absent in the Order Status grid * Fixed an issue where after applying a discount coupon and changing the currency the discount value was incorrect * Fixed an issue where trying to a new rating resulted in a fatal error * Fixed an issue where the minimum order amount was compared with subtotal without taxes * Fixed an issue where it was impossible to open the previous step during Onepage Checkout - * Fixed an issue with Persistent Shopping Cart where an unexpected message was displayed during checkout if a user started the checkout after the short-term cookie had expired + * Fixed an issue with Persistent Shopping Cart where an unexpected message was displayed during checkout if a user started the checkout after the short-term cookie had expired * Fixed an issue where a customer was redirected to the shopping cart after selecting shipping method during checkout with a payment method using 3D Secure * Fixed an issue where the Cart Item service used itemSku instead itemId * Fixed an issue where gift messages for individual items were not saved during backend order creation - * Fixed an issue where the Purchase Order Number input field was not displayed in Onepage Checkout if only one payment method was enabled + * Fixed an issue where the Purchase Order Number input field was not displayed in Onepage Checkout if only one payment method was enabled * GitHub requests: * [#446] (https://github.com/magento/magento2/issues/446) -- Rounding different in order to original quote calculation diff --git a/CONTRIBUTOR_LICENSE_AGREEMENT.html b/CONTRIBUTOR_LICENSE_AGREEMENT.html new file mode 100644 index 00000000000..58281b8e8ae --- /dev/null +++ b/CONTRIBUTOR_LICENSE_AGREEMENT.html @@ -0,0 +1,131 @@ +<!DOCTYPE html> +<html> +<head> + <title>CONTRIBUTOR LICENSE AGREEMENT</title> + <style> + body { + font-size: 14px; + } + + ol { + counter-reset: list1; + font-family: Verdana, Arial, Helvetica, sans-serif; + padding-bottom: 12px; + } + li { + list-style-type: none; + padding-top: 12px; + } + ol li:before { + counter-increment: list1; + content: counter(list1) ". "; + } + ol ol { + counter-reset: list2; + } + ol ol li:before { + counter-increment: list2; + content: counter(list1) "." counter(list2) ". "; + } + h2 { + text-align: center; + font-family: Verdana, Arial, Helvetica, sans-serif; + } + p { + font-family: Verdana, Arial, Helvetica, sans-serif; + } + div { + width: 800px; + margin: 0 auto; + } + </style> +</head> +<body> +<div> +<h2> + CONTRIBUTOR LICENSE AGREEMENT +</h2> +<p> + This Contributor License Agreement ("Agreement") is made and entered into as of _______________, 20__ (the "Effective Date"), by and between X.commerce, Inc. dba Magento, Inc., a Delaware corporation with its principal place of business at 10441 Jefferson Blvd., Suite 200, Culver City, CA 90232 ("Magento", "we", "us", or "our"), and ______________________________, a _______________ with its principal place of business at _______________________________________ ("Contributor", "you" or "your", and collectively with Magento, the "Parties"). +</p> +<ol> + <li><strong><u>Definitions:</u></strong> + <ol> + <li> + <strong>"Contribution"</strong> means any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Magento for inclusion in, or documentation of, any of the products or services owned or managed by Magento (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication provided to Magento or its representatives, including, but not limited to, communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Magento for the purpose of discussing, modifying, revising, and improving the Work, including identification of errors and/or issues and the remedy thereof. + </li> + <li> + <strong>"Contributor"</strong>, <strong>"you"</strong>, or <strong>"your"</strong> means the copyright owner or legal entity authorized by the copyright owner that is entering into this Agreement. + </li> + <li> + <strong>"Contributor Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Contributor or any of its subsidiaries. + </li> + <li> + <strong>"Control"</strong> means (i) the power, direct or indirect, to cause the direction or management of an entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares of an entity, or (iii) beneficial ownership of an entity. + </li> + <li> + <strong>"Magento Affiliate"</strong> means any past, present or future subsidiary, parent company, sister company, or other corporation, firm, business, partnership, joint venture or entity that controls, is controlled by, or is under common control of Magento or any of its subsidiaries. + </li> + </ol> + </li> + <li><strong><u>License Grants:</u></strong> + <ol> + <li><strong>Grant of Copyright License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates and all third party recipients of software, services, and all other information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Contributions and such derivative works.</li> + <li><strong>Grant of Patent License.</strong> Subject to the terms and conditions of this Agreement, Contributor and Contributor Affiliates hereby grant to Magento, Magento Affiliates, and all third party recipients of software, services, and information distributed by Magento as part of any Magento project, product or service a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Contributions, where such license applies only to those patent claims licensable by Contributor that are necessarily infringed by Contributions alone or by combination with software and/or information related to any Magento project, product or service.</li> + <li><strong>Grant to Magento and Magento Affiliates.</strong> The rights conferred in this Agreement on Magento shall automatically and immediately extend to any entity that later becomes a Magento Affiliate or a part of Magento.</li> + <li><strong>Contributions.</strong> Contributor agrees to the terms and conditions of this Agreement for present and future Contributions, which Contributor submits to Magento. Except for the licenses granted herein, Contributor reserves all right, title, and interest in and to Contributor Contributions.</li> + </ol> + </li> + <li> + <strong><u>Representations:</u></strong> + <ol> + <li><strong>Original Work.</strong> Contributor represents that each Contribution is Contributor’s own original creation and that Contributor is the copyright owner or legal entity authorized by the copyright owner of all Contributions.</li> + <li><strong>Ownership and Authority.</strong> Contributor represents that it is legally entitled to grant the licenses above and that the Contributions do not include any third party copyrights, patents, trade secrets, licenses, or other restrictions ("Third Party IP"), and that Contributor will not declare any dependencies on any open source projects, proprietary software or Third Party IP, unless Contributor has made a Complete Disclosure prior to or at the time of the Contribution submission.</li> + <li><strong>Complete Disclosure.</strong> If applicable, Contributor represents that each and every Contribution submission includes complete details of any third-party license or other restrictions associated with any part of the Contribution.</li> + <li><strong>Support.</strong> Contributor is not expected to provide support for Contributions, except to the extent Contributor desires to provide support. Contributor may provide support for free, for a fee, or not at all.</li> + <li><strong>Notification of any Change.</strong> You agree to notify Magento if any of the facts, circumstances or representations made herein are or become inaccurate in any respect.</li> + </ol> + </li> + <li> + <strong><u>General:</u></strong> + <ol> + <li><strong>Waiver.</strong> Contributor waives all other claims of any nature, including express contract, implied-in-fact contract, or quasi-contract, arising out of any disclosure of the Contributions to Magento. As such, Magento is under no obligation to use or implement the Contributions in any respect.</li> + <li><strong>Competitive or Similar Materials.</strong> In no event shall Magento or Magento Affiliates be precluded from discussing, reviewing, developing for itself, having developed, or developing for third parties, materials which are competitive with those set forth in the Contributions irrespective of their similarity to the information in the Contributions, so long as Magento complies with the terms of this Agreement.</li> + <li><strong>Term.</strong> This Agreement shall remain in effect for a period of five (5) years from the Effective Date or until termination in writing by either party is delivered to the other party.</li> + <li><strong>Governing Law.</strong> This Agreement will be construed as if both parties jointly wrote it, governed by California law except for its conflicts of laws principles, and any cause of action arising under or relating to this Agreement must be brought exclusively in a court in Santa Clara County, California. </li> + <li><strong>Survival.</strong> Upon termination or expiration of this Agreement, all terms of the Agreement, including the license grants, shall remain in full force and effect, except that Contributor will no longer make submissions to Magento.</li> + </ol> + </li> +</ol> +<p><strong>IN WITNESS WHEREOF,</strong> the Parties have caused this Agreement to be executed by their duly authorized representatives as of the Effective Date.</p> +<table border="0" width="100%"> + <tr> + <td width="9%"><strong>Magento, Inc.</strong></td> + <td width="15%"></td> + <td width="6%"></td> + <td width="9%"></td> + <td width="15%"><strong>Contributor</strong><br> + </tr> + <tr> + <td>By:</td> + <td><hr></td> + <td></td> + <td>By:</td> + <td><hr></td> + </tr> + <td>Name:</td> + <td><hr></td> + <td></td> + <td>Name:</td> + <td><hr></td> + </tr> + <tr> + <td>Title:</td> + <td><hr></td> + <td></td> + <td>Title:</td> + <td><hr></td> +</table> +</div> +</body> +</html> \ No newline at end of file diff --git a/app/autoload.php b/app/autoload.php index 073340091ce..0f6e9f7060f 100644 --- a/app/autoload.php +++ b/app/autoload.php @@ -23,10 +23,25 @@ * @copyright Copyright (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'; + +/** + * Shortcut constant for the root directory + */ +define('BP', dirname(__DIR__)); + +$vendorDir = require BP . '/app/etc/vendor_path.php'; +$vendorAutoload = BP . "/{$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']); +require_once BP . '/lib/internal/Magento/Framework/Autoload/IncludePath.php'; +$includePath = new \Magento\Framework\Autoload\IncludePath(); +$includePath->addIncludePath([BP . '/app/code', BP . '/lib/internal']); +spl_autoload_register([$includePath, 'load']); +$classMapPath = BP . '/var/classmap.ser'; +if (file_exists($classMapPath)) { + require_once BP . '/lib/internal/Magento/Framework/Autoload/ClassMap.php'; + $classMap = new \Magento\Framework\Autoload\ClassMap(BP); + $classMap->addMap(unserialize(file_get_contents($classMapPath))); + spl_autoload_register(array($classMap, 'load'), true, true); +} diff --git a/app/bootstrap.php b/app/bootstrap.php index 31abb9bdfa5..58e02598d6f 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -41,55 +41,16 @@ if (version_compare(phpversion(), '5.4.11', '<') === true) { Whoops, it looks like you have an invalid PHP version.</h3> </div> <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> </div> HTML; } - exit; + exit(1); } -/**#@+ - * Shortcut constants - */ -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'; -if (file_exists($classMapPath)) { - require_once BP . '/lib/internal/Magento/Framework/Autoload/ClassMap.php'; - $classMap = new \Magento\Framework\Autoload\ClassMap(BP); - $classMap->addMap(unserialize(file_get_contents($classMapPath))); - spl_autoload_register(array($classMap, 'load'), true, true); -} - -if (!defined('BARE_BOOTSTRAP')) { - $maintenanceFlag = BP . '/' . \Magento\Framework\App\State\MaintenanceMode::FLAG_DIR . '/' - . \Magento\Framework\App\State\MaintenanceMode::FLAG_FILENAME; - if (file_exists($maintenanceFlag)) { - if (!in_array($_SERVER['REMOTE_ADDR'], explode(",", file_get_contents($maintenanceFlag)))) { - if (PHP_SAPI == 'cli') { - echo 'Service temporarily unavailable due to maintenance downtime.'; - } else { - include_once BP . '/pub/errors/503.php'; - } - exit; - } - } +require_once BP . '/app/functions.php'; - if (!empty($_SERVER['MAGE_PROFILER'])) { - \Magento\Framework\Profiler::applyConfig( - $_SERVER['MAGE_PROFILER'], - dirname(__DIR__), - !empty($_REQUEST['isAjax']) - ); - } +if (!empty($_SERVER['MAGE_PROFILER'])) { + \Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax'])); } date_default_timezone_set(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 92cc992a3b3..ebd9195faa8 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -36,7 +36,7 @@ class Baseurl implements \Magento\Framework\Notification\MessageInterface protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,13 +47,13 @@ class Baseurl implements \Magento\Framework\Notification\MessageInterface /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\Config\ValueFactory $configValueFactory ) { diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 8207d4d7ec3..834fb0446dc 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php index 5707ac12a32..37e2df4f6a8 100644 --- a/app/code/Magento/Authorization/Model/CompositeUserContext.php +++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php @@ -24,6 +24,11 @@ namespace Magento\Authorization\Model; +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite user context (implements composite pattern). + */ class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface { /** @@ -39,19 +44,12 @@ class CompositeUserContext implements \Magento\Authorization\Model\UserContextIn /** * Register user contexts. * + * @param CompositeHelper $compositeHelper * @param UserContextInterface[] $userContexts */ - public function __construct($userContexts = []) + public function __construct(CompositeHelper $compositeHelper, $userContexts = []) { - $userContexts = array_filter( - $userContexts, - function ($item) { - return isset($item['type']) && isset($item['sortOrder']); - } - ); - - uasort($userContexts, array($this, 'compareContextsSortOrder')); - + $userContexts = $compositeHelper->filterAndSortDeclaredComponents($userContexts); foreach ($userContexts as $userContext) { $this->add($userContext['type']); } @@ -106,24 +104,4 @@ class CompositeUserContext implements \Magento\Authorization\Model\UserContextIn } 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/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 3079bd2c3b3..7df60980708 100644 --- a/app/code/Magento/Authorization/composer.json +++ b/app/code/Magento/Authorization/composer.json @@ -3,12 +3,12 @@ "description": "Authorization module provides access to Magento ACL functionality.", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/Helper/Backend.php b/app/code/Magento/Authorizenet/Helper/Backend.php index fc0d11dc938..546c7fe8edf 100644 --- a/app/code/Magento/Authorizenet/Helper/Backend.php +++ b/app/code/Magento/Authorizenet/Helper/Backend.php @@ -30,13 +30,13 @@ class Backend extends Data { /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Backend\Model\UrlInterface $backendUrl */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Backend\Model\UrlInterface $backendUrl ) { diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 0398481a245..3ca32c1028d 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -29,7 +29,7 @@ namespace Magento\Authorizenet\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper implements HelperInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -40,12 +40,12 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper implements Helpe /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory ) { parent::__construct($context); diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index df8c1202f6e..599e5b3a3ed 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -1322,7 +1322,7 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_LAST_SUCCESS); $quotePayment->setAdditionalInformation($orderPayment->getAdditionalInformation()); - $exceptionMessage = null; + $exceptionMessage = $this->_wrapGatewayError($response->getResponseReasonText()); break; case self::RESPONSE_CODE_DECLINED: case self::RESPONSE_CODE_ERROR: diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index 9d3f76530f6..0d0088aa172 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -73,7 +73,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet /**#@-*/ /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -112,7 +112,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Authorizenet\Helper\Data $authorizenetData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory * @param \Magento\Authorizenet\Model\Directpost\Response $response @@ -137,7 +137,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Authorizenet\Helper\Data $authorizenetData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory, \Magento\Authorizenet\Model\Directpost\Response $response, diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Observer.php b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php index 06820ffd10b..8c82e7dd088 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Observer.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Observer.php @@ -62,7 +62,7 @@ class Observer protected $_session; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -72,7 +72,7 @@ class Observer * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Authorizenet\Model\Directpost $payment * @param \Magento\Authorizenet\Model\Directpost\Session $session - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Authorizenet\Helper\Data $authorizenetData, @@ -80,7 +80,7 @@ class Observer \Magento\Framework\Registry $coreRegistry, \Magento\Authorizenet\Model\Directpost $payment, \Magento\Authorizenet\Model\Directpost\Session $session, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_coreRegistry = $coreRegistry; $this->_authorizenetData = $authorizenetData; diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Session.php b/app/code/Magento/Authorizenet/Model/Directpost/Session.php index 06709106c96..97e56477acc 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Session.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Session.php @@ -37,7 +37,6 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\Session\StorageInterface $storage * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param string|null $sessionName * @internal param array $data */ public function __construct( @@ -48,8 +47,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Session\ValidatorInterface $validator, \Magento\Framework\Session\StorageInterface $storage, \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - $sessionName = null + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { parent::__construct( $request, @@ -61,7 +59,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } /** diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 7c1b5596205..d782df28e00 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -3,19 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/di.xml b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml index 472bd121760..c5f39c034f1 100644 --- a/app/code/Magento/Authorizenet/etc/adminhtml/di.xml +++ b/app/code/Magento/Authorizenet/etc/adminhtml/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Authorizenet\Helper\HelperInterface" type="Magento\Authorizenet\Helper\Backend" /> - <type name="Magento\Authorizenet\Model\Directpost\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Authorizenet\Model\Directpost"> <arguments> <argument name="session" xsi:type="object">Magento\Backend\Model\Session\Quote</argument> diff --git a/app/code/Magento/Authorizenet/etc/frontend/di.xml b/app/code/Magento/Authorizenet/etc/frontend/di.xml index 59240f40d34..dd00831ba93 100644 --- a/app/code/Magento/Authorizenet/etc/frontend/di.xml +++ b/app/code/Magento/Authorizenet/etc/frontend/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Authorizenet\Helper\HelperInterface" type="Magento\Authorizenet\Helper\Data" /> - <type name="Magento\Authorizenet\Model\Directpost\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Authorizenet\Model\Directpost"> <arguments> <argument name="session" xsi:type="object">Magento\Checkout\Model\Session</argument> diff --git a/app/code/Magento/Authorizenet/etc/module.xml b/app/code/Magento/Authorizenet/etc/module.xml index 8febaa01797..4315ec97143 100644 --- a/app/code/Magento/Authorizenet/etc/module.xml +++ b/app/code/Magento/Authorizenet/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_Checkout"/> </sequence> <depends> - <module name="Magento_Store"/> <module name="Magento_Sales"/> <module name="Magento_Checkout"/> <module name="Magento_Backend"/> diff --git a/app/code/Magento/Backend/AdminConfig.php b/app/code/Magento/Backend/AdminConfig.php index 01c29802308..691cbb9d72a 100644 --- a/app/code/Magento/Backend/AdminConfig.php +++ b/app/code/Magento/Backend/AdminConfig.php @@ -35,6 +35,11 @@ use Magento\Framework\Session\Config; */ class AdminConfig extends Config { + /** + * Configuration for admin session name + */ + const SESSION_NAME_ADMIN = 'admin'; + /** * @var FrontNameResolver $frontNameResolver */ @@ -44,7 +49,6 @@ class AdminConfig extends Config * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\String $stringHelper * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\Filesystem $filesystem * @param string $scopeType * @param FrontNameResolver $frontNameResolver @@ -52,26 +56,26 @@ class AdminConfig extends Config * @param null|string $savePath * @param null|string $cacheLimiter * @param string $lifetimePath + * @param string $sessionName * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, FrontNameResolver $frontNameResolver, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, $savePath = null, $cacheLimiter = null, - $lifetimePath = self::XML_PATH_COOKIE_LIFETIME + $lifetimePath = self::XML_PATH_COOKIE_LIFETIME, + $sessionName = self::SESSION_NAME_ADMIN ) { parent::__construct( $scopeConfig, $stringHelper, $request, - $appState, $filesystem, $scopeType, $saveMethod, @@ -85,6 +89,7 @@ class AdminConfig extends Config $baseUrl = $this->_httpRequest->getBaseUrl(); $adminPath = $this->extractAdminPath($baseUrl); $this->setCookiePath($adminPath); + $this->setName($sessionName); } /** diff --git a/app/code/Magento/Backend/App/Router.php b/app/code/Magento/Backend/App/Router.php index 23f19e5c673..cf3f08516a7 100644 --- a/app/code/Magento/Backend/App/Router.php +++ b/app/code/Magento/Backend/App/Router.php @@ -70,15 +70,14 @@ class Router extends \Magento\Core\App\Router\Base * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId + * @param \Magento\Framework\Code\NameBuilder $nameBuilder * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig * @param \Magento\Backend\App\ConfigInterface $backendConfig - * @param \Magento\Framework\Code\NameBuilder $nameBuilder * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -88,9 +87,8 @@ class Router extends \Magento\Core\App\Router\Base \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\ConfigInterface $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -104,7 +102,6 @@ class Router extends \Magento\Core\App\Router\Base $defaultPath, $responseFactory, $routeConfig, - $appState, $url, $storeManager, $scopeConfig, diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index f28b2f8a0a6..70680f30e22 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -79,7 +79,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Backend\Model\Session $backendSession * @param \Magento\Framework\Math\Random $mathRandom @@ -111,7 +111,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Backend\Model\Session $backendSession, \Magento\Framework\Math\Random $mathRandom, @@ -153,7 +153,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context /** * Get store manager * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ public function getStoreManager() { diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php index daff04fcf5b..ed612197dab 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php @@ -169,7 +169,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -188,7 +188,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form } // @codingStandardsIgnoreStart if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the product you chose is not associated with a website.' ) @@ -198,7 +198,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form } elseif ($category->getId()) { $entityStores = (array)$category->getStoreIds(); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the category your chose is not associated with a website.' ) diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php index bf68ff4a064..ad42ead070c 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php @@ -138,7 +138,7 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -151,8 +151,8 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form $this->_requireStoresFilter = !in_array(0, $entityStores); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( - __('Chosen cms page does not associated with any website.') + throw new \Magento\Framework\Model\Exception( + __('Chosen cms page is not associated with any website.') ); } } diff --git a/app/code/Magento/Backend/Block/Widget/Context.php b/app/code/Magento/Backend/Block/Widget/Context.php index f5a65b938ea..8ffce8ce307 100644 --- a/app/code/Magento/Backend/Block/Widget/Context.php +++ b/app/code/Magento/Backend/Block/Widget/Context.php @@ -62,7 +62,7 @@ class Context extends \Magento\Backend\Block\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Backend\Model\Session $backendSession * @param \Magento\Framework\Math\Random $mathRandom @@ -96,7 +96,7 @@ class Context extends \Magento\Backend\Block\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Backend\Model\Session $backendSession, \Magento\Framework\Math\Random $mathRandom, diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php index d2bf0763a08..cc8125c5b71 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php @@ -45,7 +45,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra /** * Application object * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,7 +66,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency @@ -74,7 +74,7 @@ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstra */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php index 5123be8a4c5..83e1283e645 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Data.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php @@ -41,7 +41,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param string $installDate @@ -50,7 +50,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, $installDate, diff --git a/app/code/Magento/Backend/Helper/Dashboard/Order.php b/app/code/Magento/Backend/Helper/Dashboard/Order.php index b19d8297109..3ca2b183c40 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Order.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Order.php @@ -36,7 +36,7 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Reports\Model\Resource\Order\Collection $orderCollection @@ -45,7 +45,7 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Reports\Model\Resource\Order\Collection $orderCollection, diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php index 4bf70b7a933..08a06b81626 100644 --- a/app/code/Magento/Backend/Model/Config.php +++ b/app/code/Magento/Backend/Model/Config.php @@ -88,7 +88,7 @@ class Config extends \Magento\Framework\Object protected $_configValueFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Config extends \Magento\Framework\Object * @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Backend\Model\Config\Loader $configLoader * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -109,7 +109,7 @@ class Config extends \Magento\Framework\Object \Magento\Framework\DB\TransactionFactory $transactionFactory, \Magento\Backend\Model\Config\Loader $configLoader, \Magento\Framework\App\Config\ValueFactory $configValueFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($data); diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php index 9bbd7c296b8..ec8c974e009 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php @@ -50,7 +50,7 @@ class Observer protected $_response; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,7 +66,7 @@ class Observer \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\App\ResponseInterface $response, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_backendData = $backendData; $this->_coreRegistry = $coreRegistry; diff --git a/app/code/Magento/Backend/Model/Config/Source/Website.php b/app/code/Magento/Backend/Model/Config/Source/Website.php index aed17b7c910..530a9547486 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Website.php +++ b/app/code/Magento/Backend/Model/Config/Source/Website.php @@ -31,14 +31,14 @@ class Website implements \Magento\Framework\Option\ArrayInterface protected $_options; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php index a6598b0ed2b..a0c9740b012 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php +++ b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php @@ -23,7 +23,7 @@ */ namespace Magento\Backend\Model\Config\Structure; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; abstract class AbstractElement implements ElementInterface { @@ -44,12 +44,12 @@ abstract class AbstractElement implements ElementInterface /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct(StoreManagerInterface $storeManager) { diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php index 4db887d81f6..0c1e5f3ee45 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php @@ -33,10 +33,10 @@ abstract class AbstractComposite extends \Magento\Backend\Model\Config\Structure protected $_childrenIterator; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Iterator $childrenIterator */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, Iterator $childrenIterator) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, Iterator $childrenIterator) { parent::__construct($storeManager); $this->_childrenIterator = $childrenIterator; diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php index cfc5117acca..4928299a934 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php @@ -67,7 +67,7 @@ class Field extends \Magento\Backend\Model\Config\Structure\AbstractElement protected $_blockFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\BackendFactory $backendFactory * @param \Magento\Backend\Model\Config\SourceFactory $sourceFactory * @param \Magento\Backend\Model\Config\CommentFactory $commentFactory @@ -75,7 +75,7 @@ class Field extends \Magento\Backend\Model\Config\Structure\AbstractElement * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\BackendFactory $backendFactory, \Magento\Backend\Model\Config\SourceFactory $sourceFactory, \Magento\Backend\Model\Config\CommentFactory $commentFactory, diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php index c31d0f6aa33..6149666c132 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php @@ -39,13 +39,13 @@ class Group extends AbstractComposite protected $_dependencyMapper; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator * @param \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator, \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory, \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php index 4cdf82e7c7b..5f91efdb4c8 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php @@ -33,12 +33,12 @@ class Section extends AbstractComposite protected $_authorization; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Iterator $childrenIterator * @param \Magento\Framework\AuthorizationInterface $authorization */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Iterator $childrenIterator, \Magento\Framework\AuthorizationInterface $authorization ) { diff --git a/app/code/Magento/Backend/Model/Session.php b/app/code/Magento/Backend/Model/Session.php index d36bb06c32d..966400d471a 100644 --- a/app/code/Magento/Backend/Model/Session.php +++ b/app/code/Magento/Backend/Model/Session.php @@ -57,7 +57,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start('adminhtml'); + $this->start(); } /** diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 68d49ce4dbd..f6c246b1eec 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -79,7 +79,7 @@ class Quote extends \Magento\Framework\Session\SessionManager protected $_quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -100,7 +100,7 @@ class Quote extends \Magento\Framework\Session\SessionManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( @@ -115,7 +115,7 @@ class Quote extends \Magento\Framework\Session\SessionManager \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->_quoteFactory = $quoteFactory; diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 7078ff5ffb6..aab0a3ebd5f 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,32 +3,31 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-sendfriend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-search": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backup": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/module-translation": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-search": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backup": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/module-translation": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 09512c7ec5a..20b2078fd44 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -47,11 +47,6 @@ <argument name="backendUrl" xsi:type="object">Magento\Backend\Model\UrlInterface\Proxy</argument> </arguments> </type> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Backend\Model\Config\Structure\Element\Iterator\Tab" shared="false" /> <type name="Magento\Backend\Model\Config\Structure\Element\Iterator\Section" shared="false" /> <type name="Magento\Framework\View\Layout"> @@ -101,6 +96,7 @@ <type name="Magento\Backend\AdminConfig"> <arguments> <argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument> + <argument name="sessionName" xsi:type="const">Magento\Backend\AdminConfig::SESSION_NAME_ADMIN</argument> </arguments> </type> </config> diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 1b15e3702c4..a51a0195441 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -34,7 +34,6 @@ <module name="Magento_Core"/> <module name="Magento_Eav"/> <module name="Magento_Cron"/> - <module name="Magento_Sendfriend"/> <module name="Magento_Theme"/> <module name="Magento_Weee"/> <module name="Magento_Reports"/> diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index.php b/app/code/Magento/Backup/Controller/Adminhtml/Index.php index f0a921c5ac7..dd0175f9df5 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index.php @@ -53,7 +53,7 @@ class Index extends \Magento\Backend\App\Action protected $_backupModelFactory; /** - * @var \Magento\Framework\App\State\MaintenanceMode + * @var \Magento\Framework\App\MaintenanceMode */ protected $maintenanceMode; @@ -63,7 +63,7 @@ class Index extends \Magento\Backend\App\Action * @param \Magento\Framework\Backup\Factory $backupFactory * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory * @param \Magento\Backup\Model\BackupFactory $backupModelFactory - * @param \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + * @param \Magento\Framework\App\MaintenanceMode $maintenanceMode */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -71,7 +71,7 @@ class Index extends \Magento\Backend\App\Action \Magento\Framework\Backup\Factory $backupFactory, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Backup\Model\BackupFactory $backupModelFactory, - \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + \Magento\Framework\App\MaintenanceMode $maintenanceMode ) { $this->_coreRegistry = $coreRegistry; $this->_backupFactory = $backupFactory; diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php b/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php index 5472af57770..388baac9c82 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php @@ -69,7 +69,7 @@ class Create extends \Magento\Backup\Controller\Adminhtml\Index $this->_coreRegistry->register('backup_manager', $backupManager); if ($this->getRequest()->getParam('maintenance_mode')) { - if (!$this->maintenanceMode->turnOn()) { + if (!$this->maintenanceMode->set(true)) { $response->setError( __( 'You need more permissions to activate maintenance mode right now.' @@ -116,7 +116,7 @@ class Create extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } $this->getResponse()->representJson($response->toJson()); diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php b/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php index fb0848da57a..964bb7274b0 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php @@ -91,7 +91,7 @@ class Rollback extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - if (!$this->maintenanceMode->turnOn()) { + if (!$this->maintenanceMode->set(true)) { $response->setError( __( 'You need more permissions to activate maintenance mode right now.' @@ -153,7 +153,7 @@ class Rollback extends \Magento\Backup\Controller\Adminhtml\Index } if ($this->getRequest()->getParam('maintenance_mode')) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } $this->getResponse()->representJson($response->toJson()); diff --git a/app/code/Magento/Backup/Helper/Data.php b/app/code/Magento/Backup/Helper/Data.php index faa0625d479..eb046555cd9 100644 --- a/app/code/Magento/Backup/Helper/Data.php +++ b/app/code/Magento/Backup/Helper/Data.php @@ -23,7 +23,7 @@ */ namespace Magento\Backup\Helper; -use Magento\Framework\App\State\MaintenanceMode; +use Magento\Framework\App\MaintenanceMode; /** * Backup data helper diff --git a/app/code/Magento/Backup/Model/Observer.php b/app/code/Magento/Backup/Model/Observer.php index afc884990cf..df14190b718 100644 --- a/app/code/Magento/Backup/Model/Observer.php +++ b/app/code/Magento/Backup/Model/Observer.php @@ -85,7 +85,7 @@ class Observer protected $_backupFactory; /** - * @var \Magento\Framework\App\State\MaintenanceMode + * @var \Magento\Framework\App\MaintenanceMode */ protected $maintenanceMode; @@ -96,7 +96,7 @@ class Observer * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\Backup\Factory $backupFactory - * @param \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + * @param \Magento\Framework\App\MaintenanceMode $maintenanceMode */ public function __construct( \Magento\Backup\Helper\Data $backupData, @@ -105,7 +105,7 @@ class Observer \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\Backup\Factory $backupFactory, - \Magento\Framework\App\State\MaintenanceMode $maintenanceMode + \Magento\Framework\App\MaintenanceMode $maintenanceMode ) { $this->_backupData = $backupData; $this->_coreRegistry = $coreRegistry; @@ -119,7 +119,7 @@ class Observer /** * Create Backup * - * @return \Magento\Log\Model\Cron + * @return $this */ public function scheduledBackup() { @@ -128,7 +128,7 @@ class Observer } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { - $this->maintenanceMode->turnOn(); + $this->maintenanceMode->set(true); } $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE); @@ -166,7 +166,7 @@ class Observer } if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) { - $this->maintenanceMode->turnOff(); + $this->maintenanceMode->set(false); } return $this; diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 59e9c5aa1b6..fc9af6761df 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/Model/Product/CatalogPrice.php b/app/code/Magento/Bundle/Model/Product/CatalogPrice.php index f46e4c428c2..ecfe19eea62 100644 --- a/app/code/Magento/Bundle/Model/Product/CatalogPrice.php +++ b/app/code/Magento/Bundle/Model/Product/CatalogPrice.php @@ -29,7 +29,7 @@ namespace Magento\Bundle\Model\Product; class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -44,12 +44,12 @@ class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterfa protected $coreRegistry; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel * @param \Magento\Framework\Registry $coreRegistry */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel, \Magento\Framework\Registry $coreRegistry ) { diff --git a/app/code/Magento/Bundle/Model/Product/Price.php b/app/code/Magento/Bundle/Model/Product/Price.php index fa90ad6c36d..d0cb54b8953 100644 --- a/app/code/Magento/Bundle/Model/Product/Price.php +++ b/app/code/Magento/Bundle/Model/Product/Price.php @@ -59,7 +59,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price * Construct * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -67,7 +67,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index a7a700fd32c..09d31b722cc 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -99,7 +99,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType protected $_catalogProduct = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -154,7 +154,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Catalog\Model\Config $config * @param \Magento\Bundle\Model\Resource\Selection $bundleSelection * @param \Magento\Bundle\Model\OptionFactory $bundleOption - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -178,7 +178,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType \Magento\Catalog\Model\Config $config, \Magento\Bundle\Model\Resource\Selection $bundleSelection, \Magento\Bundle\Model\OptionFactory $bundleOption, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_catalogProduct = $catalogProduct; diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Link.php similarity index 85% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/Link.php index 139b1923d0a..f2742c82455 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/Metadata.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Link.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\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use \Magento\Framework\Service\Data\AbstractExtensibleObject; /** * @codeCoverageIgnore */ -class Metadata extends AbstractExtensibleObject +class Link extends AbstractExtensibleObject { const SKU = 'sku'; @@ -36,6 +36,8 @@ class Metadata extends AbstractExtensibleObject const QTY = 'qty'; + const CAN_CHANGE_QUANTITY = 'can_change_qty'; + const POSITION = 'position'; const DEFINED = 'defined'; @@ -79,7 +81,7 @@ class Metadata extends AbstractExtensibleObject } /** - * @return bool + * @return bool|null */ public function isDefined() { @@ -109,4 +111,14 @@ class Metadata extends AbstractExtensibleObject { return $this->_get(self::PRICE_TYPE); } + + /** + * Get whether quantity could be changed + * + * @return int|null + */ + public function getCanChangeQuantity() + { + return $this->_get(self::CAN_CHANGE_QUANTITY); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.php similarity index 71% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.php index 7ee6d251622..1b57e7724e2 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataBuilder.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkBuilder.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\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder; /** * @codeCoverageIgnore */ -class MetadataBuilder extends AbstractExtensibleObjectBuilder +class LinkBuilder extends AbstractExtensibleObjectBuilder { /** * @param string $value @@ -36,7 +36,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setSku($value) { - return $this->_set(Metadata::SKU, $value); + return $this->_set(Link::SKU, $value); } /** @@ -45,7 +45,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setQty($value) { - return $this->_set(Metadata::QTY, $value); + return $this->_set(Link::QTY, $value); } /** @@ -54,7 +54,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPosition($value) { - return $this->_set(Metadata::POSITION, $value); + return $this->_set(Link::POSITION, $value); } /** @@ -63,7 +63,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setOptionId($value) { - return $this->_set(Metadata::OPTION_ID, $value); + return $this->_set(Link::OPTION_ID, $value); } /** @@ -72,7 +72,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setDefined($value) { - return $this->_set(Metadata::DEFINED, (bool)$value); + return $this->_set(Link::DEFINED, (bool)$value); } /** @@ -81,7 +81,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setDefault($value) { - return $this->_set(Metadata::IS_DEFAULT, (bool)$value); + return $this->_set(Link::IS_DEFAULT, (bool)$value); } /** @@ -90,7 +90,7 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPrice($value) { - return $this->_set(Metadata::PRICE, $value); + return $this->_set(Link::PRICE, $value); } /** @@ -99,6 +99,17 @@ class MetadataBuilder extends AbstractExtensibleObjectBuilder */ public function setPriceType($value) { - return $this->_set(Metadata::PRICE_TYPE, $value); + return $this->_set(Link::PRICE_TYPE, $value); + } + + /** + * Set can change quantity + * + * @param int $canChangeQuantity + * @return $this + */ + public function setCanChangeQuantity($canChangeQuantity) + { + return $this->_set(Link::CAN_CHANGE_QUANTITY, $canChangeQuantity); } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php similarity index 89% rename from app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php rename to app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php index d62167d6aec..a2a9d535329 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Link/MetadataConverter.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/LinkConverter.php @@ -22,24 +22,24 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Bundle\Service\V1\Data\Product\Link; +namespace Magento\Bundle\Service\V1\Data\Product; use Magento\Catalog\Model\Product; /** * @codeCoverageIgnore */ -class MetadataConverter +class LinkConverter { /** - * @var MetadataBuilder + * @var LinkBuilder */ private $builder; /** - * @param MetadataBuilder $builder + * @param LinkBuilder $builder */ - public function __construct(MetadataBuilder $builder) + public function __construct(LinkBuilder $builder) { $this->builder = $builder; } @@ -47,7 +47,7 @@ class MetadataConverter /** * @param Product $product * @param Product $bundle - * @return Metadata + * @return Link */ public function createDataFromModel(Product $product, Product $bundle) { diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php index ce87c215e49..6dfe329e47c 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php @@ -42,6 +42,8 @@ class Option extends AbstractExtensibleObject const SKU = 'sku'; + const PRODUCT_LINKS = 'product_links'; + /** * Get option id * @@ -101,4 +103,14 @@ class Option extends AbstractExtensibleObject { return $this->_get(self::SKU); } + + /** + * Get product links + * + * @return \Magento\Bundle\Service\V1\Data\Product\Link[]|null + */ + public function getProductLinks() + { + return $this->_get(self::PRODUCT_LINKS); + } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php index 935a15a10a6..5247907144e 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php @@ -95,4 +95,15 @@ class OptionBuilder extends AbstractExtensibleObjectBuilder { return $this->_set(Option::SKU, $value); } + + /** + * Set product links + * + * @param \Magento\Bundle\Service\V1\Data\Product\Link[] $value + * @return $this + */ + public function setProductLinks($value) + { + return $this->_set(Option::PRODUCT_LINKS, $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 index b5de09c3576..a2331544a8a 100644 --- a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php @@ -56,14 +56,16 @@ class OptionConverter /** * @param OptionModel $option * @param Product $product + * @param Link[] $productLinks * @return Option */ - public function createDataFromModel(OptionModel $option, Product $product) + public function createDataFromModel(OptionModel $option, Product $product, $productLinks = null) { $this->builder->populateWithArray($option->getData()) ->setId($option->getId()) ->setTitle(is_null($option->getTitle()) ? $option->getDefaultTitle() : $option->getTitle()) - ->setSku($product->getSku()); + ->setSku($product->getSku()) + ->setProductLinks($productLinks); return $this->builder->create(); } diff --git a/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php b/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.php new file mode 100644 index 00000000000..c3ec9a8fe15 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessor.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\Bundle\Service\V1\Product; + +use Magento\Bundle\Model\Option; +use Magento\Bundle\Service\V1\Product\Option\ReadService as OptionReadService; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Catalog\Model\ProductRepository; +use Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface; + +/** + * Add bundle product attributes to products during load. + */ +class BundleProductLoadProcessor implements ProductLoadProcessorInterface +{ + /** + * @var OptionReadService + */ + private $optionReadService; + + /** + * @var ProductRepository + */ + private $productRepository; + + /** + * @param OptionReadService $optionReadService + * @param ProductRepository $productRepository + */ + public function __construct( + OptionReadService $optionReadService, + ProductRepository $productRepository + ) { + $this->optionReadService = $optionReadService; + $this->productRepository = $productRepository; + } + + /** + * {@inheritdoc} + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder) + { + /** @var \Magento\Catalog\Model\Product */ + $product = $this->productRepository->get($id); + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return; + } + + $productBuilder->setCustomAttribute( + 'bundle_product_options', + $this->optionReadService->getList($product->getSku()) + ); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php b/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php new file mode 100644 index 00000000000..0a5f6032a9b --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessor.php @@ -0,0 +1,233 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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; + +use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Product\Option\ReadService as OptionReadService; +use Magento\Bundle\Service\V1\Product\Option\WriteService as OptionWriteService; +use Magento\Framework\Service\Data\Eav\AttributeValue; +use Magento\Catalog\Model\Product as ProductModel; +use Magento\Catalog\Model\ProductRepository; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Catalog\Service\V1\Data\Product; +use Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface; + +/** + * Class to save bundle products + */ +class BundleProductSaveProcessor implements ProductSaveProcessorInterface +{ + /** + * @var OptionWriteService + */ + private $optionWriteService; + + /** + * @var OptionReadService + */ + private $optionReadService; + + /** + * @var ProductRepository + */ + private $productRepository; + + /** + * Initialize dependencies. + * + * @param OptionWriteService $optionWriteService + * @param OptionReadService $optionReadService + * @param ProductRepository $productRepository + */ + public function __construct( + OptionWriteService $optionWriteService, + OptionReadService $optionReadService, + ProductRepository $productRepository + ) { + $this->optionWriteService = $optionWriteService; + $this->optionReadService = $optionReadService; + $this->productRepository = $productRepository; + } + + /** + * Process bundle-related attributes of product during its creation. + * + * @param ProductModel $product + * @param Product $productData + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function create(ProductModel $product, Product $productData) + { + return $product->getSku(); + } + + /** + * Process bundle-related attributes of product after its creation. + * + * @param ProductModel $product + * @param Product $productData + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return string + */ + public function afterCreate(ProductModel $product, Product $productData) + { + /** @var string $productSku */ + $productSku = $product->getSku(); + + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return $productSku; + } + + /** @var Option[] $bundleProductOptions */ + + /* @var AttributeValue $bundleProductOptionsAttrValue */ + $bundleProductOptionsAttrValue = $productData->getCustomAttribute('bundle_product_options'); + if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { + $bundleProductOptions = array(); + } else { + $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); + } + + if (is_array($bundleProductOptions)) { + foreach ($bundleProductOptions as $option) { + $this->optionWriteService->add($productSku, $option); + } + } + + return $productSku; + } + + /** + * Update bundle-related attributes of product. + * + * @param string $sku + * @param Product $updatedProduct + * @return string + */ + public function update($sku, Product $updatedProduct) + { + /** + * @var Product $existingProduct + */ + $existingProduct = $this->productRepository->get($sku, true); + + if ($existingProduct->getTypeId() != ProductType::TYPE_BUNDLE) { + return $sku; + } + + /** + * @var Option[] $existingProductOptions + */ + $existingProductOptions = $this->optionReadService->getList($sku); + /** + * @var Option[] $newProductOptions + */ + /** + * @var AttributeValue $newProductOptionsAttrValue + */ + $newProductOptionsAttrValue = $updatedProduct->getCustomAttribute('bundle_product_options'); + if (is_null($newProductOptionsAttrValue) || !is_array($newProductOptionsAttrValue->getValue())) { + $newProductOptions = array(); + } else { + $newProductOptions = $newProductOptionsAttrValue->getValue(); + } + /** + * @var Option[] $optionsToDelete + */ + $optionsToDelete = array_udiff($existingProductOptions, $newProductOptions, array($this, 'compareOptions')); + foreach ($optionsToDelete as $option) { + $this->optionWriteService->remove($sku, $option->getId()); + } + /** @var Option[] $optionsToUpdate */ + $optionsToUpdate = array_uintersect( + $existingProductOptions, + $newProductOptions, + array($this, 'compareOptions') + ); + foreach ($optionsToUpdate as $option) { + $this->optionWriteService->update($sku, $option->getId(), $option); + } + /** + * @var Option[] $optionsToAdd + */ + $optionsToAdd = array_udiff($newProductOptions, $existingProductOptions, array($this, 'compareOptions')); + foreach ($optionsToAdd as $option) { + $this->optionWriteService->add($sku, $option); + } + + return $sku; + } + + /** + * Delete bundle-related attributes of product. + * + * @param Product $product + * @return void + */ + public function delete(Product $product) + { + if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { + return; + } + + /** + * @var string $productSku + */ + $productSku = $product->getSku(); + + /** + * @var Option[] $bundleProductOptions + */ + /** + * @var AttributeValue $bundleProductOptionsAttrValue + */ + $bundleProductOptionsAttrValue = $product->getCustomAttribute('bundle_product_options'); + if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { + $bundleProductOptions = array(); + } else { + $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); + } + foreach ($bundleProductOptions as $option) { + $this->optionWriteService->remove($productSku, $option->getId()); + } + } + + /** + * Compare two options and determine if they are equal + * + * @param Option $firstOption + * @param Option $secondOption + * @return int + */ + private function compareOptions(Option $firstOption, Option $secondOption) + { + if ($firstOption->getId() == $secondOption->getId()) { + return 0; + } else { + return 1; + } + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php deleted file mode 100644 index bc5385b6520..00000000000 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLink.php +++ /dev/null @@ -1,112 +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\Bundle\Service\V1\Product\Link\Data; - -/** - * Bundle ProductLink Service Data Object - * - * @codeCoverageIgnore - */ -class ProductLink extends \Magento\Framework\Service\Data\AbstractExtensibleObject -{ - /** - * Constants for Data Object keys - */ - const SKU = 'product_sku'; - const POSITION = 'position'; - const IS_DEFAULT = 'default'; - const PRICE_TYPE = 'slection_price_type'; - const PRICE_VALUE = 'slection_price_value'; - const QUANTITY = 'selection_qty'; - const CAN_CHANGE_QUANTITY = 'selection_can_change_qty'; - - /** - * Get product sku - * - * @return string - */ - public function getSku() - { - return $this->_get(self::SKU); - } - - /** - * Get product position - * - * @return int - */ - public function getPosition() - { - return $this->_get(self::POSITION); - } - - /** - * @return boolean - */ - public function isDefault() - { - return $this->_get(self::IS_DEFAULT); - } - - /** - * Get price type - * - * @return int - */ - public function getPriceType() - { - return $this->_get(self::PRICE_TYPE); - } - - /** - * Get price value - * - * @return float - */ - public function getPriceValue() - { - return $this->_get(self::PRICE_VALUE); - } - - /** - * Get quantity - * - * @return int - */ - public function getQuantity() - { - return $this->_get(self::QUANTITY); - } - - /** - * Get whether quantity could be changed - * - * @return int - */ - public function getCanChangeQuantity() - { - return $this->_get(self::CAN_CHANGE_QUANTITY); - } -} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php b/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php deleted file mode 100644 index 9081c04761b..00000000000 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/Data/ProductLinkBuilder.php +++ /dev/null @@ -1,144 +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\Bundle\Service\V1\Product\Link\Data; - -use Magento\Framework\Service\Data\AttributeValueBuilder; - -/** - * Builder for the ProductLink Service Data Object - * - * @method ProductLink create() - * @codeCoverageIgnore - */ -class ProductLinkBuilder extends \Magento\Framework\Service\Data\AbstractExtensibleObjectBuilder -{ - /** - * @var array - */ - protected $customAttributes = []; - - /** - * @param \Magento\Framework\Service\Data\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder - * @param \Magento\Framework\Service\Config\MetadataConfig $metadataService - * @param array $customAttributesCodes - */ - public function __construct( - \Magento\Framework\Service\Data\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, - \Magento\Framework\Service\Config\MetadataConfig $metadataService, - array $customAttributesCodes = array() - ) { - $this->customAttributes = $customAttributesCodes; - parent::__construct($objectFactory, $valueBuilder, $metadataService); - } - - /** - * Set product sku - * - * @param string $sku - * @return $this - */ - public function setSku($sku) - { - return $this->_set(ProductLink::SKU, $sku); - } - - /** - * Set product position - * - * @param int $position - * @return $this - */ - public function setPosition($position) - { - return $this->_set(ProductLink::POSITION, $position); - } - - /** - * Get custom attributes codes - * - * @return string[] - */ - public function getCustomAttributesCodes() - { - return array_merge(parent::getCustomAttributesCodes(), $this->customAttributes); - } - - /** - * Set is default - * - * @param boolean $default - * @return $this - */ - public function setDefault($default) - { - return $this->_set(ProductLink::IS_DEFAULT, $default); - } - - /** - * Set price type - * - * @param int $priceType - * @return $this - */ - public function setPriceType($priceType) - { - return $this->_set(ProductLink::PRICE_TYPE, $priceType); - } - - /** - * Set price value - * - * @param float $priceValue - * @return $this - */ - public function setPriceValue($priceValue) - { - return $this->_set(ProductLink::PRICE_VALUE, $priceValue); - } - - /** - * Set quantity - * - * @param int $priceValue - * @return $this - */ - public function setQuantity($quantity) - { - return $this->_set(ProductLink::QUANTITY, $quantity); - } - - /** - * Set can change quantity - * - * @param int $canChangeQuantity - * @return $this - */ - public function setCanChangeQuantity($canChangeQuantity) - { - return $this->_set(ProductLink::CAN_CHANGE_QUANTITY, $canChangeQuantity); - } -} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php index 2cb313a5759..ea5ede71fdc 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadService.php @@ -24,7 +24,7 @@ namespace Magento\Bundle\Service\V1\Product\Link; use Magento\Bundle\Model\Option; -use Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter; +use Magento\Bundle\Service\V1\Data\Product\LinkConverter; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductRepository; use Magento\Webapi\Exception; @@ -37,21 +37,21 @@ class ReadService implements ReadServiceInterface private $productRepository; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter + * @var \Magento\Bundle\Service\V1\Data\Product\LinkConverter */ - private $metadataConverter; + private $linkConverter; /** * @param ProductRepository $productRepository - * @param MetadataConverter $metadataConverter + * @param LinkConverter $linkConverter */ public function __construct( ProductRepository $productRepository, - MetadataConverter $metadataConverter + LinkConverter $linkConverter ) { $this->productRepository = $productRepository; - $this->metadataConverter = $metadataConverter; + $this->linkConverter = $linkConverter; } /** @@ -69,7 +69,7 @@ class ReadService implements ReadServiceInterface foreach ($this->getOptions($product) as $option) { /** @var \Magento\Catalog\Model\Product $selection */ foreach ($option->getSelections() as $selection) { - $childrenList[] = $this->metadataConverter->createDataFromModel($selection, $product); + $childrenList[] = $this->linkConverter->createDataFromModel($selection, $product); } } diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php index 82d41f220ea..01e2f1b5999 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/ReadServiceInterface.php @@ -29,7 +29,7 @@ interface ReadServiceInterface * Get all children for Bundle product * * @param string $productId - * @return \Magento\Bundle\Service\V1\Data\Product\Link\Metadata[] + * @return \Magento\Bundle\Service\V1\Data\Product\Link[] * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Webapi\Exception */ 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 2964310bc69..80212e30855 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Bundle\Service\V1\Product\Link; use Magento\Catalog\Model\ProductRepository; @@ -46,7 +45,7 @@ class WriteService implements WriteServiceInterface protected $bundleSelection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -65,14 +64,14 @@ class WriteService implements WriteServiceInterface * @param \Magento\Bundle\Model\SelectionFactory $bundleSelection * @param \Magento\Bundle\Model\Resource\BundleFactory $bundleFactory * @param \Magento\Bundle\Model\Resource\Option\CollectionFactory $optionCollection, - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( ProductRepository $productRepository, \Magento\Bundle\Model\SelectionFactory $bundleSelection, \Magento\Bundle\Model\Resource\BundleFactory $bundleFactory, \Magento\Bundle\Model\Resource\Option\CollectionFactory $optionCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->productRepository = $productRepository; $this->bundleSelection = $bundleSelection; @@ -84,7 +83,7 @@ class WriteService implements WriteServiceInterface /** * {@inheritdoc} */ - public function addChild($productSku, $optionId, Data\ProductLink $linkedProduct) + public function addChild($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->productRepository->get($productSku); @@ -120,7 +119,8 @@ class WriteService implements WriteServiceInterface } if ($selections) { foreach ($selections as $selection) { - if ($selection['option_id'] == $optionId && $selection['product_id'] == $linkProductModel->getId()) { + if ($selection['option_id'] = $optionId && + $selection['product_id'] == $linkProductModel->getId()) { throw new CouldNotSaveException( 'Child with specified sku: "%1" already assigned to product: "%2"', [$linkedProduct->getSku(), $productSku] @@ -132,9 +132,9 @@ class WriteService implements WriteServiceInterface $selectionModel = $this->bundleSelection->create(); $selectionModel->setOptionId($optionId) ->setPosition($linkedProduct->getPosition()) - ->setSelectionQty($linkedProduct->getQuantity()) + ->setSelectionQty($linkedProduct->getQty()) ->setSelectionPriceType($linkedProduct->getPriceType()) - ->setSelectionPriceValue($linkedProduct->getPriceValue()) + ->setSelectionPriceValue($linkedProduct->getPrice()) ->setSelectionCanChangeQty($linkedProduct->getCanChangeQuantity()) ->setProductId($linkProductModel->getId()) ->setParentProductId($product->getId()) diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php index 44246c350ba..c8909789ead 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteServiceInterface.php @@ -31,13 +31,13 @@ interface WriteServiceInterface * * @param string $productSku * @param int $optionId - * @param \Magento\Bundle\Service\V1\Product\Link\Data\ProductLink $linkedProduct + * @param \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\InputException * @return int */ - public function addChild($productSku, $optionId, Data\ProductLink $linkedProduct); + public function addChild($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Link $linkedProduct); /** * Remove product from Bundle product option diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php index 714401d72e4..7f566abff93 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php @@ -24,7 +24,9 @@ namespace Magento\Bundle\Service\V1\Product\Option; use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\LinkConverter; use Magento\Bundle\Service\V1\Data\Product\OptionConverter; +use Magento\Bundle\Service\V1\Product\Link\ReadService as LinkReadService; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductRepository; use Magento\Framework\Exception\NoSuchEntityException; @@ -46,19 +48,27 @@ class ReadService implements ReadServiceInterface */ private $type; + /** + * @var LinkConverter + */ + private $linkConverter; + /** * @param OptionConverter $optionConverter * @param ProductRepository $productRepository * @param Type $type + * @param LinkConverter $linkConverter */ public function __construct( OptionConverter $optionConverter, ProductRepository $productRepository, - Type $type + Type $type, + LinkConverter $linkConverter ) { $this->optionConverter = $optionConverter; $this->productRepository = $productRepository; $this->type = $type; + $this->linkConverter = $linkConverter; } /** @@ -75,7 +85,10 @@ class ReadService implements ReadServiceInterface if (!$option->getId()) { throw new NoSuchEntityException('Requested option doesn\'t exist'); } - return $this->optionConverter->createDataFromModel($option, $product); + + $productLinks = $this->getProductLinks($product, $optionId); + + return $this->optionConverter->createDataFromModel($option, $product, $productLinks); } /** @@ -90,11 +103,39 @@ class ReadService implements ReadServiceInterface $optionDtoList = []; /** @var \Magento\Bundle\Model\Option $option */ foreach ($optionCollection as $option) { - $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product); + $productLinks = $this->getProductLinks($product, $option->getId()); + + $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product, $productLinks); } return $optionDtoList; } + /** + * @param Product $product + * @param int $optionId + * @return array|null + */ + private function getProductLinks(Product $product, $optionId) + { + /** @var \Magento\Bundle\Model\Product\Type $productTypeInstance */ + $productTypeInstance = $product->getTypeInstance(); + $productTypeInstance->setStoreFilter( + $product->getStoreId(), + $product + ); + $selectionCollection = $productTypeInstance->getSelectionsCollection( + [ $optionId ], + $product + ); + + $productLinks = []; + /** @var \Magento\Catalog\Model\Product $selection */ + foreach ($selectionCollection as $selection) { + $productLinks[] = $this->linkConverter->createDataFromModel($selection, $product); + } + return $productLinks; + } + /** * @param string $productSku * @return Product diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php index d48888f5229..df486c2a59f 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteService.php @@ -24,13 +24,15 @@ namespace Magento\Bundle\Service\V1\Product\Option; use Magento\Bundle\Model\Product\Type; +use Magento\Bundle\Service\V1\Data\Product\Link; use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Product\Link\WriteService as LinkWriteService; 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\Framework\StoreManagerInterface; use Magento\Webapi\Exception; class WriteService implements WriteServiceInterface @@ -52,22 +54,30 @@ class WriteService implements WriteServiceInterface */ private $storeManager; + /** + * @var LinkWriteService + */ + private $linkWriteService; + /** * @param ProductRepository $productRepository * @param Type $type * @param OptionConverter $optionConverter * @param StoreManagerInterface $storeManager + * @param LinkWriteService $linkWriteService */ public function __construct( ProductRepository $productRepository, Type $type, OptionConverter $optionConverter, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + LinkWriteService $linkWriteService ) { $this->productRepository = $productRepository; $this->type = $type; $this->optionConverter = $optionConverter; $this->storeManager = $storeManager; + $this->linkWriteService = $linkWriteService; } /** @@ -104,7 +114,14 @@ class WriteService implements WriteServiceInterface throw new CouldNotSaveException('Could not save option', [], $e); } - return $optionModel->getId(); + $optionId = $optionModel->getId(); + if (is_array($option->getProductLinks())) { + foreach ($option->getProductLinks() as $link) { + $this->linkWriteService->addChild($productSku, $optionId, $link); + } + } + + return $optionId; } /** @@ -125,6 +142,35 @@ class WriteService implements WriteServiceInterface } $updateOption->setStoreId($this->storeManager->getStore()->getId()); + /** + * @var Link[] $existingProductLinks + */ + $existingProductLinks = $optionModel->getProductLinks(); + if (!is_array($existingProductLinks)) { + $existingProductLinks = array(); + } + /** + * @var Link[] $newProductLinks + */ + $newProductLinks = $option->getProductLinks(); + if (is_null($newProductLinks)) { + $newProductLinks = array(); + } + /** + * @var Link[] $linksToDelete + */ + $linksToDelete = array_udiff($existingProductLinks, $newProductLinks, array($this, 'compareLinks')); + foreach ($linksToDelete as $link) { + $this->linkWriteService->removeChild($productSku, $option->getId(), $link->getSku()); + } + /** + * @var Link[] $linksToAdd + */ + $linksToAdd = array_udiff($newProductLinks, $existingProductLinks, array($this, 'compareLinks')); + foreach ($linksToAdd as $link) { + $this->linkWriteService->addChild($productSku, $option->getId(), $link); + } + try { $updateOption->save(); } catch (\Exception $e) { @@ -156,4 +202,20 @@ class WriteService implements WriteServiceInterface return $product; } + + /** + * Compare two links and determine if they are equal + * + * @param Link $firstLink + * @param Link $secondLink + * @return int + */ + private function compareLinks(Link $firstLink, Link $secondLink) + { + if ($firstLink->getSku() == $secondLink->getSku()) { + return 0; + } else { + return 1; + } + } } diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 20b090534cd..c2f9926dbc1 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-webapi": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-webapi": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/frontend/di.xml b/app/code/Magento/Bundle/etc/data_object.xml similarity index 76% rename from app/code/Magento/Reports/etc/frontend/di.xml rename to app/code/Magento/Bundle/etc/data_object.xml index a5ab4ba4e5d..115fb118873 100644 --- a/app/code/Magento/Reports/etc/frontend/di.xml +++ b/app/code/Magento/Bundle/etc/data_object.xml @@ -23,10 +23,8 @@ * @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"> - <virtualType name="Magento\Reports\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </virtualType> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Service/etc/data_object.xsd"> + <custom_attributes for="Magento\Catalog\Service\V1\Data\Product"> + <attribute code="bundle_product_options" type="Magento\Bundle\Service\V1\Data\Product\Option[]" /> + </custom_attributes> </config> diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index b33dcd27d2b..6275f1d413c 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -103,4 +103,24 @@ <argument name="calculator" xsi:type="object">Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface</argument> </arguments> </type> + <type name="Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite"> + <arguments> + <argument name="loadProcessors" xsi:type="array"> + <item name="bundleProductLoadProcessor" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor</item> + <item name="sortOrder" xsi:type="string">50</item> + </item> + </argument> + </arguments> + </type> + <type name="Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite"> + <arguments> + <argument name="saveProcessors" xsi:type="array"> + <item name="bundleProductSaveProcessor" xsi:type="array"> + <item name="type" xsi:type="object">Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor</item> + <item name="sortOrder" xsi:type="string">50</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Captcha/Helper/Data.php b/app/code/Magento/Captcha/Helper/Data.php index 581e52566d3..f7ed3ae927f 100644 --- a/app/code/Magento/Captcha/Helper/Data.php +++ b/app/code/Magento/Captcha/Helper/Data.php @@ -70,7 +70,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_filesystem; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,14 +81,14 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Captcha\Model\CaptchaFactory $factory */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Filesystem $filesystem, \Magento\Captcha\Model\CaptchaFactory $factory diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index ccdc2ddac20..88d0306418c 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php index 62d8ea5508c..e3b6f29b3c2 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php @@ -32,7 +32,7 @@ namespace Magento\Catalog\Block\Adminhtml\Category\Helper; class Image extends \Magento\Framework\Data\Form\Element\Image { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -41,7 +41,7 @@ class Image extends \Magento\Framework\Data\Form\Element\Image * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -49,7 +49,7 @@ class Image extends \Magento\Framework\Data\Form\Element\Image \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $data = array() ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php index 4978d20a1ce..ac7c9b178ed 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php @@ -100,7 +100,7 @@ class Wysiwyg extends \Magento\Framework\Data\Form\Element\Textarea 'label' => __('WYSIWYG Editor'), 'type' => 'button', 'disabled' => $disabled, - 'class' => $disabled ? 'disabled action-wysiwyg' : 'action-wysiwyg', + 'class' => 'action-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl( 'catalog/product/wysiwyg' ) . '\', \'' . $this->getHtmlId() . '\')' diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php index e347dbe250e..1d5f9eeb0d9 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php @@ -36,7 +36,7 @@ use Magento\Eav\Model\Entity\Attribute; class Gallery extends AbstractElement { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -50,7 +50,7 @@ class Gallery extends AbstractElement * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -58,7 +58,7 @@ class Gallery extends AbstractElement \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, \Magento\Framework\View\LayoutInterface $layout, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $data = array() ) { $this->_layout = $layout; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php index 115ba7728b2..8c8845c7688 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php @@ -50,7 +50,7 @@ class Price extends \Magento\Framework\Data\Form\Element\Text * @param \Magento\Framework\Data\Form\Element\Factory $factoryElement * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Framework\Escaper $escaper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param \Magento\Tax\Helper\Data $taxData * @param array $data @@ -59,7 +59,7 @@ class Price extends \Magento\Framework\Data\Form\Element\Text \Magento\Framework\Data\Form\Element\Factory $factoryElement, \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, \Magento\Tax\Helper\Data $taxData, array $data = array() diff --git a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php index a1bf363c36e..26bd2557ff1 100644 --- a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php @@ -73,11 +73,11 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare protected $httpContext; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Catalog product visibility @@ -108,7 +108,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param Product\Visibility $catalogProductVisibility - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer * @param array $data @@ -118,7 +118,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare \Magento\Core\Helper\Data $coreData, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Framework\App\Http\Context $httpContext, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, array $data = array() @@ -126,7 +126,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare $this->_coreData = $coreData; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductVisibility = $catalogProductVisibility; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->httpContext = $httpContext; $this->currentCustomer = $currentCustomer; parent::__construct( @@ -184,7 +184,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare } elseif ($this->_customerId) { $this->_items->setCustomerId($this->_customerId); } else { - $this->_items->setVisitorId($this->_logVisitor->getId()); + $this->_items->setVisitorId($this->_customerVisitor->getId()); } $this->_items->addAttributeToSelect( diff --git a/app/code/Magento/Catalog/Block/Product/Context.php b/app/code/Magento/Catalog/Block/Product/Context.php index 2a3708fea28..fe22dcc23b0 100644 --- a/app/code/Magento/Catalog/Block/Product/Context.php +++ b/app/code/Magento/Catalog/Block/Product/Context.php @@ -106,7 +106,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\Framework\Registry $registry * @param \Magento\Tax\Helper\Data $taxHelper @@ -144,7 +144,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig, \Magento\Framework\Registry $registry, \Magento\Tax\Helper\Data $taxHelper, diff --git a/app/code/Magento/Catalog/Block/Product/Send.php b/app/code/Magento/Catalog/Block/Product/Send.php index 0d5cd904783..0a9c9cd244c 100644 --- a/app/code/Magento/Catalog/Block/Product/Send.php +++ b/app/code/Magento/Catalog/Block/Product/Send.php @@ -88,13 +88,4 @@ class Send extends \Magento\Catalog\Block\Product\AbstractProduct { return $this->getRequest()->getParam('id'); } - - /** - * @return int - */ - public function getMaxRecipients() - { - $sendToFriendModel = $this->_coreRegistry->registry('send_to_friend_model'); - return $sendToFriendModel->getMaxRecipients(); - } } diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index fbfd9c6a210..b23ad04e278 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -202,8 +202,7 @@ class View extends AbstractProduct implements \Magento\Framework\View\Block\Iden */ public function canEmailToFriend() { - $sendToFriendModel = $this->_coreRegistry->registry('send_to_friend_model'); - return $sendToFriendModel && $sendToFriendModel->canEmailToFriend(); + return false; } /** diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 1d4aa70d7f2..9c0a81bba6b 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -48,7 +48,7 @@ class Category extends \Magento\Backend\App\Action $category->load($categoryId); if ($storeId) { $rootId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getRootCategoryId(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 1c6693caa1b..366d0e3b898 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -38,7 +38,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category $categoryId = (int)$this->getRequest()->getParam('id'); if ($storeId && !$categoryId && !$parentId) { - $store = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + $store = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); $this->getRequest()->setParam('id', (int)$store->getRootCategoryId()); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 03178387ebc..e6f3378323a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -64,7 +64,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category if (!$parentId) { if ($storeId) { $parentId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getRootCategoryId(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php index 857c6e69af5..9d3ead8200f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php @@ -39,7 +39,7 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category if ($storeId) { if (!$categoryId) { - $store = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + $store = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); $rootId = $store->getRootCategoryId(); $this->getRequest()->setParam('id', $rootId); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php index a14533d546c..fb4fcbb3ef6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php @@ -66,7 +66,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Product $this->_setActiveMenu('Magento_Catalog::catalog_products'); if (!$this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->isSingleStoreMode() && ($switchBlock = $this->_view->getLayout()->getBlock( 'store_switcher' )) 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 c6ef67d1947..9dc472ea172 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -31,7 +31,7 @@ class Helper protected $request; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,14 +52,14 @@ class Helper /** * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param StockDataFilter $stockFilter * @param \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks * @param \Magento\Backend\Helper\Js $jsHelper */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, StockDataFilter $stockFilter, \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks, \Magento\Backend\Helper\Js $jsHelper diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php index 82bbbe2b645..3351bb8577d 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php @@ -36,7 +36,7 @@ class Wysiwyg extends \Magento\Catalog\Controller\Adminhtml\Product $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeId )->getBaseUrl( diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php index e60825d2df8..12a68a4b630 100644 --- a/app/code/Magento/Catalog/Controller/Category/View.php +++ b/app/code/Magento/Catalog/Controller/Category/View.php @@ -55,7 +55,7 @@ class View extends \Magento\Framework\App\Action\Action protected $_categoryFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -65,7 +65,7 @@ class View extends \Magento\Framework\App\Action\Action * @param \Magento\Catalog\Model\Design $catalogDesign * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -73,7 +73,7 @@ class View extends \Magento\Framework\App\Action\Action \Magento\Catalog\Model\Design $catalogDesign, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Registry $coreRegistry, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; $this->_categoryFactory = $categoryFactory; diff --git a/app/code/Magento/Catalog/Controller/Product/Compare.php b/app/code/Magento/Catalog/Controller/Product/Compare.php index 24c7f8be1f1..d814773bb34 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare.php @@ -54,11 +54,11 @@ class Compare extends \Magento\Framework\App\Action\Action protected $_catalogProductCompareList; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Customer session @@ -89,7 +89,7 @@ class Compare extends \Magento\Framework\App\Action\Action protected $_compareItemFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,10 +104,10 @@ class Compare extends \Magento\Framework\App\Action\Action * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList * @param \Magento\Catalog\Model\Session $catalogSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param FormKeyValidator $formKeyValidator */ public function __construct( @@ -116,10 +116,10 @@ class Compare extends \Magento\Framework\App\Action\Action \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList, \Magento\Catalog\Model\Session $catalogSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, FormKeyValidator $formKeyValidator ) { $this->_storeManager = $storeManager; @@ -127,7 +127,7 @@ class Compare extends \Magento\Framework\App\Action\Action $this->_productFactory = $productFactory; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_catalogProductCompareList = $catalogProductCompareList; $this->_catalogSession = $catalogSession; $this->_formKeyValidator = $formKeyValidator; diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php index 6cab38dfae2..ba8d8efe36d 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php @@ -39,7 +39,7 @@ class Add extends \Magento\Catalog\Controller\Product\Compare } $productId = (int)$this->getRequest()->getParam('product'); - if ($productId && ($this->_logVisitor->getId() || $this->_customerSession->isLoggedIn())) { + if ($productId && ($this->_customerVisitor->getId() || $this->_customerSession->isLoggedIn())) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->_productFactory->create(); $product->setStoreId($this->_storeManager->getStore()->getId())->load($productId); diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php index f2c10042575..cebf3b5340a 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Clear.php @@ -41,7 +41,7 @@ class Clear extends \Magento\Catalog\Controller\Product\Compare } elseif ($this->_customerId) { $items->setCustomerId($this->_customerId); } else { - $items->setVisitorId($this->_logVisitor->getId()); + $items->setVisitorId($this->_customerVisitor->getId()); } try { diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php index 7380db349bf..b4c2478c5c9 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php @@ -47,7 +47,7 @@ class Remove extends \Magento\Catalog\Controller\Product\Compare } elseif ($this->_customerId) { $item->setCustomerId($this->_customerId); } else { - $item->addVisitorId($this->_logVisitor->getId()); + $item->addVisitorId($this->_customerVisitor->getId()); } $item->loadByProduct($product); diff --git a/app/code/Magento/Catalog/Helper/Category.php b/app/code/Magento/Catalog/Helper/Category.php index a430b0cc64f..99e5a25df2e 100644 --- a/app/code/Magento/Catalog/Helper/Category.php +++ b/app/code/Magento/Catalog/Helper/Category.php @@ -64,7 +64,7 @@ class Category extends AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -85,14 +85,14 @@ class Category extends AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Data\CollectionFactory $dataCollectionFactory */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Catalog\Model\CategoryFactory $categoryFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Data\CollectionFactory $dataCollectionFactory ) { diff --git a/app/code/Magento/Catalog/Helper/Data.php b/app/code/Magento/Catalog/Helper/Data.php index 1a1bf36b4c5..0faa685c3dc 100644 --- a/app/code/Magento/Catalog/Helper/Data.php +++ b/app/code/Magento/Catalog/Helper/Data.php @@ -138,7 +138,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -227,7 +227,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Catalog\Model\Resource\Eav\AttributeFactory $eavAttributeFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Stdlib\String $string * @param Category $catalogCategory @@ -250,7 +250,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Catalog\Model\Resource\Eav\AttributeFactory $eavAttributeFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Stdlib\String $string, Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index 177b2639bbc..4be9078942e 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -127,7 +127,7 @@ class Product extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Session $catalogSession @@ -141,7 +141,7 @@ class Product extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Session $catalogSession, diff --git a/app/code/Magento/Catalog/Helper/Product/Compare.php b/app/code/Magento/Catalog/Helper/Product/Compare.php index 01824c14765..03eb15ffe4f 100644 --- a/app/code/Magento/Catalog/Helper/Product/Compare.php +++ b/app/code/Magento/Catalog/Helper/Product/Compare.php @@ -76,11 +76,11 @@ class Compare extends \Magento\Core\Helper\Url protected $_customerSession; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Catalog product visibility @@ -113,10 +113,10 @@ class Compare extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Model\Session $catalogSession * @param \Magento\Framework\Data\Form\FormKey $formKey @@ -125,10 +125,10 @@ class Compare extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Data\Form\FormKey $formKey, @@ -137,7 +137,7 @@ class Compare extends \Magento\Core\Helper\Url ) { $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductVisibility = $catalogProductVisibility; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_catalogSession = $catalogSession; $this->_formKey = $formKey; @@ -289,7 +289,7 @@ class Compare extends \Magento\Core\Helper\Url } elseif ($this->_customerId) { $this->_itemCollection->setCustomerId($this->_customerId); } else { - $this->_itemCollection->setVisitorId($this->_logVisitor->getId()); + $this->_itemCollection->setVisitorId($this->_customerVisitor->getId()); } $this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds()); @@ -322,7 +322,7 @@ class Compare extends \Magento\Core\Helper\Url } elseif ($this->_customerId) { $collection->setCustomerId($this->_customerId); } else { - $collection->setVisitorId($this->_logVisitor->getId()); + $collection->setVisitorId($this->_customerVisitor->getId()); } /* Price data is added to consider item stock status using price index */ diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php index 9369033f17c..ebbf3cb8f03 100644 --- a/app/code/Magento/Catalog/Helper/Product/Composite.php +++ b/app/code/Magento/Catalog/Helper/Product/Composite.php @@ -27,7 +27,7 @@ use Magento\Framework\App\Helper\Context; use Magento\Framework\App\ViewInterface; use Magento\Catalog\Helper\Product; use Magento\Catalog\Model\ProductFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Controller\RegistryConstants; use Magento\Customer\Model\Converter; use Magento\Framework\Registry; @@ -54,7 +54,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper protected $_catalogProduct = null; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -76,7 +76,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param ProductFactory $productFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Product $catalogProduct * @param Registry $coreRegistry * @param ViewInterface $view diff --git a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php index 1399a446e62..a63a8c46757 100644 --- a/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php +++ b/app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php @@ -117,7 +117,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper protected $_attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -143,7 +143,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig * @param \Magento\Catalog\Model\Resource\ConfigFactory $configFactory * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mview\View\Changelog $changelog * @param bool $addFilterableAttrs * @param bool $addChildData @@ -156,7 +156,7 @@ class Indexer extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Catalog\Model\Attribute\Config $attributeConfig, \Magento\Catalog\Model\Resource\ConfigFactory $configFactory, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mview\View\Changelog $changelog, $addFilterableAttrs = false, $addChildData = false, diff --git a/app/code/Magento/Catalog/Helper/Product/Inventory.php b/app/code/Magento/Catalog/Helper/Product/Inventory.php index e3599046fdb..d51037b1ef2 100644 --- a/app/code/Magento/Catalog/Helper/Product/Inventory.php +++ b/app/code/Magento/Catalog/Helper/Product/Inventory.php @@ -100,8 +100,8 @@ class Inventory extends \Magento\Framework\App\Helper\AbstractHelper public function getDoFieldData($field, StockItem $dataObject) { $possibleMethods = array( - 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($field), - 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($field) + 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field), + 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($field) ); foreach ($possibleMethods as $method) { diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php index e41ac7c97f6..3a567565f1d 100644 --- a/app/code/Magento/Catalog/Model/AbstractModel.php +++ b/app/code/Magento/Catalog/Model/AbstractModel.php @@ -71,14 +71,14 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -86,7 +86,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 77a70a1d91d..bc0ec4c791e 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -191,7 +191,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory @@ -212,7 +212,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php index 804e3f8d6b5..28ef8cff07a 100644 --- a/app/code/Magento/Catalog/Model/Config.php +++ b/app/code/Magento/Catalog/Model/Config.php @@ -98,7 +98,7 @@ class Config extends \Magento\Eav\Model\Config /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -142,7 +142,7 @@ class Config extends \Magento\Eav\Model\Config * @param \Magento\Catalog\Model\Product\TypeFactory $productTypeFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -157,7 +157,7 @@ class Config extends \Magento\Eav\Model\Config \Magento\Catalog\Model\Product\TypeFactory $productTypeFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig ) { $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php index 090e68cd60d..1a88eda6460 100644 --- a/app/code/Magento/Catalog/Model/Entity/Attribute.php +++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php @@ -94,7 +94,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -111,7 +111,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php index 159d3692224..06d98e19372 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php @@ -43,7 +43,7 @@ class AbstractAction protected $resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -63,12 +63,12 @@ class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper ) { $this->resource = $resource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php index 72733fa209d..3b3dddb053c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php @@ -32,13 +32,13 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory ) { diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php index 5fb3182e3b1..d546d93fb33 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php @@ -79,7 +79,7 @@ abstract class AbstractAction protected $resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -97,12 +97,12 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $config */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $config ) { $this->resource = $resource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php index fe08d6e044d..956a5c0ac33 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Eav/Plugin/AttributeSet/IndexableAttributeFilter.php @@ -50,18 +50,20 @@ class IndexableAttributeFilter { $codes = []; $catalogResource = $this->_attributeFactory->create(); - - foreach ($set->getGroups() as $group) { - /** @var $group \Magento\Eav\Model\Entity\Attribute\Group */ - foreach ($group->getAttributes() as $attribute) { - /** @var $attribute \Magento\Eav\Model\Entity\Attribute */ - $catalogResource->load($attribute->getId()); - if ($catalogResource->isIndexable()) { - // Attribute requires to be cloned for new dataset to maintain attribute set changes - $attributeClone = clone $attribute; - $attributeClone->load($attribute->getAttributeId()); - $codes[] = $attributeClone->getAttributeCode(); - unset($attributeClone); + $groups = $set->getGroups(); + if (is_array($groups)) { + foreach ($groups as $group) { + /** @var $group \Magento\Eav\Model\Entity\Attribute\Group */ + foreach ($group->getAttributes() as $attribute) { + /** @var $attribute \Magento\Eav\Model\Entity\Attribute */ + $catalogResource->load($attribute->getId()); + if ($catalogResource->isIndexable()) { + // Attribute requires to be cloned for new dataset to maintain attribute set changes + $attributeClone = clone $attribute; + $attributeClone->load($attribute->getAttributeId()); + $codes[] = $attributeClone->getAttributeCode(); + unset($attributeClone); + } } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php index 34d92420865..4e474424911 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php @@ -44,7 +44,7 @@ abstract class AbstractAction protected $_tableDropSuffix = '_drop_indexer'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -89,7 +89,7 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -97,7 +97,7 @@ abstract class AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php index 8829c244647..2caa4477bc6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php @@ -38,19 +38,19 @@ class Eraser protected $connection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->productIndexerHelper = $productHelper; $this->connection = $resource->getConnection('default'); diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php index ddaf458ae13..9cb1bc68c4d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Row.php @@ -44,7 +44,7 @@ class Row extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -54,7 +54,7 @@ class Row extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php index d0d2e38f7e7..8ee5949f63c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Rows.php @@ -39,7 +39,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper * @param \Magento\Catalog\Model\Product\Type $productType * @param TableBuilder $tableBuilder @@ -48,7 +48,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php index 787728991b7..69bee9ddc1a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php @@ -49,7 +49,7 @@ class FlatTableBuilder protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -62,14 +62,14 @@ class FlatTableBuilder * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param TableDataInterface $tableData */ public function __construct( \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper, \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface $tableData ) { $this->_productIndexerHelper = $productIndexerHelper; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php index 47e19be5f15..c695c64c1af 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php @@ -56,7 +56,7 @@ abstract class AbstractAction protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,7 +104,7 @@ abstract class AbstractAction /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -115,7 +115,7 @@ abstract class AbstractAction public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php index c3375da301a..49836720f9a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Observer.php @@ -26,7 +26,7 @@ namespace Magento\Catalog\Model\Indexer\Product\Price; class Observer { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -61,7 +61,7 @@ class Observer protected $_connection; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -69,7 +69,7 @@ class Observer * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php index 31badd1789b..fb399b491e8 100644 --- a/app/code/Magento/Catalog/Model/Layer.php +++ b/app/code/Magento/Catalog/Model/Layer.php @@ -54,7 +54,7 @@ class Layer extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -107,7 +107,7 @@ class Layer extends \Magento\Framework\Object * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -117,7 +117,7 @@ class Layer extends \Magento\Framework\Object \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Catalog\Model\Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Category.php b/app/code/Magento/Catalog/Model/Layer/Category.php index ba12e8722a4..b77a6357be2 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category.php +++ b/app/code/Magento/Catalog/Model/Layer/Category.php @@ -37,7 +37,7 @@ class Category extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Category extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php index 8d7afa77589..931dc7a0f48 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php +++ b/app/code/Magento/Catalog/Model/Layer/Category/FilterableAttributeList.php @@ -36,7 +36,7 @@ class FilterableAttributeList implements FilterableAttributeListInterface protected $collectionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -49,12 +49,12 @@ class FilterableAttributeList implements FilterableAttributeListInterface * FilterableAttributeList constructor * * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer ) { $this->collectionFactory = $collectionFactory; diff --git a/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php b/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php index 44a9d1b2b4e..9003a5363b1 100644 --- a/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php +++ b/app/code/Magento/Catalog/Model/Layer/Category/StateKey.php @@ -30,7 +30,7 @@ use Magento\Catalog\Model\Layer\StateKeyInterface; class StateKey implements StateKeyInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -40,11 +40,11 @@ class StateKey implements StateKeyInterface protected $customerSession; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php index 88c05c3425e..c760506c2c0 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php @@ -54,7 +54,7 @@ abstract class AbstractFilter extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -69,13 +69,13 @@ abstract class AbstractFilter extends \Magento\Framework\Object * Constructor * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param array $data */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php index 09917a939d3..d365147d7a4 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php @@ -53,7 +53,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter /** * @param ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\AttributeFactory $filterAttributeFactory * @param \Magento\Framework\Stdlib\String $string @@ -62,7 +62,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\AttributeFactory $filterAttributeFactory, \Magento\Framework\Stdlib\String $string, diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php index 8765e28ce4a..be76e54f90f 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php @@ -70,7 +70,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter * Construct * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Framework\Escaper $escaper @@ -79,7 +79,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Framework\Escaper $escaper, diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php index bc434112ad1..c14a9b5b64c 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php @@ -45,14 +45,14 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter * Construct * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory * @param array $data */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\DecimalFactory $filterDecimalFactory, array $data = array() diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php index 78adcb1eb05..f926f6f0b78 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php @@ -94,7 +94,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter /** * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Resource\Layer\Filter\PriceFactory $filterPriceFactory * @param \Magento\Customer\Model\Session $customerSession @@ -105,7 +105,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Resource\Layer\Filter\PriceFactory $filterPriceFactory, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Catalog/Model/Layer/Search.php b/app/code/Magento/Catalog/Model/Layer/Search.php index 055a6b21b84..a5d8f3a1e07 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search.php +++ b/app/code/Magento/Catalog/Model/Layer/Search.php @@ -37,7 +37,7 @@ class Search extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Search extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php index ff92b26ead5..6781008d8df 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/CollectionFilter.php @@ -39,7 +39,7 @@ class CollectionFilter implements CollectionFilterInterface protected $helper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -51,13 +51,13 @@ class CollectionFilter implements CollectionFilterInterface /** * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\CatalogSearch\Helper\Data $helper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility */ public function __construct( \Magento\Catalog\Model\Config $catalogConfig, \Magento\CatalogSearch\Helper\Data $helper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility ) { $this->catalogConfig = $catalogConfig; diff --git a/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php b/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php index 2f009577220..df8d2dd1709 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/FilterableAttributeList.php @@ -29,12 +29,12 @@ class FilterableAttributeList extends \Magento\Catalog\Model\Layer\Category\Filt { /** * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer\Search $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer\Search $layer ) { parent::__construct($collectionFactory, $storeManager, $layer); diff --git a/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php b/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php index 955731d9f21..a6a58adc4e4 100644 --- a/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php +++ b/app/code/Magento/Catalog/Model/Layer/Search/StateKey.php @@ -34,12 +34,12 @@ class StateKey extends \Magento\Catalog\Model\Layer\Category\StateKey protected $helper; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\CatalogSearch\Helper\Data $helper */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\CatalogSearch\Helper\Data $helper ) { diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php index 2907ed2fc45..9bf515157cd 100644 --- a/app/code/Magento/Catalog/Model/Observer.php +++ b/app/code/Magento/Catalog/Model/Observer.php @@ -61,7 +61,7 @@ class Observer /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Observer * @param \Magento\Catalog\Model\UrlFactory $urlFactory * @param \Magento\Catalog\Model\Resource\Category $categoryResource * @param \Magento\Catalog\Model\Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Index\Model\Indexer $indexIndexer * @param \Magento\Catalog\Helper\Category $catalogCategory @@ -109,7 +109,7 @@ class Observer \Magento\Catalog\Model\UrlFactory $urlFactory, \Magento\Catalog\Model\Resource\Category $categoryResource, \Magento\Catalog\Model\Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Index\Model\Indexer $indexIndexer, \Magento\Catalog\Helper\Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 7b467099e0f..6bae0cd6270 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -272,7 +272,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Product\Url $url * @param Product\Link $productLink * @param Product\Configuration\Item\OptionFactory $itemOptionFactory @@ -302,7 +302,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Product\Url $url, Product\Link $productLink, \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php index 4b60745fa47..59e690c995c 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php @@ -40,7 +40,7 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -49,7 +49,7 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php index 8f726dfda1b..c519659e4b9 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php @@ -56,7 +56,7 @@ abstract class AbstractGroupprice extends Price /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -64,7 +64,7 @@ abstract class AbstractGroupprice extends Price public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php index fadadfc5928..38db2957444 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -40,7 +40,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -63,14 +63,14 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend * * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php index d0e0ddb04cd..28fc31e5818 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php @@ -42,7 +42,7 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -51,7 +51,7 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php index d90a58cebf5..21652391443 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php @@ -35,16 +35,16 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFronten /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * Construct * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php index c32408dcee6..d54ab15f6d9 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php @@ -39,7 +39,7 @@ class Countryofmanufacture extends \Magento\Eav\Model\Entity\Attribute\Source\Ab /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -54,12 +54,12 @@ class Countryofmanufacture extends \Magento\Eav\Model\Entity\Attribute\Source\Ab * Construct * * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Cache\Type\Config $configCacheType */ public function __construct( \Magento\Directory\Model\CountryFactory $countryFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Cache\Type\Config $configCacheType ) { $this->_countryFactory = $countryFactory; diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php index 04b3c683c59..e4db0341e79 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php @@ -74,24 +74,24 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr protected $_customerSession; /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -101,8 +101,8 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Helper\Product\Compare $catalogProductCompare, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -110,7 +110,7 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr array $data = array() ) { $this->_storeManager = $storeManager; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_catalogProductCompare = $catalogProductCompare; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -267,7 +267,7 @@ class Item extends \Magento\Framework\Model\AbstractModel implements \Magento\Fr public function getVisitorId() { if (!$this->hasData('visitor_id')) { - $visitorId = $this->_logVisitor->getId(); + $visitorId = $this->_customerVisitor->getId(); $this->setData('visitor_id', $visitorId); } return $this->getData('visitor_id'); diff --git a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php index 39bac3086d5..788e5b30581 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php @@ -33,11 +33,11 @@ use Magento\Catalog\Model\Resource\Product\Compare\Item\Collection; class ListCompare extends \Magento\Framework\Object { /** - * Log visitor + * Customer visitor * - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * Customer session @@ -74,7 +74,7 @@ class ListCompare extends \Magento\Framework\Object * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param array $data */ public function __construct( @@ -82,14 +82,14 @@ class ListCompare extends \Magento\Framework\Object \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, array $data = array() ) { $this->_compareItemFactory = $compareItemFactory; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductCompareItem = $catalogProductCompareItem; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; parent::__construct($data); } @@ -168,7 +168,7 @@ class ListCompare extends \Magento\Framework\Object */ protected function _addVisitorToItem($item) { - $item->addVisitorId($this->_logVisitor->getId()); + $item->addVisitorId($this->_customerVisitor->getId()); if ($this->_customerSession->isLoggedIn()) { $item->setCustomerId($this->_customerSession->getCustomerId()); } diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index d2372eec3f7..a926fdae786 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -173,14 +173,14 @@ class Image extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase * @param \Magento\Framework\App\Filesystem $filesystem @@ -195,7 +195,7 @@ class Image extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase, \Magento\Framework\App\Filesystem $filesystem, diff --git a/app/code/Magento/Catalog/Model/Product/Media/Config.php b/app/code/Magento/Catalog/Model/Product/Media/Config.php index f7a95db8f1d..8a99bd66902 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/Config.php +++ b/app/code/Magento/Catalog/Model/Product/Media/Config.php @@ -33,14 +33,14 @@ class Config implements ConfigInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php index 4d76f7c4f47..59ebb2e3fd7 100755 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -64,7 +64,7 @@ class Price /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,14 +79,14 @@ class Price * Construct * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager diff --git a/app/code/Magento/Catalog/Model/Product/Url.php b/app/code/Magento/Catalog/Model/Product/Url.php index c8ce679c494..45268641301 100644 --- a/app/code/Magento/Catalog/Model/Product/Url.php +++ b/app/code/Magento/Catalog/Model/Product/Url.php @@ -63,7 +63,7 @@ class Url extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,7 +77,7 @@ class Url extends \Magento\Framework\Object * * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Category $catalogCategory * @param \Magento\Framework\Filter\FilterManager $filter * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -86,7 +86,7 @@ class Url extends \Magento\Framework\Object public function __construct( \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Framework\Filter\FilterManager $filter, \Magento\Framework\Session\SidResolverInterface $sidResolver, diff --git a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php index 01ce99b70ce..9238fe9c862 100644 --- a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php @@ -40,7 +40,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param array $data */ @@ -71,7 +71,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, $data = array() ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php index 3bbd658a48f..5d7929e93b1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php @@ -46,14 +46,14 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType * @param \Magento\Eav\Model\Config $eavConfig * @param LockValidatorInterface $lockValidator */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Entity\Type $eavEntityType, \Magento\Eav\Model\Config $eavConfig, LockValidatorInterface $lockValidator diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php index 2fbc171768f..3d002f93e55 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category.php +++ b/app/code/Magento/Catalog/Model/Resource/Category.php @@ -90,7 +90,7 @@ class Category extends AbstractResource * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory @@ -106,7 +106,7 @@ class Category extends AbstractResource \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php index 072536a0b26..7b310c768d2 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php @@ -35,16 +35,16 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFronten /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * Construct * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php index 17404be9d87..51515557a69 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php @@ -75,7 +75,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource * @param \Magento\Framework\App\Resource $resource * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager */ @@ -105,7 +105,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource \Magento\Framework\App\Resource $resource, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig, \Magento\Framework\Event\ManagerInterface $eventManager ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php index a25175d8bd0..e91e35d297d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php @@ -28,7 +28,7 @@ use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Model\Resource\Db\AbstractDb; use Magento\Framework\Logger; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Catalog category flat collection @@ -54,7 +54,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -70,7 +70,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param Logger $logger * @param FetchStrategyInterface $fetchStrategy * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param AbstractDb $resource */ diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php index b330626f25c..c87b776ff12 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php @@ -91,7 +91,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -114,7 +114,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp * * @param \Magento\Catalog\Model\Resource\Category $catalogCategory * @param \Magento\Framework\App\CacheInterface $cache - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig @@ -123,7 +123,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp public function __construct( \Magento\Catalog\Model\Resource\Category $catalogCategory, \Magento\Framework\App\CacheInterface $cache, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Resource $resource, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Attribute\Config $attributeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php index 70eb37b606d..7694d497346 100644 --- a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php @@ -41,7 +41,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -55,7 +55,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -70,7 +70,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php index 9027067a5ce..174fb186153 100644 --- a/app/code/Magento/Catalog/Model/Resource/Config.php +++ b/app/code/Magento/Catalog/Model/Resource/Config.php @@ -54,18 +54,18 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php index e447bb073e5..2058d82898f 100644 --- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php @@ -126,7 +126,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -146,7 +146,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php index c7b0aaefd0e..9b7e0d30cc0 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product.php +++ b/app/code/Magento/Catalog/Model/Resource/Product.php @@ -67,7 +67,7 @@ class Product extends AbstractResource * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Factory $modelFactory * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory * @param Category $catalogCategory @@ -82,7 +82,7 @@ class Product extends AbstractResource \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Factory $modelFactory, \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory, Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index 2e64d42fa00..37d073c47f1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -268,7 +268,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -291,7 +291,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php index c7e7f2773f6..fc09bc0848d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php @@ -76,7 +76,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -101,7 +101,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php index 4be82c13741..9370d89bfbc 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php @@ -49,18 +49,18 @@ class Flat extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Config $catalogConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Config $catalogConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php index e2af327803e..f66c51c7ce8 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php @@ -163,7 +163,7 @@ class Source extends AbstractEav } /**@var $select \Magento\Framework\DB\Select*/ - $select = $adapter->select()->from( + $select = $adapter->select()->distinct(true)->from( array('pid' => new \Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))), array() )->joinLeft( @@ -184,6 +184,11 @@ class Source extends AbstractEav $select->where($this->_resourceHelper->getIsNullNotNullCondition('pis.value', 'pid.value')); + /** + * Exclude attribute values that contains NULL + */ + $select->where('NOT(pis.value IS NULL AND pis.value_id IS NOT NULL)'); + /** * Add additional external limitation */ @@ -196,7 +201,6 @@ class Source extends AbstractEav 'store_field' => new \Zend_Db_Expr('pid.store_id') ) ); - $query = $select->insertFromSelect($idxTable); $adapter->query($query); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index a87e5e2bdf8..be50976351b 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -33,7 +33,7 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php index cd11770bef6..104b47e7746 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php @@ -33,7 +33,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -50,7 +50,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -60,7 +60,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { 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 741aa4c7c3e..814ad21e9e2 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -33,7 +33,7 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Website.php b/app/code/Magento/Catalog/Model/Resource/Product/Website.php index 4d992c66daf..8337c236092 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Website.php @@ -31,17 +31,17 @@ class Website extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($resource); diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php index 010e73a5f9b..18e90d9608e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Url.php +++ b/app/code/Magento/Catalog/Model/Resource/Url.php @@ -94,7 +94,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -105,7 +105,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param Product $productResource * @param \Magento\Catalog\Model\Category $catalogCategory @@ -113,7 +113,7 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, Product $productResource, \Magento\Catalog\Model\Category $catalogCategory, diff --git a/app/code/Magento/Catalog/Model/Template/Filter.php b/app/code/Magento/Catalog/Model/Template/Filter.php index 05ca3162467..912bea2a7bd 100644 --- a/app/code/Magento/Catalog/Model/Template/Filter.php +++ b/app/code/Magento/Catalog/Model/Template/Filter.php @@ -55,19 +55,19 @@ class Filter extends \Magento\Framework\Filter\Template /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Stdlib\String $string - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param array $variables */ public function __construct( \Magento\Framework\Stdlib\String $string, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo, $variables = array() ) { diff --git a/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php b/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php index 76f6fb52b32..ecbb191b2d9 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/Tree/ReadService.php @@ -36,7 +36,7 @@ class ReadService implements ReadServiceInterface protected $categoryFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -48,12 +48,12 @@ class ReadService implements ReadServiceInterface /** * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Service\V1\Data\Category\Tree $categoryTree - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Service\V1\Data\Category\Tree $categoryTree, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->categoryFactory = $categoryFactory; $this->categoryTree = $categoryTree; diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php index 8e0a607ff18..e2725bf8209 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php @@ -31,7 +31,7 @@ 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; +use Magento\Framework\StoreManagerInterface; class WriteService implements WriteServiceInterface { @@ -46,7 +46,7 @@ class WriteService implements WriteServiceInterface private $categoryMapper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -60,7 +60,7 @@ class WriteService implements WriteServiceInterface /** * @param CategoryFactory $categoryFactory * @param CategoryMapper $categoryMapper - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( CategoryFactory $categoryFactory, 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 e0eb7642466..f4d2d7bc6c1 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php @@ -36,7 +36,7 @@ class Tree protected $categoryTree; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,13 +52,13 @@ class Tree /** * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTree - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category\Collection $categoryCollection * @param \Magento\Catalog\Service\V1\Data\Eav\Category\TreeBuilderFactory $treeBuilderFactory */ public function __construct( \Magento\Catalog\Model\Resource\Category\Tree $categoryTree, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category\Collection $categoryCollection, \Magento\Catalog\Service\V1\Data\Eav\Category\TreeBuilderFactory $treeBuilderFactory ) { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Converter.php b/app/code/Magento/Catalog/Service/V1/Data/Converter.php index 4059993b865..1ecf2cc1c6f 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Converter.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Converter.php @@ -52,9 +52,20 @@ class Converter * @return \Magento\Catalog\Service\V1\Data\Product */ public function createProductDataFromModel(\Magento\Catalog\Model\Product $productModel) + { + return $this->createProductBuilderFromModel($productModel)->create(); + } + + /** + * Initialize product builder with product model data + * + * @param \Magento\Catalog\Model\Product $productModel + * @return \Magento\Catalog\Service\V1\Data\ProductBuilder + */ + public function createProductBuilderFromModel(\Magento\Catalog\Model\Product $productModel) { $this->populateBuilderWithAttributes($productModel); - return $this->productBuilder->create(); + return $this->productBuilder; } /** diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php index 6cf6786fb58..77d992841d0 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductMapper.php @@ -48,16 +48,18 @@ class ProductMapper /** * @param Product $product * @param \Magento\Catalog\Model\Product $productModel + * @param string[] $customAttributesToSkip * @return \Magento\Catalog\Model\Product * @throws \RuntimeException */ public function toModel( Product $product, - \Magento\Catalog\Model\Product $productModel = null + \Magento\Catalog\Model\Product $productModel = null, + $customAttributesToSkip = array() ) { /** @var \Magento\Catalog\Model\Product $productModel */ $productModel = $productModel ? : $this->productFactory->create(); - $productModel->addData(ExtensibleDataObjectConverter::toFlatArray($product)); + $productModel->addData(ExtensibleDataObjectConverter::toFlatArray($product, $customAttributesToSkip)); if (!is_numeric($productModel->getAttributeSetId())) { $productModel->setAttributeSetId($productModel->getDefaultAttributeSetId()); } diff --git a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php index 22794baae06..c6621813a62 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadService.php @@ -76,7 +76,7 @@ class ReadService implements ReadServiceInterface protected $attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -86,7 +86,7 @@ class ReadService implements ReadServiceInterface * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaGallery * @param \Magento\Catalog\Model\Resource\Eav\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param MediaImageBuilder $mediaImageBuilder * @param \Magento\Catalog\Model\ProductRepository $productRepository * @param GalleryEntryBuilder $galleryEntryBuilder @@ -97,7 +97,7 @@ class ReadService implements ReadServiceInterface \Magento\Eav\Model\Config $eavConfig, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaGallery, \Magento\Catalog\Model\Resource\Eav\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, MediaImageBuilder $mediaImageBuilder, \Magento\Catalog\Model\ProductRepository $productRepository, GalleryEntryBuilder $galleryEntryBuilder diff --git a/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php b/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php index 41729855bc5..e8bb6563cfa 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/GroupPriceService.php @@ -43,7 +43,7 @@ class GroupPriceService implements GroupPriceServiceInterface protected $groupPriceBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -65,7 +65,7 @@ class GroupPriceService implements GroupPriceServiceInterface /** * @param ProductRepository $productRepository * @param Product\GroupPriceBuilder $groupPriceBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Catalog\Model\Product\PriceModifier $priceModifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $config @@ -73,7 +73,7 @@ class GroupPriceService implements GroupPriceServiceInterface public function __construct( ProductRepository $productRepository, Product\GroupPriceBuilder $groupPriceBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService, \Magento\Catalog\Model\Product\PriceModifier $priceModifier, \Magento\Framework\App\Config\ScopeConfigInterface $config diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.php new file mode 100644 index 00000000000..61718d1dd34 --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorComposite.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\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite loader of product data. + * + * Allows multiple loaders to be registered and used during product data loading. + */ +class ProductLoadProcessorComposite implements ProductLoadProcessorInterface +{ + /** + * @var ProductLoadProcessorInterface[] + */ + protected $productLoadProcessors = []; + + /** + * Register product load processors. + * + * @param CompositeHelper $compositeHelper + * @param array $loadProcessors Array of the processors which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstProcessorObject, 'sortOrder' => 15], + * ['type' => $secondProcessorObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + */ + public function __construct(CompositeHelper $compositeHelper, $loadProcessors = []) + { + $loadProcessors = $compositeHelper->filterAndSortDeclaredComponents($loadProcessors); + foreach ($loadProcessors as $loadProcessor) { + $this->productLoadProcessors[] = $loadProcessor['type']; + } + } + + /** + * {@inheritdoc} + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder) + { + foreach ($this->productLoadProcessors as $loadProcessor) { + $loadProcessor->load($id, $productBuilder); + } + } +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php new file mode 100644 index 00000000000..4cb4570f260 --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductLoadProcessorInterface.php @@ -0,0 +1,41 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +/** + * Interface for product data loading. + */ +interface ProductLoadProcessorInterface +{ + /** + * Load product data to the builder, which can be used to instantiate product object. + * + * @param string $id + * @param \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder + * @return void + */ + public function load($id, \Magento\Catalog\Service\V1\Data\ProductBuilder $productBuilder); +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php new file mode 100644 index 00000000000..ae87690b07d --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorComposite.php @@ -0,0 +1,109 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +/** + * Composite pattern implementation for ProductSaveProcessorInterface. + * + * Allows multiple savers to be registered and used for product data modification. + */ +class ProductSaveProcessorComposite implements ProductSaveProcessorInterface +{ + /** + * @var ProductSaveProcessorInterface[] + */ + protected $productSaveProcessors = []; + + /** + * Register product save processors. + * + * @param CompositeHelper $compositeHelper + * @param array $saveProcessors Array of the processors which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstProcessorObject, 'sortOrder' => 15], + * ['type' => $secondProcessorObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + */ + public function __construct(CompositeHelper $compositeHelper, $saveProcessors = []) + { + $saveProcessors = $compositeHelper->filterAndSortDeclaredComponents($saveProcessors); + foreach ($saveProcessors as $saveProcessor) { + $this->productSaveProcessors[] = $saveProcessor['type']; + } + } + + /** + * {@inheritdoc} + */ + public function create( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ) { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->create($product, $productData); + } + return $productData->getSku(); + } + + /** + * {@inheritdoc} + */ + public function afterCreate( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ) { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->afterCreate($product, $productData); + } + return $productData->getSku(); + } + + /** + * {@inheritdoc} + */ + public function update($id, \Magento\Catalog\Service\V1\Data\Product $product) + { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->update($id, $product); + } + return $product->getSku(); + } + + /** + * {@inheritdoc} + */ + public function delete(\Magento\Catalog\Service\V1\Data\Product $product) + { + foreach ($this->productSaveProcessors as $saveProcessor) { + $saveProcessor->delete($product); + } + } +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.php new file mode 100644 index 00000000000..48921dfd7ad --- /dev/null +++ b/app/code/Magento/Catalog/Service/V1/Product/ProductSaveProcessorInterface.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\Catalog\Service\V1\Product; + +/** + * Interface for product data modification. + */ +interface ProductSaveProcessorInterface +{ + /** + * Create product. + * + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Service\V1\Data\Product $productData + * @return string id + */ + public function create( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ); + + /** + * Create product after the initial creation is complete. + * + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Service\V1\Data\Product $productData + * @return string id + */ + public function afterCreate( + \Magento\Catalog\Model\Product $product, + \Magento\Catalog\Service\V1\Data\Product $productData + ); + + /** + * Update product. + * + * @param string $sku + * @param \Magento\Catalog\Service\V1\Data\Product $product + * @return string id + */ + public function update($sku, \Magento\Catalog\Service\V1\Data\Product $product); + + /** + * Delete product. + * + * @param \Magento\Catalog\Service\V1\Data\Product $product + * @return void + */ + public function delete(\Magento\Catalog\Service\V1\Data\Product $product); +} diff --git a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php index e50690efc28..e00443d1f8a 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php +++ b/app/code/Magento/Catalog/Service/V1/Product/TierPriceService.php @@ -42,7 +42,7 @@ class TierPriceService implements TierPriceServiceInterface protected $priceBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -64,7 +64,7 @@ class TierPriceService implements TierPriceServiceInterface /** * @param ProductRepository $productRepository * @param Product\TierPriceBuilder $priceBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\PriceModifier $priceModifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService @@ -72,7 +72,7 @@ class TierPriceService implements TierPriceServiceInterface public function __construct( ProductRepository $productRepository, Product\TierPriceBuilder $priceBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\PriceModifier $priceModifier, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService diff --git a/app/code/Magento/Catalog/Service/V1/ProductService.php b/app/code/Magento/Catalog/Service/V1/ProductService.php index 9bb1d4d6d29..839ca2fc589 100644 --- a/app/code/Magento/Catalog/Service/V1/ProductService.php +++ b/app/code/Magento/Catalog/Service/V1/ProductService.php @@ -79,6 +79,16 @@ class ProductService implements ProductServiceInterface */ private $searchResultsBuilder; + /** + * @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface + */ + private $productLoadProcessor; + + /** + * @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface + */ + private $productSaveProcessor; + /** * @param Product\Initialization\Helper $initializationHelper * @param Data\ProductMapper $productMapper @@ -88,6 +98,10 @@ class ProductService implements ProductServiceInterface * @param ProductMetadataServiceInterface $metadataService * @param \Magento\Catalog\Service\V1\Data\Converter $converter * @param \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder + * @param \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface $productLoadProcessor + * @param \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface $productSaveProcessor + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( Product\Initialization\Helper $initializationHelper, @@ -97,7 +111,9 @@ class ProductService implements ProductServiceInterface \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollection, ProductMetadataServiceInterface $metadataService, \Magento\Catalog\Service\V1\Data\Converter $converter, - \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder + \Magento\Catalog\Service\V1\Data\Product\SearchResultsBuilder $searchResultsBuilder, + \Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface $productLoadProcessor, + \Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface $productSaveProcessor ) { $this->initializationHelper = $initializationHelper; $this->productMapper = $productMapper; @@ -107,6 +123,8 @@ class ProductService implements ProductServiceInterface $this->metadataService = $metadataService; $this->converter = $converter; $this->searchResultsBuilder = $searchResultsBuilder; + $this->productLoadProcessor = $productLoadProcessor; + $this->productSaveProcessor = $productSaveProcessor; } /** @@ -115,10 +133,12 @@ class ProductService implements ProductServiceInterface public function create(\Magento\Catalog\Service\V1\Data\Product $product) { try { - $productModel = $this->productMapper->toModel($product); + $productModel = $this->productMapper->toModel($product, null, ['bundle_product_options']); $this->initializationHelper->initialize($productModel); + $this->productSaveProcessor->create($productModel, $product); $productModel->validate(); $productModel->save(); + $this->productSaveProcessor->afterCreate($productModel, $product); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { throw \Magento\Framework\Exception\InputException::invalidFieldValue( $exception->getAttributeCode(), @@ -139,9 +159,10 @@ class ProductService implements ProductServiceInterface { $productModel = $this->productLoader->load($id); try { - $this->productMapper->toModel($product, $productModel); + $this->productMapper->toModel($product, $productModel, ['bundle_product_options']); $this->initializationHelper->initialize($productModel); $this->productTypeManager->processProduct($productModel); + $this->productSaveProcessor->update($id, $product); $productModel->validate(); $productModel->save(); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { @@ -159,8 +180,12 @@ class ProductService implements ProductServiceInterface */ public function delete($id) { - $product = $this->productLoader->load($id); - $product->delete(); + $productModel = $this->productLoader->load($id); + + $productDataObject = $this->converter->createProductDataFromModel($productModel); + $this->productSaveProcessor->delete($productDataObject); + + $productModel->delete(); return true; } @@ -169,7 +194,9 @@ class ProductService implements ProductServiceInterface */ public function get($id) { - return $this->converter->createProductDataFromModel($this->productLoader->load($id)); + $productBuilder = $this->converter->createProductBuilderFromModel($this->productLoader->load($id)); + $this->productLoadProcessor->load($id, $productBuilder); + return $productBuilder->create(); } /** @@ -221,7 +248,9 @@ class ProductService implements ProductServiceInterface $products = array(); /** @var \Magento\Catalog\Model\Product $productModel */ foreach ($collection as $productModel) { - $products[] = $this->converter->createProductDataFromModel($productModel); + $productBuilder = $this->converter->createProductBuilderFromModel($productModel); + $this->productLoadProcessor->load($productModel->getSku(), $productBuilder); + $products[] = $productBuilder->create(); } $this->searchResultsBuilder->setItems($products); diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index f3ce62d8d40..f655a3900de 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -3,33 +3,33 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-search": "0.1.0-alpha94", - "magento/module-product-alert": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-log": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-search": "0.1.0-alpha95", + "magento/module-product-alert": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index e0ffc5299d7..b838bdd88f2 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -30,11 +30,6 @@ <argument name="attributeLabelCache" xsi:type="object">Magento\Framework\App\Cache\Type\Translate</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Catalog\Block\Adminhtml\Product\Frontend\Product\Watermark"> <arguments> <argument name="imageTypes" xsi:type="array"> diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 6cea44bd685..a0f16e2eef3 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -66,6 +66,8 @@ <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ReaderInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\Reader" /> <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\WriteServiceInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\WriteService" /> <preference for="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\ConverterInterface" type="Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option\Metadata\Converter\Composite" /> + <preference for="Magento\Catalog\Service\V1\Product\ProductSaveProcessorInterface" type="Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite" /> + <preference for="Magento\Catalog\Service\V1\Product\ProductLoadProcessorInterface" type="Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite" /> <type name="Magento\Log\Model\Resource\Log"> <plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" /> </type> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index 51914835414..9665dcee2ad 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -24,11 +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\Catalog\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Catalog\Model\Resource\Category\Collection"> <arguments> <argument name="fetchStrategy" xsi:type="object">Magento\Framework\Data\Collection\Db\FetchStrategy\Cache</argument> diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 10f60a27f71..6c9bf078c50 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -218,7 +218,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\Catalog\Model\Resource\Product\Collection $collection * @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig @@ -236,7 +236,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\Catalog\Model\Resource\Product\Collection $collection, \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig, diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 2bc539809f5..7bef8186538 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -430,7 +430,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $_productFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -507,7 +507,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryColFactory * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory * @param \Magento\Catalog\Model\Resource\Product\LinkFactory $linkFactory * @param \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory @@ -538,7 +538,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryColFactory, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory, \Magento\Catalog\Model\Resource\Product\LinkFactory $linkFactory, \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory, diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index 168dbb9978a..9c9a1c154a9 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -292,7 +292,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $_resource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -320,7 +320,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\ImportExport\Model\Resource\Import\Data $importData * @param \Magento\Framework\App\Resource $resource * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper - * @param \Magento\Store\Model\StoreManagerInterface $_storeManager + * @param \Magento\Framework\StoreManagerInterface $_storeManager * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $colIteratorFactory @@ -335,7 +335,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\ImportExport\Model\Resource\Import\Data $importData, \Magento\Framework\App\Resource $resource, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, - \Magento\Store\Model\StoreManagerInterface $_storeManager, + \Magento\Framework\StoreManagerInterface $_storeManager, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $colIteratorFactory, diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 6a9713aa174..9715aa6300f 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php index 28607fe7f04..78aabdd765e 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php @@ -32,7 +32,7 @@ use Magento\CatalogInventory\Model\Stock; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -41,7 +41,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -50,7 +50,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php index e6db107f1ef..dad09e3d5e9 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php @@ -33,7 +33,7 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -51,13 +51,13 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Config $eavConfig ) { diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index dc0245c8945..436680533d2 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -61,7 +61,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -88,7 +88,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel * @param Resource\Stock\Item\CollectionFactory $collectionFactory * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService * @param Stock\Status $stockStatus - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Stock\ItemFactory $stockItemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -101,7 +101,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel \Magento\CatalogInventory\Model\Resource\Stock\Item\CollectionFactory $collectionFactory, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\CatalogInventory\Model\Stock\Status $stockStatus, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 14b744233ac..9653a6e97cb 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -203,7 +203,7 @@ class Item extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -252,7 +252,7 @@ class Item extends \Magento\Framework\Model\AbstractModel * @param ItemRegistry $stockItemRegistry * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Framework\Math\Division $mathDivision * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -271,7 +271,7 @@ class Item extends \Magento\Framework\Model\AbstractModel \Magento\CatalogInventory\Model\Stock\ItemRegistry $stockItemRegistry, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Framework\Math\Division $mathDivision, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Stock/Status.php index 69b4fd7e0bc..91ea17cbb78 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Status.php @@ -81,7 +81,7 @@ class Status extends \Magento\Framework\Model\AbstractModel /** * Store model manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Status extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param Type $productType * @param \Magento\Catalog\Model\Product\Website $productWebsite - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ItemFactory $stockItemFactory * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -109,7 +109,7 @@ class Status extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, Type $productType, \Magento\Catalog\Model\Product\Website $productWebsite, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, ItemFactory $stockItemFactory, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index e621d13a2c8..ad583e88628 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml b/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml index 3fd2fa2ab2f..a4cee45cfb0 100644 --- a/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml +++ b/app/code/Magento/CatalogInventory/etc/adminhtml/system.xml @@ -35,7 +35,7 @@ <label>Decrease Stock When Order is Placed</label> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> </field> - <field id="can_back_in_stock" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <field id="can_back_in_stock" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Set Items' Status to be In Stock When Order is Cancelled</label> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> </field> diff --git a/app/code/Magento/CatalogRule/Model/Observer.php b/app/code/Magento/CatalogRule/Model/Observer.php index cf3ae576811..57eb2b22bc2 100644 --- a/app/code/Magento/CatalogRule/Model/Observer.php +++ b/app/code/Magento/CatalogRule/Model/Observer.php @@ -35,7 +35,7 @@ use Magento\CatalogRule\Model\Rule; use Magento\CatalogRule\Model\Resource\Rule\Collection; use Magento\CatalogRule\Model\Rule\Product\Price; use Magento\Framework\Registry; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Customer\Service\V1\CustomerGroupServiceInterface as Group; use Magento\Customer\Model\Session as CustomerModelSession; diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 182beb86d10..1b4315961fe 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -95,7 +95,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource protected $_conditionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -106,7 +106,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Eav\Model\Config $eavConfig @@ -117,7 +117,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Eav\Model\Config $eavConfig, diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 952c709389a..21290013144 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -150,7 +150,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel protected $_productFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -170,7 +170,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory * @param \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -191,7 +191,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory, \Magento\CatalogRule\Model\Rule\Action\CollectionFactory $actionCollectionFactory, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 991455bb723..0d81e595a26 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-rule": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-rule": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/Controller/Result/Index.php b/app/code/Magento/CatalogSearch/Controller/Result/Index.php index dcbe1c4d53d..dcfcd4c9374 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Result/Index.php @@ -26,7 +26,7 @@ namespace Magento\CatalogSearch\Controller\Result; use Magento\Framework\App\Action\Context; use Magento\Catalog\Model\Session; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class Index extends \Magento\Framework\App\Action\Action { diff --git a/app/code/Magento/CatalogSearch/Helper/Data.php b/app/code/Magento/CatalogSearch/Helper/Data.php index 6e6d5317aaf..fda9eb9af5b 100644 --- a/app/code/Magento/CatalogSearch/Helper/Data.php +++ b/app/code/Magento/CatalogSearch/Helper/Data.php @@ -34,7 +34,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Escaper; use Magento\Framework\Filter\FilterManager; use Magento\Framework\Stdlib\String; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Catalog search helper @@ -123,7 +123,7 @@ class Data extends AbstractHelper protected $filter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 13858842888..98f994a5ba2 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -34,7 +34,7 @@ use Magento\CatalogSearch\Model\Resource\EngineProvider; use Magento\Framework\Model\Exception; use Magento\Framework\Model\Context; use Magento\Framework\Registry; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Directory\Model\Currency; use Magento\Directory\Model\CurrencyFactory; use Magento\Eav\Model\Entity\Attribute as EntityAttribute; @@ -109,7 +109,7 @@ class Advanced extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Advanced extends \Magento\Framework\Model\AbstractModel * @param EngineProvider $engineProvider * @param CurrencyFactory $currencyFactory * @param ProductFactory $productFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index f3e0932fd33..7ae849cf2a8 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -110,7 +110,7 @@ class Full /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -154,7 +154,7 @@ class Full * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -170,7 +170,7 @@ class Full \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogSearch\Helper\Data $catalogSearchData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php index 831dbe38d7e..4914e56049d 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced.php @@ -37,7 +37,7 @@ class Advanced extends \Magento\Catalog\Model\Layer * @param CategoryFactory $categoryFactory * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param Resource\Product $catalogProduct - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -47,7 +47,7 @@ class Advanced extends \Magento\Catalog\Model\Layer CategoryFactory $categoryFactory, Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, Resource\Product $catalogProduct, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php index b0d7f3173ae..c5c486b14f4 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/CollectionFilter.php @@ -39,7 +39,7 @@ class CollectionFilter implements CollectionFilterInterface protected $helper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -51,14 +51,14 @@ class CollectionFilter implements CollectionFilterInterface /** * @param \Magento\Catalog\Model\Config $catalogConfig * @param \Magento\CatalogSearch\Helper\Data $helper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Framework\Registry $registry */ public function __construct( \Magento\Catalog\Model\Config $catalogConfig, \Magento\CatalogSearch\Helper\Data $helper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Framework\Registry $registry ) { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php index d851bc4ba1e..15f42e129d6 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Advanced/FilterableAttributeList.php @@ -29,12 +29,12 @@ class FilterableAttributeList extends \Magento\Catalog\Model\Layer\Category\Filt { /** * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Layer\Advanced $layer */ public function __construct( \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Layer\Advanced $layer ) { parent::__construct($collectionFactory, $storeManager, $layer); diff --git a/app/code/Magento/CatalogSearch/Model/Query.php b/app/code/Magento/CatalogSearch/Model/Query.php index 59057d2f9bd..cdd362fcf72 100644 --- a/app/code/Magento/CatalogSearch/Model/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Query.php @@ -32,7 +32,7 @@ use Magento\Framework\Model\Context; use Magento\Framework\Registry; use Magento\Framework\Model\Resource\AbstractResource; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Data\Collection\Db; use Magento\Eav\Model\Entity\Collection\AbstractCollection; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php index 65efb780d62..007cebc8321 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php @@ -40,7 +40,7 @@ class Advanced extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,12 +48,12 @@ class Advanced extends \Magento\Framework\Model\Resource\Db\AbstractDb * Construct * * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Event\ManagerInterface $eventManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Event\ManagerInterface $eventManager ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index 4763a0154ce..e587c54cb60 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -49,7 +49,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -73,7 +73,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php index c7302a4e406..d1d13e63868 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -54,7 +54,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -79,7 +79,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php index 7703c22e41f..0922a799c35 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php @@ -42,7 +42,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -58,7 +58,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -68,7 +68,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php index d27a819b8db..3644db6635e 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php @@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -85,7 +85,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index fae48f2b90e..78c0be37f47 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml index cd88f320eef..3e337de8a9b 100644 --- a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\CatalogSearch\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\CatalogSearch\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> </config> diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index 6b995a09fc7..8f314df6174 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -61,4 +61,15 @@ <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> </arguments> </type> + <type name="Magento\Framework\Search\EntityMetadata" /> + <virtualType name="Magento\Framework\Search\ProductEntityMetadata" type="Magento\Framework\Search\EntityMetadata"> + <arguments> + <argument name="entityId" xsi:type="string">product_id</argument> + </arguments> + </virtualType> + <type name="Magento\Framework\Search\Adapter\Mysql\DocumentFactory"> + <arguments> + <argument name="entityId" xsi:type="object">Magento\Framework\Search\ProductEntityMetadata</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/CatalogSearch/etc/frontend/di.xml b/app/code/Magento/CatalogSearch/etc/frontend/di.xml index f69a0086554..408654dcd25 100644 --- a/app/code/Magento/CatalogSearch/etc/frontend/di.xml +++ b/app/code/Magento/CatalogSearch/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\CatalogSearch\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\CatalogSearch\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <virtualType name="Magento\CatalogSearch\Block\SearchResult\ListProduct" type="Magento\Catalog\Block\Product\ListProduct"> diff --git a/app/code/Magento/CatalogSearch/etc/search_request.xml b/app/code/Magento/CatalogSearch/etc/search_request.xml new file mode 100644 index 00000000000..f1c6ef3c362 --- /dev/null +++ b/app/code/Magento/CatalogSearch/etc/search_request.xml @@ -0,0 +1,84 @@ +<?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" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd"> + <request query="quick_search_container" index="product"> + <dimensions> + <dimension name="scope" value="%scope_placeholder%" /> + </dimensions> + <queries> + <query xsi:type="matchQuery" name="quick_search_container"> + <match field="name" value="$search_term" boost="1" /> + <match field="sku" value="$search_term" boost="1" /> + <match field="description" value="$search_term" boost="1" /> + <match field="short_description" value="$search_term" boost="1" /> + <match field="price" value="$search_term" boost="1" /> + <match field="tax_class" value="$search_term" boost="1" /> + </query> + </queries> + <from>10</from> + <size>10</size> + </request> + <request query="advanced_search_container" index="product"> + <dimensions> + <dimension name="scope" value="%scope_placeholder%" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="advanced_search_container" boost="1"> + <queryReference clause="should" ref="name_query" /> + <queryReference clause="should" ref="sku_query" /> + <queryReference clause="should" ref="description_query" /> + <queryReference clause="should" ref="short_description_query" /> + <queryReference clause="should" ref="price_query" /> + <queryReference clause="should" ref="tax_class_query" /> + </query> + <query xsi:type="matchQuery" name="name_query"> + <match field="name" value="$name" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="sku_query"> + <filterReference ref="sku_query_filter" /> + </query> + <query xsi:type="matchQuery" name="description_query"> + <match field="description" value="$description" boost="1" /> + </query> + <query xsi:type="matchQuery" name="short_description_query"> + <match field="short_description" value="$short_description" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="price_query"> + <filterReference ref="price_query_filter" /> + </query> + <query xsi:type="filteredQuery" name="tax_class_query"> + <filterReference ref="tax_class_query_filter" /> + </query> + </queries> + <filters> + <filter xsi:type="termFilter" name="sku_query_filter" field="sku" value="$sku" /> + <filter xsi:type="rangeFilter" name="price_query_filter" field="price" from="$price_from" to="$price_to" /> + <filter xsi:type="termFilter" name="tax_class_query_filter" field="tax_class" value="$tax_class" /> + </filters> + <from>10</from> + <size>10</size> + </request> +</requests> diff --git a/app/code/Magento/CatalogUrlRewrite/Helper/Data.php b/app/code/Magento/CatalogUrlRewrite/Helper/Data.php index 74ab3e84de1..098a731a8aa 100644 --- a/app/code/Magento/CatalogUrlRewrite/Helper/Data.php +++ b/app/code/Magento/CatalogUrlRewrite/Helper/Data.php @@ -30,7 +30,7 @@ use Magento\Catalog\Model\Product; use Magento\Eav\Model\Config; use Magento\Framework\App\Resource; use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\UrlRewrite; @@ -62,7 +62,7 @@ class Data /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php index 3a6925dee2e..73abbe199dd 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/AbstractUrlGenerator.php @@ -25,7 +25,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\Catalog\Model\ProductFactory; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php index cbb770f46f0..31d86734e46 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/CategoryUrlGenerator.php @@ -24,7 +24,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; use Magento\UrlRedirect\Service\V1\UrlMatcherInterface; @@ -48,7 +48,7 @@ class CategoryUrlGenerator implements CategoryUrlGeneratorInterface /** * Store manager * - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -74,7 +74,7 @@ class CategoryUrlGenerator implements CategoryUrlGeneratorInterface /** * @param FilterFactory $filterFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param UrlMatcherInterface $urlMatcher * @param CatalogUrlRewriteHelper $catalogUrlRewriteHelper */ diff --git a/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php b/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php index a6991bc1c0f..a41fd154e90 100644 --- a/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Service/V1/ProductUrlGenerator.php @@ -24,7 +24,7 @@ namespace Magento\CatalogUrlRewrite\Service\V1; use Magento\CatalogUrlRewrite\Helper\Data as CatalogUrlRewriteHelper; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Model\OptionProvider; use Magento\UrlRedirect\Service\V1\Data\FilterFactory; use Magento\UrlRedirect\Service\V1\UrlMatcherInterface; diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 77746445869..ddac1507065 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-url-redirect": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-url-redirect": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index a4f821efb86..36619e8fb2c 100644 --- a/app/code/Magento/Centinel/composer.json +++ b/app/code/Magento/Centinel/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/etc/adminhtml/di.xml b/app/code/Magento/Centinel/etc/adminhtml/di.xml index 49b1b498421..9afea19d704 100644 --- a/app/code/Magento/Centinel/etc/adminhtml/di.xml +++ b/app/code/Magento/Centinel/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Centinel\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Centinel\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <type name="Magento\Centinel\Model\Service"> diff --git a/app/code/Magento/Centinel/etc/frontend/di.xml b/app/code/Magento/Centinel/etc/frontend/di.xml index d7a868b509b..85c5c74c54d 100644 --- a/app/code/Magento/Centinel/etc/frontend/di.xml +++ b/app/code/Magento/Centinel/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Centinel\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Centinel\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <type name="Magento\Core\Model\Url\SecurityInfo"> diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index 865c4478acc..b825d6d2687 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -42,7 +42,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface protected $_checkoutSession; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param CustomerCart $cart */ @@ -68,7 +68,7 @@ class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface \Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, CustomerCart $cart ) { diff --git a/app/code/Magento/Checkout/Controller/Cart/Add.php b/app/code/Magento/Checkout/Controller/Cart/Add.php index b6cc05214d1..3a5faa119eb 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Add.php +++ b/app/code/Magento/Checkout/Controller/Cart/Add.php @@ -35,7 +35,7 @@ class Add extends \Magento\Checkout\Controller\Cart { $productId = (int)$this->getRequest()->getParam('product'); if ($productId) { - $storeId = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + $storeId = $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); $product = $this->_objectManager->create( 'Magento\Catalog\Model\Product' )->setStoreId( diff --git a/app/code/Magento/Checkout/Controller/Cart/Index.php b/app/code/Magento/Checkout/Controller/Cart/Index.php index 10e0e0d11ce..4f7b5e439c0 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Index.php +++ b/app/code/Magento/Checkout/Controller/Cart/Index.php @@ -39,7 +39,7 @@ class Index extends \Magento\Checkout\Controller\Cart if (!$this->cart->getQuote()->validateMinimumAmount()) { $currencyCode = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getCurrentCurrencyCode(); $minimumAmount = $this->_objectManager->get( 'Magento\Framework\Locale\CurrencyInterface' diff --git a/app/code/Magento/Checkout/Controller/Onepage/Index.php b/app/code/Magento/Checkout/Controller/Onepage/Index.php index a9e34d5ef0b..d83225b5114 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/Index.php +++ b/app/code/Magento/Checkout/Controller/Onepage/Index.php @@ -44,6 +44,7 @@ class Index extends \Magento\Checkout\Controller\Onepage return; } + $this->_customerSession->regenerateId(); $this->_objectManager->get('Magento\Checkout\Model\Session')->setCartWasUpdated(false); $currentUrl = $this->_objectManager->create('Magento\Framework\UrlInterface') ->getUrl( diff --git a/app/code/Magento/Checkout/Helper/Cart.php b/app/code/Magento/Checkout/Helper/Cart.php index e1137ecb826..98295d3060a 100644 --- a/app/code/Magento/Checkout/Helper/Cart.php +++ b/app/code/Magento/Checkout/Helper/Cart.php @@ -71,7 +71,7 @@ class Cart extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Checkout\Model\Cart $checkoutCart @@ -79,7 +79,7 @@ class Cart extends \Magento\Core\Helper\Url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Cart $checkoutCart, diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index e1733995be2..ed2b7264a87 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -45,7 +45,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -72,7 +72,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder @@ -81,7 +81,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index 5b9813aa09c..a3760e04ced 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -59,7 +59,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -97,7 +97,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Resource\Cart $resourceCart * @param Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -109,7 +109,7 @@ class Cart extends \Magento\Framework\Object implements \Magento\Checkout\Model\ \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Model\Resource\Cart $resourceCart, Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index e217ec2ef69..07ed03d5505 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -88,7 +88,7 @@ class Session extends \Magento\Framework\Session\SessionManager protected $_eventManager; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -106,7 +106,7 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param null $sessionName */ public function __construct( @@ -123,8 +123,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, - $sessionName = null + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_orderFactory = $orderFactory; $this->_customerSession = $customerSession; @@ -142,7 +141,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } /** diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 327dfe6f02f..6c353ca06c6 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -87,7 +87,7 @@ class Onepage protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -161,7 +161,7 @@ class Onepage * @param \Magento\Framework\Logger $logger * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Customer\Model\AddressFactory $customrAddrFactory * @param \Magento\Customer\Model\FormFactory $customerFormFactory @@ -186,7 +186,7 @@ class Onepage \Magento\Framework\Logger $logger, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Customer\Model\AddressFactory $customrAddrFactory, \Magento\Customer\Model\FormFactory $customerFormFactory, diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php index 8c2fa58e98b..503da90a8b1 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/ReadService.php @@ -39,19 +39,19 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param AddressConverter $addressConverter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, AddressConverter $addressConverter, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->addressConverter = $addressConverter; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php index c94d3dc4b18..a965c7067ea 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Billing/WriteService.php @@ -28,7 +28,7 @@ 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\Framework\StoreManagerInterface; use \Magento\Checkout\Service\V1\Address\Converter; use \Magento\Checkout\Service\V1\Address\Validator; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Converter.php b/app/code/Magento/Checkout/Service/V1/Address/Converter.php index 17b70ef827d..b282663988b 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Converter.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Converter.php @@ -85,7 +85,7 @@ class Converter foreach ($this->metadataService->getCustomAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $method = 'get' . SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $data[Address::CUSTOM_ATTRIBUTES_KEY][] = [AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $address->$method()]; } diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php index 4c3e9289a48..ee81610db56 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/ReadService.php @@ -40,19 +40,19 @@ class ReadService implements ReadServiceInterface protected $addressConverter; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param AddressConverter $addressConverter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, AddressConverter $addressConverter, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->addressConverter = $addressConverter; diff --git a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php index 96276b6fd7b..abf6cae32c9 100644 --- a/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Address/Shipping/WriteService.php @@ -36,7 +36,7 @@ class WriteService implements WriteServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -62,7 +62,7 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\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 @@ -70,7 +70,7 @@ class WriteService implements WriteServiceInterface */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Service\V1\Address\Converter $addressConverter, \Magento\Checkout\Service\V1\Address\Validator $addressValidator, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, diff --git a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php index 9ea16bab045..fed2d2b7b45 100644 --- a/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Cart/WriteService.php @@ -36,7 +36,7 @@ class WriteService implements WriteServiceInterface protected $quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -47,12 +47,12 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Sales\Model\QuoteFactory $quoteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry */ public function __construct( \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\CustomerRegistry $customerRegistry ) { $this->quoteFactory = $quoteFactory; diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php index de967a49e0b..948871502fc 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/ReadService.php @@ -42,19 +42,19 @@ class ReadService implements ReadServiceInterface protected $couponBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param CouponBuilder $couponBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, CouponBuilder $couponBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->couponBuilder = $couponBuilder; diff --git a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php index 5fef831aadb..33dbe23e250 100644 --- a/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/Coupon/WriteService.php @@ -44,19 +44,19 @@ class WriteService implements WriteServiceInterface protected $couponBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader * @param CouponBuilder $couponBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, CouponBuilder $couponBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteLoader = $quoteLoader; $this->couponBuilder = $couponBuilder; diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php index 584ba7c8eab..adeadd88a3f 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverter.php @@ -37,11 +37,11 @@ class ShippingMethodConverter /** * @param ShippingMethodBuilder $builder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $builder, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->builder = $builder; $this->storeManager = $storeManager; diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php index 9a7939c8733..dfc0d2c0086 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/ReadService.php @@ -25,7 +25,7 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; use \Magento\Checkout\Service\V1\QuoteLoader; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter as QuoteMethodConverter; use Magento\Checkout\Service\V1\Data\PaymentMethod\Converter as PaymentMethodConverter; use \Magento\Payment\Model\MethodList; diff --git a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php index bdc62911779..b162bce65ef 100644 --- a/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/PaymentMethod/WriteService.php @@ -25,7 +25,7 @@ namespace Magento\Checkout\Service\V1\PaymentMethod; use \Magento\Checkout\Service\V1\QuoteLoader; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder; use \Magento\Framework\Exception\State\InvalidTransitionException; use \Magento\Payment\Model\MethodList; @@ -33,7 +33,7 @@ use \Magento\Payment\Model\MethodList; class WriteService implements WriteServiceInterface { /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -54,7 +54,7 @@ class WriteService implements WriteServiceInterface /** * @param QuoteLoader $quoteLoader - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Builder $paymentMethodBuilder * @param \Magento\Payment\Model\Checks\ZeroTotal $zeroTotalValidator */ diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php index 267aab7debd..370d45b8462 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/ReadService.php @@ -37,7 +37,7 @@ class ReadService implements ReadServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -53,13 +53,13 @@ class ReadService implements ReadServiceInterface /** * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter * @param ShippingMethodBuilder $methodBuilder */ public function __construct( \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodConverter $converter, \Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder $methodBuilder ) { diff --git a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php index 1d648df3b07..91069b36753 100644 --- a/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php +++ b/app/code/Magento/Checkout/Service/V1/ShippingMethod/WriteService.php @@ -41,17 +41,17 @@ class WriteService implements WriteServiceInterface protected $quoteLoader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory * @param \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Quote\AddressFactory $addressFactory, \Magento\Checkout\Service\V1\QuoteLoader $quoteLoader ) { diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index eaf6d3af723..36015c01be5 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index d59e3e04eeb..300d93907ef 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -24,11 +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\Checkout\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php b/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php index 5df05f6675f..2d24fe98aa5 100644 --- a/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php +++ b/app/code/Magento/CheckoutAgreements/Model/AgreementsProvider.php @@ -40,17 +40,17 @@ class AgreementsProvider implements AgreementsProviderInterface /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $scopeConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param Resource\Agreement\CollectionFactory $agreementCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->agreementCollectionFactory = $agreementCollectionFactory; diff --git a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php b/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php index 8671e62df15..25bb597d6a2 100644 --- a/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php +++ b/app/code/Magento/CheckoutAgreements/Service/V1/Agreement/ReadService.php @@ -27,7 +27,7 @@ use \Magento\CheckoutAgreements\Model\Resource\Agreement\CollectionFactory as Ag use \Magento\CheckoutAgreements\Model\Resource\Agreement\Collection as AgreementCollection; use \Magento\CheckoutAgreements\Model\Agreement; use \Magento\Framework\App\Config\ScopeConfigInterface; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Store\Model\ScopeInterface; use \Magento\CheckoutAgreements\Service\V1\Data\AgreementBuilder; use \Magento\CheckoutAgreements\Service\V1\Data\Agreement as AgreementDataObject; @@ -45,7 +45,7 @@ class ReadService implements ReadServiceInterface private $agreementBuilder; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; @@ -57,7 +57,7 @@ class ReadService implements ReadServiceInterface /** * @param AgreementCollectionFactory $collectionFactory * @param AgreementBuilder $agreementBuilder - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ScopeConfigInterface $scopeConfig */ public function __construct( diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 4c1983ff11d..050712e0441 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/Block/Block.php b/app/code/Magento/Cms/Block/Block.php index 2ad0a753583..6a25831bb79 100644 --- a/app/code/Magento/Cms/Block/Block.php +++ b/app/code/Magento/Cms/Block/Block.php @@ -36,7 +36,7 @@ class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Ma /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -52,14 +52,14 @@ class Block extends \Magento\Framework\View\Element\AbstractBlock implements \Ma * * @param \Magento\Framework\View\Element\Context $context * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Cms\Model\BlockFactory $blockFactory * @param array $data */ public function __construct( \Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Template\FilterProvider $filterProvider, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Cms\Model\BlockFactory $blockFactory, array $data = array() ) { diff --git a/app/code/Magento/Cms/Block/Page.php b/app/code/Magento/Cms/Block/Page.php index b43fbe30231..8d5c12fb7a6 100644 --- a/app/code/Magento/Cms/Block/Page.php +++ b/app/code/Magento/Cms/Block/Page.php @@ -41,7 +41,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -63,7 +63,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag * @param \Magento\Framework\View\Element\Context $context * @param \Magento\Cms\Model\Page $page * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Cms\Model\PageFactory $pageFactory * @param \Magento\Framework\View\Page\Config $pageConfig * @param array $data @@ -72,7 +72,7 @@ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Mag \Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Page $page, \Magento\Cms\Model\Template\FilterProvider $filterProvider, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Cms\Model\PageFactory $pageFactory, \Magento\Framework\View\Page\Config $pageConfig, array $data = array() diff --git a/app/code/Magento/Cms/Controller/Router.php b/app/code/Magento/Cms/Controller/Router.php index a2f2f53527b..528481c8ba3 100644 --- a/app/code/Magento/Cms/Controller/Router.php +++ b/app/code/Magento/Cms/Controller/Router.php @@ -45,7 +45,7 @@ class Router implements \Magento\Framework\App\RouterInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,24 +81,21 @@ class Router implements \Magento\Framework\App\RouterInterface * @param \Magento\Framework\App\ActionFactory $actionFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\State $appState * @param \Magento\Cms\Model\PageFactory $pageFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResponseInterface $response */ public function __construct( \Magento\Framework\App\ActionFactory $actionFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\State $appState, \Magento\Cms\Model\PageFactory $pageFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\ResponseInterface $response ) { $this->actionFactory = $actionFactory; $this->_eventManager = $eventManager; $this->_url = $url; - $this->_appState = $appState; $this->_pageFactory = $pageFactory; $this->_storeManager = $storeManager; $this->_response = $response; @@ -109,16 +106,9 @@ class Router implements \Magento\Framework\App\RouterInterface * * @param \Magento\Framework\App\RequestInterface $request * @return bool - * - * @SuppressWarnings(PHPMD.ExitExpression) */ public function match(\Magento\Framework\App\RequestInterface $request) { - if (!$this->_appState->isInstalled()) { - $this->_response->setRedirect($this->_url->getUrl('install'))->sendResponse(); - exit; - } - $identifier = trim($request->getPathInfo(), '/'); $condition = new \Magento\Framework\Object(array('identifier' => $identifier, 'continue' => true)); diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index cfea022b04e..525f8e92305 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -70,7 +70,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -102,7 +102,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Cms\Model\Page $page * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Cms\Model\PageFactory $pageFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\App\ViewInterface $view @@ -114,7 +114,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Cms\Model\Page $page, \Magento\Framework\View\DesignInterface $design, \Magento\Cms\Model\PageFactory $pageFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Escaper $escaper, \Magento\Framework\App\ViewInterface $view, diff --git a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php index fa787e420dc..c8b0aa35b4e 100644 --- a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php @@ -69,7 +69,7 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -80,14 +80,14 @@ class Images extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Backend\Helper\Data $backendData * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Backend\Helper\Data $backendData, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_backendData = $backendData; diff --git a/app/code/Magento/Cms/Model/Resource/Block.php b/app/code/Magento/Cms/Model/Resource/Block.php index a7a51f5f4d3..57157637586 100644 --- a/app/code/Magento/Cms/Model/Resource/Block.php +++ b/app/code/Magento/Cms/Model/Resource/Block.php @@ -36,7 +36,7 @@ class Block extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,12 +45,12 @@ class Block extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($resource); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php index d34e800e7fb..90796013df2 100644 --- a/app/code/Magento/Cms/Model/Resource/Page.php +++ b/app/code/Magento/Cms/Model/Resource/Page.php @@ -43,7 +43,7 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -62,14 +62,14 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Filter\FilterManager $filter */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Filter\FilterManager $filter ) { diff --git a/app/code/Magento/Cms/Model/Resource/Page/Collection.php b/app/code/Magento/Cms/Model/Resource/Page/Collection.php index e2728697243..030486139be 100644 --- a/app/code/Magento/Cms/Model/Resource/Page/Collection.php +++ b/app/code/Magento/Cms/Model/Resource/Page/Collection.php @@ -38,7 +38,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -56,7 +56,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index c640be2d979..0a450210906 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,19 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-install": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php index b201c72f7e3..ce4239a0094 100644 --- a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php +++ b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0-1.6.0.1.php @@ -150,10 +150,6 @@ $pageContent = <<<EOD <th>COMPARE</th> <td>The items that you have in the Compare Products list.</td> </tr> - <tr> - <th>CURRENCY</th> - <td>Your preferred currency</td> - </tr> <tr> <th>CUSTOMER</th> <td>An encrypted version of your customer id with the store.</td> diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 0258aa60d6e..24d9c5e083a 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -39,7 +39,6 @@ <module name="Magento_Backend"/> <module name="Magento_Catalog"/> <module name="Magento_Email"/> - <module name="Magento_Install"/> </depends> </module> </config> diff --git a/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php b/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php index eda0815e280..076448145b6 100644 --- a/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Service/V1/CmsPageUrlGenerator.php @@ -23,7 +23,7 @@ */ namespace Magento\CmsUrlRewrite\Service\V1; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\UrlRedirect\Service\V1\Data\Converter; use Magento\UrlRedirect\Service\V1\Data\UrlRewrite; diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 340a2112909..c4e60a26ee1 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,12 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-url-redirect": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-url-redirect": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CmsUrlRewrite/etc/module.xml b/app/code/Magento/CmsUrlRewrite/etc/module.xml index 8df04efdd04..7d40a61c106 100644 --- a/app/code/Magento/CmsUrlRewrite/etc/module.xml +++ b/app/code/Magento/CmsUrlRewrite/etc/module.xml @@ -26,7 +26,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_CmsUrlRewrite" schema_version="1.0.0.0" active="false"> <depends> - <module name="Magento_Store"/> <module name="Magento_UrlRedirect"/> </depends> </module> diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index a225386a748..b84ae5a7bcf 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-import-export": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-import-export": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php index a03b2afd35c..55b388d494f 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php @@ -39,18 +39,28 @@ class SuggestConfigurableAttributes extends Action */ protected $coreHelper; + /** + * Store manager + * + * @var \Magento\Framework\StoreManagerInterface + */ + protected $storeManager; + /** * @param Action\Context $context * @param SuggestedAttributeList $attributeList * @param \Magento\Core\Helper\Data $coreHelper + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Action\Context $context, SuggestedAttributeList $attributeList, - \Magento\Core\Helper\Data $coreHelper + \Magento\Core\Helper\Data $coreHelper, + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->attributeList = $attributeList; $this->coreHelper = $coreHelper; + $this->storeManager = $storeManager; parent::__construct($context); } @@ -71,6 +81,8 @@ class SuggestConfigurableAttributes extends Action */ public function execute() { + $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::ADMIN_CODE); + $this->getResponse()->representJson( $this->coreHelper->jsonEncode( $this->attributeList->getSuggestedAttributes($this->getRequest()->getParam('label_part')) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 9326f2db453..ca9ca611ed0 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -386,6 +386,11 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType $res = array(); foreach ($this->getConfigurableAttributes($product) as $attribute) { $eavAttribute = $attribute->getProductAttribute(); + $storeId = 0; + if ($product->getStoreId() !== null) { + $storeId = $product->getStoreId(); + } + $eavAttribute->setStoreId($storeId); /* @var $attribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ $res[$eavAttribute->getId()] = array( 'id' => $attribute->getId(), diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php index e7aea06a2c3..1ce75115d43 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php @@ -36,7 +36,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price /** * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -44,7 +44,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Event\ManagerInterface $eventManager, diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 18f93795bf5..28b1fa104ff 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -62,6 +62,7 @@ class VariationMatrix } while (true); return $variations; + } /** @@ -77,7 +78,7 @@ class VariationMatrix $options = array(); foreach ($attribute['options'] as $valueInfo) { foreach ($attribute['values'] as $priceData) { - if ($priceData['value_index'] == $valueInfo['value'] + if (isset($priceData['value_index']) && $priceData['value_index'] == $valueInfo['value'] && (!isset($priceData['include']) || $priceData['include']) ) { $valueInfo['price'] = $priceData; diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php index b5014625915..ce7a85a10e3 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php @@ -65,7 +65,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -91,7 +91,7 @@ class AssociatedProduct extends \Magento\Catalog\Model\Resource\Product\Collecti \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, 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 b832a6c8c4e..7d2753b4319 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 @@ -53,18 +53,18 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php index 9b4cc92aaca..e7aa08e135a 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute/Collection.php @@ -68,7 +68,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,7 +77,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $catalogProductTypeConfigurable * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute $resource @@ -88,7 +88,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ConfigurableProduct\Model\Product\Type\Configurable $catalogProductTypeConfigurable, \Magento\Catalog\Helper\Data $catalogData, \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute $resource, diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php index fd87bf057ad..95dd75fbdbc 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/AttributePrice.php @@ -46,7 +46,7 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -55,14 +55,14 @@ class AttributePrice extends AbstractPrice implements AttributePriceInterface * @param float $quantity * @param CalculatorInterface $calculator * @param PriceModifierInterface $modifier - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Product $saleableItem, $quantity, CalculatorInterface $calculator, PriceModifierInterface $modifier, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->priceModifier = $modifier; $this->storeManager = $storeManager; diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php index 9a5dcbf2446..28fe23b5e1d 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteService.php @@ -33,7 +33,7 @@ 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\StoreManagerInterface; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\CouldNotSaveException; @@ -81,7 +81,7 @@ class WriteService implements WriteServiceInterface * @param ConfigurableAttributeFactory $configurableAttributeFactory * @param EavConfig $eavConfig * @param OptionConverter $optionConverter - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ConfigurableType $productType */ public function __construct( diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 6b34c23b7d9..722d22f5713 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-webapi": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-webapi": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/etc/module.xml b/app/code/Magento/ConfigurableProduct/etc/module.xml index c4e5719f372..0b9cba1389f 100644 --- a/app/code/Magento/ConfigurableProduct/etc/module.xml +++ b/app/code/Magento/ConfigurableProduct/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_CatalogInventory"/> <module name="Magento_Sales"/> <module name="Magento_Checkout"/> - <module name="Magento_ImportExport"/> </sequence> <depends> <module name="Magento_Store"/> diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml index e045fd29517..20c3a7d9d6c 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/super/matrix.phtml @@ -63,7 +63,7 @@ $productByUsedAttributes = $this->getAssociatedProducts(); <?php foreach ($usedProductAttributes as $attribute) { /** @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ - echo '<th class="col-' . preg_replace('#[^a-z0-9]+#', '-', strtolower($attribute->getStoreLabel())) . '">', $attribute->getStoreLabel(), '</th>', PHP_EOL; + echo '<th class="col-' . preg_replace('#[^a-z0-9]+#', '-', strtolower($attribute->getStoreLabel(0))) . '">', $attribute->getStoreLabel(0), '</th>', PHP_EOL; } ?> <th class="col-actions hidden"></th> diff --git a/app/code/Magento/Contact/Controller/Index.php b/app/code/Magento/Contact/Controller/Index.php index e52e7cb3c48..47bcc7c91a5 100644 --- a/app/code/Magento/Contact/Controller/Index.php +++ b/app/code/Magento/Contact/Controller/Index.php @@ -67,7 +67,7 @@ class Index extends \Magento\Framework\App\Action\Action protected $scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -76,14 +76,14 @@ class Index extends \Magento\Framework\App\Action\Action * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_transportBuilder = $transportBuilder; diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index f16c6e423d6..5ba1d3b07bf 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/App/Media.php b/app/code/Magento/Core/App/Media.php index 71ec833e5e2..0a8868324d5 100644 --- a/app/code/Magento/Core/App/Media.php +++ b/app/code/Magento/Core/App/Media.php @@ -26,6 +26,7 @@ namespace Magento\Core\App; use Magento\Framework\App\State; +use Magento\Framework\App; use Magento\Framework\AppInterface; use Magento\Framework\ObjectManager; use Magento\Core\Model\File\Storage\Request; @@ -33,11 +34,6 @@ use Magento\Core\Model\File\Storage\Response; class Media implements AppInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_applicationState; - /** * @var \Magento\Framework\ObjectManager */ @@ -99,7 +95,6 @@ class Media implements AppInterface protected $directory; /** - * @param State $applicationState * @param ObjectManager $objectManager * @param Request $request * @param Response $response @@ -111,7 +106,6 @@ class Media implements AppInterface * @param \Magento\Framework\App\Filesystem $filesystem */ public function __construct( - State $applicationState, ObjectManager $objectManager, Request $request, Response $response, @@ -122,7 +116,6 @@ class Media implements AppInterface $relativeFileName, \Magento\Framework\App\Filesystem $filesystem ) { - $this->_applicationState = $applicationState; $this->_objectManager = $objectManager; $this->_request = $request; $this->_response = $response; @@ -139,51 +132,51 @@ class Media implements AppInterface * Run application * * @return \Magento\Framework\App\ResponseInterface + * @throws \LogicException */ public function launch() { - try { - if (!$this->_applicationState->isInstalled()) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } - if (!$this->_mediaDirectory) { - $config = $this->_objectManager->create( - 'Magento\Core\Model\File\Storage\Config', - array('cacheFile' => $this->_configCacheFile) - ); - $config->save(); - $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory()); - $allowedResources = $config->getAllowedResources(); - $this->_relativeFileName = str_replace( - $this->_mediaDirectory . '/', - '', - $this->_request->getPathInfo() - ); - $isAllowed = $this->_isAllowed; - if (!$isAllowed($this->_relativeFileName, $allowedResources)) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } + if (!$this->_mediaDirectory) { + $config = $this->_objectManager->create( + 'Magento\Core\Model\File\Storage\Config', + array('cacheFile' => $this->_configCacheFile) + ); + $config->save(); + $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory()); + $allowedResources = $config->getAllowedResources(); + $this->_relativeFileName = str_replace( + $this->_mediaDirectory . '/', + '', + $this->_request->getPathInfo() + ); + $isAllowed = $this->_isAllowed; + if (!$isAllowed($this->_relativeFileName, $allowedResources)) { + throw new \LogicException('The specified path is not allowed.'); } + } - if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) { - $this->_response->setHttpResponseCode(404); - return $this->_response; - } + if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) { + throw new \LogicException('The specified path is not within media directory.'); + } - $sync = $this->_objectManager->get('Magento\Core\Model\File\Storage\Synchronization'); - $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath()); + $sync = $this->_objectManager->get('Magento\Core\Model\File\Storage\Synchronization'); + $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath()); - if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) { - $this->_response->setFilePath($this->_request->getFilePath()); - } else { - $this->_response->setHttpResponseCode(404); - } - return $this->_response; - } catch (\Exception $e) { + if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) { + $this->_response->setFilePath($this->_request->getFilePath()); + } else { $this->_response->setHttpResponseCode(404); - return $this->_response; } + return $this->_response; + } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + $this->_response->setHttpResponseCode(404); + $this->_response->sendHeaders(); + return true; } } diff --git a/app/code/Magento/Core/App/Router/Base.php b/app/code/Magento/Core/App/Router/Base.php index 42c8b2603ca..957ed87e38b 100644 --- a/app/code/Magento/Core/App/Router/Base.php +++ b/app/code/Magento/Core/App/Router/Base.php @@ -81,15 +81,10 @@ class Base implements \Magento\Framework\App\RouterInterface protected $_url; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\ResponseFactory */ @@ -133,9 +128,8 @@ class Base implements \Magento\Framework\App\RouterInterface * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface|\Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface|\Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId @@ -148,9 +142,8 @@ class Base implements \Magento\Framework\App\RouterInterface \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\ConfigInterface $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -165,7 +158,6 @@ class Base implements \Magento\Framework\App\RouterInterface $this->_scopeConfig = $scopeConfig; $this->_url = $url; $this->_storeManager = $storeManager; - $this->_appState = $appState; $this->nameBuilder = $nameBuilder; } @@ -374,7 +366,7 @@ class Base implements \Magento\Framework\App\RouterInterface */ protected function _checkShouldBeSecure(\Magento\Framework\App\RequestInterface $request, $path = '') { - if (!$this->_appState->isInstalled() || $request->getPost()) { + if ($request->getPost()) { return; } diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index c772f4a460c..bcc1e403662 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -69,7 +69,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -91,7 +91,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param PriceCurrencyInterface $priceCurrency * @param bool $dbCompatibleMode @@ -99,7 +99,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, PriceCurrencyInterface $priceCurrency, $dbCompatibleMode = true diff --git a/app/code/Magento/Core/Helper/Url.php b/app/code/Magento/Core/Helper/Url.php index 70dde1dec40..eee8a61f032 100644 --- a/app/code/Magento/Core/Helper/Url.php +++ b/app/code/Magento/Core/Helper/Url.php @@ -32,17 +32,17 @@ namespace Magento\Core\Helper; class Url extends \Magento\Framework\App\Helper\AbstractHelper { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($context); $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php index ffb50176c28..b0ff91b2808 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Core/Model/App/Emulation.php @@ -34,7 +34,7 @@ use Magento\Framework\Translate\Inline\ConfigInterface; class Emulation extends \Magento\Framework\Object { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class Emulation extends \Magento\Framework\Object protected $inlineTranslation; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\DesignInterface $viewDesign * @param \Magento\Framework\App\DesignInterface $design * @param \Magento\Framework\TranslateInterface $translate @@ -82,7 +82,7 @@ class Emulation extends \Magento\Framework\Object * @param array $data */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\DesignInterface $viewDesign, \Magento\Framework\App\DesignInterface $design, \Magento\Framework\TranslateInterface $translate, diff --git a/app/code/Magento/Core/Model/Layout/Merge.php b/app/code/Magento/Core/Model/Layout/Merge.php index 9761749cf00..94e82c47d0e 100644 --- a/app/code/Magento/Core/Model/Layout/Merge.php +++ b/app/code/Magento/Core/Model/Layout/Merge.php @@ -149,7 +149,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface * Init merge model * * @param \Magento\Framework\View\DesignInterface $design - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\File\CollectorInterface $fileSource * @param \Magento\Core\Model\Resource\Layout\Update $resource * @param \Magento\Framework\App\State $appState @@ -162,7 +162,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface */ public function __construct( \Magento\Framework\View\DesignInterface $design, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\File\CollectorInterface $fileSource, \Magento\Core\Model\Resource\Layout\Update $resource, \Magento\Framework\App\State $appState, @@ -512,9 +512,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface protected function _merge($handle) { $this->_fetchPackageLayoutUpdates($handle); - if ($this->_appState->isInstalled()) { - $this->_fetchDbLayoutUpdates($handle); - } + $this->_fetchDbLayoutUpdates($handle); return $this; } diff --git a/app/code/Magento/Core/Model/Resource/Setup.php b/app/code/Magento/Core/Model/Resource/Setup.php index 284480e10c0..5dde54656c2 100644 --- a/app/code/Magento/Core/Model/Resource/Setup.php +++ b/app/code/Magento/Core/Model/Resource/Setup.php @@ -60,7 +60,7 @@ class Setup extends \Magento\Framework\Module\Setup } /** - * @return \Magento\Core\Model\Resource\Theme\CollectionFactory + * @return \Magento\Core\Model\Resource\Theme\Collection */ public function createThemeResourceFactory() { @@ -68,7 +68,7 @@ class Setup extends \Magento\Framework\Module\Setup } /** - * @return \Magento\Core\Model\Theme\CollectionFactory + * @return \Magento\Core\Model\Theme\Collection */ public function createThemeFactory() { diff --git a/app/code/Magento/Core/Model/Theme/Collection.php b/app/code/Magento/Core/Model/Theme/Collection.php index 99cb2daccea..e490c611df3 100644 --- a/app/code/Magento/Core/Model/Theme/Collection.php +++ b/app/code/Magento/Core/Model/Theme/Collection.php @@ -70,7 +70,7 @@ class Collection extends \Magento\Framework\Data\Collection implements ListInter */ public function addDefaultPattern($area = \Magento\Framework\App\Area::AREA_FRONTEND) { - $this->addTargetPattern(implode('/', array($area, '*/*', 'theme.xml'))); + $this->addTargetPattern(implode('/', array($area, '{*/*,*/}', 'theme.xml'))); return $this; } diff --git a/app/code/Magento/Core/Model/Theme/Image/Path.php b/app/code/Magento/Core/Model/Theme/Image/Path.php index 2f2c183c4d5..1651d4aca47 100644 --- a/app/code/Magento/Core/Model/Theme/Image/Path.php +++ b/app/code/Magento/Core/Model/Theme/Image/Path.php @@ -49,7 +49,7 @@ class Path implements \Magento\Framework\View\Design\Theme\Image\PathInterface protected $assetRepo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -58,12 +58,12 @@ class Path implements \Magento\Framework\View\Design\Theme\Image\PathInterface * * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->mediaDirectory = $filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR); $this->assetRepo = $assetRepo; diff --git a/app/code/Magento/Core/Model/Url/RouteParamsResolver.php b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php index 708356a6a80..cdbee8fc799 100644 --- a/app/code/Magento/Core/Model/Url/RouteParamsResolver.php +++ b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php @@ -36,7 +36,7 @@ class RouteParamsResolver extends \Magento\Framework\Object implements \Magento\ protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,14 +48,14 @@ class RouteParamsResolver extends \Magento\Framework\Object implements \Magento\ /** * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver * @param array $data */ public function __construct( \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Url\QueryParamsResolverInterface $queryParamsResolver, array $data = array() ) { diff --git a/app/code/Magento/Core/Model/Url/ScopeResolver.php b/app/code/Magento/Core/Model/Url/ScopeResolver.php index 5937b282382..760944753e9 100644 --- a/app/code/Magento/Core/Model/Url/ScopeResolver.php +++ b/app/code/Magento/Core/Model/Url/ScopeResolver.php @@ -26,7 +26,7 @@ namespace Magento\Core\Model\Url; class ScopeResolver implements \Magento\Framework\Url\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -36,10 +36,10 @@ class ScopeResolver implements \Magento\Framework\Url\ScopeResolverInterface protected $_areaCode; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param string|null $areaCode */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, $areaCode = null) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, $areaCode = null) { $this->_storeManager = $storeManager; $this->_areaCode = $areaCode; diff --git a/app/code/Magento/Core/Model/View/Design.php b/app/code/Magento/Core/Model/View/Design.php index 7d7d7bf61ca..3b21a1a216e 100644 --- a/app/code/Magento/Core/Model/View/Design.php +++ b/app/code/Magento/Core/Model/View/Design.php @@ -54,7 +54,7 @@ class Design implements \Magento\Framework\View\DesignInterface /** * Store list manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Design implements \Magento\Framework\View\DesignInterface protected $_appState; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\Design\Theme\FlyweightFactory $flyweightFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\ThemeFactory $themeFactory @@ -93,7 +93,7 @@ class Design implements \Magento\Framework\View\DesignInterface * @param array $themes */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\Design\Theme\FlyweightFactory $flyweightFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\ThemeFactory $themeFactory, diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 5e9a33f37d7..67fbd0494bd 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php index 2f09b686e54..1a1572b6ac1 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.10-1.6.0.11.php @@ -22,13 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $filesystemCollection \Magento\Core\Model\Theme\Collection */ -$filesystemCollection = $this->createThemeFactory(); -$filesystemCollection->addDefaultPattern('*'); +/** @var $this \Magento\Core\Model\Resource\Setup */ +$fileCollection = $this->createThemeFactory(); +$fileCollection->addDefaultPattern('*'); +$fileCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); + +$resourceCollection = $this->createThemeResourceFactory(); +$resourceCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ -foreach ($this->createThemeResourceFactory() as $theme) { - $themeType = $filesystemCollection->hasTheme($theme) +foreach ($resourceCollection as $theme) { + $themeType = $fileCollection->hasTheme($theme) ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL; $theme->setType($themeType)->save(); diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php index 9f27d2da503..1655e11fc2a 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.12-1.6.0.13.php @@ -22,11 +22,16 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +$fileCollection = $this->createThemeFactory(); +$fileCollection->addDefaultPattern('*'); +$fileCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); + /** @var $themeDbCollection \Magento\Core\Model\Resource\Theme\Collection */ $themeDbCollection = $this->createThemeResourceFactory(); +$themeDbCollection->setItemObjectClass('Magento\Core\Model\Theme\Data'); /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ -foreach ($this->createThemeFactory()->addDefaultPattern('*') as $theme) { +foreach ($fileCollection as $theme) { $dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath()); $dbTheme->setCode($theme->getCode()); $dbTheme->save(); diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 9004dd991a1..4d8994e83cc 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -417,7 +417,7 @@ </arguments> </type> <type name="Magento\Framework\App\FrontController"> - <plugin name="install" type="Magento\Framework\Module\FrontController\Plugin\Install" sortOrder="40"/> + <plugin name="install" type="Magento\Framework\Module\Plugin\DbStatusValidator" sortOrder="40"/> </type> <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> diff --git a/app/code/Magento/Core/etc/frontend/di.xml b/app/code/Magento/Core/etc/frontend/di.xml index 845639a3711..6f6749c94da 100644 --- a/app/code/Magento/Core/etc/frontend/di.xml +++ b/app/code/Magento/Core/etc/frontend/di.xml @@ -24,11 +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\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Framework\View\Layout"> <plugin name="core-session-depersonalize" type="Magento\Core\Model\Layout\DepersonalizePlugin" sortOrder="1"/> diff --git a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php deleted file mode 100644 index a1187eccc63..00000000000 --- a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Cron application plugin - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Cron\App\Cron\Plugin; - -use \Magento\Framework\App\State; - -class ApplicationInitializer -{ - /** - * @var State - */ - protected $_appState; - - /** - * @var \Magento\Framework\Session\SidResolverInterface - */ - protected $_sidResolver; - - /** - * @param State $appState - * @param \Magento\Framework\Session\SidResolverInterface $sidResolver - */ - public function __construct(State $appState, \Magento\Framework\Session\SidResolverInterface $sidResolver) - { - $this->_appState = $appState; - $this->_sidResolver = $sidResolver; - } - - /** - * Perform required checks before cron run - * - * @param \Magento\Framework\App\Cron $subject - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws \Magento\Framework\Exception - */ - public function beforeLaunch(\Magento\Framework\App\Cron $subject) - { - $this->_sidResolver->setUseSessionInUrl(false); - if (false == $this->_appState->isInstalled()) { - throw new \Magento\Framework\Exception('Application is not installed yet, please complete the installation first.'); - } - } -} diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index f0455dcf52b..f7f0c5fbf51 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index e2af3968319..7af22e923b2 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -31,9 +31,6 @@ <argument name="defaultReader" xsi:type="object">Magento\Store\Model\Config\Reader\DefaultReader</argument> </arguments> </type> - <type name="Magento\Framework\App\Cron"> - <plugin name="application_initializer" type="Magento\Cron\App\Cron\Plugin\ApplicationInitializer" sortOrder="10"/> - </type> <type name="Magento\Backend\Model\Config\Structure\Converter"> <plugin name="cron_backend_config_structure_converter_plugin" type="Magento\Cron\Model\Backend\Config\Structure\Converter" /> </type> diff --git a/app/code/Magento/CurrencySymbol/Helper/Data.php b/app/code/Magento/CurrencySymbol/Helper/Data.php index 2a4e92fccb8..6446899ac03 100644 --- a/app/code/Magento/CurrencySymbol/Helper/Data.php +++ b/app/code/Magento/CurrencySymbol/Helper/Data.php @@ -39,7 +39,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory @@ -48,7 +48,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory, diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php index 2c9a48ce5cd..4180dc7adc9 100644 --- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php @@ -104,7 +104,7 @@ class Currencysymbol protected $_systemStore; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -130,7 +130,7 @@ class Currencysymbol * @param \Magento\Framework\App\Config\ReinitableConfigInterface $coreConfig * @param \Magento\Backend\Model\Config\Factory $configFactory * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Store\Model\System\Store $systemStore * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -140,7 +140,7 @@ class Currencysymbol \Magento\Framework\App\Config\ReinitableConfigInterface $coreConfig, \Magento\Backend\Model\Config\Factory $configFactory, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Store\Model\System\Store $systemStore, \Magento\Framework\Event\ManagerInterface $eventManager diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 951da498205..1167b1a9645 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php index 6ea74406b8f..b8b3d3f4dc6 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Sendemail.php @@ -36,7 +36,7 @@ class Sendemail extends Element protected $_template = 'edit/tab/account/form/renderer/sendemail.phtml'; /** - * @var \Magento\Store\Model\StoreManagerInterface|null + * @var \Magento\Framework\StoreManagerInterface|null */ protected $_storeManager = null; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php index 8a632a02aaf..0cd008fdec7 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php @@ -24,28 +24,12 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; use Magento\Customer\Controller\RegistryConstants; -use Magento\Customer\Service\V1\CustomerAccountServiceInterface; -use Magento\Customer\Service\V1\Data\AddressConverter; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** * Customer account form block - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface { - /** - * @var \Magento\Customer\Service\V1\Data\Customer - */ - protected $_customer; - - /** - * @var \Magento\Log\Model\Customer - */ - protected $_customerLog; - /** * Core registry * @@ -53,99 +37,20 @@ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\B */ protected $_coreRegistry; - /** - * @var \Magento\Log\Model\Visitor - */ - protected $_modelVisitor; - - /** - * @var CustomerAccountServiceInterface - */ - protected $_accountService; - - /** - * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface - */ - protected $_addressService; - - /** - * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface - */ - protected $_groupService; - - /** - * @var \Magento\Customer\Service\V1\Data\CustomerBuilder - */ - protected $_customerBuilder; - - /** - * @var \Magento\Customer\Helper\Address - */ - protected $_addressHelper; - - /** - * @var \Magento\Log\Model\CustomerFactory - */ - protected $_logFactory; - - /** - * @var \Magento\Framework\Stdlib\DateTime - */ - protected $dateTime; - /** * @param \Magento\Backend\Block\Template\Context $context - * @param CustomerAccountServiceInterface $accountService - * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService - * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService - * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder - * @param \Magento\Customer\Helper\Address $addressHelper - * @param \Magento\Log\Model\CustomerFactory $logFactory * @param \Magento\Framework\Registry $registry - * @param \Magento\Log\Model\Visitor $modelVisitor - * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\Block\Template\Context $context, - CustomerAccountServiceInterface $accountService, - \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, - \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, - \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, - \Magento\Customer\Helper\Address $addressHelper, - \Magento\Log\Model\CustomerFactory $logFactory, \Magento\Framework\Registry $registry, - \Magento\Log\Model\Visitor $modelVisitor, - \Magento\Framework\Stdlib\DateTime $dateTime, array $data = array() ) { $this->_coreRegistry = $registry; - $this->_modelVisitor = $modelVisitor; - $this->_accountService = $accountService; - $this->_addressService = $addressService; - $this->_groupService = $groupService; - $this->_customerBuilder = $customerBuilder; - $this->_addressHelper = $addressHelper; - $this->_logFactory = $logFactory; - $this->dateTime = $dateTime; parent::__construct($context, $data); } - /** - * @return \Magento\Customer\Service\V1\Data\Customer - */ - public function getCustomer() - { - if (!$this->_customer) { - $this->_customer = $this->_customerBuilder->populateWithArray( - $this->_backendSession->getCustomerData()['account'] - )->create(); - } - return $this->_customer; - } - /** * @return string|null */ @@ -154,212 +59,6 @@ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\B return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); } - /** - * @param int $groupId - * @return \Magento\Customer\Service\V1\Data\CustomerGroup|null - */ - private function getGroup($groupId) - { - try { - $group = $this->_groupService->getGroup($groupId); - } catch (NoSuchEntityException $e) { - $group = null; - } - return $group; - } - - /** - * @return string|null - */ - public function getGroupName() - { - $customer = $this->getCustomer(); - - if ($groupId = $customer->getId() ? $customer->getGroupId() : null) { - if ($group = $this->getGroup($groupId)) { - return $group->getCode(); - } - } - - return null; - } - - /** - * Load Customer Log model - * - * @return \Magento\Log\Model\Customer - */ - public function getCustomerLog() - { - if (!$this->_customerLog) { - $this->_customerLog = $this->_logFactory->create()->loadByCustomer($this->getCustomerId()); - } - return $this->_customerLog; - } - - /** - * Get customer creation date - * - * @return string - */ - public function getCreateDate() - { - return $this->formatDate( - $this->getCustomer()->getCreatedAt(), - TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - } - - /** - * @return string - */ - public function getStoreCreateDate() - { - $date = $this->_localeDate->scopeDate( - $this->getCustomer()->getStoreId(), - $this->dateTime->toTimestamp($this->getCustomer()->getCreatedAt()), - true - ); - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - - /** - * @return string - */ - public function getStoreCreateDateTimezone() - { - return $this->_scopeConfig->getValue( - $this->_localeDate->getDefaultTimezonePath(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getCustomer()->getStoreId() - ); - } - - /** - * Get customer last login date - * - * @return string - */ - public function getLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - return __('Never'); - } - - /** - * @return string - */ - public function getStoreLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); - return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); - } - return __('Never'); - } - - /** - * @return string - */ - public function getStoreLastLoginDateTimezone() - { - return $this->_scopeConfig->getValue( - $this->_localeDate->getDefaultTimezonePath(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getCustomer()->getStoreId() - ); - } - - /** - * @return string - */ - public function getCurrentStatus() - { - $log = $this->getCustomerLog(); - $interval = $this->_modelVisitor->getOnlineMinutesInterval(); - if ($log->getLogoutAt() - || strtotime( - $this->dateTime->now() - ) - strtotime( - $log->getLastVisitAt() - ) > $interval * 60 - ) { - return __('Offline'); - } - return __('Online'); - } - - /** - * @return string - */ - public function getIsConfirmedStatus() - { - $id = $this->getCustomerId(); - switch ($this->_accountService->getConfirmationStatus($id)) { - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMED: - return __('Confirmed'); - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED: - return __('Confirmation Required'); - case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED: - return __('Confirmation Not Required'); - } - return __('Indeterminate'); - } - - /** - * @return null|string - */ - public function getCreatedInStore() - { - return $this->_storeManager->getStore($this->getStoreId())->getName(); - } - - /** - * @return int - */ - public function getStoreId() - { - return $this->getCustomer()->getStoreId(); - } - - /** - * @return string|null - */ - public function getBillingAddressHtml() - { - try { - $address = $this->_addressService->getAddress($this->getCustomer()->getDefaultBilling()); - } catch (NoSuchEntityException $e) { - return __('The customer does not have default billing address.'); - } - return $this->_addressHelper->getFormatTypeRenderer( - 'html' - )->renderArray( - AddressConverter::toFlatArray($address) - ); - } - - /** - * @return string - */ - public function getAccordionHtml() - { - return $this->getChildHtml('accordion'); - } - - /** - * @return string - */ - public function getSalesHtml() - { - return $this->getChildHtml('sales'); - } - /** * @return string */ diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php new file mode 100644 index 00000000000..7444dc99b29 --- /dev/null +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php @@ -0,0 +1,244 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Customer\Service\V1\Data\AddressConverter; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Adminhtml customer view personal information sales block + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class PersonalInfo extends \Magento\Backend\Block\Template +{ + /** + * @var \Magento\Customer\Service\V1\Data\Customer + */ + protected $customer; + + /** + * @var CustomerAccountServiceInterface + */ + protected $accountService; + + /** + * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface + */ + protected $addressService; + + /** + * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface + */ + protected $groupService; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerBuilder + */ + protected $customerBuilder; + + /** + * @var \Magento\Customer\Helper\Address + */ + protected $addressHelper; + + /** + * @var \Magento\Framework\Stdlib\DateTime + */ + protected $dateTime; + + /** + * Core registry + * + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param CustomerAccountServiceInterface $accountService + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService + * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder + * @param \Magento\Customer\Helper\Address $addressHelper + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Registry $registry + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + CustomerAccountServiceInterface $accountService, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, + \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, + \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, + \Magento\Customer\Helper\Address $addressHelper, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Registry $registry, + array $data = array() + ) { + $this->coreRegistry = $registry; + $this->accountService = $accountService; + $this->addressService = $addressService; + $this->groupService = $groupService; + $this->customerBuilder = $customerBuilder; + $this->addressHelper = $addressHelper; + $this->dateTime = $dateTime; + parent::__construct($context, $data); + } + + /** + * @return \Magento\Customer\Service\V1\Data\Customer + */ + public function getCustomer() + { + if (!$this->customer) { + $this->customer = $this->customerBuilder->populateWithArray( + $this->_backendSession->getCustomerData()['account'] + )->create(); + } + return $this->customer; + } + + /** + * @return string|null + */ + public function getCustomerId() + { + return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @return string + */ + public function getStoreCreateDate() + { + $date = $this->_localeDate->scopeDate( + $this->getCustomer()->getStoreId(), + $this->dateTime->toTimestamp($this->getCustomer()->getCreatedAt()), + true + ); + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + + /** + * @return string + */ + public function getStoreCreateDateTimezone() + { + return $this->_scopeConfig->getValue( + $this->_localeDate->getDefaultTimezonePath(), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getCustomer()->getStoreId() + ); + } + + /** + * Get customer creation date + * + * @return string + */ + public function getCreateDate() + { + return $this->formatDate( + $this->getCustomer()->getCreatedAt(), + TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + } + + /** + * @return string + */ + public function getIsConfirmedStatus() + { + $id = $this->getCustomerId(); + switch ($this->accountService->getConfirmationStatus($id)) { + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMED: + return __('Confirmed'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED: + return __('Confirmation Required'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED: + return __('Confirmation Not Required'); + } + return __('Indeterminate'); + } + + /** + * @return null|string + */ + public function getCreatedInStore() + { + return $this->_storeManager->getStore( + $this->getCustomer()->getStoreId() + )->getName(); + } + + /** + * @return string|null + */ + public function getBillingAddressHtml() + { + try { + $address = $this->addressService->getAddress($this->getCustomer()->getDefaultBilling()); + } catch (NoSuchEntityException $e) { + return __('The customer does not have default billing address.'); + } + return $this->addressHelper->getFormatTypeRenderer( + 'html' + )->renderArray( + AddressConverter::toFlatArray($address) + ); + } + + /** + * @return string|null + */ + public function getGroupName() + { + $customer = $this->getCustomer(); + if ($groupId = $customer->getId() ? $customer->getGroupId() : null) { + if ($group = $this->getGroup($groupId)) { + return $group->getCode(); + } + } + + return null; + } + + /** + * @param int $groupId + * @return \Magento\Customer\Service\V1\Data\CustomerGroup|null + */ + private function getGroup($groupId) + { + try { + $group = $this->groupService->getGroup($groupId); + } catch (NoSuchEntityException $e) { + $group = null; + } + return $group; + } +} diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index 0acdb7b0016..c8734afd9a0 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -24,6 +24,7 @@ namespace Magento\Customer\Block\Widget; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Framework\Service\ArrayObjectSearch; class Dob extends AbstractWidget { @@ -158,8 +159,12 @@ class Dob extends AbstractWidget $dob = $this->_getAttribute('dob'); if (!is_null($dob)) { $rules = $this->_getAttribute('dob')->getValidationRules(); - if (isset($rules[self::MIN_DATE_RANGE_KEY])) { - return date("Y/m/d", $rules[self::MIN_DATE_RANGE_KEY]); + $minDateValue = ArrayObjectSearch::getArrayElementByName( + $rules, + self::MIN_DATE_RANGE_KEY + ); + if (!is_null($minDateValue)) { + return date("Y/m/d", $minDateValue); } } return null; @@ -175,8 +180,12 @@ class Dob extends AbstractWidget $dob = $this->_getAttribute('dob'); if (!is_null($dob)) { $rules = $this->_getAttribute('dob')->getValidationRules(); - if (isset($rules[self::MAX_DATE_RANGE_KEY])) { - return date("Y/m/d", $rules[self::MAX_DATE_RANGE_KEY]); + $maxDateValue = ArrayObjectSearch::getArrayElementByName( + $rules, + self::MAX_DATE_RANGE_KEY + ); + if (!is_null($maxDateValue)) { + return date("Y/m/d", $maxDateValue); } } return null; diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php index 235a62a4da5..fdfbeceb97d 100644 --- a/app/code/Magento/Customer/Controller/Account.php +++ b/app/code/Magento/Customer/Controller/Account.php @@ -65,15 +65,12 @@ class Account extends \Magento\Framework\App\Action\Action /** @var \Magento\Framework\UrlFactory */ protected $_urlFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $_scopeConfig; - /** @var \Magento\Framework\App\State */ - protected $appState; - /** @var CustomerAccountServiceInterface */ protected $_customerAccountService; @@ -82,9 +79,8 @@ class Account extends \Magento\Framework\App\Action\Action * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService */ public function __construct( @@ -92,9 +88,8 @@ class Account extends \Magento\Framework\App\Action\Action \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService ) { $this->_session = $customerSession; @@ -102,7 +97,6 @@ class Account extends \Magento\Framework\App\Action\Action $this->_urlFactory = $urlFactory; $this->_storeManager = $storeManager; $this->_scopeConfig = $scopeConfig; - $this->appState = $appState; $this->_customerAccountService = $customerAccountService; parent::__construct($context); } @@ -135,10 +129,6 @@ class Account extends \Magento\Framework\App\Action\Action */ public function dispatch(RequestInterface $request) { - if (!$this->appState->isInstalled()) { - parent::dispatch($request); - } - if (!$this->getRequest()->isDispatched()) { parent::dispatch($request); } diff --git a/app/code/Magento/Customer/Controller/Account/Create.php b/app/code/Magento/Customer/Controller/Account/Create.php index fcc57656561..b3d11180172 100644 --- a/app/code/Magento/Customer/Controller/Account/Create.php +++ b/app/code/Magento/Customer/Controller/Account/Create.php @@ -37,9 +37,8 @@ class Create extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Helper\Data $customerHelper */ @@ -48,9 +47,8 @@ class Create extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Helper\Data $customerHelper ) { @@ -62,7 +60,6 @@ class Create extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index df94a3471fa..cb347081503 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -62,9 +62,8 @@ class CreatePost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory @@ -82,9 +81,8 @@ class CreatePost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, @@ -110,7 +108,6 @@ class CreatePost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } @@ -188,6 +185,8 @@ class CreatePost extends \Magento\Customer\Controller\Account return; } + $this->_session->regenerateId(); + try { $customer = $this->customerExtractor->extract('customer_account_create', $this->_request); $address = $this->_extractAddress(); diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index 022389054c8..a07456177f2 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -40,9 +40,8 @@ class Edit extends \Magento\Customer\Controller\Account * @param Session $customerSession * @param CustomerHelper $addressHelper * @param UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder */ @@ -51,9 +50,8 @@ class Edit extends \Magento\Customer\Controller\Account Session $customerSession, CustomerHelper $addressHelper, UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder ) { @@ -65,7 +63,6 @@ class Edit extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php index 2e59c352698..742bcd3d151 100644 --- a/app/code/Magento/Customer/Controller/Account/EditPost.php +++ b/app/code/Magento/Customer/Controller/Account/EditPost.php @@ -50,9 +50,8 @@ class EditPost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator @@ -66,9 +65,8 @@ class EditPost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, @@ -86,7 +84,6 @@ class EditPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php index 50a0e8622a0..0fa38e97bff 100644 --- a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php +++ b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php @@ -30,7 +30,7 @@ use Magento\Framework\App\Action\Context; use Magento\Customer\Model\Session; use Magento\Customer\Helper\Address; use Magento\Framework\UrlFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class ForgotPasswordPost extends \Magento\Customer\Controller\Account { @@ -44,7 +44,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account * @param UrlFactory $urlFactory * @param StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Framework\Escaper $escaper */ @@ -55,7 +54,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account UrlFactory $urlFactory, StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Framework\Escaper $escaper ) { @@ -67,7 +65,6 @@ class ForgotPasswordPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 33fc21bfa58..751a4258fa5 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -47,9 +47,8 @@ class LoginPost extends \Magento\Customer\Controller\Account * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\UrlFactory $urlFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\State $appState * @param CustomerAccountServiceInterface $customerAccountService * @param \Magento\Core\Helper\Data $coreHelperData * @param \Magento\Customer\Helper\Data $customerHelperData @@ -62,9 +61,8 @@ class LoginPost extends \Magento\Customer\Controller\Account \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\UrlFactory $urlFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\State $appState, CustomerAccountServiceInterface $customerAccountService, \Magento\Core\Helper\Data $coreHelperData, \Magento\Customer\Helper\Data $customerHelperData, @@ -80,7 +78,6 @@ class LoginPost extends \Magento\Customer\Controller\Account $urlFactory, $storeManager, $scopeConfig, - $appState, $customerAccountService ); } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index 611cd4975cb..9f9e40ff164 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -72,7 +72,7 @@ class Cart extends \Magento\Backend\App\Action $this->_quote = $this->_objectManager->create( 'Magento\Sales\Model\Quote' )->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getWebsite($websiteId) )->loadByCustomer( $this->_customerId ); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php b/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php index 63e0718d440..7b5e2fd7060 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Customer/InvalidateToken.php @@ -45,8 +45,8 @@ class InvalidateToken extends \Magento\Customer\Controller\Adminhtml\Index { if ($customerId = $this->getRequest()->getParam('customer_id')) { try { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = $this->_objectManager->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\CustomerTokenService $tokenService */ + $tokenService = $this->_objectManager->get('Magento\Integration\Service\V1\CustomerTokenService'); $tokenService->revokeCustomerAccessToken($customerId); $this->messageManager->addSuccess(__('You have revoked the customer\'s tokens.')); $this->_redirect('customer/index/edit', array('id' => $customerId, '_current' => true)); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php index ff43ec8f6ac..5bc7e3e4466 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php @@ -44,7 +44,7 @@ class Cart extends \Magento\Customer\Controller\Adminhtml\Index $quote = $this->_objectManager->create( 'Magento\Sales\Model\Quote' )->setWebsite( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getWebsite($websiteId) )->loadByCustomer( $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) ); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php index 97deddec596..543a827bbd5 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php @@ -53,5 +53,6 @@ class Index extends \Magento\Customer\Controller\Adminhtml\Index $this->_addBreadcrumb(__('Manage Customers'), __('Manage Customers')); $this->_view->renderLayout(); + $this->_getSession()->unsCustomerData(); } } diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index ea5d48d4f2f..e8615a90e93 100755 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -82,7 +82,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper /** @var \Magento\Framework\View\Element\BlockFactory */ protected $_blockFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ @@ -100,7 +100,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\View\Element\BlockFactory $blockFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService * @param \Magento\Customer\Service\V1\AddressMetadataServiceInterface $addressMetadataService @@ -109,7 +109,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\View\Element\BlockFactory $blockFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService, \Magento\Customer\Service\V1\AddressMetadataServiceInterface $addressMetadataService, diff --git a/app/code/Magento/Customer/Model/Address/Config.php b/app/code/Magento/Customer/Model/Address/Config.php index f1aab65203c..0469c8176fb 100644 --- a/app/code/Magento/Customer/Model/Address/Config.php +++ b/app/code/Magento/Customer/Model/Address/Config.php @@ -59,7 +59,7 @@ class Config extends \Magento\Framework\Config\Data protected $_defaultTypes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -76,7 +76,7 @@ class Config extends \Magento\Framework\Config\Data /** * @param \Magento\Customer\Model\Address\Config\Reader $reader * @param \Magento\Framework\Config\CacheInterface $cache - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param string $cacheId @@ -84,7 +84,7 @@ class Config extends \Magento\Framework\Config\Data public function __construct( \Magento\Customer\Model\Address\Config\Reader $reader, \Magento\Framework\Config\CacheInterface $cache, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Helper\Address $addressHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, $cacheId = 'address_format' diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index 5ff0b776f02..d9525c50d0c 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -35,14 +35,14 @@ class Street extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Street extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index 5a20036fa9b..409ab4f8e72 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -37,14 +37,14 @@ class Customer extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ class Customer extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 1b1bfff634b..2f9f1a588ca 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -49,7 +49,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram */ protected $_customerResource; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @@ -58,7 +58,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -68,7 +68,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Resource\Customer $customerResource, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Converter.php b/app/code/Magento/Customer/Model/Converter.php index c3fec82385c..b9ba7ae2803 100644 --- a/app/code/Magento/Customer/Model/Converter.php +++ b/app/code/Magento/Customer/Model/Converter.php @@ -28,7 +28,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Customer\Service\V1\Data\CustomerBuilder as CustomerDataObjectBuilder; use Magento\Framework\Service\ExtensibleDataObjectConverter; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Customer Model converter. @@ -48,7 +48,7 @@ class Converter protected $_customerFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 06071b38d08..99cf6d6bdb8 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -138,7 +138,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel protected $_isReadonly = false; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -213,7 +213,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Customer\Helper\Data $customerData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Resource\Customer $resource @@ -233,7 +233,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Customer\Helper\Data $customerData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Resource\Customer $resource, diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php index 0025b504c93..da9753ef73e 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php @@ -31,15 +31,15 @@ namespace Magento\Customer\Model\Customer\Attribute\Backend; class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php index 81cc1e379b4..c8c99a5f958 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php @@ -31,15 +31,15 @@ namespace Magento\Customer\Model\Customer\Attribute\Backend; class Website extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Customer/Model/CustomerExtractor.php b/app/code/Magento/Customer/Model/CustomerExtractor.php index e82ec9b6215..f4f700e188b 100644 --- a/app/code/Magento/Customer/Model/CustomerExtractor.php +++ b/app/code/Magento/Customer/Model/CustomerExtractor.php @@ -40,7 +40,7 @@ class CustomerExtractor protected $customerBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -52,13 +52,13 @@ class CustomerExtractor /** * @param Metadata\FormFactory $formFactory * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param CustomerGroupServiceInterface $groupService */ public function __construct( \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, CustomerGroupServiceInterface $groupService ) { $this->formFactory = $formFactory; diff --git a/app/code/Magento/Customer/Model/CustomerRegistry.php b/app/code/Magento/Customer/Model/CustomerRegistry.php index 2cab8784bda..9b16df2d09b 100644 --- a/app/code/Magento/Customer/Model/CustomerRegistry.php +++ b/app/code/Magento/Customer/Model/CustomerRegistry.php @@ -26,7 +26,7 @@ namespace Magento\Customer\Model; use Magento\Customer\Model\CustomerFactory; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Registry for \Magento\Customer\Model\Customer @@ -51,7 +51,7 @@ class CustomerRegistry const REGISTRY_SEPARATOR = ':'; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; diff --git a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php index 530edc374c8..799eb75a951 100644 --- a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php +++ b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php @@ -56,7 +56,7 @@ class DepersonalizePlugin protected $moduleManager; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ protected $visitor; @@ -81,7 +81,7 @@ class DepersonalizePlugin * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Module\Manager $moduleManager - * @param \Magento\Log\Model\Visitor $visitor + * @param \Magento\Customer\Model\Visitor $visitor * @param \Magento\PageCache\Model\Config $cacheConfig */ public function __construct( @@ -90,7 +90,7 @@ class DepersonalizePlugin \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Module\Manager $moduleManager, - \Magento\Log\Model\Visitor $visitor, + \Magento\Customer\Model\Visitor $visitor, \Magento\PageCache\Model\Config $cacheConfig ) { $this->session = $session; diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php index 1dfefab91b2..15f5fababbb 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + abstract class AbstractData { /** @@ -284,8 +286,13 @@ abstract class AbstractData $label = $this->getAttribute()->getStoreLabel(); $validateRules = $this->getAttribute()->getValidationRules(); - if (!empty($validateRules['input_validation'])) { - switch ($validateRules['input_validation']) { + $inputValidation = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'input_validation' + ); + + if (!is_null($inputValidation)) { + switch ($inputValidation) { case 'alphanumeric': $validator = new \Zend_Validate_Alnum(true); $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID); diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Date.php b/app/code/Magento/Customer/Model/Metadata/Form/Date.php index d0ee99a639e..1a6580ccafd 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Date.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Date.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Date extends AbstractData { /** @@ -65,29 +67,37 @@ class Date extends AbstractData //range validation $validateRules = $attribute->getValidationRules(); - if (!empty($validateRules['date_range_min']) && strtotime( - $value - ) < $validateRules['date_range_min'] || !empty($validateRules['date_range_max']) && strtotime( - $value - ) > $validateRules['date_range_max'] + + $minDateValue = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'date_range_min' + ); + + $maxDateValue = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'date_range_max' + ); + + if (!is_null($minDateValue) && strtotime($value) < $minDateValue + || !is_null($maxDateValue) && strtotime($value) > $maxDateValue ) { - if (!empty($validateRules['date_range_min']) && !empty($validateRules['date_range_max'])) { + if (!is_null($minDateValue) && !is_null($maxDateValue)) { $errors[] = __( 'Please enter a valid date between %1 and %2 at %3.', - date('d/m/Y', $validateRules['date_range_min']), - date('d/m/Y', $validateRules['date_range_max']), + date('d/m/Y', $minDateValue), + date('d/m/Y', $maxDateValue), $label ); - } elseif (!empty($validateRules['date_range_min'])) { + } elseif (!is_null($minDateValue)) { $errors[] = __( 'Please enter a valid date equal to or greater than %1 at %2.', - date('d/m/Y', $validateRules['date_range_min']), + date('d/m/Y', $minDateValue), $label ); - } elseif (!empty($validateRules['date_range_max'])) { + } elseif (!is_null($maxDateValue)) { $errors[] = __( 'Please enter a valid date less than or equal to %1 at %2.', - date('d/m/Y', $validateRules['date_range_max']), + date('d/m/Y', $maxDateValue), $label ); } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php index abda9a3e1ed..0a7c45533c2 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/File.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class File extends AbstractData { /** @@ -147,9 +149,12 @@ class File extends AbstractData $label = $value['name']; $rules = $this->getAttribute()->getValidationRules(); $extension = pathinfo($value['name'], PATHINFO_EXTENSION); - - if (!empty($rules['file_extensions'])) { - $extensions = explode(',', $rules['file_extensions']); + $fileExtensions = ArrayObjectSearch::getArrayElementByName( + $rules, + 'file_extensions' + ); + if (!is_null($fileExtensions)) { + $extensions = explode(',', $fileExtensions); $extensions = array_map('trim', $extensions); if (!in_array($extension, $extensions)) { return array(__('"%1" is not a valid file extension.', $extension)); @@ -167,9 +172,13 @@ class File extends AbstractData return array(__('"%1" is not a valid file.', $label)); } - if (!empty($rules['max_file_size'])) { + $maxFileSize = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_file_size' + ); + if (!is_null($maxFileSize)) { $size = $value['size']; - if ($rules['max_file_size'] < $size) { + if ($maxFileSize < $size) { return array(__('"%1" exceeds the allowed file size.', $label)); } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Image.php b/app/code/Magento/Customer/Model/Metadata/Form/Image.php index fadd7f41f72..9f3b97397c1 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Image.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Image.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Image extends File { /** @@ -57,23 +59,36 @@ class Image extends File $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $allowImageTypes[$imageProp[2]]; } + $maxFileSize = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_file_size' + ); $errors = array(); - if (!empty($rules['max_file_size'])) { + if (!is_null($maxFileSize)) { $size = $value['size']; - if ($rules['max_file_size'] < $size) { + if ($maxFileSize < $size) { $errors[] = __('"%1" exceeds the allowed file size.', $label); } } - if (!empty($rules['max_image_width'])) { - if ($rules['max_image_width'] < $imageProp[0]) { - $r = $rules['max_image_width']; + $maxImageWidth = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_image_width' + ); + if (!is_null($maxImageWidth)) { + if ($maxImageWidth < $imageProp[0]) { + $r = $maxImageWidth; $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r); } } - if (!empty($rules['max_image_heght'])) { - if ($rules['max_image_heght'] < $imageProp[1]) { - $r = $rules['max_image_heght']; + + $maxImageHeight = ArrayObjectSearch::getArrayElementByName( + $rules, + 'max_image_height' + ); + if (!is_null($maxImageHeight)) { + if ($maxImageHeight < $imageProp[1]) { + $r = $maxImageHeight; $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r); } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Text.php b/app/code/Magento/Customer/Model/Metadata/Form/Text.php index 00b472c8077..d6accf1e5bf 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Text.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Text.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Framework\Service\ArrayObjectSearch; + class Text extends AbstractData { /** @@ -90,13 +92,21 @@ class Text extends AbstractData $length = $this->_string->strlen(trim($value)); $validateRules = $attribute->getValidationRules(); - if (!empty($validateRules['min_text_length']) && $length < $validateRules['min_text_length']->getValue()) { - $v = $validateRules['min_text_length']->getValue(); - $errors[] = __('"%1" length must be equal or greater than %2 characters.', $label, $v); + + $minTextLength = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'min_text_length' + ); + if (!is_null($minTextLength) && $length < $minTextLength) { + $errors[] = __('"%1" length must be equal or greater than %2 characters.', $label, $minTextLength); } - if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']->getValue()) { - $v = $validateRules['max_text_length']->getValue(); - $errors[] = __('"%1" length must be equal or less than %2 characters.', $label, $v); + + $maxTextLength = ArrayObjectSearch::getArrayElementByName( + $validateRules, + 'max_text_length' + ); + if (!is_null($maxTextLength) && $length > $maxTextLength) { + $errors[] = __('"%1" length must be equal or less than %2 characters.', $label, $maxTextLength); } $result = $this->_validateInputRule($value); diff --git a/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php b/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php index 23edc6cb58a..c16a8eca49a 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php +++ b/app/code/Magento/Customer/Model/Resource/Customer/CustomersTypeOptions.php @@ -35,8 +35,8 @@ class CustomersTypeOptions implements \Magento\Framework\Option\ArrayInterface public function toOptionArray() { return array( - \Magento\Log\Model\Visitor::VISITOR_TYPE_CUSTOMER => __('Customer'), - \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR => __('Visitor') + \Magento\Customer\Model\Visitor::VISITOR_TYPE_CUSTOMER => __('Customer'), + \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR => __('Visitor') ); } } diff --git a/app/code/Magento/Customer/Model/Resource/Visitor.php b/app/code/Magento/Customer/Model/Resource/Visitor.php new file mode 100644 index 00000000000..260bb66c547 --- /dev/null +++ b/app/code/Magento/Customer/Model/Resource/Visitor.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\Customer\Model\Resource; + +/** + * Class Visitor + * @package Magento\Customer\Model\Resource + */ +class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb +{ + /** + * Define main table + * + * @return void + */ + protected function _construct() + { + $this->_init('customer_visitor', 'visitor_id'); + } + + /** + * Prepare data for save + * + * @param \Magento\Framework\Model\AbstractModel $visitor + * @return array + */ + protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor) + { + return array( + 'session_id' => $visitor->getSessionId(), + ); + } +} diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 793aab1e8d6..6987d203578 100755 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -126,7 +126,6 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Framework\App\Http\Context $httpContext * @param Converter $converter * @param CustomerAccountServiceInterface $customerAccountService - * @param null $sessionName */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -147,8 +146,7 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Customer\Model\Converter $converter, - CustomerAccountServiceInterface $customerAccountService, - $sessionName = null + CustomerAccountServiceInterface $customerAccountService ) { $this->_coreUrl = $coreUrl; $this->_customerData = $customerData; @@ -170,7 +168,7 @@ class Session extends \Magento\Framework\Session\SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); $this->_converter = $converter; $this->_eventManager->dispatch('customer_session_init', array('customer_session' => $this)); } @@ -401,24 +399,6 @@ class Session extends \Magento\Framework\Session\SessionManager } } - /** - * Customer authorization - * - * @param string $username - * @param string $password - * @return bool - */ - public function login($username, $password) - { - try { - $customer = $this->_customerAccountService->authenticate($username, $password); - $this->setCustomerDataAsLoggedIn($customer); - return true; - } catch (\Exception $e) { - return false; - } - } - /** * @param Customer $customer * @return $this diff --git a/app/code/Magento/Customer/Model/Session/Storage.php b/app/code/Magento/Customer/Model/Session/Storage.php index 9f0c1bceb65..76e96ac03fa 100644 --- a/app/code/Magento/Customer/Model/Session/Storage.php +++ b/app/code/Magento/Customer/Model/Session/Storage.php @@ -29,13 +29,13 @@ class Storage extends \Magento\Framework\Session\Storage { /** * @param \Magento\Customer\Model\Config\Share $configShare - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param string $namespace * @param array $data */ public function __construct( \Magento\Customer\Model\Config\Share $configShare, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $namespace = 'customer', array $data = array() ) { diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php new file mode 100644 index 00000000000..242cdd822e7 --- /dev/null +++ b/app/code/Magento/Customer/Model/Visitor.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\Customer\Model; + +/** + * Class Visitor + * @package Magento\Customer\Model + */ +class Visitor extends \Magento\Framework\Model\AbstractModel +{ + const VISITOR_TYPE_CUSTOMER = 'c'; + + const VISITOR_TYPE_VISITOR = 'v'; + + /** + * @var string[] + */ + protected $ignoredUserAgents; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface + */ + protected $session; + + /** + * @var \Magento\Framework\HTTP\Header + */ + protected $httpHeader; + + /** + * @var bool + */ + protected $skipRequestLogging = false; + + /** + * Ignored Modules + * + * @var array + */ + protected $ignores; + + /** + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Framework\Session\SessionManagerInterface $session + * @param \Magento\Framework\HTTP\Header $httpHeader + * @param \Magento\Framework\Model\Resource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\Db $resourceCollection + * @param array $ignoredUserAgents + * @param array $ignores + * @param array $data + */ + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Session\SessionManagerInterface $session, + \Magento\Framework\HTTP\Header $httpHeader, + \Magento\Framework\Model\Resource\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\Db $resourceCollection = null, + array $ignoredUserAgents = array(), + array $ignores = array(), + $data = array() + ) { + $this->session = $session; + $this->httpHeader = $httpHeader; + $this->ignoredUserAgents = $ignoredUserAgents; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + $this->ignores = $ignores; + } + + /** + * Object initialization + * + * @return void + */ + protected function _construct() + { + $this->_init('Magento\Customer\Model\Resource\Visitor'); + $userAgent = $this->httpHeader->getHttpUserAgent(); + if ($this->ignoredUserAgents) { + if (in_array($userAgent, $this->ignoredUserAgents)) { + $this->skipRequestLogging = true; + } + } + } + + /** + * Skip request logging + * + * @param bool $skipRequestLogging + * @return \Magento\Customer\Model\Visitor + */ + public function setSkipRequestLogging($skipRequestLogging) + { + $this->skipRequestLogging = (bool)$skipRequestLogging; + return $this; + } + + /** + * Initialization visitor by request + * + * Used in event "controller_action_predispatch" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function initByRequest($observer) + { + if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) { + return $this; + } + if ($this->session->getVisitorData()) { + $this->setData($this->session->getVisitorData()); + } + if (!$this->getId()) { + $this->setSessionId($this->session->getSessionId()); + $this->save(); + $this->_eventManager->dispatch('visitor_init', array('visitor' => $this)); + $this->session->setVisitorData($this->getData()); + } + return $this; + } + + /** + * Save visitor by request + * + * Used in event "controller_action_postdispatch" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function saveByRequest($observer) + { + if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) { + return $this; + } + + try { + $this->save(); + $this->_eventManager->dispatch('visitor_activity_save', array('visitor' => $this)); + $this->session->setVisitorData($this->getData()); + } catch (\Exception $e) { + $this->_logger->logException($e); + } + return $this; + } + + /** + * Returns true if the module is required + * + * @param \Magento\Framework\Event\Observer $observer + * @return bool + */ + public function isModuleIgnored($observer) + { + if (is_array($this->ignores) && $observer) { + $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); + if (isset($this->ignores[$curModule])) { + return true; + } + } + return false; + } + + /** + * Bind customer data when customer login + * + * Used in event "customer_login" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindCustomerLogin($observer) + { + /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ + $customer = $observer->getEvent()->getCustomer(); + if (!$this->getCustomerId()) { + $this->setDoCustomerLogin(true); + $this->setCustomerId($customer->getId()); + } + return $this; + } + + /** + * Bind customer data when customer logout + * + * Used in event "customer_logout" + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function bindCustomerLogout($observer) + { + if ($this->getCustomerId()) { + $this->setDoCustomerLogout(true); + } + return $this; + } + + /** + * Create binding of checkout quote + * + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindQuoteCreate($observer) + { + $quote = $observer->getEvent()->getQuote(); + if ($quote) { + if ($quote->getIsCheckoutCart()) { + $this->setQuoteId($quote->getId()); + $this->setDoQuoteCreate(true); + } + } + return $this; + } + + /** + * Destroy binding of checkout quote + * @param \Magento\Framework\Event\Observer $observer + * @return \Magento\Customer\Model\Visitor + */ + public function bindQuoteDestroy($observer) + { + $quote = $observer->getEvent()->getQuote(); + if ($quote) { + $this->setDoQuoteDestroy(true); + } + return $this; + } +} diff --git a/app/code/Magento/Customer/Service/V1/AddressMetadataService.php b/app/code/Magento/Customer/Service/V1/AddressMetadataService.php index 6b7754efe17..fd526f96749 100644 --- a/app/code/Magento/Customer/Service/V1/AddressMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/AddressMetadataService.php @@ -29,6 +29,7 @@ use Magento\Customer\Service\V1\Data\Eav\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Service\Config\MetadataConfig; +use Magento\Framework\Service\SimpleDataObjectConverter; /** * Service to fetch customer address related custom attributes @@ -145,7 +146,7 @@ class AddressMetadataService implements AddressMetadataServiceInterface } foreach ($this->getAllAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $isDataObjectMethod = isset($this->addressDataObjectMethods['get' . $camelCaseKey]) || isset($this->addressDataObjectMethods['is' . $camelCaseKey]); diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php index e1c6efe1204..4000b68b0a5 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -51,7 +51,7 @@ use Magento\Framework\Service\V1\Data\Search\FilterGroup; use Magento\Framework\Service\V1\Data\SearchCriteria; use Magento\Framework\Service\V1\Data\SortOrder; use Magento\Framework\UrlInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Handle various customer account actions @@ -88,7 +88,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface private $eventManager; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; @@ -150,7 +150,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface /** * @param CustomerFactory $customerFactory * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Random $mathRandom * @param Converter $converter * @param Validator $validator diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php index 9f14aecfaa9..60bd524faf7 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php @@ -24,7 +24,7 @@ namespace Magento\Customer\Service\V1; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Group as CustomerGroupModel; use Magento\Customer\Model\GroupFactory; use Magento\Customer\Model\GroupRegistry; @@ -58,7 +58,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface private $_scopeConfig; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; @@ -90,7 +90,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface /** * @param GroupFactory $groupFactory * @param ScopeConfigInterface $scopeConfig - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Data\SearchResultsBuilder $searchResultsBuilder * @param Data\CustomerGroupBuilder $customerGroupBuilder * @param TaxClassServiceInterface $taxClassService @@ -246,7 +246,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId ); - } catch (\Magento\Framework\Model\Exception $e) { + } catch (\Magento\Framework\App\InitException $e) { throw NoSuchEntityException::singleField('storeId', $storeId); } try { diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php index c6aab6c9f9b..c2926abcaf5 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php @@ -52,7 +52,7 @@ interface CustomerGroupServiceInterface * * @param \Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria * @throws \Magento\Framework\Exception\InputException If there is a problem with the input - * @return \Magento\Customer\Service\V1\Data\SearchResults containing Data\CustomerGroup objects + * @return \Magento\Customer\Service\V1\Data\CustomerGroupSearchResults containing Data\CustomerGroup objects */ public function searchGroups(\Magento\Framework\Service\V1\Data\SearchCriteria $searchCriteria); diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 8d500fdd9bd..b37ac097871 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -29,6 +29,7 @@ use Magento\Customer\Service\V1\Data\Eav\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Service\Config\MetadataConfig; +use Magento\Framework\Service\SimpleDataObjectConverter; /** * Service to fetch customer related custom attributes @@ -146,7 +147,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface } foreach ($this->getAllAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($attributeCode); + $camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); $isDataObjectMethod = isset($this->customerDataObjectMethods['get' . $camelCaseKey]) || isset($this->customerDataObjectMethods['is' . $camelCaseKey]); diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadAuto.php b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php similarity index 72% rename from app/code/Magento/Install/Controller/Wizard/DownloadAuto.php rename to app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php index 5e178dc7c1a..4e2c8f70d06 100644 --- a/app/code/Magento/Install/Controller/Wizard/DownloadAuto.php +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResults.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,18 +21,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class DownloadAuto extends \Magento\Install\Controller\Wizard +namespace Magento\Customer\Service\V1\Data; + +/** + * SearchResults Service Data Object used for the search service requests + */ +class CustomerGroupSearchResults extends \Magento\Framework\Service\V1\Data\SearchResults { /** - * Download auto action + * Get items * - * @return void + * @return \Magento\Customer\Service\V1\Data\CustomerGroup[] */ - public function execute() + public function getItems() { - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); + return parent::getItems(); } } diff --git a/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php new file mode 100644 index 00000000000..a7cc9ad6026 --- /dev/null +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Service\V1\Data; + +use Magento\Framework\Service\Data\ObjectFactory; +use Magento\Framework\Service\V1\Data\SearchCriteriaBuilder; +use Magento\Framework\Service\V1\Data\AbstractSearchResultsBuilder; +use Magento\Framework\Service\Data\AttributeValueBuilder; +use Magento\Framework\Service\Data\MetadataServiceInterface; + +/** + * Builder for the SearchResults Service Data Object + * + * @method \Magento\Customer\Service\V1\Data\CustomerGroupSearchResults create() + */ +class CustomerGroupSearchResultsBuilder extends AbstractSearchResultsBuilder +{ + /** + * Constructor + * + * @param ObjectFactory $objectFactory + * @param AttributeValueBuilder $valueBuilder + * @param MetadataServiceInterface $metadataService + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param CustomerDetailsBuilder $itemObjectBuilder + */ + public function __construct( + ObjectFactory $objectFactory, + AttributeValueBuilder $valueBuilder, + MetadataServiceInterface $metadataService, + SearchCriteriaBuilder $searchCriteriaBuilder, + CustomerDetailsBuilder $itemObjectBuilder + ) { + parent::__construct( + $objectFactory, + $valueBuilder, + $metadataService, + $searchCriteriaBuilder, + $itemObjectBuilder + ); + } + + /** + * Set customer details items + * + * @param \Magento\Customer\Service\V1\Data\CustomerGroup[] $customerGroupItems + * @return $this + */ + public function setItems($customerGroupItems) + { + return parent::setItems($customerGroupItems); + } +} diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php index 8f86564c8e0..507bc29f52c 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverter.php @@ -86,21 +86,21 @@ class AttributeMetadataConverter $this->_attributeMetadataBuilder->setAttributeCode($attribute->getAttributeCode()) ->setFrontendInput($attribute->getFrontendInput()) - ->setInputFilter($attribute->getInputFilter()) + ->setInputFilter((string)$attribute->getInputFilter()) ->setStoreLabel($attribute->getStoreLabel()) ->setValidationRules($validationRules) - ->setVisible($attribute->getIsVisible()) - ->setRequired($attribute->getIsRequired()) - ->setMultilineCount($attribute->getMultilineCount()) - ->setDataModel($attribute->getDataModel()) + ->setVisible((boolean)$attribute->getIsVisible()) + ->setRequired((boolean)$attribute->getIsRequired()) + ->setMultilineCount((int)$attribute->getMultilineCount()) + ->setDataModel((string)$attribute->getDataModel()) ->setOptions($options) ->setFrontendClass($attribute->getFrontend()->getClass()) ->setFrontendLabel($attribute->getFrontendLabel()) + ->setNote((string)$attribute->getNote()) + ->setIsSystem((boolean)$attribute->getIsSystem()) + ->setIsUserDefined((boolean)$attribute->getIsUserDefined()) ->setBackendType($attribute->getBackendType()) - ->setNote($attribute->getNote()) - ->setIsSystem($attribute->getIsSystem()) - ->setIsUserDefined($attribute->getIsUserDefined()) - ->setSortOrder($attribute->getSortOrder()); + ->setSortOrder((int)$attribute->getSortOrder()); return $this->_attributeMetadataBuilder->create(); } diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 9423c2a5735..ecfc6424ec8 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,29 +3,28 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-newsletter": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-newsletter": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/acl.xml b/app/code/Magento/Customer/etc/acl.xml index 0544b9cd0e6..2c21ac3e63d 100644 --- a/app/code/Magento/Customer/etc/acl.xml +++ b/app/code/Magento/Customer/etc/acl.xml @@ -29,7 +29,6 @@ <resource id="Magento_Adminhtml::admin"> <resource id="Magento_Customer::customer" title="Customers" sortOrder="40"> <resource id="Magento_Customer::manage" title="All Customers" sortOrder="10" /> - <resource id="Magento_Customer::online" title="Now Online" sortOrder="20" /> </resource> <resource id="Magento_Adminhtml::stores"> <resource id="Magento_Adminhtml::stores_settings"> diff --git a/app/code/Magento/Customer/etc/adminhtml/di.xml b/app/code/Magento/Customer/etc/adminhtml/di.xml index 18759291cfb..cf67a2c6c8f 100644 --- a/app/code/Magento/Customer/etc/adminhtml/di.xml +++ b/app/code/Magento/Customer/etc/adminhtml/di.xml @@ -25,11 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Customer\Model\Customer" type="Magento\Customer\Model\Backend\Customer" /> - <type name="Magento\Customer\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Customer\Model\Resource\Customer\Collection"> <arguments> <argument name="modelName" xsi:type="string">Magento\Customer\Model\Backend\Customer</argument> diff --git a/app/code/Magento/Customer/etc/adminhtml/menu.xml b/app/code/Magento/Customer/etc/adminhtml/menu.xml index a924f1a5b82..e40abf8caca 100644 --- a/app/code/Magento/Customer/etc/adminhtml/menu.xml +++ b/app/code/Magento/Customer/etc/adminhtml/menu.xml @@ -27,7 +27,6 @@ <menu> <add id="Magento_Customer::customer" title="Customers" module="Magento_Customer" sortOrder="30" resource="Magento_Customer::customer"/> <add id="Magento_Customer::customer_manage" title="All Customers" module="Magento_Customer" sortOrder="10" parent="Magento_Customer::customer" action="customer/index/" resource="Magento_Customer::manage"/> - <add id="Magento_Customer::customer_group" title="Customer Groups" module="Magento_Customer" sortOrder="10" parent="Magento_Backend::other_settings" action="customer/group" resource="Magento_Customer::group"/> - <add id="Magento_Customer::customer_online" title="Now Online" module="Magento_Customer" sortOrder="30" parent="Magento_Customer::customer" action="customer/online" resource="Magento_Customer::online"/> + <add id="Magento_Customer::customer_group" title="Customer Groups" module="Magento_Customer" sortOrder="50" parent="Magento_Backend::other_settings" action="customer/group" resource="Magento_Customer::group"/> </menu> </config> diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index 63bb505e76d..f16fe029653 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -42,13 +42,6 @@ <source_model>Magento\Customer\Model\Config\Share</source_model> </field> </group> - <group id="online_customers" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0"> - <label>Online Customers Options</label> - <field id="online_minutes_interval" translate="label comment" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> - <label>Online Minutes Interval</label> - <comment>Leave empty for default (15 minutes).</comment> - </field> - </group> <group id="create_account" translate="label" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Create New Account Options</label> <field id="auto_group_assign" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index d0e5445bf49..fae0105f330 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -111,4 +111,13 @@ </argument> </arguments> </type> + <type name="Magento\Customer\Model\Visitor"> + <arguments> + <argument name="ignoredUserAgents" xsi:type="array"> + <item name="google1" xsi:type="string">Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</item> + <item name="google2" xsi:type="string">Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</item> + <item name="google3" xsi:type="string">Googlebot/2.1 (+http://www.googlebot.com/bot.html)</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index 3946f5ec328..d2f6c3bde88 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -24,11 +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\Customer\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/Customer/etc/frontend/events.xml b/app/code/Magento/Customer/etc/frontend/events.xml new file mode 100644 index 00000000000..2c360b2c573 --- /dev/null +++ b/app/code/Magento/Customer/etc/frontend/events.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/Event/etc/events.xsd"> + <event name="controller_action_predispatch"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="initByRequest" /> + </event> + <event name="controller_action_postdispatch"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="saveByRequest" /> + </event> + <event name="customer_data_object_login"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindCustomerLogin" /> + </event> + <event name="customer_logout"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindCustomerLogout" /> + </event> + <event name="sales_quote_save_after"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteCreate" /> + </event> + <event name="checkout_quote_destroy"> + <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteDestroy" /> + </event> +</config> diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 57366ea6e06..e50495d8ebb 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -41,7 +41,6 @@ <module name="Magento_Checkout"/> <module name="Magento_Wishlist"/> <module name="Magento_Index"/> - <module name="Magento_Log"/> <module name="Magento_Theme"/> <module name="Magento_Backend"/> <module name="Magento_Review"/> diff --git a/app/code/Magento/Customer/etc/webapi_rest/di.xml b/app/code/Magento/Customer/etc/webapi_rest/di.xml index 8eb5b6d92ba..265cd7ec07d 100644 --- a/app/code/Magento/Customer/etc/webapi_rest/di.xml +++ b/app/code/Magento/Customer/etc/webapi_rest/di.xml @@ -27,11 +27,6 @@ <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"> diff --git a/app/code/Magento/Customer/i18n/de_DE.csv b/app/code/Magento/Customer/i18n/de_DE.csv index 3e4beea4889..e138d63071c 100644 --- a/app/code/Magento/Customer/i18n/de_DE.csv +++ b/app/code/Magento/Customer/i18n/de_DE.csv @@ -124,7 +124,6 @@ Unknown,Unbekannt "Purchase Point","Gekauft von" Never,Niemals Offline,Offline -Online,Online Confirmed,Bestätigt "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -223,8 +222,6 @@ Visitor,Besucher "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers",Online-Kunden "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -354,8 +351,6 @@ Gender,Geschlecht "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 750c6cda247..f3ed0e19fb9 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -124,7 +124,6 @@ Unknown,Unknown "Purchase Point","Purchase Point" Never,Never Offline,Offline -Online,Online Confirmed,Confirmed "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitor "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Online Customers" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Gender "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/es_ES.csv b/app/code/Magento/Customer/i18n/es_ES.csv index c0299f4a923..6ee5727639a 100644 --- a/app/code/Magento/Customer/i18n/es_ES.csv +++ b/app/code/Magento/Customer/i18n/es_ES.csv @@ -124,7 +124,6 @@ Unknown,Desconocido "Purchase Point","Comprado a" Never,Nunca Offline,"Sin conexión" -Online,Conectado Confirmed,Confirmado "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitante "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Clientes conectados" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Género "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/fr_FR.csv b/app/code/Magento/Customer/i18n/fr_FR.csv index fd68872af3d..e32c2759c36 100644 --- a/app/code/Magento/Customer/i18n/fr_FR.csv +++ b/app/code/Magento/Customer/i18n/fr_FR.csv @@ -124,7 +124,6 @@ Unknown,Inconnu "Purchase Point","Acheté à " Never,Jamais Offline,"Hors ligne" -Online,"En ligne" Confirmed,Confirmé "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visiteur "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Utilisateurs en ligne" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Genre "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/nl_NL.csv b/app/code/Magento/Customer/i18n/nl_NL.csv index c4322feb692..bde6b074652 100644 --- a/app/code/Magento/Customer/i18n/nl_NL.csv +++ b/app/code/Magento/Customer/i18n/nl_NL.csv @@ -124,7 +124,6 @@ Unknown,Onbekend "Purchase Point","Gekocht van" Never,Nooit Offline,Offline -Online,Online Confirmed,Bevestigd "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Bezoeker "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Online Klanten" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Geslacht "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/pt_BR.csv b/app/code/Magento/Customer/i18n/pt_BR.csv index ade84e7110e..b02e6801702 100644 --- a/app/code/Magento/Customer/i18n/pt_BR.csv +++ b/app/code/Magento/Customer/i18n/pt_BR.csv @@ -124,7 +124,6 @@ Unknown,Desconhecido "Purchase Point","Comprado De" Never,Nunca Offline,Offline -Online,Online Confirmed,Confirmado "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,Visitante "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers","Clientes Conectados" "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,Sexo "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/i18n/zh_CN.csv b/app/code/Magento/Customer/i18n/zh_CN.csv index fab9fab5096..e344fa595c3 100644 --- a/app/code/Magento/Customer/i18n/zh_CN.csv +++ b/app/code/Magento/Customer/i18n/zh_CN.csv @@ -124,7 +124,6 @@ Unknown,未知 "Purchase Point","Purchase Point" Never,æ°¸ä¸ Offline,离线 -Online,在线 Confirmed,已确认 "Confirmation Required","Confirmation Required" "Confirmation Not Required","Confirmation Not Required" @@ -222,8 +221,6 @@ Visitor,访客 "An error occurred while resetting customer password.","An error occurred while resetting customer password." "A total of %1 record(s) were deleted.","A total of %1 record(s) were deleted." "Please select customer(s).","Please select customer(s)." -"Customers Now Online","Customers Now Online" -"Online Customers",在线客户 "No wishlist item ID is defined.","No wishlist item ID is defined." "Please load the wish list item.","Please load the wish list item." "PHP SOAP extension is required.","PHP SOAP extension is required." @@ -353,8 +350,6 @@ Gender,性别 "Customer Configuration","Customer Configuration" "Account Sharing Options","Account Sharing Options" "Share Customer Accounts","Share Customer Accounts" -"Online Customers Options","Online Customers Options" -"Online Minutes Interval","Online Minutes Interval" "Leave empty for default (15 minutes).","Leave empty for default (15 minutes)." "Create New Account Options","Create New Account Options" "Enable Automatic Assignment to Customer Group","Enable Automatic Assignment to Customer Group" diff --git a/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php b/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php index 943efd8259a..041ddc08a6b 100644 --- a/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php +++ b/app/code/Magento/Customer/sql/customer_setup/install-1.6.0.0.php @@ -1158,4 +1158,26 @@ $table = $installer->getConnection()->newTable( ); $installer->getConnection()->createTable($table); +/** + * Create table 'customer_visitor' + */ +$table = $installer->getConnection()->newTable( + $installer->getTable('customer_visitor') +)->addColumn( + 'visitor_id', + \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Visitor ID' +)->addColumn( + 'session_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 64, + array('nullable' => true, 'default' => null), + 'Session ID' +)->setComment( + 'Visitor Table' +); +$installer->getConnection()->createTable($table); + $installer->endSetup(); diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml index bf6b44f9c1b..03053ea4bd5 100644 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml +++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml @@ -30,7 +30,8 @@ <referenceContainer name="left"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tabs" name="customer_edit_tabs"> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View" name="customer_edit_tab_view" template="tab/view.phtml"> - <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales" name="sales" template="tab/view/sales.phtml" before="-"/> + <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo" name="personal_info" template="tab/view/personal_info.phtml"/> + <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales" name="sales" template="tab/view/sales.phtml"/> <block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion" name="accordion"/> </block> <action method="addTab"> diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml index 56fe8a46b00..95b09367f8e 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view.phtml @@ -21,64 +21,10 @@ * @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 + /** * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View */ -?> -<?php -$lastLoginDateAdmin = $this->getLastLoginDate(); -$lastLoginDateStore = $this->getStoreLastLoginDate(); - -$createDateAdmin = $this->getCreateDate(); -$createDateStore = $this->getStoreCreateDate(); -?> - -<div class="fieldset-wrapper customer-information"> - <div class="fieldset-wrapper-title"> - <span class="title"><?php echo __('Personal Information') ?></span> - </div> - <table class="data-table"> - <tbody> - <tr> - <th><?php echo __('Last Logged In:') ?></th> - <td><?php echo $lastLoginDateAdmin ?> (<?php echo $this->getCurrentStatus() ?>)</td> - </tr> - <?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> - <tr> - <th><?php echo __('Last Logged In (%1):', $this->getStoreLastLoginDateTimezone()) ?></th> - <td><?php echo $lastLoginDateStore ?> (<?php echo $this->getCurrentStatus() ?>)</td> - </tr> - <?php endif; ?> - <tr> - <th><?php echo __('Confirmed email:') ?></th> - <td><?php echo $this->getIsConfirmedStatus() ?></td> - </tr> - <tr> - <th><?php echo __('Account Created on:') ?></th> - <td><?php echo $createDateAdmin ?></td> - </tr> - <?php if ($createDateAdmin != $createDateStore): ?> - <tr> - <th><?php echo __('Account Created on (%1):', $this->getStoreCreateDateTimezone()) ?></th> - <td><?php echo $createDateStore ?></td> - </tr> - <?php endif; ?> - <tr> - <th><?php echo __('Account Created in:') ?></th> - <td><?php echo $this->getCreatedInStore() ?></td> - </tr> - <tr> - <th><?php echo __('Customer Group:') ?></th> - <td><?php echo $this->getGroupName() ?></td> - </tr> - </tbody> - </table> - <address> - <strong><?php echo __('Default Billing Address') ?></strong><br/> - <?php echo $this->getBillingAddressHtml() ?> - </address> -</div> -<?php echo $this->getChildHtml('', true); ?> +/** @var $this \Magento\Customer\Block\Adminhtml\Edit\Tab\View */ +echo $this->getChildHtml(); diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml new file mode 100644 index 00000000000..d065d51400b --- /dev/null +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml @@ -0,0 +1,69 @@ +<?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) + */ + +/** + * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Status\PersonalInfo + */ + +$createDateAdmin = $this->getCreateDate(); +$createDateStore = $this->getStoreCreateDate(); +?> + +<div class="fieldset-wrapper customer-information"> + <div class="fieldset-wrapper-title"> + <span class="title"><?php echo __('Personal Information') ?></span> + </div> + <table class="data-table"> + <tbody> + <?php echo $this->getChildHtml(); ?> + <tr> + <th><?php echo __('Confirmed email:') ?></th> + <td><?php echo $this->getIsConfirmedStatus() ?></td> + </tr> + <tr> + <th><?php echo __('Account Created on:') ?></th> + <td><?php echo $createDateAdmin ?></td> + </tr> + <?php if ($createDateAdmin != $createDateStore): ?> + <tr> + <th><?php echo __('Account Created on (%1):', $this->getStoreCreateDateTimezone()) ?></th> + <td><?php echo $createDateStore ?></td> + </tr> + <?php endif; ?> + <tr> + <th><?php echo __('Account Created in:') ?></th> + <td><?php echo $this->getCreatedInStore() ?></td> + </tr> + <tr> + <th><?php echo __('Customer Group:') ?></th> + <td><?php echo $this->getGroupName() ?></td> + </tr> + </tbody> + </table> + <address> + <strong><?php echo __('Default Billing Address') ?></strong><br/> + <?php echo $this->getBillingAddressHtml() ?> + </address> + +</div> diff --git a/app/code/Magento/CustomerImportExport/Model/Export/Address.php b/app/code/Magento/CustomerImportExport/Model/Export/Address.php index bd8929afe95..cde53e340c3 100644 --- a/app/code/Magento/CustomerImportExport/Model/Export/Address.php +++ b/app/code/Magento/CustomerImportExport/Model/Export/Address.php @@ -118,7 +118,7 @@ class Address extends \Magento\ImportExport\Model\Export\Entity\AbstractEav /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -130,7 +130,7 @@ class Address extends \Magento\ImportExport\Model\Export\Entity\AbstractEav */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php index 58bda0850c8..718cf7f4196 100644 --- a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php @@ -99,7 +99,7 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -109,7 +109,7 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php index 2af423a8098..97bd975cdee 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php @@ -92,7 +92,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -105,7 +105,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Address.php b/app/code/Magento/CustomerImportExport/Model/Import/Address.php index e685f184a64..cdf4fcd913d 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Address.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Address.php @@ -233,7 +233,7 @@ class Address extends AbstractCustomer * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -252,7 +252,7 @@ class Address extends AbstractCustomer \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 86a21879948..4977b6ddd2d 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -139,7 +139,7 @@ class Customer extends AbstractCustomer * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory @@ -154,7 +154,7 @@ class Customer extends AbstractCustomer \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\Resource\Import\Customer\StorageFactory $storageFactory, diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index 9760ec47fb6..b49fe86e51d 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,18 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/CustomerImportExport/etc/module.xml b/app/code/Magento/CustomerImportExport/etc/module.xml index c86315663dc..ad900498b03 100644 --- a/app/code/Magento/CustomerImportExport/etc/module.xml +++ b/app/code/Magento/CustomerImportExport/etc/module.xml @@ -31,7 +31,6 @@ <module name="Magento_Customer"/> <module name="Magento_Eav"/> <module name="Magento_ImportExport"/> - <module name="Magento_Store"/> <module name="Magento_Directory"/> </depends> </module> diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php index 889a71cb75d..e8c1c207390 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/AssignThemeToStore.php @@ -44,8 +44,8 @@ class AssignThemeToStore extends \Magento\DesignEditor\Controller\Adminhtml\Syst $defaultStore = -1; $emptyStores = -2; if ($stores == $defaultStore) { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); $ids = array_keys($storeManager->getStores()); $stores = array(array_shift($ids)); } elseif ($stores == $emptyStores) { diff --git a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php index 21dcd9aa839..2de881bb8c2 100644 --- a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php +++ b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php @@ -74,9 +74,8 @@ class Standard extends \Magento\Core\App\Router\Base * @param \Magento\Framework\App\DefaultPathInterface $defaultPath * @param \Magento\Framework\App\ResponseFactory $responseFactory * @param \Magento\Framework\App\Route\Config $routeConfig - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId @@ -95,9 +94,8 @@ class Standard extends \Magento\Core\App\Router\Base \Magento\Framework\App\DefaultPathInterface $defaultPath, \Magento\Framework\App\ResponseFactory $responseFactory, \Magento\Framework\App\Route\Config $routeConfig, - \Magento\Framework\App\State $appState, \Magento\Framework\UrlInterface $url, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, @@ -114,7 +112,6 @@ class Standard extends \Magento\Core\App\Router\Base $defaultPath, $responseFactory, $routeConfig, - $appState, $url, $storeManager, $scopeConfig, diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index 09692fa19f6..a45ad0cde17 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-url-rewrite": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-url-rewrite": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 7bd9e54369f..72e086e8620 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -168,7 +168,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin protected $_coreDate; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -221,7 +221,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Framework\Module\Dir\Reader $configReader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\String $string * @param \Magento\Framework\Math\Division $mathDivision * @param \Magento\Framework\App\Filesystem $filesystem @@ -248,7 +248,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin \Magento\Shipping\Helper\Carrier $carrierHelper, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Framework\Module\Dir\Reader $configReader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\String $string, \Magento\Framework\Math\Division $mathDivision, \Magento\Framework\App\Filesystem $filesystem, diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index ff8059e6830..f78d20be33e 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Directory/Controller/Currency/SwitchAction.php b/app/code/Magento/Directory/Controller/Currency/SwitchAction.php index c37f8e497c5..3d1af107658 100644 --- a/app/code/Magento/Directory/Controller/Currency/SwitchAction.php +++ b/app/code/Magento/Directory/Controller/Currency/SwitchAction.php @@ -31,8 +31,8 @@ class SwitchAction extends \Magento\Framework\App\Action\Action */ public function execute() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); $currency = (string)$this->getRequest()->getParam('currency'); if ($currency) { $storeManager->getStore()->setCurrentCurrencyCode($currency); diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php index fc182e6f199..a85dfddec4e 100644 --- a/app/code/Magento/Directory/Helper/Data.php +++ b/app/code/Magento/Directory/Helper/Data.php @@ -95,7 +95,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_coreHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -115,7 +115,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Directory\Model\Resource\Country\Collection $countryCollection * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regCollectionFactory, * @param \Magento\Core\Helper\Data $coreHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ @@ -125,7 +125,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Directory\Model\Resource\Country\Collection $countryCollection, \Magento\Directory\Model\Resource\Region\CollectionFactory $regCollectionFactory, \Magento\Core\Helper\Data $coreHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { diff --git a/app/code/Magento/Directory/Helper/Url.php b/app/code/Magento/Directory/Helper/Url.php index feabdfd5350..e093751a345 100644 --- a/app/code/Magento/Directory/Helper/Url.php +++ b/app/code/Magento/Directory/Helper/Url.php @@ -38,12 +38,12 @@ class Url extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData ) { $this->_coreData = $coreData; diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index d6a39c2e311..b0268d94464 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -61,7 +61,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel protected $_localeFormat; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Locale\FormatInterface $localeFormat - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Helper\Data $directoryHelper * @param Currency\FilterFactory $currencyFilterFactory * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency @@ -96,7 +96,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Locale\FormatInterface $localeFormat, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Directory\Model\Currency\FilterFactory $currencyFilterFactory, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, diff --git a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php index 74960b21ec1..bb8f6fccbc2 100644 --- a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php +++ b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php @@ -35,17 +35,17 @@ class DefaultLocator /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $configuration, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_configuration = $configuration; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Directory/Model/Currency/Filter.php b/app/code/Magento/Directory/Model/Currency/Filter.php index be2a4368648..6e5700f289b 100644 --- a/app/code/Magento/Directory/Model/Currency/Filter.php +++ b/app/code/Magento/Directory/Model/Currency/Filter.php @@ -49,7 +49,7 @@ class Filter implements \Zend_Filter_Interface protected $_localeFormat; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,14 +60,14 @@ class Filter implements \Zend_Filter_Interface /** * @param \Magento\Framework\Locale\FormatInterface $localeFormat - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param string $code * @param int $rate */ public function __construct( \Magento\Framework\Locale\FormatInterface $localeFormat, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, $code, $rate = 1 diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php index fd4ba63b2c2..b441a8781ef 100644 --- a/app/code/Magento/Directory/Model/Observer.php +++ b/app/code/Magento/Directory/Model/Observer.php @@ -61,7 +61,7 @@ class Observer protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,7 +79,7 @@ class Observer * @param \Magento\Directory\Model\Currency\Import\Factory $importFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation */ @@ -87,7 +87,7 @@ class Observer \Magento\Directory\Model\Currency\Import\Factory $importFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ) { diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index 99d76248942..e89210b81be 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -23,7 +23,7 @@ */ namespace Magento\Directory\Model; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Logger; /** @@ -32,7 +32,7 @@ use Magento\Framework\Logger; class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface { /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index e68271a1929..3a7c4476593 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php index 6a48e2440c8..7000fddc044 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php @@ -294,7 +294,7 @@ class Links extends \Magento\Backend\Block\Template if ($fileExist) { $name = '<a href="' . $this->getUrl( 'adminhtml/downloadable_product_edit/link', - array('id' => $item->getId(), '_secure' => true) + array('id' => $item->getId(), 'type' => 'link', '_secure' => true) ) . '">' . $fileHelper->getFileFromPathFile( $linkFile ) . '</a>'; @@ -316,10 +316,16 @@ class Links extends \Magento\Backend\Block\Template $fileExist = $fileHelper->ensureFileInFilesystem($file); if ($fileExist) { + $name = '<a href="' . $this->getUrl( + 'adminhtml/downloadable_product_edit/link', + array('id' => $item->getId(), 'type' => 'sample', '_secure' => true) + ) . '">' . $fileHelper->getFileFromPathFile( + $sampleFile + ) . '</a>'; $tmpLinkItem['sample_file_save'] = array( array( 'file' => $item->getSampleFile(), - 'name' => $fileHelper->getFileFromPathFile($sampleFile), + 'name' => $name, 'size' => $fileHelper->getFileSize($file), 'status' => 'old' ) diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php index 8fe24c383f0..65c2eaf7313 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Samples.php @@ -177,10 +177,16 @@ class Samples extends \Magento\Backend\Block\Widget $fileExist = $fileHelper->ensureFileInFilesystem($file); if ($fileExist) { + $name = '<a href="' . $this->getUrl( + 'adminhtml/downloadable_product_edit/sample', + array('id' => $item->getId(), '_secure' => true) + ) . '">' . $fileHelper->getFileFromPathFile( + $sampleFile + ) . '</a>'; $tmpSampleItem['file_save'] = array( array( 'file' => $sampleFile, - 'name' => $fileHelper->getFileFromPathFile($sampleFile), + 'name' => $name, 'size' => $fileHelper->getFileSize($file), 'status' => 'old' ) diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php index 468b2245c2f..bf17bfc37de 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Link.php @@ -98,22 +98,38 @@ class Link extends \Magento\Catalog\Controller\Adminhtml\Product\Edit public function execute() { $linkId = $this->getRequest()->getParam('id', 0); + $type = $this->getRequest()->getParam('type', 0); /** @var \Magento\Downloadable\Model\Link $link */ $link = $this->_createLink()->load($linkId); if ($link->getId()) { $resource = ''; $resourceType = ''; - if ($link->getLinkType() == DownloadHelper::LINK_TYPE_URL) { - $resource = $link->getLinkUrl(); - $resourceType = DownloadHelper::LINK_TYPE_URL; - } elseif ($link->getLinkType() == DownloadHelper::LINK_TYPE_FILE) { - $resource = $this->_objectManager->get( - 'Magento\Downloadable\Helper\File' - )->getFilePath( - $this->_getLink()->getBasePath(), - $link->getLinkFile() - ); - $resourceType = DownloadHelper::LINK_TYPE_FILE; + if ($type == 'link') { + if ($link->getLinkType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $link->getLinkUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($link->getLinkType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBasePath(), + $link->getLinkFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } + } else { + if ($link->getSampleType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $link->getSampleUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($link->getSampleType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBaseSamplePath(), + $link->getSampleFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } } try { $this->_processDownload($resource, $resourceType); @@ -121,6 +137,5 @@ class Link extends \Magento\Catalog\Controller\Adminhtml\Product\Edit $this->messageManager->addError(__('Something went wrong while getting the requested content.')); } } - exit(0); } } diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.php new file mode 100644 index 00000000000..7e92e41eac9 --- /dev/null +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/Sample.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\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\Downloadable\Helper\Download as DownloadHelper; + +class Sample extends \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link +{ + /** + * @return \Magento\Downloadable\Model\Sample + */ + protected function _createLink() + { + return $this->_objectManager->create('Magento\Downloadable\Model\Sample'); + } + + /** + * @return \Magento\Downloadable\Model\Sample + */ + protected function _getLink() + { + return $this->_objectManager->get('Magento\Downloadable\Model\Sample'); + } + + /** + * Download sample action + * + * @return void + */ + public function execute() + { + $sampleId = $this->getRequest()->getParam('id', 0); + /** @var \Magento\Downloadable\Model\Sample $sample */ + $sample = $this->_createLink()->load($sampleId); + if ($sample->getId()) { + $resource = ''; + $resourceType = ''; + if ($sample->getSampleType() == DownloadHelper::LINK_TYPE_URL) { + $resource = $sample->getSampleUrl(); + $resourceType = DownloadHelper::LINK_TYPE_URL; + } elseif ($sample->getSampleType() == DownloadHelper::LINK_TYPE_FILE) { + $resource = $this->_objectManager->get( + 'Magento\Downloadable\Helper\File' + )->getFilePath( + $this->_getLink()->getBasePath(), + $sample->getSampleFile() + ); + $resourceType = DownloadHelper::LINK_TYPE_FILE; + } + try { + $this->_processDownload($resource, $resourceType); + } catch (\Magento\Framework\Model\Exception $e) { + $this->messageManager->addError(__('Something went wrong while getting the requested content.')); + } + } + } +} diff --git a/app/code/Magento/Downloadable/Model/Resource/Link.php b/app/code/Magento/Downloadable/Model/Resource/Link.php index 01e173b9e0e..5c602b50b9d 100644 --- a/app/code/Magento/Downloadable/Model/Resource/Link.php +++ b/app/code/Magento/Downloadable/Model/Resource/Link.php @@ -48,7 +48,7 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_currencyFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -57,14 +57,14 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $configuration, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_catalogData = $catalogData; $this->_configuration = $configuration; diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 3d75efdf54e..b57f50f4d99 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index b2c0303adea..def7f690b71 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -84,7 +84,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -100,7 +100,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index c289d5d71e2..3df4e1509ca 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -97,7 +97,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel protected $_eavTypeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -117,7 +117,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -130,7 +130,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractModel \Magento\Core\Helper\Data $coreData, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php index e9fad9f11e2..a51cf76e66b 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php @@ -26,15 +26,15 @@ namespace Magento\Eav\Model\Entity\Attribute\Backend; class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; parent::__construct($logger); diff --git a/app/code/Magento/Eav/Model/Form.php b/app/code/Magento/Eav/Model/Form.php index 123fbc855ba..ba7f8593681 100644 --- a/app/code/Magento/Eav/Model/Form.php +++ b/app/code/Magento/Eav/Model/Form.php @@ -122,7 +122,7 @@ abstract class Form protected $_validator = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -157,7 +157,7 @@ abstract class Form protected $_validatorConfigFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Module\Dir\Reader $modulesReader * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory @@ -168,7 +168,7 @@ abstract class Form * @throws \Magento\Framework\Model\Exception */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Module\Dir\Reader $modulesReader, \Magento\Eav\Model\AttributeDataFactory $attrDataFactory, diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php index 137cc88a0ac..415c2b173da 100644 --- a/app/code/Magento/Eav/Model/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Form/Fieldset.php @@ -46,14 +46,14 @@ class Fieldset extends \Magento\Framework\Model\AbstractModel protected $_eventPrefix = 'eav_form_fieldset'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -61,7 +61,7 @@ class Fieldset extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php index c924148a9e1..c9f5205c1ca 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php @@ -57,7 +57,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C protected $_eavConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -67,7 +67,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -77,7 +77,7 @@ abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\C \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index db3dde8c4ef..e7d4999e435 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -43,7 +43,7 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb protected static $_entityAttributes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,12 +56,12 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb * Class constructor * * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Type $eavEntityType */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, Type $eavEntityType ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php index b8b92b7edc8..515e2ea7fc5 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php @@ -43,7 +43,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_coreResource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -53,7 +53,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\App\Resource $coreResource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -63,7 +63,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Resource $coreResource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php index 1f9ef354d78..c0d193e4048 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php @@ -59,7 +59,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_entityType; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -74,7 +74,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -84,7 +84,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php index 303d6cb1c6e..c736e52a7ca 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php @@ -36,7 +36,7 @@ use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Model\Resource\Db\AbstractDb; use Magento\Framework\Logger; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { @@ -57,7 +57,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param Logger $logger * @param FetchStrategyInterface $fetchStrategy * @param ManagerInterface $eventManager - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param AbstractDb $resource */ diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 11532e36489..7937cc3ea93 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index 4d3556ad196..f216daea288 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -87,7 +87,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn protected $_appEmulation; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -96,7 +96,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -104,7 +104,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_design = $design; diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index e55cfd3270d..d1461537582 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -40,7 +40,7 @@ class BackendTemplate extends Template * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\FileSystem $viewFileSystem @@ -57,7 +57,7 @@ class BackendTemplate extends Template \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\FileSystem $viewFileSystem, diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 2557b3263ee..41cce270d9a 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -25,7 +25,7 @@ namespace Magento\Email\Model; use Magento\Email\Model\Template\Filter; use Magento\Framework\Filter\Template as FilterTemplate; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; /** * Template model @@ -175,7 +175,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\View\FileSystem $viewFileSystem diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index 4bbe60dbf22..b58333b2b3e 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -88,7 +88,7 @@ class Filter extends \Magento\Framework\Filter\Template protected $_variableFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -135,7 +135,7 @@ class Filter extends \Magento\Framework\Filter\Template * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\VariableFactory $coreVariableFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\View\LayoutFactory $layoutFactory * @param \Magento\Framework\App\State $appState @@ -151,7 +151,7 @@ class Filter extends \Magento\Framework\Filter\Template \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\VariableFactory $coreVariableFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\App\State $appState, diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index b34bb25f2bf..f9d14e6c5a9 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 1daa81c68b1..0357d50e863 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -121,7 +121,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C protected $_customizableContainerTypes = array('YOUR_PACKAGING'); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -151,7 +151,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService * @param \Magento\Framework\Logger $logger - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Module\Dir\Reader $configReader * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param array $data @@ -174,7 +174,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C \Magento\Directory\Helper\Data $directoryData, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\Framework\Logger $logger, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Module\Dir\Reader $configReader, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, array $data = array() diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 90065ec7d11..852b8cd0614 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/Helper/Message.php b/app/code/Magento/GiftMessage/Helper/Message.php index 89f72ee85a9..31b0bb2ec4d 100644 --- a/app/code/Magento/GiftMessage/Helper/Message.php +++ b/app/code/Magento/GiftMessage/Helper/Message.php @@ -80,7 +80,7 @@ class Message extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -93,7 +93,7 @@ class Message extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/GiftMessage/Service/V1/WriteService.php b/app/code/Magento/GiftMessage/Service/V1/WriteService.php index e2831e8315a..b603464d644 100644 --- a/app/code/Magento/GiftMessage/Service/V1/WriteService.php +++ b/app/code/Magento/GiftMessage/Service/V1/WriteService.php @@ -37,7 +37,7 @@ class WriteService implements WriteServiceInterface protected $quoteRepository; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -58,14 +58,14 @@ class WriteService implements WriteServiceInterface /** * @param \Magento\Sales\Model\QuoteRepository $quoteRepository - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager * @param \Magento\GiftMessage\Helper\Message $helper * @param \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader */ public function __construct( \Magento\Sales\Model\QuoteRepository $quoteRepository, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\GiftMessage\Model\GiftMessageManager $giftMessageManager, \Magento\GiftMessage\Helper\Message $helper, \Magento\Catalog\Service\V1\Product\ProductLoader $productLoader diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 56ad6d81765..70536951d15 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-multishipping": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-multishipping": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index a8be39827c9..71158c07b85 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/Model/Observer.php b/app/code/Magento/GoogleAnalytics/Model/Observer.php index 5aebc6cd31f..4edcce47f58 100644 --- a/app/code/Magento/GoogleAnalytics/Model/Observer.php +++ b/app/code/Magento/GoogleAnalytics/Model/Observer.php @@ -44,17 +44,17 @@ class Observer protected $_layout; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\GoogleAnalytics\Helper\Data $googleAnalyticsData */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\GoogleAnalytics\Helper\Data $googleAnalyticsData ) { diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 42da737f20b..1d7cdd63d97 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 45eb649b57a..56f957632a5 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-google-analytics": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-google-analytics": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "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 74e74bb2929..85f0bae83ab 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -97,7 +97,7 @@ class Items extends \Magento\Backend\App\Action public function _getStore() { $store = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( (int)$this->getRequest()->getParam('store', 0) ); diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php index fa10e9f73a6..a59a4adf6c1 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php @@ -60,7 +60,7 @@ class Index extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\ 'adminhtml/*/', array( 'store' => $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), '_current' => true ) diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php index f4d3e8a2cee..068c00b7e61 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php @@ -114,9 +114,9 @@ class Types extends \Magento\Backend\App\Action { $storeId = (int)$this->getRequest()->getParam('store', 0); if ($storeId == 0) { - return $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getDefaultStoreView(); + return $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getDefaultStoreView(); } - return $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore($storeId); + return $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore($storeId); } /** diff --git a/app/code/Magento/GoogleShopping/Helper/Data.php b/app/code/Magento/GoogleShopping/Helper/Data.php index 08709495800..50fc41175da 100644 --- a/app/code/Magento/GoogleShopping/Helper/Data.php +++ b/app/code/Magento/GoogleShopping/Helper/Data.php @@ -40,19 +40,19 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\Stdlib\String $string - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\Stdlib\String $string, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->string = $string; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php index 81a8cbcc417..30253a5836f 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php @@ -56,7 +56,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -78,7 +78,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\GoogleShopping\Helper\Product $gsProduct * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService @@ -96,7 +96,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\GoogleShopping\Helper\Product $gsProduct, \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Helper\Data $taxData, \Magento\GoogleShopping\Model\Config $config, \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService, diff --git a/app/code/Magento/GoogleShopping/Model/Config.php b/app/code/Magento/GoogleShopping/Model/Config.php index 607debd2b43..252b032e681 100644 --- a/app/code/Magento/GoogleShopping/Model/Config.php +++ b/app/code/Magento/GoogleShopping/Model/Config.php @@ -47,7 +47,7 @@ class Config extends \Magento\Framework\Object /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -58,13 +58,13 @@ class Config extends \Magento\Framework\Object /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param array $data */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Encryption\EncryptorInterface $encryptor, array $data = array() ) { @@ -120,7 +120,7 @@ class Config extends \Magento\Framework\Object */ public function getAccountPassword($storeId = null) { - return $this->_encryptor->decrypt($this->getConfigData('password', $storeId)); + return $this->getConfigData('password', $storeId); } /** diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index 180aa443eee..498849c9ec9 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -50,7 +50,7 @@ class MassOperations /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -87,7 +87,7 @@ class MassOperations * @param \Magento\GoogleShopping\Model\ItemFactory $itemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\Notification\NotifierInterface $notifier - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\GoogleShopping\Helper\Data $gleShoppingData * @param \Magento\GoogleShopping\Helper\Category $gleShoppingCategory @@ -98,7 +98,7 @@ class MassOperations \Magento\GoogleShopping\Model\ItemFactory $itemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Notification\NotifierInterface $notifier, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\GoogleShopping\Helper\Data $gleShoppingData, \Magento\GoogleShopping\Helper\Category $gleShoppingCategory, diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 8b3c590709a..12d9330d129 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/etc/config.xml b/app/code/Magento/GoogleShopping/etc/config.xml index 7c040bdfcdb..0b461d386bf 100644 --- a/app/code/Magento/GoogleShopping/etc/config.xml +++ b/app/code/Magento/GoogleShopping/etc/config.xml @@ -300,6 +300,7 @@ <google_product_category /> <product_type /> </base_attributes> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> </googleshopping> </google> </default> diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index 5d10224499c..766e679ced6 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-import-export": "0.1.0-alpha94", - "magento/module-catalog-import-export": "0.1.0-alpha94", - "magento/module-grouped-product": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-import-export": "0.1.0-alpha95", + "magento/module-catalog-import-export": "0.1.0-alpha95", + "magento/module-grouped-product": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php index d6df970824f..71a160d088f 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php +++ b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php @@ -29,7 +29,7 @@ namespace Magento\GroupedProduct\Model\Product; class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -39,11 +39,11 @@ class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterfa protected $commonPriceModel; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index 154086e87ce..9308008bb7a 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -77,7 +77,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -105,7 +105,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\Logger $logger * @param \Magento\GroupedProduct\Model\Resource\Product\Link $catalogProductLink - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus * @param \Magento\Framework\App\State $appState * @param array $data @@ -124,7 +124,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType \Magento\Framework\Registry $coreRegistry, \Magento\Framework\Logger $logger, \Magento\GroupedProduct\Model\Resource\Product\Link $catalogProductLink, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus, \Magento\Framework\App\State $appState, array $data = array() diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php index 49d28eedeed..dfd18080b65 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php @@ -54,7 +54,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -79,7 +79,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\Resource\Produ \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 08d83fa0bc0..9058151754d 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/Helper/Data.php b/app/code/Magento/ImportExport/Helper/Data.php index 2fab16f07a5..b92bd27b0cc 100644 --- a/app/code/Magento/ImportExport/Helper/Data.php +++ b/app/code/Magento/ImportExport/Helper/Data.php @@ -47,7 +47,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\File\Size $fileSize @@ -56,7 +56,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\File\Size $fileSize, diff --git a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php index b94f98e7c11..ddf58edca29 100644 --- a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php @@ -49,7 +49,7 @@ abstract class AbstractEntity /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -174,14 +174,14 @@ abstract class AbstractEntity /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param array $data */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php index b9589a417b8..00ba2868914 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php @@ -77,7 +77,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Export\AbstractEn /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate @@ -86,7 +86,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Export\AbstractEn */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 4763d417ac9..8efcb89c5ad 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -157,7 +157,7 @@ abstract class AbstractEntity protected $_localeDate; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -165,13 +165,13 @@ abstract class AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_localeDate = $localeDate; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php index 35bbaf35742..919242d2962 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php @@ -36,7 +36,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -96,7 +96,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param array $data @@ -108,7 +108,7 @@ abstract class AbstractEav extends \Magento\ImportExport\Model\Import\AbstractEn \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, array $data = array() diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 6e31d471500..f2211bd9978 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-indexer": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-indexer": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/App/Indexer.php b/app/code/Magento/Index/App/Indexer.php index 5a9bd968aa8..530a44aceb2 100644 --- a/app/code/Magento/Index/App/Indexer.php +++ b/app/code/Magento/Index/App/Indexer.php @@ -26,6 +26,7 @@ namespace Magento\Index\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App; use Magento\Framework\AppInterface; class Indexer implements AppInterface @@ -96,4 +97,12 @@ class Indexer implements AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Index/App/Shell.php b/app/code/Magento/Index/App/Shell.php index e1489af69cd..0898d252943 100644 --- a/app/code/Magento/Index/App/Shell.php +++ b/app/code/Magento/Index/App/Shell.php @@ -26,6 +26,7 @@ namespace Magento\Index\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; use Magento\Framework\AppInterface; class Shell implements AppInterface @@ -76,4 +77,12 @@ class Shell implements AppInterface } return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 7e8a5dbe6d0..7eedb06bfd4 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/App/Indexer.php b/app/code/Magento/Indexer/App/Indexer.php index b09b2c12984..44fb9a96e73 100644 --- a/app/code/Magento/Indexer/App/Indexer.php +++ b/app/code/Magento/Indexer/App/Indexer.php @@ -23,6 +23,8 @@ */ namespace Magento\Indexer\App; +use Magento\Framework\App; + class Indexer implements \Magento\Framework\AppInterface { /** @@ -76,4 +78,12 @@ class Indexer implements \Magento\Framework\AppInterface return 0; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Indexer/App/Shell.php b/app/code/Magento/Indexer/App/Shell.php index b6ecaa5ecda..293668d7b3a 100644 --- a/app/code/Magento/Indexer/App/Shell.php +++ b/app/code/Magento/Indexer/App/Shell.php @@ -23,6 +23,8 @@ */ namespace Magento\Indexer\App; +use Magento\Framework\App\Bootstrap; + class Shell implements \Magento\Framework\AppInterface { /** @@ -74,4 +76,12 @@ class Shell implements \Magento\Framework\AppInterface } return $this->response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index bfd847402f0..866f2f5b127 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-page-cache": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-page-cache": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/App/Action/Plugin/Design.php b/app/code/Magento/Install/App/Action/Plugin/Design.php deleted file mode 100644 index d1b05d3e988..00000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Design.php +++ /dev/null @@ -1,99 +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\Install\App\Action\Plugin; - -use Magento\Framework\App\RequestInterface; - -class Design -{ - /** - * @var \Magento\Framework\App\RequestInterface - */ - protected $_request; - - /** - * @var \Magento\Framework\App\AreaList - */ - protected $_areaList; - - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - - /** - * @var \Magento\Framework\View\Design\Theme\ListInterface - */ - protected $_themeList; - - /** - * @var \Magento\Framework\View\DesignInterface - */ - protected $_viewDesign; - - /** - * @param RequestInterface $request - * @param \Magento\Framework\App\AreaList $areaList - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\View\DesignInterface $viewDesign - * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList - */ - public function __construct( - \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\AreaList $areaList, - \Magento\Framework\App\State $appState, - \Magento\Framework\View\DesignInterface $viewDesign, - \Magento\Framework\View\Design\Theme\ListInterface $themeList - ) { - $this->_viewDesign = $viewDesign; - $this->_themeList = $themeList; - $this->_request = $request; - $this->_areaList = $areaList; - $this->appState = $appState; - } - - /** - * Initialize design - * - * @param \Magento\Framework\App\ActionInterface $subject - * @param RequestInterface $request - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request) - { - $areaCode = $this->appState->getAreaCode(); - $area = $this->_areaList->getArea($areaCode); - $area->load(\Magento\Framework\App\Area::PART_CONFIG); - - $themePath = $this->_viewDesign->getConfigurationDesignTheme($areaCode); - $themeFullPath = $areaCode . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themePath; - $themeModel = $this->_themeList->getThemeByFullPath($themeFullPath); - $this->_viewDesign->setDesignTheme($themeModel); - - $area->detectDesign($this->_request); - $area->load(\Magento\Framework\App\Area::PART_TRANSLATE); - } -} diff --git a/app/code/Magento/Install/App/Action/Plugin/Dir.php b/app/code/Magento/Install/App/Action/Plugin/Dir.php deleted file mode 100644 index 83409bce18c..00000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Dir.php +++ /dev/null @@ -1,93 +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\Install\App\Action\Plugin; - -use Magento\Framework\App\Filesystem; -use Magento\Framework\Filesystem\FilesystemException; -use Magento\Framework\Filesystem\Directory\Write; -use Magento\Framework\App\State; -use Magento\Framework\Logger; - -class Dir -{ - /** - * Application state - * - * @var State - */ - protected $appState; - - /** - * Directory list - * - * @var Write - */ - protected $varDirectory; - - /** - * Logger - * - * @var Logger - */ - protected $logger; - - /** - * @param State $state - * @param Filesystem $filesystem - * @param Logger $logger - */ - public function __construct(State $state, Filesystem $filesystem, Logger $logger) - { - $this->appState = $state; - $this->varDirectory = $filesystem->getDirectoryWrite(Filesystem::VAR_DIR); - $this->logger = $logger; - } - - /** - * Clear temporary directories - * - * @param \Magento\Install\Controller\Index\Index $subject - * @param \Magento\Framework\App\RequestInterface $request - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeDispatch( - \Magento\Install\Controller\Index\Index $subject, - \Magento\Framework\App\RequestInterface $request - ) { - if (!$this->appState->isInstalled()) { - foreach ($this->varDirectory->read() as $dir) { - if ($this->varDirectory->isDirectory($dir)) { - try { - $this->varDirectory->delete($dir); - } catch (FilesystemException $exception) { - $this->logger->log($exception->getMessage()); - } - } - } - } - } -} diff --git a/app/code/Magento/Install/App/Action/Plugin/Install.php b/app/code/Magento/Install/App/Action/Plugin/Install.php deleted file mode 100644 index 3fc8581891b..00000000000 --- a/app/code/Magento/Install/App/Action/Plugin/Install.php +++ /dev/null @@ -1,87 +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\Install\App\Action\Plugin; - -class Install -{ - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Framework\App\ResponseInterface - */ - protected $_response; - - /** - * @var \Magento\Framework\UrlInterface - */ - protected $_url; - - /** - * @var \Magento\Framework\App\ActionFlag - */ - protected $_actionFlag; - - /** - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\App\ResponseInterface $response - * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\ActionFlag $actionFlag - */ - public function __construct( - \Magento\Framework\App\State $appState, - \Magento\Framework\App\ResponseInterface $response, - \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\ActionFlag $actionFlag - ) { - $this->_appState = $appState; - $this->_response = $response; - $this->_url = $url; - $this->_actionFlag = $actionFlag; - } - - /** - * Dispatch request - * - * @param \Magento\Framework\App\Action\Action $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * @return \Magento\Framework\App\ResponseInterface - */ - public function aroundDispatch( - \Magento\Framework\App\Action\Action $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - if (!$this->_appState->isInstalled()) { - $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true); - $this->_response->setRedirect($this->_url->getUrl('install')); - return $this->_response; - } - return $proceed($request); - } -} diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php index 9c9158fff81..37ecc5abf20 100644 --- a/app/code/Magento/Install/App/Console.php +++ b/app/code/Magento/Install/App/Console.php @@ -26,6 +26,7 @@ namespace Magento\Install\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; class Console implements \Magento\Framework\AppInterface { @@ -89,38 +90,14 @@ class Console implements \Magento\Framework\AppInterface $this->_loader = $loader; $this->_state = $state; $this->_installerFactory = $installerFactory; - $this->_arguments = $this->_buildInitArguments($arguments); + $this->_arguments = $arguments; $this->_output = $output; $this->_response = $response; $this->_objectManager = $objectManager; } /** - * Customize application init arguments - * - * @param array $args - * @return array - */ - protected function _buildInitArguments(array $args) - { - $directories = array(); - if (!empty($args[\Magento\Install\Model\Installer\Console::OPTION_URIS])) { - $uris = unserialize(base64_decode($args[\Magento\Install\Model\Installer\Console::OPTION_URIS])); - foreach ($uris as $code => $uri) { - $args[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS][$code]['uri'] = $uri; - } - } - if (!empty($args[\Magento\Install\Model\Installer\Console::OPTION_DIRS])) { - $dirs = unserialize(base64_decode($args[\Magento\Install\Model\Installer\Console::OPTION_DIRS])); - foreach ($dirs as $code => $dir) { - $args[\Magento\Framework\App\Filesystem::PARAM_APP_DIRS][$code]['path'] = $dir; - } - } - return $args; - } - - /** - * Install/Uninstall application + * Install application * * @param \Magento\Install\Model\Installer\Console $installer * @return void @@ -136,18 +113,11 @@ class Console implements \Magento\Framework\AppInterface $config = (array)include $this->_arguments['config']; $this->_arguments = array_merge((array)$config, $this->_arguments); } - $isUninstallMode = isset($this->_arguments['uninstall']); - if ($isUninstallMode) { - $result = $installer->uninstall(); - } else { - $result = $installer->install($this->_arguments); - } + + $result = $installer->install($this->_arguments); + if (!$installer->hasErrors()) { - if ($isUninstallMode) { - $msg = $result ? 'Uninstalled successfully' : 'Ignoring attempt to uninstall non-installed application'; - } else { - $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); - } + $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); $this->_output->success($msg . PHP_EOL); } else { $this->_output->error(implode(PHP_EOL, $installer->getErrors()) . PHP_EOL); @@ -164,15 +134,9 @@ class Console implements \Magento\Framework\AppInterface $areaCode = 'install'; $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_loader->load($areaCode)); - if (isset($this->_arguments['uninstall'])) { - $sessionConsole = $this->_objectManager->create('\Magento\Framework\Session\SessionConsole'); - $installerModel = $this->_objectManager - ->create('Magento\Install\Model\Installer', ['session' => $sessionConsole]); - $installer = $this->_installerFactory - ->create(['installArgs' => $this->_arguments, 'installer' => $installerModel]); - } else { - $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments)); - } + + /** @var \Magento\Install\Model\Installer\Console $installer */ + $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments)); if (isset($this->_arguments['show_locales'])) { $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableLocales())); @@ -197,4 +161,12 @@ class Console implements \Magento\Framework\AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Install/Controller/Wizard.php b/app/code/Magento/Install/Controller/Wizard.php deleted file mode 100644 index 3957dd78c5d..00000000000 --- a/app/code/Magento/Install/Controller/Wizard.php +++ /dev/null @@ -1,167 +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\Install\Controller; - -use Magento\Framework\App\RequestInterface; - -/** - * Installation wizard controller - */ -class Wizard extends \Magento\Framework\App\Action\Action -{ - /** - * Application state - * - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * Installer Model - * - * @var \Magento\Install\Model\Installer - */ - protected $_installer; - - /** - * Install Wizard - * - * @var \Magento\Install\Model\Wizard - */ - protected $_wizard; - - /** - * Install Session - * - * @var \Magento\Framework\Session\Generic - */ - protected $_session; - - /** - * DB Updater - * - * @var \Magento\Framework\Module\UpdaterInterface - */ - protected $_dbUpdater; - - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Config\Scope $configScope - * @param \Magento\Install\Model\Installer $installer - * @param \Magento\Install\Model\Wizard $wizard - * @param \Magento\Framework\Session\Generic $session - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState - */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Config\Scope $configScope, - \Magento\Install\Model\Installer $installer, - \Magento\Install\Model\Wizard $wizard, - \Magento\Framework\Session\Generic $session, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState - ) { - $this->_storeManager = $storeManager; - parent::__construct($context); - $configScope->setCurrentScope('install'); - $this->_installer = $installer; - $this->_wizard = $wizard; - $this->_session = $session; - $this->_dbUpdater = $dbUpdater; - $this->_appState = $appState; - } - - /** - * Perform necessary checks for all actions - * - * Redirect out if system is already installed - * Throw a bootstrap exception if page cannot be displayed due to mis-configured base directories - * - * @param RequestInterface $request - * @return \Magento\Framework\App\ResponseInterface - */ - public function dispatch(RequestInterface $request) - { - if ($this->_appState->isInstalled()) { - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); - $this->_redirect('/'); - } - return parent::dispatch($request); - } - - /** - * Retrieve installer object - * - * @return \Magento\Install\Model\Installer - */ - protected function _getInstaller() - { - return $this->_installer; - } - - /** - * Retrieve wizard - * - * @return \Magento\Install\Model\Wizard - */ - protected function _getWizard() - { - return $this->_wizard; - } - - /** - * Prepare layout - * - * @return $this - */ - protected function _prepareLayout() - { - $this->_view->loadLayout('install_wizard'); - $step = $this->_getWizard()->getStepByRequest($this->getRequest()); - if ($step) { - $step->setActive(true); - } - - $this->_view->getLayout()->addBlock('Magento\Install\Block\State', 'install.state', 'left'); - return $this; - } - - /** - * Checking installation status - * - * @return bool - * @SuppressWarnings(PHPMD.ExitExpression) - */ - protected function _checkIfInstalled() - { - if ($this->_getInstaller()->isApplicationInstalled()) { - $this->getResponse()->setRedirect($this->_storeManager->getStore()->getBaseUrl())->sendResponse(); - exit; - } - return true; - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php b/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php deleted file mode 100644 index eb8054d751b..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/AdministratorPost.php +++ /dev/null @@ -1,57 +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\Install\Controller\Wizard; - -class AdministratorPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process administrator installation POST data - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - - $step = $this->_wizard->getStepByName('administrator'); - $adminData = $this->getRequest()->getPost('admin'); - $encryptionKey = $this->getRequest()->getPost('encryption_key'); - - try { - $encryptionKey = $this->_getInstaller()->getValidEncryptionKey($encryptionKey); - $this->_getInstaller()->createAdministrator($adminData); - $this->_getInstaller()->installEncryptionKey($encryptionKey); - $this->getResponse()->setRedirect($step->getNextUrl()); - } catch (\Exception $e) { - $this->_session->setAdminData($adminData); - if ($e instanceof \Magento\Framework\Model\Exception) { - $this->messageManager->addMessages($e->getMessages()); - } else { - $this->messageManager->addError($e->getMessage()); - } - $this->getResponse()->setRedirect($step->getUrl()); - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Config.php b/app/code/Magento/Install/Controller/Wizard/Config.php deleted file mode 100644 index eed5fe1e447..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/Config.php +++ /dev/null @@ -1,53 +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\Install\Controller\Wizard; - -class Config extends \Magento\Install\Controller\Wizard -{ - /** - * Configuration data installation - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $this->_getInstaller()->checkServer(); - - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $data = $this->getRequest()->getQuery('config'); - if ($data) { - $this->_session->setLocaleData($data); - } - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Config', 'install.config', 'content'); - - $this->_view->renderLayout(); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/ConfigPost.php b/app/code/Magento/Install/Controller/Wizard/ConfigPost.php deleted file mode 100644 index 725f4c1ebb6..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/ConfigPost.php +++ /dev/null @@ -1,65 +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\Install\Controller\Wizard; - -use \Magento\Framework\App\ResponseInterface; - -class ConfigPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process configuration POST data - * - * @return ResponseInterface|void - */ - public function execute() - { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('config'); - - $config = $this->getRequest()->getPost('config'); - $connectionConfig = $this->getRequest()->getPost('connection'); - - if ($config && $connectionConfig && isset($connectionConfig[$config['db_model']])) { - - $data = array_merge($config, $connectionConfig[$config['db_model']]); - - $this->_session->setConfigData( - $data - )->setSkipUrlValidation( - $this->getRequest()->getPost('skip_url_validation') - )->setSkipBaseUrlValidation( - $this->getRequest()->getPost('skip_base_url_validation') - ); - try { - $this->_getInstaller()->installConfig($data); - return $this->_redirect('*/*/installDb'); - } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); - $this->getResponse()->setRedirect($step->getUrl()); - } - } - $this->getResponse()->setRedirect($step->getUrl()); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadPost.php b/app/code/Magento/Install/Controller/Wizard/DownloadPost.php deleted file mode 100644 index 794557e3a04..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/DownloadPost.php +++ /dev/null @@ -1,56 +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\Install\Controller\Wizard; - -class DownloadPost extends \Magento\Install\Controller\Wizard -{ - /** - * Download post action - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - switch ($this->getRequest()->getPost('continue')) { - case 'auto': - $this->_forward('downloadAuto'); - break; - - case 'manual': - $this->_forward('downloadManual'); - break; - - case 'svn': - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); - break; - - default: - $this->_redirect('*/*/download'); - break; - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Install.php b/app/code/Magento/Install/Controller/Wizard/Install.php deleted file mode 100644 index be896613ba6..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/Install.php +++ /dev/null @@ -1,83 +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\Install\Controller\Wizard; - -class Install extends \Magento\Install\Controller\Wizard -{ - /** - * Install success callback - * - * @return void - */ - public function installSuccessCallback() - { - echo 'parent.installSuccess()'; - } - - /** - * Install failure callback - * - * @return void - */ - public function installFailureCallback() - { - echo 'parent.installFailure()'; - } - - /** - * Install action - * - * @return void - * @SuppressWarnings(PHPMD.ExitExpression) - */ - public function execute() - { - $pear = \Magento\Framework\Pear::getInstance(); - $params = array('comment' => __("Downloading and installing Magento, please wait...") . "\r\n\r\n"); - if ($this->getRequest()->getParam('do')) { - $state = $this->getRequest()->getParam('state', 'beta'); - if ($state) { - $result = $pear->runHtmlConsole( - array( - 'comment' => __("Setting preferred state to: %1", $state) . "\r\n\r\n", - 'command' => 'config-set', - 'params' => array('preferred_state', $state) - ) - ); - if ($result instanceof PEAR_Error) { - $this->installFailureCallback(); - exit; - } - } - $params['command'] = 'install'; - $params['options'] = array('onlyreqdeps' => 1); - $params['params'] = $this->_objectManager->get('Magento\Install\Model\Installer\Pear')->getPackages(); - $params['success_callback'] = array($this, 'installSuccessCallback'); - $params['failure_callback'] = array($this, 'installFailureCallback'); - } - $pear->runHtmlConsole($params); - $this->getResponse()->clearAllHeaders(); - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/InstallDb.php b/app/code/Magento/Install/Controller/Wizard/InstallDb.php deleted file mode 100644 index 07a7f9fe176..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/InstallDb.php +++ /dev/null @@ -1,54 +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\Install\Controller\Wizard; - -class InstallDb extends \Magento\Install\Controller\Wizard -{ - /** - * Install DB - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('config'); - try { - $this->_getInstaller()->installDb(); - /** - * Clear session config data - */ - $this->_session->getConfigData(true); - - $this->_storeManager->getStore()->resetConfig(); - $this->_dbUpdater->updateData(); - - $this->getResponse()->setRedirect($step->getNextUrl()); - } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); - $this->getResponse()->setRedirect($step->getUrl()); - } - } -} diff --git a/app/code/Magento/Install/Controller/Wizard/Locale.php b/app/code/Magento/Install/Controller/Wizard/Locale.php deleted file mode 100644 index 6cd04ddec47..00000000000 --- a/app/code/Magento/Install/Controller/Wizard/Locale.php +++ /dev/null @@ -1,46 +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\Install\Controller\Wizard; - -class Locale extends \Magento\Install\Controller\Wizard -{ - /** - * Localization settings - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Locale', 'install.locale', 'content'); - $this->_view->getLayout()->getBlock('install.locale')->setLocaleCode($this->_session->getLocale()); - $this->_view->renderLayout(); - } -} diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php index dbd71b9cffd..5d5984ce81e 100644 --- a/app/code/Magento/Install/Model/Installer.php +++ b/app/code/Magento/Install/Model/Installer.php @@ -38,7 +38,7 @@ class Installer extends \Magento\Framework\Object /** * DB updated model * - * @var \Magento\Framework\Module\UpdaterInterface + * @var \Magento\Framework\Module\Updater */ protected $_dbUpdater; @@ -102,7 +102,7 @@ class Installer extends \Magento\Framework\Object /** * Store Manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -183,7 +183,7 @@ class Installer extends \Magento\Framework\Object /** * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater + * @param \Magento\Framework\Module\Updater $dbUpdater * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Cache\StateInterface $cacheState @@ -191,7 +191,7 @@ class Installer extends \Magento\Framework\Object * @param \Magento\Framework\App\Arguments $arguments * @param \Magento\Framework\App\AreaList $areaList * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\User\Model\UserFactory $userModelFactory * @param Installer\Filesystem $filesystem * @param Installer\Pear $installerPear @@ -210,7 +210,7 @@ class Installer extends \Magento\Framework\Object */ public function __construct( \Magento\Framework\App\Config\ReinitableConfigInterface $config, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, + \Magento\Framework\Module\Updater $dbUpdater, \Magento\Framework\App\CacheInterface $cache, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Cache\StateInterface $cacheState, @@ -218,7 +218,7 @@ class Installer extends \Magento\Framework\Object \Magento\Framework\App\Arguments $arguments, \Magento\Framework\App\AreaList $areaList, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\User\Model\UserFactory $userModelFactory, \Magento\Install\Model\Installer\Filesystem $filesystem, \Magento\Install\Model\Installer\Pear $installerPear, @@ -262,16 +262,6 @@ class Installer extends \Magento\Framework\Object parent::__construct($data); } - /** - * Checking install status of application - * - * @return bool - */ - public function isApplicationInstalled() - { - return $this->_appState->isInstalled(); - } - /** * Get data model * @@ -376,7 +366,8 @@ class Installer extends \Magento\Framework\Object $data = $this->_installerDb->checkDbConnectionData($data); - $this->_installerConfig->setConfigData($data)->install(); + $data = $this->_installerConfig->install($data); + $this->getDataModel()->setConfigData($data); $this->_arguments->reload(); $this->_resource->setTablePrefix($data['db_prefix']); @@ -416,12 +407,18 @@ class Installer extends \Magento\Framework\Object $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl('web'); if (!empty($data['unsecure_base_url'])) { $unsecureBaseUrl = $data['unsecure_base_url']; - $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl); + $this->_installSetup->setConfigData( + \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, + $unsecureBaseUrl + ); } if (!empty($data['use_secure'])) { $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND, 1); - $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']); + $this->_installSetup->setConfigData( + \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, + $data['secure_base_url'] + ); if (!empty($data['use_secure_admin'])) { $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, 1); } @@ -440,7 +437,10 @@ class Installer extends \Magento\Framework\Object $this->_installSetup->setConfigData($this->_localeDate->getDefaultTimezonePath(), $locale['timezone']); } if (!empty($locale['currency'])) { - $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, $locale['currency']); + $this->_installSetup->setConfigData( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, + $locale['currency'] + ); $this->_installSetup->setConfigData( \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency'] diff --git a/app/code/Magento/Install/Model/Installer/AbstractInstaller.php b/app/code/Magento/Install/Model/Installer/AbstractInstaller.php deleted file mode 100644 index 533e052cf6b..00000000000 --- a/app/code/Magento/Install/Model/Installer/AbstractInstaller.php +++ /dev/null @@ -1,107 +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) - */ - - -/** - * Abstract installer model - * - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Install\Model\Installer; - -class AbstractInstaller -{ - /** - * Installer model - * - * @var \Magento\Install\Model\Installer - */ - protected $installer; - - /** - * @param \Magento\Install\Model\Installer $installer - */ - public function __construct(\Magento\Install\Model\Installer $installer) - { - $this->_installer = $installer; - } - - /** - * Installer singleton - * - * @var \Magento\Install\Model\Installer - */ - protected $_installer; - - /** - * Get installer singleton - * - * @return \Magento\Install\Model\Installer - */ - protected function _getInstaller() - { - return $this->_installer; - } - - /** - * Validate session storage value (files or db) - * If empty, will return 'files' - * - * @param string $value - * @return string - * @throws \Exception - */ - protected function _checkSessionSave($value) - { - if (empty($value)) { - return 'files'; - } - if (!in_array($value, array('files', 'db'), true)) { - throw new \Exception('session_save value must be "files" or "db".'); - } - return $value; - } - - /** - * Validate backend area frontname value. - * If empty, "backend" will be returned - * - * @param string $value - * @return string - * @throws \Exception - */ - protected function _checkBackendFrontname($value) - { - if (empty($value)) { - return 'backend'; - } - if (!preg_match('/^[a-z]+[a-z0-9_]+$/', $value)) { - throw new \Exception( - 'backend_frontname value must contain only letters (a-z), numbers (0-9)' . - ' or underscore(_), first character should be a letter.' - ); - } - return $value; - } -} diff --git a/app/code/Magento/Install/Model/Installer/Config.php b/app/code/Magento/Install/Model/Installer/Config.php index 1311d7d9a08..a8940519f1e 100644 --- a/app/code/Magento/Install/Model/Installer/Config.php +++ b/app/code/Magento/Install/Model/Installer/Config.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * Config installer */ -class Config extends \Magento\Install\Model\Installer\AbstractInstaller +class Config { const TMP_INSTALL_DATE_VALUE = 'd-d-d-d-d'; @@ -44,11 +44,6 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $_request; - /** - * @var array - */ - protected $_configData = array(); - /** * @var \Magento\Framework\App\Filesystem */ @@ -67,7 +62,7 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller /** * Store Manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -77,20 +72,17 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->_request = $request; $this->_storeManager = $storeManager; $this->_filesystem = $filesystem; @@ -99,35 +91,14 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller $this->messageManager = $messageManager; } - /** - * @param array $data - * @return $this - */ - public function setConfigData($data) - { - if (is_array($data)) { - $this->_configData = $data; - } - return $this; - } - - /** - * @return array - */ - public function getConfigData() - { - return $this->_configData; - } - /** * Generate installation data and record them into local.xml using local.xml.template * - * @return void + * @param array $config + * @return array */ - public function install() + public function install($config) { - $data = $this->getConfigData(); - $defaults = array( 'root_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR), 'app_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::APP_DIR), @@ -135,46 +106,46 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller 'base_url' => $this->_request->getDistroBaseUrl() ); foreach ($defaults as $index => $value) { - if (!isset($data[$index])) { - $data[$index] = $value; + if (!isset($config[$index])) { + $config[$index] = $value; } } - if (isset($data['unsecure_base_url'])) { - $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : ''; - if (strpos($data['unsecure_base_url'], 'http') !== 0) { - $data['unsecure_base_url'] = 'http://' . $data['unsecure_base_url']; + if (isset($config['unsecure_base_url'])) { + $config['unsecure_base_url'] .= substr($config['unsecure_base_url'], -1) != '/' ? '/' : ''; + if (strpos($config['unsecure_base_url'], 'http') !== 0) { + $config['unsecure_base_url'] = 'http://' . $config['unsecure_base_url']; } - if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) { - $this->_checkUrl($data['unsecure_base_url']); + if (empty($config['skip_base_url_validation'])) { + $this->_checkUrl($config['unsecure_base_url']); } } - if (isset($data['secure_base_url'])) { - $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : ''; - if (strpos($data['secure_base_url'], 'http') !== 0) { - $data['secure_base_url'] = 'https://' . $data['secure_base_url']; + if (isset($config['secure_base_url'])) { + $config['secure_base_url'] .= substr($config['secure_base_url'], -1) != '/' ? '/' : ''; + if (strpos($config['secure_base_url'], 'http') !== 0) { + $config['secure_base_url'] = 'https://' . $config['secure_base_url']; } - if (!empty($data['use_secure']) && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) { - $this->_checkUrl($data['secure_base_url']); + if (!empty($config['use_secure']) && empty($config['skip_url_validation'])) { + $this->_checkUrl($config['secure_base_url']); } } - $data['date'] = self::TMP_INSTALL_DATE_VALUE; - $data['key'] = self::TMP_ENCRYPT_KEY_VALUE; - $data['var_dir'] = $data['root_dir'] . '/var'; + $config['date'] = self::TMP_INSTALL_DATE_VALUE; + $config['key'] = self::TMP_ENCRYPT_KEY_VALUE; + $config['var_dir'] = $config['root_dir'] . '/var'; - $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false'; - - $this->_getInstaller()->getDataModel()->setConfigData($data); + $config['use_script_name'] = isset($config['use_script_name']) ? 'true' : 'false'; $contents = $this->_configDirectory->readFile('local.xml.template'); - foreach ($data as $index => $value) { + foreach ($config as $index => $value) { $contents = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $contents); } $this->_configDirectory->writeFile($this->_localConfigFile, $contents); $this->_configDirectory->changePermissions($this->_localConfigFile, 0777); + + return $config; } /** diff --git a/app/code/Magento/Install/Model/Installer/Console.php b/app/code/Magento/Install/Model/Installer/Console.php index 4016b8f1a7b..f2f0fdd6ae2 100644 --- a/app/code/Magento/Install/Model/Installer/Console.php +++ b/app/code/Magento/Install/Model/Installer/Console.php @@ -27,21 +27,8 @@ */ namespace Magento\Install\Model\Installer; -use Magento\Framework\App\Filesystem as AppFilesystem; -use Magento\Framework\Filesystem\FilesystemException; -use Magento\Framework\Message\MessageInterface; - -class Console extends \Magento\Install\Model\Installer\AbstractInstaller +class Console { - /**#@+ - * Installation options for application initialization - */ - const OPTION_URIS = 'install_option_uris'; - - const OPTION_DIRS = 'install_option_dirs'; - - /**#@- */ - /** * Available installation options * @@ -49,13 +36,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $installParameters = []; - /** - * Stores errors on file delete - * - * @var array - */ - protected $fileDeleteErrors = []; - /** * Required parameters with descriptions * @@ -100,11 +80,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller 'cleanup_database' => 'Clean up database before installation. Flag value. Disabled by default' ]; - /** - * @var AppFilesystem - */ - protected $_filesystem; - /** * Installer data model to store data between installations steps * @@ -113,16 +88,16 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller protected $_dataModel; /** - * Resource config + * Installer model * - * @var \Magento\Framework\App\Resource\Config + * @var \Magento\Install\Model\Installer */ - protected $_resourceConfig; + protected $installer; /** * DB updater * - * @var \Magento\Framework\Module\UpdaterInterface + * @var \Magento\Framework\Module\Updater */ protected $_dbUpdater; @@ -133,13 +108,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ protected $_installerData = null; - /** - * Application State - * - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * Locale Lists * @@ -150,40 +118,39 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller /** * Magento Object Manager * - * @var \Magento\Framework\ObjectManager + * @var \Magento\Framework\Message\ManagerInterface + */ + protected $messageManager; + + /** + * @var \Magento\Install\Model\Installer\Db\Mysql4 */ - protected $_objectManager; + protected $db; /** * @param \Magento\Install\Model\Installer $installer - * @param \Magento\Framework\App\Resource\Config $resourceConfig - * @param \Magento\Framework\Module\UpdaterInterface $dbUpdater - * @param AppFilesystem $filesystem + * @param \Magento\Framework\Module\Updater $dbUpdater * @param \Magento\Install\Model\Installer\Data $installerData - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Locale\ListsInterface $localeLists - * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Install\Model\Installer\Db\Mysql4 $db + * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( \Magento\Install\Model\Installer $installer, - \Magento\Framework\App\Resource\Config $resourceConfig, - \Magento\Framework\Module\UpdaterInterface $dbUpdater, - AppFilesystem $filesystem, + \Magento\Framework\Module\Updater $dbUpdater, \Magento\Install\Model\Installer\Data $installerData, - \Magento\Framework\App\State $appState, \Magento\Framework\Locale\ListsInterface $localeLists, - \Magento\Framework\ObjectManager $objectManager + Db\Mysql4 $db, + \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); - $this->_resourceConfig = $resourceConfig; + $this->installer = $installer; $this->_dbUpdater = $dbUpdater; - $this->_filesystem = $filesystem; $this->_installerData = $installerData; - $this->_installer->setDataModel($this->_installerData); - $this->_appState = $appState; + $this->installer->setDataModel($this->_installerData); $this->_localeLists = $localeLists; - $this->_objectManager = $objectManager; $this->installParameters = array_keys($this->requiredParameters + $this->optionalParameters); + $this->db = $db; + $this->messageManager = $messageManager; } /** @@ -283,14 +250,6 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller return false; } - /** - * Check if already installed - */ - if ($this->_appState->isInstalled()) { - $this->addError('ERROR: Magento is already installed.'); - return false; - } - /** * Skip URL validation, if set */ @@ -351,15 +310,13 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller return false; } - $installer = $this->_getInstaller(); - /** * Install configuration */ - $installer->installConfig($this->_installerData->getConfigData()); + $this->installer->installConfig($this->_installerData->getConfigData()); if (!empty($options['cleanup_database'])) { - $this->_cleanUpDatabase(); + $this->db->cleanUpDatabase(); } if ($this->hasErrors()) { @@ -369,7 +326,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller /** * Install database */ - $installer->installDb(); + $this->installer->installDb(); if ($this->hasErrors()) { return false; @@ -382,27 +339,19 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller * Create primary administrator user & install encryption key */ $encryptionKey = !empty($options['encryption_key']) ? $options['encryption_key'] : null; - $encryptionKey = $installer->getValidEncryptionKey($encryptionKey); - $installer->createAdministrator($this->_installerData->getAdminData()); - $installer->installEncryptionKey($encryptionKey); + $encryptionKey = $this->installer->getValidEncryptionKey($encryptionKey); + $this->installer->createAdministrator($this->_installerData->getAdminData()); + $this->installer->installEncryptionKey($encryptionKey); /** * Installation finish */ - $installer->finish(); + $this->installer->finish(); if ($this->hasErrors()) { return false; } - /** - * Change directories mode to be writable by apache user - */ - $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR)->changePermissions( - '', - 0777 - ); - return $encryptionKey; } catch (\Exception $e) { if ($e instanceof \Magento\Framework\Model\Exception) { @@ -416,94 +365,12 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller } } else { - $this->addError('ERROR: ' . $e->getMessage()); + $this->addError('ERROR: ' . $e->getMessage() . $e->getTraceAsString()); } return false; } } - /** - * Cleanup database use system configuration - * - * @return void - */ - protected function _cleanUpDatabase() - { - $modelName = 'Magento\Install\Model\Installer\Db\Mysql4'; - /** @var $resourceModel \Magento\Install\Model\Installer\Db\AbstractDb */ - $resourceModel = $this->_objectManager->get($modelName); - $resourceModel->cleanUpDatabase(); - } - - /** - * Remove temp directory - * - * @return void - */ - - protected function _removeTempDir() - { - $varDirectory = $this->_filesystem->getDirectoryWrite(AppFilesystem::VAR_DIR); - foreach ($varDirectory->read() as $path) { - if ($varDirectory->isDirectory($path)) { - try { - $varDirectory->delete($path); - } catch (FilesystemException $e) { - $this->fileDeleteErrors[] = $e->getMessage(); - } - } - } - } - - /** - * Remove local.xml - * - * @return void - */ - - protected function _removeLocalXml() - { - try { - $this->_filesystem->getDirectoryWrite(AppFilesystem::CONFIG_DIR)->delete('local.xml'); - } catch (FilesystemException $e) { - $this->fileDeleteErrors[] = $e->getMessage(); - } - } - - /** - * Display files that were not deleted on uninstall - * - * @return void - */ - - protected function _displayFileDeleteErrors() - { - foreach ($this->fileDeleteErrors as $errors) { - $unDeletedFile = trim(explode(" ", $errors)[2]); - echo "Please delete the file manually : $unDeletedFile \n"; - } - } - - /** - * Uninstall the application - * - * @return bool - */ - public function uninstall() - { - if (!$this->_appState->isInstalled()) { - return false; - } - - $this->_cleanUpDatabase(); - $this->_removeTempDir(); - $this->_removeLocalXml(); - if (!empty($this->fileDeleteErrors)) { - $this->_displayFileDeleteErrors(); - } - return true; - } - /** * Retrieve available locale codes * @@ -560,21 +427,54 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ public function checkServer() { - \Magento\Framework\Phrase::setRenderer( - $this->_objectManager->get('Magento\Framework\Phrase\RendererInterface') - ); - - $installer = $this->_getInstaller(); - $result = $installer->checkServer(); + $result = $this->installer->checkServer(); if (!$result) { - /** @var \Magento\Framework\Message\ManagerInterface $messageManager*/ - $messageManager = $this->_objectManager->get('Magento\Framework\Message\ManagerInterface'); - /** @var \Magento\Framework\Message\MessageInterface $message */ - foreach ($messageManager->getMessages()->getItems() as $message) { + foreach ($this->messageManager->getMessages()->getItems() as $message) { $this->addError($message->toString()); } } return $this; } + + /** + * Validate session storage value (files or db) + * If empty, will return 'files' + * + * @param string $value + * @return string + * @throws \Exception + */ + protected function _checkSessionSave($value) + { + if (empty($value)) { + return 'files'; + } + if (!in_array($value, array('files', 'db'), true)) { + throw new \Exception('session_save value must be "files" or "db".'); + } + return $value; + } + + /** + * Validate backend area frontname value. + * If empty, "backend" will be returned + * + * @param string $value + * @return string + * @throws \Exception + */ + protected function _checkBackendFrontname($value) + { + if (empty($value)) { + return 'backend'; + } + if (!preg_match('/^[a-z]+[a-z0-9_]+$/', $value)) { + throw new \Exception( + 'backend_frontname value must contain only letters (a-z), numbers (0-9)' . + ' or underscore(_), first character should be a letter.' + ); + } + return $value; + } } diff --git a/app/code/Magento/Install/Model/Installer/Db.php b/app/code/Magento/Install/Model/Installer/Db.php index e1d58e869e2..a2139e0e533 100644 --- a/app/code/Magento/Install/Model/Installer/Db.php +++ b/app/code/Magento/Install/Model/Installer/Db.php @@ -27,7 +27,7 @@ */ namespace Magento\Install\Model\Installer; -class Db extends \Magento\Install\Model\Installer\AbstractInstaller +class Db { /** * Database resource @@ -43,7 +43,7 @@ class Db extends \Magento\Install\Model\Installer\AbstractInstaller /** * Database model factory - * + * * @var \Magento\Install\Model\Installer\Db\Factory */ protected $_dbFactory; @@ -56,18 +56,15 @@ class Db extends \Magento\Install\Model\Installer\AbstractInstaller protected $_dbConfig; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\Logger $logger * @param \Magento\Install\Model\Installer\Db\Factory $dbFactory * @param array $dbConfig */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\Logger $logger, \Magento\Install\Model\Installer\Db\Factory $dbFactory, array $dbConfig ) { - parent::__construct($installer); $this->_logger = $logger; $this->_dbConfig = $dbConfig; $this->_dbFactory = $dbFactory; diff --git a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php index c22d08822e6..918b2ed3415 100644 --- a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php +++ b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php @@ -197,7 +197,7 @@ abstract class AbstractDb /** * Clean up database * - * @return \Magento\Install\Model\Installer\Db\AbstractDb + * @return void */ abstract public function cleanUpDatabase(); } diff --git a/app/code/Magento/Install/Model/Installer/Db/Mysql4.php b/app/code/Magento/Install/Model/Installer/Db/Mysql4.php index bd0c3ff66c7..f1b25bdbacc 100644 --- a/app/code/Magento/Install/Model/Installer/Db/Mysql4.php +++ b/app/code/Magento/Install/Model/Installer/Db/Mysql4.php @@ -58,16 +58,13 @@ class Mysql4 extends \Magento\Install\Model\Installer\Db\AbstractDb } /** - * Clean database - * - * @return $this + * {@inheritdoc} */ public function cleanUpDatabase() { - $connection = $this->_getConnection(); $connectionData = $this->getConnectionData(); + $connection = $this->_getConnection(); $connection->query('DROP DATABASE IF EXISTS ' . $connectionData['dbName']); $connection->query('CREATE DATABASE ' . $connectionData['dbName']); - return $this; } } diff --git a/app/code/Magento/Install/Model/Installer/Filesystem.php b/app/code/Magento/Install/Model/Installer/Filesystem.php index b47754e505a..69534670555 100644 --- a/app/code/Magento/Install/Model/Installer/Filesystem.php +++ b/app/code/Magento/Install/Model/Installer/Filesystem.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * Filesystem installer */ -class Filesystem extends \Magento\Install\Model\Installer\AbstractInstaller +class Filesystem { /**#@+ * @deprecated since 1.7.1.0 @@ -62,18 +62,15 @@ class Filesystem extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\App\Filesystem $filesystem * @param \Magento\Install\Model\Config $installConfig * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\App\Filesystem $filesystem, \Magento\Install\Model\Config $installConfig, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->_filesystem = $filesystem; $this->_installConfig = $installConfig; $this->messageManager = $messageManager; diff --git a/app/code/Magento/Install/Model/Installer/Pear.php b/app/code/Magento/Install/Model/Installer/Pear.php index eed98694448..099ed6f848e 100644 --- a/app/code/Magento/Install/Model/Installer/Pear.php +++ b/app/code/Magento/Install/Model/Installer/Pear.php @@ -26,7 +26,7 @@ namespace Magento\Install\Model\Installer; /** * PEAR Packages Download Manager */ -class Pear extends \Magento\Install\Model\Installer\AbstractInstaller +class Pear { /** * @var \Magento\Framework\Message\ManagerInterface @@ -34,14 +34,11 @@ class Pear extends \Magento\Install\Model\Installer\AbstractInstaller protected $messageManager; /** - * @param \Magento\Install\Model\Installer $installer * @param \Magento\Framework\Message\ManagerInterface $messageManager */ public function __construct( - \Magento\Install\Model\Installer $installer, \Magento\Framework\Message\ManagerInterface $messageManager ) { - parent::__construct($installer); $this->messageManager = $messageManager; } diff --git a/app/code/Magento/Install/Model/Uninstaller.php b/app/code/Magento/Install/Model/Uninstaller.php new file mode 100644 index 00000000000..2af58797e3f --- /dev/null +++ b/app/code/Magento/Install/Model/Uninstaller.php @@ -0,0 +1,160 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Install\Model; + +use Magento\Framework\App\Filesystem; +use Magento\Framework\Filesystem\FilesystemException; + +/** + * A model for uninstalling Magento application + */ +class Uninstaller +{ + /** + * A service for cleaning up directories + * + * @var Filesystem + */ + protected $filesystem; + + /** + * A service for recreating database + * + * @var Installer\Db\Mysql4 + */ + private $db; + + /** + * Logger + * + * @var \Zend_Log + */ + private $log; + + /** + * Constructor + * + * @param Filesystem $filesystem + * @param Installer\Db\Mysql4 $db + * @param \Zend_Log $log + */ + public function __construct( + Filesystem $filesystem, + Installer\Db\Mysql4 $db, + \Zend_Log $log + ) { + $this->filesystem = $filesystem; + $this->db = $db; + $this->log = $log; + } + + /** + * Uninstalls the application + * + * @return void + */ + public function uninstall() + { + $this->log('Starting uninstall'); + $this->recreateDatabase(); + $this->log('File system cleanup:'); + $this->deleteDirContents(Filesystem::VAR_DIR); + $this->deleteDirContents(Filesystem::STATIC_VIEW_DIR); + $this->deleteLocalXml(); + $this->log('Uninstall complete.'); + } + + /** + * Log output + * + * @param string $message + * @param int $level + * @return void + */ + private function log($message, $level = \Zend_Log::INFO) + { + $this->log->log($message, $level); + } + + /** + * Deletes the database and creates it again + * + * @return void + */ + private function recreateDatabase() + { + $connectionData = $this->db->getConnectionData(); + if (empty($connectionData['dbName'])) { + $this->log('No database connection defined - skipping cleanup'); + } else { + $this->log("Recreating database '{$connectionData['dbName']}'"); + $this->db->cleanUpDatabase(); + } + } + + /** + * Removes contents of a directory + * + * @param string $type + * @return void + */ + private function deleteDirContents($type) + { + $dir = $this->filesystem->getDirectoryWrite($type); + $dirPath = $dir->getAbsolutePath(); + foreach ($dir->read() as $path) { + if (preg_match('/^\./', $path)) { + continue; + } + $this->log("{$dirPath}{$path}"); + try { + $dir->delete($path); + } catch (FilesystemException $e) { + $this->log($e->getMessage()); + } + } + } + + /** + * Removes deployment configuration + * + * @return void + */ + protected function deleteLocalXml() + { + $configDir = $this->filesystem->getDirectoryWrite(Filesystem::CONFIG_DIR); + $localXml = "{$configDir->getAbsolutePath()}local.xml"; + if (!$configDir->isFile('local.xml')) { + $this->log("The file '{$localXml}' doesn't exist - skipping cleanup"); + return; + } + try { + $this->log($localXml); + $configDir->delete('local.xml'); + } catch (FilesystemException $e) { + $this->log($e->getMessage()); + } + } +} diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index 5b3da388d63..5bea19a8a3a 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index c502e62e5a7..d324d9ebac6 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -113,11 +113,6 @@ <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> </arguments> </type> - <type name="Magento\Install\Controller\Wizard"> - <arguments> - <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> - </arguments> - </type> <type name="Magento\Install\Model\Installer"> <arguments> <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> @@ -128,11 +123,6 @@ <argument name="session" xsi:type="object">Magento\Install\Model\Session</argument> </arguments> </type> - <type name="Magento\Install\Model\Installer\AbstractInstaller"> - <arguments> - <argument name="installer" xsi:type="object">Magento\Install\Model\Installer\Proxy</argument> - </arguments> - </type> <type name="Magento\Framework\App\AreaList"> <arguments> <argument name="areas" xsi:type="array"> @@ -148,9 +138,6 @@ <argument name="areaCode" xsi:type="string">adminhtml</argument> </arguments> </type> - <type name="Magento\Framework\App\Action\Action"> - <plugin name="installInitializer" type="Magento\Install\App\Action\Plugin\Install" sortOrder="5"/> - </type> <type name="Magento\Install\Model\Setup"> <arguments> <argument name="resourceName" xsi:type="string">core_setup</argument> diff --git a/app/code/Magento/Install/etc/install/di.xml b/app/code/Magento/Install/etc/install/di.xml index 607cfefdd08..4bb37d60fd4 100644 --- a/app/code/Magento/Install/etc/install/di.xml +++ b/app/code/Magento/Install/etc/install/di.xml @@ -25,24 +25,4 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Core\Model\Theme" type="Magento\Core\Model\Theme\Data" /> - <type name="Magento\Framework\App\RouterList" shared="true"> - <arguments> - <argument name="routerList" xsi:type="array"> - <item name="install" xsi:type="array"> - <item name="class" xsi:type="string">Magento\Core\App\Router\Base</item> - <item name="disable" xsi:type="boolean">false</item> - <item name="sortOrder" xsi:type="string">20</item> - </item> - </argument> - </arguments> - </type> - <type name="Magento\Install\Controller\Index\Index"> - <plugin name="installInitializer" disabled="true" /> - <plugin name="designLoader" type="Magento\Install\App\Action\Plugin\Design" /> - <plugin name="directoryCleaner" type="Magento\Install\App\Action\Plugin\Dir" sortOrder="10"/> - </type> - <type name="Magento\Install\Controller\Wizard"> - <plugin name="installInitializer" disabled="true" /> - <plugin name="designLoader" type="Magento\Install\App\Action\Plugin\Design" /> - </type> </config> diff --git a/app/code/Magento/Install/Controller/Wizard/End.php b/app/code/Magento/Integration/Helper/Validator.php similarity index 55% rename from app/code/Magento/Install/Controller/Wizard/End.php rename to app/code/Magento/Integration/Helper/Validator.php index ce9238c0348..edf47505902 100644 --- a/app/code/Magento/Install/Controller/Wizard/End.php +++ b/app/code/Magento/Integration/Helper/Validator.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,33 +21,35 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class End extends \Magento\Install\Controller\Wizard +namespace Magento\Integration\Helper; + +use Magento\Framework\Exception\InputException; + +/** + * Validator Helper for user credentials + */ +class Validator { /** - * End installation + * Validate user credentials * + * @param string $username + * @param string $password + * @throws InputException * @return void */ - public function execute() + public function validateCredentials($username, $password) { - $this->_checkIfInstalled(); - - if ($this->_appState->isInstalled()) { - $this->_redirect('*/*'); - return; + $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; } - - $this->_getInstaller()->finish(); - - $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - - $this->_view->getLayout()->addBlock('Magento\Install\Block\End', 'install.end', 'content'); - $this->_view->renderLayout(); - $this->_session->clearStorage(); } } diff --git a/app/code/Magento/Integration/Service/V1/TokenService.php b/app/code/Magento/Integration/Service/V1/AdminTokenService.php similarity index 58% rename from app/code/Magento/Integration/Service/V1/TokenService.php rename to app/code/Magento/Integration/Service/V1/AdminTokenService.php index 49bf1f5d5b3..59974924d66 100644 --- a/app/code/Magento/Integration/Service/V1/TokenService.php +++ b/app/code/Magento/Integration/Service/V1/AdminTokenService.php @@ -24,21 +24,19 @@ 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\Integration\Helper\Validator; use Magento\Integration\Model\Oauth\Token as Token; -use Magento\User\Model\User as UserModel; +use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory; +use Magento\User\Model\User as UserModel; /** - * Class to handle token generation for Admins and Customers + * Class to handle token generation for Admins * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TokenService implements TokenServiceInterface +class AdminTokenService implements AdminTokenServiceInterface { /** * Token Model @@ -55,37 +53,35 @@ class TokenService implements TokenServiceInterface private $userModel; /** - * Customer Account Service - * - * @var CustomerAccountService + * @var \Magento\Integration\Helper\Validator */ - private $customerAccountService; + private $validatorHelper; /** * Token Collection Factory * * @var TokenCollectionFactory */ - public $tokenModelCollectionFactory; + private $tokenModelCollectionFactory; /** * Initialize service * * @param TokenModelFactory $tokenModelFactory * @param UserModel $userModel - * @param CustomerAccountService $customerAccountService * @param TokenCollectionFactory $tokenModelCollectionFactory + * @param \Magento\Integration\Helper\Validator $validatorHelper */ public function __construct( TokenModelFactory $tokenModelFactory, UserModel $userModel, - CustomerAccountService $customerAccountService, - TokenCollectionFactory $tokenModelCollectionFactory + TokenCollectionFactory $tokenModelCollectionFactory, + Validator $validatorHelper ) { $this->tokenModelFactory = $tokenModelFactory; $this->userModel = $userModel; - $this->customerAccountService = $customerAccountService; $this->tokenModelCollectionFactory = $tokenModelCollectionFactory; + $this->validatorHelper = $validatorHelper; } /** @@ -93,7 +89,7 @@ class TokenService implements TokenServiceInterface */ public function createAdminAccessToken($username, $password) { - $this->validateCredentials($username, $password); + $this->validatorHelper->validateCredentials($username, $password); try { $this->userModel->login($username, $password); if (!$this->userModel->getId()) { @@ -113,11 +109,7 @@ class TokenService implements TokenServiceInterface } /** - * Revoke token by admin id. - * - * @param int $adminId - * @return bool - * @throws \Magento\Framework\Exception\LocalizedException + * {@inheritdoc} */ public function revokeAdminAccessToken($adminId) { @@ -134,59 +126,4 @@ class TokenService implements TokenServiceInterface } return true; } - - /** - * {@inheritdoc} - */ - public function createCustomerAccessToken($username, $password) - { - $this->validateCredentials($username, $password); - $customerDataObject = $this->customerAccountService->authenticate($username, $password); - return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); - } - - /** - * Revoke token by customer id. - * - * @param int $customerId - * @return bool - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function revokeCustomerAccessToken($customerId) - { - $tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByCustomerId($customerId); - if ($tokenCollection->getSize() == 0) { - throw new LocalizedException("This customer has no tokens."); - } - try { - foreach ($tokenCollection as $token) { - $token->setRevoked(1)->save(); - } - } catch (\Exception $e) { - throw new LocalizedException("The tokens could not be revoked."); - } - return true; - } - - /** - * 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/AdminTokenServiceInterface.php similarity index 78% rename from app/code/Magento/Integration/Service/V1/TokenServiceInterface.php rename to app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php index 0f374a7a638..c613b2718d5 100644 --- a/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php +++ b/app/code/Magento/Integration/Service/V1/AdminTokenServiceInterface.php @@ -29,9 +29,9 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; /** - * Interface providing token generation for Admins and Customers + * Interface providing token generation for Admins */ -interface TokenServiceInterface +interface AdminTokenServiceInterface { /** * Create access token for admin given the admin credentials. @@ -46,13 +46,11 @@ interface TokenServiceInterface public function createAdminAccessToken($username, $password); /** - * Create access token for admin given the customer credentials. + * Revoke token by admin id. * - * @param string $username - * @param string $password - * @return string Token created - * @throws InputException For invalid input - * @throws AuthenticationException + * @param int $adminId + * @return bool + * @throws \Magento\Framework\Exception\LocalizedException */ - public function createCustomerAccessToken($username, $password); + public function revokeAdminAccessToken($adminId); } diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenService.php b/app/code/Magento/Integration/Service/V1/CustomerTokenService.php new file mode 100644 index 00000000000..6fdd3a7b3aa --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/CustomerTokenService.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\Integration\Service\V1; + +use Magento\Customer\Service\V1\CustomerAccountServiceInterface as CustomerAccountService; +use Magento\Framework\Exception\LocalizedException; +use Magento\Integration\Helper\Validator; +use Magento\Integration\Model\Oauth\Token\Factory as TokenModelFactory; +use Magento\Integration\Model\Oauth\Token as Token; +use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory; + +class CustomerTokenService implements CustomerTokenServiceInterface +{ + /** + * Token Model + * + * @var TokenModelFactory + */ + private $tokenModelFactory; + + /** + * Customer Account Service + * + * @var CustomerAccountService + */ + private $customerAccountService; + + /** + * @var \Magento\Integration\Helper\Validator + */ + private $validatorHelper; + + /** + * Token Collection Factory + * + * @var TokenCollectionFactory + */ + private $tokenModelCollectionFactory; + + /** + * Initialize service + * + * @param TokenModelFactory $tokenModelFactory + * @param CustomerAccountService $customerAccountService + * @param TokenCollectionFactory $tokenModelCollectionFactory + * @param \Magento\Integration\Helper\Validator $validatorHelper + */ + public function __construct( + TokenModelFactory $tokenModelFactory, + CustomerAccountService $customerAccountService, + TokenCollectionFactory $tokenModelCollectionFactory, + Validator $validatorHelper + ) { + $this->tokenModelFactory = $tokenModelFactory; + $this->customerAccountService = $customerAccountService; + $this->tokenModelCollectionFactory = $tokenModelCollectionFactory; + $this->validatorHelper = $validatorHelper; + } + + /** + * {@inheritdoc} + */ + public function createCustomerAccessToken($username, $password) + { + $this->validatorHelper->validateCredentials($username, $password); + $customerDataObject = $this->customerAccountService->authenticate($username, $password); + return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); + } + + /** + * {@inheritdoc} + */ + public function revokeCustomerAccessToken($customerId) + { + $tokenCollection = $this->tokenModelCollectionFactory->create()->addFilterByCustomerId($customerId); + if ($tokenCollection->getSize() == 0) { + throw new LocalizedException("This customer has no tokens."); + } + try { + foreach ($tokenCollection as $token) { + $token->setRevoked(1)->save(); + } + } catch (\Exception $e) { + throw new LocalizedException("The tokens could not be revoked."); + } + return true; + } +} diff --git a/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php b/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.php new file mode 100644 index 00000000000..bfac3a193dd --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/CustomerTokenServiceInterface.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\Integration\Service\V1; + +use Magento\Framework\Exception\AuthenticationException; + +/** + * Interface providing token generation for Customers + */ +interface CustomerTokenServiceInterface +{ + /** + * Create access token for admin given the customer credentials. + * + * @param string $username + * @param string $password + * @return string Token created + * @throws AuthenticationException + */ + public function createCustomerAccessToken($username, $password); + + /** + * Revoke token by customer id. + * + * @param int $customerId + * @return bool + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function revokeCustomerAccessToken($customerId); +} diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php index 0456688ad21..85ef600b63c 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Service/V1/Oauth.php @@ -40,7 +40,7 @@ use Magento\Integration\Model\Oauth\Consumer as ConsumerModel; class Oauth implements OauthInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -82,7 +82,7 @@ class Oauth implements OauthInterface /** * Initialize dependencies. * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param ConsumerFactory $consumerFactory * @param TokenFactory $tokenFactory * @param IntegrationOauthHelper $dataHelper @@ -92,7 +92,7 @@ class Oauth implements OauthInterface * @param TokenProvider $tokenProvider */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, ConsumerFactory $consumerFactory, TokenFactory $tokenFactory, IntegrationOauthHelper $dataHelper, diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index b8808f56f12..afe75132936 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/etc/di.xml b/app/code/Magento/Integration/etc/di.xml index b1460317df4..bcb6a1ec170 100644 --- a/app/code/Magento/Integration/etc/di.xml +++ b/app/code/Magento/Integration/etc/di.xml @@ -30,7 +30,8 @@ <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" /> + <preference for="Magento\Integration\Service\V1\CustomerTokenServiceInterface" type="Magento\Integration\Service\V1\CustomerTokenService" /> + <preference for="Magento\Integration\Service\V1\AdminTokenServiceInterface" type="Magento\Integration\Service\V1\AdminTokenService" /> <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/webapi.xml b/app/code/Magento/Integration/etc/webapi.xml index 2153888cff3..fc128e88959 100644 --- a/app/code/Magento/Integration/etc/webapi.xml +++ b/app/code/Magento/Integration/etc/webapi.xml @@ -26,13 +26,13 @@ <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"/> + <service class="Magento\Integration\Service\V1\AdminTokenServiceInterface" 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"/> + <service class="Magento\Integration\Service\V1\CustomerTokenServiceInterface" method="createCustomerAccessToken"/> <resources> <resource ref="anonymous"/> </resources> diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index eae263773ed..7d6c1dff507 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/App/Shell.php b/app/code/Magento/Log/App/Shell.php index eebdacb3bf0..58bc842e92d 100644 --- a/app/code/Magento/Log/App/Shell.php +++ b/app/code/Magento/Log/App/Shell.php @@ -26,6 +26,7 @@ namespace Magento\Log\App; use Magento\Framework\App\Console\Response; +use Magento\Framework\App\Bootstrap; use Magento\Framework\AppInterface; class Shell implements AppInterface @@ -72,4 +73,12 @@ class Shell implements AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php b/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php new file mode 100644 index 00000000000..a027e24c452 --- /dev/null +++ b/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php @@ -0,0 +1,163 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View; + +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class Status + * @package Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View + */ +class Status extends \Magento\Backend\Block\Template +{ + /** + * @var \Magento\Customer\Service\V1\Data\Customer + */ + protected $customer; + + /** + * @var \Magento\Log\Model\Customer + */ + protected $customerLog; + + /** + * @var \Magento\Log\Model\Visitor + */ + protected $modelLog; + + /** + * @var \Magento\Log\Model\CustomerFactory + */ + protected $logFactory; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerBuilder + */ + protected $customerBuilder; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Log\Model\CustomerFactory $logFactory + * @param \Magento\Log\Model\Log $modelLog + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Log\Model\CustomerFactory $logFactory, + \Magento\Log\Model\Log $modelLog, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, + array $data = array() + ) { + $this->logFactory = $logFactory; + $this->modelLog = $modelLog; + $this->dateTime = $dateTime; + $this->customerBuilder = $customerBuilder; + parent::__construct($context, $data); + } + + /** + * @return string + */ + public function getStoreLastLoginDateTimezone() + { + return $this->_scopeConfig->getValue( + $this->_localeDate->getDefaultTimezonePath(), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getCustomer()->getStoreId() + ); + } + + /** + * @return \Magento\Customer\Service\V1\Data\Customer + */ + public function getCustomer() + { + if (!$this->customer) { + $this->customer = $this->customerBuilder->populateWithArray( + $this->_backendSession->getCustomerData()['account'] + )->create(); + } + return $this->customer; + } + + /** + * Get customer's current status + * + * @return string + */ + public function getCurrentStatus() + { + $log = $this->getCustomerLog(); + $interval = $this->modelLog->getOnlineMinutesInterval(); + if ($log->getLogoutAt() || + strtotime($this->dateTime->now()) - strtotime($log->getLastVisitAt()) > $interval * 60 + ) { + return __('Offline'); + } + return __('Online'); + } + + /** + * Get customer last login date + * + * @return string + */ + public function getLastLoginDate() + { + $date = $this->getCustomerLog()->getLoginAt(); + if ($date) { + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + return __('Never'); + } + + /** + * @return string + */ + public function getStoreLastLoginDate() + { + $date = $this->getCustomerLog()->getLoginAtTimestamp(); + if ($date) { + $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); + return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true); + } + return __('Never'); + } + + /** + * Load Customer Log model + * + * @return \Magento\Log\Model\Customer + */ + public function getCustomerLog() + { + if (!$this->customerLog) { + $this->customerLog = $this->logFactory->create()->loadByCustomer($this->getCustomer()->getId()); + } + return $this->customerLog; + } +} diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online.php b/app/code/Magento/Log/Block/Adminhtml/Online.php similarity index 92% rename from app/code/Magento/Customer/Block/Adminhtml/Online.php rename to app/code/Magento/Log/Block/Adminhtml/Online.php index b7eaf9dd1d4..d488b0ea358 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online.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\Customer\Block\Adminhtml; +namespace Magento\Log\Block\Adminhtml; /** * Adminhtml online customers page content block @@ -48,7 +48,7 @@ class Online extends \Magento\Backend\Block\Template */ protected function _prepareLayout() { - $this->addChild('filterForm', 'Magento\Customer\Block\Adminhtml\Online\Filter'); + $this->addChild('filterForm', 'Magento\Log\Block\Adminhtml\Online\Filter'); return parent::_prepareLayout(); } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php b/app/code/Magento/Log/Block/Adminhtml/Online/Filter.php similarity index 97% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Filter.php index 247f96f518e..2621c053cea 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Filter.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Filter.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\Customer\Block\Adminhtml\Online; +namespace Magento\Log\Block\Adminhtml\Online; /** * Adminhtml customers online filter diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.php index 4f496796296..5d244b707aa 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Ip.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Ip.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\Customer\Block\Adminhtml\Online\Grid\Renderer; +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml customers online grid block item renderer by ip. diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.php index 39bb982bc8e..edef644a2d6 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Type.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Type.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\Customer\Block\Adminhtml\Online\Grid\Renderer; +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml customers online grid renderer for customer type. diff --git a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php similarity index 95% rename from app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php rename to app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php index 3d8cb77d2a8..2e5d3ef0d95 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Online/Grid/Renderer/Url.php +++ b/app/code/Magento/Log/Block/Adminhtml/Online/Grid/Renderer/Url.php @@ -22,14 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Log\Block\Adminhtml\Online\Grid\Renderer; /** * Adminhtml Online Customer last URL renderer * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Online\Grid\Renderer; - class Url extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php b/app/code/Magento/Log/Controller/Adminhtml/Online/Index.php similarity index 92% rename from app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php rename to app/code/Magento/Log/Controller/Adminhtml/Online/Index.php index dab423fbba5..564ef7a9a03 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Online/Index.php +++ b/app/code/Magento/Log/Controller/Adminhtml/Online/Index.php @@ -22,7 +22,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\Customer\Controller\Adminhtml\Online; +namespace Magento\Log\Controller\Adminhtml\Online; class Index extends \Magento\Backend\App\Action { @@ -31,7 +31,7 @@ class Index extends \Magento\Backend\App\Action */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magento_Customer::online'); + return $this->_authorization->isAllowed('Magento_Log::online'); } /** diff --git a/app/code/Magento/Log/Model/Aggregation.php b/app/code/Magento/Log/Model/Aggregation.php index e2aff2868e8..ab695cbad7c 100644 --- a/app/code/Magento/Log/Model/Aggregation.php +++ b/app/code/Magento/Log/Model/Aggregation.php @@ -41,14 +41,14 @@ class Aggregation extends \Magento\Framework\Model\AbstractModel protected $_lastRecord; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -56,7 +56,7 @@ class Aggregation extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Log/Model/Cron.php b/app/code/Magento/Log/Model/Cron.php index bfc4125ef5b..68ce14f15d3 100644 --- a/app/code/Magento/Log/Model/Cron.php +++ b/app/code/Magento/Log/Model/Cron.php @@ -55,7 +55,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -79,7 +79,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Log\Model\Log $log - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -91,7 +91,7 @@ class Cron extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Log\Model\Log $log, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Log/Model/Log.php b/app/code/Magento/Log/Model/Log.php index 6ab9e33a0c1..a3841892b63 100644 --- a/app/code/Magento/Log/Model/Log.php +++ b/app/code/Magento/Log/Model/Log.php @@ -45,6 +45,8 @@ class Log extends \Magento\Framework\Model\AbstractModel { const XML_LOG_CLEAN_DAYS = 'system/log/clean_after_day'; + const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; + /** * Core store config * @@ -105,4 +107,18 @@ class Log extends \Magento\Framework\Model\AbstractModel $this->getResource()->clean($this); return $this; } + + /** + * Return Online Minutes Interval + * + * @return int Minutes Interval + */ + public function getOnlineMinutesInterval() + { + $configValue = $this->_scopeConfig->getValue( + 'customer/online_customers/online_minutes_interval', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL; + } } diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php index 4e8ef5ce019..dded53fd5cc 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor.php +++ b/app/code/Magento/Log/Model/Resource/Visitor.php @@ -28,6 +28,13 @@ namespace Magento\Log\Model\Resource; */ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb { + /** + * Primary key auto increment flag + * + * @var bool + */ + protected $_isPkAutoIncrement = false; + /** * Magento string lib * @@ -41,20 +48,20 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_date; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\String $string */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\String $string ) { $this->_date = $date; @@ -82,7 +89,7 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor) { return array( - 'session_id' => $visitor->getSessionId(), + 'visitor_id' => $visitor->getVisitorId(), 'first_visit_at' => $visitor->getFirstVisitAt(), 'last_visit_at' => $visitor->getLastVisitAt(), 'last_url_id' => $visitor->getLastUrlId() ? $visitor->getLastUrlId() : 0, diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php index dcf29183f7b..2ea289f8121 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php @@ -147,7 +147,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac { if ($fieldName == 'type' && is_array($condition) && isset($condition['eq'])) { $fieldName = 'customer_id'; - if ($condition['eq'] === \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR) { + if ($condition['eq'] === \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR) { $condition = array('null' => 1); } else { $condition = array('moreq' => 1); diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php index 5e9ef54f5a7..38dbffc2f36 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php @@ -24,7 +24,7 @@ namespace Magento\Log\Model\Resource\Visitor; /** - * Log Prepare Online visitors resource + * Log Prepare Online visitors resource * * @author Magento Core Team <core@magentocommerce.com> */ @@ -95,7 +95,7 @@ class Online extends \Magento\Framework\Model\Resource\Db\AbstractDb while ($row = $query->fetch()) { $visitors[$row['visitor_id']] = $row; $lastUrls[$row['last_url_id']] = $row['visitor_id']; - $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Log\Model\Visitor::VISITOR_TYPE_VISITOR; + $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Customer\Model\Visitor::VISITOR_TYPE_VISITOR; $visitors[$row['visitor_id']]['customer_id'] = null; } @@ -144,7 +144,7 @@ class Online extends \Magento\Framework\Model\Resource\Db\AbstractDb $query = $readAdapter->query($select); while ($row = $query->fetch()) { - $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Log\Model\Visitor::VISITOR_TYPE_CUSTOMER; + $visitors[$row['visitor_id']]['visitor_type'] = \Magento\Customer\Model\Visitor::VISITOR_TYPE_CUSTOMER; $visitors[$row['visitor_id']]['customer_id'] = $row['customer_id']; } diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php index f16f6e1acb9..ae58e1f0658 100644 --- a/app/code/Magento/Log/Model/Visitor.php +++ b/app/code/Magento/Log/Model/Visitor.php @@ -24,83 +24,47 @@ namespace Magento\Log\Model; /** - * @method \Magento\Log\Model\Resource\Visitor _getResource() - * @method \Magento\Log\Model\Resource\Visitor getResource() + * @method Resource\Visitor _getResource() + * @method Resource\Visitor getResource() * @method string getSessionId() - * @method \Magento\Log\Model\Visitor setSessionId(string $value) - * @method \Magento\Log\Model\Visitor setFirstVisitAt(string $value) - * @method \Magento\Log\Model\Visitor setLastVisitAt(string $value) + * @method Visitor setSessionId(string $value) + * @method Visitor setFirstVisitAt(string $value) + * @method Visitor setLastVisitAt(string $value) + * @method Visitor setVisitorId(int $value) + * @method Visitor setIsNewVisitor(bool $value) + * @method Visitor getIsNewVisitor() + * @method Visitor getVisitorId() * @method int getLastUrlId() - * @method \Magento\Log\Model\Visitor setLastUrlId(int $value) + * @method Visitor setLastUrlId(int $value) * @method int getStoreId() - * @method \Magento\Log\Model\Visitor setStoreId(int $value) + * @method Visitor setStoreId(int $value) */ class Visitor extends \Magento\Framework\Model\AbstractModel { - const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; - - const VISITOR_TYPE_CUSTOMER = 'c'; - - const VISITOR_TYPE_VISITOR = 'v'; - - /** - * @var bool - */ - protected $_skipRequestLogging = false; - - /** - * @var string[] - */ - protected $_ignoredUserAgents; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_coreConfig; - /** - * Ignored Modules - * - * @var array + * @var \Magento\Framework\StoreManagerInterface */ - protected $_ignores; - - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; + protected $storeManager; /** * @var \Magento\Framework\Session\SessionManagerInterface */ - protected $_session; - - /** - * @var \Magento\Sales\Model\QuoteFactory - */ - protected $_quoteFactory; + protected $session; /** * @var \Magento\Framework\HTTP\Header */ - protected $_httpHeader; + protected $httpHeader; /** * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress */ - protected $_remoteAddress; + protected $remoteAddress; /** * @var \Magento\Framework\HTTP\PhpEnvironment\ServerAddress */ - protected $_serverAddress; + protected $serverAddress; /** * @var \Magento\Framework\Stdlib\DateTime @@ -110,54 +74,37 @@ class Visitor extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Framework\Session\SessionManagerInterface $session - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\HTTP\Header $httpHeader * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\Framework\HTTP\PhpEnvironment\ServerAddress $serverAddress * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param array $ignoredUserAgents - * @param array $ignores * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Framework\Session\SessionManagerInterface $session, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\HTTP\Header $httpHeader, \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\Framework\HTTP\PhpEnvironment\ServerAddress $serverAddress, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, - array $ignoredUserAgents = array(), - array $ignores = array(), array $data = array() ) { - $this->_scopeConfig = $scopeConfig; - $this->_quoteFactory = $quoteFactory; - $this->_session = $session; - $this->_storeManager = $storeManager; - $this->_coreConfig = $coreConfig; - $this->_ignoredUserAgents = $ignoredUserAgents; - $this->_httpHeader = $httpHeader; - $this->_remoteAddress = $remoteAddress; - $this->_serverAddress = $serverAddress; + $this->session = $session; + $this->storeManager = $storeManager; + $this->httpHeader = $httpHeader; + $this->remoteAddress = $remoteAddress; + $this->serverAddress = $serverAddress; $this->dateTime = $dateTime; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_ignores = $ignores; } /** @@ -168,12 +115,6 @@ class Visitor extends \Magento\Framework\Model\AbstractModel protected function _construct() { $this->_init('Magento\Log\Model\Resource\Visitor'); - $userAgent = $this->_httpHeader->getHttpUserAgent(); - if ($this->_ignoredUserAgents) { - if (in_array($userAgent, $this->_ignoredUserAgents)) { - $this->_skipRequestLogging = true; - } - } } /** @@ -183,18 +124,7 @@ class Visitor extends \Magento\Framework\Model\AbstractModel */ protected function _getSession() { - return $this->_session; - } - - /** - * Skip request logging - * - * @param bool $skipRequestLogging - * @return void - */ - public function setSkipRequestLogging($skipRequestLogging) - { - $this->_skipRequestLogging = (bool)$skipRequestLogging; + return $this->session; } /** @@ -207,36 +137,21 @@ class Visitor extends \Magento\Framework\Model\AbstractModel $clean = true; $this->addData( array( - 'server_addr' => $this->_serverAddress->getServerAddress(true), - 'remote_addr' => $this->_remoteAddress->getRemoteAddress(true), - 'http_secure' => $this->_storeManager->getStore()->isCurrentlySecure(), - 'http_host' => $this->_httpHeader->getHttpHost($clean), - 'http_user_agent' => $this->_httpHeader->getHttpUserAgent($clean), - 'http_accept_language' => $this->_httpHeader->getHttpAcceptLanguage($clean), - 'http_accept_charset' => $this->_httpHeader->getHttpAcceptCharset($clean), - 'request_uri' => $this->_httpHeader->getRequestUri($clean), - 'session_id' => $this->_getSession()->getSessionId(), - 'http_referer' => $this->_httpHeader->getHttpReferer($clean) + 'server_addr' => $this->serverAddress->getServerAddress(true), + 'remote_addr' => $this->remoteAddress->getRemoteAddress(true), + 'http_secure' => $this->storeManager->getStore()->isCurrentlySecure(), + 'http_host' => $this->httpHeader->getHttpHost($clean), + 'http_user_agent' => $this->httpHeader->getHttpUserAgent($clean), + 'http_accept_language' => $this->httpHeader->getHttpAcceptLanguage($clean), + 'http_accept_charset' => $this->httpHeader->getHttpAcceptCharset($clean), + 'request_uri' => $this->httpHeader->getRequestUri($clean), + 'http_referer' => $this->httpHeader->getHttpReferer($clean) ) ); return $this; } - /** - * Return Online Minutes Interval - * - * @return int Minutes Interval - */ - public function getOnlineMinutesInterval() - { - $configValue = $this->_scopeConfig->getValue( - 'customer/online_customers/online_minutes_interval', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL; - } - /** * Retrieve url from model data * @@ -283,21 +198,15 @@ class Visitor extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Event\Observer $observer * @return \Magento\Log\Model\Visitor */ - public function initByRequest($observer) + public function logNewVisitor($observer) { - if ($this->_skipRequestLogging || $this->isModuleIgnored($observer)) { - return $this; - } - - $this->setData($this->_getSession()->getVisitorData()); + $visitor = $observer->getEvent()->getVisitor(); + $this->setData($visitor->getData()); $this->initServerData(); - - if (!$this->getId()) { - $this->setFirstVisitAt($this->dateTime->now()); - $this->setIsNewVisitor(true); - $this->save(); - $this->_eventManager->dispatch('visitor_init', array('visitor' => $this)); - } + $this->setFirstVisitAt($this->dateTime->now()); + $this->setIsNewVisitor(true); + $this->save(); + $visitor->setData($this->getData()); return $this; } @@ -309,130 +218,20 @@ class Visitor extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Event\Observer $observer * @return \Magento\Log\Model\Visitor */ - public function saveByRequest($observer) + public function logVisitorActivity($observer) { - if ($this->_skipRequestLogging || $this->isModuleIgnored($observer)) { - return $this; - } - + $visitor = $observer->getEvent()->getVisitor(); try { - $this->setLastVisitAt($this->dateTime->now()); - $this->save(); - $this->_getSession()->setVisitorData($this->getData()); + $this->setData($visitor->getData()); + if ($this->getId() && $this->getVisitorId()) { + $this->initServerData(); + $this->setLastVisitAt($this->dateTime->now()); + $this->save(); + $visitor->setData($this->getData()); + } } catch (\Exception $e) { $this->_logger->logException($e); } return $this; } - - /** - * Bind customer data when customer login - * - * Used in event "customer_login" - * - * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Log\Model\Visitor - */ - public function bindCustomerLogin($observer) - { - /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ - $customer = $observer->getEvent()->getCustomer(); - if (!$this->getCustomerId()) { - $this->setDoCustomerLogin(true); - $this->setCustomerId($customer->getId()); - } - } - - /** - * Bind customer data when customer logout - * - * Used in event "customer_logout" - * - * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Log\Model\Visitor - */ - public function bindCustomerLogout($observer) - { - if ($this->getCustomerId()) { - $this->setDoCustomerLogout(true); - } - } - - /** - * Create binding of checkout quote - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function bindQuoteCreate($observer) - { - $quote = $observer->getEvent()->getQuote(); - if ($quote) { - if ($quote->getIsCheckoutCart()) { - $this->setQuoteId($quote->getId()); - $this->setDoQuoteCreate(true); - } - } - return $this; - } - - /** - * Destroy binding of checkout quote - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function bindQuoteDestroy($observer) - { - $quote = $observer->getEvent()->getQuote(); - if ($quote) { - $this->setDoQuoteDestroy(true); - } - return $this; - } - - /** - * Methods for research (depends from customer online admin section) - * - * @param array $data - * @return $this - */ - public function addIpData($data) - { - $ipData = array(); - $data->setIpData($ipData); - return $this; - } - - /** - * Load quote data into $data - * - * @param object $data - * @return $this - */ - public function addQuoteData($data) - { - $quoteId = $data->getQuoteId(); - if (intval($quoteId) <= 0) { - return $this; - } - $data->setQuoteData($this->_quoteFactory->create()->load($quoteId)); - return $this; - } - - /** - * Returns true if the module is required - * - * @param \Magento\Framework\Event\Observer $observer - * @return bool - */ - public function isModuleIgnored($observer) - { - if (is_array($this->_ignores) && $observer) { - $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); - if (isset($this->_ignores[$curModule])) { - return true; - } - } - return false; - } } diff --git a/app/code/Magento/Log/Model/Visitor/Online.php b/app/code/Magento/Log/Model/Visitor/Online.php index de4b28b3294..637bedfc7f4 100644 --- a/app/code/Magento/Log/Model/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Visitor/Online.php @@ -158,7 +158,7 @@ class Online extends \Magento\Framework\Model\AbstractModel ) ); if (!$value) { - $value = \Magento\Log\Model\Visitor::DEFAULT_ONLINE_MINUTES_INTERVAL; + $value = \Magento\Log\Model\Log::DEFAULT_ONLINE_MINUTES_INTERVAL; } return $value; } diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index 3af9521f0a1..1a2c5bb3819 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,17 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/etc/acl.xml b/app/code/Magento/Log/etc/acl.xml new file mode 100644 index 00000000000..19a7be98f3a --- /dev/null +++ b/app/code/Magento/Log/etc/acl.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/Acl/etc/acl.xsd"> + <acl> + <resources> + <resource id="Magento_Adminhtml::admin"> + <resource id="Magento_Customer::customer"> + <resource id="Magento_Log::online" title="Now Online" sortOrder="20" /> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/Magento/Install/etc/frontend/routes.xml b/app/code/Magento/Log/etc/adminhtml/menu.xml similarity index 77% rename from app/code/Magento/Install/etc/frontend/routes.xml rename to app/code/Magento/Log/etc/adminhtml/menu.xml index 0a76f3dab22..7e9f8a1691c 100644 --- a/app/code/Magento/Install/etc/frontend/routes.xml +++ b/app/code/Magento/Log/etc/adminhtml/menu.xml @@ -23,10 +23,8 @@ * @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="standard"> - <route id="install" frontName="install"> - <module name="Magento_Install" /> - </route> - </router> -</config> \ No newline at end of file +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd"> + <menu> + <add id="Magento_Log::visitor_online" title="Now Online" module="Magento_Log" sortOrder="30" parent="Magento_Customer::customer" action="visitor/online" resource="Magento_Log::online"/> + </menu> +</config> diff --git a/app/code/Magento/Install/etc/adminhtml/routes.xml b/app/code/Magento/Log/etc/adminhtml/routes.xml similarity index 91% rename from app/code/Magento/Install/etc/adminhtml/routes.xml rename to app/code/Magento/Log/etc/adminhtml/routes.xml index 6561687d777..42b1cd19d43 100644 --- a/app/code/Magento/Install/etc/adminhtml/routes.xml +++ b/app/code/Magento/Log/etc/adminhtml/routes.xml @@ -25,8 +25,8 @@ --> <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 id="visitor" frontName="visitor"> + <module name="Magento_Log" /> </route> </router> </config> diff --git a/app/code/Magento/Log/etc/adminhtml/system.xml b/app/code/Magento/Log/etc/adminhtml/system.xml index 439095e613d..23868256a5c 100644 --- a/app/code/Magento/Log/etc/adminhtml/system.xml +++ b/app/code/Magento/Log/etc/adminhtml/system.xml @@ -25,6 +25,15 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/system_file.xsd"> <system> + <section id="customer" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1"> + <group id="online_customers" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Online Customers Options</label> + <field id="online_minutes_interval" translate="label comment" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Online Minutes Interval</label> + <comment>Leave empty for default (15 minutes).</comment> + </field> + </group> + </section> <section id="system"> <group id="log" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Log Cleaning</label> diff --git a/app/code/Magento/Log/etc/di.xml b/app/code/Magento/Log/etc/di.xml index 2a45826caf2..87c4ef9d486 100644 --- a/app/code/Magento/Log/etc/di.xml +++ b/app/code/Magento/Log/etc/di.xml @@ -29,13 +29,4 @@ <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManager\Proxy</argument> </arguments> </type> - <type name="Magento\Log\Model\Visitor"> - <arguments> - <argument name="ignoredUserAgents" xsi:type="array"> - <item name="google1" xsi:type="string">Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</item> - <item name="google2" xsi:type="string">Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</item> - <item name="google3" xsi:type="string">Googlebot/2.1 (+http://www.googlebot.com/bot.html)</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/Log/etc/frontend/events.xml b/app/code/Magento/Log/etc/frontend/events.xml index f8eae9512b1..484ea6a536e 100644 --- a/app/code/Magento/Log/etc/frontend/events.xml +++ b/app/code/Magento/Log/etc/frontend/events.xml @@ -24,22 +24,10 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> - <event name="controller_action_predispatch"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="initByRequest" /> + <event name="visitor_init"> + <observer name="log" instance="Magento\Log\Model\Visitor" method="logNewVisitor" /> </event> - <event name="controller_action_postdispatch"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="saveByRequest" /> - </event> - <event name="customer_data_object_login"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindCustomerLogin" /> - </event> - <event name="customer_logout"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindCustomerLogout" /> - </event> - <event name="sales_quote_save_after"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindQuoteCreate" /> - </event> - <event name="checkout_quote_destroy"> - <observer name="log" instance="Magento\Log\Model\Visitor" method="bindQuoteDestroy" /> + <event name="visitor_activity_save"> + <observer name="log" instance="Magento\Log\Model\Visitor" method="logVisitorActivity" /> </event> </config> diff --git a/app/code/Magento/Log/etc/module.xml b/app/code/Magento/Log/etc/module.xml index f9ec0aeae87..068b3a77f6a 100644 --- a/app/code/Magento/Log/etc/module.xml +++ b/app/code/Magento/Log/etc/module.xml @@ -35,7 +35,6 @@ <module name="Magento_Core"/> <module name="Magento_Customer"/> <module name="Magento_Eav"/> - <module name="Magento_Sales"/> <module name="Magento_Backend"/> </depends> </module> diff --git a/app/code/Magento/Log/i18n/de_DE.csv b/app/code/Magento/Log/i18n/de_DE.csv index a0b3a6563e8..6bca6e7ceca 100644 --- a/app/code/Magento/Log/i18n/de_DE.csv +++ b/app/code/Magento/Log/i18n/de_DE.csv @@ -6,3 +6,8 @@ Frequency,Frequenz "Log Cleaning","Aufräumen des Verlaufs" "Save Log, Days","Speichere Verlauf, Tage" "Enable Log Cleaning","Aufräumen des Verlaufs anschalten" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers",Online-Kunden +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/en_US.csv b/app/code/Magento/Log/i18n/en_US.csv index 3ef19efb16c..4db797aec00 100644 --- a/app/code/Magento/Log/i18n/en_US.csv +++ b/app/code/Magento/Log/i18n/en_US.csv @@ -6,3 +6,8 @@ Frequency,Frequency "Log Cleaning","Log Cleaning" "Save Log, Days","Save Log, Days" "Enable Log Cleaning","Enable Log Cleaning" +"Customers Now Online","Customers Now Online" +Online,Online +"Online Customers","Online Customers" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/es_ES.csv b/app/code/Magento/Log/i18n/es_ES.csv index 4235ce8fc77..d9c1ce5abda 100644 --- a/app/code/Magento/Log/i18n/es_ES.csv +++ b/app/code/Magento/Log/i18n/es_ES.csv @@ -6,3 +6,8 @@ Frequency,Frecuencia "Log Cleaning","Limpieza de registros" "Save Log, Days","Guardar registro (dÃas)" "Enable Log Cleaning","Activar limpieza de registros" +Online,Conectado +"Customers Now Online","Customers Now Online" +"Online Customers","Clientes conectados" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/fr_FR.csv b/app/code/Magento/Log/i18n/fr_FR.csv index b5cc876151c..2e38a7eede3 100644 --- a/app/code/Magento/Log/i18n/fr_FR.csv +++ b/app/code/Magento/Log/i18n/fr_FR.csv @@ -6,3 +6,8 @@ Frequency,Fréquence "Log Cleaning","Effacement des logs" "Save Log, Days","Enregistrer logs, jours" "Enable Log Cleaning","Activer l'effacement des logs" +Online,"En ligne" +"Customers Now Online","Customers Now Online" +"Online Customers","Utilisateurs en ligne" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/nl_NL.csv b/app/code/Magento/Log/i18n/nl_NL.csv index 79b61bb7423..2b67d714f0e 100644 --- a/app/code/Magento/Log/i18n/nl_NL.csv +++ b/app/code/Magento/Log/i18n/nl_NL.csv @@ -6,3 +6,8 @@ Frequency,Frequentie "Log Cleaning","Log aan het schonen" "Save Log, Days","Log opslaan, dagen" "Enable Log Cleaning","Schonen van log toestaan" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers","Online Klanten" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/i18n/pt_BR.csv b/app/code/Magento/Log/i18n/pt_BR.csv index 6f2c8ab8e44..a8120528e30 100644 --- a/app/code/Magento/Log/i18n/pt_BR.csv +++ b/app/code/Magento/Log/i18n/pt_BR.csv @@ -6,3 +6,9 @@ Frequency,Freqüência "Log Cleaning","Limpeza de Registro" "Save Log, Days","Salvar Registro, Dias" "Enable Log Cleaning","Ativar Limpeza de Registro" +Online,Online +"Customers Now Online","Customers Now Online" +"Online Customers","Clientes Conectados" +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" + diff --git a/app/code/Magento/Log/i18n/zh_CN.csv b/app/code/Magento/Log/i18n/zh_CN.csv index 72a7f3132d4..26c5dc7ad75 100644 --- a/app/code/Magento/Log/i18n/zh_CN.csv +++ b/app/code/Magento/Log/i18n/zh_CN.csv @@ -6,3 +6,8 @@ Frequency,频率 "Log Cleaning",æ—¥å¿—æ¸…ç† "Save Log, Days",ä¿å˜æ—¥å¿—,天 "Enable Log Cleaning",å¯ç”¨æ—¥å¿—æ¸…ç† +Online,在线 +"Customers Now Online","Customers Now Online" +"Online Customers",在线客户 +"Online Customers Options","Online Customers Options" +"Online Minutes Interval","Online Minutes Interval" diff --git a/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php b/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php index 943671375ba..35be24be9cc 100644 --- a/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php +++ b/app/code/Magento/Log/sql/log_setup/install-1.6.0.0.php @@ -260,12 +260,6 @@ $table = $installer->getConnection()->newTable( null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Visitor ID' -)->addColumn( - 'session_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 64, - array('nullable' => true, 'default' => null), - 'Session ID' )->addColumn( 'first_visit_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, @@ -294,6 +288,15 @@ $table = $installer->getConnection()->newTable( 'Log Visitors Table' ); $installer->getConnection()->createTable($table); +$installer->getConnection()->addForeignKey( + $installer->getFkName('log_visitor', 'visitor_id', 'customer_visitor', 'visitor_id'), + $installer->getTable('log_visitor'), + 'visitor_id', + $installer->getTable('customer_visitor'), + 'visitor_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +); /** * Create table 'log_visitor_info' diff --git a/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml new file mode 100644 index 00000000000..ceb709e7832 --- /dev/null +++ b/app/code/Magento/Log/view/adminhtml/layout/customer_index_edit.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="personal_info"> + <block class="Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status" name="view_customer_status" template="customer/status.phtml"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml b/app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml similarity index 95% rename from app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml rename to app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml index 9adff30add8..e54d025b6cf 100644 --- a/app/code/Magento/Customer/view/adminhtml/layout/customer_online_index.xml +++ b/app/code/Magento/Log/view/adminhtml/layout/customer_online_index.xml @@ -25,8 +25,8 @@ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> <referenceContainer name="content"> - <block class="Magento\Customer\Block\Adminhtml\Online" name="adminhtml.block.customer.online.grid.container"> - <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.block.customer.online.grid" as="grid"> + <block class="Magento\Log\Block\Adminhtml\Online" name="adminhtml.block.log.online.grid.container"> + <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.block.log.online.grid" as="grid"> <arguments> <argument name="id" xsi:type="string">onlineGrid</argument> <argument name="dataSource" xsi:type="object">Magento\Log\Model\Resource\Visitor\Online\Grid\Collection</argument> @@ -34,7 +34,7 @@ <argument name="default_dir" xsi:type="string">DESC</argument> <argument name="save_parameters_in_session" xsi:type="string">1</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.customer.online.grid.columnSet"> + <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.log.online.grid.columnSet"> <arguments> <argument name="rowUrl" xsi:type="array"> <item name="generatorClass" xsi:type="string">Magento\Log\Model\Resource\Visitor\Online\Grid\Row\UrlGenerator</item> @@ -80,7 +80,7 @@ <argument name="header" xsi:type="string" translate="true">IP Address</argument> <argument name="default" xsi:type="string">n/a</argument> <argument name="filter" xsi:type="string">0</argument> - <argument name="renderer" xsi:type="string">Magento\Customer\Block\Adminhtml\Online\Grid\Renderer\Ip</argument> + <argument name="renderer" xsi:type="string">Magento\Log\Block\Adminhtml\Online\Grid\Renderer\Ip</argument> <argument name="index" xsi:type="string">remote_addr</argument> </arguments> </block> @@ -119,7 +119,7 @@ <argument name="linelength" xsi:type="string">60</argument> <argument name="type" xsi:type="string">wrapline</argument> <argument name="index" xsi:type="string">last_url</argument> - <argument name="renderer" xsi:type="string">Magento\Customer\Block\Adminhtml\Online\Grid\Renderer\Url</argument> + <argument name="renderer" xsi:type="string">Magento\Log\Block\Adminhtml\Online\Grid\Renderer\Url</argument> </arguments> </block> </block> diff --git a/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml b/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml new file mode 100644 index 00000000000..451742bc1bf --- /dev/null +++ b/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml @@ -0,0 +1,41 @@ +<?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) + */ + +/** + * Template for block \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status + */ + +$lastLoginDateAdmin = $this->getLastLoginDate(); +$lastLoginDateStore = $this->getStoreLastLoginDate(); +?> +<tr> + <th><?php echo __('Last Logged In:') ?></th> + <td><?php echo $lastLoginDateAdmin ?> (<?php echo $this->getCurrentStatus() ?>)</td> +</tr> +<?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> +<tr> + <th><?php echo __('Last Logged In (%1):', $this->getStoreLastLoginDateTimezone()) ?></th> + <td><?php echo $lastLoginDateStore ?> (<?php echo $this->getCurrentStatus() ?>)</td> +</tr> +<?php endif; ?> diff --git a/app/code/Magento/Customer/view/adminhtml/templates/online.phtml b/app/code/Magento/Log/view/adminhtml/templates/online.phtml similarity index 100% rename from app/code/Magento/Customer/view/adminhtml/templates/online.phtml rename to app/code/Magento/Log/view/adminhtml/templates/online.phtml diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address.php b/app/code/Magento/Multishipping/Controller/Checkout/Address.php index 27729eb2ab3..b9a18c154f4 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address.php @@ -28,6 +28,17 @@ namespace Magento\Multishipping\Controller\Checkout; */ class Address extends \Magento\Framework\App\Action\Action { + /** + * {@inheritdoc} + */ + public function dispatch(\Magento\Framework\App\RequestInterface $request) + { + if (!$this->_getCheckout()->getCustomer()->getId()) { + return $this->_redirect('customer/account/login'); + } + return parent::dispatch($request); + } + /** * Retrieve multishipping checkout model * diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index c5a34e64e59..f69ff209750 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -58,7 +58,7 @@ class Multishipping extends \Magento\Framework\Object protected $_session; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -119,7 +119,7 @@ class Multishipping extends \Magento\Framework\Object * @param \Magento\Framework\Session\Generic $session * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory * @param \Magento\Sales\Model\Convert\Quote $quote - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param \Magento\Multishipping\Helper\Data $helper * @param OrderSender $orderSender @@ -135,7 +135,7 @@ class Multishipping extends \Magento\Framework\Object \Magento\Framework\Session\Generic $session, \Magento\Sales\Model\Quote\AddressFactory $addressFactory, \Magento\Sales\Model\Convert\Quote $quote, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, OrderSender $orderSender, diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 2377b2adb3d..d7b017fc380 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-weee": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-weee": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php index 8dfd30fb797..bea838371cc 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php @@ -46,7 +46,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select protected $_coreRegistry; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -59,7 +59,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select * @param \Magento\Backend\Block\Context $context * @param \Magento\Framework\DB\Helper $resourceHelper * @param \Magento\Store\Model\Resource\Website\CollectionFactory $websitesFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $registry * @param array $data */ @@ -67,7 +67,7 @@ class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select \Magento\Backend\Block\Context $context, \Magento\Framework\DB\Helper $resourceHelper, \Magento\Store\Model\Resource\Website\CollectionFactory $websitesFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array() ) { diff --git a/app/code/Magento/Newsletter/Controller/Manage.php b/app/code/Magento/Newsletter/Controller/Manage.php index 15e28665c01..383d55923fa 100644 --- a/app/code/Magento/Newsletter/Controller/Manage.php +++ b/app/code/Magento/Newsletter/Controller/Manage.php @@ -43,7 +43,7 @@ class Manage extends \Magento\Framework\App\Action\Action protected $_formKeyValidator; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class Manage extends \Magento\Framework\App\Action\Action * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder @@ -81,7 +81,7 @@ class Manage extends \Magento\Framework\App\Action\Action \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, diff --git a/app/code/Magento/Newsletter/Controller/Subscriber.php b/app/code/Magento/Newsletter/Controller/Subscriber.php index e8f68a670c9..90012614607 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber.php @@ -28,7 +28,7 @@ namespace Magento\Newsletter\Controller; use Magento\Framework\App\Action\Context; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Session; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Newsletter\Model\SubscriberFactory; @@ -58,7 +58,7 @@ class Subscriber extends \Magento\Framework\App\Action\Action protected $_subscriberFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 95d4ae9a6ef..317bec2b0d6 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -133,7 +133,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Newsletter\Model\Template\Filter $templateFilter * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime\DateTime $date @@ -148,7 +148,7 @@ class Queue extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Newsletter\Model\Template\Filter $templateFilter, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime\DateTime $date, diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index ed26646c3fa..80222fc5278 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -113,7 +113,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -140,7 +140,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel * @param \Magento\Newsletter\Helper\Data $newsletterData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation @@ -154,7 +154,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel \Magento\Newsletter\Helper\Data $newsletterData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, CustomerAccountServiceInterface $customerAccountService, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index 1ed8bfa930b..c3668c56c41 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -70,7 +70,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate /** * Store manager to emulate design * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -112,7 +112,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\App\Emulation $appEmulation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Newsletter\Model\Template\Filter $filter * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -125,7 +125,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Core\Model\App\Emulation $appEmulation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Newsletter\Model\Template\Filter $filter, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 3fa4085a1e1..01d876cb1f2 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/etc/frontend/di.xml b/app/code/Magento/Newsletter/etc/frontend/di.xml index aeac870fe31..fc6e1f3bf22 100644 --- a/app/code/Magento/Newsletter/etc/frontend/di.xml +++ b/app/code/Magento/Newsletter/etc/frontend/di.xml @@ -24,11 +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\Newsletter\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 0e4dd8689f6..9a025f1dbaa 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-payment": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-payment": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php index 19468bff577..4a8cea06b6e 100644 --- a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php +++ b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ExportTablerates.php @@ -35,7 +35,7 @@ class ExportTablerates extends \Magento\Backend\Controller\Adminhtml\System\Abst protected $_fileFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -44,14 +44,14 @@ class ExportTablerates extends \Magento\Backend\Controller\Adminhtml\System\Abst * @param \Magento\Backend\Model\Config\Structure $configStructure * @param ConfigSectionChecker $sectionChecker * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\Config\Structure $configStructure, ConfigSectionChecker $sectionChecker, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; $this->_fileFactory = $fileFactory; diff --git a/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php index 3fca91e9971..0ec117b58df 100644 --- a/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php +++ b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php @@ -35,16 +35,16 @@ class Freeshipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTota protected $_calculator; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator ) { $this->setCode('discount'); diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php index d906e963b35..57b8b45a522 100644 --- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php @@ -106,7 +106,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_logger; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -136,7 +136,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory @@ -146,7 +146,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb \Magento\Framework\App\Resource $resource, \Magento\Framework\Logger $logger, \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate, \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 6297d766a26..03fa0cfd628 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/Model/Api.php b/app/code/Magento/Ogone/Model/Api.php index b64d69376bd..91536ad42d4 100644 --- a/app/code/Magento/Ogone/Model/Api.php +++ b/app/code/Magento/Ogone/Model/Api.php @@ -462,7 +462,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod protected $_urlBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -476,7 +476,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\Stdlib\String $string @@ -488,7 +488,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Stdlib\String $string, diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index 474001ab844..c6baf062228 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php index 3234af5463d..624b9e1e3d9 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php @@ -110,7 +110,8 @@ class MessageBox if ($this->request->isPost() && $this->messageManager->hasMessages()) { $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() ->setDuration(self::COOKIE_PERIOD) - ->setPath('/'); + ->setPath('/') + ->setHttpOnly(false); $this->cookieManager->setPublicCookie(self::COOKIE_NAME, 1, $publicCookieMetadata); } return $response; diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index 18b296cd957..0dda6829dd4 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index acd9b596410..4538e1236c5 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-paypal": "0.1.0-alpha94", - "magento/module-recurring-payment": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-paypal": "0.1.0-alpha95", + "magento/module-recurring-payment": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index 083d51d5398..2322741f596 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -54,7 +54,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -65,7 +65,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -73,7 +73,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($eventManager, $paymentData, $scopeConfig, $logAdapterFactory, $data); diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 7b2ed9f2472..0edbbc14963 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index 20caf2cdf53..898a4d3ae98 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -620,7 +620,7 @@ class Config protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -637,7 +637,7 @@ class Config /** * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory * @param \Magento\Paypal\Model\CertFactory $certFactory * @param array $params @@ -645,7 +645,7 @@ class Config public function __construct( \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Payment\Model\Source\CctypeFactory $cctypeFactory, \Magento\Paypal\Model\CertFactory $certFactory, $params = array() diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 392c2b8eb92..aa5d35482dd 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -130,7 +130,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc protected $_pro; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -159,7 +159,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -177,7 +177,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index e4d2ecfe65c..737217014bb 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -156,7 +156,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod protected $_authorizationCountKey = 'authorization_count'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -186,7 +186,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Paypal\Model\CartFactory $cartFactory * @param \Magento\Checkout\Model\Session $checkoutSession @@ -199,7 +199,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Checkout\Model\Session $checkoutSession, diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index e1c9bb83bbd..783d18c4bed 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -202,7 +202,7 @@ class Checkout protected $_paypalInfo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -297,7 +297,7 @@ class Checkout * @param \Magento\Framework\App\Cache\Type\Config $configCacheType * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Paypal\Model\Info $paypalInfo - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $coreUrl * @param \Magento\Paypal\Model\CartFactory $cartFactory * @param \Magento\Framework\Logger\AdapterFactory $logFactory @@ -308,7 +308,7 @@ class Checkout * @param \Magento\Framework\Object\Copy $objectCopyService * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService - * @param \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilder + * @param \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilderFactory * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor @@ -326,7 +326,7 @@ class Checkout \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Paypal\Model\Info $paypalInfo, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $coreUrl, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Framework\Logger\AdapterFactory $logFactory, @@ -337,7 +337,7 @@ class Checkout \Magento\Framework\Object\Copy $objectCopyService, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, - \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilder, + \Magento\Customer\Service\V1\Data\AddressBuilderFactory $addressBuilderFactory, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, @@ -363,7 +363,7 @@ class Checkout $this->_objectCopyService = $objectCopyService; $this->_checkoutSession = $checkoutSession; $this->_customerAccountService = $customerAccountService; - $this->_addressBuilderFactory = $addressBuilder; + $this->_addressBuilderFactory = $addressBuilderFactory; $this->_customerBuilder = $customerBuilder; $this->_customerDetailsBuilder = $customerDetailsBuilder; $this->_encryptor = $encryptor; @@ -549,7 +549,9 @@ class Checkout // suppress or export shipping address if ($this->_quote->getIsVirtual()) { - if ($this->_config->getConfigValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL) { + if ($this->_config->getConfigValue('requireBillingAddress') + == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL + ) { $this->_api->setRequireBillingAddress(1); } $this->_api->setSuppressShipping(true); @@ -1281,6 +1283,7 @@ class Checkout // @codingStandardsIgnoreEnd ); } else { + $this->getCustomerSession()->regenerateId(); $this->getCustomerSession()->loginById($customer->getId()); } return $this; diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index c887fde91d1..2641e741456 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -96,7 +96,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -115,7 +115,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php index cc2e0d474b0..354dbbed8a6 100644 --- a/app/code/Magento/Paypal/Model/Method/Agreement.php +++ b/app/code/Magento/Paypal/Model/Method/Agreement.php @@ -118,7 +118,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr protected $_pro; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ProFactory $proFactory * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -152,7 +152,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ProFactory $proFactory, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/Observer.php b/app/code/Magento/Paypal/Model/Observer.php index 5a8782ba831..b2021785f7b 100644 --- a/app/code/Magento/Paypal/Model/Observer.php +++ b/app/code/Magento/Paypal/Model/Observer.php @@ -196,7 +196,7 @@ class Observer $result = $this->_coreData->jsonDecode($controller->getResponse()->getBody('default')); if (empty($result['error'])) { - $this->_view->loadLayout('checkout_onepage_review'); + $this->_view->loadLayout('checkout_onepage_review', true, true, false); $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml(); $result['update_section'] = array('name' => 'paypaliframe', 'html' => $html); $result['redirect'] = false; diff --git a/app/code/Magento/Paypal/Model/PayflowExpress.php b/app/code/Magento/Paypal/Model/PayflowExpress.php index b98753af068..6c83283e259 100644 --- a/app/code/Magento/Paypal/Model/PayflowExpress.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress.php @@ -56,7 +56,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param ProFactory $proFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param CartFactory $cartFactory * @param \Magento\Checkout\Model\Session $checkoutSession @@ -70,7 +70,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, ProFactory $proFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, CartFactory $cartFactory, \Magento\Checkout\Model\Session $checkoutSession, diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 370bb739c7b..48605cadf2c 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -160,7 +160,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory @@ -183,7 +183,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index 9e4be498b69..a935047ad96 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -212,7 +212,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc ); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -240,7 +240,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory @@ -257,7 +257,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 642ca200ae5..131ed0774d7 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -164,7 +164,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel protected $_tmpDirectory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -177,7 +177,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -187,7 +187,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Filesystem $filesystem, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/Model/Standard.php b/app/code/Magento/Paypal/Model/Standard.php index db3685289c1..dc2b4e6c588 100644 --- a/app/code/Magento/Paypal/Model/Standard.php +++ b/app/code/Magento/Paypal/Model/Standard.php @@ -76,7 +76,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod protected $_urlBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -108,7 +108,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\Session\Generic $paypalSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Paypal\Model\Api\StandardFactory $apiStandardFactory * @param \Magento\Paypal\Model\CartFactory $cartFactory @@ -125,7 +125,7 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Framework\Session\Generic $paypalSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Paypal\Model\Api\StandardFactory $apiStandardFactory, \Magento\Paypal\Model\CartFactory $cartFactory, diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php index 675ed83bb83..2720de07de8 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -36,7 +36,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value protected $_coreData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -44,7 +44,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\Data $coreData, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index 4d52c851549..d968f516586 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-centinel": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-centinel": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/etc/adminhtml/di.xml b/app/code/Magento/Paypal/etc/adminhtml/di.xml index 34037115d3b..91b258f4b0f 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/di.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Paypal\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Framework\Session\Storage"> @@ -43,14 +42,8 @@ <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\PayflowSession\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> <type name="Magento\Backend\Model\Config\Structure"> <plugin name="paypal_system_configuration" type="Magento\Paypal\Model\Config\StructurePlugin"/> </type> diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 7605fb37438..689600ab689 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Paypal\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Framework\Session\Storage"> @@ -43,14 +42,8 @@ <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Paypal\Model\PayflowSession\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/code/Magento/Persistent/Helper/Data.php b/app/code/Magento/Persistent/Helper/Data.php index a54c9f3c7ee..f3679aa4759 100644 --- a/app/code/Magento/Persistent/Helper/Data.php +++ b/app/code/Magento/Persistent/Helper/Data.php @@ -63,7 +63,7 @@ class Data extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Module\Dir\Reader $modulesReader @@ -73,7 +73,7 @@ class Data extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Module\Dir\Reader $modulesReader, diff --git a/app/code/Magento/Persistent/Helper/Session.php b/app/code/Magento/Persistent/Helper/Session.php index 0946f7fcd4c..30e2b2fde05 100644 --- a/app/code/Magento/Persistent/Helper/Session.php +++ b/app/code/Magento/Persistent/Helper/Session.php @@ -66,7 +66,7 @@ class Session extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param Data $persistentData @@ -77,7 +77,7 @@ class Session extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Persistent\Helper\Data $persistentData, diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index c4dd6a31ae3..af7d6a17543 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -84,7 +84,7 @@ class Session extends \Magento\Framework\Model\AbstractModel /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -122,7 +122,7 @@ class Session extends \Magento\Framework\Model\AbstractModel * @param \Magento\Persistent\Helper\Data $persistentData * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -137,7 +137,7 @@ class Session extends \Magento\Framework\Model\AbstractModel \Magento\Persistent\Helper\Data $persistentData, \Magento\Framework\Stdlib\CookieManager $cookieManager, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -312,14 +312,8 @@ class Session extends \Magento\Framework\Model\AbstractModel */ public function setPersistentCookie($duration, $path) { - $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDuration($duration) - ->setPath($path); - $this->_cookieManager->setPublicCookie( - self::COOKIE_NAME, - $this->getKey(), - $publicCookieMetadata - ); + $value = $this->getKey(); + $this->setCookie($value, $duration, $path); return $this; } @@ -337,14 +331,7 @@ class Session extends \Magento\Framework\Model\AbstractModel } $value = $this->_cookieManager->getCookie(self::COOKIE_NAME); if (null !== $value) { - $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDuration($duration) - ->setPath($path); - $this->_cookieManager->setPublicCookie( - self::COOKIE_NAME, - $value, - $publicCookieMetadata - ); + $this->setCookie($value, $duration, $path); } return $this; } @@ -395,4 +382,25 @@ class Session extends \Magento\Framework\Model\AbstractModel $this->setUpdatedAt(gmdate('Y-m-d H:i:s')); return parent::save(); } + + /** + * Set persistent shopping cart cookie. + * + * @param string $value + * @param int $duration + * @param string $path + * @return void + */ + private function setCookie($value, $duration, $path) + { + $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setDuration($duration) + ->setPath($path) + ->setHttpOnly(true); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $value, + $publicCookieMetadata + ); + } } diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index ae67fe53027..b9a46d4c5ab 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/ProductAlert/Controller/Add/Price.php b/app/code/Magento/ProductAlert/Controller/Add/Price.php index 184fa007cfb..d990228e151 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Price.php @@ -29,19 +29,19 @@ use Magento\Framework\App\Action\Context; class Price extends \Magento\ProductAlert\Controller\Add { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param Context $context * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( Context $context, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($context, $customerSession); @@ -102,7 +102,7 @@ class Price extends \Magento\ProductAlert\Controller\Add )->setPrice( $product->getFinalPrice() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $model->save(); $this->messageManager->addSuccess(__('You saved the alert subscription.')); diff --git a/app/code/Magento/ProductAlert/Controller/Add/Stock.php b/app/code/Magento/ProductAlert/Controller/Add/Stock.php index ab2eaa59ce5..b5a40826a08 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Stock.php @@ -53,7 +53,7 @@ class Stock extends \Magento\ProductAlert\Controller\Add )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $model->save(); $this->messageManager->addSuccess(__('Alert subscription has been saved.')); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php index 2db2e593e51..39ce0731aa1 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php @@ -53,7 +53,7 @@ class Price extends \Magento\ProductAlert\Controller\Unsubscribe )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() )->loadByParam(); if ($model->getId()) { $model->delete(); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php index f0adb85609c..2d7eb719677 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/PriceAll.php @@ -36,7 +36,7 @@ class PriceAll extends \Magento\ProductAlert\Controller\Unsubscribe 'Magento\ProductAlert\Model\Price' )->deleteCustomer( $this->_customerSession->getCustomerId(), - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $this->messageManager->addSuccess(__('You will no longer receive price alerts for this product.')); } catch (\Exception $e) { diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php index 7e2f59008a0..1bdd233f249 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php @@ -54,7 +54,7 @@ class Stock extends \Magento\ProductAlert\Controller\Unsubscribe )->setProductId( $product->getId() )->setWebsiteId( - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() )->loadByParam(); if ($model->getId()) { $model->delete(); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php index fd920a5fb5b..9cf6be9a1a8 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/StockAll.php @@ -36,7 +36,7 @@ class StockAll extends \Magento\ProductAlert\Controller\Unsubscribe 'Magento\ProductAlert\Model\Stock' )->deleteCustomer( $this->_customerSession->getCustomerId(), - $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId() + $this->_objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId() ); $this->messageManager->addSuccess(__('You will no longer receive stock alerts.')); } catch (\Exception $e) { diff --git a/app/code/Magento/ProductAlert/Helper/Data.php b/app/code/Magento/ProductAlert/Helper/Data.php index c413eb9356c..d3a04208ddd 100644 --- a/app/code/Magento/ProductAlert/Helper/Data.php +++ b/app/code/Magento/ProductAlert/Helper/Data.php @@ -60,14 +60,14 @@ class Data extends \Magento\Core\Helper\Url /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig diff --git a/app/code/Magento/ProductAlert/Model/Email.php b/app/code/Magento/ProductAlert/Model/Email.php index d8016ac1d8c..4877cafbb6d 100644 --- a/app/code/Magento/ProductAlert/Model/Email.php +++ b/app/code/Magento/ProductAlert/Model/Email.php @@ -100,7 +100,7 @@ class Email extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -129,7 +129,7 @@ class Email extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\ProductAlert\Helper\Data $productAlertData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Helper\View $customerHelper * @param \Magento\Core\Model\App\Emulation $appEmulation @@ -143,7 +143,7 @@ class Email extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\ProductAlert\Helper\Data $productAlertData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Helper\View $customerHelper, \Magento\Core\Model\App\Emulation $appEmulation, diff --git a/app/code/Magento/ProductAlert/Model/Observer.php b/app/code/Magento/ProductAlert/Model/Observer.php index 361ade36842..0b3ced69f5b 100644 --- a/app/code/Magento/ProductAlert/Model/Observer.php +++ b/app/code/Magento/ProductAlert/Model/Observer.php @@ -86,7 +86,7 @@ class Observer protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -133,7 +133,7 @@ class Observer /** * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -146,7 +146,7 @@ class Observer public function __construct( \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory, \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 0e02704d83b..6649bbd012a 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/Model/Observer.php b/app/code/Magento/RecurringPayment/Model/Observer.php index 345bdb277d9..0076a8d7200 100644 --- a/app/code/Magento/RecurringPayment/Model/Observer.php +++ b/app/code/Magento/RecurringPayment/Model/Observer.php @@ -38,7 +38,7 @@ class Observer /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,13 +56,13 @@ class Observer /** * @param \Magento\Framework\LocaleInterface $locale - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\RecurringPayment\Model\RecurringPaymentFactory $recurringPaymentFactory * @param \Magento\RecurringPayment\Block\Fields $fields */ public function __construct( \Magento\Framework\LocaleInterface $locale, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\RecurringPayment\Model\RecurringPaymentFactory $recurringPaymentFactory, \Magento\RecurringPayment\Block\Fields $fields ) { diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index f7e4affabff..8f1a7652d64 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/Model/Config.php b/app/code/Magento/Reports/Model/Config.php index a24369dd0dc..3f6b17098bb 100644 --- a/app/code/Magento/Reports/Model/Config.php +++ b/app/code/Magento/Reports/Model/Config.php @@ -34,18 +34,18 @@ class Config extends \Magento\Framework\Object protected $_moduleReader; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Module\Dir\Reader $moduleReader - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( \Magento\Framework\Module\Dir\Reader $moduleReader, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { parent::__construct($data); diff --git a/app/code/Magento/Reports/Model/Event/Observer.php b/app/code/Magento/Reports/Model/Event/Observer.php index ceb50ae3be8..b2c83d086a4 100644 --- a/app/code/Magento/Reports/Model/Event/Observer.php +++ b/app/code/Magento/Reports/Model/Event/Observer.php @@ -29,7 +29,7 @@ namespace Magento\Reports\Model\Event; class Observer { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -54,32 +54,32 @@ class Observer protected $_customerSession; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Reports\Model\EventFactory $event * @param \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory * @param \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Reports\Model\EventFactory $event, \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory, \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Log\Model\Visitor $logVisitor + \Magento\Customer\Model\Visitor $customerVisitor ) { $this->_storeManager = $storeManager; $this->_eventFactory = $event; $this->_productCompFactory = $productCompFactory; $this->_productIndxFactory = $productIndxFactory; $this->_customerSession = $customerSession; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; } /** @@ -99,7 +99,7 @@ class Observer if ($this->_customerSession->isLoggedIn()) { $subjectId = $this->_customerSession->getCustomerId(); } else { - $subjectId = $this->_logVisitor->getId(); + $subjectId = $this->_customerVisitor->getId(); $subtype = 1; } } @@ -134,7 +134,7 @@ class Observer return $this; } - $visitorId = $this->_logVisitor->getId(); + $visitorId = $this->_customerVisitor->getId(); $customerId = $this->_customerSession->getCustomerId(); $eventModel = $this->_eventFactory->create(); $eventModel->updateCustomerType($visitorId, $customerId); diff --git a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php index 972858dd145..38937fcd7da 100644 --- a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php @@ -36,14 +36,14 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel protected $_countCacheKey; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * @var \Magento\Customer\Model\Session @@ -68,8 +68,8 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -81,8 +81,8 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, @@ -94,7 +94,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; $this->dateTime = $dateTime; - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; $this->_customerSession = $customerSession; $this->_reportSession = $reportSession; $this->_productVisibility = $productVisibility; @@ -137,7 +137,7 @@ abstract class AbstractIndex extends \Magento\Framework\Model\AbstractModel if ($this->hasData('visitor_id')) { return $this->getData('visitor_id'); } - return $this->_logVisitor->getId(); + return $this->_customerVisitor->getId(); } /** diff --git a/app/code/Magento/Reports/Model/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Product/Index/Compared.php index 94f337d74c7..94c64f10e0c 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Product/Index/Compared.php @@ -57,8 +57,8 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Session\Generic $reportSession * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -71,8 +71,8 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Session\Generic $reportSession, \Magento\Catalog\Model\Product\Visibility $productVisibility, @@ -86,7 +86,7 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex $context, $registry, $storeManager, - $logVisitor, + $customerVisitor, $customerSession, $reportSession, $productVisibility, diff --git a/app/code/Magento/Reports/Model/Resource/Event.php b/app/code/Magento/Reports/Model/Resource/Event.php index abf1d6a31a1..3fd772da56f 100644 --- a/app/code/Magento/Reports/Model/Resource/Event.php +++ b/app/code/Magento/Reports/Model/Resource/Event.php @@ -36,19 +36,19 @@ class Event extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct($resource); $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 357604ea000..23134cd656e 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -54,7 +54,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -80,7 +80,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\DB\Helper $coreResourceHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory @@ -96,7 +96,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\DB\Helper $coreResourceHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index 58b96aede06..f7ab6b0a0d8 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -82,7 +82,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -108,7 +108,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index fd67d640e7a..89942c3b4cf 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -40,9 +40,9 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc protected $_customerId = null; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ - protected $_logVisitor; + protected $_customerVisitor; /** * @param \Magento\Core\Model\EntityFactory $entityFactory @@ -54,7 +54,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -63,7 +63,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Log\Model\Visitor $logVisitor + * @param \Magento\Customer\Model\Visitor $customerVisitor * @param mixed $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -78,7 +78,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -87,7 +87,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Log\Model\Visitor $logVisitor, + \Magento\Customer\Model\Visitor $customerVisitor, $connection = null ) { parent::__construct( @@ -111,7 +111,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc $dateTime, $connection ); - $this->_logVisitor = $logVisitor; + $this->_customerVisitor = $customerVisitor; } /** @@ -184,7 +184,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\Resource\Produc } elseif ($this->_customerId) { $condition['customer_id'] = $this->_customerId; } else { - $condition['visitor_id'] = $this->_logVisitor->getId(); + $condition['visitor_id'] = $this->_customerVisitor->getId(); } return $condition; diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 839db3bcb64..072550c026e 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -66,7 +66,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -94,7 +94,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php index ad038a18d60..c9402640d50 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php @@ -44,7 +44,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Review\Helper\Data $reviewData * @param \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -56,7 +56,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Review\Helper\Data $reviewData, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Resource\Customer $customerResource, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index e7ffc1b1d0a..4b5426fb211 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-log": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-downloadable": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-log": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-downloadable": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/adminhtml/di.xml b/app/code/Magento/Reports/etc/adminhtml/di.xml index 42ebf99024b..17e2bd98dfa 100644 --- a/app/code/Magento/Reports/etc/adminhtml/di.xml +++ b/app/code/Magento/Reports/etc/adminhtml/di.xml @@ -24,11 +24,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <virtualType name="Magento\Reports\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </virtualType> <type name="Magento\Reports\Model\Resource\Customer\Collection"> <arguments> <argument name="modelName" xsi:type="string">Magento\Customer\Model\Backend\Customer</argument> diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index ba3076e652b..6c2d254e460 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php b/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php index aa0a64ee94b..33d0dd52936 100644 --- a/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php +++ b/app/code/Magento/Review/Block/Product/Compare/ListCompare/Plugin/Review.php @@ -36,16 +36,16 @@ class Review /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\ReviewFactory $reviewFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\ReviewFactory $reviewFactory ) { $this->storeManager = $storeManager; diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php index 72eefddbba5..d9cd0f5c1a6 100644 --- a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php +++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php @@ -34,8 +34,8 @@ class Post extends \Magento\Review\Controller\Adminhtml\Product $productId = $this->getRequest()->getParam('product_id', false); if ($data = $this->getRequest()->getPost()) { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManagerInterface */ - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManagerInterface */ + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); if ($storeManager->hasSingleStore()) { $data['stores'] = array( $storeManager->getStore(true)->getId() diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php index cd735d1fe62..2821ef0ff38 100644 --- a/app/code/Magento/Review/Controller/Product.php +++ b/app/code/Magento/Review/Controller/Product.php @@ -100,7 +100,7 @@ class Product extends \Magento\Framework\App\Action\Action /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -122,7 +122,7 @@ class Product extends \Magento\Framework\App\Action\Action * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Catalog\Model\Design $catalogDesign * @param \Magento\Framework\Session\Generic $reviewSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator */ public function __construct( @@ -136,7 +136,7 @@ class Product extends \Magento\Framework\App\Action\Action \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Catalog\Model\Design $catalogDesign, \Magento\Framework\Session\Generic $reviewSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Review/Model/Resource/Rating.php b/app/code/Magento/Review/Model/Resource/Rating.php index 3bf47064b02..8ea8e825c21 100644 --- a/app/code/Magento/Review/Model/Resource/Rating.php +++ b/app/code/Magento/Review/Model/Resource/Rating.php @@ -35,7 +35,7 @@ class Rating extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -55,14 +55,14 @@ class Rating extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Logger $logger * @param \Magento\Review\Helper\Data $ratingData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Review\Summary $reviewSummary */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Logger $logger, \Magento\Review\Helper\Data $ratingData, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Review\Summary $reviewSummary ) { $this->_ratingData = $ratingData; diff --git a/app/code/Magento/Review/Model/Resource/Rating/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Collection.php index f33c6f2edf2..7cbcf9ea511 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Collection.php @@ -31,7 +31,7 @@ namespace Magento\Review\Model\Resource\Rating; class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -51,7 +51,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -61,7 +61,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php index 396f58c2da0..5771a2667e1 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Grid/Collection.php @@ -42,7 +42,7 @@ class Collection extends \Magento\Review\Model\Resource\Rating\Collection * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param \Magento\Framework\Registry $coreRegistry * @param mixed $connection @@ -53,7 +53,7 @@ class Collection extends \Magento\Review\Model\Resource\Rating\Collection \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, \Magento\Framework\Registry $coreRegistry, $connection = null, diff --git a/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php b/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php index 4e47cc2def8..9842658ed82 100644 --- a/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Rating/Option/Vote/Collection.php @@ -33,7 +33,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store list manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource @@ -57,7 +57,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\Resource\Rating\Option\CollectionFactory $ratingCollectionF, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index 5d047fe81a9..7fcd9cf238a 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.php @@ -89,7 +89,7 @@ class Review extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -110,14 +110,14 @@ class Review extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime\DateTime $date - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Review\Model\Resource\Rating\Option $ratingOptions */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Review\Model\RatingFactory $ratingFactory, Rating\Option $ratingOptions ) { diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php index e5b52ad4440..af2c157af02 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php @@ -88,7 +88,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Review\Helper\Data $reviewData * @param \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -110,7 +110,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Review\Helper\Data $reviewData, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php index 754029321e0..fd288835d29 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php @@ -84,7 +84,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -109,7 +109,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\Resource\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index b4e22d8efa4..e7c148df21d 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -115,7 +115,7 @@ class Review extends \Magento\Framework\Model\AbstractModel /** * Core model store manager interface * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -134,7 +134,7 @@ class Review extends \Magento\Framework\Model\AbstractModel * @param \Magento\Review\Model\Resource\Review\Summary\CollectionFactory $summaryFactory * @param \Magento\Review\Model\Review\SummaryFactory $summaryModFactory * @param \Magento\Review\Model\Review\Summary $reviewSummary - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlModel * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -148,7 +148,7 @@ class Review extends \Magento\Framework\Model\AbstractModel \Magento\Review\Model\Resource\Review\Summary\CollectionFactory $summaryFactory, \Magento\Review\Model\Review\SummaryFactory $summaryModFactory, \Magento\Review\Model\Review\Summary $reviewSummary, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlModel, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 6572b19a11e..e5f0c67753d 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-newsletter": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-newsletter": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/etc/adminhtml/di.xml b/app/code/Magento/Review/etc/adminhtml/di.xml index 7260638f2af..c229601f510 100644 --- a/app/code/Magento/Review/etc/adminhtml/di.xml +++ b/app/code/Magento/Review/etc/adminhtml/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Review\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Review\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> <type name="Magento\Review\Block\Form"> diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml index 7829e685920..b28d9f17f56 100644 --- a/app/code/Magento/Review/etc/frontend/di.xml +++ b/app/code/Magento/Review/etc/frontend/di.xml @@ -32,7 +32,6 @@ <virtualType name="Magento\Review\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Review\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> <type name="Magento\Review\Block\Form"> diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php index 714d9bc3ca9..0204ebbd3e5 100644 --- a/app/code/Magento/Rss/Block/Catalog/Review.php +++ b/app/code/Magento/Rss/Block/Catalog/Review.php @@ -44,7 +44,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock protected $_reviewFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -53,7 +53,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Framework\Model\Resource\Iterator $resourceIterator * @param \Magento\Review\Model\ReviewFactory $reviewFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ public function __construct( @@ -61,7 +61,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock \Magento\Rss\Model\RssFactory $rssFactory, \Magento\Framework\Model\Resource\Iterator $resourceIterator, \Magento\Review\Model\ReviewFactory $reviewFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, array $data = array() ) { $this->_rssFactory = $rssFactory; diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 11a2d4c5b65..23a776ea84a 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-review": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-review": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/view/frontend/templates/list.phtml b/app/code/Magento/Rss/view/frontend/templates/list.phtml index 862af46b6f4..7ecf666c38a 100644 --- a/app/code/Magento/Rss/view/frontend/templates/list.phtml +++ b/app/code/Magento/Rss/view/frontend/templates/list.phtml @@ -54,7 +54,7 @@ <tbody> <?php foreach ($_categories as $_category): ?> <tr> - <td class="col feed"><?php echo $_category->getLabel() ?></td> + <td class="col feed"><?php echo $this->escapeHtml($_category->getLabel()) ?></td> <td class="col action"><a href="<?php echo $_category->getUrl() ?>" class="action get"><span><?php echo __('Get Feed'); ?></span></a></td> </tr> <?php endforeach; ?> diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 615e8883ca1..ad76ec72f52 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php index 84f43672af8..32987b6a3bc 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php @@ -44,6 +44,7 @@ class Save extends \Magento\Sales\Controller\Adminhtml\Order\Create $this->_forward('denied'); return; } + $this->_getOrderCreateModel()->getQuote()->setCustomerId($this->_getSession()->getCustomerId()); $this->_processActionData('save'); $paymentData = $this->getRequest()->getPost('payment'); if ($paymentData) { diff --git a/app/code/Magento/Sales/Helper/Admin.php b/app/code/Magento/Sales/Helper/Admin.php index d6c46a3538d..0b8975bdb46 100644 --- a/app/code/Magento/Sales/Helper/Admin.php +++ b/app/code/Magento/Sales/Helper/Admin.php @@ -31,18 +31,18 @@ class Admin extends \Magento\Framework\App\Helper\AbstractHelper protected $_salesConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Config $salesConfig */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Config $salesConfig ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Helper/Guest.php b/app/code/Magento/Sales/Helper/Guest.php index 36d410d9466..a5f3820c28b 100644 --- a/app/code/Magento/Sales/Helper/Guest.php +++ b/app/code/Magento/Sales/Helper/Guest.php @@ -81,7 +81,7 @@ class Guest extends \Magento\Core\Helper\Data /** * @param App\Helper\Context $context * @param App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Framework\Registry $coreRegistry @@ -98,7 +98,7 @@ class Guest extends \Magento\Core\Helper\Data public function __construct( App\Helper\Context $context, App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Framework\Registry $coreRegistry, @@ -186,10 +186,7 @@ class Guest extends \Magento\Core\Helper\Data if (!$errors) { $toCookie = base64_encode($order->getProtectCode() . ':' . $incrementId); - $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); - $metadata->setPath(self::COOKIE_PATH); - $metadata->setDuration(self::COOKIE_LIFETIME); - $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $toCookie, $metadata); + $this->setGuestViewCookie($toCookie); } } elseif ($fromCookie) { $cookieData = explode(':', base64_decode($fromCookie)); @@ -201,10 +198,7 @@ class Guest extends \Magento\Core\Helper\Data $order->loadByIncrementId($incrementId); if ($order->getProtectCode() == $protectCode) { // renew cookie - $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); - $metadata->setPath(self::COOKIE_PATH); - $metadata->setDuration(self::COOKIE_LIFETIME); - $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $fromCookie, $metadata); + $this->setGuestViewCookie($fromCookie); $errors = false; } } @@ -241,4 +235,19 @@ class Guest extends \Magento\Core\Helper\Data array('label' => __('Order Information'), 'title' => __('Order Information')) ); } + + /** + * Set guest-view cookie + * + * @param string $cookieValue + * @return void + */ + private function setGuestViewCookie($cookieValue) + { + $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setPath(self::COOKIE_PATH) + ->setDuration(self::COOKIE_LIFETIME) + ->setHttpOnly(true); + $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $cookieValue, $metadata); + } } diff --git a/app/code/Magento/Sales/Helper/Reorder.php b/app/code/Magento/Sales/Helper/Reorder.php index 59a6c10bd90..82ae446cf4c 100644 --- a/app/code/Magento/Sales/Helper/Reorder.php +++ b/app/code/Magento/Sales/Helper/Reorder.php @@ -38,7 +38,7 @@ class Reorder extends \Magento\Core\Helper\Data /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param \Magento\Customer\Model\Session $customerSession @@ -47,7 +47,7 @@ class Reorder extends \Magento\Core\Helper\Data public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\State $appState, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Customer\Model\Session $customerSession, diff --git a/app/code/Magento/Sales/Model/AbstractModel.php b/app/code/Magento/Sales/Model/AbstractModel.php index e22f2335ce4..1bb1f251c5e 100644 --- a/app/code/Magento/Sales/Model/AbstractModel.php +++ b/app/code/Magento/Sales/Model/AbstractModel.php @@ -69,20 +69,6 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel */ abstract public function getStore(); - /** - * Processing object after save data - * Updates relevant grid table records. - * - * @return $this - */ - public function afterCommitCallback() - { - if (!$this->getForceUpdateGridRecords()) { - $this->_getResource()->updateGridRecords($this->getId()); - } - return parent::afterCommitCallback(); - } - /** * Get object created at date affected current active store timezone * @@ -106,4 +92,24 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractModel true ); } + + /** + * Returns _eventPrefix + * + * @return string + */ + public function getEventPrefix() + { + return $this->_eventPrefix; + } + + /** + * Returns _eventObject + * + * @return string + */ + public function getEventObject() + { + return $this->_eventObject; + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php b/app/code/Magento/Sales/Model/EntityInterface.php similarity index 85% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php rename to app/code/Magento/Sales/Model/EntityInterface.php index dc03c7c6ef3..f905c8fe6e8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateConfigurable.php +++ b/app/code/Magento/Sales/Model/EntityInterface.php @@ -18,18 +18,19 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @spi * @copyright Copyright (c) 2014 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\Test\Handler\Ui; +namespace Magento\Sales\Model; /** - * Class CreateConfigurable - * Create a configurable product - * + * Interface EntityInterface */ -class CreateConfigurable extends CreateProduct +interface EntityInterface { + /** + * @return string + */ + public function getIncrementId(); } diff --git a/app/code/Magento/Sales/Model/Increment.php b/app/code/Magento/Sales/Model/Increment.php new file mode 100644 index 00000000000..7be553c332b --- /dev/null +++ b/app/code/Magento/Sales/Model/Increment.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model; + +use Magento\Sales\Model\Order; +use Magento\Eav\Model\Config as EavConfig; + +/** + * Class Increment + */ +class Increment +{ + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + + /** + * @var string + */ + protected $incrementValue; + + /** + * @param EavConfig $eavConfig + */ + public function __construct( + EavConfig $eavConfig + ) { + $this->eavConfig = $eavConfig; + } + + /** + * Returns current increment id + * + * @return string + */ + public function getCurrentValue() + { + return $this->incrementValue; + } + + /** + * Returns new value of increment id + * + * @param int $storeId + * @return string + * @throws \Exception + * @throws \Magento\Framework\Model\Exception + */ + public function getNextValue($storeId) + { + $this->incrementValue = + $this->eavConfig->getEntityType(Order::ENTITY)->fetchNewIncrementId($storeId); + return $this->incrementValue; + } +} diff --git a/app/code/Magento/Sales/Model/Observer.php b/app/code/Magento/Sales/Model/Observer.php deleted file mode 100644 index 72dc6bd2ac5..00000000000 --- a/app/code/Magento/Sales/Model/Observer.php +++ /dev/null @@ -1,357 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -/** - * Sales observer - */ -class Observer -{ - /** - * Expire quotes additional fields to filter - * - * @var array - */ - protected $_expireQuotesFilterFields = array(); - - /** - * Catalog data - * - * @var \Magento\Catalog\Helper\Data - */ - protected $_catalogData = null; - - /** - * Customer address - * - * @var \Magento\Customer\Helper\Address - */ - protected $_customerAddressHelper; - - /** - * Customer data - * - * @var \Magento\Customer\Helper\Data - */ - protected $_customerData; - - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager; - - /** - * @var \Magento\Store\Model\StoresConfig - */ - protected $_storesConfig; - - /** - * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory - */ - protected $_quoteCollectionFactory; - - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface - */ - protected $_localeDate; - - /** - * @var Resource\Report\OrderFactory - */ - protected $_orderFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory - */ - protected $_invoicedFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\RefundedFactory - */ - protected $_refundedFactory; - - /** - * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory - */ - protected $_bestsellersFactory; - - /** - * @var \Magento\Framework\Locale\ResolverInterface - */ - protected $_localeResolver; - - /** - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Helper\Data $customerData - * @param \Magento\Customer\Helper\Address $customerAddressHelper - * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Store\Model\StoresConfig $storesConfig - * @param \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory - * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param Resource\Report\OrderFactory $orderFactory - * @param Resource\Report\InvoicedFactory $invoicedFactory - * @param Resource\Report\RefundedFactory $refundedFactory - * @param Resource\Report\BestsellersFactory $bestsellersFactory - * @param \Magento\Framework\Locale\ResolverInterface $localeResolver - */ - public function __construct( - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Customer\Helper\Data $customerData, - \Magento\Customer\Helper\Address $customerAddressHelper, - \Magento\Catalog\Helper\Data $catalogData, - \Magento\Store\Model\StoresConfig $storesConfig, - \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory, - \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory, - \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory, - \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory, - \Magento\Framework\Locale\ResolverInterface $localeResolver - ) { - $this->_eventManager = $eventManager; - $this->_customerData = $customerData; - $this->_customerAddressHelper = $customerAddressHelper; - $this->_catalogData = $catalogData; - $this->_storesConfig = $storesConfig; - $this->_quoteCollectionFactory = $quoteFactory; - $this->_localeDate = $localeDate; - $this->_orderFactory = $orderFactory; - $this->_invoicedFactory = $invoicedFactory; - $this->_refundedFactory = $refundedFactory; - $this->_bestsellersFactory = $bestsellersFactory; - $this->_localeResolver = $localeResolver; - } - - /** - * Clean expired quotes (cron process) - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function cleanExpiredQuotes($schedule) - { - $this->_eventManager->dispatch('clear_expired_quotes_before', array('sales_observer' => $this)); - - $lifetimes = $this->_storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after'); - foreach ($lifetimes as $storeId => $lifetime) { - $lifetime *= 86400; - - /** @var $quotes \Magento\Sales\Model\Resource\Quote\Collection */ - $quotes = $this->_quoteCollectionFactory->create(); - - $quotes->addFieldToFilter('store_id', $storeId); - $quotes->addFieldToFilter('updated_at', array('to' => date("Y-m-d", time() - $lifetime))); - $quotes->addFieldToFilter('is_active', 0); - - foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { - $quotes->addFieldToFilter($field, $condition); - } - - $quotes->walk('delete'); - } - return $this; - } - - /** - * Retrieve expire quotes additional fields to filter - * - * @return array - */ - public function getExpireQuotesAdditionalFilterFields() - { - return $this->_expireQuotesFilterFields; - } - - /** - * Set expire quotes additional fields to filter - * - * @param array $fields - * @return $this - */ - public function setExpireQuotesAdditionalFilterFields(array $fields) - { - $this->_expireQuotesFilterFields = $fields; - return $this; - } - - /** - * Refresh sales order report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportOrderData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_orderFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh sales invoiced report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportInvoicedData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_invoicedFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh sales refunded report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportRefundedData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_refundedFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Refresh bestsellers report statistics for last day - * - * @param \Magento\Cron\Model\Schedule $schedule - * @return $this - */ - public function aggregateSalesReportBestsellersData($schedule) - { - $this->_localeResolver->emulate(0); - $currentDate = $this->_localeDate->date(); - $date = $currentDate->subHour(25); - $this->_bestsellersFactory->create()->aggregate($date); - $this->_localeResolver->revert(); - return $this; - } - - /** - * Set Quote information about MSRP price enabled - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function setQuoteCanApplyMsrp(\Magento\Framework\Event\Observer $observer) - { - /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $observer->getEvent()->getQuote(); - - $canApplyMsrp = false; - if ($this->_catalogData->isMsrpEnabled()) { - foreach ($quote->getAllAddresses() as $address) { - if ($address->getCanApplyMsrp()) { - $canApplyMsrp = true; - break; - } - } - } - - $quote->setCanApplyMsrp($canApplyMsrp); - } - - /** - * Add VAT validation request date and identifier to order comments - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function addVatRequestParamsOrderComment(\Magento\Framework\Event\Observer $observer) - { - /** @var $orderInstance \Magento\Sales\Model\Order */ - $orderInstance = $observer->getOrder(); - /** @var $orderAddress \Magento\Sales\Model\Order\Address */ - $orderAddress = $this->_getVatRequiredSalesAddress($orderInstance); - if (!$orderAddress instanceof \Magento\Sales\Model\Order\Address) { - return; - } - - $vatRequestId = $orderAddress->getVatRequestId(); - $vatRequestDate = $orderAddress->getVatRequestDate(); - if (is_string($vatRequestId) && !empty($vatRequestId) && is_string($vatRequestDate) && !empty($vatRequestDate) - ) { - $orderHistoryComment = __( - 'VAT Request Identifier' - ) . ': ' . $vatRequestId . '<br />' . __( - 'VAT Request Date' - ) . ': ' . $vatRequestDate; - $orderInstance->addStatusHistoryComment($orderHistoryComment, false); - } - } - - /** - * Retrieve sales address (order or quote) on which tax calculation must be based - * - * @param \Magento\Sales\Model\Order $order - * @param \Magento\Store\Model\Store|string|int|null $store - * @return \Magento\Sales\Model\Order\Address|null - */ - protected function _getVatRequiredSalesAddress($order, $store = null) - { - $configAddressType = $this->_customerAddressHelper->getTaxCalculationAddressType($store); - $requiredAddress = null; - switch ($configAddressType) { - case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING: - $requiredAddress = $order->getShippingAddress(); - break; - default: - $requiredAddress = $order->getBillingAddress(); - break; - } - return $requiredAddress; - } - - /** - * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address - * - * @param \Magento\Framework\Event\Observer $observer - * @return void - */ - public function restoreQuoteCustomerGroupId($observer) - { - $quoteAddress = $observer->getQuoteAddress(); - $configAddressType = $this->_customerAddressHelper->getTaxCalculationAddressType(); - // Restore initial customer group ID in quote only if VAT is calculated based on shipping address - if ($quoteAddress->hasPrevQuoteCustomerGroupId() && - $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING - ) { - $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId()); - $quoteAddress->unsPrevQuoteCustomerGroupId(); - } - } -} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php new file mode 100644 index 00000000000..0b0240cafac --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersData.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class AggregateSalesReportBestsellersData + */ +class AggregateSalesReportBestsellersData +{ + /** + * @var ResolverInterface + */ + protected $localeResolver; + + /** + * @var TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory + */ + protected $bestsellersFactory; + + /** + * @param ResolverInterface $localeResolver + * @param TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory + */ + public function __construct( + ResolverInterface $localeResolver, + TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->bestsellersFactory = $bestsellersFactory; + } + + /** + * Refresh bestsellers report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->bestsellersFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.php new file mode 100644 index 00000000000..d02db477a41 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedData.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\Sales\Model\Observer; + +/** + * Class AggregateSalesReportInvoicedData + */ +class AggregateSalesReportInvoicedData +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface + */ + protected $localeResolver; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory + */ + protected $invoicedFactory; + + /** + * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory + */ + public function __construct( + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->invoicedFactory = $invoicedFactory; + } + + /** + * Refresh sales invoiced report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->invoicedFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.php new file mode 100644 index 00000000000..9807d11e878 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportOrderData.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\Sales\Model\Observer; + +/** + * Class AggregateSalesReportOrderData + */ +class AggregateSalesReportOrderData +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface + */ + protected $localeResolver; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\OrderFactory + */ + protected $orderFactory; + + /** + * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory + */ + public function __construct( + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->orderFactory = $orderFactory; + } + + /** + * Refresh sales order report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->orderFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php new file mode 100644 index 00000000000..e6b9c3f236e --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/AggregateSalesReportRefundedData.php @@ -0,0 +1,77 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; + +/** + * Class AggregateSalesReportRefundedData + */ +class AggregateSalesReportRefundedData +{ + /** + * @var ResolverInterface + */ + protected $localeResolver; + + /** + * @var TimezoneInterface + */ + protected $localeDate; + + /** + * @var \Magento\Sales\Model\Resource\Report\RefundedFactory + */ + protected $refundedFactory; + + /** + * @param ResolverInterface $localeResolver + * @param TimezoneInterface $timezone + * @param \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory + */ + public function __construct( + ResolverInterface $localeResolver, + TimezoneInterface $timezone, + \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory + ) { + $this->localeResolver = $localeResolver; + $this->localeDate = $timezone; + $this->refundedFactory = $refundedFactory; + } + + /** + * Refresh sales refunded report statistics for last day + * + * @return void + */ + public function execute() + { + $this->localeResolver->emulate(0); + $currentDate = $this->localeDate->date(); + $date = $currentDate->subHour(25); + $this->refundedFactory->create()->aggregate($date); + $this->localeResolver->revert(); + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php b/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php index 3c4a35be908..f61e3f627b6 100644 --- a/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php +++ b/app/code/Magento/Sales/Model/Observer/Backend/CustomerQuote.php @@ -33,7 +33,7 @@ class CustomerQuote protected $_config; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -43,12 +43,12 @@ class CustomerQuote protected $_quoteFactory; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Config\Share $config * @param \Magento\Sales\Model\QuoteFactory $quoteFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Config\Share $config, \Magento\Sales\Model\QuoteFactory $quoteFactory ) { diff --git a/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php b/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.php new file mode 100644 index 00000000000..14844ae8b2e --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/CleanExpiredQuotes.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\Observer; + +use Magento\Store\Model\StoresConfig; + +/** + * Class CleanExpiredQuotes + */ +class CleanExpiredQuotes +{ + const LIFETIME = 86400; + + /** + * @var StoresConfig + */ + protected $storesConfig; + + /** + * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory + */ + protected $quoteCollectionFactory; + + /** + * @var array + */ + protected $expireQuotesFilterFields = array(); + + /** + * @param StoresConfig $storesConfig + * @param \Magento\Sales\Model\Resource\Quote\CollectionFactory $collectionFactory + */ + public function __construct( + StoresConfig $storesConfig, + \Magento\Sales\Model\Resource\Quote\CollectionFactory $collectionFactory + ) { + $this->storesConfig = $storesConfig; + $this->quoteCollectionFactory = $collectionFactory; + } + + /** + * Clean expired quotes (cron process) + * + * @return void + */ + public function execute() + { + $lifetimes = $this->storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after'); + foreach ($lifetimes as $storeId => $lifetime) { + $lifetime *= self::LIFETIME; + + /** @var $quotes \Magento\Sales\Model\Resource\Quote\Collection */ + $quotes = $this->quoteCollectionFactory->create(); + + $quotes->addFieldToFilter('store_id', $storeId); + $quotes->addFieldToFilter('updated_at', array('to' => date("Y-m-d", time() - $lifetime))); + $quotes->addFieldToFilter('is_active', 0); + + foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { + $quotes->addFieldToFilter($field, $condition); + } + + $quotes->walk('delete'); + } + } + + /** + * Retrieve expire quotes additional fields to filter + * + * @return array + */ + public function getExpireQuotesAdditionalFilterFields() + { + return $this->expireQuotesFilterFields; + } + + /** + * Set expire quotes additional fields to filter + * + * @param array $fields + * @return void + */ + public function setExpireQuotesAdditionalFilterFields(array $fields) + { + $this->expireQuotesFilterFields = $fields; + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.php new file mode 100644 index 00000000000..db6ddc6c402 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderComment.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\Observer\Frontend\Quote; + +use Magento\Customer\Helper\Address as CustomerAddress; + +/** + * Class AddVatRequestParamsOrderComment + */ +class AddVatRequestParamsOrderComment +{ + /** + * Customer address + * + * @var CustomerAddress + */ + protected $customerAddressHelper; + + /** + * @param CustomerAddress $customerAddressHelper + */ + public function __construct(CustomerAddress $customerAddressHelper) + { + $this->customerAddressHelper = $customerAddressHelper; + } + + /** + * Add VAT validation request date and identifier to order comments + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + /** @var $orderInstance \Magento\Sales\Model\Order */ + $orderInstance = $observer->getOrder(); + /** @var $orderAddress \Magento\Sales\Model\Order\Address */ + $orderAddress = $this->_getVatRequiredSalesAddress($orderInstance); + if (!$orderAddress instanceof \Magento\Sales\Model\Order\Address) { + return; + } + + $vatRequestId = $orderAddress->getVatRequestId(); + $vatRequestDate = $orderAddress->getVatRequestDate(); + if (is_string($vatRequestId) + && !empty($vatRequestId) + && is_string($vatRequestDate) + && !empty($vatRequestDate) + ) { + $orderHistoryComment = __('VAT Request Identifier') + . ': ' . $vatRequestId . '<br />' + . __('VAT Request Date') . ': ' . $vatRequestDate; + $orderInstance->addStatusHistoryComment($orderHistoryComment, false); + } + } + + /** + * Retrieve sales address (order or quote) on which tax calculation must be based + * + * @param \Magento\Sales\Model\Order $order + * @param \Magento\Store\Model\Store|string|int|null $store + * @return \Magento\Sales\Model\Order\Address|null + */ + protected function _getVatRequiredSalesAddress($order, $store = null) + { + $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store); + $requiredAddress = null; + switch ($configAddressType) { + case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING: + $requiredAddress = $order->getShippingAddress(); + break; + default: + $requiredAddress = $order->getBillingAddress(); + break; + } + return $requiredAddress; + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.php new file mode 100644 index 00000000000..09c15bc1a61 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupId.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\Observer\Frontend\Quote; + +use Magento\Customer\Helper\Address as CustomerAddress; + +/** + * Class RestoreCustomerGroupId + */ +class RestoreCustomerGroupId +{ + /** + * Customer address + * + * @var CustomerAddress + */ + protected $customerAddressHelper; + + /** + * @param CustomerAddress $customerAddressHelper + */ + public function __construct(CustomerAddress $customerAddressHelper) + { + $this->customerAddressHelper = $customerAddressHelper; + } + + /** + * Restore initial customer group ID in quote if needed on collect_totals_after event of quote address + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute($observer) + { + $quoteAddress = $observer->getQuoteAddress(); + $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType(); + // Restore initial customer group ID in quote only if VAT is calculated based on shipping address + if ($quoteAddress->hasPrevQuoteCustomerGroupId() && + $configAddressType == \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING + ) { + $quoteAddress->getQuote()->setCustomerGroupId($quoteAddress->getPrevQuoteCustomerGroupId()); + $quoteAddress->unsPrevQuoteCustomerGroupId(); + } + } +} diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php new file mode 100644 index 00000000000..de383494690 --- /dev/null +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/SetCanApplyMsrp.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +use Magento\Catalog\Helper\Data as CatalogData; + +/** + * Class SetCanApplyMsrp + */ +class SetCanApplyMsrp +{ + /** + * Catalog data + * + * @var CatalogData + */ + protected $catalogData; + + /** + * @param CatalogData $catalogData + */ + public function __construct(CatalogData $catalogData) + { + $this->catalogData = $catalogData; + } + + /** + * Set Quote information about MSRP price enabled + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + /** @var $quote \Magento\Sales\Model\Quote */ + $quote = $observer->getEvent()->getQuote(); + + $canApplyMsrp = false; + if ($this->catalogData->isMsrpEnabled()) { + foreach ($quote->getAllAddresses() as $address) { + if ($address->getCanApplyMsrp()) { + $canApplyMsrp = true; + break; + } + } + } + + $quote->setCanApplyMsrp($canApplyMsrp); + } +} diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index a275ec26e8b..6097c84f3a3 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -227,7 +227,6 @@ use Magento\Sales\Model\Resource\Order\Status\History\Collection as HistoryColle * @method \Magento\Sales\Model\Order setWeight(float $value) * @method string getCustomerDob() * @method \Magento\Sales\Model\Order setCustomerDob(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order setIncrementId(string $value) * @method string getAppliedRuleIds() * @method \Magento\Sales\Model\Order setAppliedRuleIds(string $value) @@ -310,8 +309,17 @@ use Magento\Sales\Model\Resource\Order\Status\History\Collection as HistoryColle * @method \Magento\Sales\Model\Order setShippingInclTax(float $value) * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order setBaseShippingInclTax(float $value) + * @method bool hasBillingAddressId() + * @method \Magento\Sales\Model\Order unsBillingAddressId() + * @method bool hasShippingAddressId() + * @method \Magento\Sales\Model\Order unsShippingAddressId() + * @method int getShippigAddressId() + * @method bool hasCustomerNoteNotify() + * @method bool hasForcedCanCreditmemo() + * @method bool getIsInProcess() + * @method \Magento\Customer\Model\Customer getCustomer() */ -class Order extends \Magento\Sales\Model\AbstractModel +class Order extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const ENTITY = 'order'; @@ -454,7 +462,7 @@ class Order extends \Magento\Sales\Model\AbstractModel protected $entityType = 'order'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -493,11 +501,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_currencyFactory; - /** - * @var \Magento\Eav\Model\Config - */ - protected $_eavConfig; - /** * @var \Magento\Sales\Model\Order\Status\HistoryFactory */ @@ -548,7 +551,7 @@ 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Order\Config $orderConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param Resource\Order\Item\CollectionFactory $orderItemCollectionFactory @@ -575,7 +578,7 @@ class Order extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Sales\Model\Resource\Order\Item\CollectionFactory $orderItemCollectionFactory, @@ -1176,11 +1179,17 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param string|bool $status * @param string $comment * @param bool $isCustomerNotified + * @param bool $shouldProtectState * @return \Magento\Sales\Model\Order */ - public function setState($state, $status = false, $comment = '', $isCustomerNotified = null) - { - return $this->_setState($state, $status, $comment, $isCustomerNotified, true); + public function setState( + $state, + $status = false, + $comment = '', + $isCustomerNotified = null, + $shouldProtectState = true + ) { + return $this->_setState($state, $status, $comment, $isCustomerNotified, $shouldProtectState); } /** @@ -2127,135 +2136,6 @@ class Order extends \Magento\Sales\Model\AbstractModel return ''; } - /** - * Processing object before save data - * - * @return $this - */ - protected function _beforeSave() - { - parent::_beforeSave(); - $this->_checkState(); - if (!$this->getId()) { - $store = $this->getStore(); - $name = array($store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()); - $this->setStoreName(implode("\n", $name)); - } - - if (!$this->getIncrementId()) { - $incrementId = $this->_eavConfig->getEntityType('order')->fetchNewIncrementId($this->getStoreId()); - $this->setIncrementId($incrementId); - } - - /** - * Process items dependency for new order - */ - if (!$this->getId()) { - $itemsCount = 0; - foreach ($this->getAllItems() as $item) { - $parent = $item->getQuoteParentItemId(); - if ($parent && !$item->getParentItem()) { - $item->setParentItem($this->getItemByQuoteItemId($parent)); - } elseif (!$parent) { - $itemsCount++; - } - } - // Set items count - $this->setTotalItemCount($itemsCount); - } - /** TODO refactor getCustomer usage after MAGETWO-20182 and MAGETWO-20258 are done */ - $isNewCustomer = !$this->getCustomerId() || $this->getCustomerId() === true; - if ($isNewCustomer && $this->getCustomer()) { - $this->setCustomerId($this->getCustomer()->getId()); - } - - if ($this->hasBillingAddressId() && $this->getBillingAddressId() === null) { - $this->unsBillingAddressId(); - } - - if ($this->hasShippingAddressId() && $this->getShippingAddressId() === null) { - $this->unsShippingAddressId(); - } - - $this->setData('protect_code', substr(md5(uniqid(\Magento\Framework\Math\Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6)); - return $this; - } - - /** - * Check order state before saving - * - * @return $this - */ - protected function _checkState() - { - if (!$this->getId()) { - return $this; - } - - $userNotification = $this->hasCustomerNoteNotify() ? $this->getCustomerNoteNotify() : null; - - if (!$this->isCanceled() && !$this->canUnhold() && !$this->canInvoice() && !$this->canShip()) { - if (0 == $this->getBaseGrandTotal() || $this->canCreditmemo()) { - if ($this->getState() !== self::STATE_COMPLETE) { - $this->_setState(self::STATE_COMPLETE, true, '', $userNotification); - } - } elseif (floatval( - $this->getTotalRefunded() - ) || !$this->getTotalRefunded() && $this->hasForcedCanCreditmemo() - ) { - if ($this->getState() !== self::STATE_CLOSED) { - $this->_setState(self::STATE_CLOSED, true, '', $userNotification); - } - } - } - - if ($this->getState() == self::STATE_NEW && $this->getIsInProcess()) { - $this->setState(self::STATE_PROCESSING, true, '', $userNotification); - } - return $this; - } - - /** - * Save order related objects - * - * @return $this - */ - protected function _afterSave() - { - if (null !== $this->_addresses) { - $this->_addresses->save(); - $billingAddress = $this->getBillingAddress(); - $attributesForSave = array(); - if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) { - $this->setBillingAddressId($billingAddress->getId()); - $attributesForSave[] = 'billing_address_id'; - } - - $shippingAddress = $this->getShippingAddress(); - if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) { - $this->setShippingAddressId($shippingAddress->getId()); - $attributesForSave[] = 'shipping_address_id'; - } - - if (!empty($attributesForSave)) { - $this->_getResource()->saveAttribute($this, $attributesForSave); - } - } - if (null !== $this->_items) { - $this->_items->save(); - } - if (null !== $this->_payments) { - $this->_payments->save(); - } - if (null !== $this->_statusHistory) { - $this->_statusHistory->save(); - } - foreach ($this->getRelatedObjects() as $object) { - $object->save(); - } - return parent::_afterSave(); - } - /** * @return string */ @@ -2343,4 +2223,14 @@ class Order extends \Magento\Sales\Model\AbstractModel { return $this->getState() === self::STATE_CANCELED; } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 2a380d120e2..5ac213c6df2 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -24,6 +24,7 @@ namespace Magento\Sales\Model\Order; use Magento\Framework\Model\Exception; +use Magento\Sales\Model\EntityInterface; /** * Order creditmemo model @@ -101,7 +102,6 @@ use Magento\Framework\Model\Exception; * @method \Magento\Sales\Model\Order\Creditmemo setGlobalCurrencyCode(string $value) * @method string getTransactionId() * @method \Magento\Sales\Model\Order\Creditmemo setTransactionId(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Creditmemo setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Creditmemo setCreatedAt(string $value) @@ -120,7 +120,7 @@ use Magento\Framework\Model\Exception; * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order\Creditmemo setBaseShippingInclTax(float $value) */ -class Creditmemo extends \Magento\Sales\Model\AbstractModel +class Creditmemo extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const STATE_OPEN = 1; @@ -197,7 +197,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel protected $_calculatorFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -220,7 +220,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory * @param \Magento\Framework\Math\CalculatorFactory $calculatorFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -236,7 +236,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory, \Magento\Framework\Math\CalculatorFactory $calculatorFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -865,6 +865,16 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel return $this->getResourceCollection()->getFiltered($filter); } + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } + /** * @return bool */ diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index 8a93f427a32..b466129b38f 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_creditmemo; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index 882527fca6b..61e6b2dbb97 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Creditmemo\Total; class Shipping extends AbstractTotal { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,12 +39,12 @@ class Shipping extends AbstractTotal protected $_taxConfig; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Model\Config $taxConfig * @param array $data */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Model\Config $taxConfig, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php index af38cf08fa7..1b81dfb3ee8 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php @@ -23,7 +23,7 @@ */ namespace Magento\Sales\Model\Order\Email\Container; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Store\Model\Store; use Magento\Framework\App\Config\ScopeConfigInterface; diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index e84ae0574a9..a4e40e2c48d 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Sales\Model\EntityInterface; + /** * @method \Magento\Sales\Model\Resource\Order\Invoice _getResource() * @method \Magento\Sales\Model\Resource\Order\Invoice getResource() @@ -90,7 +92,6 @@ namespace Magento\Sales\Model\Order; * @method \Magento\Sales\Model\Order\Invoice setBaseCurrencyCode(string $value) * @method string getGlobalCurrencyCode() * @method \Magento\Sales\Model\Order\Invoice setGlobalCurrencyCode(string $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Invoice setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Invoice setCreatedAt(string $value) @@ -109,7 +110,7 @@ namespace Magento\Sales\Model\Order; * @method float getBaseShippingInclTax() * @method \Magento\Sales\Model\Order\Invoice setBaseShippingInclTax(float $value) */ -class Invoice extends \Magento\Sales\Model\AbstractModel +class Invoice extends \Magento\Sales\Model\AbstractModel implements EntityInterface { /** * Invoice states @@ -196,11 +197,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_orderFactory; - /** - * @var \Magento\Sales\Model\Resource\OrderFactory - */ - protected $_orderResourceFactory; - /** * @var \Magento\Framework\Math\CalculatorFactory */ @@ -228,7 +224,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param Invoice\Config $invoiceConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory * @param \Magento\Framework\Math\CalculatorFactory $calculatorFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory * @param Invoice\CommentFactory $invoiceCommentFactory @@ -244,7 +239,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Sales\Model\Order\Invoice\Config $invoiceConfig, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory, \Magento\Framework\Math\CalculatorFactory $calculatorFactory, \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory, \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory, @@ -255,7 +249,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel ) { $this->_invoiceConfig = $invoiceConfig; $this->_orderFactory = $orderFactory; - $this->_orderResourceFactory = $orderResourceFactory; $this->_calculatorFactory = $calculatorFactory; $this->_invoiceItemCollectionFactory = $invoiceItemCollectionFactory; $this->_invoiceCommentFactory = $invoiceCommentFactory; @@ -346,16 +339,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel return $this->entityType; } - /** - * Retrieve the increment_id of the order - * - * @return string - */ - public function getOrderIncrementId() - { - return $this->_orderResourceFactory->create()->getIncrementId($this->getOrderId()); - } - /** * Retrieve billing address * @@ -884,4 +867,14 @@ class Invoice extends \Magento\Sales\Model\AbstractModel return parent::_afterSave(); } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index f4089d92426..5dd2befe00c 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_invoice; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index c8e54b3cb96..3421b7680f5 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -200,7 +200,7 @@ class Payment extends \Magento\Payment\Model\Info protected $_transactionCollectionFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -212,7 +212,7 @@ class Payment extends \Magento\Payment\Model\Info * @param \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory * @param \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -225,7 +225,7 @@ class Payment extends \Magento\Payment\Model\Info \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory, \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory, \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index 513db26f275..28430cc641c 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Creditmemo extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -43,7 +43,7 @@ class Creditmemo extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data * @@ -60,7 +60,7 @@ class Creditmemo extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index 8f5b345ed21..2221b251087 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Invoice extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -47,7 +47,7 @@ class Invoice extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data @@ -64,7 +64,7 @@ class Invoice extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index bba9ed65621..f6362aea335 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -29,7 +29,7 @@ namespace Magento\Sales\Model\Order\Pdf; class Shipment extends AbstractPdf { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -48,7 +48,7 @@ class Shipment extends AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data * @@ -64,7 +64,7 @@ class Shipment extends AbstractPdf \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index b8e7584cf7b..55b33c667aa 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Sales\Model\EntityInterface; + /** * Sales order shipment model * @@ -46,14 +48,13 @@ namespace Magento\Sales\Model\Order; * @method \Magento\Sales\Model\Order\Shipment setBillingAddressId(int $value) * @method int getShipmentStatus() * @method \Magento\Sales\Model\Order\Shipment setShipmentStatus(int $value) - * @method string getIncrementId() * @method \Magento\Sales\Model\Order\Shipment setIncrementId(string $value) * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Shipment setCreatedAt(string $value) * @method string getUpdatedAt() * @method \Magento\Sales\Model\Order\Shipment setUpdatedAt(string $value) */ -class Shipment extends \Magento\Sales\Model\AbstractModel +class Shipment extends \Magento\Sales\Model\AbstractModel implements EntityInterface { const STATUS_NEW = 1; @@ -577,4 +578,14 @@ class Shipment extends \Magento\Sales\Model\AbstractModel } return $label; } + + /** + * Returns increment id + * + * @return string + */ + public function getIncrementId() + { + return $this->getData('increment_id'); + } } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index e1b0647e0ab..761e27cc002 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -47,7 +47,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel protected $_shipment; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,7 +56,7 @@ class Comment 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index a67442483d3..023881d2d6e 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -70,7 +70,7 @@ class Track extends \Magento\Sales\Model\AbstractModel protected $_eventObject = 'track'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -84,7 +84,7 @@ class Track 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -95,7 +95,7 @@ class Track extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index a978baab62c..743c033c088 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -34,14 +34,14 @@ use Magento\Framework\Model\Exception; class Status extends \Magento\Framework\Model\AbstractModel { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -49,7 +49,7 @@ class Status extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index f4e3cfe1401..8f5d8ad3e84 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -62,7 +62,7 @@ class History extends \Magento\Sales\Model\AbstractModel protected $_eventObject = 'status_history'; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -71,7 +71,7 @@ class History 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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -81,7 +81,7 @@ class History extends \Magento\Sales\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index eaadb6a4853..d20517b11e5 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -215,7 +215,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -320,7 +320,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param Quote\AddressFactory $quoteAddressFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory @@ -349,7 +349,7 @@ class Quote extends \Magento\Framework\Model\AbstractModel \Magento\Sales\Helper\Data $salesData, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, diff --git a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php index fe5578c945f..14f1a9b598d 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php +++ b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php @@ -35,15 +35,15 @@ namespace Magento\Sales\Model\Quote\Address\RateResult; class Method extends AbstractResult { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, array $data = array()) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager, array $data = array()) { $this->_storeManager = $storeManager; parent::__construct($data); diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php index 9cf2d4ccf8a..1466c4647fa 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Collector.php @@ -83,7 +83,7 @@ class Collector extends \Magento\Sales\Model\Config\Ordered * @param \Magento\Framework\Logger $logger * @param \Magento\Sales\Model\Config $salesConfig * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Quote\Address\TotalFactory $totalFactory * @param mixed $sourceData * @param mixed $store @@ -93,7 +93,7 @@ class Collector extends \Magento\Sales\Model\Config\Ordered \Magento\Framework\Logger $logger, \Magento\Sales\Model\Config $salesConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Quote\Address\TotalFactory $totalFactory, $sourceData = null, $store = null diff --git a/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php b/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php index a194b17d1ae..eba67b299f9 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php +++ b/app/code/Magento/Sales/Model/Quote/Address/Total/Discount.php @@ -33,17 +33,17 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Model/Quote/Item/Processor.php b/app/code/Magento/Sales/Model/Quote/Item/Processor.php index f64746d0f63..90b935ef5e2 100644 --- a/app/code/Magento/Sales/Model/Quote/Item/Processor.php +++ b/app/code/Magento/Sales/Model/Quote/Item/Processor.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Quote\Item; use \Magento\Catalog\Model\Product; use \Magento\Sales\Model\Quote\ItemFactory; use \Magento\Sales\Model\Quote\Item; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Framework\App\State; use \Magento\Framework\Object; @@ -43,7 +43,7 @@ class Processor protected $quoteItemFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Sales/Model/QuoteRepository.php b/app/code/Magento/Sales/Model/QuoteRepository.php index c7c18520521..eb05fbc9e8d 100644 --- a/app/code/Magento/Sales/Model/QuoteRepository.php +++ b/app/code/Magento/Sales/Model/QuoteRepository.php @@ -33,17 +33,17 @@ class QuoteRepository protected $quoteFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** * @param QuoteFactory $quoteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->quoteFactory = $quoteFactory; $this->storeManager = $storeManager; diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php new file mode 100644 index 00000000000..01da9011b07 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php @@ -0,0 +1,100 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.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; + +use Magento\Framework\Model\Resource\Db\AbstractDb; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class AbstractGrid + */ +abstract class AbstractGrid extends AbstractDb implements GridInterface +{ + /** + * @var AdapterInterface + */ + protected $connection; + + /** + * @var string + */ + protected $gridTableName; + + /** + * @var string + */ + protected $orderTableName = 'sales_flat_order'; + + /** + * @var string + */ + protected $addressTableName = 'sales_flat_order_address'; + + /** + * @param AppResource $resource + */ + public function __construct(AppResource $resource) + { + parent::__construct($resource); + } + + /** + * Resource initialization + * + * @return void + */ + protected function _construct() + { + // + } + + /** + * Returns connection + * + * @return AdapterInterface + */ + protected function getConnection() + { + if (!$this->connection) { + $this->connection = $this->_resources->getConnection('write'); + } + return $this->connection; + } + + /** + * Purge grid row + * + * @param int|string $value + * @param null|string $field + * @return int + */ + public function purge($value, $field = null) + { + return $this->getConnection()->delete( + $this->getTable($this->gridTableName), + [($field ?: 'entity_id') . ' = ?' => $value] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/AbstractResource.php b/app/code/Magento/Sales/Model/Resource/AbstractResource.php index 379b55361c5..ffeb1db2bd4 100644 --- a/app/code/Magento/Sales/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Sales/Model/Resource/AbstractResource.php @@ -39,8 +39,10 @@ abstract class AbstractResource extends \Magento\Framework\Model\Resource\Db\Abs * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime */ - public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime) - { + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime + ) { $this->dateTime = $dateTime; parent::__construct($resource); } diff --git a/app/code/Magento/Sales/Model/Resource/Attribute.php b/app/code/Magento/Sales/Model/Resource/Attribute.php new file mode 100644 index 00000000000..6d0c719e4b1 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Attribute.php @@ -0,0 +1,154 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource; + +use Magento\Framework\App\Resource as AppResource; +use Magento\Framework\Event\ManagerInterface as EventManager; +use Magento\Sales\Model\AbstractModel; +use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; + +class Attribute +{ + /** + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected $connection; + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $eventManager; + + /** + * @param AppResource $resource + * @param EventManager $eventManager + */ + public function __construct( + AppResource $resource, + EventManager $eventManager + ) { + $this->resource = $resource; + $this->eventManager = $eventManager; + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected function getConnection() + { + if (!$this->connection) { + $this->connection = $this->resource->getConnection('write'); + } + return $this->connection; + } + + /** + * Before save object attribute + * + * @param AbstractModel $object + * @param string $attribute + * @return \Magento\Sales\Model\Resource\Attribute + */ + protected function _beforeSaveAttribute(AbstractModel $object, $attribute) + { + if ($object->getEventObject() && $object->getEventPrefix()) { + $this->eventManager->dispatch( + $object->getEventPrefix() . '_save_attribute_before', + [ + $object->getEventObject() => $this, + 'object' => $object, + 'attribute' => $attribute + ] + ); + } + return $this; + } + + /** + * Perform actions after object save + * + * @param AbstractModel $object + * @param string $attribute + * @return $this + * @throws \Exception + */ + public function saveAttribute(AbstractModel $object, $attribute) + { + if ($attribute instanceof AbstractAttribute) { + $attributes = $attribute->getAttributeCode(); + } elseif (is_string($attribute)) { + $attributes = [$attribute]; + } else { + $attributes = $attribute; + } + if (is_array($attributes) && !empty($attributes)) { + $this->getConnection()->beginTransaction(); + $data = array_intersect_key($object->getData(), array_flip($attributes)); + try { + $this->_beforeSaveAttribute($object, $attributes); + if ($object->getId() && !empty($data)) { + $this->getConnection()->update( + $object->getResource()->getMainTable(), + $data, + [$object->getResource()->getIdFieldName() . '= ?' => (int)$object->getId()] + ); + $object->addData($data); + } + $this->_afterSaveAttribute($object, $attributes); + $this->getConnection()->commit(); + } catch (\Exception $e) { + $this->getConnection()->rollBack(); + throw $e; + } + } + return $this; + } + + /** + * After save object attribute + * + * @param AbstractModel $object + * @param string $attribute + * @return \Magento\Sales\Model\Resource\Attribute + */ + protected function _afterSaveAttribute(AbstractModel $object, $attribute) + { + if ($object->getEventObject() && $object->getEventPrefix()) { + $this->eventManager->dispatch( + $object->getEventPrefix() . '_save_attribute_after', + [ + $object->getEventObject() => $this, + 'object' => $object, + 'attribute' => $attribute + ] + ); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php index b3a6a756071..c9bd1f77527 100644 --- a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php @@ -30,6 +30,36 @@ namespace Magento\Sales\Model\Resource\Collection; */ abstract class AbstractCollection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection { + /** + * @var \Zend_Db_Select + */ + protected $_countSelect; + + /** + * Set select count sql + * + * @param \Zend_Db_Select $countSelect + * @return $this + */ + public function setSelectCountSql(\Zend_Db_Select $countSelect) + { + $this->_countSelect = $countSelect; + return $this; + } + + /** + * get select count sql + * + * @return \Zend_Db_Select + */ + public function getSelectCountSql() + { + if (!$this->_countSelect instanceof \Zend_Db_Select) { + $this->setSelectCountSql(parent::getSelectCountSql()); + } + return $this->_countSelect; + } + /** * Check if $attribute is \Magento\Eav\Model\Entity\Attribute and convert to string field name * diff --git a/app/code/Magento/Sales/Model/Resource/Entity.php b/app/code/Magento/Sales/Model/Resource/Entity.php new file mode 100644 index 00000000000..c4109d065d9 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Entity.php @@ -0,0 +1,167 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource; + +use Magento\Sales\Model\EntityInterface; + +/** + * Flat sales resource abstract + */ +abstract class Entity extends AbstractResource +{ + /** + * Event prefix + * + * @var string + */ + protected $_eventPrefix = 'sales_order_resource'; + + /** + * Event object + * + * @var string + */ + protected $_eventObject = 'resource'; + + /** + * Use additional is object new check for this resource + * + * @var bool + */ + protected $_useIsObjectNew = true; + + /** + * @var \Magento\Eav\Model\Entity\TypeFactory + */ + protected $_eavEntityTypeFactory; + + /** + * @var \Magento\Sales\Model\Resource\Attribute + */ + protected $attribute; + + /** + * @var \Magento\Sales\Model\Increment + */ + protected $salesIncrement; + + /** + * @var \Magento\Sales\Model\Resource\GridInterface + */ + protected $gridAggregator; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement + * @param GridInterface|null $gridAggregator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null + ) { + $this->attribute = $attribute; + $this->salesIncrement = $salesIncrement; + $this->gridAggregator = $gridAggregator; + parent::__construct($resource, $dateTime); + } + + /** + * Perform actions after object save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @param string $attribute + * @return $this + * @throws \Exception + */ + public function saveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) + { + $this->attribute->saveAttribute($object, $attribute); + return $this; + } + + /** + * Perform actions before object save + * + * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object + * @return $this + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + if ($object instanceof EntityInterface && $object->getIncrementId() == null) { + $object->setIncrementId($this->salesIncrement->getNextValue($object->getStoreId())); + } + parent::_beforeSave($object); + return $this; + } + + /** + * Save object data + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + public function save(\Magento\Framework\Model\AbstractModel $object) + { + if (!$object->getForceObjectSave()) { + parent::save($object); + } + + return $this; + } + + /** + * Perform actions after object save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) + { + if ($this->gridAggregator) { + $this->gridAggregator->refresh($object->getId()); + } + parent::_afterSave($object); + return $this; + } + + /** + * Perform actions after object delete + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object) + { + if ($this->gridAggregator) { + $this->gridAggregator->purge($object->getId()); + } + parent::_afterDelete($object); + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/GridInterface.php b/app/code/Magento/Sales/Model/Resource/GridInterface.php new file mode 100644 index 00000000000..041eb887e2f --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/GridInterface.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\Sales\Model\Resource; + +/** + * Interface GridInterface + */ +interface GridInterface +{ + /** + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null); + + /** + * @param int|string $value + * @param null|string $field + * @return int + */ + public function purge($value, $field = null); +} diff --git a/app/code/Magento/Sales/Model/Resource/GridPool.php b/app/code/Magento/Sales/Model/Resource/GridPool.php new file mode 100644 index 00000000000..bc9644bd8a1 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/GridPool.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\Sales\Model\Resource; + +use Magento\Sales\Model\Resource\GridInterface; +use Magento\Sales\Model\Resource\Order\Grid as OrderGrid; +use Magento\Sales\Model\Resource\Order\Invoice\Grid as InvoiceGrid; +use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; +use Magento\Sales\Model\Resource\Order\Creditmemo\Grid as CreditmemoGrid; + +class GridPool +{ + /** + * @var GridInterface[] + */ + protected $grids; + + /** + * @param OrderGrid $orderGrid + * @param InvoiceGrid $invoiceGrid + * @param ShipmentGrid $shipmentGrid + * @param CreditmemoGrid $creditmemoGrid + */ + public function __construct( + OrderGrid $orderGrid, + InvoiceGrid $invoiceGrid, + ShipmentGrid $shipmentGrid, + CreditmemoGrid $creditmemoGrid + ) { + $this->grids = [ + 'order_grid' => $orderGrid, + 'invoice_grid' => $invoiceGrid, + 'shipment_grid' => $shipmentGrid, + 'creditmemo_grid' => $creditmemoGrid + ]; + } + + /** + * Refresh grids list + * + * @param int $orderId + * @return $this + */ + public function refreshByOrderId($orderId) + { + foreach ($this->grids as $grid) { + $grid->refresh($orderId, 'sfo.entity_id'); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php index 05bd41ac2fc..0950d18db32 100644 --- a/app/code/Magento/Sales/Model/Resource/Order.php +++ b/app/code/Magento/Sales/Model/Resource/Order.php @@ -23,12 +23,21 @@ */ namespace Magento\Sales\Model\Resource; +use Magento\Framework\Math\Random; +use Magento\Framework\App\Resource as AppResource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Handler\State as StateHandler; +use Magento\Sales\Model\Resource\Order\Handler\Address as AddressHandler; +use Magento\Sales\Model\Resource\Order\Grid as OrderGrid; + /** * Flat sales order resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Order extends SalesResource { /** * Event prefix @@ -45,25 +54,14 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $_eventObject = 'resource'; /** - * Is grid - * - * @var bool - */ - protected $_grid = true; - - /** - * Use increment id - * - * @var bool + * @var StateHandler */ - protected $_useIncrementId = true; + protected $stateHandler; /** - * Entity code for increment id - * - * @var string + * @var AddressHandler */ - protected $_entityCodeForIncrementId = 'order'; + protected $addressHandler; /** * Model Initialization @@ -76,30 +74,26 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder } /** - * Init virtual grid records for entity - * - * @return $this + * @param AppResource $resource + * @param DateTime $dateTime + * @param Attribute $attribute + * @param SalesIncrement $salesIncrement + * @param AddressHandler $addressHandler + * @param StateHandler $stateHandler + * @param OrderGrid $gridAggregator */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $ifnullFirst = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $ifnullLast = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatAddress = $adapter->getConcatSql(array($ifnullFirst, $adapter->quote(' '), $ifnullLast)); - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $concatAddress - )->addVirtualGridColumn( - 'shipping_name', - 'sales_flat_order_address', - array('shipping_address_id' => 'entity_id'), - $concatAddress - ); - - return $this; + public function __construct( + AppResource $resource, + DateTime $dateTime, + Attribute $attribute, + SalesIncrement $salesIncrement, + AddressHandler $addressHandler, + StateHandler $stateHandler, + OrderGrid $gridAggregator + ) { + $this->stateHandler = $stateHandler; + $this->addressHandler = $addressHandler; + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** @@ -133,21 +127,79 @@ class Order extends \Magento\Sales\Model\Resource\Order\AbstractOrder } /** - * Retrieve order_increment_id by order_id + * Process items dependency for new order, returns qty of affected items; * - * @param int $orderId - * @return string + * @param \Magento\Sales\Model\Order $object + * @return int */ - public function getIncrementId($orderId) + protected function calculateItems(\Magento\Sales\Model\Order $object) { - $adapter = $this->getReadConnection(); - $bind = array(':entity_id' => $orderId); - $select = $adapter->select()->from( - $this->getMainTable(), - array("increment_id") - )->where( - 'entity_id = :entity_id' + $itemsCount = 0; + if (!$object->getId()) { + foreach ($object->getAllItems() as $item) { + /** @var \Magento\Sales\Model\Order\Item $item */ + $parent = $item->getQuoteParentItemId(); + if ($parent && !$item->getParentItem()) { + $item->setParentItem($object->getItemByQuoteItemId($parent)); + } elseif (!$parent) { + $itemsCount++; + } + } + } + return $itemsCount; + } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + /** @var \Magento\Sales\Model\Order $object */ + $this->addressHandler->removeEmptyAddresses($object); + $this->stateHandler->check($object); + if (!$object->getId()) { + /** @var \Magento\Store\Model\Store $store */ + $store = $object->getStore(); + $name = [ + $store->getWebsite()->getName(), + $store->getGroup()->getName(), + $store->getName() + ]; + $object->setStoreName(implode("\n", $name)); + } + $object->setTotalItemCount($this->calculateItems($object)); + $object->setData( + 'protect_code', + substr(md5(uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6) ); - return $adapter->fetchOne($select, $bind); + $isNewCustomer = !$object->getCustomerId() || $object->getCustomerId() === true; + if ($isNewCustomer && $object->getCustomer()) { + $object->setCustomerId($object->getCustomer()->getId()); + } + return parent::_beforeSave($object); + } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) + { + /** @var \Magento\Sales\Model\Order $object */ + $this->addressHandler->process($object); + if (null !== $object->getItemsCollection()) { + $object->getItemsCollection()->save(); + } + if (null !== $object->getPaymentsCollection()) { + $object->getPaymentsCollection()->save(); + } + if (null !== $object->getStatusHistoryCollection()) { + $object->getStatusHistoryCollection()->save(); + } + foreach ($object->getRelatedObjects() as $relatedObject) { + $relatedObject->save(); + } + return parent::_afterSave($object); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php b/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php deleted file mode 100644 index 63acd2501c7..00000000000 --- a/app/code/Magento/Sales/Model/Resource/Order/AbstractOrder.php +++ /dev/null @@ -1,479 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model\Resource\Order; - -/** - * Flat sales resource abstract - */ -abstract class AbstractOrder extends \Magento\Sales\Model\Resource\AbstractResource -{ - /** - * Is grid available - * - * @var bool - */ - protected $_grid = false; - - /** - * Use additional is object new check for this resource - * - * @var bool - */ - protected $_useIsObjectNew = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = false; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = ''; - - /** - * Grid virtual columns - * - * @var array|null - */ - protected $_virtualGridColumns = null; - - /** - * Grid columns - * - * @var array|null - */ - protected $_gridColumns = null; - - /** - * Event prefix - * - * @var string - */ - protected $_eventPrefix = 'sales_resource'; - - /** - * Event object - * - * @var string - */ - protected $_eventObject = 'resource'; - - /** - * Core event manager proxy - * - * @var \Magento\Framework\Event\ManagerInterface - */ - protected $_eventManager = null; - - /** - * @var \Magento\Eav\Model\Entity\TypeFactory - */ - protected $_eavEntityTypeFactory; - - /** - * @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 - */ - public function __construct( - \Magento\Framework\App\Resource $resource, - \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - ) { - $this->_eventManager = $eventManager; - $this->_eavEntityTypeFactory = $eavEntityTypeFactory; - parent::__construct($resource, $dateTime); - } - - /** - * Add new virtual grid column - * - * @param string $alias - * @param string $table - * @param array $joinCondition - * @param string $column - * @return $this - * @throws \Magento\Framework\Model\Exception - */ - public function addVirtualGridColumn($alias, $table, $joinCondition, $column) - { - $table = $this->getTable($table); - - if (!in_array($alias, $this->getGridColumns())) { - throw new \Magento\Framework\Model\Exception( - __('Please specify a valid grid column alias name that exists in the grid table.') - ); - } - - $this->_virtualGridColumns[$alias] = array($table, $joinCondition, $column); - - return $this; - } - - /** - * Retrieve virtual grid columns - * - * @return array - */ - public function getVirtualGridColumns() - { - if ($this->_virtualGridColumns === null) { - $this->_initVirtualGridColumns(); - } - - return $this->_virtualGridColumns; - } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - $this->_virtualGridColumns = array(); - if ($this->_eventPrefix && $this->_eventObject) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_init_virtual_grid_columns', - array($this->_eventObject => $this) - ); - } - return $this; - } - - /** - * Update records in grid table - * - * @param array|int $ids - * @return $this - */ - public function updateGridRecords($ids) - { - if ($this->_grid) { - if (!is_array($ids)) { - $ids = array($ids); - } - - if ($this->_eventPrefix && $this->_eventObject) { - $proxy = new \Magento\Framework\Object(); - $proxy->setIds($ids)->setData($this->_eventObject, $this); - - $this->_eventManager->dispatch($this->_eventPrefix . '_update_grid_records', array('proxy' => $proxy)); - $ids = $proxy->getIds(); - } - - if (empty($ids)) { - // If nothing to update - return $this; - } - $columnsToSelect = array(); - $table = $this->getGridTable(); - $select = $this->getUpdateGridRecordsSelect($ids, $columnsToSelect); - $this->_getWriteAdapter()->query($select->insertFromSelect($table, $columnsToSelect, true)); - } - - return $this; - } - - /** - * Retrieve update grid records select - * - * @param array $ids - * @param array &$flatColumnsToSelect - * @param array|null $gridColumns - * @return \Magento\Framework\DB\Select - */ - public function getUpdateGridRecordsSelect($ids, &$flatColumnsToSelect, $gridColumns = null) - { - $flatColumns = array_keys($this->_getReadAdapter()->describeTable($this->getMainTable())); - - if ($gridColumns === null) { - $gridColumns = $this->getGridColumns(); - } - - $flatColumnsToSelect = array_intersect($flatColumns, $gridColumns); - - $select = $this->_getWriteAdapter()->select()->from( - array('main_table' => $this->getMainTable()), - $flatColumnsToSelect - )->where( - 'main_table.' . $this->getIdFieldName() . ' IN(?)', - $ids - ); - - $this->joinVirtualGridColumnsToSelect('main_table', $select, $flatColumnsToSelect); - - return $select; - } - - /** - * Join virtual grid columns to select - * - * @param string $mainTableAlias - * @param \Zend_Db_Select $select - * @param array &$columnsToSelect - * @return $this - */ - public function joinVirtualGridColumnsToSelect($mainTableAlias, \Zend_Db_Select $select, &$columnsToSelect) - { - $adapter = $this->_getWriteAdapter(); - foreach ($this->getVirtualGridColumns() as $alias => $expression) { - list($table, $joinCondition, $column) = $expression; - $tableAlias = 'table_' . $alias; - - $joinConditionExpr = array(); - foreach ($joinCondition as $fkField => $pkField) { - $pkField = $adapter->quoteIdentifier($tableAlias . '.' . $pkField); - $fkField = $adapter->quoteIdentifier($mainTableAlias . '.' . $fkField); - $joinConditionExpr[] = $fkField . '=' . $pkField; - } - - $select->joinLeft( - array($tableAlias => $table), - implode(' AND ', $joinConditionExpr), - array($alias => str_replace('{{table}}', $tableAlias, $column)) - ); - - $columnsToSelect[] = $alias; - } - - return $this; - } - - /** - * Retrieve list of grid columns - * - * @return array - */ - public function getGridColumns() - { - if ($this->_gridColumns === null) { - if ($this->_grid) { - $this->_gridColumns = array_keys($this->_getReadAdapter()->describeTable($this->getGridTable())); - } else { - $this->_gridColumns = array(); - } - } - - return $this->_gridColumns; - } - - /** - * Retrieve grid table - * - * @return string - */ - public function getGridTable() - { - if ($this->_grid) { - return $this->getTable($this->_mainTable . '_grid'); - } - return false; - } - - /** - * Before save object attribute - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - */ - protected function _beforeSaveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($this->_eventObject && $this->_eventPrefix) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_save_attribute_before', - array($this->_eventObject => $this, 'object' => $object, 'attribute' => $attribute) - ); - } - return $this; - } - - /** - * After save object attribute - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - */ - protected function _afterSaveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($this->_eventObject && $this->_eventPrefix) { - $this->_eventManager->dispatch( - $this->_eventPrefix . '_save_attribute_after', - array($this->_eventObject => $this, 'object' => $object, 'attribute' => $attribute) - ); - } - return $this; - } - - /** - * Perform actions after object save - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param string $attribute - * @return $this - * @throws \Exception - */ - public function saveAttribute(\Magento\Framework\Model\AbstractModel $object, $attribute) - { - if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) { - $attribute = $attribute->getAttributeCode(); - } - - if (is_string($attribute)) { - $attribute = array($attribute); - } - - if (is_array($attribute) && !empty($attribute)) { - $this->beginTransaction(); - try { - $this->_beforeSaveAttribute($object, $attribute); - $data = new \Magento\Framework\Object(); - foreach ($attribute as $code) { - $data->setData($code, $object->getData($code)); - } - - $updateArray = $this->_prepareDataForTable($data, $this->getMainTable()); - $this->_postSaveFieldsUpdate($object, $updateArray); - if (!$object->getForceUpdateGridRecords() && count( - array_intersect($this->getGridColumns(), $attribute) - ) > 0 - ) { - $this->updateGridRecords($object->getId()); - } - $this->_afterSaveAttribute($object, $attribute); - $this->commit(); - } catch (\Exception $e) { - $this->rollBack(); - throw $e; - } - } - - return $this; - } - - /** - * Perform actions before object save - * - * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object - * @return $this - */ - protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) - { - if ($this->_useIncrementId && !$object->getIncrementId()) { - /* @var $entityType \Magento\Eav\Model\Entity\Type */ - $entityType = $this->_eavEntityTypeFactory->create()->loadByCode($this->_entityTypeForIncrementId); - $object->setIncrementId($entityType->fetchNewIncrementId($object->getStoreId())); - } - parent::_beforeSave($object); - return $this; - } - - /** - * Update field in table if model have been already saved - * - * @param \Magento\Framework\Model\AbstractModel $object - * @param array $data - * @return $this - */ - protected function _postSaveFieldsUpdate($object, $data) - { - if ($object->getId() && !empty($data)) { - $table = $this->getMainTable(); - $this->_getWriteAdapter()->update( - $table, - $data, - array($this->getIdFieldName() . '=?' => (int)$object->getId()) - ); - $object->addData($data); - } - - return $this; - } - - /** - * Set main resource table - * - * @param string $table - * @return $this - */ - public function setMainTable($table) - { - $this->_mainTable = $table; - return $this; - } - - /** - * Save object data - * - * @param \Magento\Framework\Model\AbstractModel $object - * @return $this - */ - public function save(\Magento\Framework\Model\AbstractModel $object) - { - if (!$object->getForceObjectSave()) { - parent::save($object); - } - - return $this; - } - - /** - * Update grid table on entity update - * - * @param string $field - * @param int $entityId - * @return $this - */ - public function updateOnRelatedRecordChanged($field, $entityId) - { - $adapter = $this->_getWriteAdapter(); - $column = array(); - $select = $adapter->select()->from( - array('main_table' => $this->getMainTable()), - $column - )->where( - 'main_table.' . $field . ' = ?', - $entityId - ); - $this->joinVirtualGridColumnsToSelect('main_table', $select, $column); - $fieldsToUpdate = $adapter->fetchRow($select); - if ($fieldsToUpdate) { - $adapter->update( - $this->getGridTable(), - $fieldsToUpdate, - $adapter->quoteInto($this->getGridTable() . '.' . $field . ' = ?', $entityId) - ); - } - return $this; - } -} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index 7bb0070b82c..f71ab9835cb 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Resource\Order; /** * Flat sales order address resource */ -class Address extends AbstractOrder +class Address extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -36,34 +36,36 @@ class Address extends AbstractOrder protected $_eventPrefix = 'sales_order_address_resource'; /** - * @var \Magento\Sales\Model\Resource\Factory + * @var \Magento\Sales\Model\Order\Address\Validator */ - protected $_salesResourceFactory; + protected $_validator; /** - * @var \Magento\Sales\Model\Order\Address\Validator + * @var \Magento\Sales\Model\Resource\GridPool */ - protected $_validator; + protected $gridPool; /** * @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\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Address\Validator $validator + * @param \Magento\Sales\Model\Resource\GridPool $gridPool + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ 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\Order\Address\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Address\Validator $validator, + \Magento\Sales\Model\Resource\GridPool $gridPool, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->_validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); - $this->_salesResourceFactory = $salesResourceFactory; + $this->gridPool = $gridPool; + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } @@ -128,25 +130,9 @@ class Address extends AbstractOrder protected function _afterSave(\Magento\Framework\Model\AbstractModel $object) { $resource = parent::_afterSave($object); - if ($object->hasDataChanges() && $object->getOrder()) { - $gridList = array( - 'Magento\Sales\Model\Resource\Order' => 'entity_id', - 'Magento\Sales\Model\Resource\Order\Invoice' => 'order_id', - 'Magento\Sales\Model\Resource\Order\Shipment' => 'order_id', - 'Magento\Sales\Model\Resource\Order\Creditmemo' => 'order_id' - ); - - // update grid table after grid update - foreach ($gridList as $gridResource => $field) { - $this->_salesResourceFactory->create( - $gridResource - )->updateOnRelatedRecordChanged( - $field, - $object->getParentId() - ); - } + if ($object->hasDataChanges() && $object->getOrderId()) { + $this->gridPool->refreshByOrderId($object->getOrderId()); } - return $resource; } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php b/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php index f1ce417d843..c7f0e450a52 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Attribute/Backend/Shipping.php @@ -60,7 +60,8 @@ class Shipping extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke } if ($shippingAddressId) { $object->setShippingAddressId($shippingAddressId); - $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getAttributeCode()); + $this->getAttribute()->getEntity() + ->saveAttribute($object, $this->getAttribute()->getAttributeCode()); } } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php index 0fb9b047382..8b77a19de46 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php @@ -23,12 +23,17 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Creditmemo\Grid as CreditmemoGrid; + /** * Flat sales order creditmemo resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Creditmemo extends AbstractOrder +class Creditmemo extends SalesResource { /** * Event prefix @@ -37,27 +42,6 @@ class Creditmemo extends AbstractOrder */ protected $_eventPrefix = 'sales_order_creditmemo_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = 'creditmemo'; - /** * Model initialization * @@ -67,37 +51,4 @@ class Creditmemo extends AbstractOrder { $this->_init('sales_flat_creditmemo', 'entity_id'); } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatName = $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)); - - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $concatName - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; - } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php index 4ef922839f1..c9db568fedf 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Creditmemo; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php new file mode 100644 index 00000000000..25669e15b31 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.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\Resource\Order\Creditmemo; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_creditmemo_grid'; + + /** + * @var string + */ + protected $creditmemoTableName = 'sales_flat_creditmemo'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfc.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfc' => $this->getTable($this->creditmemoTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfc.order_id = sfo.entity_id', []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfc.entity_id', + 'store_id' => 'sfc.store_id', + 'store_to_order_rate' => 'sfc.store_to_order_rate', + 'base_to_order_rate' => 'sfc.base_to_order_rate', + 'grand_total' => 'sfc.grand_total', + 'store_to_base_rate' => 'sfc.store_to_base_rate', + 'base_to_global_rate' => 'sfc.base_to_global_rate', + 'base_grand_total' => 'sfc.base_grand_total', + 'order_id' => 'sfc.order_id', + 'creditmemo_status' => 'sfc.creditmemo_status', + 'state' => 'sfc.state', + 'invoice_id' => 'sfc.invoice_id', + 'store_currency_code' => 'sfc.store_currency_code', + 'order_currency_code' => 'sfc.order_currency_code', + 'base_currency_code' => 'sfc.base_currency_code', + 'global_currency_code' => 'sfc.global_currency_code', + 'increment_id' => 'sfc.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfc.created_at', + 'order_created_at' => 'sfo.created_at', + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))" + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php index f04b2892570..04cc496aa2e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Creditmemo; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Grid.php new file mode 100644 index 00000000000..3d266fd5fcd --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid.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. + * + * @copyright Copyright (c) 2014 X.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; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_order_grid'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfo.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfo' => $this->getTable($this->orderTableName)], []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->joinLeft( + ['ssa' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = ssa.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfo.entity_id', + 'status' => 'sfo.status', + 'store_id' => 'sfo.store_id', + 'store_name' => 'sfo.store_name', + 'customer_id' => 'sfo.customer_id', + 'base_grand_total' => 'sfo.base_grand_total', + 'base_total_paid' => 'sfo.base_total_paid', + 'grand_total' => 'sfo.grand_total', + 'total_paid' => 'sfo.total_paid', + 'increment_id' => 'sfo.increment_id', + 'base_currency_code' => 'sfo.base_currency_code', + 'order_currency_code' => 'sfo.order_currency_code', + 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))", + 'created_at' => 'sfo.created_at', + 'updated_at' => 'sfo.updated_at' + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php new file mode 100644 index 00000000000..4cc006e771e --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Handler/Address.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource\Order\Handler; + +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Resource\Attribute; + +/** + * Class Address + */ +class Address +{ + /** + * @var Attribute + */ + protected $attribute; + + /** + * @param Attribute $attribute + */ + public function __construct( + Attribute $attribute + ) { + $this->attribute = $attribute; + } + + /** + * Remove empty addresses from order + * + * @param Order $order + * @return $this + */ + public function removeEmptyAddresses(Order $order) + { + if ($order->hasBillingAddressId() && $order->getBillingAddressId() === null) { + $order->unsBillingAddressId(); + } + + if ($order->hasShippingAddressId() && $order->getShippingAddressId() === null) { + $order->unsShippingAddressId(); + } + return $this; + } + + /** + * Process addresses saving + * + * @param Order $order + * @return $this + * @throws \Exception + */ + public function process(Order $order) + { + if (null !== $order->getAddressesCollection()) { + $order->getAddressesCollection()->save(); + $billingAddress = $order->getBillingAddress(); + $attributesForSave = []; + if ($billingAddress && $order->getBillingAddressId() != $billingAddress->getId()) { + $order->setBillingAddressId($billingAddress->getId()); + $attributesForSave[] = 'billing_address_id'; + } + $shippingAddress = $order->getShippingAddress(); + if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) { + $order->setShippingAddressId($shippingAddress->getId()); + $attributesForSave[] = 'shipping_address_id'; + } + if (!empty($attributesForSave)) { + $this->attribute->saveAttribute($order, $attributesForSave); + } + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php new file mode 100644 index 00000000000..56b772fa83d --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Handler/State.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model\Resource\Order\Handler; + +use Magento\Sales\Model\Order; + +/** + * Class State + */ +class State +{ + /** + * Check order status before save + * + * @param Order $order + * @return $this + */ + public function check(Order $order) + { + if (!$order->getId()) { + return $order; + } + $userNotification = $order->hasCustomerNoteNotify() ? $order->getCustomerNoteNotify() : null; + if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) { + if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) { + if ($order->getState() !== Order::STATE_COMPLETE) { + $order->setState(Order::STATE_COMPLETE, true, '', $userNotification, false); + } + } elseif (floatval($order->getTotalRefunded()) + || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo() + ) { + if ($order->getState() !== Order::STATE_CLOSED) { + $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false); + } + } + } + if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) { + $order->setState(Order::STATE_PROCESSING, true, '', $userNotification); + } + return $this; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php index ce3e52fa6b9..08e1918d8fb 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php @@ -23,12 +23,17 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Invoice\Grid as InvoiceGrid; + /** * Flat sales order invoice resource - * - * @author Magento Core Team <core@magentocommerce.com> */ -class Invoice extends AbstractOrder +class Invoice extends SalesResource { /** * Event prefix @@ -37,27 +42,6 @@ class Invoice extends AbstractOrder */ protected $_eventPrefix = 'sales_order_invoice_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Flag for using of increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity code for increment id (Eav entity code) - * - * @var string - */ - protected $_entityTypeForIncrementId = 'invoice'; - /** * Model initialization * @@ -69,34 +53,19 @@ class Invoice extends AbstractOrder } /** - * Init virtual grid records for entity - * - * @return $this + * @param Resource $resource + * @param DateTime $dateTime + * @param Attribute $attribute + * @param SalesIncrement $salesIncrement + * @param InvoiceGrid $gridAggregator */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->_getReadAdapter(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - - $this->addVirtualGridColumn( - 'billing_name', - 'sales_flat_order_address', - array('billing_address_id' => 'entity_id'), - $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)) - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; + public function __construct( + Resource $resource, + DateTime $dateTime, + Attribute $attribute, + SalesIncrement $salesIncrement, + InvoiceGrid $gridAggregator + ) { + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php index 9dca32d432a..6d3ce1e283e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Invoice; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,25 +45,28 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } + + + /** * Model initialization * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php new file mode 100644 index 00000000000..1a68f9c0537 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.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. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Resource\Order\Invoice; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_invoice_grid'; + + /** + * @var string + */ + protected $invoiceTableName = 'sales_flat_invoice'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfi.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfi' => $this->getTable($this->invoiceTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfi.order_id = sfo.entity_id', []) + ->joinLeft( + ['sba' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = sba.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfi.entity_id', + 'store_id' => 'sfi.store_id', + 'base_grand_total' => 'sfi.base_grand_total', + 'grand_total' => 'sfi.grand_total', + 'order_id' => 'sfi.order_id', + 'state' => 'sfi.state', + 'store_currency_code' => 'sfi.store_currency_code', + 'order_currency_code' => 'sfi.order_currency_code', + 'base_currency_code' => 'sfi.base_currency_code', + 'global_currency_code' => 'sfi.global_currency_code', + 'increment_id' => 'sfi.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfi.created_at', + 'order_created_at' => 'sfo.created_at', + 'billing_name' => "trim(concat(ifnull(sba.firstname, ''), ' ', ifnull(sba.lastname, '')))" + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php index 2b363a7bd83..0ec5acbe69a 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Invoice; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Item.php index 300e61f8987..34a8ffca528 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Item.php @@ -23,12 +23,12 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Sales\Model\Resource\Entity as SalesResource; + /** * Flat sales order item resource - * - * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends AbstractOrder +class Item extends SalesResource { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment.php b/app/code/Magento/Sales/Model/Resource/Order/Payment.php index b95ce67d42b..35a0bc2e401 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment.php @@ -23,17 +23,23 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment; +use Magento\Sales\Model\Resource\Entity as SalesResource; + /** * Flat sales order payment resource */ -class Payment extends AbstractOrder +class Payment extends SalesResource { /** * Serializeable field: additional_information * * @var array */ - protected $_serializableFields = array('additional_information' => array(null, array())); + protected $_serializableFields = ['additional_information' => [null, []]]; /** * Event prefix @@ -42,21 +48,6 @@ class Payment extends AbstractOrder */ protected $_eventPrefix = 'sales_order_payment_resource'; - /** - * @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 - */ - public function __construct( - \Magento\Framework\App\Resource $resource, - \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory - ) { - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); - } - /** * Model initialization * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php index 5a5210e273c..b5555a97b7e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Payment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Transaction extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Transaction extends \Magento\Sales\Model\Resource\Entity { /** * Serializeable field: additional_information diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php index f7b982047a9..f260907b671 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php @@ -23,12 +23,19 @@ */ namespace Magento\Sales\Model\Resource\Order; +use Magento\Framework\App\Resource; +use Magento\Framework\Stdlib\DateTime; +use Magento\Sales\Model\Resource\Attribute; +use Magento\Sales\Model\Increment as SalesIncrement; +use Magento\Sales\Model\Resource\Entity as SalesResource; +use Magento\Sales\Model\Resource\Order\Shipment\Grid as ShipmentGrid; + /** * Flat sales order shipment resource * * @author Magento Core Team <core@magentocommerce.com> */ -class Shipment extends AbstractOrder +class Shipment extends SalesResource { /** * Event prefix @@ -37,33 +44,12 @@ class Shipment extends AbstractOrder */ protected $_eventPrefix = 'sales_order_shipment_resource'; - /** - * Is grid available - * - * @var bool - */ - protected $_grid = true; - - /** - * Use increment id - * - * @var bool - */ - protected $_useIncrementId = true; - - /** - * Entity type for increment id - * - * @var string - */ - protected $_entityTypeForIncrementId = 'shipment'; - /** * Fields that should be serialized before persistence * * @var array */ - protected $_serializableFields = array('packages' => array(array(), array())); + protected $_serializableFields = ['packages' => [[], []]]; /** * Model initialization @@ -74,37 +60,4 @@ class Shipment extends AbstractOrder { $this->_init('sales_flat_shipment', 'entity_id'); } - - /** - * Init virtual grid records for entity - * - * @return $this - */ - protected function _initVirtualGridColumns() - { - parent::_initVirtualGridColumns(); - $adapter = $this->getReadConnection(); - $checkedFirstname = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote('')); - $checkedLastname = $adapter->getIfNullSql('{{table}}.lastname', $adapter->quote('')); - $concatName = $adapter->getConcatSql(array($checkedFirstname, $adapter->quote(' '), $checkedLastname)); - - $this->addVirtualGridColumn( - 'shipping_name', - 'sales_flat_order_address', - array('shipping_address_id' => 'entity_id'), - $concatName - )->addVirtualGridColumn( - 'order_increment_id', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'increment_id' - )->addVirtualGridColumn( - 'order_created_at', - 'sales_flat_order', - array('order_id' => 'entity_id'), - 'created_at' - ); - - return $this; - } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php index 709d47bd2ec..fa21a5c0e3e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Comment extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Comment extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php new file mode 100644 index 00000000000..45d951c6757 --- /dev/null +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.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\Sales\Model\Resource\Order\Shipment; + +use Magento\Sales\Model\Resource\AbstractGrid; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\App\Resource as AppResource; + +/** + * Class Grid + */ +class Grid extends AbstractGrid +{ + /** + * @var string + */ + protected $gridTableName = 'sales_flat_shipment_grid'; + + /** + * @var string + */ + protected $shipmentTableName = 'sales_flat_shipment'; + + /** + * Refresh grid row + * + * @param int|string $value + * @param null|string $field + * @return \Zend_Db_Statement_Interface + */ + public function refresh($value, $field = null) + { + $select = $this->getGridOriginSelect() + ->where(($field ?: 'sfs.entity_id') . ' = ?', $value); + return $this->getConnection()->query( + $this->getConnection() + ->insertFromSelect( + $select, + $this->getTable($this->gridTableName), + [], + AdapterInterface::INSERT_ON_DUPLICATE + ) + ); + } + + /** + * Returns select object + * + * @return \Magento\Framework\DB\Select + */ + protected function getGridOriginSelect() + { + return $this->getConnection()->select() + ->from(['sfs' => $this->getTable($this->shipmentTableName)], []) + ->join(['sfo' => $this->getTable($this->orderTableName)], 'sfs.order_id = sfo.entity_id', []) + ->joinLeft( + ['ssa' => $this->getTable($this->addressTableName)], + 'sfo.billing_address_id = ssa.entity_id', + [] + ) + ->columns( + [ + 'entity_id' => 'sfs.entity_id', + 'store_id' => 'sfs.store_id', + 'total_qty' => 'sfs.total_qty', + 'order_id' => 'sfs.order_id', + 'shipment_status' => 'sfs.shipment_status', + 'increment_id' => 'sfs.increment_id', + 'order_increment_id' => 'sfo.increment_id', + 'created_at' => 'sfs.created_at', + 'order_created_at' => 'sfo.created_at', + 'shipping_name' => "trim(concat(ifnull(ssa.firstname, ''), ' ' ,ifnull(ssa.lastname, '')))", + ] + ); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php index 778aa774d10..c0a09763e7e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Item extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php index 73718f9e165..fecd4bf1730 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php @@ -28,7 +28,7 @@ namespace Magento\Sales\Model\Resource\Order\Shipment; * * @author Magento Core Team <core@magentocommerce.com> */ -class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class Track extends \Magento\Sales\Model\Resource\Entity { /** * Event prefix @@ -45,23 +45,23 @@ class Track extends \Magento\Sales\Model\Resource\Order\AbstractOrder protected $validator; /** - * Constructor - * * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param \Magento\Sales\Model\Resource\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Order\Shipment\Track\Validator $validator + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + \Magento\Sales\Model\Order\Shipment\Track\Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** 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 ca4f1d4c1e9..2143955fb86 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -30,7 +30,7 @@ use Magento\Sales\Model\Order\Status\History\Validator; * * @author Magento Core Team <core@magentocommerce.com> */ -class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder +class History extends \Magento\Sales\Model\Resource\Entity { /** * @var Validator @@ -40,19 +40,21 @@ class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder /** * @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\Attribute $attribute + * @param \Magento\Sales\Model\Increment $salesIncrement * @param Validator $validator + * @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator */ 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 + \Magento\Sales\Model\Resource\Attribute $attribute, + \Magento\Sales\Model\Increment $salesIncrement, + Validator $validator, + \Magento\Sales\Model\Resource\GridInterface $gridAggregator = null ) { $this->validator = $validator; - parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + parent::__construct($resource, $dateTime, $attribute, $salesIncrement, $gridAggregator); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php index 936804861c8..f7bc0d345bb 100644 --- a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php @@ -24,7 +24,7 @@ namespace Magento\Sales\Model\Resource\Sale; use Magento\Core\Model\EntityFactory; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Logger; @@ -92,7 +92,7 @@ class Collection extends \Magento\Framework\Data\Collection\Db * @param ManagerInterface $eventManager * @param Order $resource * @param \Magento\Store\Model\Resource\Store\CollectionFactory $storeCollectionFactory - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( EntityFactory $entityFactory, diff --git a/app/code/Magento/Sales/Service/V1/Data/Transaction.php b/app/code/Magento/Sales/Service/V1/Data/Transaction.php index 60ded30a706..8a5fd6564c8 100644 --- a/app/code/Magento/Sales/Service/V1/Data/Transaction.php +++ b/app/code/Magento/Sales/Service/V1/Data/Transaction.php @@ -63,7 +63,7 @@ class Transaction extends DataObject /** * Returns parent_id * - * @return int + * @return int|null */ public function getParentId() { diff --git a/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php b/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php index 36df5668593..0e5d852db59 100644 --- a/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php +++ b/app/code/Magento/Sales/Service/V1/Data/TransactionBuilder.php @@ -34,7 +34,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTransactionId($transactionId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TRANSACTION_ID, $transactionId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TRANSACTION_ID, (int)$transactionId); } /** @@ -50,7 +50,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setOrderId($orderId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::ORDER_ID, $orderId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::ORDER_ID, (int)$orderId); } /** @@ -58,7 +58,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setPaymentId($paymentId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PAYMENT_ID, $paymentId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PAYMENT_ID, (int)$paymentId); } /** @@ -66,7 +66,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTxnId($txnId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_ID, $txnId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_ID, (string)$txnId); } /** @@ -74,7 +74,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setParentTxnId($parentTxnId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PARENT_TXN_ID, $parentTxnId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::PARENT_TXN_ID, (string)$parentTxnId); } /** @@ -82,7 +82,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setTxnType($txnType) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_TYPE, $txnType); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::TXN_TYPE, (string)$txnType); } /** @@ -90,7 +90,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setIsClosed($isClosed) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::IS_CLOSED, $isClosed); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::IS_CLOSED, (int)$isClosed); } /** @@ -106,7 +106,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setCreatedAt($createdAt) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::CREATED_AT, $createdAt); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::CREATED_AT, (string)$createdAt); } /** @@ -114,7 +114,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setMethod($method) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::METHOD, $method); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::METHOD, (string)$method); } /** @@ -122,7 +122,7 @@ class TransactionBuilder extends \Magento\Framework\Service\Data\AbstractExtensi */ public function setIncrementId($incrementId) { - $this->_set(\Magento\Sales\Service\V1\Data\Transaction::INCREMENT_ID, $incrementId); + $this->_set(\Magento\Sales\Service\V1\Data\Transaction::INCREMENT_ID, (string)$incrementId); } /** diff --git a/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php b/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php index c27d9beb0de..95722e2d336 100644 --- a/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php +++ b/app/code/Magento/Sales/Service/V1/Data/TransactionMapper.php @@ -119,8 +119,17 @@ class TransactionMapper { /** @var TransactionBuilder $transactionBuilder */ $transactionBuilder = $this->transactionBuilderFactory->create(); - $transactionBuilder->populateWithArray($transactionModel->getData()); + $transactionBuilder->setTransactionId($transactionModel->getTransactionId()); + $transactionBuilder->setParentId($transactionModel->getParentId()); + $transactionBuilder->setOrderId($transactionModel->getOrderId()); + $transactionBuilder->setTxnId($transactionModel->getTxnId()); + $transactionBuilder->setPaymentId($transactionModel->getPaymentId()); + $transactionBuilder->setParentTxnId($transactionModel->getParentTxnId()); + $transactionBuilder->setTxnType($transactionModel->getTxnType()); + $transactionBuilder->setIsClosed($transactionModel->getIsClosed()); $transactionBuilder->setAdditionalInformation($this->getAdditionalInfo($transactionModel)); + $transactionBuilder->setCreatedAt($transactionModel->getCreatedAt()); + $transactionBuilder->setMethod($transactionModel->getMethod()); $transactionBuilder->setIncrementId($this->getIncrementId($transactionModel)); $transactionBuilder->setChildTransactions($lazy ? [] : $this->getChildTransactions($transactionModel)); return $transactionBuilder->create(); diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index cd6ab8aa6b8..e2eb6a964c7 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,30 +3,30 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-sales-rule": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-gift-message": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-wishlist": "0.1.0-alpha94", - "magento/module-email": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-sales-rule": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-gift-message": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-wishlist": "0.1.0-alpha95", + "magento/module-email": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/etc/crontab.xml b/app/code/Magento/Sales/etc/crontab.xml index 0f116b9b32f..6b5eebdec40 100644 --- a/app/code/Magento/Sales/etc/crontab.xml +++ b/app/code/Magento/Sales/etc/crontab.xml @@ -25,22 +25,22 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Cron/etc/crontab.xsd"> <group id="default"> - <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer" method="cleanExpiredQuotes"> + <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer\CleanExpiredQuotes" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportOrderData"> + <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportOrderData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportShipmentData"> + <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportShipmentData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportInvoicedData"> + <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportInvoicedData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportRefundedData"> + <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportRefundedData" method="execute"> <schedule>0 0 * * *</schedule> </job> - <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportBestsellersData"> + <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer\AggregateSalesReportBestsellersData" method="execute"> <schedule>0 0 * * *</schedule> </job> </group> diff --git a/app/code/Magento/Sales/etc/events.xml b/app/code/Magento/Sales/etc/events.xml index 9910d259433..5962f90b1ba 100644 --- a/app/code/Magento/Sales/etc/events.xml +++ b/app/code/Magento/Sales/etc/events.xml @@ -25,6 +25,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="sales_order_place_after"> - <observer name="sales_vat_request_params_order_comment" instance="Magento\Sales\Model\Observer" method="addVatRequestParamsOrderComment" /> + <observer name="sales_vat_request_params_order_comment" instance="Magento\Sales\Model\Observer\Frontend\Quote\AddVatRequestParamsOrderComment" method="execute" /> </event> </config> diff --git a/app/code/Magento/Sales/etc/frontend/events.xml b/app/code/Magento/Sales/etc/frontend/events.xml index d57edc0533e..643294e1f54 100644 --- a/app/code/Magento/Sales/etc/frontend/events.xml +++ b/app/code/Magento/Sales/etc/frontend/events.xml @@ -28,9 +28,9 @@ <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer\Frontend\Quote\Address\CollectTotals" method="dispatch" /> </event> <event name="sales_quote_address_collect_totals_after"> - <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer" method="restoreQuoteCustomerGroupId" /> + <observer name="sales_customer_validate_vat_number" instance="Magento\Sales\Model\Observer\Frontend\Quote\RestoreCustomerGroupId" method="execute" /> </event> <event name="sales_quote_collect_totals_after"> - <observer name="catalog_msrp" instance="Magento\Sales\Model\Observer" method="setQuoteCanApplyMsrp" /> + <observer name="catalog_msrp" instance="Magento\Sales\Model\Observer\Frontend\Quote\SetCanApplyMsrp" method="execute" /> </event> </config> diff --git a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php index f7455805aff..057ac7db65f 100644 --- a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php +++ b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php @@ -23,7 +23,7 @@ */ namespace Magento\SalesRule\Model\Plugin; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Customer\Model\Session; use Magento\SalesRule\Model\Resource\Rule; diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index 8eb80f3d277..46a462a0a0a 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -43,18 +43,18 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal protected $_eventManager = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\SalesRule\Model\Validator $validator */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\SalesRule\Model\Validator $validator ) { $this->_eventManager = $eventManager; @@ -93,8 +93,9 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal $address->setDiscountDescription(array()); $items = $this->_calculator->sortItemsByPriority($items); + /** @var \Magento\Sales\Model\Quote\Item $item */ foreach ($items as $item) { - if ($item->getNoDiscount()) { + if ($item->getNoDiscount() || !$this->_calculator->canApplyDiscount($item)) { $item->setDiscountAmount(0); $item->setBaseDiscountAmount(0); continue; diff --git a/app/code/Magento/SalesRule/Model/Rule.php b/app/code/Magento/SalesRule/Model/Rule.php index 3d0e3869d1e..ce1733a10c7 100644 --- a/app/code/Magento/SalesRule/Model/Rule.php +++ b/app/code/Magento/SalesRule/Model/Rule.php @@ -193,7 +193,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel protected $_couponCollection; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -207,7 +207,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory * @param \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF * @param \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -222,7 +222,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory, \Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF, \Magento\SalesRule\Model\Resource\Coupon\Collection $couponCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index dbd098b213b..58192b28fdc 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -32,11 +32,11 @@ use Magento\Sales\Model\Quote\Address; * Allows dispatching before and after events for each controller action * * @method mixed getCouponCode() - * @method \Magento\SalesRule\Model\Validator setCouponCode($code) + * @method Validator setCouponCode($code) * @method mixed getWebsiteId() - * @method \Magento\SalesRule\Model\Validator setWebsiteId($id) + * @method Validator setWebsiteId($id) * @method mixed getCustomerGroupId() - * @method \Magento\SalesRule\Model\Validator setCustomerGroupId($id) + * @method Validator setCustomerGroupId($id) */ class Validator extends \Magento\Framework\Model\AbstractModel { @@ -91,6 +91,16 @@ class Validator extends \Magento\Framework\Model\AbstractModel */ protected $rulesApplier; + /** + * @var Validator\Pool + */ + protected $validators; + + /** + * @var \Magento\Framework\Message\ManagerInterface + */ + protected $messageManager; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -98,6 +108,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel * @param \Magento\Catalog\Helper\Data $catalogData * @param Utility $utility * @param RulesApplier $rulesApplier + * @param Validator\Pool $validators + * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -109,6 +121,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel \Magento\Catalog\Helper\Data $catalogData, \Magento\SalesRule\Model\Utility $utility, \Magento\SalesRule\Model\RulesApplier $rulesApplier, + \Magento\SalesRule\Model\Validator\Pool $validators, + \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -117,6 +131,8 @@ class Validator extends \Magento\Framework\Model\AbstractModel $this->_catalogData = $catalogData; $this->validatorUtility = $utility; $this->rulesApplier = $rulesApplier; + $this->validators = $validators; + $this->messageManager = $messageManager; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -338,6 +354,7 @@ class Validator extends \Magento\Framework\Model\AbstractModel return $this; } + /** @var \Magento\SalesRule\Model\Rule $rule */ foreach ($this->_getRules() as $rule) { if (\Magento\SalesRule\Model\Rule::CART_FIXED_ACTION == $rule->getSimpleAction() && $this->validatorUtility->canProcessRule($rule, $address) @@ -354,6 +371,9 @@ class Validator extends \Magento\Framework\Model\AbstractModel if (!$rule->getActions()->validate($item)) { continue; } + if (!$this->canApplyDiscount($item)) { + continue; + } $qty = $this->validatorUtility->getItemQty($item, $rule); $ruleTotalItemsPrice += $this->getItemPrice($item) * $qty; $ruleTotalBaseItemsPrice += $this->getItemBasePrice($item) * $qty; @@ -493,4 +513,23 @@ class Validator extends \Magento\Framework\Model\AbstractModel return $this; } + + /** + * Check if we can apply discount to current QuoteItem + * + * @param AbstractItem $item + * @return bool + */ + public function canApplyDiscount(AbstractItem $item) + { + $result = true; + /** @var \Zend_Validate_Interface $validator */ + foreach ($this->validators->getValidators('discount') as $validator) { + $result = $validator->isValid($item); + if (!$result) { + break; + } + } + return $result; + } } diff --git a/app/code/Magento/Install/Controller/Index/Index.php b/app/code/Magento/SalesRule/Model/Validator/Pool.php similarity index 62% rename from app/code/Magento/Install/Controller/Index/Index.php rename to app/code/Magento/SalesRule/Model/Validator/Pool.php index abcb6414045..57fb29de7cb 100644 --- a/app/code/Magento/Install/Controller/Index/Index.php +++ b/app/code/Magento/SalesRule/Model/Validator/Pool.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,29 +21,35 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Index; -class Index extends \Magento\Framework\App\Action\Action +namespace Magento\SalesRule\Model\Validator; + +/** + * Class Pool collects custom validators for items before SalesRules are applied + */ +class Pool { /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Config\Scope $configScope + * @var array */ - public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Config\Scope $configScope - ) { - parent::__construct($context); - $configScope->setCurrentScope('install'); + protected $validators = []; + + /** + * @param array $validators + */ + public function __construct(array $validators = []) + { + $this->validators = $validators; } /** - * Index action + * Get Validators defined in di * - * @return void + * @param string $type + * @return array */ - public function execute() + public function getValidators($type) { - $this->_redirect('install/wizard/begin'); + return isset($this->validators[$type]) ? $this->validators[$type] : []; } } diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index d83d7f5bfbd..1617a87e5c9 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-rule": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-catalog-rule": "0.1.0-alpha94", - "magento/module-widget": "0.1.0-alpha94", - "magento/module-cron": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-rule": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-catalog-rule": "0.1.0-alpha95", + "magento/module-widget": "0.1.0-alpha95", + "magento/module-cron": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php b/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php new file mode 100644 index 00000000000..216db8bba4f --- /dev/null +++ b/app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.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\Sendfriend\Block\Plugin\Catalog\Product; + +class View +{ + /** + * @var \Magento\Sendfriend\Model\Sendfriend + */ + protected $_sendfriend; + + /** + * @param \Magento\Sendfriend\Model\Sendfriend $sendfriend + */ + public function __construct( + \Magento\Sendfriend\Model\Sendfriend $sendfriend + ) { + $this->_sendfriend = $sendfriend; + } + + /** + * @param \Magento\Catalog\Block\Product\View $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterCanEmailToFriend(\Magento\Catalog\Block\Product\View $subject, $result) + { + if (!$result) { + $result = $this->_sendfriend->canEmailToFriend(); + } + return $result; + } +} diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php index 42eb89a6d69..66476755feb 100644 --- a/app/code/Magento/Sendfriend/Model/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php @@ -101,7 +101,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -128,7 +128,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Catalog\Helper\Image $catalogImage * @param \Magento\Sendfriend\Helper\Data $sendfriendData @@ -143,7 +143,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Catalog\Helper\Image $catalogImage, \Magento\Sendfriend\Helper\Data $sendfriendData, @@ -506,7 +506,7 @@ class Sendfriend extends \Magento\Framework\Model\AbstractModel if ($increment) { $newTimes[] = $time; $newValue = implode(',', $newTimes); - $this->cookieManager->setPublicCookie($cookieName, $newValue); + $this->cookieManager->setSensitiveCookie($cookieName, $newValue); $this->_lastCookieValue[$cookieName] = $newValue; } diff --git a/app/code/Magento/Backend/Model/Config/Source/Checktype.php b/app/code/Magento/Sendfriend/Model/Source/Checktype.php similarity index 96% rename from app/code/Magento/Backend/Model/Config/Source/Checktype.php rename to app/code/Magento/Sendfriend/Model/Source/Checktype.php index 6a516932f46..3aa159a0ca6 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Checktype.php +++ b/app/code/Magento/Sendfriend/Model/Source/Checktype.php @@ -28,7 +28,7 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Backend\Model\Config\Source; +namespace Magento\Sendfriend\Model\Source; class Checktype implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index 8f33effe471..8d37dfba3c1 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/etc/adminhtml/system.xml b/app/code/Magento/Sendfriend/etc/adminhtml/system.xml index 3ab63941560..539edc6b2f9 100644 --- a/app/code/Magento/Sendfriend/etc/adminhtml/system.xml +++ b/app/code/Magento/Sendfriend/etc/adminhtml/system.xml @@ -53,7 +53,7 @@ </field> <field id="check_by" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Limit Sending By</label> - <source_model>Magento\Backend\Model\Config\Source\Checktype</source_model> + <source_model>Magento\Sendfriend\Model\Source\Checktype</source_model> </field> </group> </section> diff --git a/app/code/Magento/Newsletter/etc/adminhtml/di.xml b/app/code/Magento/Sendfriend/etc/frontend/di.xml similarity index 86% rename from app/code/Magento/Newsletter/etc/adminhtml/di.xml rename to app/code/Magento/Sendfriend/etc/frontend/di.xml index 55fed61209d..53efa95b7d1 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/di.xml +++ b/app/code/Magento/Sendfriend/etc/frontend/di.xml @@ -24,9 +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\Newsletter\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> + <type name="Magento\Catalog\Block\Product\View"> + <plugin name="catalogProductViewCanEmailToFriend" type="Magento\Sendfriend\Block\Plugin\Catalog\Product\View" /> </type> </config> diff --git a/app/code/Magento/Shipping/Helper/Data.php b/app/code/Magento/Shipping/Helper/Data.php index b9124397a4e..ad842a465a2 100644 --- a/app/code/Magento/Shipping/Helper/Data.php +++ b/app/code/Magento/Shipping/Helper/Data.php @@ -51,7 +51,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -59,13 +59,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Core\Helper\Data $coreData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_coreData = $coreData; $this->_scopeConfig = $scopeConfig; diff --git a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php index 3f3d5902a33..19ff4bf44a4 100644 --- a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php +++ b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php @@ -35,7 +35,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf protected $_carrierHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,7 +60,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation * @param \Magento\Shipping\Helper\Carrier $carrierHelper - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param array $data @@ -78,7 +78,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, Carrier $carrierHelper, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array() diff --git a/app/code/Magento/Shipping/Model/Order/Track.php b/app/code/Magento/Shipping/Model/Order/Track.php index a9021255388..f754599ba1d 100644 --- a/app/code/Magento/Shipping/Model/Order/Track.php +++ b/app/code/Magento/Shipping/Model/Order/Track.php @@ -59,7 +59,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -73,7 +73,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Shipping/Model/Rate/Result.php b/app/code/Magento/Shipping/Model/Rate/Result.php index 032eb1d6253..e90993ec3ec 100644 --- a/app/code/Magento/Shipping/Model/Rate/Result.php +++ b/app/code/Magento/Shipping/Model/Rate/Result.php @@ -40,14 +40,14 @@ class Result protected $_error = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Shipping/Model/Shipping.php b/app/code/Magento/Shipping/Model/Shipping.php index 1ce2afa6532..01912ab482c 100644 --- a/app/code/Magento/Shipping/Model/Shipping.php +++ b/app/code/Magento/Shipping/Model/Shipping.php @@ -57,7 +57,7 @@ class Shipping implements RateCollectorInterface protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -99,7 +99,7 @@ class Shipping implements RateCollectorInterface /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Shipping\Model\Config $shippingConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory * @param \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory @@ -110,7 +110,7 @@ class Shipping implements RateCollectorInterface public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory, diff --git a/app/code/Magento/Shipping/Model/Shipping/Labels.php b/app/code/Magento/Shipping/Model/Shipping/Labels.php index d9f8d6780f9..d816363b40e 100644 --- a/app/code/Magento/Shipping/Model/Shipping/Labels.php +++ b/app/code/Magento/Shipping/Model/Shipping/Labels.php @@ -43,7 +43,7 @@ class Labels extends \Magento\Shipping\Model\Shipping /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Shipping\Model\Config $shippingConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory * @param \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory @@ -56,7 +56,7 @@ class Labels extends \Magento\Shipping\Model\Shipping public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Shipping\Model\Shipment\RequestFactory $shipmentRequestFactory, diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 2336c2664a5..24b19f4e421 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-contact": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-payment": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-contact": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-payment": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 73b2ec3593f..91f95cd27c7 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -73,7 +73,7 @@ class Observer protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -85,14 +85,14 @@ class Observer /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Resource\Sitemap\CollectionFactory $collectionFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sitemap\Model\Resource\Sitemap\CollectionFactory $collectionFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation ) { diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php index 64c5bc79699..b081b5ec32a 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php @@ -45,7 +45,7 @@ class Category extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_attributesCache = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -56,12 +56,12 @@ class Category extends \Magento\Framework\Model\Resource\Db\AbstractDb /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Resource\Category $categoryResource */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Category $categoryResource ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php index beafdb1bde8..4efb8c625e1 100644 --- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php @@ -68,7 +68,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_productResource; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -101,7 +101,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb * @param \Magento\Framework\App\Resource $resource * @param \Magento\Sitemap\Helper\Data $sitemapData * @param \Magento\Catalog\Model\Resource\Product $productResource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute @@ -112,7 +112,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb \Magento\Framework\App\Resource $resource, \Magento\Sitemap\Helper\Data $sitemapData, \Magento\Catalog\Model\Resource\Product $productResource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute, diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 4d0a65f7445..49850bc6a97 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -143,7 +143,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel protected $_dateModel; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -167,7 +167,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel * @param \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory * @param \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory * @param \Magento\Framework\Stdlib\DateTime\DateTime $modelDate - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -184,7 +184,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory, \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory, \Magento\Framework\Stdlib\DateTime\DateTime $modelDate, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 8234013185d..4e6ebf4ade3 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/App/Action/Plugin/Context.php b/app/code/Magento/Store/App/Action/Plugin/Context.php index 89e343a1209..3cc42e4b15b 100644 --- a/app/code/Magento/Store/App/Action/Plugin/Context.php +++ b/app/code/Magento/Store/App/Action/Plugin/Context.php @@ -45,34 +45,26 @@ class Context protected $httpRequest; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $cookieManager; - /** * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Request\Http $httpRequest - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Request\Http $httpRequest, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Stdlib\CookieManager $cookieManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->session = $session; $this->httpContext = $httpContext; $this->httpRequest = $httpRequest; $this->storeManager = $storeManager; - $this->cookieManager = $cookieManager; } /** @@ -86,17 +78,18 @@ class Context \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { + $defaultStore = $this->storeManager->getWebsite()->getDefaultStore(); $this->httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_CURRENCY, $this->session->getCurrencyCode(), - $this->storeManager->getWebsite()->getDefaultStore()->getDefaultCurrency()->getCode() + $defaultStore->getDefaultCurrency()->getCode() ); $this->httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_STORE, $this->httpRequest->getParam( '___store', - $this->cookieManager->getCookie(\Magento\Store\Model\Store::COOKIE_NAME) + $defaultStore->getStoreCodeFromCookie() ), $this->storeManager->getWebsite()->getDefaultStore()->getCode() ); diff --git a/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php b/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php index 79690ba3dd4..ea2ce943fc8 100644 --- a/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php +++ b/app/code/Magento/Store/App/Action/Plugin/StoreCheck.php @@ -27,25 +27,17 @@ namespace Magento\Store\App\Action\Plugin; class StoreCheck { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; - $this->_appState = $appState; } /** @@ -55,19 +47,17 @@ class StoreCheck * * @return \Magento\Framework\App\ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function aroundDispatch( \Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if ($this->_appState->isInstalled()) { - if (!$this->_storeManager->getStore()->getIsActive()) { - throw new \Magento\Store\Model\Exception( - 'Current store is not active.' - ); - } + if (!$this->_storeManager->getStore()->getIsActive()) { + throw new \Magento\Framework\App\InitException( + 'Current store is not active.' + ); } return $proceed($request); } diff --git a/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php b/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php deleted file mode 100644 index 43a54d6090b..00000000000 --- a/app/code/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandler.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/** - * Dispatch exception handler - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Store\App\FrontController\Plugin; - -use Magento\Store\Model\StoreManager; -use Magento\Framework\App\Filesystem; - -class DispatchExceptionHandler -{ - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; - - /** - * Filesystem instance - * - * @var \Magento\Framework\App\Filesystem - */ - protected $filesystem; - - /** - * @param StoreManager $storeManager - * @param Filesystem $filesystem - */ - public function __construct(StoreManager $storeManager, Filesystem $filesystem) - { - $this->_storeManager = $storeManager; - $this->filesystem = $filesystem; - } - - /** - * Handle dispatch exceptions - * - * @param \Magento\Framework\App\FrontController $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * - * @return mixed - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundDispatch( - \Magento\Framework\App\FrontController $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - try { - return $proceed($request); - } catch (\Magento\Framework\Session\Exception $e) { - header('Location: ' . $this->_storeManager->getStore()->getBaseUrl()); - exit; - } catch (\Magento\Store\Model\Exception $e) { - require $this->filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php'; - exit; - } - } -} diff --git a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php index 686ff0bb53c..3a90f4f5053 100644 --- a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php +++ b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php @@ -41,31 +41,23 @@ class RequestPreprocessor protected $_url; /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\App\State $appState + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $url * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\ResponseFactory $responseFactory */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\App\State $appState, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $url, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\ResponseFactory $responseFactory ) { $this->_storeManager = $storeManager; - $this->_appState = $appState; $this->_url = $url; $this->_scopeConfig = $scopeConfig; $this->_responseFactory = $responseFactory; @@ -87,7 +79,7 @@ class RequestPreprocessor \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if ($this->_appState->isInstalled() && !$request->isPost() && $this->_isBaseUrlCheckEnabled()) { + if (!$request->isPost() && $this->_isBaseUrlCheckEnabled()) { $baseUrl = $this->_storeManager->getStore()->getBaseUrl( \Magento\Framework\UrlInterface::URL_TYPE_WEB, $this->_storeManager->getStore()->isCurrentlySecure() diff --git a/app/code/Magento/Store/App/Request/PathInfoProcessor.php b/app/code/Magento/Store/App/Request/PathInfoProcessor.php index fbcbcfa49b4..0dfe74cca29 100644 --- a/app/code/Magento/Store/App/Request/PathInfoProcessor.php +++ b/app/code/Magento/Store/App/Request/PathInfoProcessor.php @@ -26,14 +26,14 @@ namespace Magento\Store\App\Request; class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Store/App/Response/Redirect.php b/app/code/Magento/Store/App/Response/Redirect.php index 615e1862bfb..8f6f8555cc8 100644 --- a/app/code/Magento/Store/App/Response/Redirect.php +++ b/app/code/Magento/Store/App/Response/Redirect.php @@ -33,7 +33,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface protected $_request; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -64,7 +64,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface /** * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Encryption\UrlCoder $urlCoder * @param \Magento\Framework\Session\SessionManagerInterface $session * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -73,7 +73,7 @@ class Redirect implements \Magento\Framework\App\Response\RedirectInterface */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Encryption\UrlCoder $urlCoder, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Framework\Session\SidResolverInterface $sidResolver, diff --git a/app/code/Magento/Store/Helper/Cookie.php b/app/code/Magento/Store/Helper/Cookie.php index a0f6336af40..66ca1750b35 100644 --- a/app/code/Magento/Store/Helper/Cookie.php +++ b/app/code/Magento/Store/Helper/Cookie.php @@ -60,7 +60,7 @@ class Cookie extends \Magento\Framework\App\Helper\AbstractHelper /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param array $data * @@ -68,7 +68,7 @@ class Cookie extends \Magento\Framework\App\Helper\AbstractHelper */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, array $data = array() ) { diff --git a/app/code/Magento/Store/Model/Config/Reader/Store.php b/app/code/Magento/Store/Model/Config/Reader/Store.php index f1a8289c879..a00f4092cbb 100644 --- a/app/code/Magento/Store/Model/Config/Reader/Store.php +++ b/app/code/Magento/Store/Model/Config/Reader/Store.php @@ -58,7 +58,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface protected $_appState; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -69,7 +69,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface * @param \Magento\Store\Model\Resource\Config\Collection\ScopedFactory $collectionFactory * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Config\Initial $initialConfig, @@ -78,7 +78,7 @@ class Store implements \Magento\Framework\App\Config\Scope\ReaderInterface \Magento\Store\Model\Resource\Config\Collection\ScopedFactory $collectionFactory, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_initialConfig = $initialConfig; $this->_scopePool = $scopePool; diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index bcb3b8ff476..9972fec515f 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -109,7 +109,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F protected $_store; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -118,7 +118,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F * @param \Magento\Framework\Registry $registry * @param \Magento\Core\Model\Resource\Config\Data $configDataResource * @param \Magento\Store\Model\Store $store - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -128,7 +128,7 @@ class Group extends \Magento\Framework\Model\AbstractModel implements \Magento\F \Magento\Framework\Registry $registry, \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\Store\Model\Store $store, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Store/Model/Resolver/Store.php b/app/code/Magento/Store/Model/Resolver/Store.php index 971ee31ea70..83532eafcc0 100644 --- a/app/code/Magento/Store/Model/Resolver/Store.php +++ b/app/code/Magento/Store/Model/Resolver/Store.php @@ -26,26 +26,27 @@ namespace Magento\Store\Model\Resolver; class Store implements \Magento\Framework\App\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } /** * {@inheritdoc} + * @throws \Magento\Framework\App\InitException */ public function getScope($scopeId = null) { $scope = $this->_storeManager->getStore($scopeId); if (!$scope instanceof \Magento\Framework\App\ScopeInterface) { - throw new \Magento\Store\Model\Exception('Invalid scope object'); + throw new \Magento\Framework\App\InitException('Invalid scope object'); } return $scope; diff --git a/app/code/Magento/Store/Model/Resolver/Website.php b/app/code/Magento/Store/Model/Resolver/Website.php index 5ffd7d9122f..b1c9332c7e1 100644 --- a/app/code/Magento/Store/Model/Resolver/Website.php +++ b/app/code/Magento/Store/Model/Resolver/Website.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) */ @@ -26,27 +26,28 @@ namespace Magento\Store\Model\Resolver; class Website implements \Magento\Framework\App\ScopeResolverInterface { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; } /** * {@inheritdoc} + * @throws \Magento\Framework\App\InitException */ public function getScope($scopeId = null) { $scope = $this->_storeManager->getWebsite($scopeId); if (!($scope instanceof \Magento\Framework\App\ScopeInterface)) { - throw new \Magento\Store\Model\Exception('Invalid scope object'); + throw new \Magento\Framework\App\InitException('Invalid scope object'); } return $scope; diff --git a/app/code/Magento/Store/Model/Storage/Db.php b/app/code/Magento/Store/Model/Storage/Db.php index 1b4088b6fa3..111554471a3 100644 --- a/app/code/Magento/Store/Model/Storage/Db.php +++ b/app/code/Magento/Store/Model/Storage/Db.php @@ -32,7 +32,7 @@ use Magento\Store\Model\StoreFactory; use Magento\Store\Model\Website; use Magento\Store\Model\WebsiteFactory as WebsiteFactory; -class Db implements \Magento\Store\Model\StoreManagerInterface +class Db implements \Magento\Framework\StoreManagerInterface { /** * Flag that shows that system has only one store view @@ -287,7 +287,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|string|bool|int|Store $storeId * @return Store - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getStore($storeId = null) { @@ -315,7 +315,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface } if (!$store->getCode()) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\App\InitException( 'Store Manager has been initialized not properly' ); } @@ -354,7 +354,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|bool|int|string|Website $websiteId * @return Website - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getWebsite($websiteId = null) { @@ -371,7 +371,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface // load method will load website by code if given ID is not a numeric value $website->load($websiteId); if (!$website->hasWebsiteId()) { - throw new \Magento\Store\Model\Exception('Invalid website id/code requested.'); + throw new \Magento\Framework\App\InitException('Invalid website id/code requested.'); } $this->_websites[$website->getWebsiteId()] = $website; $this->_websites[$website->getCode()] = $website; @@ -409,7 +409,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface * * @param null|Group|string $groupId * @return Group - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ public function getGroup($groupId = null) { @@ -423,7 +423,7 @@ class Db implements \Magento\Store\Model\StoreManagerInterface if (is_numeric($groupId)) { $group->load($groupId); if (!$group->hasGroupId()) { - throw new \Magento\Store\Model\Exception('Invalid store group id requested.'); + throw new \Magento\Framework\App\InitException('Invalid store group id requested.'); } } $this->_groups[$group->getGroupId()] = $group; diff --git a/app/code/Magento/Store/Model/Storage/DefaultStorage.php b/app/code/Magento/Store/Model/Storage/DefaultStorage.php index 339b28e7be8..6bf05327ca6 100644 --- a/app/code/Magento/Store/Model/Storage/DefaultStorage.php +++ b/app/code/Magento/Store/Model/Storage/DefaultStorage.php @@ -25,7 +25,7 @@ */ namespace Magento\Store\Model\Storage; -class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface +class DefaultStorage implements \Magento\Framework\StoreManagerInterface { /** * Application store object @@ -97,10 +97,7 @@ class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store object - * - * @param null|string|bool|int|\Magento\Store\Model\Store $storeId - * @return \Magento\Store\Model\Store + * {@inheritdoc} */ public function getStore($storeId = null) { @@ -155,11 +152,7 @@ class DefaultStorage implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store group object - * - * @param null|\Magento\Store\Model\Group|string $groupId - * @return \Magento\Store\Model\Group - * @throws \Magento\Framework\Model\Exception + * {@inheritdoc} */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Store/Model/StorageFactory.php b/app/code/Magento/Store/Model/StorageFactory.php index 711d0e8f7d4..35e6b1331d7 100644 --- a/app/code/Magento/Store/Model/StorageFactory.php +++ b/app/code/Magento/Store/Model/StorageFactory.php @@ -25,7 +25,7 @@ namespace Magento\Store\Model; use Magento\Framework\Profiler; use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class StorageFactory { @@ -49,7 +49,7 @@ class StorageFactory protected $_installedStorageClassName; /** - * @var \Magento\Store\Model\StoreManagerInterface[] + * @var \Magento\Framework\StoreManagerInterface[] */ protected $_cache = array(); @@ -78,11 +78,6 @@ class StorageFactory */ protected $_writerModel; - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $_cookieManager; - /** * @var \Magento\Framework\App\Http\Context */ @@ -93,21 +88,15 @@ class StorageFactory */ protected $request; - /** - * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory - */ - protected $cookieMetadataFactory; /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Session\SidResolverInterface $sidResolver * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory * @param string $defaultStorageClassName * @param string $installedStorageClassName * @param string $writerModel @@ -121,8 +110,6 @@ class StorageFactory \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Framework\Stdlib\CookieManager $cookieManager, $defaultStorageClassName = 'Magento\Store\Model\Storage\DefaultStorage', $installedStorageClassName = 'Magento\Store\Model\Storage\Db', $writerModel = '' @@ -136,8 +123,6 @@ class StorageFactory $this->_sidResolver = $sidResolver; $this->_writerModel = $writerModel; $this->_httpContext = $httpContext; - $this->cookieMetadataFactory = $cookieMetadataFactory; - $this->_cookieManager = $cookieManager; $this->_scopeConfig = $scopeConfig; $this->request = $request; } @@ -146,7 +131,7 @@ class StorageFactory * Get storage instance * * @param array $arguments - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface * @throws \InvalidArgumentException */ public function get(array $arguments = array()) @@ -155,12 +140,12 @@ class StorageFactory $this->_appState->isInstalled() ? $this->_installedStorageClassName : $this->_defaultStorageClassName; if (false == isset($this->_cache[$className])) { - /** @var $storage \Magento\Store\Model\StoreManagerInterface */ + /** @var $storage \Magento\Framework\StoreManagerInterface */ $storage = $this->_objectManager->create($className, $arguments); - if (false === ($storage instanceof \Magento\Store\Model\StoreManagerInterface)) { + if (false === ($storage instanceof \Magento\Framework\StoreManagerInterface)) { throw new \InvalidArgumentException( - $className . ' doesn\'t implement \Magento\Store\Model\StoreManagerInterface' + $className . ' doesn\'t implement \Magento\Framework\StoreManagerInterface' ); } $this->_cache[$className] = $storage; @@ -212,12 +197,12 @@ class StorageFactory /** * Initialize currently ran store * - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param array $arguments * @return void - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ - protected function _reinitStores(\Magento\Store\Model\StoreManagerInterface $storage, $arguments) + protected function _reinitStores(\Magento\Framework\StoreManagerInterface $storage, $arguments) { Profiler::start('init_stores'); $storage->reinitStores(); @@ -240,8 +225,8 @@ class StorageFactory $storage->setCurrentStore($this->_getStoreByWebsite($storage, $scopeCode)); break; default: - throw new \Magento\Store\Model\Exception( - 'Store Manager has been initialized not properly' + throw new \Magento\Framework\App\InitException( + 'Store Manager has not been initialized properly' ); } @@ -253,11 +238,11 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ - protected function _getStoreByGroup(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function _getStoreByGroup(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $groups = $storage->getGroups(true); $stores = $storage->getStores(true); @@ -271,11 +256,11 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ - protected function _getStoreByWebsite(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function _getStoreByWebsite(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $websites = $storage->getWebsites(true, true); if (!isset($websites[$scopeCode])) { @@ -288,24 +273,24 @@ class StorageFactory } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeType * @return void */ - protected function _checkCookieStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeType) + protected function _checkCookieStore(\Magento\Framework\StoreManagerInterface $storage, $scopeType) { - $storeCode = $this->_cookieManager->getCookie(Store::COOKIE_NAME); - if (isset($storeCode)) { + $storeCode = $storage->getStore()->getStoreCodeFromCookie(); + if (null != $storeCode) { $this->setCurrentStore($storage, $storeCode, $scopeType); } } /** - * @param \Magento\Store\Model\StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeType * @return void */ - protected function _checkRequestStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeType) + protected function _checkRequestStore(\Magento\Framework\StoreManagerInterface $storage, $scopeType) { $storeCode = $this->request->getParam('___store'); if (empty($storeCode)) { @@ -316,17 +301,16 @@ class StorageFactory return; } - if ($storage->getStore()->getCode() == $storeCode) { + $storageStore = $storage->getStore(); + if ($storageStore->getCode() == $storeCode) { $store = $storage->getStore($storeCode); if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) { - $this->_cookieManager->deleteCookie(Store::COOKIE_NAME); + $store->deleteCookie(); } else { - $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie(Store::COOKIE_NAME, $storage->getStore()->getCode(), $publicCookieMetadata); + $storageStore->setCookie(); $this->_httpContext->setValue( Store::ENTITY, - $storage->getStore()->getCode(), + $storageStore->getCode(), \Magento\Store\Model\Store::DEFAULT_CODE ); } @@ -341,7 +325,7 @@ class StorageFactory * @param string $scopeCode * @return bool|Store */ - protected function getActiveStoreByCode(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) + protected function getActiveStoreByCode(\Magento\Framework\StoreManagerInterface $storage, $scopeCode) { $stores = $storage->getStores(true, true); if ($scopeCode && isset($stores[$scopeCode]) @@ -356,12 +340,12 @@ class StorageFactory /** * Set current store * - * @param StoreManagerInterface $storage + * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @param string $scopeType * @return bool */ - protected function setCurrentStore(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode, $scopeType) + protected function setCurrentStore(\Magento\Framework\StoreManagerInterface $storage, $scopeCode, $scopeType) { $store = $this->getActiveStoreByCode($storage, $scopeCode); if (!$store) { diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index dc85ed2177b..8bba65ab3f4 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -25,6 +25,7 @@ namespace Magento\Store\Model; use Magento\Directory\Model\Currency\Filter; use Magento\Framework\Model\AbstractModel; +use Magento\Framework\StoreManagerInterface; /** * Store model @@ -118,11 +119,6 @@ class Store extends AbstractModel implements */ const COOKIE_NAME = 'store'; - /** - * Cookie currency key - */ - const COOKIE_CURRENCY = 'currency'; - /** * Script name, which returns all the images */ @@ -354,7 +350,7 @@ class Store extends AbstractModel implements \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\Framework\App\Filesystem $filesystem, \Magento\Framework\App\Config\ReinitableConfigInterface $config, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Session\SidResolverInterface $sidResolver, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Framework\Stdlib\CookieManager $cookieManager, @@ -429,9 +425,8 @@ class Store extends AbstractModel implements protected function _getSession() { if (!$this->_session->isSessionExists()) { - $this->_session->start( - 'store_' . $this->getCode() - ); + $this->_session->setName('store_' . $this->getCode()); + $this->_session->start(); } return $this->_session; } @@ -497,7 +492,7 @@ class Store extends AbstractModel implements protected function _getConfig($path) { $data = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $this->getCode()); - if (!$data && !$this->_appState->isInstalled()) { + if (!$data) { $data = $this->_config->getValue($path, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT); } return $data === false ? null : $data; @@ -629,10 +624,7 @@ class Store extends AbstractModel implements */ protected function _updatePathUseRewrites($url) { - if ($this->getForceDisableRewrites() || !$this->_getConfig( - self::XML_PATH_USE_REWRITES - ) || !$this->_appState->isInstalled() - ) { + if ($this->getForceDisableRewrites() || !$this->_getConfig(self::XML_PATH_USE_REWRITES)) { if ($this->_isCustomEntryPoint()) { $indexFileName = 'index.php'; } else { @@ -699,7 +691,6 @@ class Store extends AbstractModel implements { return !($this->hasDisableStoreInUrl() && $this->getDisableStoreInUrl()) && - $this->_appState->isInstalled() && $this->_getConfig(self::XML_PATH_STORE_IN_URL); } @@ -757,26 +748,21 @@ class Store extends AbstractModel implements return true; } - if ($this->_appState->isInstalled()) { - $secureBaseUrl = $this->_config->getValue( - self::XML_PATH_SECURE_BASE_URL, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - - if (!$secureBaseUrl) { - return false; - } + $secureBaseUrl = $this->_config->getValue( + self::XML_PATH_SECURE_BASE_URL, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); - $uri = \Zend_Uri::factory($secureBaseUrl); - $port = $uri->getPort(); - $isSecure = $uri->getScheme() == 'https' && isset( - $_SERVER['SERVER_PORT'] - ) && $port == $_SERVER['SERVER_PORT']; - return $isSecure; - } else { - $isSecure = isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']; - return $isSecure; + if (!$secureBaseUrl) { + return false; } + + $uri = \Zend_Uri::factory($secureBaseUrl); + $port = $uri->getPort(); + $isSecure = $uri->getScheme() == 'https' && isset( + $_SERVER['SERVER_PORT'] + ) && $port == $_SERVER['SERVER_PORT']; + return $isSecure; } /************************************************************************************* @@ -853,16 +839,7 @@ class Store extends AbstractModel implements $code = strtoupper($code); if (in_array($code, $this->getAvailableCurrencyCodes())) { $this->_getSession()->setCurrencyCode($code); - $path = $this->_getSession()->getCookiePath(); - - $sensitiveCookieMetadata = $this->_cookieMetadataFactory->createSensitiveCookieMetadata() - ->setPath($path); - - if ($code == $this->getDefaultCurrency()->getCurrencyCode()) { - $this->_cookieManager->deleteCookie(self::COOKIE_CURRENCY, $sensitiveCookieMetadata); - } else { - $this->_cookieManager->setSensitiveCookie(self::COOKIE_CURRENCY, $code, $sensitiveCookieMetadata); - } + $this->_httpContext->setValue( \Magento\Core\Helper\Data::CONTEXT_CURRENCY, $code, @@ -1314,4 +1291,43 @@ class Store extends AbstractModel implements { return array(self::CACHE_TAG . '_' . $this->getId()); } + + /** + * Set store cookie with this store's code for a year. + * + * @return $this + */ + public function setCookie() + { + $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() + ->setHttpOnly(true) + ->setDurationOneYear(); + $this->_cookieManager->setPublicCookie( + self::COOKIE_NAME, + $this->getCode(), + $cookieMetadata + ); + return $this; + } + + /** + * Get store code from store cookie. + * + * @return null|string + */ + public function getStoreCodeFromCookie() + { + return $this->_cookieManager->getCookie(self::COOKIE_NAME); + } + + /** + * Delete store cookie. + * + * @return $this + */ + public function deleteCookie() + { + $this->_cookieManager->deleteCookie(self::COOKIE_NAME); + return $this; + } } diff --git a/app/code/Magento/Store/Model/StoreManager.php b/app/code/Magento/Store/Model/StoreManager.php index e44c6e04248..6ab4d20352c 100644 --- a/app/code/Magento/Store/Model/StoreManager.php +++ b/app/code/Magento/Store/Model/StoreManager.php @@ -23,7 +23,7 @@ */ namespace Magento\Store\Model; -class StoreManager implements \Magento\Store\Model\StoreManagerInterface +class StoreManager implements \Magento\Framework\StoreManagerInterface { /** * Application run code @@ -120,7 +120,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface /** * Get storage instance * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ protected function _getStorage() { @@ -178,11 +178,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store object - * - * @param null|string|bool|int|Store $storeId - * @return Store - * @throws \Magento\Store\Model\Exception + * {@inheritdoc} */ public function getStore($storeId = null) { @@ -246,11 +242,7 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface } /** - * Retrieve application store group object - * - * @param null|\Magento\Store\Model\Group|string $groupId - * @return \Magento\Store\Model\Group - * @throws \Magento\Framework\Model\Exception + * {@inheritdoc} */ public function getGroup($groupId = null) { diff --git a/app/code/Magento/Store/Model/StoresConfig.php b/app/code/Magento/Store/Model/StoresConfig.php index b718bae2c0c..57936d4ccef 100644 --- a/app/code/Magento/Store/Model/StoresConfig.php +++ b/app/code/Magento/Store/Model/StoresConfig.php @@ -25,12 +25,12 @@ namespace Magento\Store\Model; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; class StoresConfig { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -40,11 +40,11 @@ class StoresConfig protected $_config; /** - * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $config */ public function __construct( - StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $config ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Store/Model/System/Store.php b/app/code/Magento/Store/Model/System/Store.php index 87d5b37b4af..65b9b66dff9 100644 --- a/app/code/Magento/Store/Model/System/Store.php +++ b/app/code/Magento/Store/Model/System/Store.php @@ -58,7 +58,7 @@ class Store extends \Magento\Framework\Object private $_isAdminScopeAllowed = true; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -66,9 +66,9 @@ class Store extends \Magento\Framework\Object * Init model * Load Website, Group and Store collections * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; return $this->reload(); diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index 319b8e9fd99..79ff21b2547 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -23,6 +23,8 @@ */ namespace Magento\Store\Model; +use Magento\Framework\StoreManagerInterface; + /** * Core Website model * @@ -186,7 +188,7 @@ class Website extends \Magento\Framework\Model\AbstractModel implements * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Store\Model\GroupFactory $storeGroupFactory * @param \Magento\Store\Model\WebsiteFactory $websiteFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -200,7 +202,7 @@ class Website extends \Magento\Framework\Model\AbstractModel implements \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Store\Model\GroupFactory $storeGroupFactory, \Magento\Store\Model\WebsiteFactory $websiteFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index a91e414b43d..193b79e5e6b 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-index": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-index": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index ca80cd75581..97cd42b2070 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -39,17 +39,17 @@ <type name="Magento\Store\Model\Config\Reader\Store"> <arguments> <argument name="scopePool" xsi:type="object">Magento\Framework\App\Config\ScopePool\Proxy</argument> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Resolver\Store"> <arguments> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Resolver\Website"> <arguments> - <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument> + <argument name="storeManager" xsi:type="object">Magento\Framework\StoreManagerInterface\Proxy</argument> </arguments> </type> <type name="Magento\Store\Model\Config\Reader\ReaderPool"> @@ -69,9 +69,6 @@ <type name="Magento\Framework\App\Action\Action"> <plugin name="storeCheck" type="Magento\Store\App\Action\Plugin\StoreCheck" sortOrder="10"/> </type> - <type name="Magento\Framework\App\FrontController"> - <plugin name="dispatchExceptionHandler" type="Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler" sortOrder="30"/> - </type> <type name="Magento\Store\Model\Resource\Website\Collection"> <arguments> <argument name="fetchStrategy" xsi:type="object">Magento\Store\Model\Resource\Website\Collection\FetchStrategy</argument> diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php index a9345cbfe80..6e75bcbe972 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php @@ -31,11 +31,6 @@ namespace Magento\Tax\Controller\Adminhtml; */ class Rate extends \Magento\Backend\App\Action { - /** - * @var \Magento\Framework\App\Response\Http\FileFactory - */ - protected $_fileFactory; - /** * @var \Magento\Framework\Registry */ @@ -63,7 +58,6 @@ class Rate extends \Magento\Backend\App\Action /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService * @param \Magento\Tax\Service\V1\Data\TaxRateBuilder $taxRateBuilder @@ -72,14 +66,12 @@ class Rate extends \Magento\Backend\App\Action */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Framework\Registry $coreRegistry, \Magento\Tax\Service\V1\TaxRateServiceInterface $taxRateService, \Magento\Tax\Service\V1\Data\TaxRateBuilder $taxRateBuilder, \Magento\Tax\Service\V1\Data\ZipRangeBuilder $zipRangeBuilder, \Magento\Tax\Service\V1\Data\TaxRateTitleBuilder $taxRateTitleBuilder ) { - $this->_fileFactory = $fileFactory; $this->_coreRegistry = $coreRegistry; $this->_taxRateService = $taxRateService; $this->_taxRateBuilder = $taxRateBuilder; @@ -132,28 +124,7 @@ class Rate extends \Magento\Backend\App\Action */ protected function _isAllowed() { - switch ($this->getRequest()->getActionName()) { - case 'importExport': - return $this->_authorization->isAllowed('Magento_Tax::import_export'); - break; - - case 'index': - return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); - break; - - case 'importPost': - case 'exportPost': - return $this->_authorization->isAllowed( - 'Magento_Tax::manage_tax' - ) || $this->_authorization->isAllowed( - 'Magento_Tax::import_export' - ); - break; - - default: - return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); - break; - } + return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); } /** diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index 11067bcc77d..dfa139f1b81 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -86,7 +86,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -172,7 +172,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Config $taxConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory * @param \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory @@ -193,7 +193,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory, diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php index 52e592ec26f..1f60094b609 100644 --- a/app/code/Magento/Tax/Model/Calculation.php +++ b/app/code/Magento/Tax/Model/Calculation.php @@ -128,7 +128,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -174,7 +174,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Config $taxConfig - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Tax\Model\Resource\TaxClass\CollectionFactory $classesFactory @@ -192,7 +192,7 @@ class Calculation extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, Config $taxConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Tax\Model\Resource\TaxClass\CollectionFactory $classesFactory, diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php index 73ea7a4fc0a..3dc1a5b623f 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation.php @@ -57,19 +57,19 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb protected $_taxData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Tax\Helper\Data $taxData, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_taxData = $taxData; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php index 4392e219147..d16a823b840 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php @@ -36,7 +36,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac const TAX_RULES_CHUNK_SIZE = 1000; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,7 +45,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -54,7 +54,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Tax/Model/System/Message/Notifications.php b/app/code/Magento/Tax/Model/System/Message/Notifications.php index 97df9ccd5f8..9eb167aa289 100644 --- a/app/code/Magento/Tax/Model/System/Message/Notifications.php +++ b/app/code/Magento/Tax/Model/System/Message/Notifications.php @@ -31,7 +31,7 @@ class Notifications implements \Magento\Framework\Notification\MessageInterface /** * Store manager object * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -62,12 +62,12 @@ class Notifications implements \Magento\Framework\Notification\MessageInterface protected $storesWithInvalidDiscountSettings; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Tax\Model\Config $taxConfig */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Tax\Model\Config $taxConfig ) { diff --git a/app/code/Magento/Tax/Service/V1/TaxCalculationService.php b/app/code/Magento/Tax/Service/V1/TaxCalculationService.php index 6ba8e66711a..53f7101944c 100644 --- a/app/code/Magento/Tax/Service/V1/TaxCalculationService.php +++ b/app/code/Magento/Tax/Service/V1/TaxCalculationService.php @@ -25,7 +25,7 @@ namespace Magento\Tax\Service\V1; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; -use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use Magento\Tax\Model\Calculation; use Magento\Tax\Model\Resource\Sales\Order\Tax; use Magento\Tax\Service\V1\Data\QuoteDetails; @@ -82,7 +82,7 @@ class TaxCalculationService implements TaxCalculationServiceInterface protected $taxDetailsItemBuilder; /** - * @var StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 569b13672ea..30d2337fc42 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-reports": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-reports": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/etc/acl.xml b/app/code/Magento/Tax/etc/acl.xml index 73edcc94e71..5031185f508 100644 --- a/app/code/Magento/Tax/etc/acl.xml +++ b/app/code/Magento/Tax/etc/acl.xml @@ -35,12 +35,6 @@ </resource> </resource> </resource> - - <resource id="Magento_Adminhtml::system"> - <resource id="Magento_Adminhtml::convert"> - <resource id="Magento_Tax::import_export" title="Import/Export Tax Rates" sortOrder="30" /> - </resource> - </resource> </resource> </resources> </acl> diff --git a/app/code/Magento/Tax/etc/adminhtml/menu.xml b/app/code/Magento/Tax/etc/adminhtml/menu.xml index 08dd11a9e5d..2abe5fa2d0a 100644 --- a/app/code/Magento/Tax/etc/adminhtml/menu.xml +++ b/app/code/Magento/Tax/etc/adminhtml/menu.xml @@ -28,6 +28,5 @@ <add id="Magento_Tax::sales_tax" title="Taxes" module="Magento_Tax" sortOrder="20" parent="Magento_Backend::stores" resource="Magento_Tax::manage_tax"/> <add id="Magento_Tax::sales_tax_rules" title="Tax Rules" module="Magento_Tax" sortOrder="10" parent="Magento_Tax::sales_tax" action="tax/rule" resource="Magento_Tax::manage_tax"/> <add id="Magento_Tax::sales_tax_rates" title="Tax Zones and Rates" module="Magento_Tax" sortOrder="20" parent="Magento_Tax::sales_tax" action="tax/rate" resource="Magento_Tax::manage_tax"/> - <add id="Magento_Tax::system_convert_tax" title="Import/Export Tax Rates" sortOrder="30" module="Magento_Tax" parent="Magento_Backend::system_convert" action="tax/rate/importExport" resource="Magento_Tax::import_export"/> </menu> </config> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml b/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml index a727e22c4a6..ba39177eb2d 100644 --- a/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml +++ b/app/code/Magento/Tax/view/adminhtml/layout/tax_rate_block.xml @@ -33,20 +33,6 @@ <argument name="default_dir" xsi:type="string">ASC</argument> <argument name="save_parameters_in_session" xsi:type="string">1</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Export" name="adminhtml.tax.rate.grid.export" as="grid.export"> - <arguments> - <argument name="exportTypes" xsi:type="array"> - <item name="csv" xsi:type="array"> - <item name="urlPath" xsi:type="string">tax/*/exportCsv</item> - <item name="label" xsi:type="string" translate="true">CSV</item> - </item> - <item name="excel" xsi:type="array"> - <item name="urlPath" xsi:type="string">tax/*/exportXml</item> - <item name="label" xsi:type="string" translate="true">Excel XML</item> - </item> - </argument> - </arguments> - </block> <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" name="adminhtml.catalog.product.set.grid.columnSet" as="grid.columnSet"> <arguments> <argument name="id" xsi:type="string">tax_rate_grid</argument> @@ -57,43 +43,40 @@ </item> </argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="code"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.code" as="code"> <arguments> <argument name="header" xsi:type="string" translate="true">Tax Identifier</argument> - <argument name="header_export" xsi:type="string" translate="true">Code</argument> <argument name="filter_index" xsi:type="string">code</argument> <argument name="index" xsi:type="string">code</argument> <argument name="column_css_class" xsi:type="string">col-name</argument> <argument name="header_css_class" xsi:type="string">col-name</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="tax_country_id"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.tax_country_id" as="tax_country_id"> <arguments> <argument name="header" xsi:type="string" translate="true">Country</argument> <argument name="type" xsi:type="string">country</argument> <argument name="filter_index" xsi:type="string">tax_country_id</argument> <argument name="index" xsi:type="string">tax_country_id</argument> - <argument name="renderer" xsi:type="string">Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer\Country</argument> <argument name="sortable" xsi:type="string">0</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="region_name"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.region_name" as="region_name"> <arguments> <argument name="header" xsi:type="string" translate="true">State/Region</argument> - <argument name="header_export" xsi:type="string" translate="true">State</argument> <argument name="filter_index" xsi:type="string">region_name</argument> <argument name="index" xsi:type="string">region_name</argument> <argument name="default" xsi:type="string">*</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="tax_postcode"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.tax_postcode" as="tax_postcode"> <arguments> <argument name="header" xsi:type="string" translate="true">Zip/Post Code</argument> <argument name="index" xsi:type="string">tax_postcode</argument> <argument name="default" xsi:type="string">*</argument> </arguments> </block> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="rate"> + <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.product.set.grid.column.rate" as="rate"> <arguments> <argument name="header" xsi:type="string" translate="true">Rate</argument> <argument name="index" xsi:type="string">rate</argument> diff --git a/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml b/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml index 59185d8a369..e4a91ea35ca 100644 --- a/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml +++ b/app/code/Magento/Tax/view/adminhtml/layout/tax_rule_edit.xml @@ -45,6 +45,5 @@ <block class="Magento\Tax\Block\Adminhtml\Rule\Edit"/> <block class="Magento\Tax\Block\Adminhtml\Rule\Edit\Form" name="tax-rule-edit" template="rule/edit.phtml"/> <block class="Magento\Tax\Block\Adminhtml\Rate\Form" name="tax-rate-form" template="rule/rate/form.phtml"/> - <block class="Magento\Tax\Block\Adminhtml\Rate\ImportExport" name="tax-rate-importExport" template="importExport.phtml"/> </referenceContainer> </page> diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php similarity index 95% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php index 2bedbed3a89..2a76d338760 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Country.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/Grid/Renderer/Country.php @@ -27,7 +27,7 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer; class Country extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Country { diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.php similarity index 96% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.php index 44020abf4b8..59168cd2401 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExport.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\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExport extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php similarity index 91% rename from app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php rename to app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php index e8ccf8ade1a..bbf5b3cb7cf 100644 --- a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExportHeader.php +++ b/app/code/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportHeader.php @@ -24,10 +24,8 @@ /** * Adminhtml import/export header block - * - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExportHeader extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php new file mode 100644 index 00000000000..cf27043f97e --- /dev/null +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\TaxImportExport\Controller\Adminhtml; + +/** + * Adminhtml tax rate controller + */ +class Rate extends \Magento\Backend\App\Action +{ + /** + * @var \Magento\Framework\App\Response\Http\FileFactory + */ + protected $fileFactory; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\App\Response\Http\FileFactory $fileFactory + ) { + $this->fileFactory = $fileFactory; + parent::__construct($context); + } + + /** + * @return bool + */ + protected function _isAllowed() + { + switch ($this->getRequest()->getActionName()) { + case 'importExport': + return $this->_authorization->isAllowed('Magento_TaxImportExport::import_export'); + case 'importPost': + case 'exportPost': + return $this->_authorization->isAllowed( + 'Magento_Tax::manage_tax' + ) || $this->_authorization->isAllowed( + 'Magento_TaxImportExport::import_export' + ); + default: + return $this->_authorization->isAllowed('Magento_Tax::manage_tax'); + } + } +} diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php similarity index 88% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php index 2edb90151f5..83fb8675254 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportCsv.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportCsv.php @@ -22,11 +22,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\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportCsv extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportCsv extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Export rates grid to CSV format @@ -37,7 +37,7 @@ class ExportCsv extends \Magento\Tax\Controller\Adminhtml\Rate { $this->_view->loadLayout(false); $content = $this->_view->getLayout()->getChildBlock('adminhtml.tax.rate.grid', 'grid.export'); - return $this->_fileFactory->create( + return $this->fileFactory->create( 'rates.csv', $content->getCsvFile(), \Magento\Framework\App\Filesystem::VAR_DIR diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php similarity index 93% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php index 2c0c0363383..5f6481da900 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportPost.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php @@ -22,11 +22,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\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportPost extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * export action from import/export tax @@ -100,6 +100,6 @@ class ExportPost extends \Magento\Tax\Controller\Adminhtml\Rate $content .= $rate->toString($template) . "\n"; } $this->_view->loadLayout(); - return $this->_fileFactory->create('tax_rates.csv', $content, \Magento\Framework\App\Filesystem::VAR_DIR); + return $this->fileFactory->create('tax_rates.csv', $content, \Magento\Framework\App\Filesystem::VAR_DIR); } } diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php similarity index 88% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php index ca829de220a..19a3a4f7b9a 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ExportXml.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportXml.php @@ -22,11 +22,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\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; use \Magento\Framework\App\ResponseInterface; -class ExportXml extends \Magento\Tax\Controller\Adminhtml\Rate +class ExportXml extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Export rates grid to XML format @@ -37,7 +37,7 @@ class ExportXml extends \Magento\Tax\Controller\Adminhtml\Rate { $this->_view->loadLayout(false); $content = $this->_view->getLayout()->getChildBlock('adminhtml.tax.rate.grid', 'grid.export'); - return $this->_fileFactory->create( + return $this->fileFactory->create( 'rates.xml', $content->getExcelFile(), \Magento\Framework\App\Filesystem::VAR_DIR diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php similarity index 75% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php index 4165a32467d..fb408573187 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportExport.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.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\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; -class ImportExport extends \Magento\Tax\Controller\Adminhtml\Rate +class ImportExport extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * Import and export Page @@ -39,11 +39,11 @@ class ImportExport extends \Magento\Tax\Controller\Adminhtml\Rate $this->_view->loadLayout(); $this->_setActiveMenu( - 'Magento_Tax::system_convert_tax' + 'Magento_TaxImportExport::system_convert_tax' )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExportHeader') + $this->_view->getLayout()->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExportHeader') )->_addContent( - $this->_view->getLayout()->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExport') + $this->_view->getLayout()->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport') ); $this->_view->renderLayout(); } diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php similarity index 86% rename from app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php rename to app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.php index 659d90992a7..eae0b262f12 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/ImportPost.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportPost.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\Tax\Controller\Adminhtml\Rate; +namespace Magento\TaxImportExport\Controller\Adminhtml\Rate; -class ImportPost extends \Magento\Tax\Controller\Adminhtml\Rate +class ImportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate { /** * import action from import/export tax @@ -35,8 +35,8 @@ class ImportPost extends \Magento\Tax\Controller\Adminhtml\Rate { if ($this->getRequest()->isPost() && !empty($_FILES['import_rates_file']['tmp_name'])) { try { - /** @var $importHandler \Magento\Tax\Model\Rate\CsvImportHandler */ - $importHandler = $this->_objectManager->create('Magento\Tax\Model\Rate\CsvImportHandler'); + /** @var $importHandler \Magento\TaxImportExport\Model\Rate\CsvImportHandler */ + $importHandler = $this->_objectManager->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); $importHandler->importFromCsvFile($this->getRequest()->getFiles('import_rates_file')); $this->messageManager->addSuccess(__('The tax rate has been imported.')); diff --git a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php b/app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php similarity index 99% rename from app/code/Magento/Tax/Model/Rate/CsvImportHandler.php rename to app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php index a2b63a019e5..7ca97c0ac84 100644 --- a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php +++ b/app/code/Magento/TaxImportExport/Model/Rate/CsvImportHandler.php @@ -21,12 +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\TaxImportExport\Model\Rate; /** * Tax Rate CSV Import Handler */ -namespace Magento\Tax\Model\Rate; - class CsvImportHandler { /** diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json new file mode 100644 index 00000000000..3beada316bd --- /dev/null +++ b/app/code/Magento/TaxImportExport/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-tax-import-export", + "description": "N/A", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "version": "0.1.0-alpha95", + "extra": { + "map": [ + [ + "*", + "Magento/TaxImportExport" + ] + ] + } +} diff --git a/app/code/Magento/TaxImportExport/etc/acl.xml b/app/code/Magento/TaxImportExport/etc/acl.xml new file mode 100644 index 00000000000..1df0c1e0d53 --- /dev/null +++ b/app/code/Magento/TaxImportExport/etc/acl.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<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"> + <resource id="Magento_Adminhtml::system"> + <resource id="Magento_Adminhtml::convert"> + <resource id="Magento_TaxImportExport::import_export" title="Import/Export Tax Rates" sortOrder="30" /> + </resource> + </resource> + </resource> + </resources> + </acl> +</config> diff --git a/app/code/Magento/Checkout/etc/adminhtml/di.xml b/app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml similarity index 74% rename from app/code/Magento/Checkout/etc/adminhtml/di.xml rename to app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml index 56b53502170..d2e1c2b1a6d 100644 --- a/app/code/Magento/Checkout/etc/adminhtml/di.xml +++ b/app/code/Magento/TaxImportExport/etc/adminhtml/menu.xml @@ -23,10 +23,9 @@ * @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\Checkout\Model\Session"> - <arguments> - <argument name="sessionName" xsi:type="string">adminhtml</argument> - </arguments> - </type> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd"> + <menu> + <add id="Magento_TaxImportExport::system_convert_tax" title="Import/Export Tax Rates" sortOrder="30" module="Magento_TaxImportExport" parent="Magento_Backend::system_convert" action="tax/rate/importExport" resource="Magento_TaxImportExport::import_export"/> + </menu> </config> + diff --git a/app/code/Magento/Install/etc/install/routes.xml b/app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml similarity index 89% rename from app/code/Magento/Install/etc/install/routes.xml rename to app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml index 4baf339c284..bab5c4dfcc1 100644 --- a/app/code/Magento/Install/etc/install/routes.xml +++ b/app/code/Magento/TaxImportExport/etc/adminhtml/routes.xml @@ -24,9 +24,9 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> - <router id="install"> - <route id="install" frontName="install"> - <module name="Magento_Install" /> + <router id="admin"> + <route id="tax"> + <module name="Magento_TaxImportExport" /> </route> </router> -</config> \ No newline at end of file +</config> diff --git a/app/code/Magento/TaxImportExport/etc/module.xml b/app/code/Magento/TaxImportExport/etc/module.xml new file mode 100644 index 00000000000..d9cffcf0454 --- /dev/null +++ b/app/code/Magento/TaxImportExport/etc/module.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> + <module name="Magento_TaxImportExport" schema_version="1.0.0.0" active="true"> + <sequence> + <module name="Magento_Tax"/> + </sequence> + <depends> + <module name="Magento_Backend"/> + <module name="Magento_Directory"/> + <module name="Magento_Store"/> + <module name="Magento_Tax"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.xml new file mode 100644 index 00000000000..144e1741e33 --- /dev/null +++ b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rate_block.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) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="adminhtml.tax.rate.grid"> + <block class="Magento\Backend\Block\Widget\Grid\Export" name="adminhtml.tax.rate.grid.export" as="grid.export"> + <arguments> + <argument name="exportTypes" xsi:type="array"> + <item name="csv" xsi:type="array"> + <item name="urlPath" xsi:type="string">tax/*/exportCsv</item> + <item name="label" xsi:type="string" translate="true">CSV</item> + </item> + <item name="excel" xsi:type="array"> + <item name="urlPath" xsi:type="string">tax/*/exportXml</item> + <item name="label" xsi:type="string" translate="true">Excel XML</item> + </item> + </argument> + </arguments> + </block> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.tax_country_id"> + <arguments> + <argument name="renderer" xsi:type="string">Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer\Country</argument> + </arguments> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.code"> + <arguments> + <argument name="header_export" xsi:type="string" translate="true">Code</argument> + </arguments> + </referenceBlock> + <referenceBlock name="adminhtml.catalog.product.set.grid.column.region_name"> + <arguments> + <argument name="header_export" xsi:type="string" translate="true">State</argument> + </arguments> + </referenceBlock> +</page> diff --git a/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml new file mode 100644 index 00000000000..3e9c44aba1a --- /dev/null +++ b/app/code/Magento/TaxImportExport/view/adminhtml/layout/tax_rule_edit.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Core/etc/page.xsd"> + <referenceBlock name="content"> + <block class="Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport" name="tax-rate-importExport" template="importExport.phtml"/> + </referenceBlock> +</page> diff --git a/app/code/Magento/Tax/view/adminhtml/templates/importExport.phtml b/app/code/Magento/TaxImportExport/view/adminhtml/templates/importExport.phtml similarity index 100% rename from app/code/Magento/Tax/view/adminhtml/templates/importExport.phtml rename to app/code/Magento/TaxImportExport/view/adminhtml/templates/importExport.phtml diff --git a/app/code/Magento/Tax/view/adminhtml/templates/importExportHeader.phtml b/app/code/Magento/TaxImportExport/view/adminhtml/templates/importExportHeader.phtml similarity index 100% rename from app/code/Magento/Tax/view/adminhtml/templates/importExportHeader.phtml rename to app/code/Magento/TaxImportExport/view/adminhtml/templates/importExportHeader.phtml diff --git a/app/code/Magento/Theme/Block/Html/Header.php b/app/code/Magento/Theme/Block/Html/Header.php index 1dc1bd5e765..2122de2a370 100644 --- a/app/code/Magento/Theme/Block/Html/Header.php +++ b/app/code/Magento/Theme/Block/Html/Header.php @@ -132,7 +132,7 @@ class Header extends \Magento\Framework\View\Element\Template public function getWelcome() { if (empty($this->_data['welcome'])) { - if ($this->_appState->isInstalled() && $this->httpContext->getValue(Data::CONTEXT_AUTH)) { + if ($this->httpContext->getValue(Data::CONTEXT_AUTH)) { $customerName = $this->_customerViewHelper->getCustomerName( $this->_customerSession->getCustomerDataObject() ); diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php index 2a1df6946d9..b5d20f50e49 100644 --- a/app/code/Magento/Theme/Model/Config.php +++ b/app/code/Magento/Theme/Model/Config.php @@ -40,7 +40,7 @@ class Config protected $_configData; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -64,7 +64,7 @@ class Config /** * @param \Magento\Framework\App\Config\ValueInterface $configData * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Cache\FrontendInterface $configCache * @param \Magento\Framework\Cache\FrontendInterface $layoutCache @@ -72,7 +72,7 @@ class Config public function __construct( \Magento\Framework\App\Config\ValueInterface $configData, \Magento\Framework\App\Config\Storage\WriterInterface $configWriter, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Cache\FrontendInterface $configCache, \Magento\Framework\Cache\FrontendInterface $layoutCache diff --git a/app/code/Magento/Theme/Model/Config/Customization.php b/app/code/Magento/Theme/Model/Config/Customization.php index b838fbdc3e3..b01eba7a374 100644 --- a/app/code/Magento/Theme/Model/Config/Customization.php +++ b/app/code/Magento/Theme/Model/Config/Customization.php @@ -29,7 +29,7 @@ namespace Magento\Theme\Model\Config; class Customization { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -60,12 +60,12 @@ class Customization protected $_unassignedTheme; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\View\Design\Theme\ThemeProviderInterface $themeProvider ) { diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 0e978279184..9c1cd7028ad 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-translation": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-translation": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Translation/Model/Inline/Parser.php b/app/code/Magento/Translation/Model/Inline/Parser.php index 1c809410bd4..26cc27a7f7e 100644 --- a/app/code/Magento/Translation/Model/Inline/Parser.php +++ b/app/code/Magento/Translation/Model/Inline/Parser.php @@ -113,7 +113,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface protected $_resourceFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -140,7 +140,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface /** * Initialize base inline translation model * - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Translation\Model\Resource\StringFactory $resource * @param \Zend_Filter_Interface $inputFilter * @param \Magento\Framework\App\State $appState @@ -149,7 +149,7 @@ class Parser implements \Magento\Framework\Translate\Inline\ParserInterface */ public function __construct( \Magento\Translation\Model\Resource\StringFactory $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Zend_Filter_Interface $inputFilter, \Magento\Framework\App\State $appState, \Magento\Framework\App\Cache\TypeListInterface $appCache, diff --git a/app/code/Magento/Translation/Model/Resource/Translate.php b/app/code/Magento/Translation/Model/Resource/Translate.php index 180e00f4071..42fc1b678c4 100644 --- a/app/code/Magento/Translation/Model/Resource/Translate.php +++ b/app/code/Magento/Translation/Model/Resource/Translate.php @@ -23,12 +23,9 @@ */ namespace Magento\Translation\Model\Resource; -class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implements \Magento\Framework\Translate\ResourceInterface +class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implements + \Magento\Framework\Translate\ResourceInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; /** * @var \Magento\Framework\App\ScopeResolverInterface @@ -42,17 +39,14 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param null|string $scope */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, $scope = null ) { - $this->_appState = $appState; $this->scopeResolver = $scopeResolver; $this->scope = $scope; parent::__construct($resource); @@ -77,10 +71,6 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen */ public function getTranslationArray($storeId = null, $locale = null) { - if (!$this->_appState->isInstalled()) { - return array(); - } - if (is_null($storeId)) { $storeId = $this->getStoreId(); } @@ -110,10 +100,6 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen */ public function getTranslationArrayByStrings(array $strings, $storeId = null) { - if (!$this->_appState->isInstalled()) { - return array(); - } - if (is_null($storeId)) { $storeId = $this->getStoreId(); } diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 2ce469dc12e..69638e1b2ff 100644 --- a/app/code/Magento/Translation/composer.json +++ b/app/code/Magento/Translation/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-core": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-core": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 29b7125bc8f..93639fbc240 100644 --- a/app/code/Magento/Ups/composer.json +++ b/app/code/Magento/Ups/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php b/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php index 0875908a272..450beaea8d4 100644 --- a/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php +++ b/app/code/Magento/UrlRedirect/Block/Catalog/Edit/Form.php @@ -155,7 +155,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\Model\Exception */ protected function _getEntityStores() { @@ -173,7 +173,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form $entityStores = array_intersect($entityStores, $categoryStores); } if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\Model\Exception( __( 'We can\'t set up a URL rewrite because the product you chose is not associated with a website.' ) @@ -186,7 +186,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form 'We can\'t set up a URL rewrite because the category your chose is not associated with a website.' ); if (!$entityStores) { - throw new \Magento\Store\Model\Exception($message); + throw new \Magento\Framework\Model\Exception($message); } $this->_requireStoresFilter = true; } diff --git a/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php b/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php index 519589c91dd..6cdc0a33bfc 100644 --- a/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php +++ b/app/code/Magento/UrlRedirect/Block/Cms/Page/Edit/Form.php @@ -128,7 +128,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form * Get catalog entity associated stores * * @return array - * @throws \Magento\Store\Model\Exception + * @throws \Magento\Framework\App\InitException */ protected function _getEntityStores() { @@ -141,7 +141,7 @@ class Form extends \Magento\UrlRedirect\Block\Edit\Form $this->_requireStoresFilter = !in_array(0, $entityStores); if (!$entityStores) { - throw new \Magento\Store\Model\Exception( + throw new \Magento\Framework\App\InitException( __('Chosen cms page does not associated with any website.') ); } diff --git a/app/code/Magento/UrlRedirect/Controller/Router.php b/app/code/Magento/UrlRedirect/Controller/Router.php index 26b365613cd..2407898978e 100644 --- a/app/code/Magento/UrlRedirect/Controller/Router.php +++ b/app/code/Magento/UrlRedirect/Controller/Router.php @@ -28,13 +28,7 @@ namespace Magento\UrlRedirect\Controller; */ class Router implements \Magento\Framework\App\RouterInterface { - /** @var \Magento\Framework\UrlInterface */ - protected $url; - - /** @var \Magento\Framework\App\State */ - protected $appState; - - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; /** @var \Magento\Framework\App\ResponseInterface */ @@ -50,23 +44,17 @@ class Router implements \Magento\Framework\App\RouterInterface /** * @param \Magento\Framework\App\ActionFactory $actionFactory - * @param \Magento\Framework\UrlInterface $url - * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResponseInterface $response * @param \Magento\UrlRedirect\Service\V1\UrlMatcherInterface $urlMatcher */ public function __construct( \Magento\Framework\App\ActionFactory $actionFactory, - \Magento\Framework\UrlInterface $url, - \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\ResponseInterface $response, \Magento\UrlRedirect\Service\V1\UrlMatcherInterface $urlMatcher ) { $this->actionFactory = $actionFactory; - $this->url = $url; - $this->appState = $appState; $this->storeManager = $storeManager; $this->response = $response; $this->urlMatcher = $urlMatcher; @@ -80,11 +68,6 @@ class Router implements \Magento\Framework\App\RouterInterface */ public function match(\Magento\Framework\App\RequestInterface $request) { - if (!$this->appState->isInstalled()) { - $this->response->setRedirect($this->url->getUrl('install'))->sendResponse(); - return null; - } - $identifier = trim($request->getPathInfo(), '/'); $urlRewrite = $this->urlMatcher->match($identifier, $this->storeManager->getStore()->getId()); if ($urlRewrite === null) { diff --git a/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php b/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php index 9cc9f17e6f3..edfa1551655 100644 --- a/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php +++ b/app/code/Magento/UrlRedirect/Model/Resource/UrlRedirect/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store Manager Model * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,7 +39,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -48,7 +48,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/UrlRedirect/composer.json b/app/code/Magento/UrlRedirect/composer.json index ad444a0f914..ebfb97ff4fe 100644 --- a/app/code/Magento/UrlRedirect/composer.json +++ b/app/code/Magento/UrlRedirect/composer.json @@ -3,16 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-install": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94" + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/UrlRedirect/etc/module.xml b/app/code/Magento/UrlRedirect/etc/module.xml index 1202c64f728..dd2376b022c 100644 --- a/app/code/Magento/UrlRedirect/etc/module.xml +++ b/app/code/Magento/UrlRedirect/etc/module.xml @@ -30,7 +30,6 @@ <module name="Magento_Cms"/> <module name="Magento_Core"/> <module name="Magento_Backend"/> - <module name="Magento_Install"/> <module name="Magento_Store"/> </depends> </module> diff --git a/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php index f3141604122..be99bf62d82 100644 --- a/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php @@ -32,25 +32,17 @@ class UrlRewrite */ protected $_rewriteService; - /** - * @var \Magento\Framework\App\State - */ - protected $_state; - /** * @param \Magento\UrlRewrite\App\Request\RewriteService $rewriteService - * @param \Magento\Framework\App\State $state */ public function __construct( - \Magento\UrlRewrite\App\Request\RewriteService $rewriteService, - \Magento\Framework\App\State $state + \Magento\UrlRewrite\App\Request\RewriteService $rewriteService ) { $this->_rewriteService = $rewriteService; - $this->_state = $state; } /** - * Perform url rewites + * Perform url rewrites * * @param \Magento\Framework\App\FrontController $subject * @param callable $proceed @@ -64,9 +56,6 @@ class UrlRewrite \Closure $proceed, \Magento\Framework\App\RequestInterface $request ) { - if (!$this->_state->isInstalled()) { - return $proceed($request); - } $this->_rewriteService->applyRewrites($request); return $proceed($request); } diff --git a/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php index de4b19b675e..8724cf077d2 100644 --- a/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php +++ b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * Store Manager Model * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -39,7 +39,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\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -48,7 +48,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\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php index 6334646455d..e8837ea865d 100644 --- a/app/code/Magento/UrlRewrite/Model/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php @@ -81,17 +81,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel protected $_scopeConfig; /** - * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory - */ - protected $_cookieMetadataFactory; - - /** - * @var \Magento\Framework\Stdlib\CookieManager - */ - protected $_cookieManager; - - /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -104,9 +94,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - * @param \Magento\Framework\Stdlib\CookieManager $cookieManager, - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -116,9 +104,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, @@ -126,8 +112,6 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel ) { $this->_scopeConfig = $scopeConfig; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - $this->_cookieManager = $cookieManager; - $this->_cookieMetadataFactory = $cookieMetadataFactory; $this->_storeManager = $storeManager; $this->_httpContext = $httpContext; } @@ -207,9 +191,6 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel */ public function rewrite(\Magento\Framework\App\RequestInterface $request = null) { - if (!$this->_appState->isInstalled()) { - return false; - } if (is_null($this->getStoreId()) || false === $this->getStoreId()) { $this->setStoreId($this->_storeManager->getStore()->getId()); } @@ -256,14 +237,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel } $currentStore = $this->_storeManager->getStore(); $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); - - $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie( - \Magento\Store\Model\Store::COOKIE_NAME, - $currentStore->getCode(), - $cookieMetadata - ); + $currentStore->setCookie(); $targetUrl .= '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); @@ -278,16 +252,7 @@ class UrlRewrite extends \Magento\Framework\Model\AbstractModel $external = substr($this->getTargetPath(), 0, 6); $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { - $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); - - $cookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata() - ->setDurationOneYear(); - $this->_cookieManager->setPublicCookie( - \Magento\Store\Model\Store::COOKIE_NAME, - $destinationStoreCode, - $cookieMetadata - ); - + $this->_storeManager->getStore($this->getStoreId())->setCookie(); $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { $targetUrl .= '/' . $this->getTargetPath(); diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 16b328cf8ef..93f34470c00 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-store": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php b/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php index f4b10c5f9e1..f01c928ae02 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/InvalidateToken.php @@ -36,8 +36,8 @@ class InvalidateToken extends \Magento\User\Controller\Adminhtml\User public function execute() { if ($userId = $this->getRequest()->getParam('user_id')) { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = $this->_objectManager->get('\Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = $this->_objectManager->get('\Magento\Integration\Service\V1\AdminTokenService'); try { $tokenService->revokeAdminAccessToken($userId); $this->messageManager->addSuccess(__('You have revoked the user\'s tokens.')); diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index 3d33fe05828..400c0330ef7 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -138,7 +138,7 @@ class User extends AbstractModel implements StorageInterface protected $_transportBuilder; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -154,7 +154,7 @@ class User extends AbstractModel implements StorageInterface * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -169,7 +169,7 @@ class User extends AbstractModel implements StorageInterface \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -231,7 +231,7 @@ class User extends AbstractModel implements StorageInterface $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'); + $this->_storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); } /** diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index ccf61d9172b..bb64e5f3972 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,17 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-store": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/User/etc/module.xml b/app/code/Magento/User/etc/module.xml index 7c4efc0c354..7dfc874d137 100644 --- a/app/code/Magento/User/etc/module.xml +++ b/app/code/Magento/User/etc/module.xml @@ -30,7 +30,6 @@ </sequence> <depends> <module name="Magento_Authorization"/> - <module name="Magento_Store"/> <module name="Magento_Backend"/> <module name="Magento_Core"/> <module name="Magento_Integration"/> diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index d8e166eb745..84261a44ba4 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-shipping": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-shipping": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index 7e9ba9b4f10..af6fe32e749 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -26,9 +26,7 @@ namespace Magento\Webapi\Controller; use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\AuthorizationException; -use Magento\Framework\Service\Data\AbstractSimpleObject; -use Magento\Framework\Service\Data\AbstractExtensibleObject; -use Magento\Framework\Service\ExtensibleDataObjectConverter; +use Magento\Framework\Service\SimpleDataObjectConverter; use Magento\Webapi\Controller\Rest\Request as RestRequest; use Magento\Webapi\Controller\Rest\Response as RestResponse; use Magento\Webapi\Controller\Rest\Response\PartialResponseProcessor; @@ -65,9 +63,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface /** @var \Magento\Framework\App\State */ protected $_appState; - /** @var \Magento\Framework\View\LayoutInterface */ - protected $_layout; - /** @var AuthorizationInterface */ protected $_authorization; @@ -100,6 +95,11 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface */ protected $userContext; + /** + * @var SimpleDataObjectConverter $dataObjectConverter + */ + protected $dataObjectConverter; + /** * Initialize dependencies * @@ -108,7 +108,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param Router $router * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\View\LayoutInterface $layout * @param AuthorizationInterface $authorization * @param ServiceArgsSerializer $serializer * @param ErrorProcessor $errorProcessor @@ -116,6 +115,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface * @param \Magento\Framework\App\AreaList $areaList * @param PartialResponseProcessor $partialResponseProcessor * @param UserContextInterface $userContext + * @param SimpleDataObjectConverter $dataObjectConverter * * TODO: Consider removal of warning suppression * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -126,21 +126,20 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface Router $router, \Magento\Framework\ObjectManager $objectManager, \Magento\Framework\App\State $appState, - \Magento\Framework\View\LayoutInterface $layout, AuthorizationInterface $authorization, ServiceArgsSerializer $serializer, ErrorProcessor $errorProcessor, PathProcessor $pathProcessor, \Magento\Framework\App\AreaList $areaList, PartialResponseProcessor $partialResponseProcessor, - UserContextInterface $userContext + UserContextInterface $userContext, + SimpleDataObjectConverter $dataObjectConverter ) { $this->_router = $router; $this->_request = $request; $this->_response = $response; $this->_objectManager = $objectManager; $this->_appState = $appState; - $this->_layout = $layout; $this->_authorization = $authorization; $this->_serializer = $serializer; $this->_errorProcessor = $errorProcessor; @@ -148,6 +147,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $this->areaList = $areaList; $this->partialResponseProcessor = $partialResponseProcessor; $this->userContext = $userContext; + $this->dataObjectConverter = $dataObjectConverter; } /** @@ -163,9 +163,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $this->areaList->getArea($this->_appState->getAreaCode()) ->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { - if (!$this->_appState->isInstalled()) { - throw new \Magento\Webapi\Exception(__('Magento is not yet installed')); - } $this->checkPermissions(); $route = $this->getCurrentRoute(); if ($route->isSecure() && !$this->_request->isSecure()) { @@ -180,7 +177,7 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $service = $this->_objectManager->get($serviceClassName); /** @var \Magento\Framework\Service\Data\AbstractExtensibleObject $outputData */ $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams); - $outputData = $this->processServiceOutput($outputData); + $outputData = $this->dataObjectConverter->processServiceOutput($outputData); if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) { $outputData = $this->partialResponseProcessor->filter($outputData); } @@ -192,61 +189,6 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface return $this->_response; } - /** - * Converts the incoming data into scalar or an array of scalars format. - * - * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is - * assumed to be a Data Object and converted to an associative array with keys representing the properties of the - * Data Object. - * Nested Data Objects are also converted. If the data provided is itself an array, then we iterate through the - * contents and convert each piece individually. - * - * @param mixed $data - * @return array|int|string|bool|float Scalar or array of scalars - */ - protected function processServiceOutput($data) - { - if (is_array($data)) { - $result = []; - foreach ($data as $datum) { - if ($datum instanceof AbstractSimpleObject) { - $datum = $this->processDataObject($datum->__toArray()); - } - $result[] = $datum; - } - return $result; - } else if ($data instanceof AbstractSimpleObject) { - return $this->processDataObject($data->__toArray()); - } else if (is_null($data)) { - return []; - } else { - /** No processing is required for scalar types */ - return $data; - } - } - - /** - * Convert data object to array and process available custom attributes - * - * @param array $dataObjectArray - * @return array - */ - protected function processDataObject($dataObjectArray) - { - if (isset($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) { - $dataObjectArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray( - $dataObjectArray - ); - } - //Check for nested custom_attributes - foreach ($dataObjectArray as $key => $value) { - if (is_array($value)) { - $dataObjectArray[$key] = $this->processDataObject($value); - } - } - return $dataObjectArray; - } - /** * Override parameter values based on webapi.xml * diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php index 82488709167..1b40db6cbf4 100644 --- a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php +++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php @@ -25,13 +25,15 @@ */ namespace Magento\Webapi\Controller; +use Magento\Framework\ObjectManager; +use Magento\Framework\Service\Config\Reader as ServiceConfigReader; +use Magento\Framework\Service\Data\AttributeValue; +use Magento\Framework\Service\Data\AttributeValueBuilder; +use Magento\Webapi\Model\Config\ClassReflector\TypeProcessor; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; use Zend\Code\Reflection\ParameterReflection; -use Magento\Framework\ObjectManager; -use Magento\Webapi\Model\Config\ClassReflector\TypeProcessor; -use Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy; -use \Magento\Webapi\DeserializationException; +use Magento\Framework\Service\SimpleDataObjectConverter; class ServiceArgsSerializer { @@ -41,16 +43,30 @@ class ServiceArgsSerializer /** @var ObjectManager */ protected $_objectManager; + /** @var ServiceConfigReader */ + protected $serviceConfigReader; + + /** @var AttributeValueBuilder */ + protected $attributeValueBuilder; + /** * Initialize dependencies. * * @param TypeProcessor $typeProcessor * @param ObjectManager $objectManager + * @param ServiceConfigReader $serviceConfigReader + * @param AttributeValueBuilder $attributeValueBuilder */ - public function __construct(TypeProcessor $typeProcessor, ObjectManager $objectManager) - { + public function __construct( + TypeProcessor $typeProcessor, + ObjectManager $objectManager, + ServiceConfigReader $serviceConfigReader, + AttributeValueBuilder $attributeValueBuilder + ) { $this->_typeProcessor = $typeProcessor; $this->_objectManager = $objectManager; + $this->serviceConfigReader = $serviceConfigReader; + $this->attributeValueBuilder = $attributeValueBuilder; } /** @@ -139,18 +155,78 @@ class ServiceArgsSerializer foreach ($data as $propertyName => $value) { // Converts snake_case to uppercase CamelCase to help form getter/setter method names // This use case is for REST only. SOAP request data is already camel cased - $camelCaseProperty = str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName))); + $camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($propertyName); $methodName = $this->_processGetterMethod($class, $camelCaseProperty); $methodReflection = $class->getMethod($methodName); if ($methodReflection->isPublic()) { $returnType = $this->_typeProcessor->getGetterReturnType($methodReflection)['type']; $setterName = 'set' . $camelCaseProperty; - $builder->{$setterName}($this->_convertValue($value, $returnType)); + if ($camelCaseProperty === 'CustomAttributes') { + $setterValue = $this->convertCustomAttributeValue($value, $returnType, $className); + } else { + $setterValue = $this->_convertValue($value, $returnType); + } + $builder->{$setterName}($setterValue); } } return $builder->create(); } + /** + * Convert custom attribute data array to array of AttributeValue Data Object + * + * @param array $customAttributesValueArray + * @param string $returnType + * @param string $dataObjectClassName + * @return AttributeValue[] + */ + protected function convertCustomAttributeValue($customAttributesValueArray, $returnType, $dataObjectClassName) + { + $result = []; + $allAttributes = $this->serviceConfigReader->read(); + $dataObjectClassName = ltrim($dataObjectClassName, '\\'); + if (!isset($allAttributes[$dataObjectClassName])) { + return $this->_convertValue($customAttributesValueArray, $returnType); + } + $dataObjectAttributes = $allAttributes[$dataObjectClassName]; + $camelCaseAttributeCodeKey = lcfirst( + SimpleDataObjectConverter::snakeCaseToUpperCamelCase(AttributeValue::ATTRIBUTE_CODE) + ); + foreach ($customAttributesValueArray as $customAttribute) { + if (isset($customAttribute[AttributeValue::ATTRIBUTE_CODE])) { + $customAttributeCode = $customAttribute[AttributeValue::ATTRIBUTE_CODE]; + } else if (isset($customAttribute[$camelCaseAttributeCodeKey])) { + $customAttributeCode = $customAttribute[$camelCaseAttributeCodeKey]; + } else { + $customAttributeCode = null; + } + + //Check if type is defined, else default to mixed + $type = isset($dataObjectAttributes[$customAttributeCode]) + ? $dataObjectAttributes[$customAttributeCode] + : TypeProcessor::ANY_TYPE; + + $customAttributeValue = $customAttribute[AttributeValue::VALUE]; + if (is_array($customAttributeValue)) { + //If type for AttributeValue's value as array is mixed, further processing is not possible + if ($type === TypeProcessor::ANY_TYPE) { + continue; + } + //If custom attribute value is an array then its a data object type + $attributeValue = $this->_createFromArray($type, $customAttributeValue); + } else { + $attributeValue = $this->_convertValue($customAttributeValue, $type); + } + //Populate the attribute value data object once the value for custom attribute is derived based on type + $result[] = $this->attributeValueBuilder + ->setAttributeCode($customAttributeCode) + ->setValue($attributeValue) + ->create(); + } + + return $result; + } + /** * Convert data from array to Data Object representation if type is Data Object or array of Data Objects. * @@ -172,8 +248,10 @@ class ServiceArgsSerializer // Initializing the result for array type else it will return null for empty array $result = is_array($value) ? [] : null; $itemType = $this->_typeProcessor->getArrayItemType($type); - foreach ($value as $key => $item) { - $result[$key] = $this->_createFromArray($itemType, $item); + if (is_array($value)) { + foreach ($value as $key => $item) { + $result[$key] = $this->_createFromArray($itemType, $item); + } } } else { $result = $this->_createFromArray($type, $value); diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index 523e41baa3d..bbb8e1c5e0f 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -45,25 +45,34 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface /**#@-*/ - /** @var \Magento\Webapi\Model\Soap\Server */ + /** + * @var \Magento\Webapi\Model\Soap\Server + */ protected $_soapServer; - /** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */ + /** + * @var \Magento\Webapi\Model\Soap\Wsdl\Generator + */ protected $_wsdlGenerator; - /** @var \Magento\Webapi\Controller\Soap\Request */ + /** + * @var \Magento\Webapi\Controller\Soap\Request + */ protected $_request; - /** @var Response */ + /** + * @var Response + */ protected $_response; - /** @var ErrorProcessor */ + /** + * @var ErrorProcessor + */ protected $_errorProcessor; - /** @var \Magento\Framework\App\State */ - protected $_appState; - - /** @var \Magento\Framework\View\LayoutInterface */ + /** + * @var \Magento\Framework\View\LayoutInterface + */ protected $_layout; /** @@ -132,9 +141,6 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface $this->areaList->getArea($this->_appState->getAreaCode()) ->load(\Magento\Framework\App\Area::PART_TRANSLATE); try { - if (!$this->_appState->isInstalled()) { - throw new WebapiException(__('Magento is not yet installed')); - } if ($this->_isWsdlRequest()) { $responseBody = $this->_wsdlGenerator->generate( $this->_request->getRequestedServices(), diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php index f7fb7f1c4ac..d6a84c81e96 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php @@ -110,6 +110,9 @@ class Handler } $isAllowed = false; + $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] = array_values( + $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES][0] + ); foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resource) { if ($this->_authorization->isAllowed($resource)) { $isAllowed = true; @@ -121,7 +124,7 @@ class Handler // TODO: Consider passing Integration ID instead of Consumer ID throw new AuthorizationException( AuthorizationException::NOT_AUTHORIZED, - ['resources' => implode($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES], ', ')] + ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])] ); } $service = $this->_objectManager->get($serviceClass); @@ -142,7 +145,7 @@ class Handler { /** SoapServer wraps parameters into array. Thus this wrapping should be removed to get access to parameters. */ $arguments = reset($arguments); - $arguments = $this->_dataObjectConverter->convertStdObjectToArray($arguments); + $arguments = $this->_dataObjectConverter->convertStdObjectToArray($arguments, true); return $this->_serializer->getInputData($serviceClass, $serviceMethod, $arguments); } @@ -155,13 +158,16 @@ class Handler */ protected function _prepareResponseData($data) { + $result = null; if ($data instanceof AbstractSimpleObject) { $result = $this->_dataObjectConverter->convertKeysToCamelCase($data->__toArray()); } elseif (is_array($data)) { foreach ($data as $key => $value) { - $result[$key] = $value instanceof AbstractSimpleObject - ? $this->_dataObjectConverter->convertKeysToCamelCase($value->__toArray()) - : $value; + if ($value instanceof AbstractSimpleObject) { + $result[] = $this->_dataObjectConverter->convertKeysToCamelCase($value->__toArray()); + } else { + $result[$key] = $value; + } } } elseif (is_scalar($data) || is_null($data)) { $result = $data; diff --git a/app/code/Magento/Webapi/Model/PathProcessor.php b/app/code/Magento/Webapi/Model/PathProcessor.php index fcf0a9aeae4..0586867a6d5 100644 --- a/app/code/Magento/Webapi/Model/PathProcessor.php +++ b/app/code/Magento/Webapi/Model/PathProcessor.php @@ -29,14 +29,14 @@ use Magento\Framework\Exception\NoSuchEntityException; class PathProcessor { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ private $storeManager; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->storeManager = $storeManager; } diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php index a12bcc43cc2..750cfef9b62 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server.php +++ b/app/code/Magento/Webapi/Model/Soap/Server.php @@ -57,7 +57,7 @@ class Server /** @var \Magento\Webapi\Controller\Soap\Request */ protected $_request; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ @@ -78,7 +78,7 @@ class Server * @param \Magento\Framework\Config\ScopeInterface $configScope * @param \Magento\Webapi\Controller\Soap\Request $request * @param \Magento\Framework\DomDocument\Factory $domDocumentFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -89,7 +89,7 @@ class Server \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Webapi\Controller\Soap\Request $request, \Magento\Framework\DomDocument\Factory $domDocumentFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory, \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php index 65a822617d9..0b68461418b 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php @@ -62,7 +62,7 @@ class Generator protected $_registeredTypes = array(); /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -73,14 +73,14 @@ class Generator * @param Factory $wsdlFactory * @param \Magento\Webapi\Model\Cache\Type $cache * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Webapi\Model\Soap\Config $apiConfig, Factory $wsdlFactory, \Magento\Webapi\Model\Cache\Type $cache, \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_apiConfig = $apiConfig; $this->_wsdlFactory = $wsdlFactory; diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 274878dce63..ea3af99e71e 100644 --- a/app/code/Magento/Webapi/composer.json +++ b/app/code/Magento/Webapi/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-authorization": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-integration": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-user": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-authorization": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-integration": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-user": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml index 531736c376f..df47064738d 100644 --- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml @@ -30,11 +30,6 @@ <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"> diff --git a/app/code/Magento/Weee/Helper/Data.php b/app/code/Magento/Weee/Helper/Data.php index 0de6a7aa9ea..dc5afada3fe 100644 --- a/app/code/Magento/Weee/Helper/Data.php +++ b/app/code/Magento/Weee/Helper/Data.php @@ -61,13 +61,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_weeeConfig; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Weee\Model\Tax $weeeTax * @param \Magento\Weee\Model\Config $weeeConfig * @param \Magento\Tax\Helper\Data $taxData @@ -75,7 +75,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Weee\Model\Tax $weeeTax, \Magento\Weee\Model\Config $weeeConfig, \Magento\Tax\Helper\Data $taxData, diff --git a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php index 4d25426bf2d..fe7afcf1f81 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -33,7 +33,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price protected $_attributeTax; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -45,7 +45,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price /** * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Directory\Helper\Data $directoryHelper @@ -54,7 +54,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price public function __construct( \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Directory\Helper\Data $directoryHelper, diff --git a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php index e0cf8e9cc18..a94a900ffc0 100644 --- a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php @@ -31,17 +31,17 @@ namespace Magento\Weee\Model\Resource\Attribute\Backend\Weee; class Tax extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; /** * @param \Magento\Framework\App\Resource $resource - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\App\Resource $resource, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; parent::__construct($resource); diff --git a/app/code/Magento/Weee/Model/Tax.php b/app/code/Magento/Weee/Model/Tax.php index 78a5959b02b..cd2f168d5e5 100644 --- a/app/code/Magento/Weee/Model/Tax.php +++ b/app/code/Magento/Weee/Model/Tax.php @@ -73,7 +73,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel protected $_attributeFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -103,7 +103,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Tax\Model\CalculationFactory $calculationFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Tax\Helper\Data $taxData @@ -117,7 +117,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Tax\Model\CalculationFactory $calculationFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Tax\Helper\Data $taxData, diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index 08b213277a3..52b372e515a 100644 --- a/app/code/Magento/Weee/composer.json +++ b/app/code/Magento/Weee/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-tax": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-directory": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-eav": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-tax": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-directory": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-eav": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/Model/Template/Filter.php b/app/code/Magento/Widget/Model/Template/Filter.php index cf69ae091fa..000df5615db 100644 --- a/app/code/Magento/Widget/Model/Template/Filter.php +++ b/app/code/Magento/Widget/Model/Template/Filter.php @@ -45,7 +45,7 @@ class Filter extends \Magento\Cms\Model\Template\Filter * @param \Magento\Framework\View\Asset\Repository $assetRepo * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Core\Model\VariableFactory $coreVariableFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\View\LayoutInterface $layout * @param \Magento\Framework\View\LayoutFactory $layoutFactory * @param \Magento\Framework\App\State $appState @@ -60,7 +60,7 @@ class Filter extends \Magento\Cms\Model\Template\Filter \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Core\Model\VariableFactory $coreVariableFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\App\State $appState, diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index af2ee26b991..786d83ac569 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-cms": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-cms": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php index 196242e3f4c..591cae51aa3 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Send.php +++ b/app/code/Magento/Wishlist/Controller/Index/Send.php @@ -177,7 +177,7 @@ class Send extends Action\Action implements IndexInterface try { $scopeConfig = $this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'); - $storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); foreach ($emails as $email) { $transport = $this->_transportBuilder->setTemplateIdentifier( $scopeConfig->getValue( diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index 9e3b36d7ac7..796882bfbb0 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -102,7 +102,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_wishlistFactory; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -128,7 +128,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param WishlistProviderInterface $wishlistProvider @@ -140,7 +140,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, WishlistProviderInterface $wishlistProvider diff --git a/app/code/Magento/Wishlist/Helper/Rss.php b/app/code/Magento/Wishlist/Helper/Rss.php index 5ebeb5e9bae..28a18f60e86 100644 --- a/app/code/Magento/Wishlist/Helper/Rss.php +++ b/app/code/Magento/Wishlist/Helper/Rss.php @@ -43,7 +43,7 @@ class Rss extends \Magento\Wishlist\Helper\Data * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Customer\Helper\View $customerViewHelper * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider @@ -56,7 +56,7 @@ class Rss extends \Magento\Wishlist\Helper\Data \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider, diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index e10f40ee9ed..070ca460a74 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -101,7 +101,7 @@ class Item extends AbstractModel implements ItemInterface protected $_flagOptionsSaved = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -138,7 +138,7 @@ class Item extends AbstractModel implements ItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl @@ -152,7 +152,7 @@ class Item extends AbstractModel implements ItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, diff --git a/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php b/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php index 69d35a90fb0..3f7663f3b98 100644 --- a/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php +++ b/app/code/Magento/Wishlist/Model/LocaleQuantityProcessor.php @@ -32,17 +32,20 @@ class LocaleQuantityProcessor protected $localeResolver; /** - * @var \Zend_Filter_LocalizedToNormalized + * @var \Magento\Framework\Filter\LocalizedToNormalized */ protected $localFilter; /** * @param \Magento\Framework\Locale\ResolverInterface $localeResolver + * @param \Magento\Framework\Filter\LocalizedToNormalized $localFilter */ public function __construct( - \Magento\Framework\Locale\ResolverInterface $localeResolver + \Magento\Framework\Locale\ResolverInterface $localeResolver, + \Magento\Framework\Filter\LocalizedToNormalized $localFilter ) { $this->localeResolver = $localeResolver; + $this->localFilter = $localFilter; } /** @@ -53,11 +56,7 @@ class LocaleQuantityProcessor */ public function process($qty) { - if (!$this->localFilter) { - $this->localFilter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->localeResolver->getLocaleCode()) - ); - } + $this->localFilter->setOptions(array('locale' => $this->localeResolver->getLocaleCode())); $qty = $this->localFilter->filter((double)$qty); if ($qty < 0) { $qty = null; diff --git a/app/code/Magento/Wishlist/Model/Observer.php b/app/code/Magento/Wishlist/Model/Observer.php index 28371051459..8c07bb5488a 100644 --- a/app/code/Magento/Wishlist/Model/Observer.php +++ b/app/code/Magento/Wishlist/Model/Observer.php @@ -29,7 +29,7 @@ */ namespace Magento\Wishlist\Model; -class Observer extends \Magento\Framework\Model\AbstractModel +class Observer { /** * Wishlist data @@ -59,35 +59,24 @@ class Observer extends \Magento\Framework\Model\AbstractModel protected $messageManager; /** - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry * @param \Magento\Wishlist\Helper\Data $wishlistData * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession * @param WishlistFactory $wishlistFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager - * @param \Magento\Framework\Model\Resource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param array $data */ public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, \Magento\Wishlist\Helper\Data $wishlistData, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, WishlistFactory $wishlistFactory, - \Magento\Framework\Message\ManagerInterface $messageManager, - \Magento\Framework\Model\Resource\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\Db $resourceCollection = null, - array $data = array() + \Magento\Framework\Message\ManagerInterface $messageManager ) { $this->_wishlistData = $wishlistData; $this->_checkoutSession = $checkoutSession; $this->_customerSession = $customerSession; $this->_wishlistFactory = $wishlistFactory; $this->messageManager = $messageManager; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** @@ -177,9 +166,8 @@ class Observer extends \Magento\Framework\Model\AbstractModel return; } - $wishlist->getItemCollection()->load(); - - foreach ($wishlist->getItemCollection() as $wishlistItem) { + $wishlists = $wishlist->getItemCollection()->load(); + foreach ($wishlists as $wishlistItem) { if ($wishlistItem->getId() == $wishlistId) { $wishlistItem->delete(); } diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php index 64f2f263c29..3b4ef483802 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php @@ -99,7 +99,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac protected $_inventoryData = null; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -155,7 +155,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -177,7 +177,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php index 13575824043..d3a8e1bf561 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php @@ -43,7 +43,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility @@ -66,7 +66,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php index f1bf6dd3ebe..fbd95168661 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Wishlist.php @@ -90,7 +90,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent protected $_catalogProduct; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -136,7 +136,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent * @param \Magento\Wishlist\Helper\Data $wishlistData * @param ResourceWishlist $resource * @param Collection $resourceCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param ItemFactory $wishlistItemFactory * @param CollectionFactory $wishlistCollectionFactory @@ -153,7 +153,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent \Magento\Wishlist\Helper\Data $wishlistData, ResourceWishlist $resource, Collection $resourceCollection, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, ItemFactory $wishlistItemFactory, CollectionFactory $wishlistCollectionFactory, @@ -185,6 +185,9 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent */ public function loadByCustomerId($customerId, $create = false) { + if (is_null($customerId)) { + return $this; + } $customerId = (int)$customerId; $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName(); $this->_getResource()->load($this, $customerId, $customerIdFieldName); @@ -297,21 +300,14 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent if ($item === null) { $storeId = $product->hasWishlistStoreId() ? $product->getWishlistStoreId() : $this->getStore()->getId(); $item = $this->_wishlistItemFactory->create(); - $item->setProductId( - $product->getId() - )->setWishlistId( - $this->getId() - )->setAddedAt( - $this->dateTime->now() - )->setStoreId( - $storeId - )->setOptions( - $product->getCustomOptions() - )->setProduct( - $product - )->setQty( - $qty - )->save(); + $item->setProductId($product->getId()); + $item->setWishlistId($this->getId()); + $item->setAddedAt($this->dateTime->now()); + $item->setStoreId($storeId); + $item->setOptions($product->getCustomOptions()); + $item->setProduct($product); + $item->setQty($qty); + $item->save(); if ($item->getId()) { $this->getItemCollection()->addItem($item); } @@ -403,7 +399,9 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent } /* @var $product \Magento\Catalog\Model\Product */ - $product = $this->_productFactory->create()->setStoreId($storeId)->load($productId); + $product = $this->_productFactory->create(); + $product->setStoreId($storeId); + $product->load($productId); if ($buyRequest instanceof \Magento\Framework\Object) { $_buyRequest = $buyRequest; @@ -649,7 +647,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent * Error message */ if (is_string($resultItem)) { - throw new \Magento\Framework\Model\Exception(__($resultItem)); + throw new Exception(__($resultItem)); } if ($resultItem->getId() != $itemId) { @@ -663,7 +661,7 @@ class Wishlist extends \Magento\Framework\Model\AbstractModel implements \Magent $resultItem->setOrigData('qty', 0); } } else { - throw new \Magento\Framework\Model\Exception(__('The product does not exist.')); + throw new Exception(__('The product does not exist.')); } return $this; } diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index 7956e7620cb..cbad874b331 100644 --- a/app/code/Magento/Wishlist/composer.json +++ b/app/code/Magento/Wishlist/composer.json @@ -3,25 +3,25 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha94", - "magento/module-customer": "0.1.0-alpha94", - "magento/module-catalog": "0.1.0-alpha94", - "magento/module-core": "0.1.0-alpha94", - "magento/module-checkout": "0.1.0-alpha94", - "magento/module-theme": "0.1.0-alpha94", - "magento/module-catalog-inventory": "0.1.0-alpha94", - "magento/module-rss": "0.1.0-alpha94", - "magento/module-backend": "0.1.0-alpha94", - "magento/module-bundle": "0.1.0-alpha94", - "magento/module-sales": "0.1.0-alpha94", - "magento/module-grouped-product": "0.1.0-alpha94", - "magento/module-configurable-product": "0.1.0-alpha94", - "magento/module-downloadable": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/module-store": "0.1.0-alpha95", + "magento/module-customer": "0.1.0-alpha95", + "magento/module-catalog": "0.1.0-alpha95", + "magento/module-core": "0.1.0-alpha95", + "magento/module-checkout": "0.1.0-alpha95", + "magento/module-theme": "0.1.0-alpha95", + "magento/module-catalog-inventory": "0.1.0-alpha95", + "magento/module-rss": "0.1.0-alpha95", + "magento/module-backend": "0.1.0-alpha95", + "magento/module-bundle": "0.1.0-alpha95", + "magento/module-sales": "0.1.0-alpha95", + "magento/module-grouped-product": "0.1.0-alpha95", + "magento/module-configurable-product": "0.1.0-alpha95", + "magento/module-downloadable": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/etc/adminhtml/di.xml b/app/code/Magento/Wishlist/etc/adminhtml/di.xml index acb985b627d..44c0a0ce75a 100644 --- a/app/code/Magento/Wishlist/etc/adminhtml/di.xml +++ b/app/code/Magento/Wishlist/etc/adminhtml/di.xml @@ -37,7 +37,6 @@ <virtualType name="Magento\Wishlist\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Wishlist\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">adminhtml</argument> </arguments> </virtualType> </config> diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml index 1bd1fde51a6..35681b33c80 100644 --- a/app/code/Magento/Wishlist/etc/frontend/di.xml +++ b/app/code/Magento/Wishlist/etc/frontend/di.xml @@ -32,14 +32,8 @@ <virtualType name="Magento\Wishlist\Model\Session" type="Magento\Framework\Session\Generic"> <arguments> <argument name="storage" xsi:type="object">Magento\Wishlist\Model\Session\Storage</argument> - <argument name="sessionName" xsi:type="string">frontend</argument> </arguments> </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="sessionName" xsi:type="string">frontend</argument> - </arguments> - </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <arguments> <argument name="secureUrlList" xsi:type="array"> diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index 1034885d4a5..711429eb7ef 100644 --- a/app/design/adminhtml/Magento/backend/composer.json +++ b/app/design/adminhtml/Magento/backend/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index a3ebe78fb61..6b53d84f0ec 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-alpha94</version> + <version>0.1.0-alpha95</version> </theme> diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 34c8a20d0f3..32dc1d66d13 100644 --- a/app/design/frontend/Magento/blank/composer.json +++ b/app/design/frontend/Magento/blank/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index 1b6d152a2cb..bce93110a1a 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-alpha94</version> + <version>0.1.0-alpha95</version> <media> <preview_image>media/preview.jpg</preview_image> </media> diff --git a/app/design/frontend/Magento/plushe/composer.json b/app/design/frontend/Magento/plushe/composer.json index 2e0afdc7d2a..ae10f5ca67e 100644 --- a/app/design/frontend/Magento/plushe/composer.json +++ b/app/design/frontend/Magento/plushe/composer.json @@ -3,12 +3,12 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/theme-frontend-blank": "0.1.0-alpha94", - "magento/framework": "0.1.0-alpha94", + "magento/theme-frontend-blank": "0.1.0-alpha95", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index e260fdaa45b..b88603c9db4 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-alpha94</version> + <version>0.1.0-alpha95</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 d799aa2be57..abefe608893 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-alpha94</version> + <version>0.1.0-alpha95</version> </theme> diff --git a/app/etc/di.xml b/app/etc/di.xml index 1d4db9faf2b..1ad347d47eb 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -29,11 +29,10 @@ <preference for="Magento\Framework\App\ResponseInterface" type="Magento\Framework\App\Response\Http" /> <preference for="Magento\Framework\App\RouterListInterface" type="Magento\Framework\App\RouterList" /> <preference for="Magento\Framework\App\FrontControllerInterface" type="Magento\Framework\App\FrontController" /> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updater" /> <preference for="Magento\Framework\App\CacheInterface" type="Magento\Framework\App\Cache\Proxy" /> <preference for="Magento\Framework\App\Cache\StateInterface" type="Magento\Framework\App\Cache\State" /> <preference for="Magento\Framework\App\Cache\TypeListInterface" type="Magento\Framework\App\Cache\TypeList" /> - <preference for="Magento\Store\Model\StoreManagerInterface" type="Magento\Store\Model\StoreManager" /> + <preference for="Magento\Framework\StoreManagerInterface" type="Magento\Store\Model\StoreManager" /> <preference for="Magento\Framework\View\DesignInterface" type="Magento\Core\Model\View\Design\Proxy" /> <preference for="Magento\Framework\View\Design\ThemeInterface" type="Magento\Core\Model\Theme" /> <preference for="Magento\Framework\View\Design\Theme\ResolverInterface" type="Magento\Core\Model\Theme\Resolver" /> @@ -79,6 +78,7 @@ <preference for="Magento\Framework\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> <preference for="Magento\Framework\Session\Config\ConfigInterface" type="Magento\Framework\Session\Config" /> <preference for="Magento\Framework\Session\SidResolverInterface" type="Magento\Framework\Session\SidResolver\Proxy" /> + <preference for="Magento\Framework\Stdlib\Cookie\CookieScopeInterface" type="\Magento\Framework\Stdlib\Cookie\CookieScope" /> <preference for="Magento\Framework\Stdlib\CookieManager" type="Magento\Framework\Stdlib\Cookie\PhpCookieManager" /> <preference for="Magento\Framework\TranslateInterface" type="Magento\Framework\Translate" /> <preference for="Magento\Framework\Config\ScopeListInterface" type="interceptionConfigScope" /> @@ -111,7 +111,6 @@ <argument name="pathInfoProcessor" xsi:type="object">Magento\Store\App\Request\PathInfoProcessor\Proxy</argument> </arguments> </type> - <preference for="Magento\Framework\Error\HandlerInterface" type="Magento\Framework\App\Error\Handler" /> <preference for="Magento\Framework\Session\SaveHandlerInterface" type="Magento\Framework\Session\SaveHandler" /> <type name="Magento\Framework\Session\SaveHandler"> <arguments> @@ -136,7 +135,7 @@ <argument name="mode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument> </arguments> </type> - <type name="Magento\Framework\Module\FrontController\Plugin\Install"> + <type name="Magento\Framework\Module\Plugin\DbStatusValidator"> <arguments> <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> </arguments> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index d31dca76915..d9943b55b49 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 e98a83a5544..02f6f7dbd8f 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 dea863bf329..d1b456a5710 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 ffbb844d2b2..481e9f18dc1 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 87ca743f70e..d11fccd5ddd 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 f1e38478260..9d356d9c589 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "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 4ae023afd5a..a7b59b219c7 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-alpha94", + "version": "0.1.0-alpha95", "require": { - "magento/framework": "0.1.0-alpha94", + "magento/framework": "0.1.0-alpha95", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 21615dc9e92..c96c089d47c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/project-community-edition", "description": "Magento project (Community Edition)", "type": "project", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { "php": "~5.4.11|~5.5.0" }, @@ -81,6 +81,7 @@ "magento/module-sitemap": "self.version", "magento/module-store": "self.version", "magento/module-tax": "self.version", + "magento/module-tax-import-export": "self.version", "magento/module-theme": "self.version", "magento/module-translation": "self.version", "magento/module-ups": "self.version", @@ -103,6 +104,7 @@ "magento/language-pt_br": "self.version", "magento/language-zh_cn": "self.version", "magento/framework": "self.version", + "magento/project-setup": "0.1.0", "zendframework/zend-eventmanager": "2.0.3", "zendframework/zend-stdlib": "2.0.3", "zendframework/zend-di": "2.0.3", diff --git a/dev/shell/indexer.php b/dev/shell/indexer.php index 54460cff8c1..41703be84e9 100644 --- a/dev/shell/indexer.php +++ b/dev/shell/indexer.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Index\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Index\App\Shell $application */ +$app = $bootstrap->createApplication('Magento\Index\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/install.php b/dev/shell/install.php index cb8406e18e2..02783cc5d09 100644 --- a/dev/shell/install.php +++ b/dev/shell/install.php @@ -22,6 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +use Magento\Framework\App\State as AppState; +use Magento\Framework\App\Bootstrap; + /** * Parse command line arguments */ @@ -48,13 +51,7 @@ if (empty($args)) { foreach ($detailedOptions as $option) { echo ' php -f ' . $_SERVER['argv'][0] . ' -- --' . $option . PHP_EOL; } - echo <<<INSTALLSCHEME -Installation scheme: - php -f {$_SERVER['argv'][0]} -- [--<install_option_name> "<option_value>" ...] -Uninstallation: - php -f {$_SERVER['argv'][0]} -- --uninstall - -INSTALLSCHEME; + echo "php -f {$_SERVER['argv'][0]} -- [--<install_option_name> \"<option_value>\" ...]\n"; $exampleOptions = array( 'license_agreement_accepted' => 'yes', @@ -74,7 +71,8 @@ INSTALLSCHEME; 'admin_password' => '1234qasd', 'use_secure' => 'no', 'secure_base_url' => '"https://magento.local"', - 'cleanup_database' => '' + 'cleanup_database' => '', + 'bootstrap' => '{"extra":{"key":"value"}}', ); echo 'Example of installation:' . PHP_EOL; echo ' php -f ' . $_SERVER['argv'][0] . ' --'; @@ -89,12 +87,21 @@ INSTALLSCHEME; exit(1); } -define('BARE_BOOTSTRAP', 1); -require_once __DIR__ . '/../../app/bootstrap.php'; - -$_SERVER[\Magento\Framework\App\State::PARAM_MODE] = isset($_SERVER[\Magento\Framework\App\State::PARAM_MODE]) - ? $_SERVER[\Magento\Framework\App\State::PARAM_MODE] - : \Magento\Framework\App\State::MODE_DEVELOPER; +require __DIR__ . '/../../app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Install\App\Console', array('arguments' => $args)); +$params = $_SERVER; +$params[Bootstrap::PARAM_REQUIRE_IS_INSTALLED] = false; +if (!isset($params[AppState::PARAM_MODE])) { + $params[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +if (isset($args['bootstrap'])) { + $extra = json_decode($args['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Install\App\Console $app */ +$app = $bootstrap->createApplication('Magento\Install\App\Console', ['arguments' => $args]); +$bootstrap->run($app); diff --git a/dev/shell/log.php b/dev/shell/log.php index da6fb049b27..4642107aa82 100644 --- a/dev/shell/log.php +++ b/dev/shell/log.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Log\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Log\App\Shell $app */ +$app = $bootstrap->createApplication('Magento\Log\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/maintenance.php b/dev/shell/maintenance.php new file mode 100644 index 00000000000..ce0c850cc8e --- /dev/null +++ b/dev/shell/maintenance.php @@ -0,0 +1,77 @@ +<?php +/** + * Maintenance mode tool + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +define( + 'USAGE', + "Usage: php -f maintenance.php -- [--set=1|0] [--addresses=127.0.0.1,...|none'] [--bootstrap=<json>] + --set - enable or disable maintenance mode + --addresses - list of allowed IP addresses, comma-separated + --bootstrap - add or override parameters of the bootstrap\n" +); +$opt = getopt('', ['set::', 'addresses::', 'bootstrap::']); +if (empty($opt)) { + echo USAGE; +} + +require __DIR__ . '/../../app/bootstrap.php'; +try { + $params = $_SERVER; + if (isset($opt['bootstrap'])) { + $extra = json_decode($opt['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); + } + $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); + /** @var \Magento\Framework\App\MaintenanceMode $maintenance */ + $maintenance = $bootstrap->getObjectManager()->get('Magento\Framework\App\MaintenanceMode'); + if (isset($opt['set'])) { + if (1 === (int)$opt['set']) { + echo "Enabling maintenance mode...\n"; + $maintenance->set(true); + } else { + echo "Disabling maintenance mode...\n"; + $maintenance->set(false); + } + } + if (isset($opt['addresses'])) { + $addresses = ('none' == $opt['addresses']) ? '' : $opt['addresses']; + $maintenance->setAddresses($addresses); + } + echo 'Status: maintenance mode is ' . ($maintenance->isOn() ? 'active' : 'not active') . ".\n"; + $addresses = implode(', ', $maintenance->getAddressInfo()); + echo "List of exempt IP-addresses:"; + if ($addresses) { + echo " {$addresses}\n"; + } else { + echo " none.\n"; + } + exit(0); +} catch (Exception $e) { + echo $e; + exit(1); +} diff --git a/dev/shell/newindexer.php b/dev/shell/newindexer.php index 6b3f3887b2f..d3e76fa7097 100644 --- a/dev/shell/newindexer.php +++ b/dev/shell/newindexer.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require_once __DIR__ . '/../../app/bootstrap.php'; +use Magento\Framework\App\Bootstrap; use Magento\Store\Model\StoreManager; -$params = array( - StoreManager::PARAM_RUN_CODE => 'admin', - StoreManager::PARAM_RUN_TYPE => 'store' -); - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Indexer\App\Shell', array('entryFileName' => basename(__FILE__))); +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[StoreManager::PARAM_RUN_TYPE] = 'store'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var Magento\Indexer\App\Shell $app */ +$app = $bootstrap->createApplication('Magento\Indexer\App\Shell', ['entryFileName' => basename(__FILE__)]); +$bootstrap->run($app); diff --git a/dev/shell/run_data_fixtures.php b/dev/shell/run_data_fixtures.php new file mode 100644 index 00000000000..51001b2fa16 --- /dev/null +++ b/dev/shell/run_data_fixtures.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) + */ + +use Magento\Framework\App\Bootstrap; +use Magento\Framework\App\State as AppState; + +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +if (!isset($params[AppState::PARAM_MODE])) { + $extra[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\Module\Updater $updater */ +$updater = $bootstrap->getObjectManager()->create('\Magento\Framework\Module\Updater'); +$updater->updateData(); diff --git a/dev/shell/run_schema_updater.php b/dev/shell/run_schema_updater.php new file mode 100644 index 00000000000..9a329a4105f --- /dev/null +++ b/dev/shell/run_schema_updater.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) + */ + +use Magento\Framework\App\State as AppState; + +require __DIR__ . '/../../app/bootstrap.php'; +$params = $_SERVER; +$extra = []; +if (!isset($params[AppState::PARAM_MODE])) { + $extra[AppState::PARAM_MODE] = AppState::MODE_DEVELOPER; +} +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\Module\Updater $updater */ +$updater = $bootstrap->getObjectManager()->create('\Magento\Framework\Module\Updater'); +$updater->updateScheme(); diff --git a/dev/shell/uninstall.php b/dev/shell/uninstall.php new file mode 100644 index 00000000000..1d7538276ac --- /dev/null +++ b/dev/shell/uninstall.php @@ -0,0 +1,49 @@ +<?php +/** + * Uninstall utility + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +define('USAGE', "Usage: php -f uninstall.php -- [--bootstrap=<json>]\n"); +$opt = getopt('', ['bootstrap::']); + +require __DIR__ . '/../../app/bootstrap.php'; +try { + $params = $_SERVER; + if (isset($opt['bootstrap'])) { + $extra = json_decode($opt['bootstrap'], true); + if (!is_array($extra)) { + throw new \Exception("Unable to decode JSON in the parameter 'bootstrap'"); + } + $params = array_replace_recursive($params, $extra); + } + $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); + $log = new \Zend_Log(new \Zend_Log_Writer_Stream('php://stdout')); + /** @var \Magento\Install\Model\Uninstaller $uninstall */ + $uninstall = $bootstrap->getObjectManager()->create('\Magento\Install\Model\Uninstaller', ['log' => $log]); + $uninstall->uninstall(); + exit(0); +} catch (\Exception $e) { + echo $e; + exit(1); +} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php deleted file mode 100644 index 618124ef1d8..00000000000 --- a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectElement.php +++ /dev/null @@ -1,73 +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 Mtf\Client\Driver\Selenium\Element; - -use Mtf\Client\Driver\Selenium\Element; -use Mtf\Client\Element\Locator; - -/** - * Class LiselectElement - * Typified element class for lists selectors - * - */ -class LiselectElement extends Element -{ - /** - * Template for each element of option - * - * @var string - */ - protected $optionMaskElement = 'li[*[contains(text(), "%s")]]'; - - /** - * Additional part for each child element of option - * - * @var string - */ - protected $optionMaskFollowing = '/following-sibling::'; - - /** - * Select value in liselect dropdown - * - * @param array $value - * @throws \Exception - */ - public function setValue($value) - { - $this->_context->find('.toggle', Locator::SELECTOR_CSS)->click(); - - $optionSelector = array(); - foreach ($value as $key => $option) { - $optionSelector[] = sprintf($this->optionMaskElement, $value[$key]); - } - $optionSelector = './/' . implode($this->optionMaskFollowing, $optionSelector) . '/a'; - - $option = $this->_context->find($optionSelector, Locator::SELECTOR_XPATH); - if (!$option->isVisible()) { - throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); - } - $option->click(); - } -} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php new file mode 100644 index 00000000000..890f157acb8 --- /dev/null +++ b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/LiselectstoreElement.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Mtf\Client\Driver\Selenium\Element; + +use Mtf\Client\Driver\Selenium\Element; +use Mtf\Client\Element\Locator; + +/** + * Class LiselectstoreElement + * Typified element class for lists selectors + */ +class LiselectstoreElement extends Element +{ + /** + * Template for each element of option + * + * @var string + */ + protected $optionMaskElement = 'li[*[contains(text(), "%s")]]'; + + /** + * Additional part for each child element of option + * + * @var string + */ + protected $optionMaskFollowing = '/following-sibling::'; + + /** + * Website selector + * + * @var string + */ + protected $websiteSelector = '(.//li[a[@data-role="website-id"]])[%d]'; + + /** + * Store selector + * + * @var string + */ + protected $storeSelector = '(.//li[@class = "store-switcher-store disabled"])[%d]'; + + /** + * StoreView selector + * + * @var string + */ + protected $storeViewSelector = './/li[a[@data-role="store-view-id"]]'; + + /** + * Toggle element selector + * + * @var string + */ + protected $toggleSelector = '.toggle'; + + /** + * Select value in liselect dropdown + * + * @param string $value + * @throws \Exception + */ + public function setValue($value) + { + $this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); + $this->_context->find($this->toggleSelector)->click(); + + $value = explode('/', $value); + $optionSelector = []; + foreach ($value as $key => $option) { + $optionSelector[] = sprintf($this->optionMaskElement, $value[$key]); + } + $optionSelector = './/' . implode($this->optionMaskFollowing, $optionSelector) . '/a'; + + $option = $this->_context->find($optionSelector, Locator::SELECTOR_XPATH); + if (!$option->isVisible()) { + throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); + } + $option->click(); + } + + /** + * Get all li elements from dropdown + * + * @return array + */ + protected function getLiElements() + { + $this->_context->find($this->toggleSelector)->click(); + $criteria = new \PHPUnit_Extensions_Selenium2TestCase_ElementCriteria('css selector'); + $criteria->value('li'); + $elements = $this->_getWrappedElement()->elements($criteria); + $dropdownData = []; + foreach ($elements as $element) { + $class = $element->attribute('class'); + $dropdownData[] = [ + 'element' => $element, + 'storeView' => $this->isSubstring($class, "store-switcher-store-view"), + 'store' => $this->isSubstring($class, "store-switcher-store "), + 'website' => $this->isSubstring($class, "store-switcher-website"), + 'current' => $this->isSubstring($class, "current"), + 'default_config' => $this->isSubstring($class, "store-switcher-all"), + ]; + } + return $dropdownData; + } + + /** + * Get all available store views + * + * @return array + */ + public function getValues() + { + $dropdownData = $this->getLiElements(); + $data = []; + foreach ($dropdownData as $key => $dropdownElement) { + if ($dropdownElement['storeView']) { + $data[] = $this->findNearestElement('website', $key, $dropdownData) . "/" + . $this->findNearestElement('store', $key, $dropdownData) . "/" + . $dropdownElement['element']->text(); + } + } + return $data; + } + + /** + * Check if string contains substring + * + * @param string $haystack + * @param string $pattern + * @return bool + */ + protected function isSubstring($haystack, $pattern) + { + return preg_match("/$pattern/", $haystack) != 0 ? true : false; + } + + /** + * Return nearest elements name according to criteria + * + * @param string $criteria + * @param string $key + * @param array $elements + * @return bool + */ + protected function findNearestElement($criteria, $key, array $elements) + { + $elementText = false; + while ($elementText == false) { + $elementText = $elements[$key][$criteria] == true ? $elements[$key]['element']->text() : false; + $key--; + } + return $elementText; + } + + /** + * Get selected store value + * + * @throws \Exception + * @return string + */ + public function getValue() + { + $this->_eventManager->dispatchEvent(['get_value'], [(string)$this->_locator]); + $elements = $this->getLiElements(); + foreach ($elements as $key => $element) { + if ($element['current'] == true) { + if ($element['default_config'] == true) { + return $element['element']->text(); + } + $path = $this->findNearestElement('website', $key, $elements) . "/" + . $this->findNearestElement('store', $key, $elements) . "/" + . $element['element']->text(); + return $path; + } + } + } +} diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php index a1d02810894..250347eacd0 100755 --- a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php +++ b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php @@ -45,7 +45,7 @@ class SuggestElement extends Element * * @var string */ - protected $searchResult = '.mage-suggest-dropdown > ul'; + protected $searchResult = '.mage-suggest-dropdown'; /** * Selector item of search result @@ -96,4 +96,22 @@ class SuggestElement extends Element return $this->find($this->suggest)->getValue(); } + + /** + * Checking exist value in search result + * + * @param string $value + * @return bool + */ + public function isExistValueInSearchResult($value) + { + $searchResult = $this->find($this->searchResult); + + $this->find($this->suggest)->setValue($value); + $this->waitResult(); + if (!$searchResult->isVisible()) { + return false; + } + return $searchResult->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH)->isVisible(); + } } diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php b/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php index 1ffd322e725..3ff33762419 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php +++ b/dev/tests/functional/lib/Mtf/Util/Generate/Factory.php @@ -25,6 +25,7 @@ namespace Mtf\Util\Generate; use Magento\Framework\ObjectManager; +use Magento\Framework\App; /** * Class Factory diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php b/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php index 264557871c3..cc2b06011c8 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php +++ b/dev/tests/functional/lib/Mtf/Util/Generate/TestCase.php @@ -25,6 +25,7 @@ namespace Mtf\Util\Generate; use Mtf\Util\Protocol\CurlInterface; use Mtf\Util\Protocol\CurlTransport; +use Magento\Framework\App; /** * Class TestCaseClass diff --git a/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml b/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml index b82b9673628..e98ae08401e 100644 --- a/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml +++ b/dev/tests/functional/lib/Mtf/Util/Generate/testcase.xml @@ -24,93 +24,93 @@ */ --> <testcases> - <testcase module="Magento\Tax"> - <id>MTA-120</id> - <ticketId>MTA-120</ticketId> - <name>CreateTaxRateEntityTest</name> - <description>Test Creation for CreateTaxRateEntity</description> - <module>Tax</module> - <components> - <component>Tax (CS)</component> - </components> - <steps> - <step/> - <step>Steps:</step> - <step>Log in as default admin user.</step> - <step>Go to Stores > Taxes > Tax Zones and Rates.</step> - <step>Click 'Add New Tax Rate' button.</step> - <step>Fill in data according to dataSet</step> - <step>Save Tax Rate.</step> - <step>Perform all assertions.</step> - </steps> - </testcase> - <testcase> - <id>MTA-128</id> - <ticketId>MTA-128</ticketId> - <name>SuggestSearchingResult(SearchEntity)WithFucntionalTestsDesignedForAutomationTest</name> - <description>Cover Suggest Searching Result (SearchEntity) with fucntional tests designed for automation</description> - <module>Search</module> - <components> - <component>Search Frontend (CS)</component> - </components> - <steps/> - </testcase> - <testcase> - <id>MTA-15</id> - <ticketId>MTA-15</ticketId> - <name>CreateDownloadableProductEntityTest</name> - <description>Test Creation for Create DownloadableProductEntity </description> - <module>Catalog</module> - <components> - <component>Downloadable Product (CS)</component> - </components> - <steps> - <step>Log in to Backend.</step> - <step>Navigate to Products > Catalog.</step> - <step>Start to create new Downloadable product.</step> - <step>Fill in data according to data set.</step> - <step>Fill Downloadable Information tab according to data set.</step> - <step>Save product.</step> - <step>Verify created product.</step> - </steps> - </testcase> - <testcase> - <id>MTA-93</id> - <ticketId>MTA-93</ticketId> - <name>AdvancedSearchEntityTest</name> - <description>Test Creation for AdvancedSearchEntity</description> - <module>CatalogSearch</module> - <components> - <component>Search Frontend (MX)</component> - </components> - <steps> - <step/> - <step>Preconditions:</step> - <step> Two specific simple product is created(unique sku,name,short/full description, tax class)</step> - <step/> - <step>Steps</step> - <step>Navigate to Frontend</step> - <step>Click "Advanced Search"</step> - <step>Fill test data in to field(s)</step> - <step>Click "Search" button</step> - <step>Perform all asserts</step> - </steps> - </testcase> - <testcase> - <id>MTA-129</id> - <ticketId>MTA-129</ticketId> - <name>SearchEntityResultsTest</name> - <description>Test Creation for SearchEntity results</description> - <module>Search</module> - <components> - <component>Search Frontend (MX)</component> - </components> - <step>Preconditions:</step> - <step>1. All product types are created.</step> - <step/> - <step>Steps:</step> - <step>1. Navigate to frontend on index page.</step> - <step>2. Input test data into "search field" and press Enter key.</step> - <step>3. Perform all assertions.</step> - </testcase> + <testcase module="Magento\Tax"> + <id>MTA-120</id> + <ticketId>MTA-120</ticketId> + <name>CreateTaxRateEntityTest</name> + <description>Test Creation for CreateTaxRateEntity</description> + <module>Tax</module> + <components> + <component>Tax (CS)</component> + </components> + <steps> + <step/> + <step>Steps:</step> + <step>Log in as default admin user.</step> + <step>Go to Stores > Taxes > Tax Zones and Rates.</step> + <step>Click 'Add New Tax Rate' button.</step> + <step>Fill in data according to dataSet</step> + <step>Save Tax Rate.</step> + <step>Perform all assertions.</step> + </steps> + </testcase> + <testcase> + <id>MTA-128</id> + <ticketId>MTA-128</ticketId> + <name>SuggestSearchingResult(SearchEntity)WithFucntionalTestsDesignedForAutomationTest</name> + <description>Cover Suggest Searching Result (SearchEntity) with fucntional tests designed for automation</description> + <module>Search</module> + <components> + <component>Search Frontend (CS)</component> + </components> + <steps/> + </testcase> + <testcase> + <id>MTA-15</id> + <ticketId>MTA-15</ticketId> + <name>CreateDownloadableProductEntityTest</name> + <description>Test Creation for Create DownloadableProductEntity </description> + <module>Catalog</module> + <components> + <component>Downloadable Product (CS)</component> + </components> + <steps> + <step>Log in to Backend.</step> + <step>Navigate to Products > Catalog.</step> + <step>Start to create new Downloadable product.</step> + <step>Fill in data according to data set.</step> + <step>Fill Downloadable Information tab according to data set.</step> + <step>Save product.</step> + <step>Verify created product.</step> + </steps> + </testcase> + <testcase> + <id>MTA-93</id> + <ticketId>MTA-93</ticketId> + <name>AdvancedSearchEntityTest</name> + <description>Test Creation for AdvancedSearchEntity</description> + <module>CatalogSearch</module> + <components> + <component>Search Frontend (MX)</component> + </components> + <steps> + <step/> + <step>Preconditions:</step> + <step> Two specific simple product is created(unique sku,name,short/full description, tax class)</step> + <step/> + <step>Steps</step> + <step>Navigate to Frontend</step> + <step>Click "Advanced Search"</step> + <step>Fill test data in to field(s)</step> + <step>Click "Search" button</step> + <step>Perform all asserts</step> + </steps> + </testcase> + <testcase> + <id>MTA-129</id> + <ticketId>MTA-129</ticketId> + <name>SearchEntityResultsTest</name> + <description>Test Creation for SearchEntity results</description> + <module>Search</module> + <components> + <component>Search Frontend (MX)</component> + </components> + <step>Preconditions:</step> + <step>1. All product types are created.</step> + <step/> + <step>Steps:</step> + <step>1. Navigate to frontend on index page.</step> + <step>2. Input test data into "search field" and press Enter key.</step> + <step>3. Perform all assertions.</step> + </testcase> </testcases> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php index 1c31480dba1..3c726bbcdec 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php @@ -28,6 +28,7 @@ namespace Magento\Backend\Test\Block\System\Config; use Mtf\Client\Element\Locator; use Magento\Backend\Test\Block\FormPageActions as AbstractPageActions; +use Magento\Store\Test\Fixture\Store; /** * Class PageActions @@ -45,14 +46,28 @@ class PageActions extends AbstractPageActions /** * Select store * - * @param array $websiteScope + * @param string $websiteScope * @return $this */ public function selectStore($websiteScope) { - $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselect')->setValue($websiteScope); + $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') + ->setValue($websiteScope); $this->_rootElement->acceptAlert(); return $this; } + + /** + * Check if store visible in scope dropdown + * + * @param Store $store + * @return bool + */ + public function isStoreVisible($store) + { + $storeViews = $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') + ->getValues(); + return in_array($store->getGroupId() . "/" . $store->getName(), $storeViews); + } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php index 7d06c49614f..b04cda9434b 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/GroupForm.php @@ -25,6 +25,7 @@ namespace Magento\Backend\Test\Block\System\Store\Edit\Form; use Mtf\Block\Form; +use Mtf\Client\Element\Locator; /** * Class GroupForm @@ -32,5 +33,21 @@ use Mtf\Block\Form; */ class GroupForm extends Form { - // + /** + * Website name selector in dropdown + * + * @var string + */ + protected $website = '//option[contains(.,"%s")]'; + + /** + * Check that Website visible in Website dropdown + * + * @param string $websiteName + * @return bool + */ + public function isWebsiteVisible($websiteName) + { + return $this->_rootElement->find(sprintf($this->website, $websiteName), Locator::SELECTOR_XPATH)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml index 6991d725b4d..74c12972435 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.xml @@ -27,8 +27,10 @@ <wrapper>store</wrapper> <fields> <group_id> - <input>select</input> + <input>optgroupselect</input> </group_id> + <name /> + <code /> <is_active> <input>select</input> </is_active> diff --git a/lib/internal/Magento/Framework/Session/SessionConsole.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php similarity index 83% rename from lib/internal/Magento/Framework/Session/SessionConsole.php rename to dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php index 24788222a00..e84495e9e3b 100644 --- a/lib/internal/Magento/Framework/Session/SessionConsole.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.php @@ -21,15 +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\Framework\Session; -class SessionConsole extends Generic -{ - /** - * Empty constructor to prevent session start - */ - public function __construct() - { +namespace Magento\Backend\Test\Block\System\Store\Edit\Form; + +use Mtf\Block\Form; - } +/** + * Class WebsiteForm + * Form for Website creation + */ +class WebsiteForm extends Form +{ + // } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml similarity index 85% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml rename to dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml index 211a7cc5252..14bebd283b1 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/WebsiteForm.xml @@ -24,10 +24,13 @@ */ --> <mapping strict="0"> + <wrapper>website</wrapper> <fields> - <display> - <selector>td [name$='associated_product_ids[]']</selector> - <input>checkbox</input> - </display> + <name /> + <code /> + <sort_order /> + <default_group_id> + <input>select</input> + </default_group_id> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php index e3a0a7229d9..b47ca9bce55 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/StoreGrid.php @@ -26,6 +26,8 @@ namespace Magento\Backend\Test\Block\System\Store; use Mtf\Client\Element\Locator; use Magento\Store\Test\Fixture\StoreGroup; +use Magento\Store\Test\Fixture\Website; +use Magento\Store\Test\Fixture\Store; use Magento\Backend\Test\Block\Widget\Grid as GridInterface; /** @@ -52,6 +54,9 @@ class StoreGrid extends GridInterface ], 'group_title' => [ 'selector' => '#storeGrid_filter_group_title' + ], + 'website_title' => [ + 'selector' => '#storeGrid_filter_website_title' ] ]; @@ -82,26 +87,53 @@ class StoreGrid extends GridInterface } /** - * Click to appropriate store in Store grid for edit + * Check if website exists + * + * @param Website $website + * @return bool + */ + public function isWebsiteExists($website) + { + return $this->_rootElement->find(sprintf($this->titleFormat, $website->getName()), Locator::SELECTOR_XPATH) + ->isVisible(); + } + + /** + * Search and open appropriate Website + * + * @param Website $website + * @return void + */ + public function searchAndOpenWebsite(Website $website) + { + $websiteName = $website->getName(); + $this->search(['website_title' => $websiteName]); + $this->_rootElement->find(sprintf($this->storeName, $websiteName), Locator::SELECTOR_XPATH)->click(); + } + + /** + * Search and open appropriate Store View * - * @param string $name + * @param Store $store * @return void */ - public function editStore($name) + public function searchAndOpenStore(Store $store) { - $this->_rootElement->find(sprintf($this->storeName, $name), Locator::SELECTOR_XPATH)->click(); + $storeName = $store->getName(); + $this->search(['store_title' => $storeName]); + $this->_rootElement->find(sprintf($this->storeName, $storeName), Locator::SELECTOR_XPATH)->click(); } /** - * Search and open appropriate store + * Search and open appropriate Store * * @param StoreGroup $storeGroup * @return void */ - public function searchAndOpenStore(StoreGroup $storeGroup) + public function searchAndOpenStoreGroup(StoreGroup $storeGroup) { - $storeName = $storeGroup->getName(); - $this->search(['group_title' => $storeName]); - $this->editStore($storeName); + $storeGroupName = $storeGroup->getName(); + $this->search(['group_title' => $storeGroupName]); + $this->_rootElement->find(sprintf($this->storeName, $storeGroupName), Locator::SELECTOR_XPATH)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php old mode 100644 new mode 100755 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 9df2043bbad..c65e426bbd4 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 @@ -144,11 +144,11 @@ abstract class Grid extends Block protected $waitForSelectorVisible = true; /** - * Selector for status select + * Selector for action option select * * @var string */ - protected $status = '[name="status"]'; + protected $option = '[name="status"]'; /** * Get backend abstract block @@ -283,7 +283,7 @@ abstract class Grid extends Block $actionType = key($action); $this->_rootElement->find($this->massactionSelect, Locator::SELECTOR_CSS, 'select')->setValue($actionType); if (isset($action[$actionType]) && $action[$actionType] != '-') { - $this->_rootElement->find($this->status, Locator::SELECTOR_CSS, 'select')->setValue($action[$actionType]); + $this->_rootElement->find($this->option, Locator::SELECTOR_CSS, 'select')->setValue($action[$actionType]); } $this->massActionSubmit($acceptAlert); } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Dashboard.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/Dashboard.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Backend/Test/Page/Dashboard.xml rename to dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/Dashboard.xml diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml new file mode 100644 index 00000000000..41c456b6d02 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/DeleteWebsite.xml @@ -0,0 +1,39 @@ +<?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="system_store/deleteWebsite" module="Magento_Backend"> + <blocks> + <deleteWebsiteForm> + <class>Magento\Backend\Test\Block\System\Store\Delete\Form</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </deleteWebsiteForm> + <formPageFooterActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageFooterActions</class> + <locator>.content-footer</locator> + <strategy>css selector</strategy> + </formPageFooterActions> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml new file mode 100644 index 00000000000..eaa0aad866b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditStore.xml @@ -0,0 +1,44 @@ +<?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="admin/system_store/editStore" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <storeForm> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\StoreForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </storeForm> + <messagesBlock> + <class>Magento\Core\Test\Block\Messages</class> + <locator>#messages</locator> + <strategy>css selector</strategy> + </messagesBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml new file mode 100644 index 00000000000..ab08c0a7af4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/EditWebsite.xml @@ -0,0 +1,39 @@ +<?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="system_store/editWebsite" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <editFormWebsite> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\WebsiteForm</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </editFormWebsite> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml new file mode 100644 index 00000000000..0e5fe3b0624 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/NewWebsiteIndex.xml @@ -0,0 +1,39 @@ +<?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="system_store/newWebsite/index" module="Magento_Backend"> + <blocks> + <formPageActions> + <class>Magento\Backend\Test\Block\System\Store\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <editWebsiteForm> + <class>Magento\Backend\Test\Block\System\Store\Edit\Form\WebsiteForm</class> + <locator>#edit_form</locator> + <strategy>css selector</strategy> + </editWebsiteForm> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml index 0d41709f69e..8364e6ccc99 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/etc/page.xml @@ -24,6 +24,11 @@ */ --> <page module="Magento_Backend"> + <dashboard> + <mca>admin/dashboard</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\Dashboard</class> + </dashboard> <systemConfig> <mca>admin/system_config</mca> <area>adminhtml</area> @@ -39,6 +44,11 @@ <area>adminhtml</area> <class>Magento\Backend\Test\Page\Adminhtml\StoreNew</class> </storeNew> + <editStore> + <mca>admin/system_store/editStore</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\EditStore</class> + </editStore> <storeDelete> <mca>admin/system_store/deleteStore</mca> <area>adminhtml</area> @@ -59,4 +69,19 @@ <area>adminhtml</area> <class>Magento\Backend\Test\Page\Adminhtml\DeleteGroup</class> </deleteGroup> + <newWebsiteIndex> + <mca>system_store/newWebsite/index</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\NewWebsiteIndex</class> + </newWebsiteIndex> + <editWebsite> + <mca>system_store/editWebsite</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\EditWebsite</class> + </editWebsite> + <deleteWebsite> + <mca>system_store/deleteWebsite</mca> + <area>adminhtml</area> + <class>Magento\Backend\Test\Page\Adminhtml\DeleteWebsite</class> + </deleteWebsite> </page> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index be2d98aef7d..1dcbcaaab5b 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -25,15 +25,24 @@ namespace Magento\Bundle\Test\Block\Catalog\Product; use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Block\Product\View as ParentView; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Bundle\Test\Fixture\CatalogProductBundle; /** * Class View * Bundle product view block on the product page */ -class View extends ParentView +class View extends \Magento\Catalog\Test\Block\Product\View { + /** + * Customize and add to cart button selector + * + * @var string + */ + protected $customizeButton = '.action.primary.customize'; + /** * Bundle options block * @@ -53,4 +62,55 @@ class View extends ParentView ['element' => $this->_rootElement->find($this->bundleBlock, Locator::SELECTOR_XPATH)] ); } + + /** + * Click "Customize and add to cart button" + * + * @return void + */ + public function clickCustomize() + { + $this->_rootElement->find($this->customizeButton)->click(); + $this->waitForElementVisible($this->addToCart); + } + + /** + * Return product options + * + * @param FixtureInterface $product [optional] + * @return array + */ + public function getOptions(FixtureInterface $product = null) + { + $options = []; + + $this->clickCustomize(); + $options['bundle_options'] = $this->getBundleBlock()->getOptions($product); + $options += parent::getOptions($product); + + return $options; + } + + /** + * Fill in the option specified for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var \Magento\Bundle\Test\Fixture\CatalogProductBundle $product */ + $checkoutData = $product->getCheckoutData(); + $bundleCheckoutData = isset($checkoutData['bundle_options']) ? $checkoutData['bundle_options'] : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var \Magento\Bundle\Test\Fixture\BundleFixed $product */ + $bundleCheckoutData = $product->getSelectionData(); + } + $this->_rootElement->find($this->customizeButton)->click(); + $this->getBundleBlock()->fillBundleOptions($bundleCheckoutData); + + parent::fillOptions($product); + } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index 24d023cc122..ca9e3405628 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -25,10 +25,14 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type; use Mtf\Block\Block; +use Mtf\Client\Element; use Mtf\Client\Element\Locator; -use Magento\Bundle\Test\Fixture\CatalogProductBundle; -use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Bundle\Test\Fixture\Bundle as BundleDataFixture; +use Magento\Bundle\Test\Fixture\CatalogProductBundle; /** * Class Bundle @@ -37,85 +41,228 @@ use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; class Bundle extends Block { /** - * Bundle options block + * Selector for single option block * * @var string */ - protected $bundleBlock = './div[%d]'; + protected $optionElement = './div[contains(@class,"option")][%d]'; /** - * Label item option + * Selector for title of option * * @var string */ - protected $requiredOptions = '[%s(contains(@class,"required"))]'; + protected $title = './label/span'; /** - * Label item option + * Selector for required option * * @var string */ - protected $optionSelect = './/select/option[@value != ""][%d][contains(text(), "%s")]'; + protected $required = './self::*[contains(@class,"required")]'; /** - * Label item option + * Selector for select element of option * * @var string */ - protected $optionLabel = './/div[%d][contains(@class, "field")]//*[contains(text(), "%s")]'; + protected $selectOption = './/div[@class="control"]/select'; /** - * Selector DropDown type + * Selector for label of option value element * * @var string */ - protected $typeDropDown = './/select[contains(@class,"bundle-option-select")]'; + protected $optionLabel = './/div[@class="control"]//label[contains(@for, "options_")][%d]'; /** - * Selector Multiselect type + * Selector for option of select element * * @var string */ - protected $typeMultiple = './/select[contains(@class,"multiselect")]'; + protected $option = './/option[%d]'; /** - * Selector RadioButton type + * Selector bundle option block for fill * * @var string */ - protected $typeRadio = './/input[contains(@class,"radio")]'; + protected $bundleOptionBlock = './/div[label[span[contains(text(), "%s")]]]'; /** - * Selector Checkbox type + * Fill bundle option on frontend add click "Add to cart" button * - * @var string + * @param CatalogProductBundle $product + * @param CatalogProductView $catalogProductView + * @return void */ - protected $typeCheckbox = './/input[contains(@class,"checkbox")]'; + public function addToCart(CatalogProductBundle $product, CatalogProductView $catalogProductView) + { + $catalogProductView->getViewBlock()->fillOptions($product); + $catalogProductView->getViewBlock()->clickAddToCart(); + } /** - * Selector bundle option block for fill + * Get product options * - * @var string + * @param FixtureInterface $product + * @return array + * @throws \Exception */ - protected $bundleOptionBlock = './/div[label[span[contains(text(), "%s")]]]'; + public function getOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var CatalogProductBundle $product */ + $bundleSelections = $product->getBundleSelections(); + $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var BundleDataFixture $product */ + $bundleOptions = $product->getBundleOptions(); + } + + $listFormOptions = $this->getListOptions(); + $formOptions = []; + + foreach ($bundleOptions as $option) { + $title = $option['title']; + if (!isset($listFormOptions[$title])) { + throw new \Exception("Can't find option: \"{$title}\""); + } + + /** @var Element $optionElement */ + $optionElement = $listFormOptions[$title]; + $getTypeData = 'get' . $this->optionNameConvert($option['type']) . 'Data'; + + $optionData = $this->$getTypeData($optionElement); + $optionData['title'] = $title; + $optionData['type'] = $option['type']; + $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() + ? 'Yes' + : 'No'; + + $formOptions[] = $optionData; + } + + return $formOptions; + } /** - * Fill bundle option on frontend add click "Add to cart" button + * Get list options * - * @param CatalogProductBundle $product - * @param CatalogProductView $catalogProductView - * @return void + * @return array */ - public function addToCart(CatalogProductBundle $product, CatalogProductView $catalogProductView) + protected function getListOptions() + { + $options = []; + + $count = 1; + $optionElement = $this->_rootElement->find(sprintf($this->optionElement, $count), Locator::SELECTOR_XPATH); + while ($optionElement->isVisible()) { + $title = $optionElement->find($this->title, Locator::SELECTOR_XPATH)->getText(); + $options[$title] = $optionElement; + + ++$count; + $optionElement = $this->_rootElement->find(sprintf($this->optionElement, $count), Locator::SELECTOR_XPATH); + } + return $options; + } + + /** + * Get data of "Drop-down" option + * + * @param Element $option + * @return array + */ + protected function getDropdownData(Element $option) + { + $select = $option->find($this->selectOption, Locator::SELECTOR_XPATH, 'select'); + // Skip "Choose option ..."(option #1) + return $this->getSelectOptionsData($select, 2); + } + + /** + * Get data of "Multiple" option + * + * @param Element $option + * @return array + */ + protected function getMultipleselectData(Element $option) + { + $multiselect = $option->find($this->selectOption, Locator::SELECTOR_XPATH, 'multiselect'); + return $this->getSelectOptionsData($multiselect, 1); + } + + /** + * Get data of "Radio" option + * + * @param Element $option + * @return array + */ + protected function getRadiobuttonsData(Element $option) { - $fillData = $product->getDataFieldConfig('checkout_data')['source']->getPreset(); - if (isset($fillData['bundle_options'])) { - $this->fillBundleOptions($fillData['bundle_options']); + $listOptions = []; + + $count = 1; + $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); + while ($option->isVisible()) { + $listOptions[] = $this->parseOptionText($option->getText()); + ++$count; + $option = $option->find(sprintf($this->optionLabel, $count), Locator::SELECTOR_XPATH); } - if (isset($fillData['custom_options'])) { - $catalogProductView->getCustomOptionsBlock()->fillCustomOptions($product, $fillData['custom_options']); + + return ['options' => $listOptions]; + } + + /** + * Get data of "Checkbox" option + * + * @param Element $option + * @return array + */ + protected function getCheckboxData(Element $option) + { + return $this->getRadiobuttonsData($option); + } + + /** + * Get data from option of select and multiselect + * + * @param Element $element + * @param int $firstOption + * @return array + */ + protected function getSelectOptionsData(Element $element, $firstOption = 1) + { + $listOptions = []; + + $count = $firstOption; + $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); + while ($selectOption->isVisible()) { + $listOptions[] = $this->parseOptionText($selectOption->getText()); + ++$count; + $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); } - $catalogProductView->getViewBlock()->clickAddToCart(); + + return ['options' => $listOptions]; + } + + /** + * Parse option text to title and price + * + * @param string $optionText + * @return array + */ + protected function parseOptionText($optionText) + { + preg_match('`^(.*?)\+ ?\$(\d.*?)$`', $optionText, $match); + $optionPrice = isset($match[2]) ? str_replace(',', '', $match[2]) : 0; + $optionTitle = isset($match[1]) ? trim($match[1]) : $optionText; + + return [ + 'title' => $optionTitle, + 'price' => $optionPrice + ]; } /** @@ -138,62 +285,15 @@ class Bundle extends Block } } - /** - * Get bundle item option - * - * @param array $fields - * @param int $index - * @return bool|string - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function displayedBundleItemOption(array $fields, $index) - { - $bundleOptionBlock = $this->_rootElement->find(sprintf($this->bundleBlock, $index), Locator::SELECTOR_XPATH); - $option = $bundleOptionBlock->find( - $this->{'type' . $this->optionNameConvert($fields['type'])}, - Locator::SELECTOR_XPATH - ); - if (!$option->isVisible()) { - return '"' . $fields['title'] . '" Option does not equal to fixture option type.'; - } - - $formatRequired = sprintf( - $this->bundleBlock . $this->requiredOptions, - $index, - (($fields['required'] == 'Yes') ? '' : 'not') - ); - if (!$this->_rootElement->find($formatRequired, Locator::SELECTOR_XPATH)->isVisible()) { - return "This Option must be " . ($fields['required'] == 'Yes') ? '' : 'not' . " required."; - } - - foreach ($fields['assigned_products'] as $increment => $item) { - $isMultiAssigned = count($fields['assigned_products']) > 1; - $isSelectType = $fields['type'] == 'Drop-down' || $fields['type'] == 'Multiple Select'; - $selectOptions = $isMultiAssigned && $isSelectType ? $this->optionSelect : $this->optionLabel; - $formatOption = sprintf($selectOptions, ++$increment, $item['name']); - if (!$bundleOptionBlock->find($formatOption, Locator::SELECTOR_XPATH)->isVisible()) { - return 'SelectOption ' . $item['name'] . ' with index ' - . $increment . ' data is not equals with fixture SelectOption data.'; - } - } - return true; - } - /** * Convert option name * - * @param string $optionName + * @param string $optionType * @return string */ - protected function optionNameConvert($optionName) + protected function optionNameConvert($optionType) { - if ($end = strpos($optionName, ' ')) { - $optionName = substr($optionName, 0, $end); - } elseif ($end = strpos($optionName, '-')) { - $optionName = substr($optionName, 0, $end) . ucfirst(substr($optionName, ($end + 1))); - } - return $optionName; + $trimmedOptionType = preg_replace('/[^a-zA-Z]/', '', $optionType); + return ucfirst(strtolower($trimmedOptionType)); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php index f49b2e934e6..0e4585c1f2e 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.php @@ -27,10 +27,10 @@ namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; /** - * Class DropDown + * Class Dropdown * Bundle option drop-down type */ -class DropDown extends Option +class Dropdown extends Option { // Parent behavior } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.xml similarity index 100% rename from dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/DropDown.xml rename to dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Dropdown.xml diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php old mode 100644 new mode 100755 index 273e557f4b0..8bc169f289f --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php @@ -25,14 +25,15 @@ namespace Magento\Bundle\Test\Constraint; use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Bundle\Test\Fixture\CatalogProductBundle; use Magento\Catalog\Test\Page\Product\CatalogProductView; /** * Class AssertBundleItemsOnProductPage + * Assert that displayed product bundle items data on product page equals passed from fixture preset */ -class AssertBundleItemsOnProductPage extends AbstractConstraint +class AssertBundleItemsOnProductPage extends AbstractAssertForm { /** * Constraint severeness @@ -55,41 +56,56 @@ class AssertBundleItemsOnProductPage extends AbstractConstraint Browser $browser ) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $catalogProductView->getViewBlock()->clickCustomize(); - $result = $this->displayedBundleBlock($catalogProductView, $product); - \PHPUnit_Framework_Assert::assertTrue(empty($result), $result); + + $productOptions = $this->prepareBundleOptions($product); + $productOptions = $this->sortDataByPath($productOptions, '::title'); + foreach ($productOptions as $key => $productOption) { + $productOptions[$key] = $this->sortDataByPath($productOption, 'options::title'); + } + $formOptions = $catalogProductView->getViewBlock()->getOptions($product)['bundle_options']; + $formOptions = $this->sortDataByPath($formOptions, '::title'); + foreach ($formOptions as $key => $formOption) { + $formOptions[$key] = $this->sortDataByPath($formOption, 'options::title'); + } + + $error = $this->verifyData($productOptions, $formOptions); + \PHPUnit_Framework_Assert::assertEmpty($error, $error); } /** - * Displayed bundle block on frontend with correct fixture product + * Prepare bundle options * - * @param CatalogProductView $catalogProductView * @param CatalogProductBundle $product - * @return string|null + * @return array */ - protected function displayedBundleBlock(CatalogProductView $catalogProductView, CatalogProductBundle $product) + protected function prepareBundleOptions(CatalogProductBundle $product) { - $fields = $product->getData(); - $bundleOptions = $fields['bundle_selections']['bundle_options']; - if (!isset($bundleOptions)) { - return 'Bundle options data on product page is not equals to fixture preset.'; - } + $bundleSelections = $product->getBundleSelections(); + $bundleOptions = isset($bundleSelections['bundle_options']) ? $bundleSelections['bundle_options'] : []; + $result = []; - $catalogProductView->getViewBlock()->clickCustomize(); - foreach ($bundleOptions as $index => $item) { - foreach ($item['assigned_products'] as &$selection) { - $selection = $selection['search_data']; - } - $result = $catalogProductView->getBundleViewBlock()->getBundleBlock()->displayedBundleItemOption( - $item, - ++$index - ); + foreach ($bundleOptions as $optionKey => $bundleOption) { + $optionData = [ + 'title' => $bundleOption['title'], + 'type' => $bundleOption['type'], + 'is_require' => $bundleOption['required'], + ]; + + foreach ($bundleOption['assigned_products'] as $productKey => $assignedProduct) { + $price = isset($assignedProduct['data']['selection_price_value']) + ? $assignedProduct['data']['selection_price_value'] + : $bundleSelections['products'][$optionKey][$productKey]->getPrice(); - if ($result !== true) { - return $result; + $optionData['options'][$productKey] = [ + 'title' => $assignedProduct['search_data']['name'], + 'price' => number_format($price, 2) + ]; } + + $result[$optionKey] = $optionData; } - return null; + + return $result; } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php old mode 100644 new mode 100755 index 87997d57d38..466b2c9c085 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php @@ -95,15 +95,12 @@ class AssertBundlePriceType extends AbstractConstraint CatalogProductBundle $originalProduct = null ) { $customerGroup = 'NOT LOGGED IN'; - $catalogProductView->getViewBlock()->clickCustomize(); $bundleData = $product->getData(); $this->productPriceType = $originalProduct !== null ? $originalProduct->getPriceType() : $product->getPriceType(); - $fillData = $product->getDataFieldConfig('checkout_data')['source']->getPreset(); - $bundleBlock = $catalogProductView->getBundleViewBlock()->getBundleBlock(); - $bundleBlock->addToCart($product, $catalogProductView); - $cartBlock = $checkoutCartView->getCartBlock(); + $catalogProductView->getViewBlock()->addToCart($product); + $cartItem = $checkoutCartView->getCartBlock()->getCartItem($product); $specialPrice = 0; if (isset($bundleData['group_price'])) { $specialPrice = @@ -111,6 +108,7 @@ class AssertBundlePriceType extends AbstractConstraint } $optionPrice = []; + $fillData = $product->getCheckoutData(); foreach ($fillData['bundle_options'] as $key => $data) { $subProductPrice = 0; foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) { @@ -133,13 +131,13 @@ class AssertBundlePriceType extends AbstractConstraint $item['price'] -= $item['price'] * $specialPrice; \PHPUnit_Framework_Assert::assertEquals( number_format($item['price'], 2), - $cartBlock->getPriceBundleOptions($index + 1), + $cartItem->getPriceBundleOptions($index + 1), 'Bundle item ' . ($index + 1) . ' options on frontend don\'t equal to fixture.' ); } $sumOptionsPrice = $product->getDataFieldConfig('price')['source']->getPreset()['cart_price']; - $subTotal = number_format($cartBlock->getCartItemUnitPrice($product), 2); + $subTotal = number_format($cartItem->getPrice(), 2); \PHPUnit_Framework_Assert::assertEquals( $sumOptionsPrice, $subTotal, diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php index e6d495c55ba..8795fb22772 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php @@ -71,7 +71,7 @@ class AssertBundlePriceView extends AbstractConstraint protected function assertPrice(CatalogProductBundle $product, CatalogProductView $catalogProductView) { $priceData = $product->getDataFieldConfig('price')['source']->getPreset(); - $priceBlock = $catalogProductView->getViewBlock()->getProductPriceBlock(); + $priceBlock = $catalogProductView->getViewBlock()->getPriceBlock(); $priceLow = ($product->getPriceView() == 'Price Range') ? $priceBlock->getPriceFrom() diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php index 76880a4c015..1c93336ce9f 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductForm.php @@ -24,7 +24,6 @@ namespace Magento\Bundle\Test\Constraint; -use Mtf\Fixture\FixtureInterface; use Magento\Catalog\Test\Constraint\AssertProductForm; /** @@ -57,17 +56,16 @@ class AssertBundleProductForm extends AssertProductForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { $data['bundle_selections'] = $this->prepareBundleOptions( $data['bundle_selections']['bundle_options'] ); - return parent::prepareFixtureData($data, $product, $sortFields); + return parent::prepareFixtureData($data, $sortFields); } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php index 874df95f117..6fcb84c3a30 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php @@ -32,59 +32,26 @@ use Magento\Catalog\Test\Constraint\AssertProductPage; class AssertBundleProductPage extends AssertProductPage { /** - * Constraint severeness + * Verify displayed product price on product page(front-end) equals passed from fixture * - * @var string + * @return string|null */ - protected $severeness = 'low'; - - /** - * Error messages - * - * @var array - */ - protected $errorsMessages = [ - 'name' => '- product name on product view page is not correct.', - 'sku' => '- product sku on product view page is not correct.', - 'price_from' => '- bundle product price from on product view page is not correct.', - 'price_to' => '- bundle product price to on product view page is not correct.', - 'short_description' => '- product short description on product view page is not correct.', - 'description' => '- product description on product view page is not correct.' - ]; - - /** - * Prepare Price data - * - * @param array $price - * @return array - */ - protected function preparePrice($price) + protected function verifyPrice() { $priceData = $this->product->getDataFieldConfig('price')['source']->getPreset(); - $priceView = $this->product->getPriceView(); - if ($priceView === null || $priceView == 'Price Range') { - if (isset($price['price_from']) && isset($price['price_to'])) { - return [ - ['price_from' => $price['price_from'], 'price_to' => $price['price_to']], - [ - 'price_from' => number_format($priceData['price_from'], 2), - 'price_to' => number_format($priceData['price_to'], 2) - ] - ]; - } - return [ - ['price_regular_price' => $price['price_regular_price']], - ['price_regular_price' => number_format($priceData['price_from'], 2)] - ]; - } else { - return [ - ['price_from' => $price['price_regular_price']], - [ - 'price_from' => is_numeric($priceData['price_from']) - ? number_format($priceData['price_from'], 2) - : $priceData['price_from'] - ] - ]; + $priceBlock = $this->productView->getPriceBlock(); + $priceLow = ($this->product->getPriceView() == 'Price Range') + ? $priceBlock->getPriceFrom() + : $priceBlock->getRegularPrice(); + $errors = []; + + if ($priceData['price_from'] != $priceLow) { + $errors[] = 'Bundle price "From" on product view page is not correct.'; } + if ($this->product->getPriceView() == 'Price Range' && $priceData['price_to'] != $priceBlock->getPriceTo()) { + $errors[] = 'Bundle price "To" on product view page is not correct.'; + } + + return empty($errors) ? null : implode("\n", $errors); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php index a067d4a8fde..4d0931c789b 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertProductCustomOptionsOnBundleProductPage.php @@ -24,9 +24,6 @@ namespace Magento\Bundle\Test\Constraint; -use Mtf\Client\Browser; -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Constraint\AssertProductCustomOptionsOnProductPage; /** @@ -41,21 +38,4 @@ class AssertProductCustomOptionsOnBundleProductPage extends AssertProductCustomO * @var bool */ protected $isPrice = false; - - /** - * Open product view page - * - * @param CatalogProductView $catalogProductView - * @param FixtureInterface $product - * @param Browser $browser - * @return void - */ - protected function openProductPage( - CatalogProductView $catalogProductView, - FixtureInterface $product, - Browser $browser - ) { - $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $catalogProductView->getViewBlock()->clickCustomize(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php index a6f6acd9044..92fa8a108f0 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Bundle.php @@ -85,14 +85,21 @@ class Bundle extends Product */ public function getBundleOptions() { - $options = array(); + $options = []; $bundleOptions = $this->getData('fields/bundle_selections/value'); foreach ($bundleOptions['bundle_options'] as $optionData) { - $optionName = $optionData['title']; + $option = [ + 'title' => $optionData['title'], + 'type' => $optionData['type'], + 'options' => [] + ]; + foreach ($optionData['assigned_products'] as $productData) { - $options[$optionName][] = $productData['search_data']['name']; + $option['options'][] = ['title' => $productData['search_data']['name']]; } + $options[] = $option; } + return $options; } @@ -138,14 +145,15 @@ class Bundle extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ + 'type_id' => 'bundle', 'constraint' => 'Success', - 'create_url_params' => array( + 'create_url_params' => [ 'type' => 'bundle', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID, - ), + ], 'input_prefix' => 'product' - ); + ]; $this->_repository = Factory::getRepositoryFactory() ->getMagentoBundleBundle($this->_dataConfig, $this->_data); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php index 2b1819dab07..42d24dc006d 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.php @@ -89,6 +89,7 @@ class CatalogProductBundle extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'bundle', 'create_url_params' => [ 'type' => 'bundle', 'set' => '4', @@ -621,6 +622,7 @@ class CatalogProductBundle extends InjectableFixture 'attribute_code' => 'checkout_data', 'backend_type' => 'virtual', 'is_required' => '1', + 'group' => null, 'source' => 'Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData', ]; @@ -947,6 +949,11 @@ class CatalogProductBundle extends InjectableFixture return $this->getData('bundle_selections'); } + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } + public function getCustomOptions() { return $this->getData('custom_options'); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml index 3400eb8faf2..dbee01e0848 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle.xml @@ -431,6 +431,12 @@ <group>bundle</group> <fixture>Magento\Bundle\Test\Fixture\Bundle\BundleSelections</fixture> </bundle_selections> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <fixture>Magento\Bundle\Test\Fixture\CatalogProductBundle\CheckoutData</fixture> + </checkout_data> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php index 1485dc79402..e53658aae9a 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/CatalogProductBundle/CheckoutData.php @@ -24,23 +24,22 @@ namespace Magento\Bundle\Test\Fixture\CatalogProductBundle; -use Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData as AbstractCheckoutData; - /** * Class CheckoutData * Data keys: * - preset (Checkout data verification preset name) - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ -class CheckoutData extends AbstractCheckoutData +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData { /** * Get preset array * + * @param string $name * @return array|null + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function getPreset() + protected function getPreset($name) { $presets = [ 'default' => [ @@ -84,52 +83,52 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => [1], + 'title' => 0, + 'value' => 0, ], [ - 'option' => 2, - 'value' => [1], + 'title' => 1, + 'value' => 0, ], [ - 'option' => 3, - 'value' => ['Field'], + 'title' => 2, + 'value' => 'Field', ], [ - 'option' => 4, - 'value' => ['Field'], + 'title' => 3, + 'value' => 'Field', ], [ - 'option' => 5, - 'value' => ['Area'], + 'title' => 4, + 'value' => 'Area', ], [ - 'option' => 7, - 'value' => [1], + 'title' => 6, + 'value' => 0, ], [ - 'option' => 8, - 'value' => [1], + 'title' => 7, + 'value' => 0, ], [ - 'option' => 9, - 'value' => [1], + 'title' => 8, + 'value' => 0, ], [ - 'option' => 10, - 'value' => [1], + 'title' => 9, + 'value' => 0, ], [ - 'option' => 11, - 'value' => ['12/12/2014'], + 'title' => 10, + 'value' => '12/12/2014', ], [ - 'option' => 12, - 'value' => ['12/12/2014/12/30/AM'], + 'title' => 11, + 'value' => '12/12/2014/12/30/AM', ], [ - 'option' => 13, - 'value' => ['12/12/AM'], + 'title' => 12, + 'value' => '12/12/AM', ], ] ], @@ -145,8 +144,8 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => [1], + 'title' => 0, + 'value' => 0, ], ] ], @@ -183,40 +182,40 @@ class CheckoutData extends AbstractCheckoutData ], 'custom_options' => [ [ - 'option' => 1, - 'value' => ['Field'], + 'title' => 0, + 'value' => 'Field', ], [ - 'option' => 2, - 'value' => ['Area'], + 'title' => 1, + 'value' => 'Area', ], [ - 'option' => 4, - 'value' => [1], + 'title' => 3, + 'value' => 0, ], [ - 'option' => 5, - 'value' => [1], + 'title' => 4, + 'value' => 0, ], [ - 'option' => 6, - 'value' => [1], + 'title' => 5, + 'value' => 0, ], [ - 'option' => 7, - 'value' => [1], + 'title' => 6, + 'value' => 0, ], [ - 'option' => 8, - 'value' => ['12/12/2014'], + 'title' => 7, + 'value' => '12/12/2014', ], [ - 'option' => 9, - 'value' => ['12/12/2014/12/30/AM'], + 'title' => 8, + 'value' => '12/12/2014/12/30/AM', ], [ - 'option' => 10, - 'value' => ['12/12/AM'], + 'title' => 9, + 'value' => '12/12/AM', ], ] ], @@ -253,9 +252,6 @@ class CheckoutData extends AbstractCheckoutData ], ], ]; - if (!isset($presets[$this->currentPreset])) { - return null; - } - return $presets[$this->currentPreset]; + return isset($presets[$name]) ? $presets[$name] : null; } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml index e8e3783a8f0..470c1a0e668 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Page/Product/CatalogProductView.xml @@ -25,10 +25,12 @@ --> <page mca="catalog/product/view"> <blocks> - <bundleViewBlock> - <class>Magento\Bundle\Test\Block\Catalog\Product\View</class> - <locator>.bundle-options-container</locator> - <strategy>css selector</strategy> - </bundleViewBlock> + <viewBlock> + <renders> + <bundle> + <class>Magento\Bundle\Test\Block\Catalog\Product\View</class> + </bundle> + </renders> + </viewBlock> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php index 3e5aed8a36b..5385a4baa14 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php @@ -58,13 +58,13 @@ class BundleDynamicTest extends Functional //Pages & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('bundle'); $category = $bundle->getCategories()['category']; $productForm->fill($bundle, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verification $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class BundleDynamicTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -118,12 +118,10 @@ class BundleDynamicTest extends Functional $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); - // @TODO: add click on "Customize and Add To Cart" button and assert options count - $productOptionsBlock = $productPage->getCustomOptionsBlock(); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); - foreach ($actualOptions as $optionType => $actualOption) { - $this->assertContains($expectedOptions[$optionType], $actualOption); + foreach ($actualOptions as $key => $actualOption) { + $this->assertContains($expectedOptions[$key]['title'], $actualOption); } } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php index 0fb7cab4454..990347f630b 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php @@ -61,10 +61,10 @@ class BundleFixedTest extends Functional //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('bundle'); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); $category = $bundle->getCategories()['category']; $productForm->fill($bundle, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verification $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class BundleFixedTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -115,12 +115,10 @@ class BundleFixedTest extends Functional $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), $productViewBlock->getProductPrice()); - // @TODO: add click on "Customize and Add To Cart" button and assert options count - $productOptionsBlock = $productPage->getCustomOptionsBlock(); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); - foreach ($actualOptions as $optionType => $actualOption) { - $this->assertContains($expectedOptions[$optionType], $actualOption); + foreach ($actualOptions as $key => $actualOption) { + $this->assertContains($expectedOptions[$key]['title'], $actualOption); } } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php index 3c8ca29df08..a5715f30f56 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.php @@ -101,8 +101,8 @@ class CreateBundleProductEntityTest extends Injectable { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('bundle'); - $productBlockForm = $this->catalogProductNew->getForm(); + $productBlockForm = $this->catalogProductNew->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php index ed3b6068a95..dceb96430df 100755 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/EditBundleTest.php @@ -68,7 +68,7 @@ class EditBundleTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $gridBlock = $productGridPage->getProductGrid(); $editProductPage = Factory::getPageFactory()->getCatalogProductEdit(); - $productForm = $editProductPage->getForm(); + $productForm = $editProductPage->getProductForm(); $cachePage = Factory::getPageFactory()->getAdminCache(); $productGridPage->open(); @@ -77,7 +77,7 @@ class EditBundleTest extends Functional 'type' => 'Bundle Product' ]); $productForm->fill($editProduct); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -112,7 +112,7 @@ class EditBundleTest extends Functional $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php index 9cbf6996f50..aebdd19677d 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.php @@ -94,7 +94,7 @@ class UpdateBundleProductEntityTest extends Injectable $this->catalogProductIndex->open(); $filter = ['sku' => $originalProduct->getSku()]; $this->catalogProductIndex->getProductGrid()->searchAndOpen($filter); - $this->catalogProductEdit->getForm()->fill($product); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getProductForm()->fill($product); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index 9c47b9ffe2e..cc915d53a45 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -27,6 +27,7 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Composite; use Mtf\Block\Form; use Mtf\Client\Element\Locator; +use Mtf\Fixture\FixtureInterface; /** * Class Configure @@ -38,20 +39,37 @@ class Configure extends Form /** * Fill options for the product * - * @param array $productOptions + * @param FixtureInterface $product + * @return void */ - public function fillOptions($productOptions) + public function fillOptions(FixtureInterface $product) { - foreach ($productOptions as $attributeLabel => $attributeValue) { - $select = $this->_rootElement->find( - '//div[@class="product-options"]//label[text()="' . - $attributeLabel . - '"]//following-sibling::*//select', - Locator::SELECTOR_XPATH, - 'select' - ); - $select->setValue($attributeValue); + $productOptions = $product->getCheckoutData(); + if (!empty($productOptions['configurable_options'])) { + $configurableAttributesData = $product->getData('fields/configurable_attributes_data/value'); + $checkoutData = []; + + foreach ($productOptions['configurable_options'] as $optionData) { + $titleKey = $optionData['title']; + $valueKey = $optionData['value']; + + $checkoutData[] = [ + 'title' => $configurableAttributesData[$titleKey]['label']['value'], + 'value' => $configurableAttributesData[$titleKey][$valueKey]['option_label']['value'] + ]; + } + + foreach ($checkoutData as $option) { + $select = $this->_rootElement->find( + '//div[@class="product-options"]//label[text()="' . + $option['title'] . + '"]//following-sibling::*//select', + Locator::SELECTOR_XPATH, + 'select' + ); + $select->setValue($option['value']); + } + $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } - $this->_rootElement->find('.ui-dialog-buttonset button:nth-of-type(2)')->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php index bdcbd5fa302..c9698598a47 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php @@ -53,20 +53,21 @@ class AdvancedPricingTab extends Tab */ public function fillFormTab(array $fields, Element $element = null) { + $context = $element ? $element : $this->_rootElement; foreach ($fields as $fieldName => $field) { // Fill form if (isset($this->childrenForm[$fieldName]) && is_array($field['value'])) { - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Options $optionsForm */ + /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options\AbstractOptions $optionsForm */ $optionsForm = $this->blockFactory->create( __NAMESPACE__ . '\\' . $this->childrenForm[$fieldName], - ['element' => $this->_rootElement] + ['element' => $context] ); foreach ($field['value'] as $key => $option) { ++$key; $optionsForm->fillOptions( $option, - $this->_rootElement->find( + $context->find( '#attribute-' . $fieldName . '-container tbody tr:nth-child(' . $key . ')' ) ); @@ -93,7 +94,7 @@ class AdvancedPricingTab extends Tab foreach ($fields as $fieldName => $field) { // Data collection forms if (isset($this->childrenForm[$fieldName]) && is_array($field['value'])) { - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Options $optionsForm */ + /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options\AbstractOptions $optionsForm */ $optionsForm = $this->blockFactory->create( __NAMESPACE__ . '\\' . $this->childrenForm[$fieldName], ['element' => $this->_rootElement] diff --git a/lib/internal/Magento/Framework/Module/UpdaterInterface.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php similarity index 74% rename from lib/internal/Magento/Framework/Module/UpdaterInterface.php rename to dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php index 849cf67d898..8e0f25dcf77 100644 --- a/lib/internal/Magento/Framework/Module/UpdaterInterface.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ParentCategoryIds.php @@ -1,7 +1,5 @@ <?php /** - * DB updater interface - * * Magento * * NOTICE OF LICENSE @@ -23,21 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Module; -interface UpdaterInterface -{ - /** - * Apply database scheme updates whenever needed - * - * @return void - */ - public function updateScheme(); +namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails; +/** + * Class ParentCategoryIds + * Typified element class for parent category element + */ +class ParentCategoryIds extends CategoryIds +{ /** - * Apply database data updates whenever needed + * Selector suggest input * - * @return void + * @var string */ - public function updateData(); + protected $suggest = '#new_category_parent-suggest'; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php deleted file mode 100755 index 074465b0fa5..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php +++ /dev/null @@ -1,141 +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\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Attribute - * Attribute block in Variation section - * - */ -class Attribute extends Block -{ - /** - * Attribute option pricing value - * - * @var string - */ - protected $pricingValue = '[name*=pricing_value]'; - - /** - * Attribute option price type button - * - * @var string - */ - protected $priceTypeButton = '[data-toggle=dropdown]'; - - /** - * Attribute option price type value - * - * @var string - */ - protected $priceTypeValue = '//*[@data-role="dropdown-menu"]'; - - /** - * Attribute option Include checkbox - * - * @var string - */ - protected $include = '[data-column=include ] [type=checkbox]'; - - /** - * Attribute option Label - * - * @var string - */ - protected $labelValue = 'input[class=required-entry][name*=value]'; - - /** - * Attribute option row - * - * @var string - */ - protected $attributeRow = '//*[@data-role="options"]/tr[%row%]'; - - /** - * Add option selector - * - * @var string - */ - protected $addOption = '[data-action="add-option"]'; - - /** - * Fill in data to attribute options - * - * @param array $fields - */ - public function fillAttributeOptions(array $fields) - { - $row = 0; - foreach ($fields as $field) { - if (isset($field['option_label']['value'])) { - $optionRow = $this->getOptionRow($field['option_label']['value']); - if (!$optionRow->isVisible()) { - $this->_rootElement->find($this->addOption)->click(); - $optionRow = $this->getOptionNewRow($row); - if (isset($field['option_label']['value'])) { - $optionRow->find($this->labelValue)->setValue($field['option_label']['value']); - } - } - if (isset($field['pricing_value']['value'])) { - $optionRow->find($this->pricingValue, Locator::SELECTOR_CSS) - ->setValue($field['pricing_value']['value']); - } - if (isset($field['is_percent']['value']) && $field['is_percent']['value'] == 'Yes') { - $optionRow->find($this->priceTypeButton, Locator::SELECTOR_CSS)->click(); - $optionRow->find($this->priceTypeValue . '//a[text()="%"]', Locator::SELECTOR_XPATH)->click(); - } - $optionRow->find($this->include, Locator::SELECTOR_CSS, 'checkbox') - ->setValue($field['include']['value']); - } - ++$row; - } - } - - /** - * Get option row - * - * @param string $optionLabel - * @return Element - */ - protected function getOptionRow($optionLabel) - { - return $this->_rootElement->find('//tr[td="' . $optionLabel . '"]', Locator::SELECTOR_XPATH); - } - - /** - * Get option new row - * - * @param int $row - * @return Element - */ - protected function getOptionNewRow($row) - { - return $this->_rootElement->find(str_replace('%row%', $row, $this->attributeRow), Locator::SELECTOR_XPATH); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php deleted file mode 100644 index aefe47026b0..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ /dev/null @@ -1,212 +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\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; -use Magento\Backend\Test\Block\Widget\Tab; - -/** - * Class Variations - * Adminhtml catalog super product configurable tab - * - */ -class Config extends Tab -{ - /** - * 'Generate Variations' button - * - * @var string - */ - protected $generateVariations = '[data-ui-id=product-variations-generator-generate]'; - - /** - * Product variations matrix block - * - * @var string - */ - protected $matrixBlock = '[data-role=product-variations-matrix] table'; - - /** - * Product attribute block selector by attribute name - * - * @var string - */ - protected $attribute = '//div[*/*/span="%s"]'; - - /** - * Magento loader - * - * @var string - */ - protected $loader = './ancestor::body//*[contains(@data-role,"loader")]'; - - /** - * Attribute Opened - * - * @var string - */ - protected $attributeOpen = './/*[@class = "title active"]/span[text()="%attributeLabel%"]'; - - /** - * Attribute tab - * - * @var string - */ - protected $attributeTab = '//*[@data-role="configurable-attribute"]//*[text()="%attributeTab%"]'; - - /** - * Get attribute block - * - * @param string $attributeName - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Attribute - */ - protected function getAttributeBlock($attributeName) - { - $attributeSelector = sprintf($this->attribute, $attributeName); - $this->waitForElementVisible($attributeSelector, Locator::SELECTOR_XPATH); - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperAttribute( - $this->_rootElement->find($attributeSelector, Locator::SELECTOR_XPATH) - ); - } - - /** - * Get product variations matrix block - * - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix - */ - protected function getMatrixBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfigMatrix( - $this->_rootElement->find($this->matrixBlock, Locator::SELECTOR_CSS) - ); - } - - /** - * Press 'Generate Variations' button - * - * @return void - */ - public function generateVariations() - { - $browser = $this->_rootElement; - $browser->find($this->generateVariations, Locator::SELECTOR_CSS)->click(); - $loaderSelector = $this->loader; - $browser->waitUntil( - function () use ($browser, $loaderSelector) { - $loaderElement = $browser->find($loaderSelector, Locator::SELECTOR_XPATH); - return $loaderElement->isVisible() == false ? true : null; - } - ); - } - - /** - * Fill variations fieldset - * - * @param array $fields - * @param Element|null $element - * @return $this - */ - public function fillFormTab(array $fields, Element $element = null) - { - if (!isset($fields['configurable_attributes_data'])) { - return $this; - } - $attributes = $fields['configurable_attributes_data']['value']; - foreach ($attributes as $attribute) { - $this->selectAttribute($attribute['label']['value']); - } - $this->fillAttributeOptions($attributes); - $this->generateVariations(); - $this->fillVariationsMatrix($fields['variations-matrix']['value']); - - return $this; - } - - /** - * Fill variations matrix - * - * @param array $fields - * @return void - */ - public function fillVariationsMatrix(array $fields) - { - $variations = []; - foreach ($fields as $key => $field) { - foreach ($field['value'] as $fieldName => $value) { - $variations[$key][$fieldName] = $value['value']; - } - foreach ($field['configurable_attribute'] as $options) { - $variations[$key]['options_names'][] = $options['attribute_option']; - } - } - - $this->getMatrixBlock()->fillVariation($variations); - } - - /** - * Fill attribute options - * - * @param array $attributes - * @return void - */ - public function fillAttributeOptions(array $attributes) - { - foreach ($attributes as $attribute) { - $this->getAttributeBlock($attribute['label']['value'])->fillAttributeOptions($attribute); - } - } - - /** - * Select attribute for variations - * - * @param string $attributeName - * @return void - */ - private function selectAttribute($attributeName) - { - // TODO should be removed after suggest widget implementation as typified element - $attributeFieldSet = $this->_rootElement - ->find(str_replace('%attributeLabel%', $attributeName, $this->attributeOpen), Locator::SELECTOR_XPATH); - $attributeVisible = $this->_rootElement - ->find(str_replace('%attributeTab%', $attributeName, $this->attributeTab), Locator::SELECTOR_XPATH); - if ($attributeVisible->isVisible()) { - if (!$attributeFieldSet->isVisible()) { - $attributeVisible->click(); - } - } else { - $this->_rootElement->find('#configurable-attribute-selector')->setValue($attributeName); - $attributeListLocation = '#variations-search-field .mage-suggest-dropdown'; - $this->waitForElementVisible($attributeListLocation, Locator::SELECTOR_CSS); - $attribute = $this->_rootElement->find( - "//div[@class='mage-suggest-dropdown']//a[text()='$attributeName']", - Locator::SELECTOR_XPATH - ); - if ($attribute->isVisible()) { - $attribute->click(); - } - } - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php deleted file mode 100644 index 2aa9fdefb67..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ /dev/null @@ -1,74 +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\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; - -use Mtf\Block\Form; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Matrix - * Product variations matrix block - */ -class Matrix extends Form -{ - /** - * Fill qty to current variations - * - * @param array $variations - * @return void - */ - public function fillVariation(array $variations) - { - foreach ($variations as $variation) { - $variationRow = $this->getVariationRow($variation['options_names']); - foreach ($variation as $key => $value) { - if (!empty($this->mapping[$key])) { - $this->_rootElement->find( - $variationRow . $this->mapping[$key]['selector'], - Locator::SELECTOR_XPATH, - isset($this->mapping[$key]['input']) ? $this->mapping[$key]['input'] : null - )->setValue($value); - } - } - } - } - - /** - * Define row that clarifies which line in Current Variations grid will be used - * - * @param array $variationData - * @return string - */ - private function getVariationRow(array $variationData) - { - $options = array(); - foreach ($variationData as $attributeData) { - $options[] = 'td[text()="' . $attributeData . '"]'; - } - - return '//tr[' . implode(' and ', $options) . ']'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.php deleted file mode 100644 index 00a7d7297c5..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Variations/Search.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\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Variations; - -use Mtf\Client\Element; -use Mtf\Client\Driver\Selenium\Element\SuggestElement; -use Magento\Catalog\Test\Fixture\CatalogProductAttribute; - -/** - * Class FormAttributeSearch - * Form Attribute Search on Product page - */ -class Search extends SuggestElement -{ - /** - * Attribute Set locator - * - * @var string - */ - protected $value = '.action-toggle > span'; - - /** - * Attribute Set button - * - * @var string - */ - protected $actionToggle = '.action-toggle'; - - /** - * Search attribute result locator - * - * @var string - */ - protected $searchResult = '.mage-suggest-dropdown .ui-corner-all'; - - /** - * Set value - * - * @param string $value - * @return void - */ - public function setValue($value) - { - $this->find($this->actionToggle)->click(); - parent::setValue($value); - } - - /** - * Get value - * - * @return string - */ - public function getValue() - { - return $this->find($this->value)->getText(); - } - - /** - * Checking not exist configurable attribute in search result - * - * @param CatalogProductAttribute $productAttribute - * @return bool - */ - public function isExistAttributeInSearchResult(CatalogProductAttribute $productAttribute) - { - $attribute = $productAttribute->getFrontendLabel(); - $searchResult = $this->find($this->searchResult); - - $this->find($this->suggest)->setValue($attribute); - if (!$searchResult->isVisible()) { - return false; - } - if ($searchResult->getText() == $attribute) { - return true; - } - return false; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php index b5fe622c14b..3dbd522c6aa 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php @@ -72,18 +72,27 @@ class FormPageActions extends ParentFormPageActions protected $saveButton = '#save-split-button-button'; /** - * Save product form with window confirmation + * Click on "Save" button * - * @param BackendPage $page - * @param FixtureInterface $product + * @param FixtureInterface|null $product [optional] * @return void */ - public function saveProduct(BackendPage $page, FixtureInterface $product) + public function save(FixtureInterface $product = null) { - parent::save(); - /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\AffectedAttributeSetForm $affectedAttributeSetForm */ - $affectedAttributeSetForm = $page->getAffectedAttributeSetForm(); - $affectedAttributeSetForm->fill($product)->confirm(); + $typeId = null; + + if ($product) { + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + } + + if ($this->hasRender($typeId)) { + $this->callRender($typeId, 'save', ['product' => $product]); + } else { + $this->_rootElement->find($this->saveButton)->click(); + $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); + $this->waitForElementNotVisible($this->loaderOld, Locator::SELECTOR_XPATH); + } } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php index f2ab98df6df..b3e903278f1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php @@ -24,12 +24,14 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product; -use Magento\Backend\Test\Block\Widget\FormTabs; use Mtf\Client\Element; +use Mtf\Fixture\DataFixture; +use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\FormTabs; use Mtf\Fixture\FixtureInterface; use Mtf\Fixture\InjectableFixture; use Magento\Catalog\Test\Fixture\Product; -use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\Tab; use Magento\Catalog\Test\Fixture\CatalogCategory; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; @@ -69,25 +71,46 @@ class ProductForm extends FormTabs protected $advancedSettingContent = '#product_info_tabs-advanced [data-role="content"]'; /** - * Variations Attribute Search locator the Product page + * Custom Tab locator * * @var string */ - protected $variationsAttributeSearch = '#variations-search-field'; + protected $customTab = './/*/a[contains(@id,"product_info_tabs_%s")]'; /** - * Variations Tab locator the Product page + * Button "New Category" * * @var string */ - protected $variationsTab = '#product_info_tabs_super_config_content .title'; + protected $buttonNewCategory = '#add_category_button'; /** - * Custom Tab locator + * Dialog box "Create Category" * * @var string */ - protected $customTab = './/*/a[contains(@id,"product_info_tabs_%s")]'; + protected $createCategoryDialog = './/ancestor::body//*[contains(@class,"mage-new-category-dialog")]'; + + /** + * "Parent Category" block on dialog box + * + * @var string + */ + protected $parentCategoryBlock = '//*[contains(@class,"field-new_category_parent")]'; + + /** + * Field "Category Name" on dialog box + * + * @var string + */ + protected $fieldNewCategoryName = '//input[@id="new_category_name"]'; + + /** + * Button "Create Category" on dialog box + * + * @var string + */ + protected $createCategoryButton = '//button[contains(@class,"action-create")]'; /** * Fill the product form @@ -99,16 +122,34 @@ class ProductForm extends FormTabs */ public function fill(FixtureInterface $product, Element $element = null, FixtureInterface $category = null) { - $tabs = $this->getFieldsByTabs($product); + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + if ($this->hasRender($typeId)) { + $renderArguments = [ + 'product' => $product, + 'element' => $element, + 'category' => $category + ]; + $this->callRender($typeId, 'fill', $renderArguments); + } else { + $tabs = $this->getFieldsByTabs($product); + + if (null === $category && $product instanceof DataFixture) { + $categories = $product->getCategories(); + $category = reset($categories); + } + if ($category) { + $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) + ? $category->getName() + : $category->getCategoryName(); + } - if ($category) { - $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) - ? $category->getName() - : $category->getCategoryName(); + $this->showAdvancedSettings(); + $this->fillTabs($tabs, $element); } - $this->showAdvancedSettings(); - return parent::fillTabs($tabs, $element); + return $this; } /** @@ -137,6 +178,19 @@ class ProductForm extends FormTabs } } + /** + * Open tab + * + * @param string $tabName + * @return Tab + */ + public function openTab($tabName) + { + $this->showAdvancedSettings(); + + return parent::openTab($tabName); + } + /** * Save new category * @@ -145,15 +199,19 @@ class ProductForm extends FormTabs */ public function addNewCategory(Product $fixture) { + $this->openTab('product-details'); $this->openNewCategoryDialog(); - $this->_rootElement->find('input#new_category_name', Locator::SELECTOR_CSS) - ->setValue($fixture->getNewCategoryName()); + $this->_rootElement->find( + $this->createCategoryDialog . $this->fieldNewCategoryName, + Locator::SELECTOR_XPATH + )->setValue($fixture->getNewCategoryName()); $this->clearCategorySelect(); $this->selectParentCategory(); - $this->_rootElement->find('div.ui-dialog-buttonset button.action-create')->click(); - $this->waitForElementNotVisible('div.ui-dialog-buttonset button.action-create'); + $buttonCreateCategory = $this->createCategoryDialog . $this->createCategoryButton; + $this->_rootElement->find($buttonCreateCategory, Locator::SELECTOR_XPATH)->click(); + $this->waitForElementNotVisible($buttonCreateCategory, Locator::SELECTOR_XPATH); } /** @@ -163,12 +221,11 @@ class ProductForm extends FormTabs */ protected function selectParentCategory() { - // TODO should be removed after suggest widget implementation as typified element - $this->fillCategoryField( - 'Default Category', - 'new_category_parent-suggest', - '//*[@id="new_category_form_fieldset"]' - ); + $this->_rootElement->find( + $this->createCategoryDialog . $this->parentCategoryBlock, + Locator::SELECTOR_XPATH, + '\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\ParentCategoryIds' + )->setValue('Default Category'); } /** @@ -191,8 +248,8 @@ class ProductForm extends FormTabs */ protected function openNewCategoryDialog() { - $this->_rootElement->find('#add_category_button', Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible('input#new_category_name'); + $this->_rootElement->find($this->buttonNewCategory)->click(); + $this->waitForElementVisible($this->createCategoryDialog, Locator::SELECTOR_XPATH); } /** @@ -226,33 +283,6 @@ class ProductForm extends FormTabs )->isExistAttributeInSearchResult($productAttribute); } - /** - * Call method that checking present attribute in search result - * - * @param CatalogProductAttribute $productAttribute - * @return bool - */ - public function checkAttributeInVariationsSearchAttributeForm(CatalogProductAttribute $productAttribute) - { - return $this->_rootElement->find( - $this->variationsAttributeSearch, - Locator::SELECTOR_CSS, - 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Search' - )->isExistAttributeInSearchResult($productAttribute); - } - - /** - * Open Variations tab on Product form - * - * @return void - */ - public function openVariationsTab() - { - if (!$this->_rootElement->find($this->variationsAttributeSearch, Locator::SELECTOR_CSS)->isVisible()) { - $this->_rootElement->find($this->variationsTab, Locator::SELECTOR_CSS)->click(); - } - } - /** * Check tab visibility on Product form * @@ -262,8 +292,9 @@ class ProductForm extends FormTabs public function isTabVisible($tabName) { $tabName = strtolower($tabName); - - return $this->_rootElement->find(sprintf($this->customTab, $tabName), Locator::SELECTOR_XPATH)->isVisible(); + $selector = sprintf($this->customTab, $tabName); + $this->waitForElementVisible($selector, Locator::SELECTOR_XPATH); + return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->isVisible(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index 1d5f379a164..e54210bf600 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -82,9 +82,16 @@ <strategy>css selector</strategy> <wrapper>product</wrapper> <fields> - <special_price> - <selector>#special_price</selector> - </special_price> + <special_price /> + <group_price> + <input>select</input> + </group_price> + <tier_price> + <input>select</input> + </tier_price> + <msrp_enabled> + <input>select</input> + </msrp_enabled> </fields> </advanced-pricing> <advanced-inventory> @@ -139,11 +146,6 @@ </use_config_gift_message_available> </fields> </autosettings> - <variations> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </variations> <grouped-product> <class>\Magento\Catalog\Test\Block\Product\Grouped\AssociatedProducts</class> <selector>#product_info_tabs_product-details</selector> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php deleted file mode 100644 index bc56affda4c..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Test\Block\Backend\Product\Attribute; - -use Mtf\Fixture\FixtureInterface; -use Mtf\Client\Element; -use Magento\Backend\Test\Block\Widget\Form; - -/** - * Product attribute edit page - * - */ -class Edit extends Form -{ - /** - * Frontend properties selector - * - * @var string - */ - protected $frontendProperties = '#front_fieldset-wrapper .title'; - - /** - * Save attribute selector - * - * @var string - */ - protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; - - /** - * 'Add new option' button selector - * - * @var string - */ - protected $addNewOption = '#add_new_option_button'; - - /** - * Attribute option row - * - * @var string - */ - protected $optionRow = '//*[@id="manage-options-panel"]//tbody//tr[%row%]'; - - /** - * Open frontend properties - */ - public function openFrontendProperties() - { - $this->_rootElement->find($this->frontendProperties)->click(); - } - - /** - * Save attribute - */ - public function saveAttribute() - { - $this->_rootElement->find($this->saveAttribute)->click(); - } - - /** - * Fill form with attribute options - * - * @param FixtureInterface $fixture - * @param Element|null $element - * @return $this - */ - public function fill(FixtureInterface $fixture, Element $element = null) - { - parent::fill($fixture, $element); - $this->fillOptions($fixture); - - return $this; - } - - /** - * Fill attribute options - * - * @param FixtureInterface $fixture - */ - protected function fillOptions(FixtureInterface $fixture) - { - /** @var $fixture \Magento\Catalog\Test\Fixture\ProductAttribute */ - $options = $fixture->getOptions(); - - $row = 1; - foreach ($options as $option) { - $this->_rootElement->find($this->addNewOption)->click(); - // TODO: implement filling for any number of stores - $this->_rootElement->find( - str_replace('%row%', $row, $this->optionRow) . '/td[2]/input', - Element\Locator::SELECTOR_XPATH, - 'checkbox' - )->setValue($option['default']['value']); - $this->_rootElement->find( - str_replace('%row%', $row, $this->optionRow) . '/td[3]/input', - Element\Locator::SELECTOR_XPATH - )->setValue($option['label']['value']); - ++$row; - } - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml deleted file mode 100644 index d604e00a11d..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/Product/Attribute/Edit.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?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) - */ ---> -<mapping strict="0"> - <fields> - <attribute_label> - <selector>[name='frontend_label[0]']</selector> - </attribute_label> - <frontend_input> - <input>select</input> - </frontend_input> - <is_searchable> - <input>select</input> - </is_searchable> - <is_visible_in_advanced_search> - <input>select</input> - </is_visible_in_advanced_search> - <is_comparable> - <input>select</input> - </is_comparable> - <is_filterable> - <input>select</input> - </is_filterable> - <is_visible_on_front> - <input>select</input> - </is_visible_on_front> - <is_filterable_in_search> - <input>select</input> - </is_filterable_in_search> - </fields> -</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php deleted file mode 100644 index d9d81ec8cc9..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.php +++ /dev/null @@ -1,380 +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\Test\Block\Backend; - -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Fixture\Product; -use Magento\Catalog\Test\Fixture\Category; -use Magento\Backend\Test\Block\Widget\Tab; -use Magento\Backend\Test\Block\Widget\FormTabs; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; - -/** - * Class ProductForm - * Product creation form - */ -class ProductForm extends FormTabs -{ - /** - * 'Save' split button - * - * @var string - */ - protected $saveButton = '#save-split-button-button'; - - /** - * Variations tab selector - * - * @var string - */ - protected $variationsTab = '[data-ui-id="product-tabs-tab-content-super-config"] .title'; - - /** - * Variations wrapper selector - * - * @var string - */ - protected $variationsWrapper = '[data-ui-id="product-tabs-tab-content-super-config"]'; - - /** - * New variation set button selector - * - * @var string - */ - protected $newVariationSet = '[data-ui-id="admin-product-edit-tab-super-config-grid-container-add-attribute"]'; - - /** - * Choose affected attribute set dialog popup window - * - * @var string - */ - protected $affectedAttributeSet = "//div[div/@data-id='affected-attribute-set-selector']"; - - /** - * Category name selector - * - * @var string - */ - protected $categoryName = '//*[contains(@class, "mage-suggest-choice")]/*[text()="%categoryName%"]'; - - /** - * 'Advanced Settings' tab - * - * @var string - */ - protected $advancedSettings = '#product_info_tabs-advanced [data-role="trigger"]'; - - /** - * Advanced tab list - * - * @var string - */ - protected $advancedTabList = '#product_info_tabs-advanced[role="tablist"]'; - - /** - * Advanced tab panel - * - * @var string - */ - protected $advancedTabPanel = '[role="tablist"] [role="tabpanel"][aria-expanded="true"]:not("overflow")'; - - /** - * Selector popups 'New category' - * - * @var string - */ - protected $newCategoryPopup = "./ancestor::body//div[div[contains(@id,'new-category')]]"; - - /** - * Category fixture - * - * @var Category - */ - protected $category; - - /** - * Get choose affected attribute set dialog popup window - * - * @return \Magento\Catalog\Test\Block\Product\Configurable\AffectedAttributeSet - */ - protected function getAffectedAttributeSetBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogProductConfigurableAffectedAttributeSet( - $this->_rootElement->find($this->affectedAttributeSet, Locator::SELECTOR_XPATH) - ); - } - - /** - * Set category - * - * @param Category $category - * @return void - */ - public function setCategory(Category $category) - { - $this->category = $category; - } - - /** - * Fill the product form - * - * @param FixtureInterface $fixture - * @param Element $element - * @return $this - */ - public function fill(FixtureInterface $fixture, Element $element = null) - { - $this->fillCategory($fixture); - return parent::fill($fixture); - } - - /** - * Select category - * - * @param FixtureInterface $fixture - * @return void - */ - protected function fillCategory(FixtureInterface $fixture) - { - // TODO should be removed after suggest widget implementation as typified element - $categoryName = $this->category - ? $this->category->getCategoryName() - : ($fixture->getCategoryName() ? $fixture->getCategoryName() : ''); - - if (!$categoryName) { - return; - } - $category = $this->_rootElement->find( - str_replace('%categoryName%', $categoryName, $this->categoryName), - Locator::SELECTOR_XPATH - ); - if (!$category->isVisible()) { - $this->fillCategoryField( - $categoryName, - 'category_ids-suggest', - '//*[@id="attribute-category_ids-container"]' - ); - } - } - - /** - * Save product - * - * @param FixtureInterface $fixture - * @return \Magento\Backend\Test\Block\Widget\Form|void - */ - public function save(FixtureInterface $fixture = null) - { - parent::save($fixture); - if ($this->getAffectedAttributeSetBlock()->isVisible()) { - $this->getAffectedAttributeSetBlock()->chooseAttributeSet($fixture); - } - } - - /** - * Save new category - * - * @param Product $fixture - * @return void - */ - public function addNewCategory(Product $fixture) - { - $this->openNewCategoryDialog(); - $popupElement = $this->_rootElement->find($this->newCategoryPopup, Locator::SELECTOR_XPATH); - - if ($popupElement->isVisible()) { - $popupElement->find('input#new_category_name', Locator::SELECTOR_CSS) - ->setValue($fixture->getNewCategoryName()); - $this->clearCategorySelect($popupElement); - $this->selectParentCategory($popupElement); - $popupElement->find('div.ui-dialog-buttonset button.action-create')->click(); - $this->waitForElementNotVisible('div.ui-dialog-buttonset button.action-create'); - } - - } - - /** - * Get variations block - * - * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config - */ - protected function getVariationsBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfig( - $this->_rootElement->find($this->variationsWrapper) - ); - } - - /** - * Fill product variations - * - * @param ConfigurableProduct $variations - * @return void - */ - public function fillVariations(ConfigurableProduct $variations) - { - $variationsBlock = $this->getVariationsBlock(); - $variationsBlock->fillAttributeOptions($variations->getConfigurableAttributes()); - $variationsBlock->generateVariations(); - $variationsBlock->fillVariationsMatrix($variations->getVariationsMatrix()); - } - - /** - * Open variations tab - * - * @return void - */ - public function openVariationsTab() - { - $this->_rootElement->find($this->variationsTab)->click(); - } - - /** - * Click on 'Create New Variation Set' button - * - * @return void - */ - public function clickCreateNewVariationSet() - { - $this->_rootElement->find($this->newVariationSet)->click(); - } - - /** - * Clear category field - * - * @param Element $element - * @return void - */ - public function clearCategorySelect(Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $selectedCategory = 'li.mage-suggest-choice span.mage-suggest-choice-close'; - if ($element->find($selectedCategory)->isVisible()) { - $element->find($selectedCategory)->click(); - } - } - - /** - * Select parent category for new one - * - * @param Element $element - * @return void - */ - protected function selectParentCategory(Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - // TODO should be removed after suggest widget implementation as typified element - $this->fillCategoryField( - 'Default Category', - 'new_category_parent-suggest', - '//*[@id="new_category_form_fieldset"]', - $element - ); - } - - /** - * Fills select category field - * - * @param string $name - * @param string $elementId - * @param string $parentLocation - * @param Element $element - * @return void - */ - protected function fillCategoryField($name, $elementId, $parentLocation, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - // TODO should be removed after suggest widget implementation as typified element - $element->find($elementId, Locator::SELECTOR_ID)->setValue($name); - //*[@id="attribute-category_ids-container"] //*[@id="new_category_form_fieldset"] - $categoryListLocation = $parentLocation . '//div[@class="mage-suggest-dropdown"]'; // - $this->waitForElementVisible($categoryListLocation, Locator::SELECTOR_XPATH); - $categoryLocation = $parentLocation . '//li[contains(@data-suggest-option, \'"label":"' . $name . '",\')]//a'; - $element->find($categoryLocation, Locator::SELECTOR_XPATH)->click(); - } - - /** - * Open new category dialog - * - * @return void - */ - protected function openNewCategoryDialog() - { - $this->_rootElement->find('#add_category_button', Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible($this->newCategoryPopup, Locator::SELECTOR_XPATH); - } - - /** - * Open tab - * - * @param string $tabName - * @return Tab|bool - */ - public function openTab($tabName) - { - $rootElement = $this->_rootElement; - $selector = $this->tabs[$tabName]['selector']; - $strategy = isset($this->tabs[$tabName]['strategy']) - ? $this->tabs[$tabName]['strategy'] - : Locator::SELECTOR_CSS; - $advancedTabList = $this->advancedTabList; - $tab = $this->_rootElement->find($selector, $strategy); - $advancedSettings = $this->_rootElement->find($this->advancedSettings); - - // Wait until all tabs will load - $this->_rootElement->waitUntil( - function () use ($rootElement, $advancedTabList) { - return $rootElement->find($advancedTabList)->isVisible(); - } - ); - - if ($tab->isVisible()) { - $tab->click(); - } elseif ($advancedSettings->isVisible()) { - $advancedSettings->click(); - // Wait for open tab animation - $tabPanel = $this->advancedTabPanel; - $this->_rootElement->waitUntil( - function () use ($rootElement, $tabPanel) { - return $rootElement->find($tabPanel)->isVisible(); - } - ); - // Wait until needed tab will appear - $this->_rootElement->waitUntil( - function () use ($rootElement, $selector, $strategy) { - return $rootElement->find($selector, $strategy)->isVisible(); - } - ); - $tab->click(); - } else { - return false; - } - - return $this; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml deleted file mode 100644 index 8e7c8113ab2..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductForm.xml +++ /dev/null @@ -1,138 +0,0 @@ -<?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) - */ ---> -<tabs> - <product-details> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <tax_class_id> - <input>select</input> - </tax_class_id> - <is_virtual> - <input>checkbox</input> - </is_virtual> - <qty> - <selector>[name='product[quantity_and_stock_status][qty]']</selector> - </qty> - <quantity_and_stock_status> - <selector>[name='product[quantity_and_stock_status][is_in_stock]']</selector> - <input>select</input> - </quantity_and_stock_status> - </fields> - </product-details> - <websites> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_websites</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <product_website_1> - <selector>[name='product[website_ids][]']</selector> - <input>checkbox</input> - </product_website_1> - </fields> - </websites> - <advanced-pricing> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab</class> - <selector>#product_info_tabs_advanced-pricing</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <special_price> - <selector>[name='product[special_price]']</selector> - </special_price> - <group_price> - <input>select</input> - </group_price> - <tier_price> - <input>select</input> - </tier_price> - </fields> - </advanced-pricing> - <advanced-inventory> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_advanced-inventory</selector> - <strategy>css selector</strategy> - <wrapper>product[stock_data]</wrapper> - <fields> - <inventory_manage_stock> - <selector>[name='product[stock_data][manage_stock]']</selector> - <input>select</input> - </inventory_manage_stock> - <inventory_qty> - <selector>[name='product[stock_data][qty]']</selector> - </inventory_qty> - </fields> - </advanced-inventory> - <autosettings> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_autosettings</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <visibility> - <input>select</input> - </visibility> - </fields> - </autosettings> - <variations> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </variations> - <grouped-product> - <class>\Magento\Catalog\Test\Block\Product\Grouped\AssociatedProducts</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - </grouped-product> - <customer-options> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options</class> - <selector>#product_info_tabs_customer_options</selector> - <strategy>css selector</strategy> - <fields> - <custom_options> - <input>select</input> - </custom_options> - </fields> - </customer-options> - <related-products> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Related</class> - <selector>#product_info_tabs_related</selector> - <strategy>css selector</strategy> - </related-products> - <upsells> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Upsell</class> - <selector>#product_info_tabs_upsell</selector> - <strategy>css selector</strategy> - </upsells> - <crosssells> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Crosssell</class> - <selector>#product_info_tabs_crosssell</selector> - <strategy>css selector</strategy> - </crosssells> -</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php index 98cfd200d72..e1a681048cc 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Compare/ListCompare.php @@ -53,7 +53,7 @@ class ListCompare extends Block * * @var string */ - protected $nameSelector = './/*[contains(@class, "product name")]/a'; + protected $nameSelector = './/*[contains(@class, "product-item-name")]/a'; /** * Selector for search product via name diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php deleted file mode 100644 index a1be12d13cf..00000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Configurable/AffectedAttributeSet.php +++ /dev/null @@ -1,74 +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\Test\Block\Product\Configurable; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; - -/** - * Class AffectedAttributeSet - * Choose affected attribute set dialog popup window - * - */ -class AffectedAttributeSet extends Block -{ - /** - * Create new attribute set based on default - * - * @var string - */ - protected $affectedAttributeSet = '[name=affected-attribute-set][value=new]'; - - /** - * New attribute set name - * - * @var string - */ - protected $attributeSetName = '[name=new-attribute-set-name]'; - - /** - * 'Confirm' button - * - * @var string - */ - protected $confirmButton = '[id*=confirm-button]'; - - /** - * Choose affected attribute set - * - * @param ConfigurableProduct $fixture - */ - public function chooseAttributeSet(ConfigurableProduct $fixture) - { - $attributeSetName = $fixture->getAffectedAttributeSet(); - if ($attributeSetName) { - $this->_rootElement->find($this->affectedAttributeSet)->click(); - $this->_rootElement->find($this->attributeSetName)->setValue($attributeSetName); - } - $this->_rootElement->find($this->confirmButton)->click(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.php new file mode 100644 index 00000000000..ceff3348c3d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/BottomToolbar.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\Catalog\Test\Block\Product\ProductList; + +use Mtf\Block\Block; + +/** + * Class BottomToolbar + * Bottom toolbar the product list page + */ +class BottomToolbar extends Block +{ + /** + * Selector next active element + * + * @var string + */ + protected $nextPageSelector = '.item.current + .item a'; + + /** + * Go to the next page + * + * @return bool + */ + public function nextPage() + { + $nextPageItem = $this->_rootElement->find($this->nextPageSelector); + + if ($nextPageItem->isVisible()) { + $nextPageItem->click(); + return true; + } + return false; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php similarity index 74% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php rename to dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php index ff9eeaae543..0bf728d67d6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/Toolbar.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php @@ -27,18 +27,11 @@ namespace Magento\Catalog\Test\Block\Product\ProductList; use Mtf\Block\Block; /** - * Class Toolbar - * Toolbar the product list page + * Class TopToolbar + * Top toolbar the product list page */ -class Toolbar extends Block +class TopToolbar extends Block { - /** - * Selector next active element - * - * @var string - */ - protected $nextPageSelector = '.item.current + .item a'; - /** * Selector for "sort by" element * @@ -46,22 +39,6 @@ class Toolbar extends Block */ protected $sorter = '#sorter'; - /** - * Go to the next page - * - * @return bool - */ - public function nextPage() - { - $nextPageItem = $this->_rootElement->find($this->nextPageSelector); - if ($nextPageItem->isVisible()) { - $nextPageItem->click(); - return true; - } - - return false; - } - /** * Get method of sorting product * 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 8ff2ae1ef23..de14d5daef5 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 @@ -25,11 +25,11 @@ namespace Magento\Catalog\Test\Block\Product; use Mtf\Block\Block; -use Mtf\Factory\Factory; use Mtf\Client\Element\Locator; use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Fixture\GroupedProduct; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; /** * Class View @@ -117,13 +117,6 @@ class View extends Block */ protected $productPrice = '.price-box .price'; - /** - * Bundle options block - * - * @var string - */ - protected $bundleBlock = '#product-options-wrapper'; - /** * Click for Price link on Product page * @@ -145,13 +138,6 @@ class View extends Block */ protected $stockAvailability = '.stock span'; - /** - * Customize and add to cart button selector - * - * @var string - */ - protected $customizeButton = '.action.primary.customize'; - /** * This member holds the class name of the tier price block. * @@ -181,27 +167,28 @@ class View extends Block protected $addToWishlist = '[data-action="add-to-wishlist"]'; /** - * Get bundle options block + * Get block price * - * @return \Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle + * @return \Magento\Catalog\Test\Block\Product\Price */ - public function getBundleBlock() + public function getPriceBlock() { - return Factory::getBlockFactory()->getMagentoBundleCatalogProductViewTypeBundle( - $this->_rootElement->find($this->bundleBlock) + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Product\Price', + ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] ); } /** - * Get block price + * This method returns the custom options block. * - * @return \Magento\Catalog\Test\Block\Product\Price + * @return \Magento\Catalog\Test\Block\Product\View\CustomOptions */ - protected function getPriceBlock() + public function getCustomOptionsBlock() { return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', - ['element' => $this->_rootElement->find($this->priceBlock, Locator::SELECTOR_XPATH)] + 'Magento\Catalog\Test\Block\Product\View\CustomOptions', + ['element' => $this->_rootElement->find($this->customOptionsSelector)] ); } @@ -217,16 +204,6 @@ class View extends Block $this->clickAddToCart(); } - /** - * Find button 'Add to cart' - * - * @return boolean - */ - public function addToCartIsVisible() - { - return $this->_rootElement->find($this->addToCart, Locator::SELECTOR_CSS)->isVisible(); - } - /** * Click link * @@ -289,32 +266,6 @@ class View extends Block return $this->_rootElement->find($this->productSku, Locator::SELECTOR_CSS)->getText(); } - /** - * This method returns the price box block. - * - * @return Price - */ - public function getProductPriceBlock() - { - return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\Price', - ['element' => $this->_rootElement->find($this->priceBlockClass, Locator::SELECTOR_CLASS_NAME)] - ); - } - - /** - * This method returns the custom options block. - * - * @return \Magento\Catalog\Test\Block\Product\View\CustomOptions - */ - public function getCustomOptionsBlock() - { - return $this->blockFactory->create( - 'Magento\Catalog\Test\Block\Product\View\CustomOptions', - ['element' => $this->_rootElement->find($this->customOptionsSelector)] - ); - } - /** * Return product price displayed on page * @@ -352,26 +303,29 @@ class View extends Block } /** - * Return configurable product options + * Return product options * + * @param FixtureInterface $product [optional] * @return array */ - public function getProductOptions() + public function getOptions(FixtureInterface $product = null) { - $options = []; - for ($i = 2; $i <= 3; $i++) { - $options[] = $this->_rootElement->find(".super-attribute-select option:nth-child({$i})")->getText(); - } - return $options; + /** @var CatalogProductSimple $product */ + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + return $this->hasRender($typeId) + ? $this->callRender($typeId, 'getOptions', ['product' => $product]) + : $this->getCustomOptionsBlock()->getOptions($product); } /** - * Verify configurable product options + * Verify product options * - * @param ConfigurableProduct $product + * @param FixtureInterface $product * @return bool */ - public function verifyProductOptions(ConfigurableProduct $product) + public function verifyProductOptions(FixtureInterface $product) { $attributes = $product->getConfigurableOptions(); foreach ($attributes as $attributeName => $attribute) { @@ -400,18 +354,60 @@ class View extends Block */ public function fillOptions(FixtureInterface $product) { - $configureButton = $this->_rootElement->find($this->customizeButton); - $configureSection = $this->_rootElement->find('.product-options-wrapper'); + $dataConfig = $product->getDataConfig(); + $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null; + + /** @var CatalogProductSimple $product */ + if ($this->hasRender($typeId)) { + $this->callRender($typeId, 'fillOptions', ['product' => $product]); + } else { + $optionsCheckoutData = []; + + if ($product instanceof InjectableFixture) { + /** @var CatalogProductSimple $product */ + $customOptions = $product->hasData('custom_options') + ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() + : []; + $checkoutData = $product->getCheckoutData(); + $productCheckoutData = isset($checkoutData['custom_options']) + ? $checkoutData['custom_options'] + : []; + $optionsCheckoutData = $this->prepareCheckoutData($customOptions, $productCheckoutData); + } - if ($configureButton->isVisible()) { - $configureButton->click(); - $bundleOptions = $product->getSelectionData(); - $this->getBundleBlock()->fillBundleOptions($bundleOptions); + $this->getCustomOptionsBlock()->fillCustomOptions($optionsCheckoutData); } - if ($configureSection->isVisible()) { - $productOptions = $product->getProductOptions(); - $this->getCustomOptionsBlock()->fillProductOptions($productOptions); + } + + /** + * Replace index fields to name fields in checkout data + * + * @param array $options + * @param array $checkoutData + * @return array + */ + protected function prepareCheckoutData(array $options, array $checkoutData) + { + $result = []; + + foreach ($checkoutData as $checkoutOption) { + $attributeKey = $checkoutOption['title']; + $optionKey = $checkoutOption['value']; + + if (isset($options[$attributeKey])) { + $result[] = [ + 'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attributeKey]['type'])), + 'title' => isset($options[$attributeKey]['title']) + ? $options[$attributeKey]['title'] + : $attributeKey, + 'value' => isset($options[$attributeKey]['options'][$optionKey]['title']) + ? $options[$attributeKey]['options'][$optionKey]['title'] + : $optionKey + ]; + } } + + return $result; } /** @@ -428,17 +424,6 @@ class View extends Block )->getText(); } - /** - * Click "Customize and add to cart button" - * - * @return void - */ - public function clickCustomize() - { - $this->_rootElement->find($this->customizeButton)->click(); - $this->waitForElementVisible($this->addToCart); - } - /** * Click "ADD TO CART" button * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php index f46da17bfd1..46ae9456532 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php @@ -28,6 +28,7 @@ use Mtf\Block\Form; use Mtf\Client\Element; use Mtf\Client\Element\Locator; use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; /** * Class Custom Options @@ -129,17 +130,22 @@ class CustomOptions extends Form /** * Get product options * - * @param FixtureInterface|null $product [optional] + * @param FixtureInterface $product * @return array * @throws \Exception */ - public function getOptions(FixtureInterface $product = null) + public function getOptions(FixtureInterface $product) { - $dataOptions = ($product && $product->hasData('custom_options')) - ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() - : []; - $listCustomOptions = $this->getListCustomOptions(); - $readyOptions = []; + if ($product instanceof InjectableFixture) { + $dataOptions = $product->hasData('custom_options') + ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() + : []; + } else { + // TODO: Removed after refactoring(removed) old product fixture. + $dataOptions = $product->getData('fields/custom_options/value'); + $dataOptions = $dataOptions ? $dataOptions : []; + } + $listCustomOptions = $this->getListOptions(); $result = []; foreach ($dataOptions as $option) { @@ -160,17 +166,10 @@ class CustomOptions extends Form ? 'Yes' : 'No'; - $readyOptions[] = $title; $result[$title] = $optionData; } - $unreadyCustomOptions = array_diff_key($listCustomOptions, array_flip($readyOptions)); - foreach ($unreadyCustomOptions as $optionElement) { - $title = $optionElement->find($this->title, Locator::SELECTOR_XPATH)->getText(); - $result[$title] = ['title' => $title]; - } - - return $result; + return ['custom_options' => $result]; } /** @@ -178,7 +177,7 @@ class CustomOptions extends Form * * @return array */ - protected function getListCustomOptions() + protected function getListOptions() { $customOptions = []; $context = $this->_rootElement->find($this->optionsContext); @@ -418,169 +417,90 @@ class CustomOptions extends Form ]; } - /** - * Fill configurable product options - * - * @param array $productOptions - * @return void - */ - public function fillProductOptions(array $productOptions) - { - foreach ($productOptions as $attributeLabel => $attributeValue) { - $select = $this->_rootElement->find( - sprintf($this->selectByTitleLocator, $attributeLabel), - Locator::SELECTOR_XPATH, - 'select' - ); - $select->setValue($attributeValue); - } - } - /** * Fill custom options * - * @param FixtureInterface $product - * @param array $customOptions + * @param array $checkoutData * @return void */ - public function fillCustomOptions(FixtureInterface $product, array $customOptions) + public function fillCustomOptions(array $checkoutData) { - $customOptions = $this->prepareCustomOptions($product, $customOptions); - foreach ($customOptions as $option) { - $this->fillOption($option); - } + $checkoutOptions = $this->prepareOptions($checkoutData); + $this->fillOptions($checkoutOptions); } /** - * Prepare custom options for fill + * Prepare composite fields in checkout options data * - * @param FixtureInterface $product - * @param array $customOptions + * @param array $options * @return array */ - protected function prepareCustomOptions(FixtureInterface $product, array $customOptions) + protected function prepareOptions(array $options) { - $options = []; - $productCustomOptions = $product->hasData('custom_options') - ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() - : null; - - if ($productCustomOptions !== null) { - foreach ($customOptions as $key => $option) { - $type = $productCustomOptions[$option['option'] - 1]['type']; - $title = $productCustomOptions[$option['option'] - 1]['title']; - $titleOption = []; - foreach ($option['value'] as $value) { - $titleOption[] = is_numeric($value) - ? $productCustomOptions[$option['option'] - 1]['options'][$value - 1]['title'] - : null; - } - - $options[$key] = $this->dataMapping([$option, $type, $title, $titleOption]); - } - } + $result = []; - return $options; - } + foreach ($options as $key => $option) { + switch ($option['type']) { + case 'datetime': + list($day, $month, $year, $hour, $minute, $dayPart) = explode('/', $option['value']); + $option['value'] = [ + 'day' => $day, + 'month' => $month, + 'year' => $year, + 'hour' => $hour, + 'minute' => $minute, + 'day_part' => $dayPart + ]; + break; + case 'date': + list($day, $month, $year) = explode('/', $option['value']); + $option['value'] = [ + 'day' => $day, + 'month' => $month, + 'year' => $year, + ]; + break; + case 'time': + list($hour, $minute, $dayPart) = explode('/', $option['value']); + $option['value'] = [ + 'hour' => $hour, + 'minute' => $minute, + 'day_part' => $dayPart + ]; + break; + } - /** - * Custom options mapping - * - * @param array|null $fields - * @param string|null $parent - * @return array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - protected function dataMapping(array $fields = null, $parent = null) - { - list($option, $type, $title, $titleOption) = $fields; - - $isDate = $type == 'Date' || $type == 'Time' || $type == 'Date & Time'; - $isChecked = $type == 'Checkbox' || $type == 'Radio Buttons'; - $isField = $type == 'Field' || $type == 'Area'; - - $optionName = strtolower(preg_replace('/[^a-zA-Z]/', '', $type)); - $option += parent::dataMapping([$optionName => []]); - $selector = [$option[$optionName]['selector']]; - - if ($isDate) { - $value = explode('/', $option['value'][0]); - $selector = $this->setDateTypeSelector(count($value), $selector[0]); - } elseif ($isChecked) { - $selector[0] = str_replace('%option_name%', $titleOption[0], $selector[0]); - $value = ['Yes']; - } elseif ($isField) { - $value = $option['value']; - } else { - $value = $titleOption; + $result[$key] = $option; } - return [ - 'title' => $title, - 'value' => $value, - 'selector' => $selector, - 'input' => $option[$optionName]['input'] - ]; + return $result; } /** - * Fill custom option + * Fill product options * - * @param array $customOption + * @param array $options * @return void */ - public function fillOption(array $customOption) + protected function fillOptions(array $options) { - foreach ($customOption['value'] as $key => $attributeValue) { - $select = $this->_rootElement->find( - sprintf($this->optionByName, $customOption['title']) . $customOption['selector'][$key], - Locator::SELECTOR_XPATH, - $customOption['input'] + foreach ($options as $option) { + $optionBlock = $this->_rootElement->find( + sprintf($this->optionByName, $option['title']), + Locator::SELECTOR_XPATH ); - $select->setValue($attributeValue); - } - } - - /** - * Set item data type selector - * - * @param int $count - * @param string $selector [optional] - * @return array - */ - protected function setDateTypeSelector($count, $selector = '') - { - $result = []; - $parent = ''; - for ($i = 0; $i < $count; $i++) { - if (!(($i + 1) % 4)) { - $parent = '//span'; + $type = $option['type']; + $mapping = $this->dataMapping([$type => $option['value']]); + + if ('radiobuttons' == $type || 'checkbox' == $type) { + $mapping[$type]['selector'] = str_replace( + '%option_name%', + $mapping[$type]['value'], + $mapping[$type]['selector'] + ); + $mapping[$type]['value'] = 'Yes'; } - $result[$i] = $selector . $parent . '//select[' . ($i % 3 + 1) . ']'; - } - - return $result; - } - - /** - * Choose custom option in a drop down - * - * @param string $title - * @param string|null $value [optional] - * @return void - */ - public function selectProductCustomOption($title, $value = null) - { - $select = $this->_rootElement->find( - sprintf($this->selectByTitleLocator, $title), - Locator::SELECTOR_XPATH, - 'select' - ); - - if (null === $value) { - $value = $select->find('.//option[@value != ""][1]', Locator::SELECTOR_XPATH)->getText(); + $this->_fill($mapping, $optionBlock); } - $select->setValue($value); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml index af94825cc49..e4de24ff1b9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.xml @@ -26,41 +26,90 @@ <mapping strict="0"> <fields> <dropdown> - <selector>//select</selector> + <selector>.//select</selector> <input>select</input> + <strategy>xpath</strategy> </dropdown> <multipleselect> - <selector>//select</selector> + <selector>.//select</selector> <input>multiselect</input> + <strategy>xpath</strategy> </multipleselect> <checkbox> - <selector>//div[label[span[contains(text(), "%option_name%")]]]/input</selector> + <selector>.//div[label[span[contains(text(), "%option_name%")]]]/input</selector> <input>checkbox</input> + <strategy>xpath</strategy> </checkbox> <radiobuttons> - <selector>//div[label[span[contains(text(), "%option_name%")]]]/input</selector> + <selector>.//div[label[span[contains(text(), "%option_name%")]]]/input</selector> <input>checkbox</input> + <strategy>xpath</strategy> </radiobuttons> - <date> - <selector /> - <input>select</input> + <date composite="1"> + <month> + <selector>[name$="[month]"]</selector> + <input>select</input> + </month> + <day> + <selector>[name$="[day]"]</selector> + <input>select</input> + </day> + <year> + <selector>[name$="[year]"]</selector> + <input>select</input> + </year> </date> - <datetime> - <selector /> - <input>select</input> + <datetime composite="1"> + <month> + <selector>[name$="[month]"]</selector> + <input>select</input> + </month> + <day> + <selector>[name$="[day]"]</selector> + <input>select</input> + </day> + <year> + <selector>[name$="[year]"]</selector> + <input>select</input> + </year> + <hour> + <selector>[name$="[hour]"]</selector> + <input>select</input> + </hour> + <minute> + <selector>[name$="[minute]"]</selector> + <input>select</input> + </minute> + <day_part> + <selector>[name$="[day_part]"]</selector> + <input>select</input> + </day_part> </datetime> - <time> - <selector /> - <input>select</input> + <time composite="1"> + <hour> + <selector>[name$="[hour]"]</selector> + <input>select</input> + </hour> + <minute> + <selector>[name$="[minute]"]</selector> + <input>select</input> + </minute> + <day_part> + <selector>[name$="[day_part]"]</selector> + <input>select</input> + </day_part> </time> <area> - <selector>//textarea</selector> + <selector>.//textarea</selector> + <strategy>xpath</strategy> </area> <file> - <selector>//input</selector> + <selector>.//input</selector> + <strategy>xpath</strategy> </file> <field> - <selector>//input</selector> + <selector>.//input</selector> + <strategy>xpath</strategy> </field> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php index 7e749999428..7544902d30f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php @@ -107,7 +107,7 @@ class AssertAddedProductAttributeOnProductForm extends AbstractConstraint : $productAttribute->getData(); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($catalogProductAttribute), + $productEdit->getProductForm()->checkAttributeLabel($catalogProductAttribute), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index a7e5badc39e..47e5c403b5c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -107,7 +107,7 @@ class AssertCategoryPage extends AbstractConstraint if (isset($categoryData['default_sort_by'])) { $sortBy = strtolower($categoryData['default_sort_by']); - $sortType = $categoryView->getToolbar()->getSelectSortType(); + $sortType = $categoryView->getTopToolbar()->getSelectSortType(); \PHPUnit_Framework_Assert::assertEquals( $sortBy, $sortType, @@ -126,7 +126,7 @@ class AssertCategoryPage extends AbstractConstraint ); if ($availableSortType) { $availableSortType = array_values($availableSortType); - $availableSortTypeOnPage = $categoryView->getToolbar()->getSortType(); + $availableSortTypeOnPage = $categoryView->getTopToolbar()->getSortType(); \PHPUnit_Framework_Assert::assertEquals( $availableSortType, $availableSortTypeOnPage, diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php index d7a7209b8e2..0d780437103 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInSearchOnProductForm.php @@ -28,7 +28,6 @@ use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; /** * Class AssertAbsenceInAddAttributeSearch @@ -60,7 +59,7 @@ class AssertProductAttributeAbsenceInSearchOnProductForm extends AbstractConstra $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); \PHPUnit_Framework_Assert::assertFalse( - $newProductPage->getForm()->checkAttributeInSearchAttributeForm($productAttribute), + $newProductPage->getProductForm()->checkAttributeInSearchAttributeForm($productAttribute), "Product attribute found in Attribute Search form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeDisplayingOnFrontend.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeDisplayingOnFrontend.php old mode 100644 new mode 100755 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php index c4473c4a498..eb8c9a4e873 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductCustomOptionsOnProductPage.php @@ -24,6 +24,7 @@ namespace Magento\Catalog\Test\Constraint; +use Mtf\ObjectManager; use Mtf\Client\Browser; use Mtf\Fixture\FixtureInterface; use Mtf\Constraint\AbstractAssertForm; @@ -106,46 +107,22 @@ class AssertProductCustomOptionsOnProductPage extends AbstractAssertForm */ public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, Browser $browser) { - $this->openProductPage($product, $browser); - // Prepare data - $formCustomOptions = $catalogProductView->getCustomOptionsBlock()->getOptions($product); - $actualPrice = $this->isPrice ? $this->getProductPrice($catalogProductView) : null; + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + + $actualPrice = null; + if ($this->isPrice) { + $prices = $catalogProductView->getViewBlock()->getPriceBlock()->getPrice(); + $actualPrice = isset($prices['price_special_price']) + ? $prices['price_special_price'] + : $prices['price_regular_price']; + } $fixtureCustomOptions = $this->prepareOptions($product, $actualPrice); + $formCustomOptions = $catalogProductView->getViewBlock()->getOptions($product)['custom_options']; $error = $this->verifyData($fixtureCustomOptions, $formCustomOptions); \PHPUnit_Framework_Assert::assertEmpty($error, $error); } - /** - * Get price from product page - * - * @param CatalogProductView $catalogProductView - * @return string - */ - protected function getProductPrice(CatalogProductView $catalogProductView) - { - $prices = $catalogProductView->getViewBlock()->getProductPriceBlock()->getPrice(); - $actualPrice = isset($prices['price_special_price']) - ? $prices['price_special_price'] - : $prices['price_regular_price']; - - return $actualPrice; - } - - /** - * Open product view page - * - * @param FixtureInterface $product - * @param Browser $browser - * @return void - */ - protected function openProductPage( - FixtureInterface $product, - Browser $browser - ) { - $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - } - /** * Preparation options before comparing * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php index 93defce60ad..db4d8cb3ce5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductDuplicateForm.php @@ -79,8 +79,8 @@ class AssertProductDuplicateForm extends AssertProductForm $filter = ['sku' => $product->getSku() . '-1']; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $formData = $productPage->getForm()->getData($product); - $fixtureData = $this->prepareFixtureData($product->getData(), $product); + $formData = $productPage->getProductForm()->getData($product); + $fixtureData = $this->prepareFixtureData($product->getData()); $errors = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); @@ -90,11 +90,10 @@ class AssertProductDuplicateForm extends AssertProductForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { $compareData = array_filter($data); @@ -117,16 +116,14 @@ class AssertProductDuplicateForm extends AssertProductForm $compareData['status'] = 'Product offline'; } if (isset($compareData['quantity_and_stock_status']['qty'])) { - $compareData['quantity_and_stock_status']['qty'] = ''; + $compareData['quantity_and_stock_status']['qty'] = 0; } if (isset($compareData['special_price'])) { $compareData['special_price'] = ['special_price' => $compareData['special_price']]; } $compareData['sku'] .= '-1'; - $compareData['quantity_and_stock_status']['is_in_stock'] = 'Out of Stock'; - unset($compareData['category_ids'], $compareData['id']); - return $compareData; + return parent::prepareFixtureData($compareData, $sortFields); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php index 46d4fe28d6f..37c0fa13078 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php @@ -34,6 +34,16 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; */ class AssertProductForm extends AbstractAssertForm { + /** + * List skipped fixture fields in verify + * + * @var array + */ + protected $skippedFixtureFields = [ + 'id', + 'checkout_data' + ]; + /** * Sort fields for fixture and form data * @@ -74,8 +84,13 @@ class AssertProductForm extends AbstractAssertForm $productGrid->open(); $productGrid->getProductGrid()->searchAndOpen($filter); - $fixtureData = $this->prepareFixtureData($product->getData(), $product, $this->sortFields); - $formData = $this->prepareFormData($productPage->getForm()->getData($product), $this->sortFields); + $productData = $product->getData(); + if ($product->hasData('custom_options')) { + $customOptionsSource = $product->getDataFieldConfig('custom_options')['source']; + $productData['custom_options'] = $customOptionsSource->getCustomOptions(); + } + $fixtureData = $this->prepareFixtureData($productData, $this->sortFields); + $formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields); $error = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertTrue(empty($error), $error); } @@ -84,18 +99,16 @@ class AssertProductForm extends AbstractAssertForm * Prepares fixture data for comparison * * @param array $data - * @param FixtureInterface $product * @param array $sortFields [optional] * @return array */ - protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = []) + protected function prepareFixtureData(array $data, array $sortFields = []) { + $data = array_diff_key($data, array_flip($this->skippedFixtureFields)); + if (isset($data['website_ids']) && !is_array($data['website_ids'])) { $data['website_ids'] = [$data['website_ids']]; } - if (isset($data['custom_options'])) { - $data['custom_options'] = $product->getDataFieldConfig('custom_options')['source']->getCustomOptions(); - } if (!empty($this->specialArray)) { $data = $this->prepareSpecialPriceArray($data); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php index 66096b71f5a..a50c602cee5 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCart.php @@ -32,6 +32,7 @@ use Magento\Catalog\Test\Page\Product\CatalogProductView; /** * Class AssertProductInCart + * Assertion that the product is correctly displayed in cart */ class AssertProductInCart extends AbstractConstraint { @@ -59,13 +60,7 @@ class AssertProductInCart extends AbstractConstraint ) { // Add product to cart $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $productOptions = $product->getCustomOptions(); - if ($productOptions) { - $customOption = $catalogProductView->getCustomOptionsBlock(); - $options = $customOption->getOptions(); - $key = $productOptions[0]['title']; - $customOption->selectProductCustomOption($options[$key]['title']); - } + $catalogProductView->getViewBlock()->fillOptions($product); $catalogProductView->getViewBlock()->clickAddToCart(); // Check price @@ -81,43 +76,39 @@ class AssertProductInCart extends AbstractConstraint */ protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart) { - $cartBlock = $checkoutCart->getCartBlock(); - $productName = $product->getName(); - $productOptions = $product->getCustomOptions(); - $priceComparing = $product->getPrice(); + $customOptions = $product->getCustomOptions(); + $checkoutData = $product->getCheckoutData(); + $checkoutCustomOptions = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : []; + $fixturePrice = $product->getPrice(); + $groupPrice = $product->getGroupPrice(); + $specialPrice = $product->getSpecialPrice(); + $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); + $formPrice = $cartItem->getPrice(); - if ($groupPrice = $product->getGroupPrice()) { + if ($groupPrice) { $groupPrice = reset($groupPrice); - $priceComparing = $groupPrice['price']; + $fixturePrice = $groupPrice['price']; } - - if ($specialPrice = $product->getSpecialPrice()) { - $priceComparing = $specialPrice; + if ($specialPrice) { + $fixturePrice = $specialPrice; } + $fixtureActualPrice = $fixturePrice; - if (!empty($productOptions)) { - $productOption = reset($productOptions); - $optionsData = reset($productOption['options']); - $optionName = $cartBlock->getCartItemOptionsNameByProductName($productName); - $optionValue = $cartBlock->getCartItemOptionsValueByProductName($productName); - - \PHPUnit_Framework_Assert::assertTrue( - trim($optionName) === $productOption['title'] - && trim($optionValue) === $optionsData['title'], - 'In the cart wrong option product.' - ); + foreach ($checkoutCustomOptions as $checkoutOption) { + $attributeKey = $checkoutOption['title']; + $optionKey = $checkoutOption['value']; + $option = $customOptions[$attributeKey]['options'][$optionKey]; - if ($optionsData['price_type'] === 'Percent') { - $priceComparing = $priceComparing * (1 + $optionsData['price'] / 100); + if ('Fixed' == $option['price_type']) { + $fixtureActualPrice += $option['price']; } else { - $priceComparing += $optionsData['price']; + $fixtureActualPrice += ($fixturePrice / 100) * $option['price']; } } - $price = $checkoutCart->getCartBlock()->getProductPriceByName($productName); \PHPUnit_Framework_Assert::assertEquals( - number_format($priceComparing, 2), - $price, + number_format($fixtureActualPrice, 2), + $formPrice, 'Product price in shopping cart is not correct.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php index 44909683986..9f352c5ce2e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInCategory.php @@ -67,7 +67,7 @@ class AssertProductInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php index b42fbe7453e..aa94f596bdb 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductInStock.php @@ -61,7 +61,7 @@ class AssertProductInStock extends AbstractConstraint \PHPUnit_Framework_Assert::assertEquals( self::STOCK_AVAILABILITY, $catalogProductView->getViewBlock()->stockAvailability(), - 'Control \'' . self::STOCK_AVAILABILITY . '\' is not visible.' + 'Control "' . self::STOCK_AVAILABILITY . '" is not visible.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php index a309cce5966..fab93fbed78 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductIsNotDisplayingOnFrontend.php @@ -162,7 +162,7 @@ class AssertProductIsNotDisplayingOnFrontend extends AbstractConstraint $this->cmsIndex->open(); $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $this->catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $this->catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $this->catalogCategoryView->getListProductBlock() ->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php index e8a88c5ae6b..a79bdd64060 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductNotVisibleInCategory.php @@ -64,7 +64,7 @@ class AssertProductNotVisibleInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } \PHPUnit_Framework_Assert::assertFalse( diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php index 1958984f661..9ea6b1e13d3 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php @@ -24,145 +24,191 @@ namespace Magento\Catalog\Test\Constraint; +use Mtf\ObjectManager; use Mtf\Client\Browser; -use Mtf\Fixture\FixtureInterface; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; /** * Class AssertProductPage + * Assert that displayed product data on product page(front-end) equals passed from fixture. */ -class AssertProductPage extends AbstractConstraint +class AssertProductPage extends AbstractAssertForm { /** - * Product fixture + * Product view block on frontend page * - * @var FixtureInterface + * @var \Magento\ConfigurableProduct\Test\Block\Product\View */ - protected $product; + protected $productView; /** - * Constraint severeness + * Product fixture * - * @var string + * @var ConfigurableProductInjectable */ - protected $severeness = 'low'; + protected $product; /** - * Error messages + * Constraint severeness * - * @var array + * @var string */ - protected $errorsMessages = [ - 'name' => '- product name on product view page is not correct.', - 'sku' => '- product sku on product view page is not correct.', - 'regular_price' => '- product regular price on product view page is not correct.', - 'short_description' => '- product short description on product view page is not correct.', - 'description' => '- product description on product view page is not correct.' - ]; + protected $severeness = 'middle'; /** - * Assertion that the product page is displayed correctly + * Assert that displayed product data on product page(front-end) equals passed from fixture: + * 1. Product Name + * 2. Price + * 3. Special price + * 4. SKU + * 5. Description + * 6. Short Description * - * @param CatalogProductView $catalogProductView * @param Browser $browser + * @param CatalogProductView $catalogProductView * @param FixtureInterface $product * @return void */ - public function processAssert(CatalogProductView $catalogProductView, Browser $browser, FixtureInterface $product) + public function processAssert(Browser $browser, CatalogProductView $catalogProductView, FixtureInterface $product) { - $this->product = $product; - // TODO fix initialization url for frontend page - //Open product view page $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $data = $this->prepareData($catalogProductView); - $badValues = array_diff($data['onPage'], $data['fixture']); - $errors = array_intersect_key($this->errorsMessages, array_keys($badValues)); - $errors += $this->verifySpecialPrice($catalogProductView); + $this->product = $product; + $this->productView = $catalogProductView->getViewBlock(); + + $errors = $this->verify(); \PHPUnit_Framework_Assert::assertEmpty( $errors, - PHP_EOL . 'Found the following errors:' . PHP_EOL . implode(' ' . PHP_EOL, $this->errorsMessages) + "\nFound the following errors:\n" . implode(" \n", $errors) ); } /** - * Prepare array for assert + * Verify displayed product data on product page(front-end) equals passed from fixture * - * @param CatalogProductView $catalogProductView * @return array */ - protected function prepareData(CatalogProductView $catalogProductView) + protected function verify() { - $viewBlock = $catalogProductView->getViewBlock(); - $price = $viewBlock->getProductPriceBlock()->getPrice(); - $data = [ - 'onPage' => [ - 'name' => $viewBlock->getProductName(), - 'sku' => $viewBlock->getProductSku(), - ], - 'fixture' => [ - 'name' => $this->product->getName(), - 'sku' => $this->product->getSku(), - ] - ]; - - list($priceOnPage, $priceFixture) = $this->preparePrice($price); - $data['onPage'] += $priceOnPage; - $data['fixture'] += $priceFixture; - - if ($productShortDescription = $this->product->getShortDescription()) { - $data['fixture']['short_description'] = $productShortDescription; - $data['onPage']['short_description'] = $viewBlock->getProductShortDescription(); - } - if ($productDescription = $this->product->getDescription()) { - $data['fixture']['description'] = $productDescription; - $data['onPage']['description'] = $viewBlock->getProductDescription(); - } + $errors = []; - return $data; + $errors[] = $this->verifyName(); + $errors[] = $this->verifyPrice(); + $errors[] = $this->verifySpecialPrice(); + $errors[] = $this->verifySku(); + $errors[] = $this->verifyDescription(); + $errors[] = $this->verifyShortDescription(); + + return array_filter($errors); } /** - * Prepare Price data + * Verify displayed product name on product page(front-end) equals passed from fixture * - * @param array $price - * @return array + * @return string|null */ - protected function preparePrice($price) + protected function verifyName() { - return [ - ['regular_price' => $price['price_regular_price']], - ['regular_price' => number_format($this->product->getPrice(), 2)] - ]; + $fixtureProductName = $this->product->getName(); + $formProductName = $this->productView->getProductName(); + + if ($fixtureProductName == $formProductName) { + return null; + } + return "Displayed product name on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductName}, expected: {$fixtureProductName}."; } /** - * Checking the special product price + * Verify displayed product price on product page(front-end) equals passed from fixture * - * @param CatalogProductView $catalogProductView - * @return array + * @return string|null + */ + protected function verifyPrice() + { + $fixtureProductPrice = number_format($this->product->getPrice(), 2); + $formProductPrice = $this->productView->getPriceBlock()->getRegularPrice(); + + if ($fixtureProductPrice == $formProductPrice) { + return null; + } + return "Displayed product price on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductPrice}, expected: {$fixtureProductPrice}."; + } + + /** + * Verify displayed product special price on product page(front-end) equals passed from fixture + * + * @return string|null */ - protected function verifySpecialPrice(CatalogProductView $catalogProductView) + protected function verifySpecialPrice() { - $priceBlock = $catalogProductView->getViewBlock()->getProductPriceBlock(); - $price = $priceBlock->isVisible() ? $priceBlock->getPrice() : ['price_special_price' => null]; - $priceComparing = false; + $fixtureProductSpecialPrice = $this->product->getSpecialPrice(); + if (!$fixtureProductSpecialPrice) { + return null; + } - if ($specialPrice = $this->product->getSpecialPrice()) { - $priceComparing = $specialPrice; + $fixtureProductSpecialPrice = number_format($fixtureProductSpecialPrice, 2); + $formProductSpecialPrice = $this->productView->getPriceBlock()->getSpecialPrice(); + if ($fixtureProductSpecialPrice == $formProductSpecialPrice) { + return null; } - if ($groupPrice = $this->product->getGroupPrice()) { - $groupPrice = reset($groupPrice); - $priceComparing = $groupPrice['price']; + return "Displayed product special price on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductSpecialPrice}, expected: {$fixtureProductSpecialPrice}."; + } + + /** + * Verify displayed product sku on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifySku() + { + $fixtureProductSku = $this->product->getSku(); + $formProductSku = $this->productView->getProductSku(); + + if ($fixtureProductSku == $formProductSku) { + return null; } - if ($priceComparing && isset($price['price_special_price']) - && number_format($priceComparing, 2) !== $price['price_special_price'] - ) { - return ['special_price' => '- product special price on product view page is not correct.']; + return "Displayed product sku on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductSku}, expected: {$fixtureProductSku}."; + } + + /** + * Verify displayed product description on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyDescription() + { + $fixtureProductDescription = $this->product->getDescription(); + $formProductDescription = $this->productView->getProductDescription(); + + if ($fixtureProductDescription == $formProductDescription) { + return null; } + return "Displayed product description on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductDescription}, expected: {$fixtureProductDescription}."; + } - return []; + /** + * Verify displayed product short description on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyShortDescription() + { + $fixtureProductShortDescription = $this->product->getShortDescription(); + $formProductShortDescription = $this->productView->getProductShortDescription(); + + if ($fixtureProductShortDescription == $formProductShortDescription) { + return null; + } + return "Displayed product short description on product page(front-end) not equals passed from fixture. " + . "Actual: {$formProductShortDescription}, expected: {$fixtureProductShortDescription}."; } /** @@ -172,6 +218,6 @@ class AssertProductPage extends AbstractConstraint */ public function toString() { - return 'Product on product view page is not correct.'; + return 'Product on product view page is correct.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php index db48a737ccb..d12d85f57d7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductSearchableBySku.php @@ -80,7 +80,7 @@ class AssertProductSearchableBySku extends AbstractConstraint : null; $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); - while (!$isVisible && $catalogSearchResult->getToolbar()->nextPage()) { + while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php index 492294e88ed..690e7d2045a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateGroupOnProductForm.php @@ -72,7 +72,7 @@ class AssertProductTemplateGroupOnProductForm extends AbstractConstraint $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode( @@ -87,13 +87,13 @@ class AssertProductTemplateGroupOnProductForm extends AbstractConstraint $productBlockForm->fill($productSimple); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->isTabVisible($attributeSet->getGroup()), + $productEdit->getProductForm()->isTabVisible($attributeSet->getGroup()), "Product Group is absent on Product form tabs." ); - $productEdit->getForm()->openCustomTab($attributeSet->getGroup()); + $productEdit->getProductForm()->openCustomTab($attributeSet->getGroup()); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($productAttributeOriginal), + $productEdit->getProductForm()->checkAttributeLabel($productAttributeOriginal), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php index c0b365a1e1f..3c902550d6d 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductTemplateOnProductForm.php @@ -73,7 +73,7 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); /**@var CatalogProductSimple $catalogProductSimple */ $productSimple = $fixtureFactory->createByCode( @@ -86,9 +86,9 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint ] ); $productBlockForm->fill($productSimple); - $newProductPage->getFormAction()->save(); + $newProductPage->getFormPageActions()->save(); - $formData = $productEdit->getForm()->getData($productSimple); + $formData = $productEdit->getProductForm()->getData($productSimple); $formAttributeSet = $formData['attribute_set_id']; \PHPUnit_Framework_Assert::assertEquals( $attributeSet->getAttributeSetName(), @@ -99,10 +99,10 @@ class AssertProductTemplateOnProductForm extends AbstractConstraint ); if ($attributeSetOriginal === null) { - $productEdit->getForm()->openTab('product-details'); + $productEdit->getProductForm()->openTab('product-details'); \PHPUnit_Framework_Assert::assertTrue( - $productEdit->getForm()->checkAttributeLabel($productAttribute), + $productEdit->getProductForm()->checkAttributeLabel($productAttribute), "Product Attribute is absent on Product form." ); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php index 8927be881d6..5037a3c3be1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductView.php @@ -71,7 +71,7 @@ class AssertProductView extends AbstractConstraint protected function assertOnProductView(CatalogProductSimple $product, CatalogProductView $catalogProductView) { $viewBlock = $catalogProductView->getViewBlock(); - $price = $viewBlock->getProductPriceBlock()->getPrice(); + $price = $viewBlock->getPriceBlock()->getPrice(); $name = $viewBlock->getProductName(); $sku = $viewBlock->getProductSku(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php index da0b9f38421..64f8ccfd363 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductVisibleInCategory.php @@ -78,7 +78,7 @@ class AssertProductVisibleInCategory extends AbstractConstraint $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) { + while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php old mode 100644 new mode 100755 index 49576b99733..52dad8b9bb5 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogAttributeSet/AssignedAttributes.php @@ -33,6 +33,7 @@ use Magento\Catalog\Test\Fixture\CatalogProductAttribute; * * Data keys: * - presets + * - attributes */ class AssignedAttributes implements FixtureInterface { @@ -66,13 +67,19 @@ class AssignedAttributes implements FixtureInterface public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; - if (isset($data['presets']) && $data['presets'] !== '-') { + if (isset($data['presets']) && is_string($data['presets'])) { $presets = explode(',', $data['presets']); foreach ($presets as $preset) { /** @var CatalogProductAttribute $attribute */ $attribute = $fixtureFactory->createByCode('catalogProductAttribute', ['dataSet' => $preset]); $attribute->persist(); + $this->data[] = $attribute->getAttributeCode(); + $this->attributes[] = $attribute; + } + } elseif (isset($data['attributes']) && is_array($data['attributes'])) { + foreach ($data['attributes'] as $attribute) { + /** @var CatalogProductAttribute $attribute */ $this->data[] = $attribute->getAttributeCode(); $this->attributes[] = $attribute; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php index bb614003f83..ec87b10f042 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.php @@ -560,4 +560,9 @@ class CatalogProductAttribute extends InjectableFixture { return $this->getData('search_weight'); } + + public function getOptions() + { + return $this->getData('options'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml index 8a690570411..d4ae55aa028 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductAttribute.xml @@ -287,6 +287,15 @@ <default_value>1</default_value> <input></input> </search_weight> + <options> + <attribute_code>options</attribute_code> + <backend_type>smallint</backend_type> + <is_required></is_required> + <default_value></default_value> + <input></input> + <source>\Magento\Catalog\Test\Fixture\CatalogProductAttribute\Options</source> + <group>manage-options</group> + </options> </fields> <repository_class>Magento\Catalog\Test\Repository\CatalogProductAttribute</repository_class> <handler_interface>Magento\Catalog\Test\Handler\CatalogProductAttribute\CatalogAttributeEntityInterface</handler_interface> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php index f029c62865b..cc5c4476db5 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.php @@ -89,6 +89,7 @@ class CatalogProductSimple extends InjectableFixture } protected $dataConfig = [ + 'type_id' => 'simple', 'create_url_params' => [ 'type' => 'simple', 'set' => '4', @@ -549,6 +550,12 @@ class CatalogProductSimple extends InjectableFixture 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\AttributeSetId', ]; + protected $attributes = [ + 'attribute_code' => 'attributes', + 'backend_type' => 'virtual', + 'group' => 'product-details', + ]; + protected $custom_options = [ 'attribute_code' => 'custom_options', 'backend_type' => 'virtual', @@ -597,6 +604,13 @@ class CatalogProductSimple extends InjectableFixture 'group' => 'advanced-inventory' ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData' + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -862,6 +876,11 @@ class CatalogProductSimple extends InjectableFixture return $this->getData('attribute_set_id'); } + public function getAttribute() + { + return $this->getData('attributes'); + } + public function getCustomOptions() { return $this->getData('custom_options'); @@ -887,8 +906,13 @@ class CatalogProductSimple extends InjectableFixture return $this->getData('news_to_date'); } - public function getStockDate() + public function getStockData() { return $this->getData('stock_data'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml index 8f88072b983..659821b132b 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml @@ -432,6 +432,11 @@ <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\AttributeSetId</source> <group>product-details</group> </attribute_set_id> + <attributes> + <attribute_code>attributes</attribute_code> + <backend_type>virtual</backend_type> + <group>product-details</group> + </attributes> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> @@ -459,6 +464,12 @@ <backend_type>virtual</backend_type> <group>advanced-inventory</group> </stock_data> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php index 884b098f388..8780e106d91 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/CheckoutData.php @@ -28,17 +28,26 @@ use Mtf\Fixture\FixtureInterface; /** * Class CheckoutData + * Data for fill product form on frontend + * * Data keys: * - preset (Checkout data verification preset name) */ class CheckoutData implements FixtureInterface { /** - * Current preset + * Data set configuration settings * - * @var string + * @var array */ - protected $currentPreset; + protected $params; + + /** + * Prepared dataSet data + * + * @var array + */ + protected $data; /** * @constructor @@ -48,9 +57,10 @@ class CheckoutData implements FixtureInterface public function __construct(array $params, array $data = []) { $this->params = $params; - $this->data = (isset($data['value']) && $data['value'] != '-') ? $data['value'] : null; - if (isset($data['preset'])) { - $this->currentPreset = $data['preset']; + $this->data = isset($data['preset']) ? $this->getPreset($data['preset']) : []; + + if (isset($data['value'])) { + $this->data = array_replace_recursive($this->data, $data['value']); } } @@ -90,14 +100,52 @@ class CheckoutData implements FixtureInterface /** * Return array preset * + * @param string $name * @return array|null */ - public function getPreset() + protected function getPreset($name) { - $presets = []; - if (!isset($presets[$this->currentPreset])) { - return null; - } - return $presets[$this->currentPreset]; + $presets = [ + 'MAGETWO-23062' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 0 + ] + ] + ], + 'MAGETWO-23063' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 0 + ] + ] + ], + 'options-suite' => [ + 'custom_options' => [ + [ + 'title' => 0, + 'value' => 'Field value 1 %isolation%' + ], + [ + 'title' => 1, + 'value' => 'Field value 2 %isolation%' + ], + [ + 'title' => 2, + 'value' => 1 + ], + [ + 'title' => 3, + 'value' => 0 + ] + ] + ], + 'order_default' => [ + 'qty' => 2 + ] + ]; + return isset($presets[$name]) ? $presets[$name] : null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php index 44b724c2135..041ae5ba679 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.php @@ -72,6 +72,9 @@ class CatalogProductVirtual extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -82,10 +85,6 @@ class CatalogProductVirtual extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php index 54a9275c6b6..94d0b6b3caf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CrosssellProducts.php @@ -24,9 +24,10 @@ namespace Magento\Catalog\Test\Fixture; -use Mtf\System\Config; use Mtf\Factory\Factory; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Crosssell; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Related; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Upsell; class CrosssellProducts extends AssignProducts { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php index a74300f52ce..daa44f21022 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product.php @@ -162,7 +162,7 @@ class Product extends DataFixture ->getMagentoDownloadableDownloadableProductLinksNotPurchasedSeparately(); break; case 'configurable': - $product = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $product = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); break; default: throw new \InvalidArgumentException( diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php index 96c3edb4b72..a191a6283df 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ProductAttribute.php @@ -45,9 +45,9 @@ class ProductAttribute extends DataFixture * * @return string */ - public function getAttributeLabel() + public function getFrontendLabel() { - return $this->getData('fields/attribute_label/value'); + return $this->getData('fields/frontend_label/value'); } /** @@ -131,7 +131,7 @@ class ProductAttribute extends DataFixture 'value' => 'attribute_code_%isolation%', 'group' => self::GROUP_PRODUCT_ATTRIBUTE_MAIN, ), - 'attribute_label' => array( + 'frontend_label' => array( 'value' => 'Attribute %isolation%', 'input_name' => 'frontend_label[0]', 'group' => self::GROUP_PRODUCT_ATTRIBUTE_MAIN diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php index 5731eaf803a..040cce24086 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/SimpleProduct.php @@ -26,6 +26,10 @@ namespace Magento\Catalog\Test\Fixture; use Mtf\Factory\Factory; use Mtf\System\Config; +/** + * Class SimpleProduct + * Fixture simple product + */ class SimpleProduct extends Product { const PRICE_VALUE = 'price.value'; @@ -36,7 +40,7 @@ class SimpleProduct extends Product * @param Config $configuration * @param array $placeholders */ - public function __construct(Config $configuration, $placeholders = array()) + public function __construct(Config $configuration, $placeholders = []) { $this->_placeholders[self::PRICE_VALUE] = 10; @@ -49,12 +53,12 @@ class SimpleProduct extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ 'constraint' => 'Success', - 'grid_filter' => array('name'), - 'create_url_params' => array('type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID), + 'grid_filter' => ['name'], + 'create_url_params' => ['type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product' - ); + ]; $data = $this->_getPreparedData(); $this->_data['fields'] = array_merge($this->_data['fields'], $data); @@ -72,43 +76,43 @@ class SimpleProduct extends Product */ protected function _getPreparedData() { - return array( - 'price' => array( + return [ + 'price' => [ 'value' => '%' . self::PRICE_VALUE . '%', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'tax_class_id' => array( + ], + 'tax_class_id' => [ 'value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => 1000, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][qty]' - ), - 'quantity_and_stock_status' => array( + ], + 'quantity_and_stock_status' => [ 'value' => 'In Stock', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][is_in_stock]' - ), - 'weight' => array('value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS), - 'product_website_1' => array( + ], + 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], + 'product_website_1' => [ 'value' => 'Yes', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'product[website_ids][]' - ), - 'inventory_manage_stock' => array( + ], + 'inventory_manage_stock' => [ 'value' => 'No', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_INVENTORY, 'input' => 'select', 'input_name' => 'product[stock_data][manage_stock]' - ), - ); + ], + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index f2d5662eb7f..afd59f648f0 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -58,7 +58,10 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface 'Yes' => 1, 'No' => 0, ], - + 'is_configurable' => [ + 'Yes' => 1, + 'No' => 0, + ], ]; /** @@ -70,7 +73,6 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface */ public function persist(FixtureInterface $fixture = null) { - $data = $this->replaceMappingData($fixture->getData()); $data['frontend_label'] = [0 => $data['frontend_label']]; 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 old mode 100644 new mode 100755 index 82523cf8cec..b50bb378285 --- 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 @@ -161,6 +161,7 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface protected function prepareData(FixtureInterface $fixture, $prefix = null) { $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']->getTaxClassId(); @@ -201,6 +202,12 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface $fields['attribute_set_id'] = $attributeSetId; } + // Prepare assigned attribute + if (isset($fields['attributes'])) { + $fields += $fields['attributes']; + unset($fields['attributes']); + } + $fields = $this->prepareStockData($fields); $fields = $prefix ? [$prefix => $fields] : $fields; if ($isCustomOptions) { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php index 8d0d5918fca..386e9301881 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Ui.php @@ -50,9 +50,8 @@ class Ui extends AbstractUi implements CatalogProductSimpleInterface 'set' => $fixture->getDataConfig()['create_url_params']['set'] ]); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($fixture); - $createProductPage->getFormAction()->save(); + $createProductPage->getProductForm()->fill($fixture); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php index 727d560c875..1552bdb046f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Ui/CreateProduct.php @@ -50,9 +50,8 @@ class CreateProduct extends Ui 'set' => $fixture->getDataConfig()['create_url_params']['set'] ]); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($fixture); - $createProductPage->getFormAction()->save(); + $createProductPage->getProductForm()->fill($fixture); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml index f07500d222d..9cb150f6ab4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductEdit.xml @@ -25,30 +25,20 @@ --> <page mca="catalog/product/edit" module="Magento_Catalog"> <blocks> - <form> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </form> - <productForm> - <class>Magento\Catalog\Test\Block\Backend\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </productForm> - <configurableProductForm> - <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableProductForm> - <formAction> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> - <locator>.page-main-actions</locator> - <strategy>css selector</strategy> - </formAction> <messagesBlock> <class>Magento\Core\Test\Block\Messages</class> <locator>#messages .messages</locator> <strategy>css selector</strategy> </messagesBlock> + <formPageActions> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <productForm> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml index 3aed3088b93..a56bb9d5359 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductNew.xml @@ -25,35 +25,20 @@ --> <page mca="catalog/product/new" module="Magento_Catalog"> <blocks> - <form> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </form> - <productForm> - <class>Magento\Catalog\Test\Block\Backend\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </productForm> - <configurableProductForm> - <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableProductForm> - <formAction> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> - <locator>.page-main-actions</locator> - <strategy>css selector</strategy> - </formAction> - <affectedAttributeSetForm> - <class>Magento\Catalog\Test\Block\Adminhtml\Product\AffectedAttributeSetForm</class> - <locator>#affected-attribute-set-form</locator> - <strategy>css selector</strategy> - </affectedAttributeSetForm> <messagesBlock> <class>Magento\Core\Test\Block\Messages</class> <locator>#messages .messages</locator> <strategy>css selector</strategy> </messagesBlock> + <formPageActions> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </formPageActions> + <productForm> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm</class> + <locator>[id="page:main-container"]</locator> + <strategy>css selector</strategy> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml index 611c03b7e9b..c569c0952f5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetAdd.xml @@ -26,7 +26,7 @@ <page mca="catalog/product_set/add" module="Magento_Catalog"> <blocks> <pageActions> - <class>Magento\Backend\Test\Block\FormPageActions</class> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\FormPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActions> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml index e41ef0bf185..99e2db0b472 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml @@ -32,7 +32,7 @@ </pageActions> <attributeSetEditBlock> <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\Main</class> - <locator>#tree-div2</locator> + <locator>.attribute-set</locator> <strategy>css selector</strategy> </attributeSetEditBlock> <attributeSetEditForm> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml index d11ced488d6..3ae56b70273 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetIndex.xml @@ -31,7 +31,7 @@ <strategy>css selector</strategy> </messagesBlock> <pageActionsBlock> - <class>Magento\Backend\Test\Block\GridPageActions</class> + <class>Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Set\GridPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActionsBlock> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index cefcabc57ab..6fea5f301b1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -40,11 +40,16 @@ <locator>.block.filter</locator> <strategy>css selector</strategy> </layeredNavigationBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> - <locator>.toolbar-products</locator> - <strategy>css selector</strategy> - </toolbar> + <topToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\TopToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][1]</locator> + <strategy>xpath</strategy> + </topToolbar> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][2]</locator> + <strategy>xpath</strategy> + </bottomToolbar> <titleBlock> <class>Magento\Theme\Test\Block\Html\Title</class> <locator>.page-title h1.title .base</locator> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php old mode 100644 new mode 100755 index fd546ebee5d..7c79a7148b4 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.php @@ -54,6 +54,7 @@ class CatalogProductAttribute extends AbstractRepository 'attribute_code' => 'attribute_dropdown%isolation%', 'frontend_input' => 'Dropdown', 'is_required' => 'No', + 'is_configurable' => 'Yes', 'options' => [ [ 'is_default' => 'Yes', @@ -72,5 +73,40 @@ class CatalogProductAttribute extends AbstractRepository ] ] ]; + + $this->_data['attribute_type_dropdown_two_options'] = [ + 'frontend_label' => 'attribute_dropdown%isolation%', + 'attribute_code' => 'attribute_dropdown%isolation%', + 'frontend_input' => 'Dropdown', + 'is_required' => 'No', + 'is_configurable' => 'Yes', + 'options' => [ + [ + 'is_default' => 'Yes', + 'admin' => 'black', + 'view' => 'option_0_%isolation%', + ], + [ + 'is_default' => 'No', + 'admin' => 'white', + 'view' => 'option_1_%isolation%', + ] + ] + ]; + + $this->_data['attribute_type_dropdown_one_option'] = [ + 'frontend_label' => 'attribute_dropdown%isolation%', + 'attribute_code' => 'attribute_dropdown%isolation%', + 'frontend_input' => 'Dropdown', + 'is_required' => 'No', + 'is_configurable' => 'Yes', + 'options' => [ + [ + 'is_default' => 'Yes', + 'admin' => 'black', + 'view' => 'option_0_%isolation%', + ], + ] + ]; } } 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 b770f0bbc73..e115de5eaf6 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 @@ -56,6 +56,7 @@ class CatalogProductSimple extends AbstractRepository 'tax_class_id' => ['dataSet' => 'Taxable Goods'], 'website_ids' => ['Main Website'], 'visibility' => 'Catalog, Search', + 'checkout_data' => ['preset' => 'order_default'], ]; $this->_data['100_dollar_product'] = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php index c3095b53af8..b9766e52dae 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/SimpleProduct.php @@ -28,6 +28,7 @@ use Magento\Catalog\Test\Fixture; /** * Class Product Repository * + * Data for create simple product */ class SimpleProduct extends Product { @@ -48,14 +49,14 @@ class SimpleProduct extends Product /** * {inheritdoc} */ - public function __construct(array $defaultConfig = array(), array $defaultData = array()) + public function __construct(array $defaultConfig = [], array $defaultData = []) { parent::__construct($defaultConfig, $defaultData); $this->_data[self::ADVANCED_INVENTORY] = $this->getSimpleAdvancedInventory(); - $this->_data[self::NEW_CATEGORY] = array( + $this->_data[self::NEW_CATEGORY] = [ 'config' => $defaultConfig, 'data' => $this->buildSimpleWithNewCategoryData($defaultData) - ); + ]; $this->_data[self::ADVANCED_PRICING] = $this->getSimpleAdvancedPricing(); $this->_data[self::CUSTOM_OPTIONS] = $this->getSimpleCustomOption(); $this->_data[self::SIMPLE_WITH_MAP] = $this->getSimpleAppliedMap($defaultData); @@ -70,18 +71,18 @@ class SimpleProduct extends Product */ protected function buildSimpleWithNewCategoryData($defaultData) { - return array( - 'category_new' => array( - 'category_name' => array('value' => 'New category %isolation%'), - 'parent_category' => array('value' => 'Default') - ), + return [ + 'category_new' => [ + 'category_name' => ['value' => 'New category %isolation%'], + 'parent_category' => ['value' => 'Default'] + ], 'category_name' => '%category::getCategoryName%', 'category_id' => '%category::getCategoryId%', 'fields' => array_intersect_key( $defaultData['fields'], - array_flip(array('name', 'sku', 'price', 'weight', 'product_website_1')) + array_flip(['name', 'sku', 'price', 'weight', 'product_website_1']) ) - ); + ]; } /** @@ -91,14 +92,14 @@ class SimpleProduct extends Product */ protected function getSimpleAdvancedInventory() { - $inventory = array( - 'data' => array( - 'fields' => array( - 'inventory_manage_stock' => array('value' => 'Yes', 'input_value' => '1'), - 'inventory_qty' => array('value' => 1, 'group' => Fixture\Product::GROUP_PRODUCT_INVENTORY) - ) - ) - ); + $inventory = [ + 'data' => [ + 'fields' => [ + 'inventory_manage_stock' => ['value' => 'Yes', 'input_value' => '1'], + 'inventory_qty' => ['value' => 1, 'group' => Fixture\Product::GROUP_PRODUCT_INVENTORY] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $inventory); unset($product['data']['fields']['qty']); @@ -112,13 +113,13 @@ class SimpleProduct extends Product */ protected function getSimpleAdvancedPricing() { - $pricing = array( - 'data' => array( - 'fields' => array( - 'special_price' => array('value' => '9', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING) - ) - ) - ); + $pricing = [ + 'data' => [ + 'fields' => [ + 'special_price' => ['value' => '9', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $pricing); return $product; @@ -132,13 +133,13 @@ class SimpleProduct extends Product { return array_replace_recursive( parent::resetRequiredFields($productType), - array( - 'data' => array( - 'fields' => array( - 'price' => array('value' => '1.99', 'group' => Fixture\Product::GROUP_PRODUCT_DETAILS) - ) - ) - ) + [ + 'data' => [ + 'fields' => [ + 'price' => ['value' => '1.99', 'group' => Fixture\Product::GROUP_PRODUCT_DETAILS] + ] + ] + ] ); } @@ -149,30 +150,30 @@ class SimpleProduct extends Product { return array_merge_recursive( $this->_data['simple'], - array( - 'data' => array( - 'fields' => array( - 'custom_options' => array( - 'value' => array( - array( + [ + 'data' => [ + 'fields' => [ + 'custom_options' => [ + 'value' => [ + [ 'title' => 'custom option drop down', 'is_require' => true, 'type' => 'Drop-down', - 'options' => array( - array( + 'options' => [ + [ 'title' => 'Title Drop - down 1', 'price' => 2.56, 'price_type' => 'Fixed', 'sku' => 'sku_drop_down_row_1' - ) - ) - ) - ), + ] + ] + ] + ], 'group' => Fixture\Product::GROUP_CUSTOM_OPTIONS - ) - ) - ) - ) + ] + ] + ] + ] ); } @@ -183,28 +184,28 @@ class SimpleProduct extends Product */ protected function getSimpleAppliedMap() { - $pricing = array( - 'data' => array( - 'fields' => array( - 'msrp_enabled' => array( + $pricing = [ + 'data' => [ + 'fields' => [ + 'msrp_enabled' => [ 'value' => 'Yes', 'input_value' => '1', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING, 'input' => 'select' - ), - 'msrp_display_actual_price_type' => array( + ], + 'msrp_display_actual_price_type' => [ 'value' => 'On Gesture', 'input_value' => '1', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING, 'input' => 'select' - ), - 'msrp' => array( + ], + 'msrp' => [ 'value' => '15', 'group' => Fixture\Product::GROUP_PRODUCT_PRICING - ) - ) - ) - ); + ] + ] + ] + ]; $product = array_replace_recursive($this->_data['simple'], $pricing); return $product; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php index 7e1fdc7b308..c3d8aae6597 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/AssignProductTest.php @@ -44,7 +44,7 @@ class AssignProductTest extends Functional $simple = Factory::getFixtureFactory()->getMagentoCatalogSimpleProduct(); $simple->switchData('simple_required'); $simple->persist(); - $configurable = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $configurable->switchData('configurable_required'); $configurable->persist(); $bundle = Factory::getFixtureFactory()->getMagentoBundleBundleFixed(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php index b23622a1eed..08d3bfb537a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateGroupedTest.php @@ -64,7 +64,7 @@ class CreateGroupedTest extends Functional $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('grouped'); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php index fb8b7e41f1b..de826502d30 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateProductTest.php @@ -60,7 +60,7 @@ class CreateProductTest extends Functional //Steps $createProductPage->open(['type' => 'simple', 'set' => 4]); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache $cachePage = Factory::getPageFactory()->getAdminCache(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php index 5e9f56d3634..d9f0e01a9da 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.php @@ -112,8 +112,7 @@ class CreateSimpleProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getGridPageActionBlock()->addProduct('simple'); - $productBlockForm = $this->newProductPage->getForm(); - $productBlockForm->fill($product, null, $category); - $this->newProductPage->getFormAction()->save(); + $this->newProductPage->getProductForm()->fill($product, null, $category); + $this->newProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv index 2741e51bef7..ea731e709c5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest/testCreate.csv @@ -1,19 +1,19 @@ -"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23062";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23063";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage";"" -"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" -"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage";"" +"product/data/name";"product/data/sku";"product/data/tax_class_id/dataSet";"product/data/price/value";"product/data/special_price";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/qty";"product/data/quantity_and_stock_status/is_in_stock";"product/data/visibility";"product/data/custom_options/preset";"product/data/checkout_data/preset";"product/data/custom_options/import_products";"product/data/price/preset";"product/data/group_price/preset";"product/data/tier_price/preset";"constraint";"issue" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10000";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"50";"657";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23062";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10001";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"51";"658";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23063";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10002";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"52";"659";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10003";"90";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"53";"660";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10004";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"54";"661";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10005";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"55";"662";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"MAGETWO-23055";"-";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10006";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"56";"663";"-";"-";"MAGETWO-23063";"MAGETWO-23063";"-";"MAGETWO-23030";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10007";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"57";"664";"-";"-";"MAGETWO-23062";"MAGETWO-23062";"-";"MAGETWO-23029";"-";"MAGETWO-23002";"assertProductSaveMessage, assertProductInGrid, assertProductInCategory, assertProductPage, assertProductInCart";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10008";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"58";"665";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductVisibleInCategory, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10009";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"59";"75";"In Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInStock";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10010";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"60";"0";"Out of Stock";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductOutOfStock";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10011";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"61";"138";"-";"Search";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductSearchableBySku";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10012";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"62";"139";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductSearchableBySku, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10013";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"63";"140";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10014";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"64";"141";"-";"-";"-";"-";"-";"-";"default";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductGroupedPriceOnProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"Taxable Goods";"10015";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"65";"142";"-";"-";"-";"-";"-";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductSpecialPriceOnProductPage";"" +"Simple Product %isolation%";"simple_sku_%isolation%";"None";"10016";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"66";"143";"-";"-";"-";"-";"-";"-";"-";"default";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductTierPriceOnProductPage";"Bug: MAGETWO-26853" +"Simple Product %isolation%";"simple_sku_%isolation%";"-";"10017";"-";"Simple Product short_description %isolation%";"Simple Product description %isolation%";"67";"144";"-";"-";"options-suite";"options-suite";"catalogProductSimple::with_two_custom_option,catalogProductSimple::with_all_custom_option";"-";"-";"-";"assertProductSaveMessage, assertProductInGrid, assertProductForm, assertProductInStock, assertProductVisibleInCategory, assertProductPage, assertProductCustomOptionsOnProductPage";"" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php index 6b011703794..cd9e03f0bc6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCategoryTest.php @@ -65,9 +65,9 @@ class CreateSimpleWithCategoryTest extends Functional //Steps $productListPage->open(); $addProductBlock->addProduct(); - $productForm->addNewCategory($product); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $productForm->addNewCategory($product); + $createProductPage->getFormPageActions()->save(); //Verifying $this->assertSuccessMessage("You saved the product."); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php index fc94695b1dc..9ec55181111 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleWithCustomOptionsAndCategoryTest.php @@ -56,7 +56,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $product->switchData('simple_custom_options'); //Data $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $productForm = $createProductPage->getForm(); + $productForm = $createProductPage->getProductForm(); //Steps $createProductPage->open([ 'type' => $product->getDataConfig()['create_url_params']['type'], @@ -64,7 +64,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional ]); $category = $product->getCategories()['category']; $productForm->fill($product, null, $category); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache @@ -88,7 +88,7 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $productGridPage->open(); /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Grid $gridBlock */ $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** @@ -116,11 +116,11 @@ class CreateSimpleWithCustomOptionsAndCategoryTest extends Functional $price = $productViewBlock->getProductPrice(); $this->assertEquals(number_format($product->getProductPrice(), 2), $price['price_regular_price']); - $productOptionsBlock = $productPage->getCustomOptionsBlock(); + $productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock(); $fixture = $product->getData('fields/custom_options/value'); - $actualOptions = $productOptionsBlock->getOptions(); + $actualOptions = $productOptionsBlock->getOptions($product); $this->assertCount(count($fixture), $actualOptions); - $this->assertTrue(isset($actualOptions[$fixture[0]['title']]['title'])); - $this->assertEquals($fixture[0]['title'], $actualOptions[$fixture[0]['title']]['title']); + $this->assertTrue(isset($actualOptions['custom_options'][$fixture[0]['title']]['options'][0]['title'])); + $this->assertEquals($fixture[0]['title'], $actualOptions['custom_options'][$fixture[0]['title']]['title']); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php index f13d99a5e02..3af413238f3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateTest.php @@ -63,7 +63,7 @@ class CreateTest extends Functional 'set' => $product->getDataConfig()['create_url_params']['set'] ]); $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache @@ -88,7 +88,7 @@ class CreateTest extends Functional $productGridPage->open(); /** @var \Magento\Catalog\Test\Block\Adminhtml\Product\Grid $gridBlock */ $gridBlock = $productGridPage->getProductGrid(); - $this->assertTrue($gridBlock->isRowVisible(array('sku' => $product->getProductSku()))); + $this->assertTrue($gridBlock->isRowVisible(['sku' => $product->getProductSku()])); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php index 74c3de84954..238d9c95d81 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.php @@ -106,8 +106,7 @@ class CreateVirtualProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getGridPageActionBlock()->addProduct('virtual'); - $productBlockForm = $this->newProductPage->getForm(); - $productBlockForm->fill($product, null, $category); - $this->newProductPage->getFormAction()->save(); + $this->newProductPage->getProductForm()->fill($product, null, $category); + $this->newProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php index aba1a617e0a..1c85047b1ee 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualTest.php @@ -60,7 +60,7 @@ class CreateVirtualTest extends Functional $productForm = $createProductPage->getProductForm(); //Steps $productForm->fill($product); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php index 48e0e1ff1e7..b2fd0411a43 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/EditSimpleProductTest.php @@ -66,14 +66,9 @@ class EditSimpleProductTest extends Functional $cachePage = Factory::getPageFactory()->getAdminCache(); $productGridPage->open(); - $gridBlock->searchAndOpen( - [ - 'sku' => $product->getProductSku(), - 'type' => 'Simple Product' - ] - ); + $gridBlock->searchAndOpen(['sku' => $product->getProductSku(), 'type' => 'Simple Product']); $productForm->fill($editProduct); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); // Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php index c6cf9dbd579..89ad44368f8 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UnassignCategoryTest.php @@ -61,7 +61,7 @@ class UnassignCategoryTest extends Functional $editProductPage->open(['id' => $simple->getProductId()]); $productForm = $editProductPage->getProductForm(); $productForm->clearCategorySelect(); - $editProductPage->getFormAction()->save(); + $editProductPage->getFormPageActions()->save(); //Verifying $editProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php index 2bf01a6dd0e..bdd82444458 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.php @@ -130,8 +130,7 @@ class UpdateSimpleProductEntityTest extends Injectable { $filter = ['sku' => $this->product->getSku()]; $this->productGrid->open()->getProductGrid()->searchAndOpen($filter); - $productBlockForm = $this->editProductPage->getForm(); - $productBlockForm->fill($product); - $this->editProductPage->getFormAction()->save(); + $this->editProductPage->getProductForm()->fill($product); + $this->editProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php index 1d3781e35c6..80f780cd37c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.php @@ -131,7 +131,7 @@ class UpdateVirtualProductEntityTest extends Injectable // Steps $this->productGrid->open(); $this->productGrid->getProductGrid()->searchAndOpen(['sku' => $this->product->getSku()]); - $this->editProductPage->getForm()->fill($product); - $this->editProductPage->getFormAction()->save(); + $this->editProductPage->getProductForm()->fill($product); + $this->editProductPage->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php index d434beda7b6..601cec2327f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php @@ -28,7 +28,7 @@ use Mtf\TestCase\Injectable; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; /** * Test Creation for Delete Used in Configurable ProductAttribute @@ -81,16 +81,16 @@ class DeleteUsedInConfigurableProductAttributeTest extends Injectable /** * Run Delete used in configurable product attribute test * - * @param CatalogProductConfigurable $product + * @param ConfigurableProductInjectable $product * @return array */ - public function test(CatalogProductConfigurable $product) + public function test(ConfigurableProductInjectable $product) { // Precondition $product->persist(); /** @var CatalogProductAttribute $attribute */ - $attribute = $product->getConfigurableAttributesData()['attributes'][0]; - + $attribute = $product->getDataFieldConfig('configurable_attributes_data')['source'] + ->getAttributes()['attribute_0']; // Steps $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv index 0641a3d880d..161f8dc5563 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest/test.csv @@ -1,2 +1,2 @@ "product/dataSet";"constraint" -"default_one_variation";"assertUsedSuperAttributeImpossibleDeleteMessages, assertProductAttributeInGrid, assertConfigurableProductForm" +"one_variation";"assertUsedSuperAttributeImpossibleDeleteMessages, assertProductAttributeInGrid, assertConfigurableProductForm" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml index b709c5df439..25e94d915d6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/constraint.xml @@ -95,7 +95,7 @@ </require> </assertProductInCart> <assertProductPage module="Magento_Catalog"> - <severeness>low</severeness> + <severeness>middle</severeness> <require> <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> <product class="Mtf\Fixture\FixtureInterface" /> @@ -403,9 +403,6 @@ <assertProductAttributeAbsenceInUnassignedAttributes module="Magento_Catalog"> <severeness>low</severeness> </assertProductAttributeAbsenceInUnassignedAttributes> - <assertProductAttributeAbsenceInVariationsSearch module="Magento_Catalog"> - <severeness>low</severeness> - </assertProductAttributeAbsenceInVariationsSearch> <assertProductDuplicateMessage module="Magento_Catalog"> <severeness>high</severeness> <require> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml index 5a98b6e3602..42c47d2b968 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml @@ -59,41 +59,6 @@ <input_prefix>product</input_prefix> </data_config> </catalogProductSimple> - <catalogProductConfigurable module="Magento_Catalog"> - <type>eav</type> - <entity_type>catalog_product</entity_type> - <product_type>configurable</product_type> - <collection>Magento\Catalog\Model\Resource\Product\Collection</collection> - <identifier>sku</identifier> - <fields> - <id> - <attribute_code>id</attribute_code> - <backend_type>virtual</backend_type> - </id> - <type_id> - <attribute_code>type_id</attribute_code> - <backend_type>virtual</backend_type> - </type_id> - <attribute_set_id> - <attribute_code>attribute_set_id</attribute_code> - <backend_type>virtual</backend_type> - </attribute_set_id> - </fields> - <data_set> - <sku /> - <name /> - <short_description /> - <description /> - <tax_class_id /> - </data_set> - <data_config> - <create_url_params> - <type>configurable</type> - <set>4</set> - </create_url_params> - <input_prefix>product</input_prefix> - </data_config> - </catalogProductConfigurable> <catalogProductVirtual module="Magento_Catalog"> <type>eav</type> <entity_type>catalog_product</entity_type> 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 d5659735afb..5f451dac7ee 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 @@ -95,7 +95,7 @@ class AssertAdvancedSearchProductsResult extends AbstractConstraint /** @var CatalogProductSimple $product */ $name = $product->getName(); $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($product->getName()); - while (!$isProductVisible && $resultPage->getToolbar()->nextPage()) { + while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($product->getName()); } if (!$isProductVisible) { diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php index cb4b1d9a822..96486d72dc0 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertCatalogSearchResult.php @@ -53,7 +53,7 @@ class AssertCatalogSearchResult extends AbstractConstraint foreach ($products as $product) { $name = $product->getName(); $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($name); - while (!$isProductVisible && $resultPage->getToolbar()->nextPage()) { + while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->isProductVisible($name); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml index 043d2ac4954..1595b810500 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedResult.xml @@ -30,11 +30,11 @@ <locator>.column.main</locator> <strategy>css selector</strategy> </searchResultBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> <locator>.column.main</locator> <strategy>css selector</strategy> - </toolbar> + </bottomToolbar> <listProductBlock> <class>Magento\Catalog\Test\Block\Product\ListProduct</class> <locator>.search.results</locator> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml index efc42a591f7..4e639b2039e 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/CatalogsearchResult.xml @@ -30,10 +30,10 @@ <locator>.search.results</locator> <strategy>css selector</strategy> </listProductBlock> - <toolbar> - <class>Magento\Catalog\Test\Block\Product\ProductList\Toolbar</class> - <locator>.toolbar.products</locator> - <strategy>css selector</strategy> - </toolbar> + <bottomToolbar> + <class>Magento\Catalog\Test\Block\Product\ProductList\BottomToolbar</class> + <locator>.//*[contains(@class,"toolbar-products")][2]</locator> + <strategy>xpath</strategy> + </bottomToolbar> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php index 7c5c437ef25..b91c88f1ed0 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchTest.php @@ -30,7 +30,6 @@ use Mtf\TestCase\Functional; /** * Class AdvancedSearchTest * Searching product in the Frontend via advanced search - * */ class AdvancedSearchTest extends Functional { @@ -41,6 +40,7 @@ class AdvancedSearchTest extends Functional */ public function testProductSearch() { + $this->markTestIncomplete('MAGETWO-27664'); //Data $productFixture = Factory::getFixtureFactory()->getMagentoCatalogSimpleProduct(); $productFixture->switchData('simple'); 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 fdf1e8c4aa5..22278d1c4aa 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 @@ -21,15 +21,13 @@ * @copyright Copyright (c) 2014 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\Test\Block; use Exception; use Mtf\Block\Block; use Mtf\Factory\Factory; use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\Product; -use Magento\Catalog\Test\Fixture\SimpleProduct; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; use Magento\Checkout\Test\Block\Onepage\Link; use Mtf\Fixture\FixtureInterface; @@ -39,40 +37,28 @@ use Mtf\Fixture\FixtureInterface; */ class Cart extends Block { + // @codingStandardsIgnoreStart /** - * Proceed to checkout block - * - * @var string - */ - protected $onepageLinkBlock = '.action.primary.checkout'; - - /** - * 'Clear Shopping Cart' button - * - * @var string - */ - protected $clearShoppingCart = '#empty_cart_button'; - - /** - * Cart item sub-total xpath selector + * Selector for cart item block * * @var string */ - protected $itemSubTotalSelector = '//td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + protected $cartItemByProductName = './/tr[contains(@class,"item-info") and (.//*[contains(@class,"product-item-name")]/a[.="%s"])]'; + // @codingStandardsIgnoreEnd /** - * Cart item unit price xpath selector + * Proceed to checkout block * * @var string */ - protected $itemUnitPriceSelector = '//td[@class="col price"]//*[@class="excl tax"]//span[@class="price"]'; + protected $onepageLinkBlock = '.action.primary.checkout'; /** - * Unit Price value + * 'Clear Shopping Cart' button * * @var string */ - protected $cartProductPrice = '//tr[string(td/div/strong/a)="%s"]/td[@class="col price"]/*[@class="excl tax"]/span'; + protected $clearShoppingCart = '#empty_cart_button'; /** * 'Update Shopping Cart' button @@ -82,115 +68,21 @@ class Cart extends Block protected $updateShoppingCart = '[name="update_cart_action"]'; /** - * Quantity input selector - * - * @var string - */ - protected $productQty = '//input[@type="number" and @title="Qty"]'; - - /** - * Cart item selector - * - * @var string - */ - protected $cartItem = './/tr[td//*[contains(.,"%s")]]'; - - /** - * Get bundle options - * - * @var string - */ - protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; - - /** - * Get sub-total for the specified item in the cart - * - * @param SimpleProduct $product - * @return string - */ - public function getCartItemSubTotal($product) - { - $selector = sprintf($this->cartItem, $this->getProductName($product)) . $this->itemSubTotalSelector; - return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get sub-total for the specified item in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemSubTotalByProductName($productName) - { - $selector = sprintf($this->cartItem, $productName) . $this->itemSubTotalSelector; - $itemSubtotal = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($itemSubtotal); - } - - /** - * Get unit price for the specified item in the cart + * Get cart item block * * @param FixtureInterface $product - * @param string $currency - * @return float + * @return \Magento\Checkout\Test\Block\Cart\CartItem */ - public function getCartItemUnitPrice($product, $currency = '$') + public function getCartItem(FixtureInterface $product) { - $selector = sprintf($this->cartItem, $this->getProductName($product)) . $this->itemUnitPriceSelector; - $prices = explode("\n", trim($this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText())); - return floatval(trim($prices[0], $currency)); - } - - /** - * Get product options in the cart - * - * @param Product $product - * @return string - */ - public function getCartItemOptions($product) - { - $selector = '//tr[string(td/div/strong/a)="' . $this->getProductName($product) - . '"]//dl[@class="cart item options"]'; - - $optionsBlock = $this->_rootElement->find($selector, Locator::SELECTOR_XPATH); - if (!$optionsBlock->isVisible()) { - return ''; - } - return $optionsBlock->getText(); - } - - /** - * Get product options value in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemOptionsNameByProductName($productName) - { - $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()) { - return ''; - } - return $optionsBlock->getText(); - } - - /** - * Get product options value in the cart by product name - * - * @param string $productName - * @return string - */ - public function getCartItemOptionsValueByProductName($productName) - { - $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()) { - return ''; - } - return $optionsBlock->getText(); + $cartItem = $this->_rootElement->find( + sprintf($this->cartItemByProductName, $product->getName()), + Locator::SELECTOR_XPATH + ); + return $this->blockFactory->create( + 'Magento\Checkout\Test\Block\Cart\CartItem', + ['element' => $cartItem] + ); } /** @@ -218,7 +110,6 @@ class Cart extends Block /** * Returns the total discount price * - * @var string * @return string * @throws Exception */ @@ -252,46 +143,12 @@ class Cart extends Block /** * Check if a product has been successfully added to the cart * - * @param Product $product - * @return boolean - */ - public function isProductInShoppingCart($product) - { - return $this->_rootElement->find( - sprintf($this->cartItem, $this->getProductName($product)), - Locator::SELECTOR_XPATH - )->isVisible(); - } - - /** - * Return the name of the specified product. - * * @param FixtureInterface $product - * @return string - */ - private function getProductName($product) - { - $productName = $product->getName(); - if ($product instanceof ConfigurableProduct) { - $productOptions = $product->getProductOptions(); - if (!empty($productOptions)) { - $productName = $productName . '")] and *[contains(.,"' . current($productOptions); - } - } - return $productName; - } - - /** - * Get product price "Unit Price" by product name - * - * @param $productName - * @return string + * @return boolean */ - public function getProductPriceByName($productName) + public function isProductInShoppingCart(FixtureInterface $product) { - $priceSelector = sprintf($this->cartProductPrice, $productName); - $cartProductPrice = $this->_rootElement->find($priceSelector, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($cartProductPrice); + return $this->getCartItem($product)->isVisible(); } /** @@ -303,55 +160,4 @@ class Cart extends Block { $this->_rootElement->find($this->updateShoppingCart, Locator::SELECTOR_CSS)->click(); } - - /** - * Set product quantity - * - * @param string $productName - * @param int $qty - * @return void - */ - public function setProductQty($productName, $qty) - { - $productQtySelector = sprintf($this->cartItem, $productName) . $this->productQty; - $this->_rootElement->find($productQtySelector, Locator::SELECTOR_XPATH)->setValue($qty); - } - - /** - * Get product quantity - * - * @param string $productName - * @return string - */ - public function getProductQty($productName) - { - $productQtySelector = sprintf($this->cartItem, $productName) . $this->productQty; - return $this->_rootElement->find($productQtySelector, Locator::SELECTOR_XPATH)->getValue(); - } - - /** - * Method that escapes currency symbols - * - * @param string $price - * @return string - */ - protected function escapeCurrency($price) - { - preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); - return (isset($matches[1])) ? $matches[1] : null; - } - - /** - * Get item Bundle options - * - * @param int $index - * @param int $itemIndex - * @param string $currency - * @return string - */ - public function getPriceBundleOptions($index, $itemIndex = 1, $currency = '$') - { - $formatPrice = sprintf($this->bundleOptions, $index, $itemIndex); - return trim($this->_rootElement->find($formatPrice, Locator::SELECTOR_XPATH)->getText(), $currency); - } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php new file mode 100755 index 00000000000..6e5090d9e72 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Block\Cart; + +use Mtf\Block\Block; +use Mtf\Client\Element\Locator; + +/** + * Class CartItem + * Product item block on checkout page + */ +class CartItem extends Block +{ + /** + * Selector for options block + * + * @var string + */ + protected $optionsBlock = './/dl[@class="cart-item-options"]'; + + /** + * Selector for unit price + * + * @var string + */ + protected $price = './/td[@class="col price"]/*[@class="excl tax"]/span'; + + /** + * Quantity input selector + * + * @var string + */ + protected $qty = './/input[@type="number" and @title="Qty"]'; + + /** + * Cart item sub-total xpath selector + * + * @var string + */ + protected $subtotalPrice = './/td[@class="col subtotal"]//*[@class="excl tax"]//span[@class="price"]'; + + /** + * Get bundle options + * + * @var string + */ + protected $bundleOptions = './/dl[contains(@class, "cart-item-options")]/dd[%d]/span[@class="price"][%d]'; + + /** + * Get product price + * + * @return string + */ + public function getPrice() + { + $cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($cartProductPrice); + } + + /** + * Set product quantity + * + * @param int $qty + * @return void + */ + public function setQty($qty) + { + $this->_rootElement->find($this->qty, Locator::SELECTOR_XPATH)->setValue($qty); + } + + /** + * Get product quantity + * + * @return string + */ + public function getQty() + { + return $this->_rootElement->find($this->qty, Locator::SELECTOR_XPATH)->getValue(); + } + + /** + * Get sub-total for the specified item in the cart + * + * @return string + */ + public function getSubtotalPrice() + { + $price = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($price); + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } + + /** + * Get product options in the cart + * + * @return string + */ + public function getOptions() + { + $optionsBlock = $this->_rootElement->find($this->optionsBlock, Locator::SELECTOR_XPATH); + if (!$optionsBlock->isVisible()) { + return ''; + } + return $optionsBlock->getText(); + } + + /** + * Get product options name in the cart + * + * @return string + */ + public function getOptionsName() + { + $optionsName = $this->_rootElement->find($this->optionsBlock . '//dt', Locator::SELECTOR_XPATH); + if (!$optionsName->isVisible()) { + return ''; + } + return $optionsName->getText(); + } + + /** + * Get product options value in the cart + * + * @return string + */ + public function getOptionsValue() + { + $optionsValue = $this->_rootElement->find($this->optionsBlock . '//dd', Locator::SELECTOR_XPATH); + if (!$optionsValue->isVisible()) { + return ''; + } + return $optionsValue->getText(); + } + + /** + * Get item Bundle options + * + * @param int $index + * @param int $itemIndex [optional] + * @param string $currency [optional] + * @return string + */ + public function getPriceBundleOptions($index, $itemIndex = 1, $currency = '$') + { + $formatPrice = sprintf($this->bundleOptions, $index, $itemIndex); + return trim($this->_rootElement->find($formatPrice, Locator::SELECTOR_XPATH)->getText(), $currency); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php old mode 100644 new mode 100755 index 96949593e8a..4dedaae48d8 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php @@ -54,7 +54,8 @@ class AssertPriceInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductPrice = $checkoutCart->open()->getCartBlock()->getProductPriceByName($product->getName()); + $checkoutCart->open(); + $cartProductPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); \PHPUnit_Framework_Assert::assertEquals( $cartProductPrice, $cart->getPrice(), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php old mode 100644 new mode 100755 index fa27cfce7b7..a2c800226f2 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php @@ -54,7 +54,8 @@ class AssertProductQtyInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductQty = $checkoutCart->open()->getCartBlock()->getProductQty($product->getName()); + $checkoutCart->open(); + $cartProductQty = $checkoutCart->getCartBlock()->getCartItem($product)->getQty(); \PHPUnit_Framework_Assert::assertEquals( $cartProductQty, $cart->getQty(), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php old mode 100644 new mode 100755 index c788bc26dcb..ceb3b5f45f1 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php @@ -54,8 +54,8 @@ class AssertSubtotalInShoppingCart extends AbstractConstraint Cart $cart, CatalogProductSimple $product ) { - $cartProductSubtotal = $checkoutCart->open()->getCartBlock() - ->getCartItemSubTotalByProductName($product->getName()); + $checkoutCart->open(); + $cartProductSubtotal = $checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPrice(); \PHPUnit_Framework_Assert::assertEquals( $cartProductSubtotal, $cart->getRowTotal(), 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 c348ea65ba8..24505b7d5c7 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/back/edit/active_tab/content_section/'; + protected $url = '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/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php old mode 100644 new mode 100755 similarity index 69% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php index 97788285960..db163a29a8f --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Block\Adminhtml\Product; +namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product; use Mtf\Client\Element; use Mtf\Client\Element\Locator; @@ -33,15 +33,8 @@ use Magento\Backend\Test\Block\Widget\Form as ParentForm; * Class AffectedAttributeSet * Choose affected attribute set dialog popup window */ -class AffectedAttributeSetForm extends ParentForm +class AffectedAttributeSet extends ParentForm { - /** - * 'Confirm' button container locator - * - * @var string - */ - protected $confirmButtonContainer = '//parent::div[div[@id="affected-attribute-set-form"]]'; - /** * 'Confirm' button locator * @@ -60,18 +53,21 @@ class AffectedAttributeSetForm extends ParentForm * Fill popup form * * @param FixtureInterface $product - * @param Element|null $element + * @param Element|null $element [optional] * @return $this */ public function fill(FixtureInterface $product, Element $element = null) { - $data = $product->getData('affect_configurable_product_attributes'); - if (!empty($data)) { - $this->_rootElement->find($this->affectedAttributeSetNew)->click(); - $fields = ['new_attribute_set_name' => strval($data)]; + $affectedAttributeSet = $product->getData('affected_attribute_set'); + + if ($affectedAttributeSet) { + $fields = ['new_attribute_set_name' => $affectedAttributeSet]; $mapping = $this->dataMapping($fields); + + $this->_rootElement->find($this->affectedAttributeSetNew)->click(); $this->_fill($mapping, $element); } + return $this; } @@ -82,16 +78,6 @@ class AffectedAttributeSetForm extends ParentForm */ public function confirm() { - $isVisible = $this->_rootElement->find( - $this->confirmButtonContainer . $this->confirmButton, - Locator::SELECTOR_XPATH - )->isVisible(); - - if ($isVisible) { - $this->_rootElement->find( - $this->confirmButtonContainer . $this->confirmButton, - Locator::SELECTOR_XPATH - )->click(); - } + $this->_rootElement->find($this->confirmButton, Locator::SELECTOR_XPATH)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.xml old mode 100644 new mode 100755 similarity index 100% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/AffectedAttributeSetForm.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AffectedAttributeSet.xml diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php deleted file mode 100644 index 2dba0bd3cbe..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Attribute.php +++ /dev/null @@ -1,140 +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\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; - -/** - * Class Attribute - * Attribute block in Variation section - */ -class Attribute extends Block -{ - /** - * Attribute option pricing value - * - * @var string - */ - protected $pricingValue = '[name*=pricing_value]'; - - /** - * Attribute option price type button - * - * @var string - */ - protected $priceTypeButton = '[data-toggle=dropdown]'; - - /** - * Attribute option price type value - * - * @var string - */ - protected $priceTypeValue = '//*[@data-role="dropdown-menu"]'; - - /** - * Attribute option Include checkbox - * - * @var string - */ - protected $include = '[data-column=include ] [type=checkbox]'; - - /** - * Attribute option Label - * - * @var string - */ - protected $labelValue = 'input[class=required-entry][name*=value]'; - - /** - * Attribute option row - * - * @var string - */ - protected $attributeRow = '//*[@data-role="options"]/tr[%row%]'; - - /** - * Add option selector - * - * @var string - */ - protected $addOption = '[data-action="add-option"]'; - - /** - * Fill in data to attribute options - * - * @param array $fields - */ - public function fillAttributeOptions(array $fields) - { - $row = 0; - foreach ($fields['options'] as $option) { - if (!empty($option['name'])) { - $optionRow = $this->getOptionRow($option['name']); - if (!$optionRow->isVisible()) { - $this->_rootElement->find($this->addOption)->click(); - $optionRow = $this->getOptionNewRow($row); - if (isset($option['name'])) { - $optionRow->find($this->labelValue)->setValue($option['name']); - } - } - if (isset($option['pricing_value'])) { - $optionRow->find($this->pricingValue, Locator::SELECTOR_CSS) - ->setValue($option['pricing_value']); - } - if (isset($option['is_percent']) && $option['is_percent'] == 'Yes') { - $optionRow->find($this->priceTypeButton, Locator::SELECTOR_CSS)->click(); - $optionRow->find($this->priceTypeValue . '//a[text()="%"]', Locator::SELECTOR_XPATH)->click(); - } - $optionRow->find($this->include, Locator::SELECTOR_CSS, 'checkbox') - ->setValue($option['include']); - } - ++$row; - } - } - - /** - * Get option row - * - * @param string $optionLabel - * @return Element - */ - protected function getOptionRow($optionLabel) - { - return $this->_rootElement->find('//tr[td="' . $optionLabel . '"]', Locator::SELECTOR_XPATH); - } - - /** - * Get option new row - * - * @param int $row - * @return Element - */ - protected function getOptionNewRow($row) - { - return $this->_rootElement->find(str_replace('%row%', $row, $this->attributeRow), Locator::SELECTOR_XPATH); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php old mode 100644 new mode 100755 index ebf6a8a5209..dbaf43e4e35 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -24,131 +24,43 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; -use Mtf\Client\Element; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; use Magento\Backend\Test\Block\Widget\Tab; +use Mtf\Client\Element; +use Magento\Catalog\Test\Fixture\CatalogCategory; /** - * Class Variations + * Class Config * Adminhtml catalog super product configurable tab */ class Config extends Tab { /** - * 'Generate Variations' button - * - * @var string - */ - protected $generateVariations = '[data-ui-id=product-variations-generator-generate]'; - - /** - * Product variations matrix block - * - * @var string - */ - protected $matrixBlock = '[data-role=product-variations-matrix] table'; - - /** - * Product attribute block selector by attribute name + * Selector for trigger show/hide "Variations" tab * * @var string */ - protected $attribute = '//div[*/*/span[contains(text(), "%s")]]'; + protected $variationsTabTrigger = '[data-panel="product-variations"] .title'; /** - * Magento loader + * Selector for content "Variations" tab * * @var string */ - protected $loader = './ancestor::body//*[contains(@data-role,"loader")]'; + protected $variationsTabContent = '#super_config-content'; /** - * Attribute Opened + * Selector for button "Generate Variations" * * @var string */ - protected $attributeOpen = './/*[@class = "title active"]/span[text()="%attributeLabel%"]'; + protected $generateVariations = '[data-ui-id="product-variations-generator-generate"]'; /** - * Attribute tab + * Selector for variations matrix * * @var string */ - protected $attributeTab = './/*[@data-role="configurable-attribute"]//*[text()="%attributeTab%"]'; - - /** - * XPath Selector attribute variations row content - * - * @var string - */ - protected $activeButtonSelector = '//*[contains(@class,"fieldset-wrapper-title")]//*[@class="title"]'; - - /** - * XPath Selector attribute variations row - * - * @var string - */ - protected $rowSelector = '//div[contains(@data-role,"configurable-attribute") and position()=%d]'; - - /** - * XPath Selector attribute options row - * - * @var string - */ - protected $rowOptions = './/tbody/tr[contains(@data-role,"option-container") and position()=%d]'; - - /** - * XPath Selector attribute options row - * - * @var string - */ - protected $rowMatrix = './/tbody/tr[contains(@data-role,"row") and position()=%d]'; - - /** - * CSS selector variations label - * - * @var string - */ - protected $labelSelector = '.store-label'; - - /** - * Get attribute block - * - * @param string $attributeName - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Attribute - */ - public function getAttributeBlock($attributeName) - { - $attributeSelector = sprintf($this->attribute, $attributeName); - $this->waitForElementVisible($attributeSelector, Locator::SELECTOR_XPATH); - return Factory::getBlockFactory()->getMagentoConfigurableProductAdminhtmlProductEditTabSuperAttribute( - $this->_rootElement->find($attributeSelector, Locator::SELECTOR_XPATH) - ); - } - - /** - * Get product variations matrix block - * - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix - */ - protected function getMatrixBlock() - { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlProductEditTabSuperConfigMatrix( - $this->_rootElement->find($this->matrixBlock, Locator::SELECTOR_CSS) - ); - } - - /** - * Press 'Generate Variations' button - * - * @return void - */ - public function generateVariations() - { - $this->_rootElement->find($this->generateVariations, Locator::SELECTOR_CSS)->click(); - $this->waitForElementVisible($this->matrixBlock, Locator::SELECTOR_CSS); - } + protected $variationsMatrix = '[data-role="product-variations-matrix"]'; /** * Fill variations fieldset @@ -159,146 +71,89 @@ class Config extends Tab */ public function fillFormTab(array $fields, Element $element = null) { - if (!isset($fields['configurable_attributes_data'])) { - return $this; - } - $attributes = $fields['configurable_attributes_data']['value']; - foreach ($attributes['attributes_data'] as $attribute) { - $this->selectAttribute($attribute['title']); + $attributes = isset($fields['configurable_attributes_data']['value']) + ? $fields['configurable_attributes_data']['value'] + : []; + + $this->showContent(); + + if (!empty($attributes['attributes_data'])) { + $this->getAttributeBlock()->fillAttributes($attributes['attributes_data']); } - $this->fillAttributeOptions($attributes); - $this->generateVariations(); if (!empty($attributes['matrix'])) { - $this->fillVariationsMatrix($attributes['matrix']); + $this->generateVariations(); + $this->getVariationsBlock()->fillVariations($attributes['matrix']); } return $this; } /** - * Fill variations matrix + * Show "Variations" tab content * - * @param array $fields * @return void */ - public function fillVariationsMatrix(array $fields) + public function showContent() { - $this->getMatrixBlock()->fillVariation($fields); + $content = $this->_rootElement->find($this->variationsTabContent); + if (!$content->isVisible()) { + $this->_rootElement->find($this->variationsTabTrigger)->click(); + $this->waitForElementVisible($this->variationsTabContent); + } } /** - * Fill attribute options + * Generate variations * - * @param array $attributes * @return void */ - public function fillAttributeOptions(array $attributes) + public function generateVariations() { - foreach ($attributes['attributes_data'] as $attribute) { - $this->getAttributeBlock($attribute['title'])->fillAttributeOptions($attribute); - } + $this->_rootElement->find($this->generateVariations)->click(); + $this->waitForElementVisible($this->variationsMatrix); } /** - * Select attribute for variations + * Get block of attributes * - * @param string $attributeName - * @return void + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute */ - private function selectAttribute($attributeName) + public function getAttributeBlock() { - // TODO should be removed after suggest widget implementation as typified element - $attributeFieldSet = $this->_rootElement - ->find(str_replace('%attributeLabel%', $attributeName, $this->attributeOpen), Locator::SELECTOR_XPATH); - $attributeVisible = $this->_rootElement - ->find(str_replace('%attributeTab%', $attributeName, $this->attributeTab), Locator::SELECTOR_XPATH); - if ($attributeVisible->isVisible()) { - if (!$attributeFieldSet->isVisible()) { - $attributeVisible->click(); - } - } else { - $this->_rootElement->find('#configurable-attribute-selector')->setValue($attributeName); - $attributeListLocation = '#variations-search-field .mage-suggest-dropdown'; - $this->waitForElementVisible($attributeListLocation, Locator::SELECTOR_CSS); - $attribute = $this->_rootElement->find( - "//div[@class='mage-suggest-dropdown']//a[text()='$attributeName']", - Locator::SELECTOR_XPATH - ); - $attribute->waitUntil( - function () use ($attribute) { - return $attribute->isVisible() ? true : null; - } - ); - $attribute->click(); - } + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute', + ['element' => $this->_rootElement] + ); } /** - * Get data of tab + * Get block of variations * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix */ - public function getDataFormTab($fields = null, Element $element = null) + public function getVariationsBlock() { - $dataResult = []; - if (isset($fields['configurable_attributes_data']['value']['attributes_data'])) { - $field['attributes_data']['value'] = $fields['configurable_attributes_data']['value']['attributes_data']; - $data = $this->dataMapping($field)['attributes_data']; - $variationsBlock = $this->_rootElement->find($data['selector']); - - foreach ($data['value'] as $key => $value) { - ++$key; - $this->openVariation($key, $variationsBlock); - $row = $variationsBlock->find(sprintf($this->rowSelector, $key), Locator::SELECTOR_XPATH); - --$key; - $dataResult['attributes_data'][$key]['title'] = $row->find($this->labelSelector)->getValue(); - $dataResult['attributes_data'][$key]['options'] = []; - foreach ($value['options'] as $optionKey => $option) { - ++$optionKey; - $optionsForm = $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Options', - ['element' => $row->find(sprintf($this->rowOptions, $optionKey), Locator::SELECTOR_XPATH)] - ); - $dataResult['attributes_data'][$key]['options'][] = $optionsForm->getDataOptions($option); - } - } - } - if (isset($fields['configurable_attributes_data']['value']['matrix'])) { - $field['matrix']['value'] = $fields['configurable_attributes_data']['value']['matrix']; - $data = $this->dataMapping($field)['matrix']; - $matrixBlock = $this->_rootElement->find($data['selector']); - - $index = 1; - foreach ($data['value'] as $key => $value) { - $matrixCell = $this->blockFactory->create( - 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Matrix', - ['element' => $matrixBlock->find(sprintf($this->rowMatrix, $index), Locator::SELECTOR_XPATH)] - ); - $dataResult['matrix'][$key] = $matrixCell->getDataOptions(); - ++$index; - } - } - - return ['configurable_attributes_data' => $dataResult]; + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Matrix', + ['element' => $this->_rootElement->find($this->variationsMatrix)] + ); } /** - * Active variation tab + * Get data of tab * - * @param int $row - * @param Element $variationsBlock - * @return void + * @param array|null $fields + * @param Element|null $element + * @return array */ - protected function openVariation($row, Element $variationsBlock) + public function getDataFormTab($fields = null, Element $element = null) { - $element = $variationsBlock->find( - sprintf($this->rowSelector, $row) . $this->activeButtonSelector, - Locator::SELECTOR_XPATH - ); - if ($element->isVisible()) { - $element->click(); - } + $data = []; + + $this->showContent(); + $data['attributes_data'] = $this->getAttributeBlock()->getAttributesData(); + $data['matrix'] = $this->getVariationsBlock()->getVariationsData(); + + return ['configurable_attributes_data' => $data]; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php new file mode 100755 index 00000000000..5dce160b4cc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.php @@ -0,0 +1,381 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; + +use Mtf\Client\Element\Locator; +use Mtf\Client\Driver\Selenium\Element; +use Magento\Backend\Test\Block\Widget\Form; +use Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\AttributeSelector; + +/** + * Class Attribute + * Attribute block in Variation section + */ +class Attribute extends Form +{ + /** + * Mapping fields for get values of form + * + * @var array + */ + protected $mappingGetFields = [ + 'label' => [ + 'selector' => 'td[data-column="name"]', + 'strategy' => Locator::SELECTOR_CSS + ] + ]; + + /** + * Variation search block + * + * @var string + */ + protected $variationSearchBlock = '#variations-search-field'; + + /** + * Selector for "Create New Variations Set" + * + * @var string + */ + protected $createNewVariationSet = '[data-ui-id$="add-attribute"]'; + + /** + * New attribute frame selector + * + * @var string + */ + protected $newAttributeFrame = '#create_new_attribute_container'; + + /** + * Selector for "New Attribute" block + * + * @var string + */ + protected $newAttribute = 'body'; + + /** + * Selector for "Save Attribute" button on "New Attribute" dialog window + * + * @var string + */ + protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; + + /** + * Selector attribute block by label + * + * @var string + */ + protected $attributeBlockByName = './/*[*/strong[contains(@class,"title") and contains(.,"%s")]]'; + + /** + * Selector for attribute block + * + * @var string + */ + protected $attributeBlock = '//div[@id="configurable-attributes-container"]/div[contains(@class,"entry-edit")][%d]'; + + /** + * Selector for "Add Option" button + * + * @var string + */ + protected $addOption = '[role="button"]'; + + /** + * Selector for option container + * + * @var string + */ + protected $optionContainer = './/tr[@data-role="option-container"]'; + + /** + * Selector for option container(row) by number + * + * @var string + */ + protected $optionContainerByNumber = './/tr[@data-role="option-container"][%d]'; + + /** + * Selector for attribute title + * + * @var string + */ + protected $attributeTitle = '.title > span'; + + /** + * Selector for attribute content + * + * @var string + */ + protected $attributeContent = '[id$="-content"]'; + + /** + * Selector for attribute label + * + * @var string + */ + protected $attributeLabel = '[name$="[label]"]'; + + /** + * Fill attributes + * + * @param array $attributes + * @return void + */ + public function fillAttributes(array $attributes) + { + foreach ($attributes as $attribute) { + $isExistAttribute = $this->isExistAttribute($attribute['frontend_label']); + + if (!$isExistAttribute && empty($attribute['attribute_id'])) { + $this->createNewVariationSet($attribute); + $this->fillOptions($attribute); + } else { + if (!$isExistAttribute) { + $this->getAttributeSelector()->setValue($attribute['frontend_label']); + } + $this->updateOptions($attribute); + } + } + } + + /** + * Create new variation set + * + * @param array $attribute + * @return void + */ + protected function createNewVariationSet(array $attribute) + { + $this->_rootElement->find($this->createNewVariationSet)->click(); + $this->browser->switchToFrame(new Locator($this->newAttributeFrame)); + + $newAttribute = $this->getEditAttributeForm(); + $newAttribute->getTabElement('properties')->fillFormTab($attribute); + $newAttribute->_rootElement->find($this->saveAttribute)->click(); + + $this->browser->switchToFrame(); + } + + /** + * Fill options + * + * @param array $attribute + * @return void + */ + protected function fillOptions(array $attribute) + { + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlockByName, $attribute['frontend_label']), + Locator::SELECTOR_XPATH + ); + $count = 0; + + $this->showAttributeContent($attributeBlock); + if (isset($attribute['label'])) { + $attributeBlock->find($this->attributeLabel)->setValue($attribute['label']); + } + foreach ($attribute['options'] as $option) { + $attributeBlock->find($this->addOption)->click(); + $count++; + $optionContainer = $attributeBlock->find( + sprintf($this->optionContainerByNumber, $count), + Locator::SELECTOR_XPATH + ); + + $mapping = $this->dataMapping($option); + $this->_fill($mapping, $optionContainer); + } + } + + /** + * Update options + * + * @param array $attribute + * @return void + */ + protected function updateOptions(array $attribute) + { + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlockByName, $attribute['frontend_label']), + Locator::SELECTOR_XPATH + ); + $count = 0; + + $this->showAttributeContent($attributeBlock); + if (isset($attribute['label'])) { + $attributeBlock->find($this->attributeLabel)->setValue($attribute['label']); + } + foreach ($attribute['options'] as $option) { + $count++; + $optionContainer = $attributeBlock->find( + sprintf($this->optionContainerByNumber, $count), + Locator::SELECTOR_XPATH + ); + + if (!$optionContainer->isVisible() && $this->isVisibleOption($attributeBlock, $count-1)) { + $attributeBlock->find($this->addOption)->click(); + } + $mapping = $this->dataMapping($option); + $this->_fill($mapping, $optionContainer); + } + } + + /** + * Check is visible option + * + * @param Element $attributeBlock + * @param int $number + * @return bool + */ + protected function isVisibleOption(Element $attributeBlock, $number) + { + return $attributeBlock->find( + sprintf($this->optionContainerByNumber, $number), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Get attribute form block + * + * @return \Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm + */ + protected function getEditAttributeForm() + { + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\AttributeForm', + ['element' => $this->browser->find($this->newAttribute)] + ); + } + + /** + * Get attribute selector element + * + * @return AttributeSelector + */ + public function getAttributeSelector() + { + return $this->_rootElement->find( + $this->variationSearchBlock, + Locator::SELECTOR_CSS, + 'Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\AttributeSelector' + ); + } + + /** + * Get attributes data + * + * @return array + */ + public function getAttributesData() + { + $data = []; + $optionMapping = $this->dataMapping(); + + $count = 1; + $attributeBlock = $this->_rootElement->find(sprintf($this->attributeBlock, $count), Locator::SELECTOR_XPATH); + while ($attributeBlock->isVisible()) { + $attribute = [ + 'frontend_label' => $attributeBlock->find($this->attributeTitle)->getText(), + 'label' => $attributeBlock->find($this->attributeLabel)->getValue(), + 'options' => [] + ]; + + /** @var Element $attributeBlock */ + $this->showAttributeContent($attributeBlock); + $options = $attributeBlock->find($this->optionContainer, Locator::SELECTOR_XPATH)->getElements(); + foreach ($options as $optionKey => $option) { + /** @var Element $option */ + if ($option->isVisible()) { + $attribute['options'][$optionKey] = $this->_getData($optionMapping, $option); + $attribute['options'][$optionKey] += $this->getOptionalFields($option); + } + } + $data[] = $attribute; + + ++$count; + $attributeBlock = $this->_rootElement->find( + sprintf($this->attributeBlock, $count), + Locator::SELECTOR_XPATH + ); + } + + return $data; + } + + /** + * Show attribute content + * + * @param Element $attribute + * @return void + */ + protected function showAttributeContent(Element $attribute) + { + if (!$attribute->find($this->attributeContent)->isVisible()) { + $attribute->find($this->attributeTitle)->click(); + + $browser = $attribute; + $selector = $this->attributeContent; + $browser->waitUntil( + function () use ($browser, $selector) { + return $browser->find($selector)->isVisible() ? true : null; + } + ); + } + } + + /** + * Check exist attribute by label + * + * @param string $label + * @return bool + */ + protected function isExistAttribute($label) + { + return $this->_rootElement->find( + sprintf($this->attributeBlockByName, $label), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Get optional fields + * + * @param Element $context + * @param array $fields + * @return array + */ + protected function getOptionalFields(Element $context, array $fields = []) + { + $data = []; + + $fields = empty($fields) ? $this->mappingGetFields : $fields; + foreach ($fields as $name => $params) { + $data[$name] = $context->find($params['selector'], $params['strategy'])->getText(); + } + return $data; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml old mode 100644 new mode 100755 similarity index 60% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml index 67da2d5734e..8c369a076a4 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute.xml @@ -25,26 +25,19 @@ --> <mapping strict="0"> <fields> - <display> - <selector>//*[@data-column='display']/input</selector> - <strategy>xpath</strategy> + <label> + <selector>[name$="[label]"]</selector> + </label> + <pricing_value> + <selector>[name$="[pricing_value]"]</selector> + </pricing_value> + <is_percent> + <selector>.field-pricing-measure</selector> + <input>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute\ToggleDropdown</input> + </is_percent> + <include> + <selector>.include[name$="[include]"]</selector> <input>checkbox</input> - </display> - <name> - <selector>//*[@data-column='name']/input</selector> - <strategy>xpath</strategy> - </name> - <sku> - <selector>//*[@data-column='sku']/input</selector> - <strategy>xpath</strategy> - </sku> - <qty> - <selector>//*[@data-column='qty']/input</selector> - <strategy>xpath</strategy> - </qty> - <weight> - <selector>//*[@data-column='weight']/input</selector> - <strategy>xpath</strategy> - </weight> + </include> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php new file mode 100755 index 00000000000..98c68ebb230 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/AttributeSelector.php @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute; + +use Mtf\Client\Element; +use Mtf\Client\Driver\Selenium\Element\SuggestElement; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class AttributeSelector + * Form Attribute Search on Product page + */ +class AttributeSelector extends SuggestElement +{ + /** + * Checking exist configurable attribute in search result + * + * @param CatalogProductAttribute $productAttribute + * @return bool + */ + public function isExistAttributeInSearchResult(CatalogProductAttribute $productAttribute) + { + return $this->isExistValueInSearchResult($productAttribute->getFrontendLabel()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.php new file mode 100755 index 00000000000..f7c5def0496 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Attribute/ToggleDropdown.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\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute; + +use Mtf\Client\Element\Locator; +use Mtf\Client\Driver\Selenium\Element; + +/** + * Class ToggleDropdown + * Class for toggle dropdown elements. + */ +class ToggleDropdown extends Element +{ + /** + * Selector for field value + * + * @var string + */ + protected $field = './/button/span'; + + /** + * Selector for list options + * + * @var string + */ + protected $listOptions = './/ul[@data-role="dropdown-menu"]'; + + /** + * Selector for search option by text + * + * @var string + */ + protected $optionByText = './/ul[@data-role="dropdown-menu"]/li/a[.="%s"]'; + + /** + * Set value + * + * @param string $value + * @return void + */ + public function setValue($value) + { + $this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); + + if ($value != $this->getValue()) { + $value = ('Yes' == $value) ? '%' : '$'; + + $this->find($this->field, Locator::SELECTOR_XPATH)->click(); + $this->waitListOptionsVisible(); + $this->find(sprintf($this->optionByText, $value), Locator::SELECTOR_XPATH)->click(); + } + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + $this->_eventManager->dispatchEvent(['get_value'], [(string)$this->_locator]); + + $value = $this->find($this->field, Locator::SELECTOR_XPATH)->getText(); + return ('%' == $value) ? 'Yes' : 'No'; + } + + /** + * Wait visible list options + * + * @return void + */ + protected function waitListOptionsVisible() + { + $browser = $this; + $selector = $this->listOptions; + $browser->waitUntil( + function () use ($browser, $selector) { + return $browser->find($selector, Locator::SELECTOR_XPATH)->isVisible() ? true : null; + } + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php old mode 100644 new mode 100755 index 60f6e94fbde..9892a82c763 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -24,51 +24,155 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config; -use Mtf\Block\Form; -use Mtf\Client\Element; +use Mtf\Client\Driver\Selenium\Element; use Mtf\Client\Element\Locator; +use Magento\Backend\Test\Block\Widget\Form; /** * Class Matrix - * Product variations matrix block + * Matrix row form */ class Matrix extends Form { /** - * Fill qty to current variations + * Mapping for get optional fields * - * @param array $variations + * @var array + */ + protected $mappingGetFields = [ + 'name' => [ + 'selector' => 'td[data-column="name"] > a', + 'strategy' => Locator::SELECTOR_CSS + ], + 'sku' => [ + 'selector' => 'td[data-column="sku"] > span', + 'strategy' => Locator::SELECTOR_CSS + ], + 'quantity_and_stock_status' => [ + 'composite' => 1, + 'fields' => [ + 'qty' => [ + 'selector' => 'td[data-column="qty"]', + 'strategy' => Locator::SELECTOR_CSS + ] + ] + ], + 'weight' => [ + 'selector' => 'td[data-column="weight"]', + 'strategy' => Locator::SELECTOR_CSS + ], + ]; + + /** + * Selector for variation row by number + * + * @var string + */ + protected $variationRowByNumber = './/tr[@data-role="row"][%d]'; + + /** + * Selector for variation row + * + * @var string + */ + protected $variationRow = './/tr[@data-role="row"]'; + + /** + * Button for assign product to variation + * + * @var string + */ + protected $configurableAttribute = 'td[data-column="name"] button.action-choose'; + + // @codingStandardsIgnoreStart + /** + * Selector for row on product grid by product id + * + * @var string + */ + protected $selectAssociatedProduct = '//ancestor::div[*[@id="associated-products-container"]]//td[@data-column="entity_id" and (contains(text(),"%s"))]'; + // @codingStandardsIgnoreEnd + + /** + * Fill variations + * + * @param array $matrix * @return void */ - public function fillVariation(array $variations) + public function fillVariations(array $matrix) { - foreach ($variations as $variation) { - $variationRow = $this->getVariationRow($variation['configurable_attribute']); - foreach ($variation['value'] as $key => $field) { - if (!empty($this->mapping[$key])) { - $this->_rootElement->find( - $variationRow . $this->mapping[$key]['selector'], - Locator::SELECTOR_XPATH, - isset($this->mapping[$key]['input']) ? $this->mapping[$key]['input'] : null - )->setValue($field['value']); - } + $count = 1; + foreach ($matrix as $variation) { + $variationRow = $this->_rootElement->find( + sprintf($this->variationRowByNumber, $count), + Locator::SELECTOR_XPATH + ); + $mapping = $this->dataMapping($variation); + + $this->_fill($mapping, $variationRow); + if (isset($variation['configurable_attribute'])) { + $this->assignProduct($variationRow, $variation['configurable_attribute']); } + + ++$count; } } /** - * Define row that clarifies which line in Current Variations grid will be used + * Assign product to variation matrix + * + * @param Element $variationRow + * @param int $productId + * @return void + */ + protected function assignProduct(Element $variationRow, $productId) + { + $variationRow->find($this->configurableAttribute)->click(); + $this->_rootElement->find( + sprintf($this->selectAssociatedProduct, $productId), + Locator::SELECTOR_XPATH + )->click(); + } + + /** + * Get variations data * - * @param array $variationData - * @return string + * @return array */ - private function getVariationRow(array $variationData) + public function getVariationsData() { - $options = array(); - foreach ($variationData as $attributeData) { - $options[] = 'td[text()="' . $attributeData['attribute_option'] . '"]'; + $data = []; + $variationRows = $this->_rootElement->find($this->variationRow, Locator::SELECTOR_XPATH)->getElements(); + + foreach ($variationRows as $key => $variationRow) { + /** @var Element $variationRow */ + if ($variationRow->isVisible()) { + $data[$key] = $this->_getData($this->dataMapping(), $variationRow); + $data[$key] += $this->getOptionalFields($variationRow, $this->mappingGetFields); + } } - return '//tr[' . implode(' and ', $options) . ']'; + return $data; + } + + /** + * Get optional fields + * + * @param Element $context + * @param array $fields + * @return array + */ + protected function getOptionalFields(Element $context, array $fields) + { + $data = []; + + foreach ($fields as $name => $params) { + if (isset($params['composite']) && $params['composite']) { + $data[$name] = $this->getOptionalFields($context, $params['fields']); + } else { + $data[$name] = $context->find($params['selector'], $params['strategy'])->getText(); + } + } + return $data; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml old mode 100644 new mode 100755 index 67da2d5734e..c4989e4edc6 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.xml @@ -26,25 +26,23 @@ <mapping strict="0"> <fields> <display> - <selector>//*[@data-column='display']/input</selector> - <strategy>xpath</strategy> + <selector>[name="associated_product_ids[]"]</selector> <input>checkbox</input> </display> <name> - <selector>//*[@data-column='name']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[name]"]</selector> </name> <sku> - <selector>//*[@data-column='sku']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[sku]"]</selector> </sku> - <qty> - <selector>//*[@data-column='qty']/input</selector> - <strategy>xpath</strategy> - </qty> + <quantity_and_stock_status composite="1"> + <qty> + <selector>[name$="[quantity_and_stock_status][qty]"]</selector> + </qty> + </quantity_and_stock_status> <weight> - <selector>//*[@data-column='weight']/input</selector> - <strategy>xpath</strategy> + <selector>[name$="[weight]"]</selector> </weight> </fields> </mapping> + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php deleted file mode 100644 index c0aecc288f0..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Matrix.php +++ /dev/null @@ -1,83 +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\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options as CatalogOptions; - -/** - * Class Matrix - * Matrix row form - */ -class Matrix extends CatalogOptions -{ - /** - * CSS selector data cell - * - * @var string - */ - protected $cellSelector = 'td:nth-child(%d)'; - - /** - * Field name mapping - * - * @var array - */ - protected $fieldNameMapping = [ - 3 => 'name', - 4 => 'sku', - 5 => 'price', - 6 => 'qty', - 7 => 'weight' - ]; - - /** - * Getting product matrix data form on the product form - * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array - */ - public function getDataOptions(array $fields = null, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $mapping = $this->dataMapping($fields); - $data = $this->_getData($mapping, $element); - - $column = 3; - $cell = $element->find(sprintf($this->cellSelector, $column)); - $data['options_names'] = []; - while ($cell->isVisible()) { - if (isset($this->fieldNameMapping[$column])) { - $data[$this->fieldNameMapping[$column]] = $cell->getText(); - } else { - $data['options_names'][] = $cell->getText(); - } - $cell = $element->find(sprintf($this->cellSelector, ++$column)); - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php deleted file mode 100644 index 3749a1d246b..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.php +++ /dev/null @@ -1,77 +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\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super; - -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options as CatalogOptions; - -/** - * Class Options - * Attribute options row form - */ -class Options extends CatalogOptions -{ - /** - * CSS selector name item - * - * @var string - */ - protected $nameSelector = 'td[data-column="name"]'; - - /** - * XPath selector percent label - * - * @var string - */ - protected $percentSelector = '//button[span[contains(text(),"%")]]'; - - /** - * Getting options data form on the product form - * - * @param array|null $fields [optional] - * @param Element|null $element [optional] - * @return array - */ - public function getDataOptions(array $fields = null, Element $element = null) - { - $element = $element === null ? $this->_rootElement : $element; - $mapping = $this->dataMapping($fields); - $data = $this->_getData($mapping, $element); - - $data['is_percent'] = 'No'; - $percentElement = $element->find($this->percentSelector, Locator::SELECTOR_XPATH); - if ($percentElement->isVisible()) { - $data['is_percent'] = 'Yes'; - } - - $nameElement = $element->find($this->nameSelector); - if ($nameElement->isVisible()) { - $data['name'] = $nameElement->getText(); - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.php new file mode 100755 index 00000000000..95a8f41fd8d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/FormPageActions.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\ConfigurableProduct\Test\Block\Adminhtml\Product; + +use Mtf\Client\Element\Locator; +use Mtf\Fixture\FixtureInterface; + +/** + * Class FormPageActions + * Page actions block on page + */ +class FormPageActions extends \Magento\Catalog\Test\Block\Adminhtml\Product\FormPageActions +{ + /** + * Selector for "Affected Attribute Set" popup form + * + * @var string + */ + protected $affectedAttributeSetForm = '//ancestor::body//div[div[@id="affected-attribute-set-form"]]'; + + /** + * Click on "Save" button + * + * @param FixtureInterface|null $product [optional] + * @return void + */ + public function save(FixtureInterface $product = null) + { + parent::save(); + $affectedAttributeSetForm = $this->getAffectedAttributeSetForm(); + if ($affectedAttributeSetForm->isVisible()) { + $affectedAttributeSetForm->fill($product)->confirm(); + } + } + + /** + * Get "Choose Affected Attribute Set" form + * + * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet + */ + protected function getAffectedAttributeSetForm() + { + return $this->blockFactory->create( + '\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\AffectedAttributeSet', + ['element' => $this->_rootElement->find($this->affectedAttributeSetForm, Locator::SELECTOR_XPATH)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php index 91238c1a295..278f35f2e4a 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.php @@ -24,166 +24,102 @@ namespace Magento\ConfigurableProduct\Test\Block\Adminhtml\Product; -use Mtf\Block\Mapper; use Mtf\Client\Element; -use Mtf\Client\Browser; -use Mtf\Factory\Factory; +use Magento\Backend\Test\Block\Widget\FormTabs; +use Mtf\Fixture\DataFixture; use Mtf\Fixture\FixtureInterface; -use Mtf\Util\XmlConverter; -use Mtf\Block\BlockFactory; -use Mtf\Client\Element\Locator; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm as ParentForm; +use Mtf\Fixture\InjectableFixture; /** * Class ProductForm * Product creation form */ -class ProductForm extends ParentForm +class ProductForm extends \Magento\Catalog\Test\Block\Adminhtml\Product\ProductForm { /** - * New attribute selector + * Fill the product form * - * @var string + * @param FixtureInterface $product + * @param Element|null $element [optional] + * @param FixtureInterface|null $category [optional] + * @return FormTabs */ - protected $newAttribute = 'body'; - - /** - * New attribute frame selector - * - * @var string - */ - protected $newAttributeFrame = '#create_new_attribute_container'; - - /** - * New variation set button selector - * - * @var string - */ - protected $newVariationSet = '[data-ui-id="admin-product-edit-tab-super-config-grid-container-add-attribute"]'; - - /** - * Variations tab selector - * - * @var string - */ - protected $productDetailsTab = '#product_info_tabs_product-details'; - - /** - * Choose affected attribute set dialog popup window - * - * @var string - */ - protected $affectedAttributeSet = "//div[div/@data-id='affected-attribute-set-selector']"; + public function fill(FixtureInterface $product, Element $element = null, FixtureInterface $category = null) + { + $tabs = $this->getFieldsByTabs($product); + ksort($tabs); - /** - * Variations tab selector - * - * @var string - */ - protected $variationsTab = '#product_info_tabs_super_config_content .title'; + if ($product instanceof DataFixture) { + $tabs = $this->normalizeDeprecateData($tabs); + $category = ($category === null) ? $product->getCategories()['category'] : $category; + } - /** - * Variations wrapper selector - * - * @var string - */ - protected $variationsWrapper = '#product_info_tabs_super_config_content'; + if ($category) { + $tabs['product-details']['category_ids']['value'] = ($category instanceof InjectableFixture ) + ? $category->getName() + : $category->getCategoryName(); + } - /** - * Get choose affected attribute set dialog popup window - * - * @return \Magento\ConfigurableProduct\Test\Block\Backend\Product\AffectedAttributeSet - */ - protected function getAffectedAttributeSetBlock() - { - return Factory::getBlockFactory()->getMagentoConfigurableProductBackendProductAffectedAttributeSet( - $this->_rootElement->find($this->affectedAttributeSet, Locator::SELECTOR_XPATH) - ); + $this->showAdvancedSettings(); + return $this->fillTabs($tabs, $element); } /** - * Get attribute edit block + * Normalize data in DataFixture * - * @return \Magento\ConfigurableProduct\Test\Block\Backend\Product\Attribute\Edit + * @param array $tabs + * @return array */ - public function getConfigurableAttributeEditBlock() + protected function normalizeDeprecateData(array $tabs) { - $this->browser->switchToFrame(new Locator($this->newAttributeFrame)); - return Factory::getBlockFactory()->getMagentoConfigurableProductBackendProductAttributeEdit( - $this->browser->find($this->newAttribute, Locator::SELECTOR_TAG_NAME) - ); - } - - /** - * Save product - * - * @param FixtureInterface $fixture - * @return \Magento\Backend\Test\Block\Widget\Form|void - */ - public function save(FixtureInterface $fixture = null) - { - parent::save($fixture); - if ($this->getAffectedAttributeSetBlock()->isVisible()) { - $this->getAffectedAttributeSetBlock()->chooseAttributeSet($fixture); + if (!isset($tabs['variations'])) { + return $tabs; } - } - /** - * Get variations block - * - * @return \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config - */ - protected function getVariationsBlock() - { - return Factory::getBlockFactory()->getMagentoConfigurableProductAdminhtmlProductEditTabSuperConfig( - $this->browser->find($this->variationsWrapper) - ); - } + $variations = $tabs['variations']; - /** - * Fill product variations - * - * @param array $variations - * @return void - */ - public function variationsFill(array $variations) - { - $variationsBlock = $this->getVariationsBlock(); - $variationsBlock->fillAttributeOptions($variations); - $variationsBlock->generateVariations(); - } + $attributesData = []; + if (isset($variations['configurable_attributes_data']['value'])) { + foreach ($variations['configurable_attributes_data']['value'] as $key => $attribute) { + $attributesData[$key] = [ + 'frontend_label' => $attribute['label']['value'] + ]; + unset($attribute['label']); - /** - * Open variations tab - * - * @return void - */ - public function openVariationsTab() - { - $this->_rootElement->find($this->variationsTab)->click(); - } + foreach ($attribute as $optionKey => $option) { + foreach ($option as $name => $field) { + $option[$name] = $field['value']; + } - /** - * Click on 'Create New Variation Set' button - * - * @return void - */ - public function clickCreateNewVariationSet() - { - $this->_rootElement->find($this->newVariationSet)->click(); - } + $option['label'] = $option['option_label']; + unset($option['option_label']); - /** - * Find Attribute on Product page - * - * @param string $attributeName - * @return bool - */ - public function findAttribute($attributeName) - { - $this->openTab('product-details'); + $attribute[$optionKey] = $option; + } + + + $attributesData[$key]['options'] = $attribute; + } + } + + $matrix = []; + if (isset($variations['variations-matrix'])) { + foreach ($variations['variations-matrix']['value'] as $key => $variation) { + foreach ($variation['value'] as $name => $field) { + $matrix[$key][$name] = $field['value']; + } + } + } - return $this->getVariationsBlock()->getAttributeBlock($attributeName)->isVisible(); + $tabs['variations'] = [ + 'configurable_attributes_data' => [ + 'value' => [ + 'attributes_data' => $attributesData, + 'matrix' => $matrix + ] + ] + ]; + unset($tabs['variations']['variations-matrix']); + return $tabs; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml old mode 100644 new mode 100755 index 68c9e8a73eb..90b68453348 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml @@ -24,46 +24,6 @@ */ --> <tabs> - <product-details> - <class>\Magento\Backend\Test\Block\Widget\Tab</class> - <selector>#product_info_tabs_product-details</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <tax_class_id> - <input>select</input> - </tax_class_id> - <is_virtual> - <input>checkbox</input> - </is_virtual> - <quantity_and_stock_status composite="1"> - <qty> - <selector>#qty</selector> - </qty> - <is_in_stock> - <selector>#quantity_and_stock_status</selector> - <input>select</input> - </is_in_stock> - </quantity_and_stock_status> - </fields> - </product-details> - <advanced-pricing> - <class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab</class> - <selector>#product_info_tabs_advanced-pricing</selector> - <strategy>css selector</strategy> - <wrapper>product</wrapper> - <fields> - <special_price> - <selector>[name='product[special_price]']</selector> - </special_price> - <group_price> - <input>select</input> - </group_price> - <tier_price> - <input>select</input> - </tier_price> - </fields> - </advanced-pricing> <variations> <class>\Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config</class> <selector>#product_info_tabs_product-details</selector> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php deleted file mode 100644 index 53fa7fbd1b5..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/AffectedAttributeSet.php +++ /dev/null @@ -1,73 +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\ConfigurableProduct\Test\Block\Backend\Product; - -use Mtf\Block\Block; -use Mtf\Client\Element; -use Mtf\Client\Element\Locator; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AffectedAttributeSet - * Choose affected attribute set dialog popup window - */ -class AffectedAttributeSet extends Block -{ - /** - * Create new attribute set based on default - * - * @var string - */ - protected $affectedAttributeSet = '[name=affected-attribute-set][value=new]'; - - /** - * New attribute set name - * - * @var string - */ - protected $attributeSetName = '[name=new-attribute-set-name]'; - - /** - * 'Confirm' button - * - * @var string - */ - protected $confirmButton = '[id*=confirm-button]'; - - /** - * Choose affected attribute set - * - * @param CatalogProductConfigurable $fixture - */ - public function chooseAttributeSet(CatalogProductConfigurable $fixture) - { - $attributeSetName = $fixture->getAttributeSetName(); - if ($attributeSetName) { - $this->_rootElement->find($this->affectedAttributeSet)->click(); - $this->_rootElement->find($this->attributeSetName)->setValue($attributeSetName); - } - $this->_rootElement->find($this->confirmButton)->click(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php deleted file mode 100644 index 81a2926052b..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.php +++ /dev/null @@ -1,108 +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\ConfigurableProduct\Test\Block\Backend\Product\Attribute; - -use Mtf\Client\Element; -use Magento\Backend\Test\Block\Widget\Form; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class Edit - * Product attribute edit page - */ -class Edit extends Form -{ - /** - * Frontend properties selector - * - * @var string - */ - protected $frontendProperties = '#front_fieldset-wrapper .title'; - - /** - * Save attribute selector - * - * @var string - */ - protected $saveAttribute = '[data-ui-id="attribute-edit-content-save-button"]'; - - /** - * 'Add new option' button selector - * - * @var string - */ - protected $addNewOption = '#add_new_option_button'; - - /** - * Attribute option row - * - * @var string - */ - protected $optionRow = '//*[@id="manage-options-panel"]//tbody//tr[%row%]'; - - /** - * Open frontend properties - * - * @return void - */ - public function openFrontendProperties() - { - $this->_rootElement->find($this->frontendProperties)->click(); - } - - /** - * Save attribute - * - * @return void - */ - public function saveAttribute() - { - $this->_rootElement->find($this->saveAttribute)->click(); - } - - /** - * Fill attribute options - * - * @param array $data - * @return void - */ - public function fillAttributeOption(array $data) - { - $this->_rootElement->find('#attribute_label') - ->setValue($data['attribute_options']['attribute_label']); - $this->_rootElement->find('#frontend_input', Element\Locator::SELECTOR_CSS, 'select') - ->setValue($data['attribute_options']['frontend_input']); - $this->_rootElement->find('#is_required', Element\Locator::SELECTOR_CSS, 'select') - ->setValue($data['attribute_options']['is_required']); - - $addButton = $this->_rootElement->find('#add_new_option_button'); - $table = $this->_rootElement->find('.data-table'); - foreach ($data['attribute_options']['options'] as $index => $value) { - $addButton->click(); - $table->find('[name="' . $index . '"]')->setValue($value); - } - $this->saveAttribute(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml deleted file mode 100644 index d604e00a11d..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Backend/Product/Attribute/Edit.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?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) - */ ---> -<mapping strict="0"> - <fields> - <attribute_label> - <selector>[name='frontend_label[0]']</selector> - </attribute_label> - <frontend_input> - <input>select</input> - </frontend_input> - <is_searchable> - <input>select</input> - </is_searchable> - <is_visible_in_advanced_search> - <input>select</input> - </is_visible_in_advanced_search> - <is_comparable> - <input>select</input> - </is_comparable> - <is_filterable> - <input>select</input> - </is_filterable> - <is_visible_on_front> - <input>select</input> - </is_visible_on_front> - <is_filterable_in_search> - <input>select</input> - </is_filterable_in_search> - </fields> -</mapping> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php new file mode 100644 index 00000000000..4cf100c22af --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View.php @@ -0,0 +1,125 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Block\Product; + +use Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class View + * Product view block on frontend page + */ +class View extends \Magento\Catalog\Test\Block\Product\View +{ + /** + * Get configurable options block + * + * @return ConfigurableOptions + */ + public function getConfigurableOptionsBlock() + { + return $this->blockFactory->create( + 'Magento\ConfigurableProduct\Test\Block\Product\View\ConfigurableOptions', + ['element' => $this->_rootElement] + ); + } + + /** + * Fill in the option specified for the product + * + * @param FixtureInterface $product + * @return void + */ + public function fillOptions(FixtureInterface $product) + { + if ($product instanceof InjectableFixture) { + /** @var ConfigurableProductInjectable $product */ + $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + $checkoutData = $product->getCheckoutData(); + + // Prepare attribute data + foreach ($attributesData as $attributeKey => $attribute) { + $attributesData[$attributeKey] = [ + 'type' => $attribute['frontend_input'], + 'title' => $attribute['label'], + 'options' => [], + ]; + + foreach ($attribute['options'] as $optionKey => $option) { + $attributesData[$attributeKey]['options'][$optionKey] = [ + 'title' => $option['label'] + ]; + } + } + } else { + // TODO: Removed after refactoring(removed) old product fixture. + /** @var ConfigurableProduct $product */ + $attributesData = $product->getConfigurableAttributes(); + $checkoutData = $product->getCheckoutData(); + + // Prepare attributes data + foreach ($attributesData as $attributeKey => $attribute) { + $attributesData[$attributeKey] = [ + 'type' => 'dropdown', + 'title' => $attribute['label']['value'] + ]; + + unset($attribute['label']); + foreach ($attribute as $optionKey => $option) { + $attributesData[$attributeKey]['options'][$optionKey] = [ + 'title' => $option['option_label']['value'] + ]; + } + } + } + + $configurableCheckoutData = isset($checkoutData['configurable_options']) + ? $checkoutData['configurable_options'] + : []; + $checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData); + $this->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData); + + parent::fillOptions($product); + } + + /** + * Return product options + * + * @param FixtureInterface $product [optional] + * @return array + */ + public function getOptions(FixtureInterface $product = null) + { + $options = [ + 'configurable_options' => $this->getConfigurableOptionsBlock()->getOptions($product) + ]; + $options += parent::getOptions($product); + + return $options; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.php new file mode 100644 index 00000000000..16fe173d132 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Product/View/ConfigurableOptions.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\ConfigurableProduct\Test\Block\Product\View; + +use Mtf\Client\Element; +use Mtf\Client\Element\Locator; +use Magento\Catalog\Test\Block\Product\View\CustomOptions; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class ConfigurableOptions + * Form of configurable options product + */ +class ConfigurableOptions extends CustomOptions +{ + /** + * Get configurable product options + * + * @param FixtureInterface|null $product [optional] + * @return array + * @throws \Exception + */ + public function getOptions(FixtureInterface $product) + { + /** @var ConfigurableProductInjectable $product */ + $attributesData = $product->hasData('configurable_attributes_data') + ? $product->getConfigurableAttributesData()['attributes_data'] + : []; + $listOptions = $this->getListOptions(); + $result = []; + + foreach ($attributesData as $option) { + $title = $option['label']; + if (!isset($listOptions[$title])) { + throw new \Exception("Can't find option: \"{$title}\""); + } + + /** @var Element $optionElement */ + $optionElement = $listOptions[$title]; + $typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['frontend_input']); + $getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data'; + + $optionData = $this->$getTypeData($optionElement); + $optionData['title'] = $title; + $optionData['type'] = $option['frontend_input']; + $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() + ? 'Yes' + : 'No'; + + $result[$title] = $optionData; + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php new file mode 100644 index 00000000000..4b6ea432794 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductIsNotDisplayedSeparately.php @@ -0,0 +1,89 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\ConfigurableProduct\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\CatalogSearch\Test\Page\CatalogsearchResult; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertChildProductIsNotDisplayedSeparately + * Assert that products generated during configurable product creation - are not visible on frontend(by default). + */ +class AssertChildProductIsNotDisplayedSeparately extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'middle'; + + /** + * Assert that products generated during configurable product creation - are not visible on frontend(by default). + * + * @param CatalogSearchResult $catalogSearchResult + * @param CmsIndex $cmsIndex + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert( + CatalogsearchResult $catalogSearchResult, + CmsIndex $cmsIndex, + ConfigurableProductInjectable $product + ) { + $configurableAttributesData = $product->getConfigurableAttributesData(); + $errors = []; + + $cmsIndex->open(); + foreach ($configurableAttributesData['matrix'] as $variation) { + $cmsIndex->getSearchBlock()->search($variation['sku']); + + $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($variation['name']); + while (!$isVisibleProduct && $catalogSearchResult->getBottomToolbar()->nextPage()) { + $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); + } + if ($isVisibleProduct) { + $errors[] = sprintf( + "\nChild product with sku: \"%s\" is visible on frontend(by default).", + $variation['sku'] + ); + } + } + + \PHPUnit_Framework_Assert::assertEmpty($errors, implode(' ', $errors)); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Child products generated during configurable product creation are not visible on frontend(by default)'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.php new file mode 100755 index 00000000000..9170954eb70 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertChildProductsInGrid.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\ConfigurableProduct\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertChildProductsInGrid + * Assert that child products generated during configurable product are present in products grid + */ +class AssertChildProductsInGrid extends AbstractConstraint +{ + /** + * Default status visibility on child products + */ + const NOT_VISIBLE_INDIVIDUALLY = 'Not Visible Individually'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that child products generated during configurable product are present in products grid + * + * @param CatalogProductIndex $productGrid + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert(CatalogProductIndex $productGrid, ConfigurableProductInjectable $product) + { + $configurableAttributesData = $product->getConfigurableAttributesData(); + $productType = $product->getIsVirtual() ? 'Virtual Product' : 'Simple Product'; + $errors = []; + + $productGrid->open(); + foreach ($configurableAttributesData['matrix'] as $variation) { + $filter = [ + 'name' => $variation['name'], + 'type' => $productType, + 'sku' => $variation['sku'], + 'visibility' => self::NOT_VISIBLE_INDIVIDUALLY, + ]; + + if (!$productGrid->getProductGrid()->isRowVisible($filter)) { + $errors[] = sprintf( + 'Child product with name: "%s" and sku:"%s" is absent in grid.', + $filter['name'], + $filter['sku'] + ); + } + } + + \PHPUnit_Framework_Assert::assertEmpty($errors, implode($errors, ' ')); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Child products generated during configurable product are present in products grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php deleted file mode 100755 index 8d6e2510b07..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCart.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\ConfigurableProduct\Test\Constraint; - -use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; -use Magento\Checkout\Test\Page\CheckoutCart; -use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertConfigurableInCart - */ -class AssertConfigurableInCart extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the product in the cart - * - * @param CatalogProductView $catalogProductView - * @param CatalogProductConfigurable $configurable - * @param Browser $browser - * @param CheckoutCart $checkoutCart - * @return void - */ - public function processAssert( - CatalogProductView $catalogProductView, - CatalogProductConfigurable $configurable, - Browser $browser, - CheckoutCart $checkoutCart - ) { - //Add product to cart - $browser->open($_ENV['app_frontend_url'] . $configurable->getUrlKey() . '.html'); - $configurableData = $configurable->getConfigurableAttributesData(); - if (!empty($configurableData)) { - $configurableOption = $catalogProductView->getCustomOptionsBlock(); - foreach ($configurableData['attributes_data'] as $attribute) { - $configurableOption->selectProductCustomOption($attribute['title']); - } - } - $catalogProductView->getViewBlock()->clickAddToCart(); - - $this->assertOnShoppingCart($configurable, $checkoutCart); - } - - /** - * Assert prices on the shopping Cart - * - * @param CatalogProductConfigurable $configurable - * @param CheckoutCart $checkoutCart - * @return void - */ - protected function assertOnShoppingCart(CatalogProductConfigurable $configurable, CheckoutCart $checkoutCart) - { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - $price = $checkoutCart->getCartBlock()->getProductPriceByName($configurable->getName()); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['cart_price'], - $price, - 'Product price in shopping cart is not correct.' - ); - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price in shopping cart is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php deleted file mode 100644 index 40389e96bda..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInCategory.php +++ /dev/null @@ -1,124 +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\ConfigurableProduct\Test\Constraint; - -use Magento\Cms\Test\Page\CmsIndex; -use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Page\Category\CatalogCategoryView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertProductInCategory - */ -class AssertConfigurableInCategory extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the category page - * - * @param CatalogCategoryView $catalogCategoryView - * @param CmsIndex $cmsIndex - * @param CatalogProductConfigurable $configurable - * @param CatalogCategory $category - * @return void - */ - public function processAssert( - CatalogCategoryView $catalogCategoryView, - CmsIndex $cmsIndex, - CatalogProductConfigurable $configurable, - CatalogCategory $category - ) { - //Open category view page - $cmsIndex->open(); - $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); - - //process asserts - $this->assertPrice($configurable, $catalogCategoryView); - } - - /** - * Verify product price on category view page - * - * @param CatalogProductConfigurable $configurable - * @param CatalogCategoryView $catalogCategoryView - * @return void - */ - protected function assertPrice( - CatalogProductConfigurable $configurable, - CatalogCategoryView $catalogCategoryView - ) { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - //Regular price verification - if (isset($pricePresetData['category_special_price'])) { - $regularPrice = $catalogCategoryView->getListProductBlock() - ->getProductPriceBlock($configurable->getName()) - ->getRegularPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['category_price'], - $regularPrice, - 'Product regular price on category page is not correct.' - ); - //Special price verification - $specialPrice = $catalogCategoryView->getListProductBlock()->getProductPriceBlock( - $configurable->getName() - )->getSpecialPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['category_special_price'], - $specialPrice, - 'Product special price on category page is not correct.' - ); - } else { - //Price verification - $price = $catalogCategoryView->getListProductBlock() - ->getProductPriceBlock($configurable->getName()) - ->getPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $price['price_regular_price'], - $pricePresetData['category_price'], - 'Product price on category page is not correct.' - ); - } - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price on category page is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.php new file mode 100644 index 00000000000..8e151a7da35 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductDuplicateForm.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\ConfigurableProduct\Test\Constraint; + +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; +use Mtf\Fixture\FixtureInterface; + +/** + * Class AssertConfigurableProductDuplicateForm + * Assert form data equals duplicate product configurable data + */ +class AssertConfigurableProductDuplicateForm extends AssertConfigurableProductForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert form data equals duplicate product configurable data + * + * @param FixtureInterface $product + * @param CatalogProductIndex $productGrid + * @param CatalogProductEdit $productPage + * @return void + */ + public function processAssert( + FixtureInterface $product, + CatalogProductIndex $productGrid, + CatalogProductEdit $productPage + ) { + $duplicateProductSku = $product->getSku() . '-1'; + $filter = ['sku' => $duplicateProductSku]; + $productGrid->open(); + $productGrid->getProductGrid()->searchAndOpen($filter); + + $productData = $product->getData(); + $productData['sku'] = $duplicateProductSku; + $productData['status'] = 'Product offline'; + $fixtureData = $this->prepareFixtureData($productData, $this->sortFields); + $formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields); + $error = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertTrue(empty($error), $error); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Form data equals to fixture data of duplicated product.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php old mode 100644 new mode 100755 index dfdb5e15755..1db4f952d80 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -24,99 +24,117 @@ namespace Magento\ConfigurableProduct\Test\Constraint; -use Mtf\Fixture\FixtureInterface; use Magento\Catalog\Test\Constraint\AssertProductForm; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; /** * Class AssertConfigurableProductForm - * Assert that displayed product data on edit page equals passed from fixture + * Assert form data equals fixture data */ class AssertConfigurableProductForm extends AssertProductForm { /** - * Constraint severeness + * List skipped fixture fields in verify * - * @var string + * @var array */ - protected $severeness = 'high'; + protected $skippedFixtureFields = [ + 'id', + 'affected_attribute_set', + 'checkout_data' + ]; /** - * Assert that displayed product data on edit page equals passed from fixture + * List skipped attribute fields in verify * - * @param FixtureInterface $product - * @param CatalogProductIndex $productGrid - * @param CatalogProductEdit $productPage - * @return void + * @var array */ - public function processAssert( - FixtureInterface $product, - CatalogProductIndex $productGrid, - CatalogProductEdit $productPage - ) { - $productGrid->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); + protected $skippedAttributeFields = [ + 'frontend_input', + 'attribute_code', + 'attribute_id', + 'is_required', + ]; - $form = $productPage->getForm(); - $formData = $form->getData($product); - foreach (array_keys($formData['configurable_attributes_data']['matrix']) as $key) { - unset($formData['configurable_attributes_data']['matrix'][$key]['price']); - } - - $fixtureData = $this->prepareFixtureData($product->getData(), $product); - $attributes = $fixtureData['configurable_attributes_data']['attributes_data']; - $matrix = $fixtureData['configurable_attributes_data']['matrix']; - unset($fixtureData['configurable_attributes_data'], $fixtureData['id']); + /** + * List skipped option fields in verify + * + * @var array + */ + protected $skippedOptionFields = [ + 'id', + 'is_default', + ]; - $fixtureData['configurable_attributes_data']['attributes_data'] = $this->prepareAttributes($attributes); - $fixtureData['configurable_attributes_data']['matrix'] = $this->prepareMatrix($matrix); + protected $skippedVariationMatrixFields = [ + 'configurable_attribute' + ]; - $errors = $this->verifyData($fixtureData, $formData); - \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); - } + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'high'; /** - * Preparing data attributes fixture + * Prepares fixture data for comparison * - * @param array $fixtureAttribute + * @param array $data + * @param array $sortFields [optional] * @return array */ - protected function prepareAttributes(array $fixtureAttribute) + protected function prepareFixtureData(array $data, array $sortFields = []) { - foreach ($fixtureAttribute as &$attribute) { - unset($attribute['id'], $attribute['label'], $attribute['code']); - foreach ($attribute['options'] as &$option) { - $option['pricing_value'] = number_format($option['pricing_value'], 4); - unset($option['id']); + // filter values and reset keys in attributes data + $attributeData = $data['configurable_attributes_data']['attributes_data']; + foreach ($attributeData as $attributeKey => $attribute) { + foreach ($attribute['options'] as $optionKey => $option) { + $attribute['options'][$optionKey] = array_diff_key($option, array_flip($this->skippedOptionFields)); } + $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); + $attributeData[$attributeKey] = array_diff_key($attribute, array_flip($this->skippedAttributeFields)); + } + $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); + + + // prepare and filter values, reset keys in variation matrix + $variationsMatrix = $data['configurable_attributes_data']['matrix']; + foreach ($variationsMatrix as $key => $variationMatrix) { + $variationMatrix['display'] = isset($variationMatrix['display']) ? $variationMatrix['display'] : 'Yes'; + $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); } + $data['configurable_attributes_data']['matrix'] = array_values($variationsMatrix); - return $fixtureAttribute; + return parent::prepareFixtureData($data, $sortFields); } /** - * Preparing data matrix fixture + * Prepares form data for comparison * - * @param array $fixtureMatrix + * @param array $data + * @param array $sortFields [optional] * @return array */ - protected function prepareMatrix(array $fixtureMatrix) + protected function prepareFormData(array $data, array $sortFields = []) { - foreach ($fixtureMatrix as &$matrix) { - $matrix['display'] = 'Yes'; - unset($matrix['configurable_attribute'], $matrix['associated_product_ids']); + // prepare attributes data + $attributeData = $data['configurable_attributes_data']['attributes_data']; + foreach ($attributeData as $attributeKey => $attribute) { + $attribute['options'] = $this->sortDataByPath($attribute['options'], '::label'); + $attributeData[$attributeKey] = $attribute; } + $data['configurable_attributes_data']['attributes_data'] = $this->sortDataByPath($attributeData, '::label'); - return $fixtureMatrix; - } + // filter values and reset keys in variation matrix + $variationsMatrix = $data['configurable_attributes_data']['matrix']; + foreach ($variationsMatrix as $key => $variationMatrix) { + $variationsMatrix[$key] = array_diff_key($variationMatrix, array_flip($this->skippedVariationMatrixFields)); + } + $data['configurable_attributes_data']['matrix'] = array_values($variationsMatrix); - /** - * Returns a string representation of the object - * - * @return string - */ - public function toString() - { - return 'Form data equal the configurable product data.'; + foreach ($sortFields as $path) { + $data = $this->sortDataByPath($data, $path); + } + return $data; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.php new file mode 100755 index 00000000000..95241dc236b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInCart.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\ConfigurableProduct\Test\Constraint; + +use Mtf\Client\Browser; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Checkout\Test\Page\CheckoutCart; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertConfigurableProductInCart + * Assertion that the product is correctly displayed in cart + */ +class AssertConfigurableProductInCart extends AbstractConstraint +{ + /** + * Assertion that the product is correctly displayed in cart + * + * @param Browser $browser + * @param CatalogProductView $catalogProductView + * @param CheckoutCart $checkoutCart + * @param ConfigurableProductInjectable $product + * @return void + */ + public function processAssert( + Browser $browser, + CatalogProductView $catalogProductView, + CheckoutCart $checkoutCart, + ConfigurableProductInjectable $product + ) { + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + + $catalogProductView->getViewBlock()->addToCart($product); + + $checkoutData = $product->getCheckoutData(); + $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); + \PHPUnit_Framework_Assert::assertEquals( + $checkoutData['checkoutItemForm']['price'], + $price, + 'Product price in shopping cart is not correct.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Product price in shopping cart is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.php new file mode 100644 index 00000000000..ae25bd0d715 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductInItemsOrderedGrid.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\ConfigurableProduct\Test\Constraint; + +use Mtf\Fixture\FixtureInterface; +use Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class AssertConfigurableProductInItemsOrderedGrid + * Assert configurable product was added to Items Ordered grid in customer account on Order creation page backend + */ +class AssertConfigurableProductInItemsOrderedGrid extends AssertProductInItemsOrderedGrid +{ + /** + * Get configurable product price + * + * @param FixtureInterface $product + * @throws \Exception + * @return int + */ + protected function getProductPrice(FixtureInterface $product) + { + $price = $product->getPrice(); + if (!$this->productsIsConfigured) { + return $price; + } + if (!$product instanceof ConfigurableProductInjectable) { + throw new \Exception("Product '$product->getName()' is not configurable product."); + } + $checkoutData = $product->getCheckoutData(); + if ($checkoutData === null) { + return 0; + } + $attributesData = $product->getConfigurableAttributesData()['attributes_data']; + foreach ($checkoutData['configurable_options'] as $option) { + $itemOption = $attributesData[$option['title']]['options'][$option['value']]; + $itemPrice = $itemOption['is_percent'] == 'No' + ? $itemOption['pricing_value'] + : $product->getPrice() / 100 * $itemOption['pricing_value']; + $price += $itemPrice; + } + + return $price; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php new file mode 100755 index 00000000000..0a185d25775 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.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\ConfigurableProduct\Test\Constraint; + +use Magento\Catalog\Test\Constraint\AssertProductPage; + +/** + * Class AssertConfigurableProductPage + * Assert that displayed product data on product page(front-end) equals passed from fixture + */ +class AssertConfigurableProductPage extends AssertProductPage +{ + /** + * Verify displayed product data on product page(front-end) equals passed from fixture: + * 1. Product Name + * 2. Price + * 3. SKU + * 4. Description + * 5. Short Description + * 6. Attributes + * + * @return array + */ + protected function verify() + { + $errors = parent::verify(); + $errors[] = $this->verifyAttributes(); + + return array_filter($errors); + } + + /** + * Verify displayed product attributes on product page(front-end) equals passed from fixture + * + * @return string|null + */ + protected function verifyAttributes() + { + $attributesData = $this->product->getConfigurableAttributesData()['attributes_data']; + $configurableOptions = []; + $formOptions = $this->productView->getOptions($this->product)['configurable_options']; + + foreach ($attributesData as $attributeKey => $attributeData) { + $optionData = [ + 'title' => $attributeData['frontend_label'], + 'type' => $attributeData['frontend_input'], + 'is_require' => 'Yes', + ]; + + foreach ($attributeData['options'] as $optionKey => $option) { + $price = ('Yes' == $option['is_percent']) + ? ($this->product->getPrice() * $option['pricing_value']) / 100 + : $option['pricing_value']; + + $optionData['options'][$optionKey] = [ + 'title' => $option['label'], + 'price' => number_format($price, 2) + ]; + } + + $configurableOptions[$attributeKey] = $optionData; + } + + // Sort data for compare + $configurableOptions = $this->sortDataByPath($configurableOptions, '::title'); + foreach ($configurableOptions as $key => $configurableOption) { + $configurableOptions[$key] = $this->sortDataByPath($configurableOption, 'options::title'); + } + $formOptions = $this->sortDataByPath($formOptions, '::title'); + foreach ($formOptions as $key => $formOption) { + $formOptions[$key] = $this->sortDataByPath($formOption, 'options::title'); + } + + $errors = $this->verifyData($configurableOptions, $formOptions, true, false); + return empty($errors) ? null : $this->prepareErrors($errors, 'Error configurable options:'); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php deleted file mode 100644 index 3daee2a4833..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableView.php +++ /dev/null @@ -1,115 +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\ConfigurableProduct\Test\Constraint; - -use Mtf\Client\Browser; -use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Page\Product\CatalogProductView; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Class AssertConfigurableView - */ -class AssertConfigurableView extends AbstractConstraint -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert configurable product, corresponds to the product page - * - * @param CatalogProductView $catalogProductView - * @param Browser $browser - * @param CatalogProductConfigurable $configurable - * @return void - */ - public function processAssert( - CatalogProductView $catalogProductView, - Browser $browser, - CatalogProductConfigurable $configurable - ) { - //Open product view page - $browser->open($_ENV['app_frontend_url'] . $configurable->getUrlKey() . '.html'); - - //Process assertions - $this->assertOnProductView($configurable, $catalogProductView); - } - - /** - * Assert prices on the product view Page - * - * @param CatalogProductConfigurable $configurable - * @param CatalogProductView $catalogProductView - * @return void - */ - protected function assertOnProductView( - CatalogProductConfigurable $configurable, - CatalogProductView $catalogProductView - ) { - /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ - $priceFixture = $configurable->getDataFieldConfig('price')['source']; - $pricePresetData = $priceFixture->getPreset(); - - if (isset($pricePresetData['product_special_price'])) { - $regularPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getRegularPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['product_price'], - $regularPrice, - 'Product regular price on product view page is not correct.' - ); - - $specialPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getSpecialPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $pricePresetData['product_special_price'], - $specialPrice, - 'Product special price on product view page is not correct.' - ); - } else { - //Price verification - $price = $catalogProductView->getViewBlock() - ->getProductPriceBlock($configurable->getName()) - ->getPrice(); - \PHPUnit_Framework_Assert::assertEquals( - $price['price_regular_price'], - $pricePresetData['product_price'], - 'Product price on category page is not correct.' - ); - } - } - - /** - * Text of Visible in category assert - * - * @return string - */ - public function toString() - { - return 'Product price on product view page is not correct.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php similarity index 76% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php index c913d8fc6e6..94a471ebddf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeAbsenceInVariationsSearch.php @@ -22,13 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Constraint; +namespace Magento\ConfigurableProduct\Test\Constraint; use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config as VariationsTab; +use \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config\Attribute as AttributeBlock; /** * Class AssertProductAttributeAbsenceInVariationsSearch @@ -36,6 +37,11 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; */ class AssertProductAttributeAbsenceInVariationsSearch extends AbstractConstraint { + /** + * Label "Variations" tab + */ + const TAB_VARIATIONS = 'variations'; + /** * Constraint severeness * @@ -49,21 +55,24 @@ class AssertProductAttributeAbsenceInVariationsSearch extends AbstractConstraint * @param CatalogProductAttribute $productAttribute * @param CatalogProductIndex $productGrid * @param CatalogProductNew $newProductPage - * @param CatalogProductEdit $productEdit * @return void */ public function processAssert ( CatalogProductAttribute $productAttribute, CatalogProductIndex $productGrid, - CatalogProductEdit $productEdit, CatalogProductNew $newProductPage ) { $productGrid->open(); $productGrid->getGridPageActionBlock()->addProduct('simple'); - $productEdit->getForm()->openVariationsTab(); + + /** @var VariationsTab $variationsTab */ + $variationsTab = $newProductPage->getProductForm()->getTabElement(self::TAB_VARIATIONS); + $variationsTab->showContent(); + /** @var AttributeBlock $attributesBlock */ + $attributesBlock = $variationsTab->getAttributeBlock(); \PHPUnit_Framework_Assert::assertFalse( - $newProductPage->getForm()->checkAttributeInVariationsSearchAttributeForm($productAttribute), + $attributesBlock->getAttributeSelector()->isExistAttributeInSearchResult($productAttribute), "Product attribute found in Attribute Search form." ); } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php old mode 100755 new mode 100644 index 1ba750db888..83964414380 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductAttributeIsConfigurable.php @@ -28,11 +28,11 @@ use Mtf\Fixture\FixtureFactory; use Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; /** * Class AssertProductAttributeIsConfigurable + * Assert check whether the attribute is used to create a configurable products */ class AssertProductAttributeIsConfigurable extends AbstractConstraint { @@ -86,11 +86,11 @@ class AssertProductAttributeIsConfigurable extends AbstractConstraint ] ); - $productBlockForm = $newProductPage->getForm(); + $productBlockForm = $newProductPage->getProductForm(); $productBlockForm->fill($productConfigurable); \PHPUnit_Framework_Assert::assertTrue( - $newProductPage->getForm()->findAttribute($this->attribute->getFrontendLabel()), + $productBlockForm->checkAttributeInSearchAttributeForm($this->attribute), "Product attribute is absent on the product page." ); } @@ -102,6 +102,6 @@ class AssertProductAttributeIsConfigurable extends AbstractConstraint */ public function toString() { - return 'Attribute label, present on the product page in variations section.'; + return 'Attribute label present on the product page in variations section.'; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php deleted file mode 100644 index e666431ea63..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertProductConfigurableDuplicateForm.php +++ /dev/null @@ -1,112 +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\ConfigurableProduct\Test\Constraint; - -use Mtf\Fixture\FixtureInterface; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\Catalog\Test\Constraint\AssertProductDuplicateForm; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; - -/** - * Class AssertProductConfigurableDuplicateForm - */ -class AssertProductConfigurableDuplicateForm extends AssertProductDuplicateForm -{ - /** - * Constraint severeness - * - * @var string - */ - protected $severeness = 'low'; - - /** - * Assert form data equals duplicate product configurable data - * - * @param FixtureInterface $product - * @param CatalogProductIndex $productGrid - * @param CatalogProductEdit $productPage - * @return void - */ - public function processAssert( - FixtureInterface $product, - CatalogProductIndex $productGrid, - CatalogProductEdit $productPage - ) { - $filter = ['sku' => $product->getSku() . '-1']; - $productGrid->open()->getProductGrid()->searchAndOpen($filter); - - $form = $productPage->getForm(); - $formData = $form->getData($product); - foreach (array_keys($formData['configurable_attributes_data']['matrix']) as $key) { - unset($formData['configurable_attributes_data']['matrix'][$key]['price']); - } - - $fixtureData = $this->prepareFixtureData($product->getData(), $product); - $attributes = $fixtureData['configurable_attributes_data']['attributes_data']; - $matrix = $fixtureData['configurable_attributes_data']['matrix']; - unset($fixtureData['configurable_attributes_data']); - - $fixtureData['configurable_attributes_data']['attributes_data'] = $this->prepareAttributes($attributes); - $fixtureData['configurable_attributes_data']['matrix'] = $this->prepareMatrix($matrix); - - $errors = $this->verifyData($fixtureData, $formData); - \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); - } - - /** - * Preparing data attributes fixture - * - * @param array $fixtureAttribute - * @return array - */ - protected function prepareAttributes(array $fixtureAttribute) - { - foreach ($fixtureAttribute as &$attribute) { - unset($attribute['id'], $attribute['label'], $attribute['code']); - foreach ($attribute['options'] as &$option) { - $option['pricing_value'] = number_format($option['pricing_value'], 4); - unset($option['id']); - } - } - - return $fixtureAttribute; - } - - /** - * Preparing data matrix fixture - * - * @param array $fixtureMatrix - * @return array - */ - protected function prepareMatrix(array $fixtureMatrix) - { - foreach ($fixtureMatrix as &$matrix) { - $matrix['display'] = 'Yes'; - unset($matrix['configurable_attribute'], $matrix['associated_product_ids']); - } - - return $fixtureMatrix; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php deleted file mode 100644 index f3914dfe8b3..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/ConfigurableAttributesData.php +++ /dev/null @@ -1,581 +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\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -use Mtf\Fixture\FixtureFactory; -use Mtf\Fixture\FixtureInterface; -use Mtf\Fixture\InjectableFixture; - -/** - * Class ConfigurableAttributesData - * Source configurable attributes data of the configurable products - */ -class ConfigurableAttributesData implements FixtureInterface -{ - /** - * Prepared dataSet data - * - * @var array - */ - protected $data = [ - 'products' => [], - 'attributes' => [] - ]; - - /** - * Data set configuration settings - * - * @var array - */ - protected $params; - - /** - * Current preset - * - * @var string - */ - protected $currentPreset; - - /** - * Fixture factory - * - * @var FixtureFactory - */ - protected $fixtureFactory; - - /** - * Source constructor - * - * @param FixtureFactory $fixtureFactory - * @param array $data - * @param array $params [optional] - * - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) - { - $this->fixtureFactory = $fixtureFactory; - $this->params = $params; - $data['products'] = empty($data['products']) ? [] : $data['products']; - $data['attributes'] = empty($data['attributes']) ? [] : $data['attributes']; - - if (isset($data['preset']) && $data['preset'] !== '-') { - $this->currentPreset = $data['preset']; - $this->data = $this->getPreset($this->currentPreset); - unset($data['preset']); - } - - foreach ($data['products'] as $key => $product) { - $this->data['products'][$key] = $product; - } - foreach ($data['attributes'] as $key => $attribute) { - $this->data['attributes'][$key] = $attribute; - } - - $this->prepareProducts(); - $this->prepareAttributes(); - } - - /** - * Persist configurable attribute data - * - * @return void - */ - public function persist() - { - // - } - - /** - * Preparation of products fixture - * - * @return void - */ - protected function prepareProducts() - { - if (!empty($this->data['products'])) { - foreach ($this->data['products'] as $key => $product) { - if (is_string($product)) { - list($fixture, $dataSet) = explode('::', $product); - /** @var $product InjectableFixture */ - $product = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); - if (!$product->hasData('id')) { - $product->persist(); - } - } - $this->data['products'][$key] = $product; - } - } - } - - /** - * Preparation of attributes fixture - * - * @return void - */ - protected function prepareAttributes() - { - if (!empty($this->data['attributes'])) { - foreach ($this->data['attributes'] as $key => $attribute) { - if (is_string($attribute)) { - list($fixture, $dataSet) = explode('::', $attribute); - /** @var $attribute InjectableFixture */ - $attribute = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); - if (!$attribute->hasData('id')) { - $attribute->persist(); - } - } - $this->data['attributes'][$key] = $attribute; - } - // Set options used. - $this->setOptions(); - // Initialization data matrix - $this->matrixInit(); - // Assigning products - $this->assigningProducts(); - } - } - - /** - * Set options used - * - * @return void - * - * @SuppressWarnings(PHPMD.NPathComplexity) - */ - protected function setOptions() - { - $fixtures = $this->data['attributes']; - foreach (array_keys($this->data['attributes_data']) as $key) { - $fixtureData = $fixtures[$key]->getData(); - $this->data['attributes_data'][$key]['id'] = isset($fixtureData['attribute_id']) - ? $fixtureData['attribute_id'] - : $key; - $this->data['attributes_data'][$key]['title'] = $fixtureData['frontend_label']; - $this->data['attributes_data'][$key]['code'] = $fixtureData['frontend_label']; - foreach ($this->data['attributes_data'][$key]['options'] as $optionKey => &$value) { - if (!isset($fixtureData['options'][$optionKey])) { - unset($this->data['attributes_data'][$key]['options'][$optionKey]); - continue; - } - $value['id'] = isset($fixtureData['options'][$optionKey]['id']) - ? $fixtureData['options'][$optionKey]['id'] - : $optionKey; - $value['name'] = empty($fixtureData['options'][$optionKey]['view']) - ? $fixtureData['options'][$optionKey]['admin'] - : $fixtureData['options'][$optionKey]['view']; - } - unset($value); - } - } - - /** - * Prepare data for matrix - * - * @return array - */ - protected function prepareDataMatrix() - { - $attributes = []; - foreach ($this->data['attributes_data'] as $attributeKey => $attribute) { - $options = []; - foreach ($attribute['options'] as $optionKey => $option) { - if ($option['include'] === 'Yes') { - $option['key'] = $optionKey; - $options[] = $option; - } - } - $attributes[] = [ - 'key' => $attributeKey, - 'id' => $attribute['id'], - 'code' => $attribute['code'], - 'options' => $options - ]; - } - - return $attributes; - } - - /** - * Generation variants - * - * @return array - */ - protected function generationVariants() - { - $attributes = array_reverse($this->prepareDataMatrix()); - $variations = []; - $attributesCount = count($attributes); - $currentVariation = array_fill(0, $attributesCount, 0); - $lastAttribute = $attributesCount - 1; - do { - for ($attributeIndex = 0; $attributeIndex < $attributesCount - 1; ++$attributeIndex) { - if ($currentVariation[$attributeIndex] >= count($attributes[$attributeIndex]['options'])) { - $currentVariation[$attributeIndex] = 0; - ++$currentVariation[$attributeIndex + 1]; - } - } - if ($currentVariation[$lastAttribute] >= count($attributes[$lastAttribute]['options'])) { - break; - } - - $filledVariation = []; - for ($attributeIndex = $attributesCount; $attributeIndex--;) { - $currentAttribute = $attributes[$attributeIndex]; - $currentVariationValue = $currentVariation[$attributeIndex]; - $filledVariation[$currentAttribute['key']] = $currentAttribute['options'][$currentVariationValue]; - $filledVariation[$currentAttribute['key']]['code'] = $currentAttribute['code']; - } - - $variationsKeys = []; - $placeholder = []; - $optionsNames = []; - foreach ($filledVariation as $key => $option) { - $variationKey = sprintf('%%attribute_%d-option_%d%%', $key, $option['key']); - $variationsKeys[] = $variationKey; - $keyName = sprintf('%%attribute_%d-option_%d_name%%', $key, $option['key']); - $keyId = sprintf('%%attribute_%d-option_%d_id%%', $key, $option['key']); - $attributeCode = sprintf('%%attribute_%d_code%%', $key); - $optionsNames[] = $option['name']; - $placeholder += [ - $keyName => $option['name'], - $keyId => $option['id'], - $variationKey => $option['id'], - $attributeCode => $option['code'] - ]; - } - - $variationsKey = implode('-', $variationsKeys); - $variations[$variationsKey]['placeholder'] = $placeholder; - $variations[$variationsKey]['options_names'] = $optionsNames; - $currentVariation[0]++; - } while (true); - - return $variations; - } - - /** - * Initialization data matrix - * - * @return void - */ - protected function matrixInit() - { - // Generation variants - $variations = $this->generationVariants(); - - foreach (array_keys($this->data['matrix']) as $key) { - if (isset($variations[$key])) { - foreach ($this->data['matrix'][$key] as $innerKey => &$value) { - if ($innerKey === 'configurable_attribute') { - $value = strtr(json_encode($value), $variations[$key]['placeholder']); - } elseif (is_string($value)) { - $value = strtr($value, $variations[$key]['placeholder']); - } - } - unset($value); - $newKey = strtr($key, $variations[$key]['placeholder']); - $this->data['matrix'][$newKey] = $this->data['matrix'][$key]; - $this->data['matrix'][$newKey]['options_names'] = $variations[$key]['options_names']; - unset($this->data['matrix'][$key]); - } - } - } - - /** - * Assigning products - * - * @return void - */ - protected function assigningProducts() - { - foreach ($this->data['products'] as $key => $product) { - foreach ($this->data['matrix'] as &$value) { - if (isset($value['associated_product_ids'][$key])) { - unset($value['associated_product_ids'][$key]); - /** @var $attribute InjectableFixture */ - $value['associated_product_ids'][] = $product->getId(); - $value['name'] = $product->getName(); - $value['sku'] = $product->getSku(); - } - } - unset($value); - } - } - - /** - * Return prepared data set - * - * @param string|null $key - * @return mixed - */ - 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; - } - - /** - * Preset array - * - * @param string $name - * @return mixed|null - * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function getPreset($name) - { - $presets = [ - 'default' => [ - 'attributes_data' => [ - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation1 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 12.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 20.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 18.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - ] - ], - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation2 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 42.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 40.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 48.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ], - ] - ] - ], - 'products' => [ - - ], - 'attributes' => [ - 'catalogProductAttribute::attribute_type_dropdown', - 'catalogProductAttribute::attribute_type_dropdown' - ], - 'matrix' => [ - '%attribute_0-option_0%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1 - ], - '%attribute_0-option_0%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_0%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_1%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_1%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_1_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_1_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_0%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_1%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_1%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_1_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_1_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ], - '%attribute_0-option_2%-%attribute_1-option_2%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_2%', - '%attribute_1_code%' => '%attribute_1-option_2%' - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_2_name% %attribute_1-option_2_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_2_id%_%attribute_1-option_2_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ] - ] - ], - 'one_variation' => [ - 'attributes_data' => [ - [ - 'id' => '%id%', - 'title' => '%title%', - 'label' => 'Test variation1 label', - 'options' => [ - [ - 'id' => '%id%', - 'name' => '%name%', - 'pricing_value' => 12.00, - 'include' => 'Yes', - 'is_percent' => 'No' - ] - ] - ] - ], - 'products' => [ - - ], - 'attributes' => [ - 'catalogProductAttribute::attribute_type_dropdown' - ], - 'matrix' => [ - '%attribute_0-option_0%' => [ - 'configurable_attribute' => [ - '%attribute_0_code%' => '%attribute_0-option_0%', - ], - 'associated_product_ids' => [], - 'name' => 'In configurable %isolation% %attribute_0-option_0_name%', - 'sku' => 'sku_configurable_%isolation%_%attribute_0-option_0_id%', - 'qty' => 10, - 'weight' => 1, - 'options_names' => [] - ] - ] - ] - ]; - - if (!isset($presets[$name])) { - return null; - } - - return $presets[$name]; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php old mode 100755 new mode 100644 similarity index 59% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php index 344edc124ad..fbc37084773 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/ConfigurableProduct.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.php @@ -21,16 +21,18 @@ * @copyright Copyright (c) 2014 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\Test\Fixture; +namespace Magento\ConfigurableProduct\Test\Fixture; + +use Magento\Catalog\Test\Fixture\ProductAttribute; use Mtf\System\Config; use Mtf\Factory\Factory; -use Magento\Catalog\Test\Repository\ConfigurableProduct as Repository; +use Magento\Catalog\Test\Fixture\Product; +use Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct as Repository; /** * Class ConfigurableProduct * Configurable product data - * */ class ConfigurableProduct extends Product { @@ -42,7 +44,7 @@ class ConfigurableProduct extends Product /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Custom constructor to create configurable product with attribute @@ -50,11 +52,11 @@ class ConfigurableProduct extends Product * @param Config $configuration * @param array $placeholders */ - public function __construct(Config $configuration, $placeholders = array()) + public function __construct(Config $configuration, $placeholders = []) { parent::__construct($configuration, $placeholders); - $this->_placeholders['attribute_label_1'] = array($this, 'attributeProvider'); + $this->_placeholders['attribute_label_1'] = [$this, 'attributeProvider']; } /** @@ -66,7 +68,7 @@ class ConfigurableProduct extends Product public function provideNewAttributeData(ProductAttribute $attribute) { $options = $attribute->getOptionLabels(); - $placeholders['new_attribute_label'] = $attribute->getAttributeLabel(); + $placeholders['new_attribute_label'] = $attribute->getFrontendLabel(); $placeholders['new_attribute_option_1_label'] = $options[0]; $placeholders['new_attribute_option_2_label'] = $options[1]; $this->_applyPlaceholders($this->_data, $placeholders); @@ -87,12 +89,12 @@ class ConfigurableProduct extends Product $this->_dataConfig['options'][$attribute->getAttributeId()]['id'] = $attribute->getOptionIds(); $options = $attribute->getOptionLabels(); - $placeholders['attribute_1_name'] = $attribute->getAttributeLabel(); + $placeholders['attribute_1_name'] = $attribute->getFrontendLabel(); $placeholders['attribute_1_option_label_1'] = $options[0]; $placeholders['attribute_1_option_label_2'] = $options[1]; $this->_applyPlaceholders($this->_data, $placeholders); - return $attribute->getAttributeLabel(); + return $attribute->getFrontendLabel(); } /** @@ -103,8 +105,8 @@ class ConfigurableProduct extends Product */ public function getAffectedAttributeSet() { - return $this->getData('affect_configurable_product_attributes') - ? $this->getData('affect_configurable_product_attributes') + return $this->getData('affected_attribute_set') + ? $this->getData('affected_attribute_set') : null; } @@ -117,13 +119,19 @@ class ConfigurableProduct extends Product public function getVariationSku($selectedOption) { $sku = ''; - foreach ($this->getData('fields/variations-matrix/value') as $variation) { - $configurableAttributes = $variation['configurable_attribute']; + $configurableAttributes = $this->getConfigurableAttributes(); + $attributeKey = $selectedOption['title']; + $optionKey = $selectedOption['value']; + $optionValue = $configurableAttributes[$attributeKey][$optionKey]['option_label']['value']; + + foreach ($this->getVariationsMatrix() as $variation) { foreach ($configurableAttributes as $configurableAttribute) { - $attributeOption = $configurableAttribute['attribute_option']; - if ($attributeOption === $selectedOption) { - $sku = $variation['value']['name']['value']; - break 2; + foreach ($configurableAttribute as $option) { + if (isset($option['option_label']['value']) + && $option['option_label']['value'] == $optionValue) { + $sku = $variation['value']['sku']['value']; + break 3; + } } } } @@ -137,9 +145,9 @@ class ConfigurableProduct extends Product */ public function getVariationSkus() { - $variationSkus = array(); + $variationSkus = []; foreach ($this->getVariationsMatrix() as $variation) { - if (is_array($variation)) { + if (is_array($variation) && isset($variation['value']['name']['value'])) { $variationSkus[] = $variation['value']['name']['value']; } } @@ -155,7 +163,7 @@ class ConfigurableProduct extends Product public function getVariationsMatrix() { $variations = $this->getData('fields/variations-matrix/value'); - return is_array($variations) ? $variations : array(); + return is_array($variations) ? $variations : []; } /** @@ -165,7 +173,7 @@ class ConfigurableProduct extends Product */ public function persist() { - $id = Factory::getApp()->magentoCatalogCreateConfigurable($this); + $id = Factory::getApp()->magentoConfigurableProductCreateConfigurable($this); $this->_data['id']['value'] = $id; return $this; @@ -179,7 +187,7 @@ class ConfigurableProduct extends Product public function getConfigurableAttributes() { $attributes = $this->getData('fields/configurable_attributes_data/value'); - return is_array($attributes) ? $attributes : array(); + return is_array($attributes) ? $attributes : []; } /** @@ -189,7 +197,7 @@ class ConfigurableProduct extends Product */ public function getConfigurableOptions() { - $options = array(); + $options = []; foreach ($this->getConfigurableAttributes() as $attribute) { foreach ($attribute as $option) { if (isset($option['option_label']['value'])) { @@ -210,155 +218,150 @@ class ConfigurableProduct extends Product protected function _initData() { parent::_initData(); - $this->_dataConfig = array( + $this->_dataConfig = [ + 'type_id' => 'configurable', 'constraint' => 'Success', - - 'create_url_params' => array( + 'create_url_params' => [ 'type' => Repository::CONFIGURABLE, 'set' => static::DEFAULT_ATTRIBUTE_SET_ID, - ), - ); - $data = array( - 'fields' => array( - 'price' => array( + ], + ]; + $data = [ + 'fields' => [ + 'price' => [ 'value' => '10', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'tax_class_id' => array( + ], + 'tax_class_id' => [ 'value' => 'Taxable Goods', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select', 'input_value' => '2', - ), - 'weight' => array( + ], + 'weight' => [ 'value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS - ), - 'product_website_1' => array( + ], + 'product_website_1' => [ 'value' => 'Yes', - 'input_value' => array(1), + 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids' - ), - 'configurable_attributes_data' => array( - 'value' => array( - '0' => array( - 'label' => array( + ], + 'configurable_attributes_data' => [ + 'value' => [ + '0' => [ + 'label' => [ 'value' => '%attribute_label_1%' - ), - '0' => array( - 'option_label' => array( + ], + '0' => [ + 'option_label' => [ 'value' => '%attribute_1_option_label_1%' - ), - 'pricing_value' => array( + ], + 'pricing_value' => [ 'value' => '1' - ), - 'is_percent' => array( + ], + 'is_percent' => [ 'value' => 'No' - ), - 'include' => array( + ], + 'include' => [ 'value' => 'Yes' - ), - ), - '1' => array( - 'option_label' => array( + ], + ], + '1' => [ + 'option_label' => [ 'value' => '%attribute_1_option_label_2%' - ), - 'pricing_value' => array( + ], + 'pricing_value' => [ 'value' => '2' - ), - 'is_percent' => array( + ], + 'is_percent' => [ 'value' => 'No' - ), - 'include' => array( + ], + 'include' => [ 'value' => 'Yes' - ), - ) - ) - ), + ], + ] + ] + ], 'group' => static::GROUP - ), - 'variations-matrix' => array( - 'value' => array( - '0' => array( - 'configurable_attribute' => array( - '0' => array( + ], + 'variations-matrix' => [ + 'value' => [ + '0' => [ + 'configurable_attribute' => [ + '0' => [ 'attribute_option' => '%attribute_1_option_label_1%' - ) - ), - 'value' => array( - 'display' => array( + ] + ], + 'value' => [ + 'display' => [ 'value' => 'Yes', 'input' => 'checkbox' - ), - 'name' => array( + ], + 'name' => [ 'value' => 'Variation 0-%isolation%' - ), - 'sku' => array( + ], + 'sku' => [ 'value' => 'Variation 0-%isolation%' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => '100' - ) - ) - ), - '1' => array( - 'configurable_attribute' => array( - '0' => array( + ] + ] + ], + '1' => [ + 'configurable_attribute' => [ + '0' => [ 'attribute_option' => '%attribute_1_option_label_2%' - ) - ), - 'value' => array( - 'display' => array( + ] + ], + 'value' => [ + 'display' => [ 'value' => 'Yes', 'input' => 'checkbox' - ), - 'name' => array( + ], + 'name' => [ 'value' => 'Variation 1-%isolation%' - ), - 'sku' => array( + ], + 'sku' => [ 'value' => 'Variation 1-%isolation%' - ), - 'qty' => array( + ], + 'qty' => [ 'value' => '200' - ) - ) - ) - ), + ] + ] + ] + ], 'group' => static::GROUP - ), - ), - 'checkout' => array( - 'selections' => array( - '0' => array( - 'attribute_name' => '%attribute_1_name%', - 'option_name' => '%attribute_1_option_label_1%' - ) - ), + ], + ], + 'checkout_data' => [ + 'configurable_options' => [ + [ + 'title' => '0', + 'value' => '0' + ] + ], 'special_price' => '10' - ) - ); + ] + ]; $this->_data = array_merge_recursive($this->_data, $data); $this->_repository = Factory::getRepositoryFactory() - ->getMagentoCatalogConfigurableProduct($this->_dataConfig, $this->_data); + ->getMagentoConfigurableProductConfigurableProduct($this->_dataConfig, $this->_data); } /** - * Get configurable options + * Get checkout data configurable product * * @return array */ - public function getProductOptions() + public function getCheckoutData() { - $selections = $this->getData('checkout/selections'); - $options = array(); - foreach ($selections as $selection) { - $options[$selection['attribute_name']] = $selection['option_name']; - } - return $options; + return $this->getData('checkout_data'); } /** @@ -369,7 +372,7 @@ class ConfigurableProduct extends Product */ public function getProductSpecialPrice() { - return $this->getData('checkout/special_price'); + return $this->getData('checkout_data/special_price'); } /** @@ -380,19 +383,11 @@ class ConfigurableProduct extends Product public function getProductOptionsPrice() { $price = 0; - $selections = $this->getData('checkout/selections'); - foreach ($selections as $selection) { - $optionName = $selection['option_name']; - $attributes = $this->getData('fields/configurable_attributes_data/value'); - foreach ($attributes as $attribute) { - $optionCount = 0; - while (isset($attribute[$optionCount])) { - if ($attribute[$optionCount]['option_label']['value'] == $optionName) { - $price += $attribute[$optionCount]['pricing_value']['value']; - } - ++$optionCount; - } - } + $configurableOptions = $this->getData('checkout_data/configurable_options'); + $attributes = $this->getData('fields/configurable_attributes_data/value'); + + foreach ($configurableOptions as $option) { + $price += $attributes[$option['title']][$option['value']]['pricing_value']['value']; } return $price; } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php similarity index 92% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php index 927a42c2111..fd65fadaad2 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.php @@ -32,23 +32,23 @@ use Mtf\Repository\RepositoryFactory; use Mtf\System\Event\EventManagerInterface; /** - * Class CatalogProductConfigurable + * Class ConfigurableProduct * * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CatalogProductConfigurable extends InjectableFixture +class ConfigurableProductInjectable extends InjectableFixture { /** * @var string */ - protected $repositoryClass = 'Magento\ConfigurableProduct\Test\Repository\CatalogProductConfigurable'; + protected $repositoryClass = 'Magento\ConfigurableProduct\Test\Repository\ConfigurableProductInjectable'; // @codingStandardsIgnoreStart /** * @var string */ - protected $handlerInterface = 'Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\CatalogProductConfigurableInterface'; + protected $handlerInterface = 'Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\ConfigurableProductInjectableInterface'; // @codingStandardsIgnoreEnd /** @@ -74,6 +74,9 @@ class CatalogProductConfigurable extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -84,13 +87,10 @@ class CatalogProductConfigurable extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ + 'type_id' => 'configurable', 'create_url_params' => [ 'type' => 'configurable', 'set' => '4', @@ -100,11 +100,12 @@ class CatalogProductConfigurable extends InjectableFixture protected $defaultDataSet = [ 'type_id' => 'configurable', - 'attribute_set_id' => 'Default', + 'attribute_set_id' => ['dataSet' => 'Default'], 'name' => 'Configurable Product %isolation%', 'sku' => 'sku_configurable_product_%isolation%', 'price' => ['value' => 100.00], 'weight' => 1, + 'url_key' => 'configurable-product-%isolation%', ]; protected $category_ids = [ @@ -113,6 +114,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'text', + 'group' => 'product-details', 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds' ]; @@ -178,6 +180,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'textarea', + 'group' => 'product-details', ]; protected $enable_googlecheckout = [ @@ -374,7 +377,7 @@ class CatalogProductConfigurable extends InjectableFixture 'default_value' => '', 'input' => 'price', 'group' => 'product-details', - 'source' => 'Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price' + 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\Price', ]; protected $quantity_and_stock_status = [ @@ -408,6 +411,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'textarea', + 'group' => 'autosettings', ]; protected $sku = [ @@ -548,6 +552,12 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'product-details', ]; + protected $is_virtual = [ + 'attribute_code' => 'is_virtual', + 'backend_type' => 'virtual', + 'group' => 'product-details', + ]; + protected $id = [ 'attribute_code' => 'id', 'backend_type' => 'virtual', @@ -556,6 +566,7 @@ class CatalogProductConfigurable extends InjectableFixture protected $type_id = [ 'attribute_code' => 'type_id', 'backend_type' => 'virtual', + 'group' => null ]; protected $attribute_set_id = [ @@ -571,6 +582,12 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'variations' ]; + protected $affected_attribute_set = [ + 'attribute_code' => 'affected_attribute_set', + 'backend_type' => 'virtual', + 'group' => null, + ]; + protected $custom_options = [ 'attribute_code' => 'custom_options', 'backend_type' => 'virtual', @@ -585,7 +602,7 @@ class CatalogProductConfigurable extends InjectableFixture 'is_required' => '0', 'input' => 'variations', 'group' => 'variations', - 'source' => 'Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableAttributesData' + 'source' => 'Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData' ]; protected $website_ids = [ @@ -595,6 +612,13 @@ class CatalogProductConfigurable extends InjectableFixture 'group' => 'websites', ]; + protected $checkout_data = [ + 'attribute_code' => 'checkout_data', + 'backend_type' => 'virtual', + 'group' => null, + 'source' => 'Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\CheckoutData', + ]; + public function getCategoryIds() { return $this->getData('category_ids'); @@ -860,6 +884,11 @@ class CatalogProductConfigurable extends InjectableFixture return $this->getData('weight'); } + public function getIsVirtual() + { + return $this->getData('is_virtual'); + } + public function getId() { return $this->getData('id'); @@ -885,6 +914,11 @@ class CatalogProductConfigurable extends InjectableFixture return $this->getData('attribute_set_name'); } + public function getAffectedAttributeSet() + { + return $this->getData('affected_attribute_set'); + } + public function getConfigurableAttributesData() { return $this->getData('configurable_attributes_data'); @@ -894,4 +928,9 @@ class CatalogProductConfigurable extends InjectableFixture { return $this->getData('website_ids'); } + + public function getCheckoutData() + { + return $this->getData('checkout_data'); + } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml similarity index 94% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml index 8fcbbdc441b..f778c74eadb 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<fixture class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable"> +<fixture class="Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable"> <module>Magento_ConfigurableProduct</module> <type>eav</type> <entity_type>catalog_product</entity_type> @@ -37,6 +37,8 @@ <is_required>0</is_required> <default_value></default_value> <input>text</input> + <group>product-details</group> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds</source> </category_ids> <configurable_attributes_data> <attribute_code>configurable_attributes_data</attribute_code> @@ -44,7 +46,7 @@ <is_required>0</is_required> <input>variations</input> <group>variations</group> - <source>Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableAttributesData</source> + <source>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData</source> </configurable_attributes_data> <color> <attribute_code>color</attribute_code> @@ -101,6 +103,7 @@ <is_required>0</is_required> <default_value></default_value> <input>textarea</input> + <group>product-details</group> </description> <enable_googlecheckout> <attribute_code>enable_googlecheckout</attribute_code> @@ -303,6 +306,7 @@ <is_required>0</is_required> <default_value></default_value> <input>textarea</input> + <group>autosettings</group> </short_description> <sku> <attribute_code>sku</attribute_code> @@ -422,6 +426,10 @@ <input>weight</input> <group>product_info_tabs_product-details</group> </weight> + <is_virtual> + <attribute_code>is_virtual</attribute_code> + <backend_type>virtual</backend_type> + </is_virtual> <id> <attribute_code>id</attribute_code> <backend_type>virtual</backend_type> @@ -429,6 +437,7 @@ <type_id> <attribute_code>type_id</attribute_code> <backend_type>virtual</backend_type> + <group /> </type_id> <attribute_set_id> <attribute_code>attribute_set_id</attribute_code> @@ -441,6 +450,10 @@ <backend_type>virtual</backend_type> <group>product-details</group> </attribute_set_name> + <affected_attribute_set> + <attribute_code>affected_attribute_set</attribute_code> + <backend_type>virtual</backend_type> + </affected_attribute_set> <custom_options> <attribute_code>custom_options</attribute_code> <backend_type>virtual</backend_type> @@ -454,6 +467,12 @@ <default_value>Main Website</default_value> <group>websites</group> </website_ids> + <checkout_data> + <attribute_code>checkout_data</attribute_code> + <backend_type>virtual</backend_type> + <group /> + <source>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\CheckoutData</source> + </checkout_data> </fields> <data_set> <sku></sku> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.php new file mode 100644 index 00000000000..f586878dd95 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/CheckoutData.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\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Class CheckoutData + * Data for fill product form on frontend + * + * Data keys: + * - preset (Checkout data verification preset name) + */ +class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\CheckoutData +{ + /** + * Get preset array + * + * @param $name + * @return array|null + */ + protected function getPreset($name) + { + $presets = [ + 'default' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ], + [ + 'title' => 'attribute_1', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ], + 'qty' => 1 + ], + 'two_options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ] + ], + 'two_new_options' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_1', + ] + ], + 'checkoutItemForm' => [ + 'price' => 102, + ] + ], + 'two_new_options_with_special_price' =>[ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_1', + ] + ], + 'checkoutItemForm' => [ + 'price' => 12, + ] + ], + 'two_options_with_assigned_product' => [ + 'configurable_options' => [ + [ + 'title' => 'attribute_0', + 'value' => 'option_0', + ] + ], + 'checkoutItemForm' => [ + 'price' => 101, + ] + ], + ]; + return isset($presets[$name]) ? $presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php new file mode 100644 index 00000000000..7109b845623 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProductInjectable/ConfigurableAttributesData.php @@ -0,0 +1,726 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Fixture\ConfigurableProductInjectable; + +use Mtf\Fixture\FixtureFactory; +use Mtf\Fixture\FixtureInterface; +use Mtf\Fixture\InjectableFixture; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class ConfigurableAttributesData + * Source configurable attributes data of the configurable products + */ +class ConfigurableAttributesData implements FixtureInterface +{ + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Data set configuration settings + * + * @var array + */ + protected $params; + + /** + * Prepared dataSet data + * + * @var array + */ + protected $data = []; + + /** + * Prepared attributes data + * + * @var array + */ + protected $attributesData = []; + + /** + * Prepared variation matrix + * + * @var array + */ + protected $variationsMatrix = []; + + /** + * Prepared attributes + * + * @var array + */ + protected $attributes = []; + + /** + * Prepared products + * + * @var array + */ + protected $products = []; + + /** + * Presets data + * + * @var array + */ + protected $presets = [ + 'default' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 12.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_1' => [ + 'pricing_value' => 20.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_2' => [ + 'pricing_value' => 18.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + ] + ], + 'attribute_1' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 42.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_1' => [ + 'pricing_value' => 40.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + 'option_2' => [ + 'pricing_value' => 48.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ], + ] + ] + ], + 'products' => [ + + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown', + 'attribute_1' => 'catalogProductAttribute::attribute_type_dropdown' + ], + 'matrix' => [ + 'attribute_0:option_0 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_0 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_0 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_1' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_2 attribute_1:option_2' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + ] + ], + 'one_variation' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'pricing_value' => 12.00, + 'include' => 'Yes', + 'is_percent' => 'No' + ] + ] + ] + ], + 'products' => [ + + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_one_option' + ], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + ] + ], + 'two_options' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'Yes', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'Yes', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + ], + 'products' => [], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ], + 'two_new_options' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'frontend_label' => 'two_new_options_title_%isolation%', + 'frontend_input' => 'Dropdown', + 'label' => 'two_new_options_title_%isolation%', + 'is_required' => 'No', + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'No', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'No', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [], + 'products' => [], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ], + 'two_options_with_assigned_product' => [ + 'attributes_data' => [ + 'attribute_0' => [ + 'options' => [ + 'option_0' => [ + 'label' => 'option_1_%isolation%', + 'pricing_value' => 1, + 'is_percent' => 'Yes', + 'include' => 'Yes' + ], + 'option_1' => [ + 'label' => 'option_2_%isolation%', + 'pricing_value' => 2, + 'is_percent' => 'Yes', + 'include' => 'Yes', + ] + ] + ] + ], + 'attributes' => [ + 'attribute_0' => 'catalogProductAttribute::attribute_type_dropdown_two_options', + ], + 'products' => [ + 'attribute_0:option_0' => 'catalogProductSimple::default', + 'attribute_0:option_1' => 'catalogProductSimple::default' + ], + 'matrix' => [ + 'attribute_0:option_0' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 10 + ], + 'weight' => 1 + ], + 'attribute_0:option_1' => [ + 'display' => 'Yes', + 'quantity_and_stock_status' => [ + 'qty' => 20 + ], + 'weight' => 2 + ] + ] + ] + ]; + + + /** + * Source constructor + * + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->fixtureFactory = $fixtureFactory; + $this->params = $params; + + $preset = isset($data['preset']) ? $this->getPreset($data['preset']) : []; + + $this->prepareAttributes($preset); + $this->prepareAttributesData($preset); + $this->prepareProducts($preset); + $this->prepareVariationsMatrix($preset); + $this->prepareData(); + } + + /** + * Persist configurable attribute data + * + * @return void + */ + public function persist() + { + // + } + + /** + * Prepare attributes + * + * @param array $data + * @return void + */ + protected function prepareAttributes(array $data) + { + if (empty($data['attributes'])) { + return; + } + + foreach ($data['attributes'] as $key => $attribute) { + if (is_string($attribute)) { + list($fixture, $dataSet) = explode('::', $attribute); + /** @var InjectableFixture $attribute */ + $attribute = $this->fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); + } + if (!$attribute->hasData('attribute_id')) { + $attribute->persist(); + } + $this->attributes[$key] = $attribute; + } + } + + /** + * Prepare attributes data + * + * @param array $data + * @return void + */ + protected function prepareAttributesData(array $data) + { + foreach ($this->attributes as $attributeKey => $attribute) { + $attributeData = $attribute->getData(); + $options = []; + + foreach ($attributeData['options'] as $key => $option) { + $options['option_' . $key] = $option; + } + $attributeData['options'] = $options; + + $this->attributesData[$attributeKey] = $attributeData; + } + + $this->attributesData = array_replace_recursive( + isset($data['attributes_data']) ? $data['attributes_data'] : [], + $this->attributesData + ); + } + + /** + * Prepare products + * + * @param array $data + * @return void + */ + protected function prepareProducts(array $data) + { + if (empty($data['products'])) { + return; + } + + $attributeSetData = []; + if (!empty($this->attributes)) { + $attributeSetData['attribute_set_id'] = ['attribute_set' => $this->createAttributeSet()]; + } + + foreach ($data['products'] as $key => $product) { + if (is_string($product)) { + list($fixture, $dataSet) = explode('::', $product); + $attributeData = ['attributes' => $this->getProductAttributeData($key)]; + $product = $this->fixtureFactory->createByCode( + $fixture, + ['dataSet' => $dataSet, 'data' => array_merge($attributeSetData, $attributeData)] + ); + } + if (!$product->hasData('id')) { + $product->persist(); + } + + $this->products[$key] = $product; + } + } + + /** + * Create attribute set + * + * @return FixtureInterface + */ + protected function createAttributeSet() + { + $attributeSet = $this->fixtureFactory->createByCode( + 'catalogAttributeSet', + [ + 'dataSet' => 'custom_attribute_set', + 'data' => [ + 'assigned_attributes' => [ + 'attributes' => array_values($this->attributes) + ] + ] + ] + ); + $attributeSet->persist(); + return $attributeSet; + } + + /** + * Get prepared attribute data for persist product + * + * @param string $key + * @return array + */ + protected function getProductAttributeData($key) + { + $compositeKeys = explode(' ', $key); + $data = []; + + foreach ($compositeKeys as $compositeKey) { + $attributeId = $this->getAttributeOptionId($compositeKey); + if ($attributeId) { + $compositeKey = explode(':', $compositeKey); + $attributeKey = $compositeKey[0]; + $data[$this->attributesData[$attributeKey]['attribute_code']] = $attributeId; + } + } + + return $data; + } + + /** + * Get id of attribute option by composite key + * + * @param string $compositeKey + * @return int|null + */ + protected function getAttributeOptionId($compositeKey) + { + list($attributeKey, $optionKey) = explode(':', $compositeKey); + return isset($this->attributesData[$attributeKey]['options'][$optionKey]['id']) + ? $this->attributesData[$attributeKey]['options'][$optionKey]['id'] + : null; + } + + /** + * Prepare data for matrix + * + * @param array $data + * @return void + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function prepareVariationsMatrix(array $data) + { + $variationsMatrix = []; + + // generate matrix + foreach ($this->attributesData as $attributeKey => $attribute) { + $variationsMatrix = $this->addVariationMatrix($variationsMatrix, $attribute, $attributeKey); + } + $this->variationsMatrix = array_replace_recursive($variationsMatrix, $data['matrix']); + + // assigned products + foreach ($this->variationsMatrix as $key => $row) { + if (isset($this->products[$key])) { + /** @var CatalogProductSimple $product */ + $product = $this->products[$key]; + $quantityAndStockStatus = $product->getQuantityAndStockStatus(); + + $this->variationsMatrix[$key]['configurable_attribute'] = $product->getId(); + $this->variationsMatrix[$key]['name'] = $product->getName(); + $this->variationsMatrix[$key]['sku'] = $product->getSku(); + $this->variationsMatrix[$key]['quantity_and_stock_status']['qty'] = $quantityAndStockStatus['qty']; + $this->variationsMatrix[$key]['weight'] = $product->getWeight(); + } + } + } + + /** + * Add matrix variation + * + * @param array $variationsMatrix + * @param array $attribute + * @param string $attributeKey + * @return array + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function addVariationMatrix(array $variationsMatrix, array $attribute, $attributeKey) + { + $result = []; + + /* If empty matrix add one empty row */ + if (empty($variationsMatrix)) { + $variationsMatrix = [ + [ + 'name' => 'In configurable product %isolation%', + 'sku' => 'in_configurable_product_%isolation%', + ] + ]; + } + + foreach ($variationsMatrix as $rowKey => $row) { + foreach ($attribute['options'] as $optionKey => $option) { + $compositeKey = "{$attributeKey}:{$optionKey}"; + $optionId = $this->getAttributeOptionId($compositeKey); + + $row['name'] .= '-' . $optionId; + $row['sku'] .= '_' . $optionId; + + $newRowKey = $rowKey ? "{$rowKey} {$compositeKey}" : $compositeKey; + $result[$newRowKey] = $row; + } + } + + return $result; + } + + /** + * Prepare data from source + * + * @return void + */ + protected function prepareData() + { + $attributeFields = [ + 'frontend_label', + 'label', + 'frontend_input', + 'attribute_code', + 'attribute_id', + 'is_required', + 'options', + ]; + $optionFields = [ + 'label', + 'pricing_value', + 'is_percent', + 'include', + ]; + $variationMatrixFields = [ + 'configurable_attribute', + 'display', + 'name', + 'sku', + 'price', + 'quantity_and_stock_status', + 'weight', + ]; + + $this->data = [ + 'matrix' => [], + 'attributes_data' => [] + ]; + + foreach ($this->attributesData as $attributeKey => $attribute) { + foreach ($attribute['options'] as $optionKey => $option) { + $option['label'] = isset($option['view']) ? $option['view'] : $option['label']; + $attribute['options'][$optionKey] = array_intersect_key($option, array_flip($optionFields)); + } + $attribute['label'] = isset($attribute['label']) ? $attribute['label'] : $attribute['frontend_label']; + $attribute = array_intersect_key($attribute, array_flip($attributeFields)); + + $this->data['attributes_data'][$attributeKey] = $attribute; + } + foreach ($this->variationsMatrix as $key => $variationMatrix) { + $this->data['matrix'][$key] = array_intersect_key($variationMatrix, array_flip($variationMatrixFields)); + } + } + + /** + * Return data set configuration settings + * + * @return array + */ + public function getDataConfig() + { + return $this->params; + } + + /** + * Return prepared data set + * + * @param string|null $key + * @return mixed + */ + public function getData($key = null) + { + return isset($this->data[$key]) ? $this->data[$key] : $this->data; + } + + /** + * Get prepared attributes data + * + * @return array + */ + public function getAttributesData() + { + return $this->attributesData; + } + + /** + * Get prepared variations matrix + * + * @return array + */ + public function getVariationsMatrix() + { + return $this->variationsMatrix; + } + + /** + * Get prepared attributes + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Get prepared products + * + * @return array + */ + public function getProducts() + { + return $this->products; + } + + /** + * Preset array + * + * @param string $name + * @return mixed|null + */ + protected function getPreset($name) + { + return isset($this->presets[$name]) ? $this->presets[$name] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php deleted file mode 100644 index a33deec3fec..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/Curl.php +++ /dev/null @@ -1,169 +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\ConfigurableProduct\Test\Handler\CatalogProductConfigurable; - -use Mtf\System\Config; -use Mtf\Fixture\FixtureInterface; -use Mtf\Util\Protocol\CurlTransport; -use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; - -/** - * Class Curl - * Create new configurable product via curl - */ -class Curl extends ProductCurl implements CatalogProductConfigurableInterface -{ - /** - * Constructor - * - * @param Config $configuration - */ - public function __construct(Config $configuration) - { - parent::__construct($configuration); - - $this->mappingData += [ - 'is_percent' => [ - 'Yes' => 1, - 'No' => 0 - ], - 'include' => [ - 'Yes' => 1, - 'No' => 0 - ] - ]; - } - - /** - * Prepare POST data for creating product request - * - * @param FixtureInterface $fixture - * @param string|null $prefix [optional] - * @return array - */ - protected function prepareData(FixtureInterface $fixture, $prefix = null) - { - $data = parent::prepareData($fixture, null); - $attributeSetId = $data['attribute_set_id']; - $matrix = $data['configurable_attributes_data']['matrix']; - $attributesData = $data['configurable_attributes_data']['attributes_data']; - unset($data['configurable_attributes_data'], $data['attribute_set_id']); - - // Preparing attribute data - $attributesIds = []; - $data['configurable_attributes_data'] = $this->preparingAttributeData($attributesData, $attributesIds); - $matrix = $this->preparingMatrixData( - $matrix, - [ - '%product_name%' => $data['name'], - '%product_sku%' => $data['sku'], - ] - ); - - // Add prefix data - $data = $prefix ? [$prefix => $data] : $data; - $data['attributes'] = $attributesIds; - - $data = array_merge($data, $this->prepareVariationsMatrix($matrix)); - $data['new-variations-attribute-set-id'] = $attributeSetId; - - return $this->replaceMappingData($data); - } - - /** - * Preparing attribute data - * - * @param array $attributesData - * @param array $attributesIds [link] - * @return array - */ - protected function preparingAttributeData(array $attributesData, array &$attributesIds) - { - $data = []; - foreach ($attributesData as $attribute) { - $attributesIds[] = $attribute['id']; - $data[$attribute['id']] = []; - $dataOption = & $data[$attribute['id']]; - $dataOption['code'] = $attribute['title']; - $dataOption['label'] = $attribute['title']; - $dataOption['attribute_id'] = $attribute['id']; - foreach ($attribute['options'] as $option) { - $dataOption['values'][$option['id']]['pricing_value'] = $option['pricing_value']; - $dataOption['values'][$option['id']]['is_percent'] = $option['is_percent']; - $dataOption['values'][$option['id']]['include'] = $option['include']; - $dataOption['values'][$option['id']]['value_index'] = $option['id']; - } - } - - return $data; - } - - /** - * Preparing matrix data - * - * @param array $matrix - * @param array $placeholder - * @return array - */ - protected function preparingMatrixData(array $matrix, array $placeholder) - { - foreach (array_keys($matrix) as $key) { - foreach ($matrix[$key] as &$value) { - if (is_string($value)) { - $value = strtr($value, $placeholder); - } - } - } - - return $matrix; - } - - /** - * Prepare variations matrix data - * - * @param array $matrix - * @return array - */ - protected function prepareVariationsMatrix(array $matrix) - { - $data = [ - 'variations-matrix' => [], - 'associated_product_ids' => [] - ]; - foreach ($matrix as $key => $variation) { - $data['associated_product_ids'] = array_merge( - $data['associated_product_ids'], - $variation['associated_product_ids'] - ); - $data['variations-matrix'][$key]['name'] = $variation['name']; - $data['variations-matrix'][$key]['configurable_attribute'] = $variation['configurable_attribute']; - $data['variations-matrix'][$key]['sku'] = $variation['sku']; - $data['variations-matrix'][$key]['quantity_and_stock_status']['qty'] = $variation['qty']; - $data['variations-matrix'][$key]['weight'] = $variation['weight']; - } - - return $data; - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php similarity index 82% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php index dba4fea8b1d..049f914bd9e 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/CatalogProductConfigurable/CatalogProductConfigurableInterface.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/ConfigurableProductInjectableInterface.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable; +namespace Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable; use Mtf\Handler\HandlerInterface; /** - * Interface CatalogProductConfigurableInterface + * Interface ConfigurableProductInjectableInterface */ -interface CatalogProductConfigurableInterface extends HandlerInterface +interface ConfigurableProductInjectableInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php new file mode 100644 index 00000000000..d0f6e70df45 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProductInjectable/Curl.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\Handler\ConfigurableProductInjectable; + +use Mtf\System\Config; +use Mtf\Fixture\FixtureInterface; +use Mtf\Util\Protocol\CurlTransport; +use Magento\Catalog\Test\Handler\CatalogProductSimple\Curl as ProductCurl; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableAttributesData; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; + +/** + * Class Curl + * Create new configurable product via curl + */ +class Curl extends ProductCurl implements ConfigurableProductInjectableInterface +{ + /** + * Constructor + * + * @param Config $configuration + */ + public function __construct(Config $configuration) + { + parent::__construct($configuration); + + $this->mappingData += [ + 'is_percent' => [ + 'Yes' => 1, + 'No' => 0 + ], + 'include' => [ + 'Yes' => 1, + 'No' => 0 + ] + ]; + } + + /** + * Prepare POST data for creating product request + * + * @param FixtureInterface $product + * @param string|null $prefix [optional] + * @return array + */ + protected function prepareData(FixtureInterface $product, $prefix = null) + { + $data = parent::prepareData($product, null); + + /** @var ConfigurableAttributesData $configurableAttributesData */ + $configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source']; + $attributeSetId = $data['attribute_set_id']; + + $data['configurable_attributes_data'] = $this->prepareAttributesData($configurableAttributesData); + $data = $prefix ? [$prefix => $data] : $data; + $data['variations-matrix'] = $this->prepareVariationsMatrix($product); + $data['attributes'] = $this->prepareAttributes($configurableAttributesData); + $data['new-variations-attribute-set-id'] = $attributeSetId; + $data['associated_product_ids'] = []; + + return $this->replaceMappingData($data); + } + + /** + * Preparing attribute data + * + * @param ConfigurableAttributesData $configurableAttributesData + * @return array + */ + protected function prepareAttributesData(ConfigurableAttributesData $configurableAttributesData) + { + $optionFields = [ + 'pricing_value', + 'is_percent', + 'include', + ]; + $result = []; + + foreach ($configurableAttributesData->getAttributesData() as $attribute) { + $attributeId = isset($attribute['attribute_id']) ? $attribute['attribute_id'] : null; + $dataOptions = []; + + foreach ($attribute['options'] as $option) { + $optionId = isset($option['id']) ? $option['id'] : null; + + $dataOption = array_intersect_key($option, array_flip($optionFields)); + $dataOption['value_index'] = $optionId; + + $dataOptions[$optionId] = $dataOption; + } + + $result[$attributeId] = [ + 'code' => $attribute['attribute_code'], + 'attribute_id' => $attributeId, + 'label' => $attribute['frontend_label'], + 'values' => $dataOptions + ]; + } + + return $result; + } + + /** + * Preparing matrix data + * + * @param FixtureInterface $product + * @return array + */ + protected function prepareVariationsMatrix(FixtureInterface $product) + { + /** @var ConfigurableAttributesData $configurableAttributesData */ + $configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source']; + $attributesData = $configurableAttributesData->getAttributesData(); + $matrixData = $product->getConfigurableAttributesData()['matrix']; + $result = []; + + foreach ($matrixData as $variationKey => $variation) { + $compositeKeys = explode(' ', $variationKey); + $keyIds = []; + $configurableAttribute = []; + + foreach ($compositeKeys as $compositeKey) { + list($attributeKey, $optionKey) = explode(':', $compositeKey); + $attribute = $attributesData[$attributeKey]; + + $keyIds[] = $attribute['options'][$optionKey]['id']; + $configurableAttribute[] = sprintf( + '"%s":"%s"', + $attribute['attribute_code'], + $attribute['options'][$optionKey]['id'] + ); + } + + $keyIds = implode('-', $keyIds); + $variation['configurable_attribute'] = '{' . implode(',', $configurableAttribute) . '}'; + $result[$keyIds] = $variation; + } + + return $result; + } + + /** + * Prepare attributes + * + * @param ConfigurableAttributesData $configurableAttributesData + * @return array + */ + protected function prepareAttributes(ConfigurableAttributesData $configurableAttributesData) + { + $ids = []; + + foreach ($configurableAttributesData->getAttributes() as $attribute) { + /** @var CatalogProductAttribute $attribute */ + $ids[] = $attribute->getAttributeId(); + } + return $ids; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php similarity index 94% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php index 3b57ed5855a..b3d8769e3a2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Curl/CreateConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/Curl/CreateConfigurable.php @@ -23,15 +23,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\Handler\Curl; +namespace Magento\ConfigurableProduct\Test\Handler\Curl; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; -use Mtf\Fixture\FixtureInterface; use Mtf\Handler\Curl; use Mtf\System\Config; use Mtf\Util\Protocol\CurlInterface; use Mtf\Util\Protocol\CurlTransport; use Mtf\Util\Protocol\CurlTransport\BackendDecorator; +use Mtf\Fixture\FixtureInterface; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class Create Configurable Product @@ -46,13 +46,13 @@ class CreateConfigurable extends Curl */ protected function _prepareData(ConfigurableProduct $fixture) { - $curlData = array(); + $curlData = []; $curlData['product'] = $this->_getProductData($fixture); $curlData['product']['configurable_attributes_data'] = $this->_getConfigurableData($fixture); $curlData['variations-matrix'] = $this->_getVariationMatrix($fixture); $curlData['attributes'] = $fixture->getDataConfig()['attributes']['id']; - $curlData['affect_configurable_product_attributes'] = 1; + $curlData['affected_attribute_set'] = 1; $curlData['new-variations-attribute-set-id'] = 4; $curlData['product']['category_ids'] = $fixture->getCategoryIds(); @@ -71,7 +71,7 @@ class CreateConfigurable extends Curl */ protected function _getProductData(ConfigurableProduct $fixture) { - $curlData = array(); + $curlData = []; $baseData = $fixture->getData('fields'); unset($baseData['configurable_attributes_data']); unset($baseData['variations-matrix']); @@ -85,10 +85,10 @@ class CreateConfigurable extends Curl } $curlData['quantity_and_stock_status']['is_in_stock'] = 1; - $curlData['stock_data'] = array( + $curlData['stock_data'] = [ 'use_config_manage_stock' => 1, 'is_in_stock' => 1 - ); + ]; return $curlData; } @@ -103,7 +103,7 @@ class CreateConfigurable extends Curl { $configurableAttribute = $fixture->getData('fields/configurable_attributes_data/value'); $config = $fixture->getDataConfig(); - $curlData = array(); + $curlData = []; foreach ($configurableAttribute as $attributeNumber => $attribute) { $attributeId = $config['attributes']['id'][$attributeNumber]; @@ -137,7 +137,7 @@ class CreateConfigurable extends Curl { $config = $fixture->getDataConfig(); $variationData = $fixture->getData('fields/variations-matrix/value'); - $curlData = array(); + $curlData = []; $variationNumber = 0; foreach ($config['options'] as $attributeId => $options) { foreach ($options['id'] as $option) { @@ -174,7 +174,7 @@ class CreateConfigurable extends Curl $params = $this->_prepareData($fixture); $curl = new BackendDecorator(new CurlTransport(), new Config()); $curl->addOption(CURLOPT_HEADER, 1); - $curl->write(CurlInterface::POST, $url, '1.0', array(), $params); + $curl->write(CurlInterface::POST, $url, '1.0', [], $params); $response = $curl->read(); $curl->close(); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductEdit.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductEdit.xml old mode 100644 new mode 100755 diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml old mode 100644 new mode 100755 index 4f9d7579b29..88d3d654d50 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Adminhtml/CatalogProductNew.xml @@ -25,10 +25,19 @@ --> <page mca="catalog/product/new"> <blocks> - <configurableForm> + <formPageActions> + <renders> + <configurable> + <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\FormPageActions</class> + </configurable> + </renders> + </formPageActions> + <productForm> + <renders> + <configurable> <class>Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\ProductForm</class> - <locator>[id="page:main-container"]</locator> - <strategy>css selector</strategy> - </configurableForm> + </configurable> + </renders> + </productForm> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.xml new file mode 100644 index 00000000000..af7e9ddc1bd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Page/Product/CatalogProductView.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) + */ +--> +<page mca="catalog/product/view"> + <blocks> + <viewBlock> + <renders> + <configurable> + <class>Magento\ConfigurableProduct\Test\Block\Product\View</class> + </configurable> + </renders> + </viewBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php old mode 100755 new mode 100644 similarity index 88% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php index 37877aab6da..79069c70ee1 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigurableProduct.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.php @@ -21,10 +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\Catalog\Test\Repository; +namespace Magento\ConfigurableProduct\Test\Repository; use Magento\Catalog\Test\Fixture; -use Magento\Catalog\Test\Fixture\ConfigurableProduct as ConfigurableProductFixture; +use Magento\Catalog\Test\Repository\Product; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct as ConfigurableProductFixture; /** * Class Configurable Product Repository @@ -121,7 +122,7 @@ class ConfigurableProduct extends Product protected function buildProductVariations(array $defaultData) { $data = $defaultData; - $data['affect_configurable_product_attributes'] = 'Template %isolation%'; + $data['affected_attribute_set'] = 'Template %isolation%'; $data['fields'] = array( 'configurable_attributes_data' => array( 'value' => array( @@ -169,6 +170,9 @@ class ConfigurableProduct extends Product protected function editConfigurable() { $editData = array( + 'config' => [ + 'type_id' => 'configurable' + ], 'data' => array( 'fields' => array( 'name' => array( @@ -205,7 +209,23 @@ class ConfigurableProduct extends Product ), 'variations-matrix' => array( 'value' => array( - '0' => array( + '0' => [ + 'value' => [ + 'display' => array( + 'value' => 'Yes', + 'input' => 'checkbox' + ), + ] + ], + '1' => [ + 'value' => [ + 'display' => array( + 'value' => 'Yes', + 'input' => 'checkbox' + ), + ] + ], + '2' => array( 'configurable_attribute' => array( '0' => array( 'attribute_option' => 'Option3_%isolation%' diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php similarity index 91% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php index b7a8498137d..bd125a2ebdd 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/CatalogProductConfigurable.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProductInjectable.php @@ -27,10 +27,10 @@ namespace Magento\ConfigurableProduct\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductConfigurable + * Class ConfigurableProductInjectable * Data for creation Catalog Product Configurable */ -class CatalogProductConfigurable extends AbstractRepository +class ConfigurableProductInjectable extends AbstractRepository { /** * Constructor @@ -50,16 +50,17 @@ class CatalogProductConfigurable extends AbstractRepository 'status' => 'Product online', 'visibility' => 'Catalog, Search', 'tax_class_id' => ['dataSet' => 'Taxable Goods'], - 'url_key' => 'test-configurable-product-%isolation%', + 'url_key' => 'configurable-product-%isolation%', 'configurable_attributes_data' => ['preset' => 'default'], 'quantity_and_stock_status' => [ 'is_in_stock' => 'In Stock', ], 'website_ids' => ['Main Website'], 'attribute_set_id' => ['dataSet' => 'default'], + 'checkout_data' => ['preset' => 'default'], ]; - $this->_data['default_one_variation'] = [ + $this->_data['one_variation'] = [ 'name' => 'Test configurable product %isolation%', 'sku' => 'sku_test_configurable_product_%isolation%', 'price' => ['value' => 120.00], diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php new file mode 100644 index 00000000000..4c57a3af5cd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Catalog\Test\Fixture\CatalogCategory; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable; + +/** + * Test Coverage for CreateConfigurableProductEntity + * + * Test Flow: + * + * Preconditions: + * 1. Two simple products are created. + * 2. Configurable attribute with two options is created + * 3. Configurable attribute added to Default template + * + * Steps: + * 1. Go to Backend + * 2. Open Product -> Catalog + * 3. Click on narrow near "Add Product" button + * 4. Select Configurable Product + * 5. Fill in data according to data sets + * 5.1 If field "attributeNew/dataSet" is not empty - search created attribute by putting it's name + * to variation Search field. + * 5.2 If "attribute/dataSet" is not empty- create new Variation Set + * 6. Save product + * 7. Perform all assertions + * + * @group Configurable_Product_(MX) + * @ZephyrId MAGETWO-26041 + */ +class CreateConfigurableProductEntityTest extends Injectable +{ + /** + * Product page with a grid + * + * @var CatalogProductIndex + */ + protected $productIndex; + + /** + * Page to create a product + * + * @var CatalogProductNew + */ + protected $productNew; + + /** + * Injection data + * + * @param CatalogProductIndex $productIndex + * @param CatalogProductNew $productNew + * @return void + */ + public function __inject(CatalogProductIndex $productIndex, CatalogProductNew $productNew) + { + $this->productIndex = $productIndex; + $this->productNew = $productNew; + } + + /** + * Test create catalog Configurable product run + * + * @param ConfigurableProductInjectable $product + * @return void + */ + public function test(ConfigurableProductInjectable $product) + { + // Steps + $this->productIndex->open(); + $this->productIndex->getGridPageActionBlock()->addProduct('configurable'); + $this->productNew->getProductForm()->fill($product); + $this->productNew->getFormPageActions()->save($product); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv new file mode 100644 index 00000000000..89c333704a0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest/test.csv @@ -0,0 +1,5 @@ +"product/data/configurable_attributes_data/preset";"product/data/checkout_data/preset";"product/data/name";"product/data/sku";"product/data/tax_class_id";"product/data/price/value";"product/data/special_price";"product/data/category_ids/presets";"product/data/short_description";"product/data/description";"product/data/weight";"product/data/quantity_and_stock_status/is_in_stock";"product/data/affected_attribute_set";"constraint";"issue" +"two_new_options";"two_new_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"default_subcategory";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertProductInCategory, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertChildProductIsNotDisplayedSeparately";"Bug: MAGETWO-26979" +"two_options";"two_options";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"-";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" +"two_new_options";"two_new_options_with_special_price";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"10";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertChildProductsInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart, assertProductSpecialPriceOnProductPage";"Bug: MAGETWO-26979" +"two_options_with_assigned_product";"two_options_with_assigned_product";"Configurable Product %isolation%";"configurable_sku_%isolation%";"-";"100";"-";"-";"Configurable short description";"Configurable Product description %isolation%";"2";"In Stock";"custom_attribute_set_%isolation%";"assertProductSaveMessage, assertProductInGrid, assertConfigurableProductForm, assertConfigurableProductPage, assertProductInStock, assertConfigurableProductInCart";"" diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php similarity index 88% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php index ba57c01cbce..f126cdd375a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateConfigurableTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableTest.php @@ -22,11 +22,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class CreateConfigurableTest @@ -34,16 +34,6 @@ use Magento\Catalog\Test\Fixture\ConfigurableProduct; */ class CreateConfigurableTest extends Functional { - /** - * Login into backend area before test - * - * @return void - */ - protected function setUp() - { - Factory::getApp()->magentoBackendLoginUser(); - } - /** * Creating configurable product and assigning it to category * @@ -53,7 +43,7 @@ class CreateConfigurableTest extends Functional public function testCreateConfigurableProduct() { //Data - $product = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $product = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $product->switchData('configurable'); //Page & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); @@ -61,9 +51,8 @@ class CreateConfigurableTest extends Functional //Steps $manageProductsGrid->open(); $manageProductsGrid->getGridPageActionBlock()->addProduct('configurable'); - $productForm = $createProductPage->getProductForm(); - $productForm->fill($product); - $createProductPage->getFormAction()->saveProduct($createProductPage, $product); + $createProductPage->getProductForm()->fill($product); + $createProductPage->getFormPageActions()->save($product); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache @@ -82,7 +71,7 @@ class CreateConfigurableTest extends Functional * @param ConfigurableProduct $product * @return void */ - protected function assertOnGrid($product) + protected function assertOnGrid(ConfigurableProduct $product) { //Search data $configurableSearch = [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php old mode 100755 new mode 100644 similarity index 76% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php index 898c802d99c..8194b254bc0 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/CreateWithAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateWithAttributeTest.php @@ -22,13 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product\Configurable; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; use Mtf\TestCase\Functional; use Magento\Catalog\Test\Fixture\Product; use Magento\Catalog\Test\Fixture\ProductAttribute; -use Magento\Catalog\Test\Fixture\ConfigurableProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; /** * Class CreateWithAttributeTest @@ -36,16 +36,6 @@ use Magento\Catalog\Test\Fixture\ConfigurableProduct; */ class CreateWithAttributeTest extends Functional { - /** - * Login into backend area before test - * - * @return void - */ - protected function setUp() - { - Factory::getApp()->magentoBackendLoginUser(); - } - /** * Creating configurable product with creating new category and new attribute (required fields only) * @@ -61,7 +51,7 @@ class CreateWithAttributeTest extends Functional $attribute = Factory::getFixtureFactory()->getMagentoCatalogProductAttribute(); $attribute->switchData('new_attribute'); - $variations = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $variations = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $variations->switchData('product_variations'); $variations->provideNewAttributeData($attribute); @@ -82,11 +72,11 @@ class CreateWithAttributeTest extends Functional * @param Product $product * @return void */ - protected function fillSimpleProductWithNewCategory($product) + protected function fillSimpleProductWithNewCategory(Product $product) { //Page & Blocks $manageProductsGrid = Factory::getPageFactory()->getCatalogProductIndex(); - $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $createProductPage = Factory::getPageFactory()->getCatalogProductEdit(); $productForm = $createProductPage->getProductForm(); //Steps @@ -105,19 +95,21 @@ class CreateWithAttributeTest extends Functional */ protected function addNewAttribute(ProductAttribute $attribute) { - $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $attributeData = $attribute->getData(); + $attributeFields = []; + foreach ($attributeData['fields'] as $name => $field) { + $attributeFields[$name] = $field['value']; + } + $attributeFields['options'] = $attributeData['options']['value']; - $productForm = $createProductPage->getConfigurableProductForm(); - $productForm->openVariationsTab(); - $productForm->clickCreateNewVariationSet(); - - $newAttributeForm = $productForm->getConfigurableAttributeEditBlock(); - $this->assertTrue($newAttributeForm->isVisible(), '"New attribute" window is not opened'); + $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); + $productForm = $createProductPage->getProductForm(); + $productForm->openTab('variations'); - $newAttributeForm->openFrontendProperties(); - $newAttributeForm->fill($attribute); - $newAttributeForm->saveAttribute(); - Factory::getClientBrowser()->switchToFrame(); + /** @var \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config $variations */ + $variations = $productForm->getTabElement('variations'); + $variations->showContent(); + $variations->getAttributeBlock()->fillAttributes([$attributeFields]); } /** @@ -128,9 +120,26 @@ class CreateWithAttributeTest extends Functional */ protected function fillProductVariationsAndSave(ConfigurableProduct $variations) { + $variationsData = $variations->getData(); + $matrix = []; + foreach ($variationsData['fields']['variations-matrix']['value'] as $variation) { + $matrix[] = [ + 'quantity_and_stock_status' => [ + 'qty' => $variation['value']['qty']['value'] + ] + ]; + } + $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); - $createProductPage->getProductForm()->fillVariations($variations); - $createProductPage->getFormAction()->saveProduct($createProductPage, $variations); + $productForm = $createProductPage->getProductForm(); + $productForm->openTab('variations'); + + /** @var \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Super\Config $variationsTab */ + $variationsTab = $productForm->getTabElement('variations'); + $variationsTab->generateVariations(); + $variationsTab->getVariationsBlock()->fillVariations($matrix); + + $createProductPage->getFormPageActions()->save($variations); } /** @@ -156,10 +165,10 @@ class CreateWithAttributeTest extends Functional */ protected function assertOnGrid(Product $product) { - $configurableSearch = array( + $configurableSearch = [ 'sku' => $product->getProductSku(), 'type' => 'Configurable Product', - ); + ]; $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); $gridBlock = $productGridPage->getProductGrid(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php old mode 100755 new mode 100644 similarity index 92% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php rename to dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php index 7c4e5dfc882..a63df3a08ee --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/Configurable/EditConfigurableTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/EditConfigurableTest.php @@ -22,10 +22,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Test\TestCase\Product\Configurable; +namespace Magento\ConfigurableProduct\Test\TestCase; use Mtf\Factory\Factory; -use Magento\Catalog\Test\TestCase\Product\CreateConfigurableTest; /** * Class EditConfigurableTest @@ -43,12 +42,13 @@ class EditConfigurableTest extends CreateConfigurableTest { //Preconditions //Preparing Data for original product - $configurable = Factory::getFixtureFactory()->getMagentoCatalogConfigurableProduct(); + $configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $configurable->switchData('configurable'); $configurable->persist(); $productSku = $configurable->getProductSku(); //Preparing Data for editing product $editProduct = $configurable->getEditData(); + //Steps $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); $productForm = $createProductPage->getProductForm(); @@ -60,7 +60,7 @@ class EditConfigurableTest extends CreateConfigurableTest $productGridPage->getProductGrid()->searchAndOpen(['sku' => $productSku]); //Editing product options $productForm->fill($editProduct); - $createProductPage->getFormAction()->save(); + $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->assertSuccessMessage(); //Flush cache diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php deleted file mode 100755 index 05581120708..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest.php +++ /dev/null @@ -1,118 +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\ConfigurableProduct\Test\TestCase\Product; - -use Mtf\TestCase\Injectable; -use Magento\Catalog\Test\Fixture\CatalogCategory; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; - -/** - * Test Coverage for CreateConfigurableProductEntity - * - * General Flow: - * 1. Log in to Backend. - * 2. Navigate to Products > Catalog. - * 3. Start to create new product. - * 4. Fill in data according to data set. - * 5. Save product. - * 6. Verify created product. - * - * @ticketId MAGETWO-20024 - */ -class CreateConfigurableEntityTest extends Injectable -{ - /** - * Category fixture - * - * @var CatalogCategory - */ - protected $category; - - /** - * Backend catalog page (product grid) - * - * @var CatalogProductIndex - */ - protected $productPageGrid; - - /** - * Product page (product form) - * - * @var CatalogProductNew - */ - protected $newProductPage; - - /** - * Prepare data - * - * @param CatalogCategory $category - * @return array - */ - public function __prepare(CatalogCategory $category) - { - $category->persist(); - - return [ - 'category' => $category - ]; - } - - /** - * Inject data - * - * @param CatalogCategory $category - * @param CatalogProductIndex $productPageGrid - * @param CatalogProductNew $newProductPage - */ - public function __inject( - CatalogCategory $category, - CatalogProductIndex $productPageGrid, - CatalogProductNew $newProductPage - ) { - $this->category = $category; - $this->productPageGrid = $productPageGrid; - $this->newProductPage = $newProductPage; - } - - /** - * Run create configurable product test - * - * @param CatalogProductConfigurable $configurable - * @param CatalogCategory $category - * @return void - */ - public function testCreate(CatalogProductConfigurable $configurable, CatalogCategory $category) - { - // Steps - $this->productPageGrid->open(); - $this->productPageGrid->getGridPageActionBlock()->addProduct('configurable'); - // Fill form - $productBlockForm = $this->newProductPage->getConfigurableProductForm(); - $productBlockForm->fill($configurable, null, $category); - $this->newProductPage->getFormAction()->saveProduct($this->newProductPage, $configurable); - } -} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv deleted file mode 100755 index 628ab880371..00000000000 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/Product/CreateConfigurableEntityTest/testCreate.csv +++ /dev/null @@ -1,2 +0,0 @@ -"configurable/data/name"; "configurable/data/sku"; "configurable/data/price/value"; "configurable/data/weight"; "configurable/data/quantity_and_stock_status/qty"; "configurable/data/quantity_and_stock_status/is_in_stock"; "configurable/data/visibility"; "constraint"; "configurable/data/price/preset";"configurable/data/configurable_attributes_data/preset"; -"Configurable %isolation%"; "conf_sku_%isolation%";"100";"1";"-";"-";"-"; "assertProductSaveMessage, assertConfigurableInGrid, assertConfigurableInCategory, assertConfigurableView, assertConfigurableInCart";"MAGETWO-23062";"default"; diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml index 242fa892490..07c56238913 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/constraint.xml @@ -24,59 +24,28 @@ */ --> <constraint> - <assertConfigurableInGrid module="Magento_ConfigurableProduct"> + <assertConfigurableProductInCart module="Magento_ConfigurableProduct"> + <severeness>low</severeness> + </assertConfigurableProductInCart> + <assertConfigurableProductDuplicateForm module="Magento_ConfigurableProduct"> <severeness>high</severeness> - <require> - <manageProductsPage class="Magento\Catalog\Test\Page\Product\CatalogProductIndex" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - </require> - </assertConfigurableInGrid> - <assertConfigurableInCategory module="Magento_ConfigurableProduct"> + </assertConfigurableProductDuplicateForm> + <assertChildProductIsNotDisplayedSeparately module="Magento_ConfigurableProduct"> + <severeness>middle</severeness> + </assertChildProductIsNotDisplayedSeparately> + <assertChildProductsInGrid module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogCategoryView class="Magento\Catalog\Test\Page\Category\CatalogCategoryView" /> - <cmsIndex class="Magento\Cms\Test\Page\CmsIndex" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - <category class="Magento\Catalog\Test\Fixture\Category" /> - </require> - </assertConfigurableInCategory> - <assertConfigurableView module="Magento_ConfigurableProduct"> + </assertChildProductsInGrid> + <assertConfigurableProductForm module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - </require> - </assertConfigurableView> - <assertConfigurableInCart module="Magento_ConfigurableProduct"> + </assertConfigurableProductForm> + <assertConfigurableProductInItemsOrderedGrid module="Magento_ConfigurableProduct"> <severeness>low</severeness> - <require> - <catalogProductView class="Magento\Catalog\Test\Page\Product\CatalogProductView" /> - <configurable class="Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable" /> - <checkoutCart class="Magento\Checkout\Test\Page\CheckoutCart" /> - </require> - </assertConfigurableInCart> - <assertProductAttributeIsConfigurable module="Magento_ConfigurableProduct"> - <severeness>high</severeness> - <require> - <productAttribute class="Magento\Catalog\Test\Fixture\CatalogAttributeEntity" /> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <newProductPage class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew" /> - </require> - </assertProductAttributeIsConfigurable> - <assertProductConfigurableDuplicateForm module="Magento_ConfigurableProduct"> + </assertConfigurableProductInItemsOrderedGrid> + <assertConfigurableProductPage module="Magento_ConfigurableProduct"> <severeness>high</severeness> - <require> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <productPage class="Magento\ConfigurableProduct\Test\Page\Adminhtml\CatalogProductEdit" /> - <product class="Mtf\Fixture\FixtureInterface" /> - </require> - </assertProductConfigurableDuplicateForm> - <assertConfigurableProductForm module="Magento_ConfigurableProduct"> - <severeness>high</severeness> - <require> - <productGrid class="Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex" /> - <productPage class="Magento\ConfigurableProduct\Test\Page\Adminhtml\CatalogProductEdit" /> - <product class="Mtf\Fixture\FixtureInterface" /> - </require> - </assertConfigurableProductForm> + </assertConfigurableProductPage> + <assertProductAttributeAbsenceInVariationsSearch module="Magento_ConfigurableProduct"> + <severeness>low</severeness> + </assertProductAttributeAbsenceInVariationsSearch> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml old mode 100644 new mode 100755 index c60ac77fe79..1e7f710a6de --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/curl/di.xml @@ -24,5 +24,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <preference for="Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\CatalogProductConfigurableInterface" type="\Magento\ConfigurableProduct\Test\Handler\CatalogProductConfigurable\Curl" /> + <preference for="Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\ConfigurableProductInjectableInterface" type="\Magento\ConfigurableProduct\Test\Handler\ConfigurableProductInjectable\Curl" /> </config> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml index 0ea61b470ee..1ca8a81b2d2 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/fixture.xml @@ -25,7 +25,7 @@ --> <fixture> - <catalogProductConfigurable module="Magento_ConfigurableProduct"> + <configurableProductInjectable module="Magento_ConfigurableProduct"> <type>eav</type> <entity_type>catalog_product</entity_type> <product_type>configurable</product_type> @@ -49,7 +49,7 @@ <backend_type>virtual</backend_type> <is_required>0</is_required> <group>variations</group> - <fixture>Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\ConfigurableOptions</fixture> + <fixture>Magento\ConfigurableProduct\Test\Fixture\ConfigurableProductInjectable\ConfigurableOptions</fixture> </configurable_options> </fields> <data_set> @@ -66,5 +66,5 @@ </create_url_params> <input_prefix>product</input_prefix> </data_config> - </catalogProductConfigurable> + </configurableProductInjectable> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml new file mode 100644 index 00000000000..d9c92344d7d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/etc/page.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page module="Magento_ConfigurableProduct"> + <catalogProductEdit> + <mca>catalog/product/edit</mca> + <area>adminhtml</area> + <class>Magento\Configurable\Test\Page\Adminhtml\CatalogProductEdit</class> + </catalogProductEdit> + <catalogProductNew> + <mca>catalog/product/edit</mca> + <area>adminhtml</area> + <class>Magento\Configurable\Test\Page\Adminhtml\CatalogProductNew</class> + </catalogProductNew> + <catalogProductView> + <mca>catalog/product/view</mca> + <area>product</area> + <class>Magento\Configurable\Test\Page\CatalogProductView</class> + </catalogProductView> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php index c72bb53b30f..31297e06bdc 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php +++ b/dev/tests/functional/tests/app/Magento/Core/Test/Block/Messages.php @@ -89,6 +89,24 @@ class Messages extends Block return count($messages) > 1 ? $messages : $messages[0]; } + /** + * Wait for element is visible in the page + * + * @param string $selector + * @param string $strategy + * @return bool|null + */ + public function waitForElementVisible($selector, $strategy = Locator::SELECTOR_CSS) + { + $browser = $this->browser; + return $browser->waitUntil( + function () use ($browser, $selector, $strategy) { + $message = $browser->find($selector, $strategy); + return $message->isVisible() ? true : null; + } + ); + } + /** * Get all error messages which are present on the page * diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php index 062bb11cb81..72fddd7a340 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/CustomerGrid.php @@ -33,6 +33,13 @@ use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; */ class CustomerGrid extends AbstractGrid { + /** + * Selector for action option select + * + * @var string + */ + protected $option = '[name="group"]'; + /** * Filters array mapping * diff --git a/lib/internal/Magento/Framework/Error/HandlerInterface.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php similarity index 65% rename from lib/internal/Magento/Framework/Error/HandlerInterface.php rename to dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php index 5bc4cd4a01d..59be071e65e 100644 --- a/lib/internal/Magento/Framework/Error/HandlerInterface.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/FormPageActions.php @@ -22,30 +22,30 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Test\Block\Adminhtml\Edit; + +use Magento\Backend\Test\Block\FormPageActions as ParentFormPageActions; + /** - * Interface of Error Handler + * Class FormPageActions + * Form page actions block for customer page */ -namespace Magento\Framework\Error; - -interface HandlerInterface +class FormPageActions extends ParentFormPageActions { /** - * Error handler callback method + * "Create Order" button * - * @param int $errorNo - * @param string $errorStr - * @param string $errorFile - * @param int $errorLine - * @return bool + * @var string */ - public function handler($errorNo, $errorStr, $errorFile, $errorLine); + protected $createOrderButton = '#order'; /** - * Process exception + * Click on "Create Order" button * - * @param \Exception $exception - * @param string[] $params * @return void */ - public function processException(\Exception $exception, array $params = array()); + public function createOrder() + { + $this->_rootElement->find($this->createOrderButton)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.php new file mode 100644 index 00000000000..fc88269417a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertMassActionSuccessUpdateMessage.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 Mtf\Constraint\AbstractConstraint; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; + +/** + * Class AssertMassActionSuccessUpdateMessage + * Assert update message is appears on customer grid (Customers > All Customers) + */ +class AssertMassActionSuccessUpdateMessage extends AbstractConstraint +{ + /** + * Text value to be checked + */ + const UPDATE_MESSAGE = 'A total of %d record(s) were updated.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert update message is appears on customer grid (Customers > All Customers) + * + * @param CustomerInjectable|CustomerInjectable[] $customer + * @param CustomerIndex $pageCustomerIndex + * @return void + */ + public function processAssert($customer, CustomerIndex $pageCustomerIndex) + { + $customers = is_array($customer) ? $customer : [$customer]; + $customerCount = count($customers); + $actualMessage = $pageCustomerIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertEquals(sprintf(self::UPDATE_MESSAGE, $customerCount), $actualMessage); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Assert that update message is displayed.'; + } +} 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 index 695bd999815..910d212ce63 100644 --- 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 @@ -117,7 +117,7 @@ class GroupId implements FixtureInterface * * @return array */ - public function getAddresses() + public function getCustomerGroup() { return $this->customerGroupFixture; } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml index 0a43813146a..903c8a5a4fc 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml @@ -36,7 +36,7 @@ <strategy>css selector</strategy> </messagesBlock> <pageActionsBlock> - <class>Magento\Backend\Test\Block\FormPageActions</class> + <class>Magento\Customer\Test\Block\Adminhtml\Edit\FormPageActions</class> <locator>.page-main-actions</locator> <strategy>css selector</strategy> </pageActionsBlock> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php deleted file mode 100644 index 313553af0ae..00000000000 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.php +++ /dev/null @@ -1,87 +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. - * - * @spi - * @copyright Copyright (c) 2014 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\Page; - -use Mtf\Page\Page; -use Mtf\Factory\Factory; -use Mtf\Client\Element\Locator; - -/** - * Class CustomerAccountLogin - * Customer frontend login page. - * - */ -class CustomerAccountLogin extends Page -{ - /** - * URL for customer login - */ - const MCA = 'customer/account/login'; - - /** - * Messages block - * - * @var string - */ - protected $messagesBlock = '.page.messages'; - - /** - * Form for customer login - * - * @var string - */ - protected $loginBlock = '#login-form'; - - /** - * Custom constructor - */ - protected function _init() - { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; - } - - /** - * Get Messages block - * - * @return \Magento\Core\Test\Block\Messages - */ - public function getMessages() - { - return Factory::getBlockFactory()->getMagentoCoreMessages($this->_browser->find($this->messagesBlock)); - } - - /** - * Get customer login form - * - * @return \Magento\Customer\Test\Block\Form\Login - */ - public function getLoginBlock() - { - return Factory::getBlockFactory()->getMagentoCustomerFormLogin( - $this->_browser->find($this->loginBlock, Locator::SELECTOR_CSS) - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml new file mode 100644 index 00000000000..6405c18d535 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogin.xml @@ -0,0 +1,39 @@ +<?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="customer/account/login" module="Magento_Customer"> + <blocks> + <messages> + <class>Magento\Core\Test\Block\Messages</class> + <locator>.page.messages</locator> + <strategy>css selector</strategy> + </messages> + <loginBlock> + <class>Magento\Customer\Test\Block\Form\Login</class> + <locator>#login-form</locator> + <strategy>css selector</strategy> + </loginBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.php new file mode 100644 index 00000000000..c9230ef6296 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest.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\Customer\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Fixture\CustomerGroupInjectable; + +/** + * Test creation for MassAssignCustomerGroup + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create customer group + * + * Steps: + * 1. Open Backend + * 2. Go to Customers> All Customers + * 3. Find and select(using checkbox) created customer + * 4. Select "Assign a Customer Group" from action drop-down + * 5. Select created customer group + * 6. Click "Submit" button + * 7. Perform all assertions + * + * @group Customer_Groups_(CS), Customers_(CS) + * @ZephyrId MAGETWO-27892 + */ +class MassAssignCustomerGroupTest extends Injectable +{ + /** + * Customer index page + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customers grid actions + * + * @var string + */ + protected $customersGridActions = 'Assign a Customer Group'; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CustomerIndex $customerIndex + * @return void + */ + public function __inject(CustomerIndex $customerIndex) + { + $this->customerIndex = $customerIndex; + } + + /** + * Mass assign customer group + * + * @param CustomerInjectable $customer + * @param CustomerGroupInjectable $customerGroup + * @return void + */ + public function test(CustomerInjectable $customer, CustomerGroupInjectable $customerGroup) + { + // Steps + $customerGroup->persist(); + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->massaction( + [['email' => $customer->getEmail()]], + [$this->customersGridActions => $customerGroup->getCustomerGroupCode()] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv new file mode 100644 index 00000000000..67a66f8bf9c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassAssignCustomerGroupTest/test.csv @@ -0,0 +1,2 @@ +"customerGroup/dataSet";"constraint" +"default";"assertMassActionSuccessUpdateMessage, assertCustomerGroupInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml index c82ef107d76..48923128731 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/constraint.xml @@ -133,4 +133,7 @@ <severeness>low</severeness> <require /> </assertCustomerMassDeleteInGrid> + <assertMassActionSuccessUpdateMessage module="Magento_Customer"> + <severeness>low</severeness> + </assertMassActionSuccessUpdateMessage> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml index a40bce6276e..58b39cbc38f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/page.xml @@ -32,6 +32,10 @@ <mca>customer/account/index</mca> <class>Magento\Customer\Test\Page\CustomerAccountIndex</class> </customerAccountIndex> + <customerAccountLogin> + <mca>customer/account/login</mca> + <class>Magento\Customer\Test\Page\CustomerAccountLogin</class> + </customerAccountLogin> <customerAccountEdit> <mca>customer/account/edit</mca> <class>Magento\Customer\Test\Page\CustomerAccountEdit</class> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php index b831d11b23e..c12476856b3 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php @@ -57,7 +57,7 @@ class AssertDownloadableDuplicateForm extends AssertProductDuplicateForm $filter = ['sku' => $product->getSku() . '-1']; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $formData = $productPage->getForm()->getData($product); + $formData = $productPage->getProductForm()->getData($product); $fixtureData = $this->convertDownloadableArray($this->prepareFixtureData($product->getData())); $errors = $this->verifyData($fixtureData, $formData); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php index 40a4780c225..e6d589489fa 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.php @@ -75,6 +75,9 @@ class CatalogProductDownloadable extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -85,10 +88,6 @@ class CatalogProductDownloadable extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ @@ -120,6 +119,7 @@ class CatalogProductDownloadable extends InjectableFixture 'is_required' => '0', 'default_value' => '', 'input' => 'text', + 'group' => 'product-details', 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds' ]; diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml index e83b7dea985..b900829c1ee 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/CatalogProductDownloadable.xml @@ -37,6 +37,8 @@ <is_required>0</is_required> <default_value></default_value> <input>text</input> + <group>product-details</group> + <source>Magento\Catalog\Test\Fixture\CatalogProductSimple\CategoryIds</source> </category_ids> <cost> <attribute_code>cost</attribute_code> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php index db0a8266b81..9b064e8544a 100755 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/Create/LinksPurchasedSeparatelyTest.php @@ -61,11 +61,11 @@ class LinksPurchasedSeparatelyTest extends Functional $createProductPage->getGridPageActionBlock()->addProduct('downloadable'); $createProductPageNew = Factory::getPageFactory()->getCatalogProductNew(); - $productBlockForm = $createProductPageNew->getForm(); + $productBlockForm = $createProductPageNew->getProductForm(); $category = $this->product->getCategories()['category']; $productBlockForm->fill($this->product, null, $category); - $createProductPageNew->getFormAction()->save(); + $createProductPageNew->getFormPageActions()->save(); $createProductPageNew->getMessagesBlock()->assertSuccessMessage(); diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php index 7c7f564bc8f..d10086c72eb 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php @@ -111,8 +111,8 @@ class CreateDownloadableProductEntityTest extends Injectable { $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('downloadable'); - $productBlockForm = $this->catalogProductNew->getForm(); + $productBlockForm = $this->catalogProductNew->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php index 0c0de0794e3..0f826750300 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.php @@ -121,8 +121,8 @@ class UpdateDownloadableProductEntityTest extends Injectable { $filter = ['sku' => $this->product->getSku()]; $this->catalogProductIndex->open()->getProductGrid()->searchAndOpen($filter); - $productBlockForm = $this->catalogProductEdit->getForm(); + $productBlockForm = $this->catalogProductEdit->getProductForm(); $productBlockForm->fill($product, null, $category); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php index b85ac418f65..71fabdb0b95 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductForm.php @@ -56,7 +56,7 @@ class AssertGroupedProductForm extends AssertProductForm ) { $filter = ['sku' => $product->getSku()]; $productGrid->open()->getProductGrid()->searchAndOpen($filter); - $fieldsForm = $productPage->getForm()->getData($product); + $fieldsForm = $productPage->getProductForm()->getData($product); $fieldsFixture = $this->prepareFixtureData($product->getData()); $fieldsFixture['associated'] = $this->prepareGroupedOptions($fieldsFixture['associated']); diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php index a50d70becff..d8ecfa6b48d 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/CatalogProductGrouped.php @@ -75,6 +75,9 @@ class CatalogProductGrouped extends InjectableFixture $dataSet = '', $persist = false ) { + if (!isset($data['url_key']) && isset($data['name'])) { + $data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $data['name'])), '-'); + } parent::__construct( $configuration, $repositoryFactory, @@ -85,10 +88,6 @@ class CatalogProductGrouped extends InjectableFixture $dataSet, $persist ); - - if (!isset($this->data['url_key']) && isset($this->data['name'])) { - $this->data['url_key'] = trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $this->data['name'])), '-'); - } } protected $dataConfig = [ diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php index ed912e0c5b6..04ea3664ed7 100755 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.php @@ -105,8 +105,7 @@ class CreateGroupedProductEntityTest extends Injectable //Steps $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('grouped'); - $productBlockForm = $this->catalogProductNew->getForm(); - $productBlockForm->fill($product, null, $category); - $this->catalogProductNew->getFormAction()->save(); + $this->catalogProductNew->getProductForm()->fill($product, null, $category); + $this->catalogProductNew->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php index fbff0403b2d..cce5f8a4976 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/UpdateGroupedProductEntityTest.php @@ -94,7 +94,7 @@ class UpdateGroupedProductEntityTest extends Injectable // Steps $this->catalogProductIndex->open(); $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $originalProduct->getSku()]); - $this->catalogProductEdit->getForm()->fill($product); - $this->catalogProductEdit->getFormAction()->save(); + $this->catalogProductEdit->getProductForm()->fill($product); + $this->catalogProductEdit->getFormPageActions()->save(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.php new file mode 100644 index 00000000000..863f515d1bb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Customer/AccountsGrid.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\Reports\Test\Block\Adminhtml\Customer; + +use Mtf\ObjectManager; +use Mtf\Client\Element\Locator; + +/** + * Class AccountsGrid + * New Customer Account report grid + */ +class AccountsGrid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Mapping for fields in Account Report Grid + * + * @var array + */ + protected $dataMapping = [ + 'report_from' => 'datepicker', + 'report_to' => 'datepicker', + 'report_period' => 'select', + ]; + + /** + * Total results locator + * + * @var string + */ + protected $totalResults = 'tfoot .col-qty'; + + /** + * Filter locator + * + * @var string + */ + protected $filter = '[name=%s]'; + + /** + * Refresh button locator + * + * @var string + */ + protected $refreshButton = '[data-ui-id="adminhtml-report-grid-refresh-button"]'; + + /** + * Search accounts in report grid + * + * @var array $customersReport + * @return void + */ + public function searchAccounts(array $customersReport) + { + $customersReport = $this->prepareData($customersReport); + foreach ($customersReport as $name => $value) { + $this->_rootElement + ->find(sprintf($this->filter, $name), Locator::SELECTOR_CSS, $this->dataMapping[$name]) + ->setValue($value); + } + $this->_rootElement->find($this->refreshButton)->click(); + } + + /** + * Get total Results from New Accounts Report grid + * + * @return string + */ + public function getTotalResults() + { + return $this->_rootElement->find($this->totalResults)->getText(); + } + + /** + * Prepare data + * + * @param array $customersReport + * @return array + */ + protected function prepareData(array $customersReport) + { + foreach ($customersReport as $name => $reportFilter) { + if ($name === 'report_period') { + continue; + } + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $customersReport[$name] = $date->getData(); + } + return $customersReport; + } +} diff --git a/app/code/Magento/Install/Controller/Wizard/Administrator.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php similarity index 67% rename from app/code/Magento/Install/Controller/Wizard/Administrator.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php index ebdd7c395fa..bccabb9ab18 100644 --- a/app/code/Magento/Install/Controller/Wizard/Administrator.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Action.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,23 +21,31 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class Administrator extends \Magento\Install\Controller\Wizard +namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; + +use Magento\Backend\Test\Block\GridPageActions; + +/** + * Class Action + * Action block for Product Views Report + */ +class Action extends GridPageActions { /** - * Install administrator account + * Show Report button + * + * @var string + */ + protected $showReportButton = '#filter_form_submit'; + + /** + * Show report button click * * @return void */ - public function execute() + public function showReport() { - $this->_checkIfInstalled(); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - - $this->_view->getLayout()->addBlock('Magento\Install\Block\Admin', 'install.administrator', 'content'); - $this->_view->renderLayout(); + $this->_rootElement->find($this->showReportButton)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.php new file mode 100644 index 00000000000..9f808c067f3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.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\Reports\Test\Block\Adminhtml\Review\Products\Viewed; + +use Mtf\Block\Form; +use Mtf\ObjectManager; + +/** + * Class Filter + * Filter for Product Views Report + */ +class Filter extends Form +{ + /** + * Search products in report grid + * + * @var array $productsReport + * @return void + */ + public function viewsReport(array $viewsReport) + { + $viewsReport = $this->prepareData($viewsReport); + $data = $this->dataMapping($viewsReport); + $this->_fill($data); + } + + /** + * Prepare data + * + * @param array $viewsReport + * @return array + */ + protected function prepareData(array $viewsReport) + { + foreach ($viewsReport as $name => $reportFilter) { + if ($name === 'period_type' || $name === 'show_empty_rows') { + continue; + } + $date = ObjectManager::getInstance()->create( + '\Magento\Backend\Test\Fixture\Date', + ['params' => [], 'data' => ['pattern' => $reportFilter]] + ); + $viewsReport[$name] = $date->getData(); + } + return $viewsReport; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml similarity index 77% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml index 94b0ab23542..0d28736f7b1 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/Edit/Tab/Super/Options.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/Filter.xml @@ -25,12 +25,17 @@ --> <mapping strict="0"> <fields> - <pricing_value> - <selector>[name$='[pricing_value]']</selector> - </pricing_value> - <include> - <selector>[type="checkbox"][name$='[include]']</selector> - <input>checkbox</input> - </include> + <from> + <input>datepicker</input> + </from> + <to> + <input>datepicker</input> + </to> + <period_type> + <input>select</input> + </period_type> + <show_empty_rows> + <input>select</input> + </show_empty_rows> </fields> </mapping> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php similarity index 55% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php rename to dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php index 6f026ca74a9..a98e434e52f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Backend/ProductGrid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Review/Products/Viewed/ProductGrid.php @@ -18,51 +18,48 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @spi * @copyright Copyright (c) 2014 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\Test\Block\Backend; +namespace Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed; use Magento\Backend\Test\Block\Widget\Grid; /** * Class ProductGrid - * Backend catalog product grid - * + * Product Views Report */ class ProductGrid extends Grid { /** - * Initialize block elements + * Product in grid locator + * + * @var string + */ + protected $product = './/*[contains(.,"%s") and *[contains(@class,"price") and contains(.,"%d")]]'; + + /** + * Count product views + * + * @var string */ - protected $filters = array( - 'name' => array( - 'selector' => '#productGrid_product_filter_name' - ), - 'sku' => array( - 'selector' => '#productGrid_product_filter_sku' - ), - 'type' => array( - 'selector' => '#productGrid_product_filter_type', - 'input' => 'select' - ), - 'price_from' => array( - 'selector' => '#productGrid_product_filter_price_from' - ), - 'price_to' => array( - 'selector' => '#productGrid_product_filter_price_to' - ) - ); + protected $productView = '/*[contains(@class,"qty")]'; /** - * Update attributes for selected items + * Get views Results from Products Report grid * - * @param array $items + * @param array $products + * @return array */ - public function updateAttributes(array $items = array()) + public function getViewsResults(array $products) { - $this->massaction($items, 'Update Attributes'); + $views = []; + foreach ($products as $product) { + $views[] = $this->_rootElement + ->find(sprintf($this->product . $this->productView, $product->getName(), $product->getPrice())) + ->getText(); + } + return $views; } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.php new file mode 100644 index 00000000000..408b50fb0cf --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Shopcart/Product/Grid.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\Reports\Test\Block\Adminhtml\Shopcart\Product; + +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Products in Carts Report grid + */ +class Grid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Product row selector + * + * @var string + */ + protected $productRow = '//tr[td[contains(@class,"col-name")] and contains(.,"%s")]'; + + /** + * Product price selector + * + * @var string + */ + protected $productPrice = '//td[contains(@class,"col-price") and contains(.,"%s")]'; + + /** + * Product carts selector + * + * @var string + */ + protected $productCarts = '//td[contains(@class,"col-carts") and contains(.,"%d")]'; + + /** + * Check that product visible in grid + * + * @param CatalogProductSimple $product + * @param string $carts + * @return bool + */ + public function isProductVisible(CatalogProductSimple $product, $carts) + { + $result = false; + $productRowSelector = sprintf($this->productRow, $product->getName()); + $productPrice = sprintf($this->productPrice, $product->getPrice()); + $productRow = $this->_rootElement->find($productRowSelector, Locator::SELECTOR_XPATH); + if ($productRow->isVisible()) { + $result = $productRow->find($productPrice, Locator::SELECTOR_XPATH)->isVisible() + && $productRow->find(sprintf($this->productCarts, $carts), Locator::SELECTOR_XPATH)->isVisible(); + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.php new file mode 100644 index 00000000000..15d7e847046 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertNewAccountsReportTotalResult.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\Reports\Test\Constraint; + +use Magento\Reports\Test\Page\Adminhtml\CustomerAccounts; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertNewAccountsReportTotalResult + * Assert that new account total result is equals to data from dataSet + */ +class AssertNewAccountsReportTotalResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that new account total result is equals to data from dataSet + * + * @param CustomerAccounts $customerAccounts + * @param string $total + * @return void + */ + public function processAssert(CustomerAccounts $customerAccounts, $total) + { + $totalForm = $customerAccounts->getGridBlock()->getTotalResults(); + \PHPUnit_Framework_Assert::assertEquals($totalForm, $total); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'New account total result is equals to data from dataSet.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.php new file mode 100644 index 00000000000..48f94e5bd9d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductInCartResult.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\Reports\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Reports\Test\Page\Adminhtml\ShopCartProductReport; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; + +/** + * Class AssertProductInCartResult + * Assert that product is present in Products in Carts report grid + */ +class AssertProductInCartResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that product is present in Products in Carts report grid by name, price, carts + * + * @param ShopCartProductReport $shopCartProductReport + * @param CatalogProductSimple $product + * @param string $carts + * @return void + */ + public function processAssert(ShopCartProductReport $shopCartProductReport, CatalogProductSimple $product, $carts) + { + $shopCartProductReport->open(); + \PHPUnit_Framework_Assert::assertTrue( + $shopCartProductReport->getGridBlock()->isProductVisible($product, $carts), + 'Product is absent in Products in Carts report grid.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Product is present in Products in Carts report grid with correct carts number.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php new file mode 100644 index 00000000000..3375ac30ed1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertProductViewsReportTotalResult.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\Constraint; + +use Magento\Reports\Test\Page\Adminhtml\ProductReportView; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertProductViewsReportTotalResult + * Assert product info in report: product name, price and views + */ +class AssertProductViewsReportTotalResult extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert product info in report: product name, price and views + * + * @param ProductReportView $productReportView + * @param string $total + * @param array $productsList + * @return void + */ + public function processAssert(ProductReportView $productReportView, $total, array $productsList) + { + $total = explode(', ', $total); + $totalForm = $productReportView->getGridBlock()->getViewsResults($productsList); + \PHPUnit_Framework_Assert::assertEquals($totalForm, $total); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Products view total result is equals to data from dataSet.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml new file mode 100644 index 00000000000..b259f8c77e1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/CustomerAccounts.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" ?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<page mca="reports/report_customer/accounts/index" module="Magento_Reports"> + <blocks> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Customer\AccountsGrid</class> + <locator>#gridAccounts</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml new file mode 100644 index 00000000000..32c82d39a3a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ProductReportView.xml @@ -0,0 +1,49 @@ +<?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="reports/report_product/viewed/" module="Magento_Reports"> + <blocks> + <actionsBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Action</class> + <locator>.page-main-actions</locator> + <strategy>css selector</strategy> + </actionsBlock> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\ProductGrid</class> + <locator>.grid</locator> + <strategy>css selector</strategy> + </gridBlock> + <filterBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Review\Products\Viewed\Filter</class> + <locator>#filter_form</locator> + <strategy>css selector</strategy> + </filterBlock> + <messagesBlock> + <class>Magento\Core\Test\Block\Messages</class> + <locator>#messages .messages</locator> + <strategy>css selector</strategy> + </messagesBlock> + </blocks> +</page> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml new file mode 100644 index 00000000000..6de291e9561 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Page/Adminhtml/ShopCartProductReport.xml @@ -0,0 +1,35 @@ +<?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="reports/report_shopcart/product" module="Magento_Reports"> + <blocks> + <gridBlock> + <class>Magento\Reports\Test\Block\Adminhtml\Shopcart\Product\Grid</class> + <locator>#gridProducts</locator> + <strategy>css selector</strategy> + </gridBlock> + </blocks> +</page> + diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.php new file mode 100644 index 00000000000..1c80e538e06 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest.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\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Reports\Test\Page\Adminhtml\CustomerAccounts; + +/** + * Test Creation for NewAccountsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Delete all existing customers + * 2. Create customer + * + * Steps: + * 1. Open Backend + * 2. Go to Reports> Customers> New + * 3. Select time range and report period + * 4. Click "Refresh button" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27742 + */ +class NewAccountsReportEntityTest extends Injectable +{ + /** + * Customer Accounts pages + * + * @var CustomerAccounts + */ + protected $customerAccounts; + + /** + * Customer index pages + * + * @var CustomerIndex + */ + protected $customerIndexPage; + + /** + * Inject pages + * + * @param CustomerIndex $customerIndexPage + * @param CustomerAccounts $customerAccounts + * @return void + */ + public function __inject(CustomerIndex $customerIndexPage, CustomerAccounts $customerAccounts) + { + $this->customerAccounts = $customerAccounts; + $this->customerIndexPage = $customerIndexPage; + } + + /** + * New Accounts Report + * + * @param CustomerInjectable $customer + * @param array $customersReport + * @return void + */ + public function test(CustomerInjectable $customer, array $customersReport) + { + // Preconditions + $this->customerIndexPage->open(); + $this->customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All'); + $customer->persist(); + + // Steps + $this->customerAccounts->open(); + $this->customerAccounts->getGridBlock()->searchAccounts($customersReport); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv new file mode 100644 index 00000000000..c8b4dda5f11 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/NewAccountsReportEntityTest/test.csv @@ -0,0 +1,5 @@ +"customer/dataSet";"total";"customersReport/report_from";"customersReport/report_to";"customersReport/report_period";"constraint" +"default";"1";"m/d/Y";"m/d/Y";"Year";"assertNewAccountsReportTotalResult" +"default";"1";"m/d/Y";"m/d/Y";"Month";"assertNewAccountsReportTotalResult" +"default";"1";"m/d/Y";"m/d/Y";"Day";"assertNewAccountsReportTotalResult" +"default";"0";"m/d/Y 12:00 a+1 day";"m/d/Y 12:00 a+1 day";"Day";"assertNewAccountsReportTotalResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.php new file mode 100644 index 00000000000..a9e5af3ed66 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity.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\Reports\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Client\Browser; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Cms\Test\Page\CmsIndex; + +/** + * Test Creation for ProductsInCartReportEntity + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create product + * + * Steps: + * 1. Login as customer in frontend + * 2. Add product to cart + * 3. Logout + * 4. Add product to cart as unregistered customer + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27952 + */ +class ProductsInCartReportEntity extends Injectable +{ + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Customer logout page + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogProductView $catalogProductView + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout, + CatalogProductView $catalogProductView + ) { + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogProductView = $catalogProductView; + } + + /** + * Create products in cart report entity + * + * @param CustomerInjectable $customer + * @param CatalogProductSimple $product + * @param string $isGuest + * @param Browser $browser + * @return void + */ + public function test( + CustomerInjectable $customer, + CatalogProductSimple $product, + $isGuest, + Browser $browser + ) { + // Preconditions + $product->persist(); + + //Steps + $this->cmsIndex->open()->getLinksBlock()->openLink("Log In"); + $this->customerAccountLogin->getLoginBlock()->login($customer); + $productUrl = $_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'; + $browser->open($productUrl); + $this->catalogProductView->getViewBlock()->addToCart($product); + if ($isGuest) { + $this->customerAccountLogout->open(); + $browser->open($productUrl); + $this->catalogProductView->getViewBlock()->addToCart($product); + } + } + + /** + * Log out after test + * + * @return void + */ + public function tearDown() + { + $this->customerAccountLogout->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv new file mode 100644 index 00000000000..d2461670586 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ProductsInCartReportEntity/test.csv @@ -0,0 +1,3 @@ +"product/dataSet";"carts";"isGuest";"constraint" +"default";"1";"0";"assertProductInCartResult" +"default";"2";"1";"assertProductInCartResult" \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php new file mode 100644 index 00000000000..68f07881e4f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Test\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Reports\Test\Page\Adminhtml\ProductReportView; + +/** + * Test Creation for ViewedProductsReportEntity + * + * Test Flow: + * Preconditions: + * 1. Create products + * 2. Open product page on frontend + * 3. Refresh statistic + * + * Steps: + * 1. Open Backend + * 2. Go to Reports> Products> Views + * 3. Select time range, report period + * 4. Click "Show report" + * 5. Perform all assertions + * + * @group Reports_(MX) + * @ZephyrId MAGETWO-27954 + */ +class ViewedProductsReportEntityTest extends Injectable +{ + /** + * Product Report View page + * + * @var ProductReportView + */ + protected $productReportView; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Browser interface + * + * @var Browser + */ + protected $browser; + + /** + * Inject pages + * + * @param ProductReportView $productReportView + * @param FixtureFactory $fixtureFactory + * @param Browser $browser + * @return void + */ + public function __inject( + ProductReportView $productReportView, + FixtureFactory $fixtureFactory, + Browser $browser + ) { + $this->productReportView = $productReportView; + $this->fixtureFactory = $fixtureFactory; + $this->browser = $browser; + } + + /** + * Viewed product report list + * + * @param string $products + * @param array $viewsReport + * @param string $total + * @return array + */ + public function test($products, array $viewsReport, $total) + { + $this->markTestIncomplete('MAGETWO-15707'); + // Preconditions + $productsList = $this->prepareProducts($products); + $this->openProducts($productsList, $total); + $this->productReportView->open(); + $this->productReportView->getMessagesBlock()->clickLinkInMessages('notice', 'here'); + + // Steps + $this->productReportView->getFilterBlock()->viewsReport($viewsReport); + $this->productReportView->getActionsBlock()->showReport(); + return ['productsList' => $productsList]; + } + + /** + * Create products + * + * @param string $productList + * @return array + */ + protected function prepareProducts($productList) + { + $productsData = explode(', ', $productList); + $products = []; + foreach ($productsData as $productConfig) { + $product = explode('::', $productConfig); + $productFixture = $this->fixtureFactory->createByCode($product[0], ['dataSet' => $product[1]]); + $productFixture->persist(); + $products[] = $productFixture; + } + return $products; + } + + /** + * Open products + * + * @param array $products + * @param string $total + * @return void + */ + protected function openProducts(array $products, $total) + { + $total = explode(', ', $total); + foreach ($products as $key => $product) { + for ($i = 0; $i < $total[$key]; $i++) { + $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv new file mode 100644 index 00000000000..430790d9c78 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest/test.csv @@ -0,0 +1,4 @@ +"description";"total";"products";"viewsReport/period_type";"viewsReport/from";"viewsReport/to";"viewsReport/show_empty_rows";"constraint" +"view products on front and verify they all reflected in Year report";"2, 1";"catalogProductSimple::default, catalogProductVirtual::default";"Year";"m/d/Y -1 year";"m/d/Y";"No";"assertProductViewsReportTotalResult" +"view products on front and verify they all reflected in Month report";"1, 1";"catalogProductDownloadable::default, catalogProductBundle::bundle_dynamic_product";"Month";"m/d/Y";"m/d/Y";"No";"assertProductViewsReportTotalResult" +"view products on front and verify they all reflected in Day report";"1, 1";"catalogProductConfigurable::default, catalogProductGrouped::default";"Day";"m/d/Y -1 day";"m/d/Y +1 day";"Yes";"assertProductViewsReportTotalResult" diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml index 738295b83c7..6fd3f3d703a 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/constraint.xml @@ -39,6 +39,9 @@ <assertProductReviewIsAvailableForProduct module="Magento_Reports"> <severeness>low</severeness> </assertProductReviewIsAvailableForProduct> + <assertNewAccountsReportTotalResult module="Magento_Reports"> + <severeness>low</severeness> + </assertNewAccountsReportTotalResult> <assertProductReviewsQtyByCustomer module="Magento_Reports"> <severeness>low</severeness> </assertProductReviewsQtyByCustomer> @@ -48,4 +51,10 @@ <assertProductReportByCustomerNotInGrid module="Magento_Reports"> <severeness>low</severeness> </assertProductReportByCustomerNotInGrid> + <assertProductViewsReportTotalResult module="Magento_Reports"> + <severeness>low</severeness> + </assertProductViewsReportTotalResult> + <assertProductInCartResult module="Magento_Reports"> + <severeness>low</severeness> + </assertProductInCartResult> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml index 106bba5c02c..f486dc56450 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/etc/page.xml @@ -39,9 +39,24 @@ <area>adminhtml</area> <class>Magento\Reports\Test\Page\Adminhtml\ProductReportReview</class> </productReportReview> + <customerAccounts> + <mca>reports/report_customer/accounts/index</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\CustomerAccounts</class> + </customerAccounts> <customerReportReview> <mca>reports/report_review/customer</mca> <area>adminhtml</area> <class>Magento\Reports\Test\Page\Adminhtml\CustomerReportReview</class> </customerReportReview> + <productReportView> + <mca>reports/report_product/viewed/</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\ProductReportView</class> + </productReportView> + <shopCartProductReport> + <mca>reports/report_shopcart/product</mca> + <area>adminhtml</area> + <class>Magento\Reports\Test\Page\Adminhtml\ShopCartProductReport</class> + </shopCartProductReport> </page> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php new file mode 100644 index 00000000000..ce2372c7c61 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.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\Review\Test\Block\Adminhtml\Customer\Edit\Tab; + +use Magento\Review\Test\Block\Adminhtml\ReviewsTab; + +/** + * Class Reviews + * Reviews tab on customer edit page + */ +class Reviews extends ReviewsTab +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml new file mode 100644 index 00000000000..23020202fb8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.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) + */ +--> +<tabs> + <product_reviews> + <class>\Magento\Review\Test\Block\Adminhtml\Customer\Edit\Tab\Reviews</class> + <selector>#customer_info_tabs_reviews</selector> + <strategy>css selector</strategy> + </product_reviews> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php index f295e2c0c8b..4b2965cfdd6 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Grid.php @@ -24,7 +24,6 @@ namespace Magento\Review\Test\Block\Adminhtml; -use Mtf\Client\Element; use Magento\Backend\Test\Block\Widget\Grid as GridAbstract; /** @@ -46,7 +45,7 @@ class Grid extends GridAbstract 'selector' => 'input[name="title"]', ], 'status' => [ - 'selector' => '.grid select[name="status"]', + 'selector' => '#reviwGrid_filter_status', 'input' => 'select', ], 'nickname' => [ diff --git a/app/code/Magento/Webapi/DeserializationException.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php similarity index 81% rename from app/code/Magento/Webapi/DeserializationException.php rename to dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php index f9e4db42d4b..037dff88e52 100644 --- a/app/code/Magento/Webapi/DeserializationException.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php @@ -22,12 +22,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Webapi; +namespace Magento\Review\Test\Block\Adminhtml\Product\Edit\Tab; + +use Magento\Review\Test\Block\Adminhtml\ReviewsTab; /** - * Exception to be thrown when there is an issue with deserialization of web API request. + * Class Reviews + * Reviews tab on product edit page */ -class DeserializationException extends \Magento\Framework\Exception\LocalizedException +class Reviews extends ReviewsTab { - + // } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml new file mode 100644 index 00000000000..c9866c8ffdb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.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) + */ +--> +<tabs> + <product_reviews> + <class>\Magento\Review\Test\Block\Adminhtml\Product\Edit\Tab\Reviews</class> + <selector>#product_info_tabs_product-reviews</selector> + <strategy>css selector</strategy> + </product_reviews> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php new file mode 100644 index 00000000000..f81428b1c5b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.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\Review\Test\Block\Adminhtml; + +use Magento\Backend\Test\Block\Widget\Tab; + +/** + * Class Reviews + * Reviews tab on backend + */ +class ReviewsTab extends Tab +{ + /** + * Product reviews block selector + * + * @var string + */ + protected $reviews = '#Product_Reviews'; + + /** + * Returns product reviews grid + * + * @return \Magento\Review\Test\Block\Adminhtml\Grid + */ + public function getReviewsGrid() + { + return $this->blockFactory->create( + 'Magento\Review\Test\Block\Adminhtml\Grid', + ['element' => $this->_rootElement->find($this->reviews)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php index eaacf1b4c1f..5d21b495e74 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingInProductPage.php @@ -48,20 +48,19 @@ class AssertProductRatingInProductPage extends AbstractConstraint * Assert that product rating is displayed on product review(frontend) * * @param CatalogProductView $catalogProductView - * @param CatalogProductSimple $product * @param Browser $browser + * @param CatalogProductSimple $product * @param ReviewInjectable|null $review [optional] * @param Rating|null $productRating [optional] * @return void */ public function processAssert( CatalogProductView $catalogProductView, - CatalogProductSimple $product, Browser $browser, + CatalogProductSimple $product, ReviewInjectable $review = null, Rating $productRating = null ) { - $product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $reviewSummaryBlock = $catalogProductView->getReviewSummary(); if ($reviewSummaryBlock->isVisible()) { diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php index 95bdafbd232..c43da69ab5d 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductRatingNotInProductPage.php @@ -27,7 +27,6 @@ namespace Magento\Review\Test\Constraint; use Mtf\Client\Browser; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Catalog\Test\Fixture\CatalogProductSimple; -use Magento\Review\Test\Fixture\ReviewInjectable; use Magento\Review\Test\Fixture\Rating; use Mtf\Constraint\AbstractConstraint; @@ -50,17 +49,14 @@ class AssertProductRatingNotInProductPage extends AbstractConstraint * @param CatalogProductSimple $product * @param Rating $productRating * @param Browser $browser - * @param ReviewInjectable $review * @return void */ public function processAssert( CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, - Browser $browser, - ReviewInjectable $review = null + Browser $browser ) { - $product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getReviewSummary()->getAddReviewLink()->click(); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php index ec615729f01..14f2a1ebdc8 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGrid.php @@ -63,21 +63,18 @@ class AssertProductReviewInGrid extends AbstractConstraint * Assert that review is displayed in grid * * @param ReviewIndex $reviewIndex - * @param ReviewInjectable $review + * @param ReviewInjectable $review , + * @param FixtureInterface $product * @param string $gridStatus - * @param ReviewInjectable $reviewInitial * @return void */ public function processAssert( ReviewIndex $reviewIndex, ReviewInjectable $review, - $gridStatus = '', - ReviewInjectable $reviewInitial = null + FixtureInterface $product, + $gridStatus = '' ) { - $product = $reviewInitial === null - ? $review->getDataFieldConfig('entity_id')['source']->getEntity() - : $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); - $filter = $this->prepareFilter($product, $review, $gridStatus); + $filter = $this->prepareFilter($product, $review->getData(), $gridStatus); $reviewIndex->open(); $reviewIndex->getReviewGrid()->search($filter); @@ -92,11 +89,13 @@ class AssertProductReviewInGrid extends AbstractConstraint * Prepare filter for assert * * @param FixtureInterface $product - * @param ReviewInjectable $review - * @param string $gridStatus + * @param array $review + * @param string $gridStatus [optional] * @return array + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function prepareFilter(FixtureInterface $product, ReviewInjectable $review, $gridStatus) + public function prepareFilter(FixtureInterface $product, array $review, $gridStatus = '') { $filter = []; foreach ($this->filter as $key => $item) { @@ -110,13 +109,13 @@ class AssertProductReviewInGrid extends AbstractConstraint $value = $product->getData($param); break; case 'select_stores': - $value = $review->getData($param)[0]; + $value = isset($review[$param]) ? $review[$param][0] : null; break; case 'status_id': - $value = $gridStatus != '' ? $gridStatus : $review->getData($param); + $value = $gridStatus != '' ? $gridStatus : (isset($review[$param]) ? $review[$param] : null); break; default: - $value = $review->getData($param); + $value = isset($review[$param]) ? $review[$param] : null; break; } if ($value !== null) { diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.php new file mode 100644 index 00000000000..13af1eae396 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewInGridOnCustomerPage.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\Review\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Review\Test\Block\Adminhtml\Product\Grid as ReviewsGrid; + +/** + * Class AssertProductReviewInGridOnCustomerPage + * Asserts all Product Review variables in the reviews grid on customer page + */ +class AssertProductReviewInGridOnCustomerPage extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Asserts all Product Review variables in the reviews grid on customer page + * + * @param CustomerInjectable $customer + * @param ReviewInjectable $reviewInitial + * @param ReviewInjectable $review + * @param CustomerIndexEdit $customerIndexEdit + * @param CustomerIndex $customerIndex + * @param AssertProductReviewInGrid $assertProductReviewInGrid + * @return void + */ + public function processAssert( + CustomerInjectable $customer, + ReviewInjectable $reviewInitial, + ReviewInjectable $review, + CustomerIndexEdit $customerIndexEdit, + CustomerIndex $customerIndex, + AssertProductReviewInGrid $assertProductReviewInGrid + ) { + /** var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $customerIndex->open(); + $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $customerIndexEdit->getCustomerForm()->openTab('product_reviews'); + $filter = $assertProductReviewInGrid->prepareFilter($product, $this->prepareData($review, $reviewInitial)); + /** @var ReviewsGrid $reviewsGrid */ + $reviewsGrid = $customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid(); + $reviewsGrid->search($filter); + unset($filter['visible_in']); + \PHPUnit_Framework_Assert::assertTrue( + $reviewsGrid->isRowVisible($filter, false), + 'Review is absent in Review grid on customer page.' + ); + } + + /** + * Prepare Review data + * + * @param ReviewInjectable $review + * @param ReviewInjectable $reviewInitial + * @return array + */ + protected function prepareData(ReviewInjectable $review, ReviewInjectable $reviewInitial) + { + $dataReviewInitial = $reviewInitial->getData(); + $data = $review->getData(); + foreach ($dataReviewInitial as $key => $value) { + if (!isset($data[$key])) { + $data[$key] = $value; + } + } + $data['type'] = 'Customer'; + return $data; + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Review is present in grid on customer 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 index 61910be58d6..5a8ffcaedee 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertProductReviewOnProductPage.php @@ -25,8 +25,10 @@ namespace Magento\Review\Test\Constraint; use Mtf\Client\Browser; +use Mtf\Fixture\FixtureInterface; use Mtf\Constraint\AbstractConstraint; use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Backend\Test\Page\Adminhtml\AdminCache; use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Page\Product\CatalogProductView; @@ -48,19 +50,20 @@ class AssertProductReviewOnProductPage extends AbstractConstraint * * @param CatalogProductView $catalogProductView * @param ReviewInjectable $review - * @param ReviewInjectable $reviewInitial + * @param FixtureInterface $product * @param Browser $browser + * @param AdminCache $cachePage * @return void */ public function processAssert( CatalogProductView $catalogProductView, ReviewInjectable $review, - ReviewInjectable $reviewInitial, - Browser $browser + FixtureInterface $product, + Browser $browser, + AdminCache $cachePage ) { $errors = []; - /** @var CatalogProductSimple $product */ - $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $cachePage->open()->getActionsBlock()->flushMagentoCache(); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $reviewBlock = $catalogProductView->getCustomerReviewBlock(); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php b/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php index cfd0a5f385a..f1b7bd57076 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Fixture/ReviewInjectable/Ratings.php @@ -64,16 +64,21 @@ class Ratings implements FixtureInterface public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; + /** @var Rating $fixtureRating */ + $fixtureRating = null; foreach ($data as $rating) { if (isset($rating['dataSet'])) { - /** @var Rating $fixtureRating */ $fixtureRating = $fixtureFactory->createByCode('rating', ['dataSet' => $rating['dataSet']]); - if (!$fixtureRating->hasData('id')) { + if (!$fixtureRating->hasData('rating_id')) { $fixtureRating->persist(); } - $this->ratings[] = $fixtureRating; + } elseif (isset($rating['fixtureRating'])) { + $fixtureRating = $rating['fixtureRating']; + } + if ($fixtureRating !== null) { + $this->ratings[] = $fixtureRating; $this->data[] = [ 'title' => $fixtureRating->getRatingCode(), 'rating' => $rating['rating'] diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php index 413bf728aba..d34bc2ae604 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php @@ -129,6 +129,9 @@ class CreateProductRatingEntityTest extends Injectable */ public function tearDown() { + if (!($this->productRating instanceof Rating)) { + return; + } $filter = ['rating_code' => $this->productRating->getRatingCode()]; $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php index faa53940c74..18cd55a0a6d 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php @@ -119,12 +119,13 @@ class CreateProductReviewBackendEntityTest extends Injectable * Run Create Product Review Entity Backend Test * * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $review) { // Precondition: - $filter = ['id' => $review->getDataFieldConfig('entity_id')['source']->getEntity()->getId()]; + $product = $review->getDataFieldConfig('entity_id')['source']->getEntity(); + $filter = ['id' => $product->getId()]; $this->review = $review; // Steps: @@ -133,6 +134,8 @@ class CreateProductReviewBackendEntityTest extends Injectable $this->reviewEdit->getProductGrid()->searchAndOpen($filter); $this->reviewEdit->getReviewForm()->fill($this->review); $this->reviewEdit->getPageActions()->save(); + + return ['product' => $product]; } /** @@ -143,12 +146,11 @@ class CreateProductReviewBackendEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $filter = ['rating_code' => $rating['title']]; - $ratingGrid->searchAndOpen($filter); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php index 96fbb068a92..2f214ff54d8 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php @@ -104,7 +104,7 @@ class CreateProductReviewFrontendEntityTest extends Injectable * * @param ReviewInjectable $review * @param Browser $browser - * @return void + * @return array */ public function test(ReviewInjectable $review, Browser $browser) { @@ -121,6 +121,8 @@ class CreateProductReviewFrontendEntityTest extends Injectable $reviewForm = $this->catalogProductView->getReviewFormBlock(); $reviewForm->fill($review); $reviewForm->submit(); + + return ['product' => $product]; } /** @@ -131,12 +133,11 @@ class CreateProductReviewFrontendEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $filter = ['rating_code' => $rating['title']]; - $ratingGrid->searchAndOpen($filter); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php new file mode 100644 index 00000000000..9c72dad9e7e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.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\Review\Test\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Review\Test\Page\Adminhtml\ReviewEdit; +use Magento\Review\Test\Page\Adminhtml\RatingEdit; +use Magento\Review\Test\Page\Adminhtml\RatingIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; + +/** + * Test Creation for ManageProductReviewFromCustomerPage + * + * Test Flow: + * + * Preconditions: + * 1. Create Customer + * 2. Create simple product + * 3. Create Product review on the front + * + * Steps: + * 1. Open backend + * 2. Go to Customers->All Customers + * 3. Open customer from preconditions + * 4. Open Product Review tab + * 5. Open Review created in preconditions + * 6. Fill data according to dataset + * 7. Click "Submit review" + * 8. Perform all assertions + * + * @group Reviews_and_Ratings_(MX) + * @ZephyrId MAGETWO-27625 + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ManageProductReviewFromCustomerPageTest extends Injectable +{ + /** + * Customer index page + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Catalog product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Browser + * + * @var Browser + */ + protected $browser; + + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Backend rating grid page + * + * @var RatingIndex + */ + protected $ratingIndex; + + /** + * Backend rating edit page + * + * @var RatingEdit + */ + protected $ratingEdit; + + /** + * Review fixture + * + * @var ReviewInjectable + */ + protected $reviewInitial; + + /** + * Review edit page + * + * @var ReviewEdit + */ + protected $reviewEdit; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CustomerIndexEdit $customerIndexEdit + * @param CustomerIndex $customerIndex + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CatalogProductView $catalogProductView + * @param Browser $browser + * @param RatingIndex $ratingIndex + * @param RatingEdit $ratingEdit + * @param ReviewEdit $reviewEdit + * @return void + */ + public function __inject( + CustomerIndexEdit $customerIndexEdit, + CustomerIndex $customerIndex, + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CatalogProductView $catalogProductView, + Browser $browser, + RatingIndex $ratingIndex, + RatingEdit $ratingEdit, + ReviewEdit $reviewEdit + ) { + $this->customerIndexEdit = $customerIndexEdit; + $this->customerIndex = $customerIndex; + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->catalogProductView = $catalogProductView; + $this->browser = $browser; + $this->ratingIndex = $ratingIndex; + $this->ratingEdit = $ratingEdit; + $this->reviewEdit = $reviewEdit; + } + + /** + * Run manage product review test + * + * @param ReviewInjectable $reviewInitial + * @param ReviewInjectable $review + * @param CustomerInjectable $customer + * @return array + */ + public function test( + ReviewInjectable $reviewInitial, + ReviewInjectable $review, + CustomerInjectable $customer + ) { + // Preconditions + $this->login($customer); + /** @var CatalogProductSimple $product */ + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getReviewSummary()->getAddReviewLink()->click(); + $this->catalogProductView->getReviewFormBlock()->fill($reviewInitial); + $this->catalogProductView->getReviewFormBlock()->submit(); + $this->reviewInitial = $reviewInitial; + // Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getCustomerForm()->openTab('product_reviews'); + $filter = [ + 'title' => $reviewInitial->getTitle(), + 'sku' => $product->getSku() + ]; + $this->customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid() + ->searchAndOpen($filter); + $this->reviewEdit->getReviewForm()->fill($review); + $this->reviewEdit->getPageActions()->save(); + + return ['reviewInitial' => $reviewInitial, 'product' => $product]; + } + + /** + * Login customer on frontend + * + * @param CustomerInjectable $customer + * @return void + */ + protected function login(CustomerInjectable $customer) + { + $this->cmsIndex->open(); + if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { + $this->cmsIndex->getLinksBlock()->openLink("Log In"); + $this->customerAccountLogin->getLoginBlock()->login($customer); + } + } + + /** + * Clear data after test + * + * @return void + */ + public function tearDown() + { + $this->ratingIndex->open(); + if ($this->reviewInitial instanceof ReviewInjectable) { + foreach ($this->reviewInitial->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv new file mode 100644 index 00000000000..ef0f249f45b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest/test.csv @@ -0,0 +1,3 @@ +"review/data/status_id";"review/data/nickname";"review/data/title";"review/data/detail";"constraint" +"Approved";"name_upd_%isolation%";"title_upd_%isolation%";"review_upd_%isolation%";"assertReviewSuccessSaveMessage, assertProductReviewInGridOnCustomerPage, assertProductReviewOnProductPage" +"Not Approved";"name_upd_%isolation%";"title_upd_%isolation%";"review_upd_%isolation%";"assertReviewSuccessSaveMessage, assertProductReviewInGridOnCustomerPage, assertProductRatingNotInProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php index 385c9e70b9a..3629490c1e5 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php @@ -102,8 +102,9 @@ class MassActionsProductReviewEntityTest extends Injectable $this->ratingEdit = $ratingEdit; $this->review = $review; $this->review->persist(); + $product = $review->getDataFieldConfig('entity_id')['source']->getEntity(); - return ['review' => $this->review]; + return ['review' => $this->review, 'product' => $product]; } /** @@ -132,11 +133,11 @@ class MassActionsProductReviewEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $ratingGrid->searchAndOpen(['rating_code' => $rating['title']]); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } 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 index 59a11b666bf..5eeebb4c41b 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ModerateProductReviewEntityTest.php @@ -83,7 +83,7 @@ class ModerateProductReviewEntityTest extends Injectable * * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review) { @@ -95,5 +95,10 @@ class ModerateProductReviewEntityTest extends Injectable $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); + + // Prepare data for asserts + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + + return ['product' => $product]; } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php new file mode 100644 index 00000000000..8306fbd1a5b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -0,0 +1,211 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Review\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Review\Test\Fixture\ReviewInjectable; +use Magento\Review\Test\Page\Adminhtml\ReviewEdit; +use Magento\Review\Test\Page\Adminhtml\RatingEdit; +use Magento\Review\Test\Page\Adminhtml\RatingIndex; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; + +/** + * Test Creation for UpdateProductReviewEntity on product page + * + * Test Flow: + * + * Preconditions: + * 1. Create Product + * 2. Create review with rating for this product + * + * Steps: + * 1. Open Products -> Catalog + * 2. Search and open product from preconditions + * 3. Open Review tab + * 4. Search and open review created in preconditions + * 5. Fill data according to dataSet + * 6. Save changes + * 7. Perform all assertions + * + * @group Reviews_and_Ratings_(MX) + * @ZephyrId MAGETWO-27743 + */ +class UpdateProductReviewEntityOnProductPageTest extends Injectable +{ + /** + * Catalog product index page + * + * @var CatalogProductIndex + */ + protected $catalogProductIndex; + + /** + * Catalog product edit page + * + * @var CatalogProductEdit + */ + protected $catalogProductEdit; + + /** + * Backend rating grid page + * + * @var RatingIndex + */ + protected $ratingIndex; + + /** + * Backend rating edit page + * + * @var RatingEdit + */ + protected $ratingEdit; + + /** + * Review fixture + * + * @var ReviewInjectable + */ + protected $reviewInitial; + + /** + * Review edit page + * + * @var ReviewEdit + */ + protected $reviewEdit; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Prepare data + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->reviewInitial = $fixtureFactory->createByCode( + 'reviewInjectable', + ['dataSet' => 'review_for_simple_product_with_rating'] + ); + $this->reviewInitial->persist(); + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Injection data + * + * @param RatingIndex $ratingIndex + * @param RatingEdit $ratingEdit + * @param CatalogProductIndex $catalogProductIndex + * @param CatalogProductEdit $catalogProductEdit + * @param ReviewEdit $reviewEdit + * @return void + */ + public function __inject( + RatingIndex $ratingIndex, + RatingEdit $ratingEdit, + CatalogProductIndex $catalogProductIndex, + CatalogProductEdit $catalogProductEdit, + ReviewEdit $reviewEdit + ) { + $this->ratingIndex = $ratingIndex; + $this->ratingEdit = $ratingEdit; + $this->catalogProductIndex = $catalogProductIndex; + $this->catalogProductEdit = $catalogProductEdit; + $this->reviewEdit = $reviewEdit; + } + + /** + * Update product review on product page + * + * @param ReviewInjectable $review + * @param int $rating + * @return array + */ + public function test(ReviewInjectable $review, $rating) + { + // Steps + $review = $this->createReview($review, $rating); + $this->catalogProductIndex->open(); + /** @var CatalogProductSimple $product */ + $product = $this->reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); + $this->catalogProductEdit->getForm()->openTab('product_reviews'); + $filter = [ + 'title' => $this->reviewInitial->getTitle(), + 'sku' => $product->getSku() + ]; + $this->catalogProductEdit->getForm()->getTabElement('product_reviews')->getReviewsGrid() + ->searchAndOpen($filter); + $this->reviewEdit->getReviewForm()->fill($review); + $this->reviewEdit->getPageActions()->save(); + $productRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0]; + + return ['product' => $product, 'productRating' => $productRating]; + } + + /** + * Create review + * + * @param ReviewInjectable $review + * @param int $rating + * @return ReviewInjectable + */ + protected function createReview($review, $rating) + { + $reviewData = $review->getData(); + $fixtureRating = $this->reviewInitial->getDataFieldConfig('ratings')['source']->getRatings()[0]; + $reviewData['ratings'][0] = ['fixtureRating' => $fixtureRating, 'rating' => $rating]; + + return $this->fixtureFactory->createByCode('reviewInjectable', ['data' => $reviewData]); + } + + /** + * Clear data after test + * + * @return void + */ + public function tearDown() + { + if (!$this->reviewInitial instanceof ReviewInjectable) { + return; + } + $this->ratingIndex->open(); + foreach ($this->reviewInitial->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv new file mode 100644 index 00000000000..9d4bcc35b2b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest/test.csv @@ -0,0 +1,2 @@ +"rating";"review/data/status_id";"productRating/data/select_stores";"review/data/nickname";"review/data/title";"review/data/detail";"constraint" +"3";"Approved";"Main Website/Main Website Store/Default Store View";"name%isolation%";"title%isolation%";"details%isolation%";"assertProductReviewBackendSuccessSaveMessage, assertProductReviewInGrid, assertProductReviewOnProductPage, assertProductRatingInProductPage" diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php index 5be0f612f0c..6b2c90d28ea 100755 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php @@ -115,7 +115,7 @@ class UpdateProductReviewEntityTest extends Injectable * * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review - * @return void + * @return array */ public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review) { @@ -130,6 +130,11 @@ class UpdateProductReviewEntityTest extends Injectable $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); + + // Prepare data for asserts + $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); + + return ['product' => $product]; } /** @@ -140,11 +145,11 @@ class UpdateProductReviewEntityTest extends Injectable public function tearDown() { $this->ratingIndex->open(); - $ratingGrid = $this->ratingIndex->getRatingGrid(); - $pageActions = $this->ratingEdit->getPageActions(); - foreach ($this->review->getRatings() as $rating) { - $ratingGrid->searchAndOpen(['rating_code' => $rating['title']]); - $pageActions->delete(); + if ($this->review instanceof ReviewInjectable) { + foreach ($this->review->getRatings() as $rating) { + $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); + $this->ratingEdit->getPageActions()->delete(); + } } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml index 793cb704f30..113b6538e8b 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/etc/constraint.xml @@ -81,4 +81,7 @@ <assertProductReviewNotInGrid module="Magento_Review"> <severeness>low</severeness> </assertProductReviewNotInGrid> + <assertProductReviewInGridOnCustomerPage module="Magento_Review"> + <severeness>low</severeness> + </assertProductReviewInGridOnCustomerPage> </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 ac873714ba6..592979ef677 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 @@ -27,6 +27,7 @@ namespace Magento\Store\Test\Block; use Mtf\Block\Block; use Mtf\Client\Element\Locator; +use Magento\Store\Test\Fixture\Store; class Switcher extends Block { @@ -37,6 +38,13 @@ class Switcher extends Block */ protected $dropDownButton = '#switcher-language-trigger'; + /** + * StoreView selector + * + * @var string + */ + protected $storeViewSelector = 'li.view-%s'; + /** * Select store * @@ -59,4 +67,31 @@ class Switcher extends Block { return $this->_rootElement->find($this->dropDownButton)->getText(); } + + /** + * Check is Store View Visible + * + * @param Store $store + * @return bool + */ + public function isStoreViewVisible($store) + { + $storeViewDropdown = $this->_rootElement->find($this->dropDownButton); + + $storeViewDropdown->click(); + $isStoreViewVisible = $this->_rootElement->find(sprintf($this->storeViewSelector, $store->getCode())) + ->isVisible(); + $storeViewDropdown->click(); + return $isStoreViewVisible; + } + + /** + * Check if StoreView dropdown is visible + * + * @return bool + */ + public function isStoreViewDropdownVisible() + { + return $this->_rootElement->find($this->dropDownButton)->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php new file mode 100644 index 00000000000..1df338ce297 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreBackend.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Store\Test\Constraint; + +use Magento\Backend\Test\Page\Adminhtml\SystemConfig; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreBackend + * Assert that created store view displays in backend configuration (Stores > Configuration > "Scope" dropdown) + */ +class AssertStoreBackend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view displays in backend configuration (Stores > Configuration > "Scope" dropdown) + * + * @param Store $store + * @param SystemConfig $systemConfig + * @return void + */ + public function processAssert(Store $store, SystemConfig $systemConfig) + { + $systemConfig->open(); + $isStoreVisible = $systemConfig->getPageActions()->isStoreVisible($store); + \PHPUnit_Framework_Assert::assertTrue($isStoreVisible, "Store view is not visible in dropdown on config page"); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View is available in backend configuration (Stores > Configuration > "Scope" dropdown)'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.php new file mode 100644 index 00000000000..5fc67645681 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreForm.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractAssertForm; +use Magento\Store\Test\Fixture\Store; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreNew; + +/** + * Class AssertStoreForm + * Assert that displayed Store View data on edit page equals passed from fixture + */ +class AssertStoreForm extends AbstractAssertForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that displayed Store View data on edit page equals passed from fixture + * + * @param StoreIndex $storeIndex + * @param StoreNew $storeNew + * @param Store $store + * @return void + */ + public function processAssert( + StoreIndex $storeIndex, + StoreNew $storeNew, + Store $store + ) { + $storeIndex->open()->getStoreGrid()->searchAndOpenStore($store); + $formData = $storeNew->getStoreForm()->getData(); + $fixtureData = $store->getData(); + $errors = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store View data on edit page equals data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.php new file mode 100644 index 00000000000..7665c01494b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreFrontend.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\Store\Test\Constraint; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreFrontend + * Assert that created store view available on frontend (store view selector on page top) + */ +class AssertStoreFrontend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view available on frontend (store view selector on page top) + * + * @param Store $store + * @param CmsIndex $cmsIndex + * @return void + */ + public function processAssert(Store $store, CmsIndex $cmsIndex) + { + $cmsIndex->open(); + if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() + && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store) + ) { + $cmsIndex->getFooterBlock()->selectStoreGroup($store); + } + + $isStoreViewVisible = !$cmsIndex->getStoreSwitcherBlock()->isStoreViewDropdownVisible() + ? true // if only one store view is assigned to store group + : $cmsIndex->getStoreSwitcherBlock()->isStoreViewVisible($store); + + \PHPUnit_Framework_Assert::assertTrue( + $isStoreViewVisible, + "Store view is not visible in dropdown on CmsIndex page" + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store view is visible in dropdown on CmsIndex page'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php index f3921c91553..a2475dd2eff 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupForm.php @@ -67,7 +67,7 @@ class AssertStoreGroupForm extends AbstractAssertForm $fixtureData = $storeGroupOrigin != null ? array_merge($storeGroupOrigin->getData(), $storeGroup->getData()) : $storeGroup->getData(); - $storeIndex->open()->getStoreGrid()->searchAndOpenStore($storeGroup); + $storeIndex->open()->getStoreGrid()->searchAndOpenStoreGroup($storeGroup); $formData = $editGroup->getEditFormGroup()->getData(); $errors = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php index 151a7b83717..829d8587a61 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreGroupSuccessDeleteAndBackupMessages.php @@ -62,7 +62,7 @@ class AssertStoreGroupSuccessDeleteAndBackupMessages extends AbstractConstraint \PHPUnit_Framework_Assert::assertTrue( in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), - 'Wrong success messages is displayed.' + 'Wrong success messages are displayed.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.php new file mode 100644 index 00000000000..f97e9ad95ff --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreInGrid.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\Store\Test\Constraint; + +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreInGrid + * Assert that created Store View can be found in Stores grid + */ +class AssertStoreInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Store View can be found in Stores grid by name + * + * @param StoreIndex $storeIndex + * @param Store $store + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Store $store) + { + $storeName = $store->getName(); + $storeIndex->open()->getStoreGrid()->search(['store_title' => $storeName]); + \PHPUnit_Framework_Assert::assertTrue( + $storeIndex->getStoreGrid()->isStoreExists($storeName), + 'Store \'' . $storeName . '\' is not present in grid.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View is present in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.php new file mode 100644 index 00000000000..20ff2a2e0aa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotInGrid.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Store; + +/** + * Class AssertStoreNotInGrid + * Assert that store is absent in grid + */ +class AssertStoreNotInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Store can not be found in Stores grid by name + * + * @param StoreIndex $storeIndex + * @param Store $store + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Store $store) + { + $storeName = $store->getName(); + $storeIndex->open()->getStoreGrid()->search(['store_title' => $storeName]); + \PHPUnit_Framework_Assert::assertFalse( + $storeIndex->getStoreGrid()->isStoreExists($storeName), + 'Store \'' . $storeName . '\' is present in grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store is absent in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.php new file mode 100644 index 00000000000..eaa81fd9864 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreNotOnFrontend.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\Store\Test\Constraint; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Store\Test\Fixture\Store; +use Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertStoreNotOnFrontend + * Assert that created store view is not available on frontend (store view selector on page top) + */ +class AssertStoreNotOnFrontend extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created store view is not available on frontend (store view selector on page top) + * + * @param Store $store + * @param CmsIndex $cmsIndex + * @return void + */ + public function processAssert(Store $store, CmsIndex $cmsIndex) + { + $cmsIndex->open(); + if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() + && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store) + ) { + $cmsIndex->getFooterBlock()->selectStoreGroup($store); + } + + $isStoreViewVisible = !$cmsIndex->getStoreSwitcherBlock()->isStoreViewDropdownVisible() + ? false // if only one store view is assigned to store group + : $cmsIndex->getStoreSwitcherBlock()->isStoreViewVisible($store); + + \PHPUnit_Framework_Assert::assertFalse( + $isStoreViewVisible, + "Store view is visible in dropdown on CmsIndex page" + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store view is not visible in dropdown on CmsIndex page'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.php new file mode 100644 index 00000000000..b70be010e34 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteAndBackupMessages.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessDeleteAndBackupMessages + * Assert that store success delete and backup messages are present + */ +class AssertStoreSuccessDeleteAndBackupMessages extends AbstractConstraint +{ + /** + * Success backup message + */ + const SUCCESS_BACKUP_MESSAGE = 'The database was backed up.'; + + /** + * Success store delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The store view has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that store success delete and backup messages are present + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + $actualMessages = $storeIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertTrue( + in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && + in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), + 'Wrong success messages are displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Store view success delete and backup messages are present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.php new file mode 100644 index 00000000000..ebb965440ff --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessDeleteMessage.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessDeleteMessage + * Assert that after store delete successful message appears + */ +class AssertStoreSuccessDeleteMessage extends AbstractConstraint +{ + /** + * Success store delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The store view has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that after store delete successful message appears + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_DELETE_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success delete message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.php new file mode 100644 index 00000000000..b488a730f7c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertStoreSuccessSaveMessage.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertStoreSuccessSaveMessage + * Assert that after Store View save successful message appears + */ +class AssertStoreSuccessSaveMessage extends AbstractConstraint +{ + /** + * Success store view create message + */ + const SUCCESS_MESSAGE = 'The store view has been saved'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after Store View has been created + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Store View success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.php new file mode 100644 index 00000000000..7949cd24020 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteForm.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractAssertForm; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; + +/** + * Class AssertWebsiteForm + * Assert that displayed Website data on edit page equals passed from fixture + */ +class AssertWebsiteForm extends AbstractAssertForm +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Skipped fields for verify data + * + * @var array + */ + protected $skippedFields = ['website_id']; + + /** + * Assert that displayed Website data on edit page equals passed from fixture + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param Website $website + * @return void + */ + public function processAssert( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + Website $website + ) { + $fixtureData = $website->getData(); + $storeIndex->open()->getStoreGrid()->searchAndOpenWebsite($website); + $formData = $editWebsite->getEditFormWebsite()->getData(); + $errors = $this->verifyData($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website data on edit page equals data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php similarity index 59% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php rename to dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php index 0bd4f7ffd02..4d170d9c942 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteInGrid.php @@ -22,38 +22,39 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Constraint; +namespace Magento\Store\Test\Constraint; use Mtf\Constraint\AbstractConstraint; -use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; -use Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Website; /** - * Class AssertConfigurableInGrid + * Class AssertWebsiteInGrid + * Assert that created Website can be found in Stores grid */ -class AssertConfigurableInGrid extends AbstractConstraint +class AssertWebsiteInGrid extends AbstractConstraint { /** * Constraint severeness * * @var string */ - protected $severeness = 'high'; + protected $severeness = 'low'; /** - * Assert product availability in products grid + * Assert that created Website can be found in Stores grid by name * - * @param CatalogProductConfigurable $configurable - * @param CatalogProductIndex $productPageGrid + * @param StoreIndex $storeIndex + * @param Website $website * @return void */ - public function processAssert(CatalogProductConfigurable $configurable, CatalogProductIndex $productPageGrid) + public function processAssert(StoreIndex $storeIndex, Website $website) { - $filter = ['sku' => $configurable->getSku()]; - $productPageGrid->open(); + $websiteName = $website->getName(); + $storeIndex->open()->getStoreGrid()->search(['website_title' => $websiteName]); \PHPUnit_Framework_Assert::assertTrue( - $productPageGrid->getProductGrid()->isRowVisible($filter), - 'Product with sku \'' . $configurable->getSku() . '\' is absent in Products grid.' + $storeIndex->getStoreGrid()->isWebsiteExists($website), + 'Website \'' . $websiteName . '\' is not present in grid.' ); } @@ -64,6 +65,6 @@ class AssertConfigurableInGrid extends AbstractConstraint */ public function toString() { - return 'Product is present in Products grid.'; + return 'Website is present in grid.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.php new file mode 100644 index 00000000000..f2810e0aa4a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteNotInGrid.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Website; + +/** + * Class AssertWebsiteNotInGrid + * Assert that deleted website is absent in grid + */ +class AssertWebsiteNotInGrid extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that created Website can't be found in grid by name + * + * @param StoreIndex $storeIndex + * @param Website $website + * @return void + */ + public function processAssert(StoreIndex $storeIndex, Website $website) + { + $websiteName = $website->getName(); + $storeIndex->open()->getStoreGrid()->search(['website_title' => $websiteName]); + \PHPUnit_Framework_Assert::assertFalse( + $storeIndex->getStoreGrid()->isWebsiteExists($website), + 'Website \'' . $websiteName . '\' is present in grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website is absent in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.php new file mode 100644 index 00000000000..c1f74ded798 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteOnStoreForm.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\NewGroupIndex; +use Magento\Store\Test\Fixture\Website; + +/** + * Class AssertWebsiteOnStoreForm + * Assert that Website visible on Store Group Form in Website dropdown + */ +class AssertWebsiteOnStoreForm extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that Website visible on Store Group Form in Website dropdown + * + * @param StoreIndex $storeIndex + * @param NewGroupIndex $newGroupIndex + * @param Website $website + * @return void + */ + public function processAssert(StoreIndex $storeIndex, NewGroupIndex $newGroupIndex, Website $website) + { + $websiteName = $website->getName(); + $storeIndex->open()->getGridPageActions()->createStoreGroup(); + \PHPUnit_Framework_Assert::assertTrue( + $newGroupIndex->getEditFormGroup()->isWebsiteVisible($websiteName), + 'Website \'' . $websiteName . '\' is not present on Store Group Form in Website dropdown.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website is visible on Store Group Form in Website dropdown.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.php new file mode 100644 index 00000000000..a53faf5be80 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteAndBackupMessages.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessDeleteAndBackupMessages + * Assert that after website delete successful messages appears + */ +class AssertWebsiteSuccessDeleteAndBackupMessages extends AbstractConstraint +{ + /** + * Success backup message + */ + const SUCCESS_BACKUP_MESSAGE = 'The database was backed up.'; + + /** + * Success website delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The website has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success messages is displayed after deleting website + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + $actualMessages = $storeIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertTrue( + in_array(self::SUCCESS_BACKUP_MESSAGE, $actualMessages) && + in_array(self::SUCCESS_DELETE_MESSAGE, $actualMessages), + 'Wrong success messages are displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website success delete and backup messages are present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.php new file mode 100644 index 00000000000..b4d52d6191a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessDeleteMessage.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessDeleteMessage + * Assert that after website delete successful message appears + */ +class AssertWebsiteSuccessDeleteMessage extends AbstractConstraint +{ + /** + * Success website delete message + */ + const SUCCESS_DELETE_MESSAGE = 'The website has been deleted.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after deleting website + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_DELETE_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success delete message is displayed.' + ); + } + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString() + { + return 'Website success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.php new file mode 100644 index 00000000000..0f56d581a03 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Constraint/AssertWebsiteSuccessSaveMessage.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\Store\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; + +/** + * Class AssertWebsiteSuccessSaveMessage + * Assert that after Website save successful message appears + */ +class AssertWebsiteSuccessSaveMessage extends AbstractConstraint +{ + /** + * Success website create message + */ + const SUCCESS_MESSAGE = 'The website has been saved.'; + + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that success message is displayed after Website has been created + * + * @param StoreIndex $storeIndex + * @return void + */ + public function processAssert(StoreIndex $storeIndex) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $storeIndex->getMessagesBlock()->getSuccessMessages(), + 'Wrong success message is displayed.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Website success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php index e530f73b84f..bd8e0f574fb 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.php @@ -43,7 +43,7 @@ class Store extends InjectableFixture protected $handlerInterface = 'Magento\Store\Test\Handler\Store\StoreInterface'; protected $defaultDataSet = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'Custom_Store_%isolation%', 'code' => 'code_%isolation%', 'is_active' => 'Enabled', @@ -79,6 +79,7 @@ class Store extends InjectableFixture 'is_required' => '', 'default_value' => '0', 'input' => 'select', + 'source' => 'Magento\Store\Test\Fixture\Store\GroupId', ]; protected $name = [ diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml index cd4f421f55c..7dd02b13a5f 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store.xml @@ -56,6 +56,7 @@ <is_required></is_required> <default_value>0</default_value> <input>select</input> + <source>Magento\Store\Test\Fixture\Store\GroupId</source> </group_id> <name> <attribute_code>name</attribute_code> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php similarity index 61% rename from dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php rename to dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php index 918f84757d5..3ab42e6505d 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/CatalogProductConfigurable/Price.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php @@ -22,18 +22,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable; +namespace Magento\Store\Test\Fixture\Store; +use Mtf\Fixture\FixtureFactory; use Mtf\Fixture\FixtureInterface; +use Magento\Store\Test\Fixture\StoreGroup; /** - * Class Price - * - * Data keys: - * - preset (Price verification preset name) - * - value (Price value) + * Class GroupId + * Prepare StoreGroup for Store */ -class Price implements FixtureInterface +class GroupId implements FixtureInterface { /** * Prepared dataSet data @@ -50,31 +49,35 @@ class Price implements FixtureInterface protected $params; /** - * Current preset + * StoreGroup fixture * - * @var string + * @var StoreGroup */ - protected $currentPreset; + protected $storeGroup; /** * Constructor * + * @param FixtureFactory $fixtureFactory * @param array $params * @param array $data [optional] */ - public function __construct(array $params, array $data = []) + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) { $this->params = $params; - if (isset($data['value'])) { - $this->data = $data['value']; - } - if (isset($data['preset'])) { - $this->currentPreset = $data['preset']; + if (isset($data['dataSet'])) { + $storeGroup = $fixtureFactory->createByCode('storeGroup', ['dataSet' => $data['dataSet']]); + /** @var StoreGroup $storeGroup */ + if (!$storeGroup->getGroupId()) { + $storeGroup->persist(); + } + $this->storeGroup = $storeGroup; + $this->data = $storeGroup->getWebsiteId() . "/" . $storeGroup->getName(); } } /** - * Persist custom selections products + * Persist attribute options * * @return void */ @@ -99,7 +102,7 @@ class Price implements FixtureInterface /** * Return data set configuration settings * - * @return string + * @return array */ public function getDataConfig() { @@ -107,27 +110,12 @@ class Price implements FixtureInterface } /** - * @return array|null + * Return StoreGroup fixture + * + * @return StoreGroup */ - public function getPreset() + public function getStoreGroup() { - $presets = [ - 'MAGETWO-23062' => [ - 'category_price' => '100.00', - 'product_price' => '100.00', - 'cart_price' => '154.00' - ], - 'MAGETWO-23063' => [ - 'category_price' => '100.00', - 'product_price' => '100.00', - 'cart_price' => '140.00' - ], - ]; - - if (!isset($presets[$this->currentPreset])) { - return null; - } - - return $presets[$this->currentPreset]; + return $this->storeGroup; } } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php b/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php index e62368ac341..58a6e8c4543 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Handler/Store/Curl.php @@ -92,6 +92,7 @@ class Curl extends AbstractCurl implements StoreInterface $data['store'] = $this->replaceMappingData($fixture->getData()); $data['store_action'] = isset($data['store_action']) ? $data['store_action'] : 'add'; $data['store_type'] = isset($data['store_type']) ? $data['store_type'] : 'store'; + $data['store']['group_id'] = $fixture->getDataFieldConfig('group_id')['source']->getStoreGroup()->getGroupId(); return $data; } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php index 3c86a70dc52..3c76d6bf812 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.php @@ -42,19 +42,24 @@ class Store extends AbstractRepository public function __construct(array $defaultConfig = [], array $defaultData = []) { $this->_data['default'] = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'Custom_Store_%isolation%', 'code' => 'code_%isolation%', 'is_active' => 'Enabled', ]; + $this->_data['default_store_view'] = [ + 'store_id' => 1, + 'name' => 'Default Store View', + ]; + $this->_data['All Store Views'] = [ 'name' => 'All Store Views', 'store_id' => 0, ]; $this->_data['german'] = [ - 'group_id' => 'Main Website Store', + 'group_id' => ['dataSet' => 'default'], 'name' => 'DE%isolation%', 'code' => 'de%isolation%', 'is_active' => 'Enabled', diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php index 1e1b11aede3..ca9c6f50841 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.php @@ -42,6 +42,17 @@ class StoreGroup extends AbstractRepository public function __construct(array $defaultConfig = [], array $defaultData = []) { $this->_data['default'] = [ + 'website_id' => [ + 'dataSet' => 'main_website' + ], + 'name' => 'Main Website Store', + 'group_id' => 1, + 'root_category_id' => [ + 'dataSet' => 'default_category' + ], + ]; + + $this->_data['custom'] = [ 'website_id' => [ 'dataSet' => 'main_website' ], diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php new file mode 100644 index 00000000000..62257154991 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.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\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreNew; +use Magento\Store\Test\Fixture\Store; +use Magento\Store\Test\Fixture\StoreGroup; + +/** + * Test Creation for CreateStoreEntity (Store Management) + * + * Preconditions: + * 1. Create Store Group + * + * Test Flow: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Click "Create Store View" button + * 4. Fill data according to dataset + * 5. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27647 + */ +class CreateStoreEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page StoreNew + * + * @var StoreNew + */ + protected $storeNew; + + /** + * Preparing pages for test + * + * @param StoreIndex $storeIndex + * @param StoreNew $storeNew + * @return void + */ + public function __inject(StoreIndex $storeIndex, StoreNew $storeNew) + { + $this->storeIndex = $storeIndex; + $this->storeNew = $storeNew; + } + + /** + * Runs Test Creation for StoreEntityTest + * + * @param Store $store + * @return void + */ + public function test(Store $store) + { + //Steps: + $this->storeIndex->open(); + $this->storeIndex->getGridPageActions()->addStoreView(); + $this->storeNew->getStoreForm()->fill($store); + $this->storeNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv new file mode 100644 index 00000000000..ab0eb22bdb5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest/test.csv @@ -0,0 +1,4 @@ +"store/data/group_id/dataSet";"store/data/name";"store/data/code";"store/data/is_active";"constraint";"issue" +"default";"store_name_%isolation%";"storecode_%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"" +"default";"store_name_%isolation%";"storecode_%isolation%";"Disabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreNotOnFrontend";"" +"custom";"store_name_%isolation%";"storecode_%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"Bug: MAGETWO-27726" \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php new file mode 100644 index 00000000000..310a4ffff29 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.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\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\NewWebsiteIndex; + +/** + * Create Website (Store Management) + * + * Test Flow: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Click "Create Website" button + * 4. Fill data according to dataset + * 5. Click "Save Web Site" button + * 6. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27665 + */ +class CreateWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * NewWebsiteIndex page + * + * @var NewWebsiteIndex + */ + protected $newWebsiteIndex; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param NewWebsiteIndex $newWebsiteIndex + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + NewWebsiteIndex $newWebsiteIndex + ) { + $this->storeIndex = $storeIndex; + $this->newWebsiteIndex = $newWebsiteIndex; + } + + /** + * Create Website + * + * @param Website $website + * @return void + */ + public function test(Website $website) + { + //Steps + $this->storeIndex->open(); + $this->storeIndex->getGridPageActions()->addNew(); + $this->newWebsiteIndex->getEditWebsiteForm()->fill($website); + $this->newWebsiteIndex->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv new file mode 100644 index 00000000000..5f4163b380f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest/test.csv @@ -0,0 +1,2 @@ +"website/data/name";"website/data/code";"constraint" +"website_%isolation%";"code_%isolation%";"assertWebsiteSuccessSaveMessage, assertWebsiteInGrid, assertWebsiteForm, assertWebsiteOnStoreForm" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php new file mode 100644 index 00000000000..ceaf7055d87 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.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\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditStore; +use Magento\Backup\Test\Page\Adminhtml\BackupIndex; +use Magento\Backend\Test\Page\Adminhtml\StoreDelete; +use Magento\Store\Test\Fixture\Store; + +/** + * Test Creation for DeleteStoreEntity + * + * Test Flow: + * Preconditions: + * 1. Create store view + * + * Steps: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Open created store view + * 4. Click "Delete Store View" + * 5. Set "Create DB Backup" according to dataSet + * 6. Click "Delete Store View" + * 7. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27942 + */ +class DeleteStoreEntityTest extends Injectable +{ + /** + * Page BackupIndex + * + * @var BackupIndex + */ + protected $backupIndex; + + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditStore + * + * @var EditStore + */ + protected $editStore; + + /** + * Page StoreDelete + * + * @var StoreDelete + */ + protected $storeDelete; + + /** + * Prepare pages for test + * + * @param BackupIndex $backupIndex + * @param StoreIndex $storeIndex + * @param EditStore $editStore + * @param StoreDelete $storeDelete + * @return void + */ + public function __inject( + BackupIndex $backupIndex, + StoreIndex $storeIndex, + EditStore $editStore, + StoreDelete $storeDelete + ) { + $this->storeIndex = $storeIndex; + $this->editStore = $editStore; + $this->backupIndex = $backupIndex; + $this->storeDelete = $storeDelete; + } + + /** + * Run Delete Store Entity test + * + * @param Store $store + * @param string $createBackup + * @return void + */ + public function test(Store $store, $createBackup) + { + // Preconditions: + $store->persist(); + $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All'); + + // Steps: + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenStore($store); + $this->editStore->getFormPageActions()->delete(); + $this->storeDelete->getStoreForm()->fillForm(['create_backup' => $createBackup]); + $this->storeDelete->getFormPageFooterActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv new file mode 100644 index 00000000000..51721d81362 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest/test.csv @@ -0,0 +1,3 @@ +"store/dataSet";"createBackup";"constraint" +"default";"Yes";"assertStoreSuccessDeleteAndBackupMessages, assertStoreNotInGrid, assertBackupInGrid, assertStoreNotOnFrontend" +"custom";"No";"assertStoreSuccessDeleteMessage, assertStoreNotInGrid, assertStoreNotOnFrontend" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php index 3cfbff17125..ebce8803b16 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php @@ -118,7 +118,7 @@ class DeleteStoreGroupEntityTest extends Injectable //Steps $this->storeIndex->open(); - $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeGroup); + $this->storeIndex->getStoreGrid()->searchAndOpenStoreGroup($storeGroup); $this->editGroup->getFormPageActions()->delete(); $this->deleteGroup->getDeleteGroupForm()->fillForm(['create_backup' => $createBackup]); $this->deleteGroup->getFormPageFooterActions()->delete(); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv index 546ab359a88..d79cf9afa6d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest/test.csv @@ -1,3 +1,3 @@ "storeGroup/dataSet";"createBackup";"constraint" -"default";"Yes";"assertStoreGroupSuccessDeleteAndBackupMessages, assertStoreGroupNotInGrid, assertBackupInGrid" -"default";"No";"assertStoreGroupSuccessDeleteMessage, assertStoreGroupNotInGrid" +"custom";"Yes";"assertStoreGroupSuccessDeleteAndBackupMessages, assertStoreGroupNotInGrid, assertBackupInGrid" +"custom";"No";"assertStoreGroupSuccessDeleteMessage, assertStoreGroupNotInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php new file mode 100644 index 00000000000..30cd3e6d2c6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.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\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; +use Magento\Backend\Test\Page\Adminhtml\DeleteWebsite; +use Magento\Backup\Test\Page\Adminhtml\BackupIndex; + +/** + * Delete Website (Store Management) + * + * Test Flow: + * + * Preconditions: + * 1. Create website + * 2. Delete all backups + * + * Steps: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Open created website + * 4. Click "Delete Web Site" + * 5. Fill data according to dataset + * 6. Click "Delete Web Site" + * 7. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27723 + */ +class DeleteWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditWebsite + * + * @var EditWebsite + */ + protected $editWebsite; + + /** + * Page DeleteWebsite + * + * @var DeleteWebsite + */ + protected $deleteWebsite; + + /** + * Page BackupIndex + * + * @var BackupIndex + */ + protected $backupIndex; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param DeleteWebsite $deleteWebsite + * @param BackupIndex $backupIndex + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + DeleteWebsite $deleteWebsite, + BackupIndex $backupIndex + ) { + $this->storeIndex = $storeIndex; + $this->editWebsite = $editWebsite; + $this->deleteWebsite = $deleteWebsite; + $this->backupIndex = $backupIndex; + } + + /** + * Delete Website + * + * @param Website $website + * @param string $createBackup + * @return void + */ + public function test(Website $website, $createBackup) + { + //Preconditions + $website->persist(); + $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All'); + + //Steps + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenWebsite($website); + $this->editWebsite->getFormPageActions()->delete(); + $this->deleteWebsite->getDeleteWebsiteForm()->fillForm(['create_backup' => $createBackup]); + $this->deleteWebsite->getFormPageFooterActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv new file mode 100644 index 00000000000..5e94af67424 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest/test.csv @@ -0,0 +1,3 @@ +"website/dataSet";"createBackup";"constraint" +"custom_website";"Yes";"assertWebsiteSuccessDeleteAndBackupMessages, assertWebsiteNotInGrid, assertBackupInGrid" +"custom_website";"No";"assertWebsiteSuccessDeleteMessage, assertWebsiteNotInGrid" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php index 303a97ace44..a4fb5a0a3ec 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/StoreTest.php @@ -70,9 +70,7 @@ class StoreTest extends Functional $configPage = Factory::getPageFactory()->getAdminSystemConfig(); $configPage->open(); - $configPage->getPageActions()->selectStore( - ['Main Website', $storeFixture->getGroupId(), $storeFixture->getName()] - ); + $configPage->getPageActions()->selectStore($storeFixture->getGroupId() . "/" . $storeFixture->getName()); $configGroup = $configPage->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', 'German (Germany)'); diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php new file mode 100644 index 00000000000..888a7f09943 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.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\Store\Test\TestCase; + +use Magento\Store\Test\Fixture\Store; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditStore; +use Mtf\TestCase\Injectable; + +/** + * Test Creation for UpdateStoreEntity (Store Management) + * + * Test Flow: + * Preconditions: + * 1.Create store view + * + * Steps: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Open created store view + * 4. Fill data according to dataset + * 5. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27786 + */ +class UpdateStoreEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditStore + * + * @var EditStore + */ + protected $editStore; + + /** + * Preparing pages for test + * + * @param StoreIndex $storeIndex + * @param EditStore $editStore + * @return void + */ + public function __inject(StoreIndex $storeIndex, EditStore $editStore) + { + $this->storeIndex = $storeIndex; + $this->editStore = $editStore; + } + + /** + * Runs Update Store Entity test + * + * @param Store $storeInitial + * @param Store $store + * @return void + */ + public function test(Store $storeInitial, Store $store) + { + // Preconditions: + $storeInitial->persist(); + + // Steps: + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeInitial); + $this->editStore->getStoreForm()->fill($store); + $this->editStore->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv new file mode 100644 index 00000000000..57998422915 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest/test.csv @@ -0,0 +1,2 @@ +"store/data/group_id/dataSet";"store/data/name";"store/data/code";"store/data/is_active";"constraint";"issue" +"default";"storename_updated%isolation%";"storecode_updated%isolation%";"Enabled";"assertStoreSuccessSaveMessage, assertStoreInGrid, assertStoreForm, assertStoreBackend, assertStoreFrontend";"Bug: MAGETWO-27726" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php index bb7284c19d3..8282fb0051d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php @@ -93,7 +93,7 @@ class UpdateStoreGroupEntityTest extends Injectable //Steps $this->storeIndex->open(); - $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeGroupOrigin); + $this->storeIndex->getStoreGrid()->searchAndOpenStoreGroup($storeGroupOrigin); $this->editGroup->getEditFormGroup()->fill($storeGroup); $this->editGroup->getFormPageActions()->save(); } diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php new file mode 100644 index 00000000000..32fb04a0fed --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.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\Store\Test\TestCase; + +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Store\Test\Fixture\Website; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Backend\Test\Page\Adminhtml\EditWebsite; + +/** + * Update Website (Store Management) + * + * Test Flow: + * + * Preconditions: + * 1. Create website + * + * Steps: + * 1. Open Backend + * 2. Go to Stores-> All Stores + * 3. Open created website + * 4. Fill data according to dataset + * 5. Click "Save Web Site" button + * 6. Perform all assertions + * + * @group Store_Management_(PS) + * @ZephyrId MAGETWO-27690 + */ +class UpdateWebsiteEntityTest extends Injectable +{ + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditWebsite + * + * @var EditWebsite + */ + protected $editWebsite; + + /** + * Fixture factory + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Injection data + * + * @param StoreIndex $storeIndex + * @param EditWebsite $editWebsite + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __inject( + StoreIndex $storeIndex, + EditWebsite $editWebsite, + FixtureFactory $fixtureFactory + ) { + $this->storeIndex = $storeIndex; + $this->editWebsite = $editWebsite; + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Update Website + * + * @param Website $websiteOrigin + * @param Website $website + * @return array + */ + public function test(Website $websiteOrigin, Website $website) + { + //Preconditions + $websiteOrigin->persist(); + + //Steps + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenWebsite($websiteOrigin); + $this->editWebsite->getEditFormWebsite()->fill($website); + $this->editWebsite->getFormPageActions()->save(); + + return ['website' => $this->mergeFixture($website, $websiteOrigin)]; + } + + /** + * Merge Website fixtures + * + * @param Website $website + * @param Website $websiteOrigin + * @return Website + */ + protected function mergeFixture(Website $website, Website $websiteOrigin) + { + $data = array_merge($websiteOrigin->getData(), $website->getData()); + return $this->fixtureFactory->createByCode('website', ['data' => $data]); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv new file mode 100644 index 00000000000..003ccb847ab --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest/test.csv @@ -0,0 +1,2 @@ +"websiteOrigin/dataSet";"website/data/name";"website/data/code";"constraint" +"custom_website";"website_upd%isolation%";"code_upd%isolation%";"assertWebsiteSuccessSaveMessage, assertWebsiteInGrid, assertWebsiteForm, assertWebsiteOnStoreForm" diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml index 4d1b8dafb80..6f3542645b2 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/etc/constraint.xml @@ -45,4 +45,58 @@ <assertStoreGroupSuccessDeleteAndBackupMessages module="Magento_Store"> <severeness>low</severeness> </assertStoreGroupSuccessDeleteAndBackupMessages> + <assertStoreSuccessSaveMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessSaveMessage> + <assertStoreInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertStoreInGrid> + <assertStoreBackend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreBackend> + <assertStoreFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreFrontend> + <assertStoreNotOnFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotOnFrontend> + <assertWebsiteSuccessSaveMessage module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessSaveMessage> + <assertWebsiteInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteInGrid> + <assertWebsiteOnStoreForm module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteOnStoreForm> + <assertWebsiteForm module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteForm> + <assertWebsiteSuccessDeleteAndBackupMessages module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessDeleteAndBackupMessages> + <assertWebsiteSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteSuccessDeleteMessage> + <assertWebsiteNotInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertWebsiteNotInGrid> + <assertStoreForm module="Magento_Store"> + <severeness>low</severeness> + </assertStoreForm> + <assertStoreSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteMessage> + <assertStoreSuccessDeleteMessage module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteMessage> + <assertStoreNotInGrid module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotInGrid> + <assertStoreNotOnFrontend module="Magento_Store"> + <severeness>low</severeness> + </assertStoreNotOnFrontend> + <assertStoreSuccessDeleteAndBackupMessages module="Magento_Store"> + <severeness>low</severeness> + </assertStoreSuccessDeleteAndBackupMessages> </constraint> diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php index e8c6933006c..bb64ed04fa7 100644 --- a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Footer.php @@ -27,9 +27,11 @@ namespace Magento\Theme\Test\Block\Html; use Mtf\Block\Block; use Mtf\Client\Element\Locator; +use Magento\Store\Test\Fixture\Store; /** * Footer block + * CmsIndex page footer block */ class Footer extends Block { @@ -47,6 +49,27 @@ class Footer extends Block */ protected $variableSelector = './/div[contains(@class, "links")]/*[text()="%s"]'; + /** + * Store group dropdown selector + * + * @var string + */ + protected $storeGroupDropdown = '.switcher.store'; + + /** + * Store Group switch selector + * + * @var string + */ + protected $storeGroupSwitch = '[data-toggle="dropdown"]'; + + /** + * Store group selector + * + * @var string + */ + protected $storeGroupSelector = './/a[contains(.,"%s")]'; + /** * Click on link by name * @@ -76,4 +99,47 @@ class Footer extends Block Locator::SELECTOR_XPATH )->isVisible(); } + + /** + * Select store group + * + * @param Store $store + * @return void + */ + public function selectStoreGroup(Store $store) + { + $storeGroupName = explode("/", $store->getGroupId())[1]; + $this->_rootElement->find($this->storeGroupSwitch)->click(); + $storeGroup = $this->_rootElement->find( + sprintf($this->storeGroupSelector, $storeGroupName), + Locator::SELECTOR_XPATH + ); + $storeGroup->click(); + } + + /** + * Check if store visible in dropdown + * + * @param Store $store + * @return bool + */ + public function isStoreGroupVisible(Store $store) + { + $storeGroupName = explode("/", $store->getGroupId())[1]; + $this->_rootElement->find($this->storeGroupSwitch)->click(); + return $this->_rootElement->find( + sprintf($this->storeGroupSelector, $storeGroupName), + Locator::SELECTOR_XPATH + )->isVisible(); + } + + /** + * Check if store group switcher is visible + * + * @return bool + */ + public function isStoreGroupSwitcherVisible() + { + return $this->_rootElement->find($this->storeGroupSwitch)->isVisible(); + } } 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 2b4a18baeea..bb95c7642d6 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 @@ -53,14 +53,11 @@ class Links extends Block * Open Link by title * * @param string $linkTitle - * @return Element + * @return void */ public function openLink($linkTitle) { - $link = $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH); - if ($link->isVisible()) { - $link->click(); - } + $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH)->click(); } /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php index fde7fdf4d8f..8d47ae09773 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserRoleSalesRestrictedAccess.php @@ -24,7 +24,7 @@ namespace Magento\User\Test\Constraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserIndex; use Mtf\Constraint\AbstractConstraint; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php index f28c256c9a5..b36598af652 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogOut.php @@ -24,7 +24,7 @@ namespace Magento\User\Test\Constraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Mtf\Constraint\AbstractConstraint; use Magento\Backend\Test\Page\AdminAuthLogin; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php index ec153d57da0..1b892d2dccb 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Constraint/AssertUserSuccessLogin.php @@ -26,7 +26,7 @@ namespace Magento\User\Test\Constraint; use Magento\User\Test\Fixture\User; use Mtf\Constraint\AbstractConstraint; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\Backend\Test\Page\AdminAuthLogin; /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php index 025957a13f0..41becdfffb2 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserEdit; use Magento\User\Test\Page\Adminhtml\UserIndex; use Mtf\TestCase\Injectable; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php index 6b4aa2d57f6..67d86b6cffc 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Fixture\User; use Magento\User\Test\Fixture\AdminUserRole; use Magento\User\Test\Page\Adminhtml\UserRoleIndex; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php index a7c99546e7d..b62a01cf0ec 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php @@ -29,7 +29,7 @@ use Magento\User\Test\Fixture\User; use Magento\User\Test\Fixture\AdminUserRole; use Mtf\Fixture\FixtureFactory; use Mtf\TestCase\Injectable; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserEdit; use Magento\User\Test\Page\Adminhtml\UserIndex; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php index e86507cf1e6..2c802043f44 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php @@ -25,7 +25,7 @@ namespace Magento\User\Test\TestCase; use Magento\Backend\Test\Page\AdminAuthLogin; -use Magento\Backend\Test\Page\Dashboard; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\User\Test\Page\Adminhtml\UserRoleIndex; use Magento\User\Test\Page\Adminhtml\UserRoleEditRole; use Magento\User\Test\Fixture\User; diff --git a/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml index cff67adbe36..b0b8a44a22f 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/etc/constraint.xml @@ -27,7 +27,7 @@ <assertUserSuccessLogin module="Magento_User"> <severeness>low</severeness> <require> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> <adminAuth class="Magento\Backend\Test\Page\AdminAuthLogin" /> <user class="Magento\User\Test\Fixture\User" /> <customAdmin class="Magento\User\Test\Fixture\User" /> @@ -37,7 +37,7 @@ <severeness>low</severeness> <require> <adminAuth class="Magento\Backend\Test\Page\AdminAuthLogin" /> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> </require> </assertUserSuccessLogOut> <assertUserWrongCredentialsMessage module="Magento_User"> @@ -51,7 +51,7 @@ <severeness>low</severeness> <require> <userIndex class="Magento\User\Test\Page\Adminhtml\UserIndex" /> - <dashboard class="Magento\Backend\Test\Page\Dashboard" /> + <dashboard class="Magento\Backend\Test\Page\Adminhtml\Dashboard" /> </require> </assertUserRoleSalesRestrictedAccess> <assertRoleSuccessSaveMessage module="Magento_User"> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.php new file mode 100644 index 00000000000..ec3a08020fc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist.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\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab; + +use Mtf\Client\Element; +use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid; + +/** + * Class Wishlist + * Customer Wishlist edit tab + */ +class Wishlist extends Tab +{ + /** + * Wishlist grid selector + * + * @var string + */ + protected $wishlistGrid = '#wishlistGrid'; + + /** + * Get wishlist grid + * + * @return Grid + */ + public function getSearchGridBlock() + { + return $this->blockFactory->create( + 'Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid', + ['element' => $this->_rootElement->find($this->wishlistGrid)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php new file mode 100644 index 00000000000..d6a2795732a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.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\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist; + +use Magento\Backend\Test\Block\Widget\Grid as ParentGrid; +use Mtf\Client\Element\Locator; + +/** + * Class Grid + * Grid on Wishlist tab in customer details on backend + */ +class Grid extends ParentGrid +{ + /** + * Grid fields map + * + * @var array + */ + protected $filters = [ + 'product_name' => [ + 'selector' => 'input[name="product_name"]' + ], + ]; + + /** + * Delete link selector + * + * @var string + */ + protected $deleteLink = 'a[onclick*="removeItem"]'; + + /** + * Search item and delete it + * + * @param array $filter + * @return void + * @throws \Exception + */ + public function searchAndDelete(array $filter) + { + $this->search($filter); + $rowItem = $this->_rootElement->find($this->rowItem, Locator::SELECTOR_CSS); + $rowItem->find($this->deleteLink, Locator::SELECTOR_CSS)->click(); + $this->_rootElement->acceptAlert(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml new file mode 100644 index 00000000000..3b0db450390 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.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) + */ +--> +<tabs> + <wishlist> + <class>\Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist</class> + <selector>#customer_info_tabs_wishlist</selector> + <strategy>css selector</strategy> + </wishlist> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php index 7e59d1c591b..d9cde22eebd 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist.php @@ -39,6 +39,27 @@ class Wishlist extends Block */ protected $shareWishList = '[name="save_and_share"]'; + /** + * Product items selector + * + * @var string + */ + protected $productItems = '.product-items'; + + /** + * Selector for 'Add to Cart' button + * + * @var string + */ + protected $addToCart = '.action.tocart'; + + /** + * Button 'Update Wish List' css selector + * + * @var string + */ + protected $updateButton = '.action.update'; + /** * Click button "Share Wish List" * @@ -48,4 +69,37 @@ class Wishlist extends Block { $this->_rootElement->find($this->shareWishList)->click(); } + + /** + * Get items product block + * + * @return \Magento\Wishlist\Test\Block\Customer\Wishlist\Items + */ + public function getProductItemsBlock() + { + return $this->blockFactory->create( + 'Magento\Wishlist\Test\Block\Customer\Wishlist\Items', + ['element' => $this->_rootElement->find($this->productItems)] + ); + } + + /** + * Click button 'Add To Cart' + * + * @return void + */ + public function clickAddToCart() + { + $this->_rootElement->find($this->addToCart)->click(); + } + + /** + * Click button 'Update Wish List' + * + * @return void + */ + public function clickUpdateWishlist() + { + $this->_rootElement->find($this->updateButton)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.php new file mode 100644 index 00000000000..9bb947f4b96 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items.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\Wishlist\Test\Block\Customer\Wishlist; + +use Mtf\Block\Block; +use Mtf\Client\Element; +use Mtf\Client\Element\Locator; + +/** + * Class Items + * Customer wishlist items block on frontend + */ +class Items extends Block +{ + /** + * Product name link selector + * + * @var string + */ + protected $productName = '//a[contains(@class,"product-item-link") and contains(.,"%s")]'; + + /** + * Check that product present in wishlist + * + * @param string $productName + * @return bool + */ + public function isProductPresent($productName) + { + $productNameSelector = sprintf($this->productName, $productName); + + return $this->_rootElement->find($productNameSelector, Locator::SELECTOR_XPATH)->isVisible(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.php new file mode 100644 index 00000000000..d5d194f202e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsAbsentInWishlist.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\Wishlist\Test\Constraint; + +use Mtf\Constraint\AbstractConstraint; +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Magento\Wishlist\Test\Page\WishlistIndex; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Mtf\Fixture\InjectableFixture; + +/** + * Class AssertProductIsAbsentInWishlist + * Assert that product is absent in Wishlist on Frontend + */ +class AssertProductIsAbsentInWishlist extends AbstractConstraint +{ + /** + * Constraint severeness + * + * @var string + */ + protected $severeness = 'low'; + + /** + * Assert that product is not present in Wishlist on Frontend + * + * @param CustomerAccountIndex $customerAccountIndex + * @param WishlistIndex $wishlistIndex + * @param InjectableFixture $product + * @param CustomerInjectable $customer + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @return void + */ + public function processAssert( + CustomerAccountIndex $customerAccountIndex, + WishlistIndex $wishlistIndex, + InjectableFixture $product, + CustomerInjectable $customer, + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout + ) { + $productName = $product->getName(); + $customerAccountLogout->open(); + $cmsIndex->getLinksBlock()->openLink('Log In'); + $customerAccountLogin->getLoginBlock()->login($customer); + $customerAccountIndex->open()->getAccountMenuBlock()->openMenuItem("My Wish List"); + \PHPUnit_Framework_Assert::assertFalse( + $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->isProductPresent($productName), + 'Product \'' . $productName . '\' is present in Wishlist on Frontend.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Product is absent in Wishlist on Frontend.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php new file mode 100644 index 00000000000..42dc56f3d80 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\TestCase; + +use Mtf\Client\Browser; +use Mtf\TestCase\Injectable; +use Mtf\Fixture\FixtureFactory; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountLogin; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Customer\Test\Fixture\CustomerInjectable; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; + +/** + * Test creation for DeleteProductFromCustomerWishlistOnBackend + * + * Test Flow: + * + * Preconditions: + * 1. Create customer + * 2. Create product + * 3. Login to frontend as a customer + * 4. Add product to Wish List + * + * Steps: + * 1. Go to Backend + * 2. Go to Customers > All Customers + * 3. Open the customer + * 4. Open wishlist tab + * 5. Click 'Delete' + * 6. Perform assertions + * + * @group Wishlist_(CS) + * @ZephyrId MAGETWO-27813 + */ +class DeleteProductFromCustomerWishlistOnBackendTest extends Injectable +{ + /** + * Cms index page + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Customer login page + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Product view page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Page CustomerAccountLogout + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Page of all customer grid + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Prepare data + * + * @param CustomerInjectable $customer + * @return array + */ + public function __prepare(CustomerInjectable $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Injection data + * + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogProductView $catalogProductView + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout, + CatalogProductView $catalogProductView, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit + ) { + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogProductView = $catalogProductView; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + + } + + /** + * Delete product from customer wishlist on backend + * + * @param Browser $browser + * @param CustomerInjectable $customer + * @param FixtureFactory $fixtureFactory + * @param string $product + * @return array + */ + public function test(Browser $browser, CustomerInjectable $customer, FixtureFactory $fixtureFactory, $product) + { + $this->markTestIncomplete('MAGETWO-27949'); + //Preconditions + list($fixture, $dataSet) = explode('::', $product); + $product = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); + $product->persist(); + $this->loginCustomer($customer); + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->addToWishlist(); + + //Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $customerForm = $this->customerIndexEdit->getCustomerForm(); + $customerForm->openTab('wishlist'); + $filter = ['product_name' => $product->getName()]; + $customerForm->getTabElement('wishlist')->getSearchGridBlock()->searchAndDelete($filter); + + return ['product' => $product]; + } + + /** + * Login customer + * + * @param CustomerInjectable $customer + * @return void + */ + protected function loginCustomer(CustomerInjectable $customer) + { + $this->cmsIndex->open(); + if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { + $this->cmsIndex->getLinksBlock()->openLink('Log In'); + $this->customerAccountLogin->getLoginBlock()->login($customer); + } + } + + /** + * Log out after test + * + * @return void + */ + public function tearDown() + { + $this->customerAccountLogout->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv new file mode 100644 index 00000000000..1991656cea3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductFromCustomerWishlistOnBackendTest/test.csv @@ -0,0 +1,3 @@ +"product";"constraint" +"configurableProductInjectable::default";"assertProductIsAbsentInWishlist" +"catalogProductSimple::simple_for_composite_products";"assertProductIsAbsentInWishlist" diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php index 19dcbed29de..a2b41e6afab 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php @@ -24,6 +24,7 @@ namespace Magento\Wishlist\Test\TestCase; +use Mtf\Client\Browser; use Mtf\TestCase\Injectable; use Magento\Cms\Test\Page\CmsIndex; use Magento\Customer\Test\Page\CustomerAccountLogin; @@ -38,11 +39,13 @@ use Magento\Wishlist\Test\Page\WishlistShare; /** * Test Creation for ShareWishlistEntity * + * Test Flow: + * * Preconditions: * 1. Create Customer Account * 2. Create product * - * Test Flow: + * Steps: * 1. Login to frontend as a Customer * 2. Add product to Wish List * 3. Click "Share Wish List" button @@ -157,17 +160,22 @@ class ShareWishlistEntityTest extends Injectable /** * Share wish list * + * @param Browser $browser * @param CustomerInjectable $customer * @param CatalogProductSimple $product * @param array $sharingInfo * @return void */ - public function test(CustomerInjectable $customer, CatalogProductSimple $product, $sharingInfo) - { + public function test( + Browser $browser, + CustomerInjectable $customer, + CatalogProductSimple $product, + array $sharingInfo + ) { //Steps $this->loginCustomer($customer); - $this->catalogProductView->init($product); - $this->catalogProductView->open()->getViewBlock()->addToWishlist(); + $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->addToWishlist(); $this->wishlistIndex->getWishlistBlock()->clickShareWishList(); $this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo); $this->wishlistShare->getSharingInfoForm()->shareWishlist(); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml similarity index 88% rename from dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml rename to dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml index 4d3295a7648..3645f787454 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/global/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/etc/constraint.xml @@ -27,4 +27,7 @@ <assertWishlistShareMessage module="Magento_Wishlist"> <severeness>low</severeness> </assertWishlistShareMessage> + <assertProductIsAbsentInWishlist module="Magento_Wishlist"> + <severeness>low</severeness> + </assertProductIsAbsentInWishlist> </constraint> diff --git a/dev/tests/functional/utils/generate/factory.php b/dev/tests/functional/utils/generate/factory.php index 69fa2cc30fd..279a8d24bca 100644 --- a/dev/tests/functional/utils/generate/factory.php +++ b/dev/tests/functional/utils/generate/factory.php @@ -21,11 +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) */ -umask(0); -$appRoot = dirname(dirname(dirname(dirname(dirname(__DIR__))))); - -require $appRoot . '/app/bootstrap.php'; +require __DIR__ . '/../../../../../app/bootstrap.php'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); $mtfRoot = dirname(dirname(dirname(__FILE__))); $mtfRoot = str_replace('\\', '/', $mtfRoot); @@ -41,6 +39,8 @@ $path .= PATH_SEPARATOR . MTF_BP . '/vendor/magento/mtf'; $path .= PATH_SEPARATOR . MTF_BP . '/vendor/phpunit/phpunit'; set_include_path($path); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Mtf\Util\Generate\Factory'); +$om = $bootstrap->getObjectManager(); +/** @var \Mtf\Util\Generate\Factory $generator */ +$generator = $om->create('Mtf\Util\Generate\Factory'); +$generator->launch(); \Mtf\Util\Generate\GenerateResult::displayResults(); diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php index 0ab3c7d9f6d..5f3f878465f 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Eav.php @@ -36,7 +36,7 @@ class Eav public static function setIncrementIdPrefix($entityType, $prefix) { $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite(); $storeId = $website->getDefaultStore()->getId(); $entityTypeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index e0ae647b2ac..21cc7371364 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -157,6 +157,7 @@ class ObjectManagerFactory extends \Magento\Framework\App\ObjectManagerFactory * Override method in while running integration tests to prevent getting Exception * * @param \Magento\Framework\ObjectManager $objectManager + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function configureDirectories(\Magento\Framework\ObjectManager $objectManager) { diff --git a/app/code/Magento/Install/Controller/Wizard/LocalePost.php b/dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php similarity index 63% rename from app/code/Magento/Install/Controller/Wizard/LocalePost.php rename to dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php index e98107200f2..eabab85f95f 100644 --- a/app/code/Magento/Install/Controller/Wizard/LocalePost.php +++ b/dev/tests/integration/testsuite/Magento/Backend/AdminConfigTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,25 +21,28 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class LocalePost extends \Magento\Install\Controller\Wizard +namespace Magento\Backend; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test class for \Magento\Backend\AdminConfig + * + */ +class AdminConfigTest extends \PHPUnit_Framework_TestCase { /** - * Saving localization settings + * Test for setting session name for admin * - * @return void */ - public function execute() + public function testSetSessionNameByConstructor() { - $this->_checkIfInstalled(); - $step = $this->_getWizard()->getStepByName('locale'); - - $data = $this->getRequest()->getPost('config'); - if ($data) { - $this->_session->setLocaleData($data); - } - - $this->getResponse()->setRedirect($step->getNextUrl()); + $sessionName = 'adminHtmlSession'; + $adminConfig = Bootstrap::getObjectManager()->create( + 'Magento\Backend\AdminConfig', + ['sessionName' => $sessionName] + ); + $this->assertSame($sessionName, $adminConfig->getName()); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php index f215badc3a4..720fa4b7d0a 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Edit/FormTest.php @@ -118,7 +118,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the product you chose is not associated with */ public function testGetEntityStoresProductStoresException() @@ -133,7 +133,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the product you chose is not associated with */ public function testGetEntityStoresProductCategoryStoresException() @@ -151,7 +151,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\Model\Exception * @expectedExceptionMessage We can't set up a URL rewrite because the category your chose is not associated with */ public function testGetEntityStoresCategoryStoresException() diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php index f45662a2115..5620a13d839 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/FormTest.php @@ -114,8 +114,8 @@ class FormTest extends \PHPUnit_Framework_TestCase * @magentoAppIsolation enabled * @magentoDataFixture Magento/Core/_files/store.php * - * @expectedException \Magento\Store\Model\Exception - * @expectedExceptionMessage Chosen cms page does not associated with any website. + * @expectedException \Magento\Framework\Model\Exception + * @expectedExceptionMessage Chosen cms page is not associated with any website. */ public function testGetEntityStoresProductStoresException() { diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php index 83dbf152e17..c0d0354f2bf 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Edit/FormTest.php @@ -122,7 +122,7 @@ class FormTest extends \PHPUnit_Framework_TestCase // Check that store value set correctly $defaultStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( true )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php new file mode 100644 index 00000000000..44d019b7f9d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php @@ -0,0 +1,215 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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; + +use Magento\Bundle\Service\V1\Data\Product\Link; +use Magento\Bundle\Service\V1\Data\Product\LinkBuilder; +use Magento\Bundle\Service\V1\Data\Product\Option; +use Magento\Bundle\Service\V1\Data\Product\OptionBuilder; +use Magento\Catalog\Service\V1\Data\Product; +use Magento\Catalog\Service\V1\Data\ProductBuilder; +use Magento\Catalog\Service\V1\Data\ProductMapper; +use Magento\Catalog\Service\V1\ProductServiceInterface; +use Magento\Catalog\Service\V1\Product\ProductLoader; +use Magento\Catalog\Model\Product\Type; +use Magento\Framework\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Integration test for service layer \Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor + * + */ +class BundleProductSaveProcessorTest extends \PHPUnit_Framework_TestCase +{ + + /** @var ProductMapper */ + protected $productMapper; + + /** @var ObjectManager */ + private $objectManager; + + /** @var ProductLoader */ + private $productLoader; + + /** @var ProductServiceInterface */ + private $productService; + + /** @var ProductBuilder */ + private $productBuilder; + + /** @var LinkBuilder */ + private $linkBuilder; + + /** @var OptionBuilder */ + private $optionBuilder; + + /** @var \Magento\Bundle\Model\Product\Type $productType */ + private $productType; + + /** @var \Magento\Catalog\Model\ProductRepository */ + private $productRepository; + + + /** + * Initialize dependencies + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->productType = $this->objectManager->create('Magento\Bundle\Model\Product\Type'); + $this->productRepository = $this->objectManager->get('Magento\Catalog\Model\ProductRepository'); + $this->productLoader = $this->objectManager->create('Magento\Catalog\Service\V1\Product\ProductLoader'); + $this->productMapper = $this->objectManager->create('Magento\Catalog\Service\V1\Data\ProductMapper'); + $this->productService = $this->objectManager->create('Magento\Catalog\Service\V1\ProductServiceInterface'); + $this->productBuilder = $this->objectManager->create('Magento\Catalog\Service\V1\Data\ProductBuilder'); + $this->linkBuilder = $this->objectManager->create('Magento\Bundle\Service\V1\Data\Product\LinkBuilder'); + $this->optionBuilder = $this->objectManager->create('Magento\Bundle\Service\V1\Data\Product\OptionBuilder'); + + // create existing options + } + + /** + * Create bundle product data for use in creating a new product + * + * @return Product + */ + private function createBundleProductData($skuSuffix) + { + /** @var Link $firstLink */ + $firstLink = $this->linkBuilder + ->setSku('simple') + ->create(); + /** @var Link[] $links */ + $links = array($firstLink); + + /** @var Option $firstOption */ + $firstOption = $this->optionBuilder + ->setProductLinks($links) + ->create(); + + /** @var Product bundleProduct */ + $bundleProduct = $this->productBuilder + ->setSku('sku-z' . $skuSuffix) + ->setName('Fancy Bundle') + ->setTypeId(Type::TYPE_BUNDLE) + ->setPrice(50.00) + ->setCustomAttribute('bundle_product_options', array($firstOption)) + ->setCustomAttribute('price_view', 'test') + ->create(); + + return $bundleProduct; + } + + /** + * Test creation of bundle product through ProductService. + * data fixture below automatically isolates the db + * + * @magentoDataFixture Magento/Catalog/_files/products.php + * @magentoAppIsolation enabled + */ + public function testCreateBundleProduct() + { + /** @var Product $bundleProduct */ + $bundleProduct = $this->createBundleProductData('-create'); + $sku = $this->productService->create($bundleProduct); + $this->assertEquals('sku-z-create', $sku); + + // load and confirm number of options and links + /** @var Product $savedProduct */ + $savedProduct = $this->productService->get($sku); + /** @var Option[] $updatedOptions */ + $savedOptions = $savedProduct->getCustomAttribute('bundle_product_options')->getValue(); + $this->assertTrue(is_array($savedOptions)); + $this->assertEquals(1, count($savedOptions)); + $option = $savedOptions[0]; + $linkedProducts = $option->getProductLinks(); + $this->assertTrue(is_array($linkedProducts)); + $this->assertEquals(1, count($linkedProducts)); + $link = $linkedProducts[0]; + $this->assertEquals('simple', $link->getSku()); + } + + /** + * @magentoDataFixture Magento/Bundle/_files/product.php + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * @magentoAppIsolation enabled + */ + public function testUpdateBundleProduct() + { + // get existing bundle product + $savedProduct = $this->productService->get('bundle-product'); + + /** @var Link $newLink */ + $newLink = $this->linkBuilder + ->setSku('simple2') + ->create(); + /** @var Link[] $links */ + $links = array($newLink); + + /** @var Option $newOption */ + $newOption = $this->optionBuilder + ->setProductLinks($links) + ->create(); + + /** @var Product bundleProduct */ + $updatedBundleProduct = $this->productBuilder + ->populate($savedProduct) + ->setCustomAttribute('bundle_product_options', array($newOption)) + ->setCustomAttribute('price_view', 'test') + ->setCustomAttribute('price', 10) + ->create(); + + $this->assertEquals('bundle-product', $this->productService->update('bundle-product', $updatedBundleProduct)); + $this->productRepository->get('bundle-product')->unsetData('_cache_instance_options_collection'); + + // load and confirm number of links and options + $savedProduct = $this->productService->get('bundle-product'); + /** @var Option[] $updatedOptions */ + $savedOptions = $savedProduct->getCustomAttribute('bundle_product_options')->getValue(); + $this->assertTrue(is_array($savedOptions)); + $this->assertEquals(1, count($savedOptions)); + $option = $savedOptions[0]; + $linkedProducts = $option->getProductLinks(); + $this->assertTrue(is_array($linkedProducts)); + $this->assertEquals(1, count($linkedProducts)); + $link = $linkedProducts[0]; + $this->assertEquals('simple2', $link->getSku()); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Bundle/_files/product.php + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ + public function testDeleteBundleProduct() + { + $existingProduct = $this->productService->get('bundle-product'); + $this->assertNotNull($existingProduct); + $this->assertTrue($this->productService->delete('bundle-product')); + $this->productService->get('bundle-product'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php index ac9337bbe27..570e72a9b51 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php @@ -64,7 +64,7 @@ class ObserverTest extends \Magento\TestFramework\TestCase\AbstractController public function testCaptchaIsRequiredAfterFailedLoginAttempts() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setCurrentStore( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php index edf1e97513a..50e23a41906 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/NewTest.php @@ -65,7 +65,7 @@ class NewTest extends \PHPUnit_Framework_TestCase $this->assertSame(1, array_shift($keys)); $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $info[1] ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php index b33bd480889..bae2f771724 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php @@ -175,8 +175,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _prepareCompareListWithProductNameXss() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -187,7 +188,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ); $item->setVisitorId($visitor->getId())->setProductId(1)->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -195,8 +196,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _requireVisitorWithNoProducts() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() @@ -205,7 +207,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $visitor->setSessionId(md5(time()) . md5(microtime()))->setLastVisitAt($dateTime->now())->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -215,8 +217,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController protected function _requireVisitorWithTwoProducts() { - /** @var $visitor \Magento\Log\Model\Visitor */ - $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Log\Model\Visitor'); + /** @var $visitor \Magento\Customer\Model\Visitor */ + $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -235,7 +238,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $item->setVisitorId($visitor->getId())->setProductId(2)->save(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Log\Model\Visitor' + 'Magento\Customer\Model\Visitor' )->load( $visitor->getId() ); @@ -271,9 +274,9 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ->get('Magento\Customer\Model\Session'); $session->setCustomerId(1); - /** @var $visitor \Magento\Log\Model\Visitor */ + /** @var $visitor \Magento\Customer\Model\Visitor */ $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Log\Model\Visitor'); + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -296,7 +299,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ->setProductId(2) ->save(); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor') ->load($visitor->getId()); $this->_assertCompareListEquals(array(1, 2)); @@ -316,7 +319,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $compareItems->useProductItem(true); // important $compareItems->setVisitorId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor')->getId() + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor')->getId() ); $actualProductIds = array(); foreach ($compareItems as $compareItem) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php index 7ccf67c76c4..6b90f42df52 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php @@ -232,7 +232,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->helper->isUsingStaticUrlsAllowed()); $this->helper->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ); $this->assertTrue($this->helper->isUsingStaticUrlsAllowed()); @@ -253,7 +253,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->helper->isUrlDirectivesParsingAllowed()); $this->helper->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ); $this->assertFalse($this->helper->isUrlDirectivesParsingAllowed()); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php index 9178ab60097..fb3748e4951 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/ImageTest.php @@ -63,7 +63,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase // watermark fixture mkdir( $fixtureMediaDir . '/watermark/stores/' . $objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), 0777, true @@ -71,7 +71,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase copy( "{$fixtureDir}/watermark.jpg", $fixtureMediaDir . '/watermark/stores/' . $objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() . '/watermark.jpg' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php index 3d03920b914..3973c36cff9 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php @@ -155,7 +155,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->assertSame( $store, \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore() ); } @@ -164,7 +164,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $ids = $this->_model->getWebsiteStoreIds(); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $this->assertEquals(array($storeId => $storeId), $ids); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php index e292e1ac09d..283efafec1b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php @@ -47,12 +47,12 @@ class CategoryImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_oldLogActive = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getConfig( 'dev/log/active' ); $this->_oldExceptionFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getConfig( 'dev/log/exception_file' ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 3e30cf4c7b4..5465f19b8a1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -63,8 +63,8 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var $storeManager \Magento\Store\Model\StoreManagerInterface */ - $storeManager = self::$_objectManager->get('Magento\Store\Model\StoreManagerInterface'); + /** @var $storeManager \Magento\Framework\StoreManagerInterface */ + $storeManager = self::$_objectManager->get('Magento\Framework\StoreManagerInterface'); $this->_store = $storeManager->getStore(); $this->_model = self::$_objectManager->create('Magento\Catalog\Model\Category'); } @@ -139,7 +139,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase /* id from fixture */ $this->assertContains( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreIds() ); @@ -149,7 +149,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreId() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php index 22ed5a1c7c0..d4ad93bc741 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/CategoryTest.php @@ -169,7 +169,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $this->assertSame( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore(), $this->_model->getCurrentStore() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php index 57f39e17b42..cf125e7e7d1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php @@ -97,7 +97,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase $product->getId(), $this->_model->getAttribute()->getId(), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php index 00e57c0ff30..16d5e004a7a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/TierpriceTest.php @@ -159,10 +159,10 @@ class TierpriceTest extends \PHPUnit_Framework_TestCase public function testAfterSaveEmpty() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setCurrentStore( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( \Magento\Store\Model\Store::DEFAULT_STORE_ID ) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php index c145e148301..f664846e97d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php @@ -36,7 +36,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Log\Model\Visitor + * @var \Magento\Customer\Model\Visitor */ protected $_visitor; @@ -49,7 +49,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase $this->_session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Customer\Model\Session'); $this->_visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Log\Model\Visitor'); + ->create('Magento\Customer\Model\Visitor'); /** @var \Magento\Framework\Stdlib\DateTime $dateTime */ $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Framework\Stdlib\DateTime'); @@ -57,7 +57,7 @@ class ListCompareTest extends \PHPUnit_Framework_TestCase ->setLastVisitAt($dateTime->now()) ->save(); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Catalog\Model\Product\Compare\ListCompare', ['logVisitor' => $this->_visitor]); + ->create('Magento\Catalog\Model\Product\Compare\ListCompare', ['customerVisitor' => $this->_visitor]); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php index 452afac3beb..ea43aa2b92d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductExternalTest.php @@ -49,7 +49,7 @@ class ProductExternalTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $this->_model->getStoreId() ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php index ecd81605f25..ce6fc4da174 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php @@ -218,7 +218,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function _undo($duplicate) { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( \Magento\Store\Model\Store::DEFAULT_STORE_ID ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php index f19bccb2591..0e68315937c 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products.php @@ -23,37 +23,26 @@ */ /** @var $product \Magento\Catalog\Model\Product */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); -$product->setTypeId( - 'simple' -)->setId( - 1 -)->setAttributeSetId( - 4 -)->setWebsiteIds( - array(1) -)->setName( - 'Simple Product' -)->setSku( - 'simple' -)->setPrice( - 10 -)->setMetaTitle( - 'meta title' -)->setMetaKeyword( - 'meta keyword' -)->setMetaDescription( - 'meta description' -)->setVisibility( - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH -)->setStatus( - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED -)->setStockData( - array('use_config_manage_stock' => 0) -)->save(); +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product + ->setTypeId('simple') + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(array('use_config_manage_stock' => 0)) + ->save(); + +$customDesignProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product', array('data' => $product->getData())); -$customDesignProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Catalog\Model\Product', - array('data' => $product->getData()) -); $customDesignProduct->setId(2)->setCustomDesign('Magento/blank')->save(); + diff --git a/app/code/Magento/Install/Controller/Wizard/BeginPost.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php similarity index 56% rename from app/code/Magento/Install/Controller/Wizard/BeginPost.php rename to dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php index 098c2501a2c..4d2c4684a76 100644 --- a/app/code/Magento/Install/Controller/Wizard/BeginPost.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_product_simple.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,24 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class BeginPost extends \Magento\Install\Controller\Wizard -{ - /** - * Process begin step POST data - * - * @return void - */ - public function execute() - { - $this->_checkIfInstalled(); +/** @var $product2 \Magento\Catalog\Model\Product */ +$product2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product2 + ->setTypeId('simple') + ->setId(6) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Simple Product2') + ->setSku('simple2') + ->setPrice(10) + ->setMetaTitle('meta title2') + ->setMetaKeyword('meta keyword2') + ->setMetaDescription('meta description2') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(array('use_config_manage_stock' => 0)) + ->save(); - $agree = $this->getRequest()->getPost('agree'); - if ($agree && ($step = $this->_getWizard()->getStepByName('begin'))) { - $this->getResponse()->setRedirect($step->getNextUrl()); - } else { - $this->_redirect('install'); - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php b/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php index d3ee0fbc146..b7b19ccb7be 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php @@ -44,7 +44,7 @@ $productOne->setId( )->setAttributeSetId( 4 )->setWebsiteIds( - array($obectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId()) + array($obectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId()) )->setSku( 'simple_product_1' )->setName( @@ -85,7 +85,7 @@ $productTwo->setId( )->setAttributeSetId( 4 )->setWebsiteIds( - array($obectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getWebsiteId()) + array($obectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getWebsiteId()) )->setSku( 'simple_product_2' )->setName( diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 5e4747d7632..d58d379f966 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -764,7 +764,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $product->load($id); $this->assertEquals('1', $product->getHasOptions()); - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->setCurrentStore('fixturestore'); + $objectManager->get('Magento\Framework\StoreManagerInterface')->setCurrentStore('fixturestore'); /** @var \Magento\Catalog\Model\Product $simpleProduct */ $simpleProduct = $objectManager->create('Magento\Catalog\Model\Product'); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php index a519a4f0a5b..90444c6427f 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Helper/DataTest.php @@ -75,7 +75,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\CatalogSearch\Model\QueryFactory'), $objectManager->get('Magento\Framework\Escaper'), $objectManager->get('Magento\Framework\Filter\FilterManager'), - $objectManager->get('Magento\Store\Model\StoreManagerInterface') + $objectManager->get('Magento\Framework\StoreManagerInterface') ) ); $catalogSearchHelper->expects( diff --git a/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php b/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php index e32afba7425..bb76f02b78a 100644 --- a/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Centinel/CreateOrderTest.php @@ -53,7 +53,7 @@ class CreateOrderTest extends \Magento\Backend\Utility\Controller ); $quote = $order->addProducts(array(1 => array('qty' => 1)))->getQuote(); $defaultStoreId = $this->_objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'default' )->getId(); 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 7b3cc4b2839..5f3835fa99a 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -401,7 +401,8 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** Execute SUT */ $result = $this->_model->saveBilling($customerData, $customerAddressId); $validationErrors = array( - '"First Name" is a required value.' + '"First Name" is a required value.', + '"First Name" length must be equal or greater than 1 characters.' ); $this->assertEquals( array('error' => 1, 'message' => $validationErrors), @@ -513,7 +514,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** Execute SUT */ $result = $this->_model->saveBilling($customerData, $customerAddressId); - $validationErrors = 'Please correct this email address: "invalidemail".'; + $validationErrors = '"Email" is not a valid email address.'; $this->assertEquals( array('error' => -1, 'message' => $validationErrors), $result, diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php index 35d69af5375..60daa59df93 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent.php @@ -32,7 +32,7 @@ $data = array( 'is_active' => true, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getWebsiteId() ), 'customer_group_ids' => array(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID), diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php index abed80acca2..19250bb5ea0 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/RouterTest.php @@ -42,13 +42,12 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Event\ObserverFactory', array(), array(), '', false) ), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\UrlInterface'), - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\StateInterface'), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Cms\Model\PageFactory'), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ), \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ) ); } diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/block.php b/dev/tests/integration/testsuite/Magento/Cms/_files/block.php index 4bb701e9a24..ff51d31ef82 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/_files/block.php +++ b/dev/tests/integration/testsuite/Magento/Cms/_files/block.php @@ -39,7 +39,7 @@ $block->setTitle( )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php index 4a2493c24e7..f64a5ac189e 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php @@ -54,7 +54,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\DesignInterface' ); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); // fixture design_change $designChange = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( @@ -121,7 +121,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase ->create('Magento\Framework\Stdlib\DateTime'); $date = $dateTime->now(true); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); // fixture design_change @@ -184,7 +184,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase } $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $storeCode ); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php index 6036cfa367b..38255371ea4 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Layout/UpdateTest.php @@ -51,7 +51,7 @@ class UpdateTest extends \PHPUnit_Framework_TestCase 'test_handle', $theme, \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore() ); $this->assertEquals('not_temporary', $result); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php index 2e1ffc286c3..77409fe8521 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/View/DesignTest.php @@ -148,7 +148,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase public function testGetConfigurationDesignThemeStore() { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $this->assertEquals('one', $this->_model->getConfigurationDesignTheme()); $this->assertEquals('one', $this->_model->getConfigurationDesignTheme(null, array('store' => $storeId))); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php b/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php index c6bb5232569..482c141a72c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/design_change.php @@ -23,7 +23,7 @@ */ $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId(); /** @var $change \Magento\Core\Model\Design */ $change = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Design'); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php b/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php index f941c7799d6..ce6f9360d45 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/design_change_timezone.php @@ -32,7 +32,7 @@ $designChanges = array( ); foreach ($designChanges as $designChangeData) { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $designChangeData['store'] )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php index 4a3c0e3491f..a8ff0e3b33f 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php @@ -49,5 +49,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/store.php b/dev/tests/integration/testsuite/Magento/Core/_files/store.php index 77bcb314ef9..f9cc8d29b35 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/store.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/store.php @@ -24,10 +24,10 @@ $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); $websiteId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId(); $groupId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getDefaultGroupId(); $store->setCode( 'fixturestore' @@ -46,5 +46,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php index b4733b969f9..676fc880371 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php @@ -40,7 +40,7 @@ class CartTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Registry */ private $_coreRegistry; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** @var Cart */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php new file mode 100644 index 00000000000..6284845a4b6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php @@ -0,0 +1,276 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; +use Magento\Customer\Service\V1\Data\Customer; +use Magento\Customer\Service\V1\Data\CustomerBuilder; + +/** + * Magento\Customer\Block\Adminhtml\Edit\Tab\View + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @magentoAppArea adminhtml + */ +class PersonalInfoTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Backend\Block\Template\Context */ + private $_context; + + /** @var \Magento\Framework\Registry */ + private $_coreRegistry; + + /** @var CustomerBuilder */ + private $_customerBuilder; + + /** @var CustomerAccountServiceInterface */ + private $_customerAccountService; + + /** @var CustomerGroupServiceInterface */ + private $_groupService; + + /** @var \Magento\Framework\StoreManagerInterface */ + private $_storeManager; + + /** @var \Magento\Framework\ObjectManager */ + private $_objectManager; + + /** @var PersonalInfo */ + private $_block; + + /** + * @var \Magento\Framework\Stdlib\DateTime + */ + protected $dateTime; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->_storeManager = $this->_objectManager->get('Magento\Framework\StoreManagerInterface'); + $this->_context = $this->_objectManager->get( + 'Magento\Backend\Block\Template\Context', + array('storeManager' => $this->_storeManager) + ); + + $this->_customerBuilder = $this->_objectManager->get('Magento\Customer\Service\V1\Data\CustomerBuilder'); + $this->_coreRegistry = $this->_objectManager->get('Magento\Framework\Registry'); + $this->_customerAccountService = $this->_objectManager->get( + 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' + ); + $this->_groupService = $this->_objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); + $this->dateTime = $this->_objectManager->get('\Magento\Framework\Stdlib\DateTime'); + + $this->_block = $this->_objectManager->get( + 'Magento\Framework\View\LayoutInterface' + )->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo', + '', + array( + 'context' => $this->_context, + 'groupService' => $this->_groupService, + 'registry' => $this->_coreRegistry + ) + ); + } + + public function tearDown() + { + $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCustomer() + { + $this->assertEquals($this->_loadCustomer(), $this->_block->getCustomer()); + } + + public function testGetCustomerEmpty() + { + $this->assertEquals($this->_createCustomer(), $this->_block->getCustomer()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetGroupName() + { + $groupName = $this->_groupService->getGroup($this->_loadCustomer()->getGroupId())->getCode(); + $this->assertEquals($groupName, $this->_block->getGroupName()); + } + + public function testGetGroupNameNull() + { + $this->_createCustomer(); + $this->assertNull($this->_block->getGroupName()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCreateDate() + { + $createdAt = $this->_block->formatDate( + $this->_loadCustomer()->getCreatedAt(), + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + $this->assertEquals($createdAt, $this->_block->getCreateDate()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetStoreCreateDate() + { + $customer = $this->_loadCustomer(); + $date = $this->_context->getLocaleDate()->scopeDate( + $customer->getStoreId(), + $this->dateTime->toTimestamp($customer->getCreatedAt()), + true + ); + $storeCreateDate = $this->_block->formatDate( + $date, + \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + true + ); + $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetStoreCreateDateTimezone() + { + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface $defaultTimeZonePath + */ + $defaultTimeZonePath = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->getDefaultTimezonePath(); + $timezone = $this->_context->getScopeConfig()->getValue( + $defaultTimeZonePath, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->_loadCustomer()->getStoreId() + ); + $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testIsConfirmedStatusConfirmed() + { + $this->_loadCustomer(); + $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testIsConfirmedStatusConfirmationIsNotRequired() + { + /** @var Customer $customer */ + $customer = $this->_customerBuilder->setConfirmation( + true + )->setFirstname( + 'firstname' + )->setLastname( + 'lastname' + )->setEmail( + 'email@email.com' + )->create(); + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ + $customerDetailsBuilder = $objectManager->create('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); + $customerDetails = $customerDetailsBuilder->setCustomer($customer)->create(); + $customer = $this->_customerAccountService->createCustomer($customerDetails); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); + $this->assertEquals('Confirmation Not Required', $this->_block->getIsConfirmedStatus()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCreatedInStore() + { + $storeName = $this->_storeManager->getStore($this->_loadCustomer()->getStoreId())->getName(); + $this->assertEquals($storeName, $this->_block->getCreatedInStore()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testGetBillingAddressHtml() + { + $this->_loadCustomer(); + $html = $this->_block->getBillingAddressHtml(); + $this->assertContains('John Smith<br/>', $html); + $this->assertContains('Green str, 67<br />', $html); + $this->assertContains('CityM, Alabama, 75477<br/>', $html); + } + + public function testGetBillingAddressHtmlNoDefaultAddress() + { + $this->_createCustomer(); + $this->assertEquals( + __('The customer does not have default billing address.'), + $this->_block->getBillingAddressHtml() + ); + } + + /** + * @return Customer + */ + private function _createCustomer() + { + /** @var \Magento\Customer\Service\V1\Data\Customer $customer */ + $customer = $this->_customerBuilder->setFirstname( + 'firstname' + )->setLastname( + 'lastname' + )->setEmail( + 'email@email.com' + )->create(); + $data = array('account' => $customer->__toArray()); + $this->_context->getBackendSession()->setCustomerData($data); + return $customer; + } + + /** + * @return Customer + */ + private function _loadCustomer() + { + $customer = $this->_customerAccountService->getCustomer(1); + $data = array('account' => $customer->__toArray()); + $this->_context->getBackendSession()->setCustomerData($data); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); + return $customer; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php index d896b8a2093..befb58195da 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -49,10 +49,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase /** @var CustomerAccountServiceInterface */ private $_customerAccountService; - /** @var CustomerGroupServiceInterface */ - private $_groupService; - - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ private $_storeManager; /** @var \Magento\Framework\ObjectManager */ @@ -61,11 +58,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase /** @var View */ private $_block; - /** - * @var \Magento\Framework\Stdlib\DateTime - */ - protected $_dateTime; - public function setUp() { $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -81,7 +73,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->_customerAccountService = $this->_objectManager->get( 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' ); - $this->_groupService = $this->_objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->_block = $this->_objectManager->get( 'Magento\Framework\View\LayoutInterface' @@ -90,12 +81,9 @@ class ViewTest extends \PHPUnit_Framework_TestCase '', array( 'context' => $this->_context, - 'groupService' => $this->_groupService, 'registry' => $this->_coreRegistry ) ); - - $this->_dateTime = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime'); } public function tearDown() @@ -103,153 +91,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); } - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCustomer() - { - $this->assertEquals($this->_loadCustomer(), $this->_block->getCustomer()); - } - - public function testGetCustomerEmpty() - { - $this->assertEquals($this->_createCustomer(), $this->_block->getCustomer()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetGroupName() - { - $groupName = $this->_groupService->getGroup($this->_loadCustomer()->getGroupId())->getCode(); - $this->assertEquals($groupName, $this->_block->getGroupName()); - } - - public function testGetGroupNameNull() - { - $this->_createCustomer(); - $this->assertNull($this->_block->getGroupName()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCreateDate() - { - $createdAt = $this->_block->formatDate( - $this->_loadCustomer()->getCreatedAt(), - \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - $this->assertEquals($createdAt, $this->_block->getCreateDate()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreCreateDate() - { - $customer = $this->_loadCustomer(); - $date = $this->_context->getLocaleDate() - ->scopeDate($customer->getStoreId(), $this->_dateTime->toTimestamp($customer->getCreatedAt()), true); - $storeCreateDate = $this->_block->formatDate( - $date, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, - true - ); - $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreCreateDateTimezone() - { - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface $defaultTimeZonePath - */ - $defaultTimeZonePath = $this->_objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface') - ->getDefaultTimezonePath(); - $timezone = $this->_context->getScopeConfig()->getValue( - $defaultTimeZonePath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->_loadCustomer()->getStoreId() - ); - $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testIsConfirmedStatusConfirmed() - { - $this->_loadCustomer(); - $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus()); - } - - /** - * @magentoDbIsolation enabled - */ - public function testIsConfirmedStatusConfirmationIsNotRequired() - { - /** @var Customer $customer */ - $customer = $this->_customerBuilder->setConfirmation( - true - )->setFirstname( - 'firstname' - )->setLastname( - 'lastname' - )->setEmail( - 'email@email.com' - )->create(); - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ - $customerDetailsBuilder = $objectManager->create('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); - $customerDetails = $customerDetailsBuilder->setCustomer($customer)->create(); - $customer = $this->_customerAccountService->createCustomer($customerDetails); - $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId()); - $this->assertEquals('Confirmation Not Required', $this->_block->getIsConfirmedStatus()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetCreatedInStore() - { - $storeName = $this->_storeManager->getStore($this->_loadCustomer()->getStoreId())->getName(); - $this->assertEquals($storeName, $this->_block->getCreatedInStore()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testGetStoreId() - { - $this->assertEquals($this->_loadCustomer()->getStoreId(), $this->_block->getStoreId()); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testGetBillingAddressHtml() - { - $this->_loadCustomer(); - $html = $this->_block->getBillingAddressHtml(); - $this->assertContains('John Smith<br/>', $html); - $this->assertContains('Green str, 67<br />', $html); - $this->assertContains('CityM, Alabama, 75477<br/>', $html); - } - - public function testGetBillingAddressHtmlNoDefaultAddress() - { - $this->_createCustomer(); - $this->assertEquals( - __('The customer does not have default billing address.'), - $this->_block->getBillingAddressHtml() - ); - } - public function testGetTabLabel() { $this->assertEquals(__('Customer View'), $this->_block->getTabLabel()); diff --git a/dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php rename to dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php index 32a078a66c8..f7ec83eb8bd 100644 --- a/dev/tests/integration/testsuite/Magento/Log/Model/VisitorTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.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\Log\Model; +namespace Magento\Customer\Model; use Magento\TestFramework\Helper\Bootstrap; @@ -33,8 +33,8 @@ class VisitorTest extends \PHPUnit_Framework_TestCase */ public function testBindCustomerLogin() { - /** @var \Magento\Log\Model\Visitor $visitor */ - $visitor = Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor'); + /** @var \Magento\Customer\Model\Visitor $visitor */ + $visitor = Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor'); $visitor->unsCustomerId(); $visitor->unsDoCustomerLogin(); @@ -56,8 +56,8 @@ class VisitorTest extends \PHPUnit_Framework_TestCase */ public function testBindCustomerLogout() { - /** @var \Magento\Log\Model\Visitor $visitor */ - $visitor = Bootstrap::getObjectManager()->get('Magento\Log\Model\Visitor'); + /** @var \Magento\Customer\Model\Visitor $visitor */ + $visitor = Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor'); $this->_loginCustomer('customer@example.com', 'password'); $visitor->setCustomerId(1); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 59ee976b74a..328bfeb7f02 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -1502,8 +1502,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase */ public function getValidEmailDataProvider() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $defaultWebsiteId = $storeManager->getStore()->getWebsiteId(); return [ 'valid email' => ['customer@example.com', null], diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php index 90053a700c3..572f8770bf1 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerGroupServiceTest.php @@ -194,8 +194,8 @@ class CustomerGroupServiceTest extends \PHPUnit_Framework_TestCase */ public function getDefaultGroupDataProvider() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $defaultStoreId = $storeManager->getStore()->getId(); return [ 'no store id' => [['id' => 1, 'code' => 'General', 'tax_class_id' => 3], null], @@ -207,8 +207,8 @@ class CustomerGroupServiceTest extends \PHPUnit_Framework_TestCase * @magentoDataFixture Magento/Core/_files/second_third_store.php */ public function testGetDefaultGroupWithNonDefaultStoreId() - { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); + { /** @var \Magento\Framework\StoreManagerInterface $storeManager */ + $storeManager = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface'); $nonDefaultStore = $storeManager->getStore('secondstore'); $nonDefaultStoreId = $nonDefaultStore->getId(); /** @var \Magento\Framework\App\MutableScopeConfig $scopeConfig */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php new file mode 100644 index 00000000000..023157234cd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_rollback.php @@ -0,0 +1,26 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model->load('address_user_attribute', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php index 420b91aeb30..f62f77505a2 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php @@ -44,6 +44,8 @@ $model->setName( 'text' )->setFrontendLabel( FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL +)->setSortOrder( + 1221 ); $model->save(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php new file mode 100644 index 00000000000..c3c1f261dca --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer_rollback.php @@ -0,0 +1,26 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +$model =\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); +$model->load('user_attribute', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php index 503e61b801d..d9906b263cc 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php @@ -57,7 +57,7 @@ $quoteItem = $quote->setCustomerId( 1 )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php index c4e5f27ade9..94544885068 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/AddressTest.php @@ -51,7 +51,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase ); $websites = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsites( true ); diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php index 6db81937cd7..8713392f0e8 100644 --- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php +++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php @@ -200,7 +200,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase 'email' => 'example.com', 'created_at' => array($createdAtDate, ''), 'store_id' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) ); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index ba9abad6090..57e9706eeac 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -83,7 +83,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $this->assertSame($filter, $this->_model->getTemplateFilter()); $this->assertEquals( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(), $filter->getStoreId() ); @@ -124,7 +124,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase array( 'area' => 'frontend', 'store' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId() @@ -190,7 +190,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase array( 'area' => 'frontend', 'store' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId() @@ -230,7 +230,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase public function setDesignConfigExceptionDataProvider() { $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + ->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); return array( array(array()), array(array('area' => 'frontend')), diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php index e797f4ca93d..f3a996c6b96 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/App/FilesystemTest.php @@ -25,8 +25,6 @@ */ namespace Magento\Framework\App; -use Magento\TestFramework\Helper\Bootstrap; - /** * Class FilesystemTest * Test for Magento\Framework\App\Filesystem class @@ -41,7 +39,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystem = Bootstrap::getObjectManager()->create('Magento\Framework\App\Filesystem'); + $this->filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Framework\App\Filesystem'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.php deleted file mode 100644 index d060656055f..00000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/App/FrontController/Plugin/InstallTest.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\Framework\App\FrontController\Plugin; - -class InstallTest extends \Magento\TestFramework\TestCase\AbstractController -{ - /** - * @var \Magento\Framework\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Framework\Module\Setup - */ - protected $_model; - - protected function setUp() - { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\Setup', - array('resourceName' => 'default_setup', 'moduleName' => 'Magento_Core') - ); - } - - public function testApplyAllDataUpdates() - { - /*reset versions*/ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\ResourceInterface' - )->setDbVersion( - 'adminnotification_setup', - false - ); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Module\ResourceInterface' - )->setDataVersion( - 'adminnotification_setup', - false - ); - $this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup'); - $this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox')); - $this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages')); - /** @var \Magento\Framework\Cache\FrontendInterface $cache */ - $cache = $this->_objectManager->get('Magento\Framework\App\Cache\Type\Config'); - $cache->clean(); - - try { - /* This triggers plugin to be executed */ - $this->dispatch('index/index'); - } catch (\Exception $e) { - $this->fail("Impossible to continue other tests, because database is broken: {$e}"); - } - - try { - $tableData = $this->_model->getConnection()->describeTable( - $this->_model->getTable('adminnotification_inbox') - ); - $this->assertNotEmpty($tableData); - } catch (\Exception $e) { - $this->fail("Impossible to continue other tests, because database is broken: {$e}"); - } - - $this->assertNotEmpty( - $this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version') - ); - $this->assertNotEmpty( - $this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version') - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php new file mode 100644 index 00000000000..e95a00a5f96 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.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\Framework\Module\Plugin; + +class DbStatusValidatorTest extends \Magento\TestFramework\TestCase\AbstractController +{ + public function testValidationUpToDateDb() + { + $this->dispatch('index/index'); + } + + public function testValidationOutdatedDb() + { + $resourceName = 'adminnotification_setup'; + /*reset versions*/ + /** @var \Magento\Framework\Module\ResourceInterface $resource */ + $resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Framework\Module\ResourceInterface' + ); + $dbVersion = $resource->getDbVersion($resourceName); + $dbDataVersion = $resource->getDataVersion($resourceName); + try { + $resource->setDbVersion($resourceName, '0.1'); + $resource->setDataVersion($resourceName, '0.1'); + /** @var \Magento\Framework\Cache\FrontendInterface $cache */ + $cache = $this->_objectManager->get('Magento\Framework\App\Cache\Type\Config'); + $cache->clean(); + + try { + /* This triggers plugin to be executed */ + $this->dispatch('index/index'); + } catch (\Magento\Framework\Module\Exception $e) { + if ($e->getMessage() != 'Looks like database is outdated. Please, use setup tool to perform update') { + $failureMessage = "DB status validation doesn't work properly. Caught exception message is '" + . $e->getMessage() ."'"; + } + } + } catch (\Exception $e) { + $failureMessage = "Impossible to continue other tests, because database is broken: {$e}"; + } + + $resource->setDbVersion($resourceName, $dbVersion); + $resource->setDataVersion($resourceName, $dbDataVersion); + + if (isset($failureMessage)) { + $this->fail($failureMessage); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml index e3a7e38e9d5..5917a1bee53 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_merged.xml @@ -23,9 +23,9 @@ * @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\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\UpdaterOne" /> - <preference for="Magento\Framework\Module\UpdaterInterfaceTwo" type="Magento\Framework\Module\UpdaterTwo"/> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> + <preference for="Magento\Framework\Module\SomeInterfaceTwo" type="Magento\Framework\Module\ClassTwo" /> <type name="Magento\Framework\App\Arguments\Loader" shared="false"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml index a838cf28783..944d99020e0 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_one.xml @@ -23,8 +23,8 @@ * @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\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updater" /> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> <type name="Magento\Framework\App\Arguments\Loader"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml index ce4dd60f272..bf599564574 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/ObjectManager/_files/config_two.xml @@ -23,9 +23,9 @@ * @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\Framework\Module\UpdaterInterfaceTwo" type="Magento\Framework\Module\UpdaterTwo" /> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\UpdaterOne" /> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> + <preference for="Magento\Framework\Module\SomeInterfaceTwo" type="Magento\Framework\Module\ClassTwo" /> <type name="Magento\Framework\App\Arguments\Loader" shared="false"> <arguments> <argument name="customFile" xsi:type="init_parameter">Magento\Framework\App\Arguments\Loader::PARAM_CUSTOM_FILE</argument> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php new file mode 100644 index 00000000000..7c63a2eb0c4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php @@ -0,0 +1,324 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\Bootstrap; + +class AdapterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Adapter + */ + private $adapter; + + /** + * @var \Magento\Framework\Search\RequestFactory + */ + private $requestFactory; + + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Framework\Search\Request\Config\Converter $converter */ + $converter = $this->objectManager->create('Magento\Framework\Search\Request\Config\Converter'); + + $document = new \DOMDocument(); + $document->load(__DIR__ . '/../../_files/requests.xml'); + $requestConfig = $converter->convert($document); + + /** @var \Magento\Framework\Search\Request\Config $config */ + $config = $this->objectManager->create('Magento\Framework\Search\Request\Config'); + $config->merge($requestConfig); + + /** @var \Magento\Framework\Search\RequestFactory $requestFactory */ + $this->requestFactory = $this->objectManager->create( + 'Magento\Framework\Search\RequestFactory', + ['config' => $config] + ); + + $this->adapter = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\Adapter'); + } + + /** + * Sample test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testMatchQuery() + { + $bindValues = [ + '%request.title%' => 'socks', + ]; + $requestName = 'one_match'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + } + + /** + * Sample test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testMatchQueryFilters() + { + $bindValues = [ + '%request.title%' => 'socks', + '%pidm_from%' => 1, + '%pidm_to%' => 3, + '%pidsh%' => 4 + ]; + $requestName = 'one_match_filters'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithAllFields() + { + $bindValues = [ + '%request.product_id.from%' => 1, + '%request.product_id.to%' => 3, + ]; + $requestName = 'range_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(2, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithoutFromField() + { + $bindValues = [ + '%request.product_id.to%' => 4, + ]; + $requestName = 'range_filter_without_from_field'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(3, $queryResponse->count()); + } + + /** + * Range filter test with all fields filled + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testRangeFilterWithoutToField() + { + $bindValues = [ + '%request.product_id.from%' => 2, + ]; + $requestName = 'range_filter_without_to_field'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(4, $queryResponse->count()); + } + + /** + * Term filter test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testTermFilter() + { + $id = 4; + + $bindValues = [ + '%request.product_id%' => $id, + ]; + $requestName = 'term_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(1, $queryResponse->count()); + $this->assertEquals($id, $queryResponse->getIterator()->offsetGet(0)->getId()); + } + + /** + * Bool filter test + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testBoolFilter() + { + /* + * TODO: Remove test skipping after fixing issue + */ + $this->markTestSkipped('Bool filter doesn\'t work correctly and we have issue in bug tracker'); + $expectedIds = [2, 3]; + $bindValues = [ + '%request.must.range_filter1.from%' => 1, + '%request.must.range_filter1.to%' => 5, + '%request.should.term_filter1%' => 1, + '%request.should.term_filter2%' => 2, + '%request.should.term_filter3%' => 3, + '%request.should.term_filter4%' => 4, + '%request.not.term_filter1%' => 1, + '%request.not.term_filter2%' => 4, + ]; + $requestName = 'bool_filter'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals(count($expectedIds), $queryResponse->count()); + $actualIds = []; + foreach ($queryResponse as $document) { + /** @var \Magento\Framework\Search\Document $document */ + $actualIds[] = $document->getId(); + } + $this->assertEquals($expectedIds, $actualIds); + } + + /** + * Sample Advanced search request test + * + * @dataProvider advancedSearchDataProvider + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/search/engine Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @magentoConfigFixture current_store catalog/search/search_type 2 + * @magentoDataFixture Magento/Framework/Search/_files/products.php + */ + public function testSimpleAdvancedSearch($bindValues, $expectedRecorsCount) + { + $requestName = 'advanced_search_test'; + + $queryResponse = $this->executeQuery($requestName, $bindValues); + $this->assertEquals($expectedRecorsCount, $queryResponse->count()); + } + + /** + * @return array + */ + public function advancedSearchDataProvider() + { + return array( + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '3', + '%request.to_product_id%' => '4', + ], + 0 // Record is not in filter range + ], + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '4', + ], + 1 // One record is expected + ], + [ + [ + '%request.name%' => 'white', + '%request.description%' => 'shorts', + '%request.store_id%' => '5', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '4', + ], + 0 // store_id filter is invalid + ], + [ + [ + '%request.name%' => 'black', + '%request.description%' => 'tshirts', + '%request.store_id%' => '1', + '%request.from_product_id%' => '1', + '%request.to_product_id%' => '5', + ], + 0 // Non existing search terms + ], + ); + } + + private function executeQuery($requestName, $bindValues) + { + $this->reindexAll(); + + /** @var \Magento\Framework\Search\Request $queryRequest */ + $queryRequest = $this->requestFactory->create($requestName, $bindValues); + + $queryResponse = $this->adapter->query($queryRequest); + + return $queryResponse; + } + + private function reindexAll() + { + /** @var \Magento\Indexer\Model\Indexer[] $indexerList */ + $indexerList = $this->objectManager->get('\Magento\Indexer\Model\Indexer\CollectionFactory') + ->create() + ->getItems(); + + foreach ($indexerList as $indexer) { + $indexer->reindexAll(); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php new file mode 100644 index 00000000000..30bb7fa1d3f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.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\Search\Adapter\Mysql\Builder\Query; + +use Magento\Framework\App\Resource\Config; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\TestFramework\Helper\Bootstrap; + +class MatchTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + } + + public function testBuildQuery() + { + $expectedSql = "SELECT `table`.* FROM `table` WHERE (MATCH (with_boost) AGAINST ('-wb' IN BOOLEAN MODE)) " . + "AND (MATCH (without_boost) AGAINST ('-wob' IN BOOLEAN MODE))"; + + /** @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $scoreBuilder */ + $scoreBuilder = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder'); + /** @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match $match */ + $match = $this->objectManager->create('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match'); + /** @var \Magento\Framework\Search\Request\Query\Match $query */ + $query = $this->objectManager->create( + 'Magento\Framework\Search\Request\Query\Match', + [ + 'name' => 'Match query', + 'boost' => 3.14, + 'matches' => [ + ['field' => 'with_boost', 'value' => 'wb', 'boost' => 2.15], + ['field' => 'without_boost', 'value' => 'wob'] + ] + ] + ); + /** @var \Magento\Framework\App\Resource $resource */ + $resource = $this->objectManager->create('Magento\Framework\App\Resource'); + /** @var \Magento\Framework\DB\Select $select */ + $select = $resource->getConnection(Config::DEFAULT_SETUP_CONNECTION)->select(); + $select->from('table'); + + $resultSelect = $match->build($scoreBuilder, $select, $query, Bool::QUERY_CONDITION_NOT); + $this->assertEquals($expectedSql, $resultSelect->assemble()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php index cbea9989331..836b89dbfd1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/Config/ConverterTest.php @@ -40,6 +40,8 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $document->load(__DIR__ . '../../../_files/search_request.xml'); $result = $this->object->convert($document); $expected = include __DIR__ . '/../../_files/search_request_config.php'; + sort($expected); + sort($result); $this->assertEquals($expected, $result); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php index eb75216b091..7cd6139834c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/Request/MapperTest.php @@ -42,7 +42,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase 'queries' => $request['queries'], 'rootQueryName' => 'suggested_search_container', 'filters' => $request['filters'], - 'aggregation' => $request['aggregation'], + 'aggregations' => $request['aggregations'], ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php new file mode 100644 index 00000000000..00802d2848e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/products.php @@ -0,0 +1,345 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (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 $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Green socks') + ->setSku('green_socks') + ->setPrice(10) + ->setWeight(1) + ->setShortDescription("Unisex green socks for some good peoples") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Unisex <b>green socks</b> for some good peoples') + ->setMetaTitle('green socks metadata') + ->setMetaKeyword('green,socks,unisex') + ->setMetaDescription('green socks metadata description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 1, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Stone', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'stone-1', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(2) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('White shorts') + ->setSku('white_shorts') + ->setPrice(12) + ->setWeight(2) + ->setShortDescription("Small white shorts for your children") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Small <b>white shorts</b> for your children') + ->setMetaTitle('white shorts for your children metadata') + ->setMetaKeyword('white,shorts,children') + ->setMetaDescription('white shorts for your children metadata description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 2, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Gold', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'Gold', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(3) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Red trousers') + ->setSku('red_trousers') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Red pants for men") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Red pants for <b>men</b>') + ->setMetaTitle('Red trousers meta title') + ->setMetaKeyword('red,trousers,meta,men') + ->setMetaDescription('Red trousers meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->setCanSaveCustomOptions(true) + ->setProductOptions( + array( + array( + 'id' => 3, + 'option_id' => 0, + 'previous_group' => 'text', + 'title' => 'Silver', + 'type' => 'field', + 'is_require' => 1, + 'sort_order' => 0, + 'price' => 1, + 'price_type' => 'fixed', + 'sku' => 'silver', + 'max_characters' => 100 + ) + ) + ) + ->setHasOptions(true) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(4) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Blue briefs') + ->setSku('blue_briefs') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Blue briefs for Russian men") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Blue briefs for <b>men</b>') + ->setMetaTitle('Blue briefs meta title') + ->setMetaKeyword('blue,briefs,meta,men') + ->setMetaDescription('Blue briefs meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Catalog\Model\Product'); +$product->isObjectNew(true); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE) + ->setId(5) + ->setAttributeSetId(4) + ->setWebsiteIds(array(1)) + ->setName('Grey shorts') + ->setSku('grey_shorts') + ->setPrice(14) + ->setWeight(3) + ->setShortDescription("Grey shorts for all peoples") + ->setTaxClassId(0) + ->setTierPrice( + array( + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 2, + 'price' => 8, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::CUST_GROUP_ALL, + 'price_qty' => 5, + 'price' => 5, + ), + array( + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, + 'price_qty' => 3, + 'price' => 5, + ), + ) + ) + ->setDescription('Grey shorts for <b>peoples</b>') + ->setMetaTitle('Grey shorts meta title') + ->setMetaKeyword('grey,shorts,meta,men') + ->setMetaDescription('Grey shorts meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setCategoryIds(array(2)) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 1, + ) + ) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml new file mode 100644 index 00000000000..24391d4c77f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/requests.xml @@ -0,0 +1,223 @@ +<?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="one_match" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="one_match" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + </query> + + <query xsi:type="matchQuery" name="fulltext_search_query" boost="5"> + <match field="data_index" value="%request.title%" boost="2" /> + </query> + </queries> + <from>10</from> + <size>10</size> + </request> + <request query="one_match_filters" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="one_match_filters" boost="2"> + <queryReference clause="must" ref="fulltext_search_query" /> + <queryReference clause="must" ref="fulltext_search_query2" /> + </query> + + <query xsi:type="matchQuery" name="fulltext_search_query" boost="5"> + <match field="data_index" value="%request.title%" boost="2" /> + </query> + + <query xsi:type="filteredQuery" name="fulltext_search_query2"> + <filterReference ref="pid" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="pid"> + <filterReference clause="should" ref="pidm" /> + <filterReference clause="should" ref="pidsh" /> + </filter> + <filter name="pidm" xsi:type="rangeFilter" field="product_id" from="%pidm_from%" to="%pidm_to%" /> + <filter name="pidsh" xsi:type="termFilter" field="product_id" value="%pidsh%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter"> + <filterReference ref="range_filter" /> + </query> + </queries> + <filters> + <filter name="range_filter" + xsi:type="rangeFilter" + field="product_id" + from="%request.product_id.from%" + to="%request.product_id.to%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter_without_from_field" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter_without_from_field"> + <filterReference ref="range_filter_without_from_field" /> + </query> + </queries> + <filters> + <filter name="range_filter_without_from_field" + xsi:type="rangeFilter" + field="product_id" + to="%request.product_id.to%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="range_filter_without_to_field" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="range_filter_without_to_field"> + <filterReference ref="range_filter_without_to_field" /> + </query> + </queries> + <filters> + <filter name="range_filter_without_to_field" + xsi:type="rangeFilter" + field="product_id" + from="%request.product_id.from%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="term_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="term_filter"> + <filterReference ref="term_filter" /> + </query> + </queries> + <filters> + <filter name="term_filter" xsi:type="termFilter" field="product_id" value="%request.product_id%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="bool_filter" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="filteredQuery" name="bool_filter"> + <filterReference ref="bool_filter" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="bool_filter"> + <filterReference clause="must" ref="must_range_filter1" /> + <filterReference clause="should" ref="should_term_filter1" /> + <filterReference clause="should" ref="should_term_filter2" /> + <filterReference clause="not" ref="not_term_filter1" /> + <filterReference clause="not" ref="not_term_filter2" /> + </filter> + <filter name="must_range_filter1" + xsi:type="rangeFilter" + field="product_id" + from="%request.must.range_filter1.from%" + to="%request.must.range_filter1.to%" /> + <filter name="should_term_filter1" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter1%" /> + <filter name="should_term_filter2" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter2%" /> + <filter name="should_term_filter3" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter3%" /> + <filter name="should_term_filter4" + xsi:type="termFilter" + field="product_id" + value="%request.should.term_filter4%" /> + <filter name="not_term_filter1" + xsi:type="termFilter" + field="product_id" + value="%request.not.term_filter1%" /> + <filter name="not_term_filter2" + xsi:type="termFilter" + field="product_id" + value="%request.not.term_filter2%" /> + </filters> + <from>10</from> + <size>10</size> + </request> + <request query="advanced_search_test" index="catalogsearch_fulltext"> + <dimensions> + <dimension name="scope" value="default" /> + </dimensions> + <queries> + <query xsi:type="boolQuery" name="advanced_search_test" boost="1"> + <queryReference clause="should" ref="name_query" /> + <queryReference clause="should" ref="description_query" /> + <queryReference clause="should" ref="query_filter" /> + </query> + <query xsi:type="matchQuery" name="name_query"> + <match field="data_index" value="%request.name%" boost="1" /> + </query> + <query xsi:type="matchQuery" name="description_query"> + <match field="data_index" value="%request.description%" boost="1" /> + </query> + <query xsi:type="filteredQuery" name="query_filter"> + <filterReference ref="filter" /> + </query> + </queries> + <filters> + <filter xsi:type="boolFilter" name="filter"> + <filterReference clause="must" ref="store_filter" /> + <filterReference clause="must" ref="product_id_filter" /> + </filter> + <filter name="store_filter" xsi:type="termFilter" field="store_id" value="%request.store_id%" /> + <filter name="product_id_filter" xsi:type="rangeFilter" field="product_id" from="%request.from_product_id%" to="%request.to_product_id%" /> + </filters> + <from>10</from> + <size>10</size> + </request> +</requests> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml index c5b97e2e6e6..7d7125a42d5 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request.xml @@ -51,7 +51,7 @@ <filter xsi:type="rangeFilter" field="promoted_boost" name="price_name" from="10" to="100" /> <filter xsi:type="termFilter" name="price_name1" field="price_name" value="$name" /> </filters> - <aggregation> + <aggregations> <bucket xsi:type="termBucket" name="category_bucket" field="category"> <metrics> <metric type="sum" /> @@ -73,7 +73,7 @@ <range from="100" to=""/> </ranges> </bucket> - </aggregation> + </aggregations> <from>10</from> <size>10</size> </request> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php index 84066fed20a..06a33a142c9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/search_request_config.php @@ -100,7 +100,7 @@ return [ "type" => "termFilter" ] ], - "aggregation" => [ + "aggregations" => [ "category_bucket" => [ "name" => "category_bucket", "field" => "category", @@ -159,4 +159,4 @@ return [ "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 562b23072a9..8299a35ba92 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -35,9 +35,17 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase */ protected $_sidResolver; + /** + * @var string + */ + protected $sessionName; + protected function setUp() { + $this->sessionName = 'frontEndSession'; + ini_set('session.use_only_cookies', '0'); + ini_set('session.name', $this->sessionName); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -58,6 +66,13 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase ); } + public function testSessionNameFromIni() + { + $this->_model->start(); + $this->assertSame($this->sessionName, $this->_model->getName()); + $this->_model->destroy(); + } + public function testSessionUseOnlyCookies() { $expectedValue = '1'; @@ -129,7 +144,7 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase public function testGetSessionIdForHost() { $_SERVER['HTTP_HOST'] = 'localhost'; - $this->_model->start('test'); + $this->_model->start(); $this->assertEmpty($this->_model->getSessionIdForHost('localhost')); $this->assertNotEmpty($this->_model->getSessionIdForHost('test')); $this->_model->destroy(); @@ -138,7 +153,7 @@ class SessionManagerTest extends \PHPUnit_Framework_TestCase public function testIsValidForHost() { $_SERVER['HTTP_HOST'] = 'localhost'; - $this->_model->start('test'); + $this->_model->start(); $reflection = new \ReflectionMethod($this->_model, '_addHost'); $reflection->setAccessible(true); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php index aa72cde5eec..409158bb2cd 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -46,9 +46,18 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase public function testGetSensitiveCookieMetadataEmpty() { + $serverVal = $_SERVER; + $_SERVER['HTTPS'] = 'on'; $cookieScope = $this->createCookieScope(); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray()); + + $_SERVER = $serverVal; } public function testGetPublicCookieMetadataEmpty() @@ -72,7 +81,15 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase 'cookieMetadata' => null ] ); - $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => false, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); } public function testGetPublicCookieMetadataDefaults() @@ -126,7 +143,14 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase ] ); $override = $this->createSensitiveMetadata($overrideValues); - $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => false, + ], + $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); } public function testGetPublicCookieMetadataOverrides() diff --git a/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php index 31e02a8a856..b15f4a5661a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Translate/InlineTest.php @@ -61,7 +61,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase ); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId )->getConfig( @@ -84,7 +84,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertTrue( $this->_model->isAllowed( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId ) @@ -96,7 +96,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertFalse( $this->_model->isAllowed( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId ) diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php index f22f6966426..c35734a149a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php @@ -82,7 +82,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase 'Magento\Core\Model\View\Design', array('getDesignTheme'), array( - $objectManager->get('Magento\Store\Model\StoreManagerInterface'), + $objectManager->get('Magento\Framework\StoreManagerInterface'), $objectManager->get('Magento\Framework\View\Design\Theme\FlyweightFactory'), $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface'), $objectManager->get('Magento\Core\Model\ThemeFactory'), diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php index 6d2759d7418..d87651088ab 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php @@ -31,7 +31,7 @@ abstract class AbstractStubEntity extends \Magento\ImportExport\Model\Export\Abs { public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php index 083a641ff8f..702c2162c0d 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php @@ -125,7 +125,7 @@ abstract class Stub_Magento_ImportExport_Model_Export_AbstractEntity { public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() diff --git a/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php b/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php deleted file mode 100644 index 99ab68df055..00000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Controller/WizardTest.php +++ /dev/null @@ -1,69 +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\Install\Controller; - -class WizardTest extends \Magento\TestFramework\TestCase\AbstractController -{ - /** - * @var string - */ - protected static $_tmpDir; - - /** - * @var array - */ - protected static $_params = array(); - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - $varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - $tmpDir = 'WizardTest'; - $varDirectory->delete($tmpDir); - // deliberately create a file instead of directory to emulate broken access to static directory - $varDirectory->touch($tmpDir); - - self::$_tmpDir = $varDirectory->getAbsolutePath($tmpDir); - } - - public function testPreDispatch() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure( - array( - 'preferences' => array( - 'Magento\Framework\App\RequestInterface' => 'Magento\TestFramework\Request', - 'Magento\Framework\App\Response\Http' => 'Magento\TestFramework\Response' - ) - ) - ); - /** @var $appState \Magento\Framework\App\State */ - $appState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\State'); - $appState->setInstallDate(false); - $this->dispatch('install/wizard'); - $this->assertEquals(302, $this->getResponse()->getHttpResponseCode()); - $appState->setInstallDate(date('r', strtotime('now'))); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.php deleted file mode 100644 index bb712f651c9..00000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Model/Installer/ConfigTest.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\Install\Model\Installer; - -class ConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected static $_tmpDir = ''; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write - */ - protected static $_varDirectory; - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - self::$_tmpDir = self::$_varDirectory->getAbsolutePath('ConfigTest'); - self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public static function tearDownAfterClass() - { - self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public function testInstall() - { - file_put_contents(self::$_tmpDir . '/local.xml.template', "test; {{date}}; {{base_url}}; {{unknown}}"); - $expectedFile = self::$_tmpDir . '/local.xml'; - - $request = $this->getMock('Magento\Framework\App\Request\Http', array('getDistroBaseUrl'), array(), '', false); - - $request->expects($this->once())->method('getDistroBaseUrl')->will($this->returnValue('http://example.com/')); - $expectedContents = "test; <![CDATA[d-d-d-d-d]]>; <![CDATA[http://example.com/]]>; {{unknown}}"; - - $this->assertFileNotExists($expectedFile); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryList = $objectManager->create( - 'Magento\Framework\App\Filesystem\DirectoryList', - array( - 'root' => self::$_tmpDir, - 'directories' => array(\Magento\Framework\App\Filesystem::CONFIG_DIR => array('path' => self::$_tmpDir)) - ) - ); - $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList\Configuration')->configure($directoryList); - $filesystem = $objectManager->create( - 'Magento\Framework\App\Filesystem', - array('directoryList' => $directoryList) - ); - $model = $objectManager->create( - 'Magento\Install\Model\Installer\Config', - array('request' => $request, 'filesystem' => $filesystem) - ); - - $model->install(); - $this->assertFileExists($expectedFile); - $this->assertStringEqualsFile($expectedFile, $expectedContents); - } - - public function testGetFormData() - { - /** @var $model \Magento\Install\Model\Installer\Config */ - $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Install\Model\Installer\Config' - ); - /** @var $result \Magento\Framework\Object */ - $result = $model->getFormData(); - $this->assertInstanceOf('Magento\Framework\Object', $result); - $data = $result->getData(); - $this->assertArrayHasKey('db_host', $data); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php deleted file mode 100644 index 854aff32a16..00000000000 --- a/dev/tests/integration/testsuite/Magento/Install/Model/InstallerTest.php +++ /dev/null @@ -1,233 +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\Install\Model; - -class InstallerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected static $_tmpDir = ''; - - /** - * @var string - */ - protected static $_tmpConfigFile = ''; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write - */ - protected static $_varDirectory; - - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\App\Filesystem $filesystem */ - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Filesystem'); - self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); - self::$_tmpDir = self::$_varDirectory->getAbsolutePath('InstallerTest'); - self::$_tmpConfigFile = self::$_tmpDir . '/local.xml'; - self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - public static function tearDownAfterClass() - { - self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir)); - } - - /** - * Emulate configuration directory for the installer config model. - * Method usage should be accompanied with '@magentoAppIsolation enabled' because of the object manager pollution. - * - * @param bool $emulateConfig - * @return \Magento\Install\Model\Installer - */ - protected function _getModel($emulateConfig = false) - { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryList = $objectManager->create( - 'Magento\Framework\App\Filesystem\DirectoryList', - array( - 'root' => __DIR__, - 'directories' => array(\Magento\Framework\App\Filesystem::CONFIG_DIR => array('path' => self::$_tmpDir)) - ) - ); - $objectManager->get('\Magento\Framework\App\Filesystem\DirectoryList\Configuration')->configure($directoryList); - $filesystem = $objectManager->create( - 'Magento\Framework\App\Filesystem', - array('directoryList' => $directoryList) - ); - - if ($emulateConfig) { - $installerConfig = new \Magento\Install\Model\Installer\Config( - $objectManager->get('Magento\Install\Model\Installer'), - $objectManager->get('Magento\Framework\App\RequestInterface'), - $filesystem, - $objectManager->get('Magento\Store\Model\StoreManager'), - $objectManager->get('Magento\Framework\Message\Manager') - ); - $objectManager->addSharedInstance($installerConfig, 'Magento\Install\Model\Installer\Config'); - } - return $objectManager->create('Magento\Install\Model\Installer'); - } - - /** - * @magentoDbIsolation enabled - * @magentoAppArea install - */ - public function testCreateAdministrator() - { - $userName = 'installer_test'; - $userPassword = '123123q'; - $userData = array( - 'username' => $userName, - 'firstname' => 'First Name', - 'lastname' => 'Last Name', - 'email' => 'installer_test@example.com' - ); - - /** @var $user \Magento\User\Model\User */ - $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\User\Model\User'); - $user->loadByUsername($userName); - $this->assertEmpty($user->getId()); - - $this->_getModel()->createAdministrator($userData + array('password' => $userPassword)); - - $user->loadByUsername($userName); - $this->assertNotEmpty($user->getId()); - $this->assertEquals($userData, array_intersect_assoc($user->getData(), $userData)); - $this->assertNotEmpty($user->getPassword(), 'Password hash is expected to be loaded.'); - $this->assertNotEquals( - $userPassword, - $user->getPassword(), - 'Original password should not be stored/loaded as is for security reasons.' - ); - $this->assertInstanceOf('Magento\Authorization\Model\Role', $user->getRole()); - $this->assertEquals(1, $user->getRole()->getId(), 'User has to have admin privileges.'); - } - - /** - * @magentoAppIsolation enabled - */ - public function testInstallEncryptionKey() - { - $keyPlaceholder = \Magento\Install\Model\Installer\Config::TMP_ENCRYPT_KEY_VALUE; - $fixtureConfigData = "<key>{$keyPlaceholder}</key>"; - $expectedConfigData = '<key>d41d8cd98f00b204e9800998ecf8427e</key>'; - - file_put_contents(self::$_tmpConfigFile, $fixtureConfigData); - $this->assertEquals($fixtureConfigData, file_get_contents(self::$_tmpConfigFile)); - $this->_getModel(true)->installEncryptionKey('d41d8cd98f00b204e9800998ecf8427e'); - $this->assertEquals($expectedConfigData, file_get_contents(self::$_tmpConfigFile)); - } - - /** - * @magentoAppIsolation enabled - * @expectedException \Magento\Framework\Exception - * @expectedExceptionMessage Key must not exceed - */ - public function testInstallEncryptionKeySizeViolation() - { - $this->_getModel(true)->installEncryptionKey(str_repeat('a', 57)); - } - - /** - * @magentoAppIsolation enabled - */ - public function testGetValidEncryptionKey() - { - $validKey = 'abcdef1234567890'; - $this->assertEquals($validKey, $this->_getModel()->getValidEncryptionKey($validKey)); - } - - /** - * @magentoAppIsolation enabled - * @expectedException \Magento\Framework\Exception - * @expectedExceptionMessage Key must not exceed - */ - public function testGetValidEncryptionKeySizeViolation() - { - $this->_getModel()->getValidEncryptionKey(str_repeat('1', 57)); - } - - /** - * @magentoAppIsolation enabled - */ - public function testGetValidEncryptionKeyRandom() - { - $model = $this->_getModel(); - $actualKey = $model->getValidEncryptionKey(); - $this->assertRegExp('/^[a-f0-9]{32}$/', $actualKey); - $this->assertNotEquals($actualKey, $model->getValidEncryptionKey()); - } - - /** - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Backend/controllers/_files/cache/all_types_disabled.php - */ - public function testFinish() - { - $configFile = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInstallDir() . '/etc/local.xml'; - copy($configFile, self::$_tmpConfigFile); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - /** - * @var $cache \Magento\Framework\App\Cache - */ - $cache = $objectManager->create('Magento\Framework\App\Cache'); - /** - * @var $appState \Magento\Framework\App\State - */ - $appState = $objectManager->get('Magento\Framework\App\State'); - - $cache->save('testValue', 'testName'); - $this->assertEquals('testValue', $cache->load('testName')); - - //to test it works - set state to uninstalled - $appState->setInstallDate(null); - $this->assertFalse($appState->isInstalled()); - - $this->_getModel(true)->finish(); - - $this->assertFalse($cache->load('testName'), 'Cache was not cleaned'); - $this->assertTrue( - $appState->isInstalled(), - 'In-memory application installation state was not changed right after finishing installation phase' - ); - - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = $objectManager->create('Magento\Framework\App\Cache\StateInterface'); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = $objectManager->create('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - foreach ($types as $type) { - $this->assertTrue( - $cacheState->isEnabled($type), - "'{$type}' cache type has not been enabled after installation" - ); - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php new file mode 100644 index 00000000000..62b254d97e3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Integration\Service\V1; + +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\AdminTokenService. + */ +class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AdminTokenServiceInterface + */ + private $tokenService; + + /** + * @var TokenModel + */ + private $tokenModel; + + /** + * @var UserModel + */ + private $userModel; + + /** + * Setup AdminTokenService + */ + public function setUp() + { + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + $this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); + $this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); + } + + /** + * @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/Integration/Service/V1/TokenServiceTest.php b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php similarity index 68% rename from dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php rename to dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php index d92a18de977..672c77c41b3 100644 --- a/dev/tests/integration/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php @@ -28,15 +28,14 @@ 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. + * Test class for \Magento\Integration\Service\V1\CustomerTokenService. */ -class TokenServiceTest extends \PHPUnit_Framework_TestCase +class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase { /** - * @var TokenServiceInterface + * @var CustomerTokenServiceInterface */ private $tokenService; @@ -51,21 +50,15 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase private $tokenModel; /** - * @var UserModel - */ - private $userModel; - - /** - * Setup TokenService + * Setup CustomerTokenService */ public function setUp() { - $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + $this->tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\CustomerTokenService'); $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'); } /** @@ -105,47 +98,6 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase $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 * diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php b/dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php rename to dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.php index e5a4604cf93..91265277f7c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/OnlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Log/Block/Adminhtml/OnlineTest.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\Customer\Block\Adminhtml; +namespace Magento\Log\Block\Adminhtml; /** * @magentoAppArea adminhtml @@ -38,8 +38,8 @@ class OnlineTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Layout', array('area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) ); - /** @var $block \Magento\Customer\Block\Adminhtml\Online */ - $block = $layout->createBlock('Magento\Customer\Block\Adminhtml\Online', 'block'); + /** @var $block \Magento\Log\Block\Adminhtml\Online */ + $block = $layout->createBlock('Magento\Log\Block\Adminhtml\Online', 'block'); $this->assertNotEmpty($block->getFilterFormHtml()); } } diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php index 8e6f043b9c0..e28c3ab4328 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/queue.php @@ -32,8 +32,8 @@ $template = $objectManager->create('Magento\Newsletter\Model\Template'); $template->load('fixture_tpl', 'template_code'); $templateId = $template->getId(); -$currentStore = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); -$otherStore = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore('fixturestore')->getId(); +$currentStore = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); +$otherStore = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore('fixturestore')->getId(); /** @var $queue \Magento\Newsletter\Model\Queue */ $queue = $objectManager->create('Magento\Newsletter\Model\Queue'); diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php index 9b1eb01ff59..2d472eff6df 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php @@ -26,10 +26,10 @@ require __DIR__ . '/../../../Magento/Core/_files/store.php'; require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; $currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); $otherStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( 'fixturestore' )->getId(); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php index 6199eb72d84..e509a02ff56 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php @@ -158,6 +158,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected function _resetConfig() { $this->_objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface')->reinit(); - $this->_objectManager->create('Magento\Store\Model\StoreManagerInterface')->reinitStores(); + $this->_objectManager->create('Magento\Framework\StoreManagerInterface')->reinitStores(); } } diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index 78541ca2593..3d9dcf86892 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -24,7 +24,6 @@ namespace Magento\Paypal\Model\Express; -use Magento\Customer\Model\Customer; use Magento\TestFramework\Helper\Bootstrap; use Magento\Checkout\Model\Type\Onepage; use Magento\Sales\Model\Quote; diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php index 00de2fc305a..306aacaf570 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php @@ -40,7 +40,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase $logAdapterFactory = $objectManager->get('Magento\Framework\Logger\AdapterFactory'); $localeDate = $objectManager->get('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $centinelService = $objectManager->get('Magento\Centinel\Model\Service'); - $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); $configFactory = $objectManager->get('Magento\Paypal\Model\ConfigFactory'); $mathRandom = $objectManager->get('Magento\Framework\Math\Random'); $httpClientFactoryMock = $this->getMockBuilder('Magento\Framework\HTTP\ZendClientFactory') 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 50f11548e50..5a69fa2a8d8 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 @@ -92,7 +92,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test02' diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php index 72a9700cda5..99bedc37ef5 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_express_with_customer.php @@ -84,7 +84,7 @@ $quote->setCustomerIsGuest(false) ->setCustomerId($customer->getId()) ->setCustomer($customer) ->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ) ->setReservedOrderId('test02') diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php index 231953582f4..ff87ee92e4d 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment_payflow.php @@ -101,7 +101,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test02' 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 b8a57762a80..308e524ab2f 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 @@ -100,7 +100,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php index cf504e15946..3528c8e0818 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/customer_review.php @@ -44,11 +44,11 @@ $review ->setEntityPkValue($product->getId()) ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING) ->setStoreId( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ) ->setStores([ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface') ->getStore()->getId() ]) ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php b/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php index 56298e0f746..eeb5c17d4b0 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/different_reviews.php @@ -36,12 +36,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); @@ -58,12 +58,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_APPROVED )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); @@ -80,12 +80,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_APPROVED )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php b/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php index 1dd4bfbf0fd..c13b65fb37b 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/review_xss.php @@ -33,12 +33,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->setNickname( diff --git a/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php b/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php index ada86ae0422..94bc83aee40 100644 --- a/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php +++ b/dev/tests/integration/testsuite/Magento/Review/_files/reviews.php @@ -36,12 +36,12 @@ $review->setEntityId( \Magento\Review\Model\Review::STATUS_PENDING )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setStores( array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() ) )->save(); diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php index 00ee0805c2b..56f1ffeaf38 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php +++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php @@ -148,7 +148,7 @@ class CatalogTest extends \Magento\TestFramework\TestCase\AbstractController $this->getRequest()->setParam( 'cid', \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getRootCategoryId() ); $this->dispatch('rss/catalog/category'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php deleted file mode 100644 index 631e2ba7c9c..00000000000 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AbstractTest.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -class AbstractTest extends \PHPUnit_Framework_TestCase -{ - /** - * @magentoDataFixture Magento/Sales/_files/order.php - */ - public function testAfterCommitCallbackOrderGrid() - { - $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Resource\Order\Grid\Collection' - ); - $this->assertEquals(1, $collection->count()); - foreach ($collection as $order) { - $this->assertInstanceOf('Magento\Sales\Model\Order', $order); - $this->assertEquals('100000001', $order->getIncrementId()); - } - } - - public function testAfterCommitCallbackOrderGridNotInvoked() - { - $adapter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Framework\App\Resource' - )->getConnection( - 'core_write' - ); - $this->assertEquals(0, $adapter->getTransactionLevel(), 'This test must be outside a transaction.'); - - $localOrderModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Order' - ); - $resource = $localOrderModel->getResource(); - $resource->beginTransaction(); - try { - /** @var $order \Magento\Sales\Model\Order */ - require __DIR__ . '/../_files/order.php'; - $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Sales\Model\Resource\Order\Grid\Collection' - ); - $this->assertEquals(0, $collection->count()); - $resource->rollBack(); - } catch (\Exception $e) { - $resource->rollBack(); - throw $e; - } - } -} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php index 2f0c89bd1ac..ce9377140c5 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order.php @@ -66,7 +66,7 @@ $order->setIncrementId( )->setShippingAddress( $shippingAddress )->setStoreId( - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId() + $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId() )->addItem( $orderItem )->setPayment( diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php index 292e40f8f43..bb857360024 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php @@ -63,7 +63,7 @@ $order->setIncrementId( )->setShippingAddress( $shippingAddress )->setStoreId( - $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore('fixturestore')->getId() + $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore('fixturestore')->getId() )->addItem( $orderItem )->setPayment( 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 4d8d86ba287..e3986009163 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php @@ -63,7 +63,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' 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 c7f27e00b37..8bbac47f430 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 @@ -53,7 +53,7 @@ $order->setIncrementId( $shippingAddress )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setPayment( $payment diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php index 5a66eb4642d..27d01be37d7 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote.php @@ -67,7 +67,7 @@ $quote->setCustomerIsGuest( true )->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId() )->setReservedOrderId( 'test01' diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php index 46e8f8be779..f66536c45a0 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off.php @@ -43,7 +43,7 @@ $salesRule->setData( 'stop_rules_processing' => 1, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId() ) ) diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php index 6142194f770..88215b2e051 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off.php @@ -43,7 +43,7 @@ $salesRule->setData( 'stop_rules_processing' => 1, 'website_ids' => array( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId() ) ) diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php index e6ed4ae093e..2b12a989efe 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/GroupTest.php @@ -40,7 +40,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testSetGetWebsite() { $this->assertFalse($this->_model->getWebsite()); - $website = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getWebsite(); + $website = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getWebsite(); $this->_model->setWebsite($website); $actualResult = $this->_model->getWebsite(); $this->assertSame($website, $actualResult); @@ -52,7 +52,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testGetWebsiteDefault() { $this->assertFalse($this->_model->getWebsite()); - $website = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getWebsite(); + $website = Bootstrap::getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getWebsite(); $this->_model->setWebsite($website); // Empty string should get treated like no parameter $actualResult = $this->_model->getWebsite(''); diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php index cc861ac6958..ba812c310c4 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php @@ -28,16 +28,22 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** * @var array */ - protected $_modelParams; + protected $modelParams; /** * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - protected $_model; + protected $model; + + /** + * @var array + */ + protected $existingCookies; protected function setUp() { - $this->_model = $this->_getStoreModel(); + $this->model = $this->_getStoreModel(); + $this->existingCookies = $_COOKIE; } /** @@ -46,7 +52,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function _getStoreModel() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_modelParams = [ + $this->modelParams = array( 'context' => $objectManager->get('Magento\Framework\Model\Context'), 'registry' => $objectManager->get('Magento\Framework\Registry'), 'resource' => $objectManager->get('Magento\Store\Model\Resource\Store'), @@ -65,14 +71,40 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'session' => $objectManager->get('Magento\Framework\Session\SessionManagerInterface'), 'currencyFactory' => $objectManager->get('Magento\Directory\Model\CurrencyFactory'), 'currencyInstalled' => 'system/currency/installed', - ]; + ); - return $this->getMock('Magento\Store\Model\Store', ['getUrl'], $this->_modelParams); + return $this->getMock('Magento\Store\Model\Store', array('getUrl'), $this->modelParams); } protected function tearDown() { - $this->_model = null; + $this->model = null; + $_COOKIE = $this->existingCookies; + } + + public function testSetCookie() + { + $storeCode = 'store code'; + $this->assertArrayNotHasKey(Store::COOKIE_NAME, $_COOKIE); + $this->model->setCode($storeCode); + $this->model->setCookie(); + $this->assertEquals($storeCode, $_COOKIE[Store::COOKIE_NAME]); + } + + public function testGetStoreCodeFromCookie() + { + $storeCode = 'store code'; + $_COOKIE[Store::COOKIE_NAME] = $storeCode; + $this->assertEquals($storeCode, $this->model->getStoreCodeFromCookie()); + } + + public function testDeleteCookie() + { + $storeCode = 'store code'; + $_COOKIE[Store::COOKIE_NAME] = $storeCode; + $this->assertArrayHasKey(Store::COOKIE_NAME, $_COOKIE); + $this->model->deleteCookie(); + $this->assertArrayNotHasKey(Store::COOKIE_NAME, $_COOKIE); } /** @@ -80,8 +112,8 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testLoad($loadId, $expectedId) { - $this->_model->load($loadId); - $this->assertEquals($expectedId, $this->_model->getId()); + $this->model->load($loadId); + $this->assertEquals($expectedId, $this->model->getId()); } /** @@ -89,28 +121,28 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function loadDataProvider() { - return [[1, 1], ['default', 1], ['nostore', null]]; + return array(array(1, 1), array('default', 1), array('nostore', null)); } public function testSetGetWebsite() { - $this->assertFalse($this->_model->getWebsite()); + $this->assertFalse($this->model->getWebsite()); $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite(); - $this->_model->setWebsite($website); - $actualResult = $this->_model->getWebsite(); + $this->model->setWebsite($website); + $actualResult = $this->model->getWebsite(); $this->assertSame($website, $actualResult); } public function testSetGetGroup() { - $this->assertFalse($this->_model->getGroup()); + $this->assertFalse($this->model->getGroup()); $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Store\Model\StoreManager' )->getGroup(); - $this->_model->setGroup($storeGroup); - $actualResult = $this->_model->getGroup(); + $this->model->setGroup($storeGroup); + $actualResult = $this->model->getGroup(); $this->assertSame($storeGroup, $actualResult); } @@ -127,7 +159,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrl($type, $useRewrites, $useStoreCode, $expected) { /* config operations require store to be loaded */ - $this->_model->load('default'); + $this->model->load('default'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\App\Config\MutableScopeConfigInterface' )->setValue( @@ -143,7 +175,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - $actual = $this->_model->getBaseUrl($type); + $actual = $this->model->getBaseUrl($type); $this->assertEquals($expected, $actual); } @@ -152,28 +184,28 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlDataProvider() { - return [ - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'], - [\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'] - ]; + return array( + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/') + ); } /** @@ -182,22 +214,22 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlInPub() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize( - [ - \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => [ - \Magento\Framework\App\Filesystem::PUB_DIR => ['uri' => ''] - ] - ] + array( + \Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\Framework\App\Filesystem::PUB_DIR => array('uri' => '') + ) + ) ); - $this->_model = $this->_getStoreModel(); - $this->_model->load('default'); + $this->model = $this->_getStoreModel(); + $this->model->load('default'); $this->assertEquals( 'http://localhost/pub/static/', - $this->_model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC) + $this->model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC) ); $this->assertEquals( 'http://localhost/pub/media/', - $this->_model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) + $this->model->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) ); } @@ -214,7 +246,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testGetBaseUrlForCustomEntryPoint($type, $useCustomEntryPoint, $useStoreCode, $expected) { /* config operations require store to be loaded */ - $this->_model->load('default'); + $this->model->load('default'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\App\Config\MutableScopeConfigInterface' )->setValue( @@ -233,11 +265,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase // emulate custom entry point $_SERVER['SCRIPT_FILENAME'] = 'custom_entry.php'; if ($useCustomEntryPoint) { - $property = new \ReflectionProperty($this->_model, '_isCustomEntryPoint'); + $property = new \ReflectionProperty($this->model, '_isCustomEntryPoint'); $property->setAccessible(true); - $property->setValue($this->_model, $useCustomEntryPoint); + $property->setValue($this->model, $useCustomEntryPoint); } - $actual = $this->_model->getBaseUrl($type); + $actual = $this->model->getBaseUrl($type); $this->assertEquals($expected, $actual); } @@ -246,38 +278,38 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseUrlForCustomEntryPointDataProvider() { - return [ - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'], - [ + return array( + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'), + array( \Magento\Framework\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/' - ], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'], - [ + ), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'), + array( \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/' - ], - [ + ), + array( \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/' - ], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'], - [\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'] - ]; + ), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/') + ); } public function testGetDefaultCurrency() { /* currency operations require store to be loaded */ - $this->_model->load('default'); - $this->assertEquals($this->_model->getDefaultCurrencyCode(), $this->_model->getDefaultCurrency()->getCode()); + $this->model->load('default'); + $this->assertEquals($this->model->getDefaultCurrencyCode(), $this->model->getDefaultCurrency()->getCode()); } /** @@ -285,25 +317,25 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetPriceFilter() { - $this->_model->load('default'); - $this->assertInstanceOf('Magento\Directory\Model\Currency\Filter', $this->_model->getPriceFilter()); + $this->model->load('default'); + $this->assertInstanceOf('Magento\Directory\Model\Currency\Filter', $this->model->getPriceFilter()); } public function testIsCanDelete() { - $this->assertFalse($this->_model->isCanDelete()); - $this->_model->load(1); - $this->assertFalse($this->_model->isCanDelete()); - $this->_model->setId(100); - $this->assertTrue($this->_model->isCanDelete()); + $this->assertFalse($this->model->isCanDelete()); + $this->model->load(1); + $this->assertFalse($this->model->isCanDelete()); + $this->model->setId(100); + $this->assertTrue($this->model->isCanDelete()); } public function testGetCurrentUrl() { - $this->_model->load('admin'); - $this->_model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php')); - $this->assertStringEndsWith('default', $this->_model->getCurrentUrl()); - $this->assertStringEndsNotWith('default', $this->_model->getCurrentUrl(false)); + $this->model->load('admin'); + $this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php')); + $this->assertStringEndsWith('default', $this->model->getCurrentUrl()); + $this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false)); } /** @@ -313,20 +345,18 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testCRUD() { - $this->_model->setData( - [ + $this->model->setData( + array( 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ] + ) ); $crud = new \Magento\TestFramework\Entity( - $this->_model, - ['name' => 'new name'], - 'Magento\Store\Model\Store' + $this->model, array('name' => 'new name'), 'Magento\Store\Model\Store' ); $crud->testCrud(); } @@ -342,17 +372,17 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testSaveValidation($badStoreData) { - $normalStoreData = [ + $normalStoreData = array( 'code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1 - ]; + ); $data = array_merge($normalStoreData, $badStoreData); - $this->_model->setData($data); - $this->_model->save(); + $this->model->setData($data); + $this->model->save(); } /** @@ -360,27 +390,26 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public static function saveValidationDataProvider() { - return [ - 'empty store name' => [['name' => '']], - 'empty store code' => [['code' => '']], - 'invalid store code' => [['code' => '^_^']] - ]; + return array( + 'empty store name' => array(array('name' => '')), + 'empty store code' => array(array('code' => '')), + 'invalid store code' => array(array('code' => '^_^')) + ); } /** * @dataProvider isUseStoreInUrlDataProvider */ - public function testIsUseStoreInUrl($isInstalled, $storeInUrl, $disableStoreInUrl, $expectedResult) + public function testIsUseStoreInUrl($storeInUrl, $disableStoreInUrl, $expectedResult) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $configMock = $this->getMock('Magento\Framework\App\Config\ReinitableConfigInterface'); - $appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false, false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue($isInstalled)); + $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false, false); - $params = $this->_modelParams; + $params = $this->modelParams; $params['context'] = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Framework\Model\Context', - ['appState' => $appStateMock] + array('appState' => $appStateMock) ); $configMock->expects( @@ -404,12 +433,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function isUseStoreInUrlDataProvider() { - return [ - [true, true, null, true], - [false, true, null, false], - [true, false, null, false], - [true, true, true, false], - [true, true, false, true] - ]; + return array( + array(true, null, true), + array(false, null, false), + array(true, true, false), + array(true, false, true) + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php index bbba87052bf..3182708e1e1 100644 --- a/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store.php @@ -24,10 +24,10 @@ $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Store\Model\Store'); $websiteId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getId(); $groupId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getWebsite()->getDefaultGroupId(); $store->setCode( 'fixture_second_store' @@ -46,5 +46,5 @@ $store->save(); /* Refresh stores memory cache */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php b/dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.php index 1f638fecf47..8c921d57cfe 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Block/Adminhtml/Rate/ImportExportTest.php +++ b/dev/tests/integration/testsuite/Magento/TaxImportExport/Block/Adminhtml/Rate/ImportExportTest.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\Tax\Block\Adminhtml\Rate; +namespace Magento\TaxImportExport\Block\Adminhtml\Rate; class ImportExportTest extends \PHPUnit_Framework_TestCase { @@ -36,7 +36,7 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\View\LayoutInterface' - )->createBlock('Magento\Tax\Block\Adminhtml\Rate\ImportExport'); + )->createBlock('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport'); } protected function tearDown() @@ -46,7 +46,7 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase public function testCreateBlock() { - $this->assertInstanceOf('Magento\Tax\Block\Adminhtml\Rate\ImportExport', $this->_block); + $this->assertInstanceOf('Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport', $this->_block); } public function testFormExists() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php index 4fe35186731..66fdc3353c8 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/CsvImportHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.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\Tax\Model\Rate; +namespace Magento\TaxImportExport\Model\Rate; class CsvImportHandlerTest extends \PHPUnit_Framework_TestCase { @@ -33,7 +33,7 @@ class CsvImportHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_importHandler = $objectManager->create('Magento\Tax\Model\Rate\CsvImportHandler'); + $this->_importHandler = $objectManager->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/correct_rates_import_file.csv b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/correct_rates_import_file.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/correct_rates_import_file.csv rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/correct_rates_import_file.csv diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/rates_import_file_incorrect_country.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/Tax/Model/Rate/_files/rates_import_file_incorrect_country.csv rename to dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/_files/rates_import_file_incorrect_country.csv diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php index 95ba3db70c0..4804bd35d66 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php @@ -43,7 +43,7 @@ class MethodsTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Element\BlockFactory' ); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getId(); /** @var $model \Magento\Payment\Model\MethodInterface */ if (empty($methodClass)) { @@ -78,20 +78,20 @@ class MethodsTest extends \PHPUnit_Framework_TestCase if ($model->canUseInternal()) { try { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( \Magento\Store\Model\Store::DEFAULT_STORE_ID ); $block->setArea('adminhtml'); $this->assertFileExists($block->getTemplateFile(), $message); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( $storeId ); } catch (\Exception $e) { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setId( $storeId ); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php index b6a643dfc05..67001f2fa01 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/BlockInstantiationTest.php @@ -70,7 +70,7 @@ class BlockInstantiationTest extends \Magento\TestFramework\TestCase\AbstractInt try { /** @var $website \Magento\Store\Model\Website */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setWebsiteId( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php index 0030df52d92..309a216fa2c 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php @@ -65,7 +65,7 @@ class TemplateFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrit try { /** @var $website \Magento\Store\Model\Website */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->setWebsiteId( 0 ); diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php index e1296c78835..777fdc92956 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/Html/FooterTest.php @@ -47,7 +47,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase $context->setValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH, false, false); $block = $objectManager->get('Magento\Framework\View\LayoutInterface') ->createBlock('Magento\Theme\Block\Html\Footer'); - $storeId = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId(); + $storeId = $objectManager->get('Magento\Framework\StoreManagerInterface')->getStore()->getId(); $this->assertEquals( array('PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), null), $block->getCacheKeyInfo() diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php index 554c89593c7..5e39f9fe90c 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php @@ -68,7 +68,7 @@ class HtmlTest extends \PHPUnit_Framework_TestCase array('scopeConfig' => $scopeConfig, 'urlBuilder' => $urlBuilder) ); $storeManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' ); $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Theme\Block\Html', diff --git a/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php index a37e0df01ef..56f9149e2e8 100644 --- a/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/InlineParserTest.php @@ -44,7 +44,7 @@ class InlineParserTest extends \PHPUnit_Framework_TestCase ); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore( $this->_storeId )->getConfig( diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php index 1eb55815619..72055d052de 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php @@ -54,7 +54,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'fancy/url.html' @@ -72,7 +72,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase ); $read->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByRequestPath( 'fancy/url.html' @@ -98,7 +98,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'product1.html' @@ -118,7 +118,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase ); $read->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->loadByIdPath( 'product/1' @@ -194,14 +194,8 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase $scopeConfig = $this->objectManager->create( '\Magento\Framework\App\Config\ScopeConfigInterface' ); - $cookieMetadataFactory = $this->objectManager->create( - '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory' - ); - $cookieManager = $this->objectManager->create( - '\Magento\Framework\Stdlib\CookieManager' - ); $storeManager = $this->objectManager->create( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' ); $httpContext = $this->objectManager->create( '\Magento\Framework\App\Http\Context' @@ -211,8 +205,6 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase 'context' => $context, 'registry' => $registry, 'scopeConfig' => $scopeConfig, - 'cookieMetadataFactory' => $cookieMetadataFactory, - 'cookieManager' => $cookieManager, 'storeManager' => $storeManager, 'httpContext' => $httpContext, ]; @@ -275,7 +267,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase $request = $this->objectManager ->create('Magento\Framework\App\RequestInterface'); $_GET['___from_store'] = $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getCode(); $this->assertFalse($this->model->rewrite($request)); } @@ -298,7 +290,7 @@ class UrlRewriteTest extends \PHPUnit_Framework_TestCase { $this->model->setStoreId( $this->objectManager->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getDefaultStoreView()->getId() )->setRequestPath( 'fancy/url.html' diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php index c3ea6e96a15..d3b1da48c79 100644 --- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/User/InvalidateTokenTest.php @@ -37,8 +37,8 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller */ public function testInvalidateSingleToken() { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); /** @var \Magento\Integration\Model\Oauth\Token $tokenModel */ $tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token'); /** @var \Magento\User\Model\User $userModel */ @@ -63,8 +63,14 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller */ public function testInvalidateMultipleTokens() { - /** @var \Magento\Integration\Service\V1\TokenService $tokenService */ - $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\TokenService'); + /** @var \Magento\Integration\Service\V1\AdminTokenService $tokenService */ + $tokenService = Bootstrap::getObjectManager()->get('Magento\Integration\Service\V1\AdminTokenService'); + + /** @var \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory $tokenModelCollectionFactory */ + $tokenModelCollectionFactory = Bootstrap::getObjectManager()->get( + 'Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory' + ); + /** @var \Magento\User\Model\User $userModel */ $userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User'); @@ -84,7 +90,7 @@ class InvalidateTokenTest extends \Magento\Backend\Utility\Controller // invalidate tokens $this->getRequest()->setParam('user_id', $adminUserId); $this->dispatch('backend/admin/user/invalidateToken'); - foreach ($tokenService->tokenModelCollectionFactory->create()->addFilterByAdminId($adminUserId) as $token) { + foreach ($tokenModelCollectionFactory->create()->addFilterByAdminId($adminUserId) as $token) { $this->assertEquals(1, $token->getRevoked()); } } diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php index 447326e29d4..e4b6488d628 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/PathProcessorTest.php @@ -27,7 +27,7 @@ namespace Magento\Webapi\Model; class PathProcessorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManager; @@ -40,7 +40,7 @@ class PathProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $objectManager->get('Magento\Framework\StoreManagerInterface'); $this->pathProcessor = $objectManager->get('\Magento\Webapi\Model\PathProcessor'); } diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index 0ec54eb5fa6..40b7c49e07e 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -46,7 +46,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store */ protected $_storeMock; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ diff --git a/dev/tests/performance/framework/Magento/TestFramework/Application.php b/dev/tests/performance/framework/Magento/TestFramework/Application.php index 6fac19c1850..5bd1efb2243 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Application.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Application.php @@ -29,11 +29,6 @@ namespace Magento\TestFramework; class Application { - /** - * Area code - */ - const AREA_CODE = 'install'; - /** * Configuration object * @@ -46,7 +41,14 @@ class Application * * @var string */ - protected $_installerScript; + protected $_installScript; + + /** + * Path to shell uninstaller script + * + * @var string + */ + protected $_uninstallScript; /** * @var \Magento\Framework\Shell @@ -76,18 +78,35 @@ class Application * Constructor * * @param \Magento\TestFramework\Performance\Config $config + * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Shell $shell + */ + public function __construct( + \Magento\TestFramework\Performance\Config $config, + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\Shell $shell + ) { + $shellDir = $config->getApplicationBaseDir() . '/dev/shell'; + $this->_objectManager = $objectManager; + $this->_installScript = $this->_assertPath($shellDir . '/install.php'); + $this->_uninstallScript = $this->_assertPath($shellDir . '/uninstall.php'); + $this->_config = $config; + $this->_shell = $shell; + } + + /** + * Asserts that a file exists and returns its real path + * + * @param string $path + * @return string * @throws \Magento\Framework\Exception */ - public function __construct(\Magento\TestFramework\Performance\Config $config, \Magento\Framework\Shell $shell) + private function _assertPath($path) { - $installerScript = $config->getApplicationBaseDir() . '/dev/shell/install.php'; - if (!is_file($installerScript)) { - throw new \Magento\Framework\Exception("File '{$installerScript}' is not found."); + if (!is_file($path)) { + throw new \Magento\Framework\Exception("File '{$path}' is not found."); } - $this->_installerScript = realpath($installerScript); - $this->_config = $config; - $this->_shell = $shell; + return realpath($path); } /** @@ -139,7 +158,7 @@ class Application */ protected function _uninstall() { - $this->_shell->execute('php -f %s -- --uninstall', array($this->_installerScript)); + $this->_shell->execute('php -f %s', array($this->_uninstallScript)); $this->_isInstalled = false; $this->_fixtures = array(); @@ -169,7 +188,7 @@ class Application } $installCmd = 'php -f %s --'; - $installCmdArgs = array($this->_installerScript); + $installCmdArgs = array($this->_installScript); foreach ($installOptions as $optionName => $optionValue) { $installCmd .= " --{$optionName} %s"; $installCmdArgs[] = $optionValue; @@ -195,30 +214,6 @@ class Application $varDirectory->changePermissions('', 0777); } - /** - * Bootstrap application, so it is possible to use its resources - * - * @return \Magento\TestFramework\Application - */ - protected function _bootstrap() - { - $this->getObjectManager()->configure( - $this->getObjectManager()->get('Magento\Framework\App\ObjectManager\ConfigLoader')->load(self::AREA_CODE) - ); - $this->getObjectManager()->get('Magento\Framework\Config\ScopeInterface')->setCurrentScope(self::AREA_CODE); - return $this; - } - - /** - * Bootstrap - * - * @return Application - */ - public function bootstrap() - { - return $this->_bootstrap(); - } - /** * Work on application, so that it has all and only $fixtures applied. May require reinstall, if * excessive fixtures has been applied before. @@ -237,7 +232,6 @@ class Application return; } - $this->_bootstrap(); foreach ($fixturesToApply as $fixtureFile) { $this->applyFixture($fixtureFile); } @@ -274,24 +268,8 @@ class Application * * @return \Magento\Framework\ObjectManager */ - public function getObjectManager() + protected function getObjectManager() { - if (!$this->_objectManager) { - $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory(); - $this->_objectManager = $locatorFactory->create(BP, $_SERVER); - $this->_objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); - } return $this->_objectManager; } - - /** - * Reset object manager - * - * @return \Magento\Framework\ObjectManager - */ - public function resetObjectManager() - { - $this->_objectManager = null; - return $this; - } } diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php index dd3dff154c9..bceec3ed950 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Bootstrap.php @@ -29,25 +29,37 @@ namespace Magento\TestFramework\Performance; class Bootstrap { + /** + * The real application bootstrap + * + * @var \Magento\Framework\App\Bootstrap + */ + private $appBootstrap; + + /** + * Tests base directory + * + * @var string + */ + private $testsBaseDir; + /** * Tests configuration holder * * @var \Magento\TestFramework\Performance\Config */ - protected $_config; + private $config; /** * Constructor * + * @param \Magento\Framework\App\Bootstrap $appBootstrap * @param string $testsBaseDir - * @param string $appBaseDir */ - public function __construct($testsBaseDir, $appBaseDir) + public function __construct(\Magento\Framework\App\Bootstrap $appBootstrap, $testsBaseDir) { - $configFile = "{$testsBaseDir}/config.php"; - $configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist"; - $configData = require $configFile; - $this->_config = new \Magento\TestFramework\Performance\Config($configData, $testsBaseDir, $appBaseDir); + $this->appBootstrap = $appBootstrap; + $this->testsBaseDir = $testsBaseDir; } /** @@ -57,7 +69,7 @@ class Bootstrap */ public function cleanupReports() { - $reportDir = $this->_config->getReportDir(); + $reportDir = $this->getConfig()->getReportDir(); try { $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); if ($filesystemAdapter->isExists($reportDir)) { @@ -71,6 +83,35 @@ class Bootstrap mkdir($reportDir, 0777, true); } + /** + * Test framework application factory method + * + * @param \Magento\Framework\Shell $shell + * @return \Magento\TestFramework\Application + */ + public function createApplication(\Magento\Framework\Shell $shell) + { + return new \Magento\TestFramework\Application( + $this->getConfig(), + $this->appBootstrap->getObjectManager(), + $shell + ); + } + + /** + * Test suite factory method + * + * @param \Magento\TestFramework\Application $application + * @param \Magento\TestFramework\Performance\Scenario\HandlerInterface $scenarioHandler + * @return Testsuite + */ + public function createTestSuite( + \Magento\TestFramework\Application $application, + \Magento\TestFramework\Performance\Scenario\HandlerInterface $scenarioHandler + ) { + return new Testsuite($this->getConfig(), $application, $scenarioHandler); + } + /** * Return configuration for the tests * @@ -78,6 +119,12 @@ class Bootstrap */ public function getConfig() { - return $this->_config; + if (null === $this->config) { + $configFile = "{$this->testsBaseDir}/config.php"; + $configFile = file_exists($configFile) ? $configFile : "{$configFile}.dist"; + $configData = require $configFile; + $this->config = new Config($configData, $this->testsBaseDir, $this->appBootstrap->getDirList()->getRoot()); + } + return $this->config; } } diff --git a/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php b/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php index 602d9d7d3a0..e605ee82045 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Performance/Testsuite.php @@ -93,16 +93,6 @@ class Testsuite $this->_scenarioHandler = $scenarioHandler; } - /** - * Get test framework application instance - * - * @return \Magento\TestFramework\Application - */ - public function getApplication() - { - return $this->_application; - } - /** * Run entire test suite of scenarios */ diff --git a/dev/tests/performance/framework/bootstrap.php b/dev/tests/performance/framework/bootstrap.php index f383f8470d7..77bdec73559 100644 --- a/dev/tests/performance/framework/bootstrap.php +++ b/dev/tests/performance/framework/bootstrap.php @@ -24,12 +24,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$testsBaseDir = realpath(__DIR__ . '/..'); -$magentoBaseDir = realpath($testsBaseDir . '/../../../'); - -require_once "{$magentoBaseDir}/app/bootstrap.php"; -(new \Magento\Framework\Autoload\IncludePath())->addIncludePath("{$testsBaseDir}/framework"); - -$bootstrap = new \Magento\TestFramework\Performance\Bootstrap($testsBaseDir, $magentoBaseDir); +$testsBaseDir = dirname(__DIR__); +require __DIR__ . '/../../../../app/bootstrap.php'; +$appBootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); +(new \Magento\Framework\Autoload\IncludePath())->addIncludePath($testsBaseDir . '/framework'); +$bootstrap = new \Magento\TestFramework\Performance\Bootstrap($appBootstrap, $testsBaseDir); $bootstrap->cleanupReports(); -return $bootstrap->getConfig(); +return $bootstrap; diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php index 0739198d3f0..d72682dbfcd 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php @@ -49,6 +49,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase */ protected $_installerScript; + /** + * @var string + */ + protected $_uninstallScript; + /** * @var string */ @@ -67,7 +72,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->_fixtureDir = __DIR__ . '/Performance/_files'; $this->_fixtureConfigData = require $this->_fixtureDir . '/config_data.php'; - $this->_installerScript = realpath($this->_fixtureDir . '/app_base_dir//dev/shell/install.php'); + $this->_installerScript = realpath($this->_fixtureDir . '/app_base_dir/dev/shell/install.php'); + $this->_uninstallScript = substr($this->_installerScript, 0, -11) . 'uninstall.php'; $this->_config = new \Magento\TestFramework\Performance\Config( $this->_fixtureConfigData, @@ -75,13 +81,15 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->_fixtureDir . '/app_base_dir' ); $this->_shell = $this->getMock('Magento\Framework\Shell', array('execute'), array(), '', false); + $objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManager'); $this->_object = $this->getMock( 'Magento\TestFramework\Application', - array('_bootstrap', '_cleanupMage', '_reindex', '_updateFilesystemPermissions'), - array($this->_config, $this->_shell) + array('_cleanupMage', '_reindex', '_updateFilesystemPermissions', 'getObjectManager'), + array($this->_config, $objectManager, $this->_shell) ); $this->_object->expects($this->any())->method('_reindex')->will($this->returnValue($this->_object)); + $this->_object->expects($this->any())->method('getObjectManager')->will($this->returnValue($objectManager)); // For fixture testing $this->_object->applied = array(); @@ -97,24 +105,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase unset($this->_object); } - /** - * Constructor test - * - * @expectedException \Magento\Framework\Exception - */ - public function testConstructorException() - { - $invalidAppDir = __DIR__; - new \Magento\TestFramework\Application( - new \Magento\TestFramework\Performance\Config( - $this->_fixtureConfigData, - $this->_fixtureDir, - $invalidAppDir - ), - $this->_shell - ); - } - /** * Apply fixtures test * @@ -212,8 +202,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -221,7 +211,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); @@ -253,8 +243,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -262,7 +252,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); @@ -271,8 +261,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->stringContains('--uninstall'), - $this->contains($this->_installerScript) + $this->anything(), + $this->contains($this->_uninstallScript) ); $this->_shell->expects( @@ -280,7 +270,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase )->method( 'execute' )->with( - $this->logicalNot($this->stringContains('--uninstall')), + $this->anything(), $this->contains($this->_installerScript) ); diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php index 4677947c1fe..3e784f15ba6 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/BootstrapTest.php @@ -25,6 +25,23 @@ namespace Magento\Test\Performance; class BootstrapTest extends \PHPUnit_Framework_TestCase { + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $appBootstrap; + + protected function setUp() + { + $this->appBootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $dirList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); + $dirList->expects($this->any())->method('getRoot')->will($this->returnValue(BP)); + $this->appBootstrap->expects($this->any())->method('getDirList')->will($this->returnValue($dirList)); + $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManager'); + $this->appBootstrap->expects($this->any()) + ->method('getObjectManager') + ->will($this->returnValue($objectManager)); + } + protected function tearDown() { // Delete a directory, where tests do some temporary work @@ -43,8 +60,8 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testConfigLoad($fixtureDir, $expectedUrl) { $bootstrap = new \Magento\TestFramework\Performance\Bootstrap( - $fixtureDir, - $this->_getBaseFixtureDir() . '/app_base_dir' + $this->appBootstrap, + $fixtureDir ); $config = $bootstrap->getConfig(); $this->assertInstanceOf('Magento\TestFramework\Performance\Config', $config); @@ -76,7 +93,7 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testCleanupReportsCreatesDirectory() { $fixtureDir = $this->_getBaseFixtureDir() . '/config_dist'; - $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($fixtureDir, $fixtureDir); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($this->appBootstrap, $fixtureDir); $reportDir = $fixtureDir . '/tmp/subdirectory/report'; @@ -88,7 +105,7 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase public function testCleanupReportsRemovesFiles() { $fixtureDir = $this->_getBaseFixtureDir() . '/config_dist'; - $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($fixtureDir, $fixtureDir); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($this->appBootstrap, $fixtureDir); $reportDir = $fixtureDir . '/tmp/subdirectory/report'; mkdir($reportDir, 0777, true); @@ -99,4 +116,18 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase $bootstrap->cleanupReports(); $this->assertFileNotExists($reportFile); } + + public function testCreateApplicationTestSuite() + { + $shell = $this->getMock('Magento\Framework\Shell', [], [], '', false); + $bootstrap = new \Magento\TestFramework\Performance\Bootstrap( + $this->appBootstrap, + $this->_getBaseFixtureDir() . '/config_dist' + ); + $application = $bootstrap->createApplication($shell); + $this->assertInstanceOf('Magento\TestFramework\Application', $application); + $handler = $this->getMockForAbstractClass('Magento\TestFramework\Performance\Scenario\HandlerInterface'); + $testSuite = $bootstrap->createTestSuite($application, $handler); + $this->assertInstanceOf('Magento\TestFramework\Performance\Testsuite', $testSuite); + } } diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php index a4e44bc4bd7..bc3b4a178f1 100644 --- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php @@ -81,7 +81,7 @@ class TestsuiteTest extends \PHPUnit_Framework_TestCase $this->_application = $this->getMock( 'Magento\TestFramework\Application', array('applyFixtures'), - array($this->_config, $shell) + array($this->_config, $this->getMockForAbstractClass('Magento\Framework\ObjectManager'), $shell) ); $this->_handler = $this->getMockForAbstractClass( 'Magento\TestFramework\Performance\Scenario\HandlerInterface' @@ -288,12 +288,4 @@ class TestsuiteTest extends \PHPUnit_Framework_TestCase { $this->_object->onScenarioFailure(array($this, 'invalid_callback')); } - - /** - * Test get application - */ - public function testGetApplication() - { - $this->assertEquals(true, $this->_object->getApplication() instanceof \Magento\TestFramework\Application); - } } diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.php new file mode 100644 index 00000000000..5956af5ae0d --- /dev/null +++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/_files/app_base_dir/dev/shell/uninstall.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) + */ + +/* Magento console uninstaller stub */ diff --git a/dev/tests/performance/run_scenarios.php b/dev/tests/performance/run_scenarios.php index 409fe3aa529..322da462721 100644 --- a/dev/tests/performance/run_scenarios.php +++ b/dev/tests/performance/run_scenarios.php @@ -24,8 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $config \Magento\TestFramework\Performance\Config */ -$config = require_once __DIR__ . '/framework/bootstrap.php'; +/** @var $bootstrap \Magento\TestFramework\Performance\Bootstrap */ +$bootstrap = require_once __DIR__ . '/framework/bootstrap.php'; $logWriter = new \Zend_Log_Writer_Stream('php://output'); $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL)); @@ -41,13 +41,10 @@ $scenarioHandler->register( new \Magento\TestFramework\Performance\Scenario\Handler\Php($shell) ); -$testsuite = new \Magento\TestFramework\Performance\Testsuite( - $config, - new \Magento\TestFramework\Application($config, $shell), - $scenarioHandler -); +$application = $bootstrap->createApplication($shell); +$testsuite = $bootstrap->createTestSuite($application, $scenarioHandler); -$scenarioTotalCount = count($config->getScenarios()); +$scenarioTotalCount = count($bootstrap->getConfig()->getScenarios()); $scenarioCount = 1; $scenarioFailCount = 0; $testsuite->onScenarioRun( diff --git a/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php b/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php index d96a51a0ee1..e2467c58b9c 100644 --- a/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php +++ b/dev/tests/performance/testsuite/fixtures/catalog_200_categories_80k_products.php @@ -33,7 +33,7 @@ $anchorStep = 2; $nestingLevel = 1; $parentCategoryId = $defaultParentCategoryId = $this->getObjectManager()->get( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->getStore()->getRootCategoryId(); $nestingPath = "1/{$parentCategoryId}"; $categoryPath = ''; diff --git a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php index 3b51484bf16..f97738ae61d 100644 --- a/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php +++ b/dev/tests/performance/testsuite/fixtures/sales_100k_orders.php @@ -61,7 +61,7 @@ $order->setBaseSubtotal( \Magento\Sales\Model\Order::STATE_NEW, true )->setStoreId( - $this->getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId() + $this->getObjectManager()->get('Magento\Framework\StoreManagerInterface')->getStore()->getId() ); for ($i = 1; $i <= 100000; $i++) { diff --git a/dev/tests/static/framework/bootstrap.php b/dev/tests/static/framework/bootstrap.php index f4e680ce228..e67cf580dbb 100644 --- a/dev/tests/static/framework/bootstrap.php +++ b/dev/tests/static/framework/bootstrap.php @@ -22,8 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('BP', str_replace('\\', '/', realpath(__DIR__ . '/../../../../'))); -require BP . '/app/autoload.php'; +require __DIR__ . '/../../../../app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array(__DIR__, dirname(__DIR__) . '/testsuite', BP . '/lib/internal') ); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php index b85b880e4f1..d8d1ec63cae 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Search/ConfigTest.php @@ -86,7 +86,6 @@ class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig 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'. " 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 2c1e544dcbe..3a875897abe 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 @@ -163,6 +163,7 @@ return array( 'customer_entity_int' => 'Magento_Customer', 'customer_entity_text' => 'Magento_Customer', 'customer_entity_varchar' => 'Magento_Customer', + 'customer_visitor' => 'Magento_Customer', 'directory_country' => 'Magento_Directory', 'directory_country_format' => 'Magento_Directory', 'directory_country_name' => 'Magento_Directory', 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 f0db8227cbb..4a278c7b431 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 @@ -843,8 +843,8 @@ return array( array('Mage_Core_Model_Session_Abstract_Varien'), array('Mage_Core_Model_Session_Abstract_Zend'), array('Magento\Core\Model\Source\Email\Variables', 'Magento\Email\Model\Source\Variables'), - array('Magento\Core\Model\Store\ListInterface', 'Magento\Store\Model\StoreManagerInterface'), - array('Magento\Core\Model\Store\StorageInterface', 'Magento\Store\Model\StoreManagerInterface'), + array('Magento\Core\Model\Store\ListInterface', 'Magento\Framework\StoreManagerInterface'), + array('Magento\Core\Model\Store\StorageInterface', 'Magento\Framework\StoreManagerInterface'), array('Mage_Core_Model_Store_Group_Limitation'), array('Mage_Core_Model_Store_Limitation'), array('Magento\Core\Model\Variable\Observer'), @@ -2122,7 +2122,7 @@ return array( array('Recurring\Profile', 'Recurring\Payment'), // recurring profile was renamed to recurring payment array('Magento\Catalog\Helper\Product\Flat'), array('Magento\Catalog\Helper\Flat\AbstractFlat'), - array('Magento\Core\App\Action\Plugin\Install', 'Magento\Install\App\Action\Plugin\Install'), + array('Magento\Core\App\Action\Plugin\Install', 'Magento\Framework\App\Bootstrap'), array('Magento\Core\App\Action\Plugin\Session', 'Magento\Core\Block\RequireCookie'), array( 'Magento\Core\Model\LocaleInterface', @@ -2307,8 +2307,8 @@ return array( ['Magento\Framework\App\Locale\ScopeConfigInterface', 'Magento\Framework\App\Config\ScopeConfigInterface'], ['Magento\Core\App\Action\Plugin\StoreCheck', 'Magento\Store\App\Action\Plugin\StoreCheck'], [ - 'Magento\Core\App\FrontController\Plugin\DispatchExceptionHandler', - 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler' + 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler', + 'Magento\Framework\App\Bootstrap' ], [ 'Magento\Core\App\FrontController\Plugin\RequestPreprocessor', @@ -2333,14 +2333,14 @@ return array( ['Magento\Core\Model\Resource\Website\Grid\Collection', 'Magento\Store\Model\Resource\Website\Grid\Collection'], ['Magento\Core\Model\ScopeInterface', 'Magento\Store\Model\ScopeInterface'], ['Magento\Core\Model\Store', 'Magento\Store\Model\Store'], - ['Magento\Core\Model\Store\Exception', 'Magento\Store\Model\Exception'], + ['Magento\Store\Model\Exception', 'Magento\Framework\Model\Exception, Magento\Framework\App\InitException'], ['Magento\Core\Model\Store\Group', 'Magento\Store\Model\Group'], ['Magento\Core\Model\Store\Group\Factory', 'Magento\Store\Model\GroupFactory'], ['Magento\Core\Model\Store\Storage\Db', 'Magento\Store\Model\Storage\Db'], ['Magento\Core\Model\Store\Storage\DefaultStorage', 'Magento\Store\Model\Storage\DefaultStorage'], ['Magento\Core\Model\Store\StorageFactory', 'Magento\Store\Model\StorageFactory'], ['Magento\Core\Model\StoreManager', 'Magento\Store\Model\StoreManager'], - ['Magento\Core\Model\StoreManagerInterface', 'Magento\Store\Model\StoreManagerInterface'], + ['Magento\Core\Model\StoreManagerInterface', 'Magento\Framework\StoreManagerInterface'], ['Magento\Core\Model\System\Store', 'Magento\Store\Model\System\Store'], ['Magento\Core\Model\Website', 'Magento\Store\Model\Website'], ['Magento\Core\Model\Website\Factory', 'Magento\Store\Model\WebsiteFactory'], @@ -2549,7 +2549,8 @@ return array( ['Magento\OsInfo', 'Magento\Framework\OsInfo'], ['Magento\Registry', 'Magento\Framework\Registry'], ['Magento\Util', 'Magento\Framework\Util'], - ['Magento\BootstrapException', 'Magento\Framework\BootstrapException'], + ['Magento\BootstrapException', 'Magento\Framework\App\InitException'], + ['Magento\Framework\BootstrapException', 'Magento\Framework\App\InitException'], ['Magento\Checkout\Helper\Url'], [ 'Magento\Customer\Service\V1\CustomerCurrentService', @@ -2735,8 +2736,66 @@ return array( ['Magento\Catalog\Model\Observer\Reindex'], ['Magento\CatalogSearch\Model\Fulltext\Observer'], ['Magento\CatalogSearch\Model\Resource\Indexer\Fulltext'], + [ + 'Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer\Country', + 'Magento\TaxImportExport\Block\Adminhtml\Rate\Grid\Renderer\Country' + ], + ['Magento\Tax\Block\Adminhtml\Rate\ImportExport', 'Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExport'], + [ + 'Magento\Tax\Block\Adminhtml\Rate\ImportExportHeader', + 'Magento\TaxImportExport\Block\Adminhtml\Rate\ImportExportHeader' + ], + ['Magento\Tax\Controller\Adminhtml\Rate\ExportCsv', 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportCsv'], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ExportPost', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportPost' + ], + ['Magento\Tax\Controller\Adminhtml\Rate\ExportXml', 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportXml'], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ImportExport', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportExport' + ], + [ + 'Magento\Tax\Controller\Adminhtml\Rate\ImportPost', + 'Magento\TaxImportExport\Controller\Adminhtml\Rate\ImportPost' + ], + ['Magento\Tax\Model\Rate\CsvImportHandler', 'Magento\TaxImportExport\Model\Rate\CsvImportHandler'], ['\Magento\Theme\Helper\Layout'], ['Magento\Framework\Stdlib\Cookie', 'Magento\Framework\Stdlib\CookieManager'], + ['Magento\Framework\View\Design\Theme\Provider'], + ['Magento\Install\Controller\Index'], + ['Magento\Install\Controller\Wizard'], + ['Magento\Install\Controller\Wizard\Administrator'], + ['Magento\Install\Controller\Wizard\AdministratorPost'], + ['Magento\Install\Controller\Wizard\Begin'], + ['Magento\Install\Controller\Wizard\BeginPost'], + ['Magento\Install\Controller\Wizard\Config'], + ['Magento\Install\Controller\Wizard\ConfigPost'], + ['Magento\Install\Controller\Wizard\Download'], + ['Magento\Install\Controller\Wizard\DownloadAuto'], + ['Magento\Install\Controller\Wizard\DownloadManual'], + ['Magento\Install\Controller\Wizard\DownloadPost'], + ['Magento\Install\Controller\Wizard\End'], + ['Magento\Install\Controller\Wizard\Index'], + ['Magento\Install\Controller\Wizard\Install'], + ['Magento\Install\Controller\Wizard\InstallDb'], + ['Magento\Install\Controller\Wizard\Locale'], + ['Magento\Install\Controller\Wizard\LocaleChange'], + ['Magento\Install\Controller\Wizard\LocalePost'], + ['Magento\Install\App\Action\Plugin\Dir'], + ['\Magento\Framework\App\EntryPoint\EntryPoint', '\Magento\Framework\App\Bootstrap'], + ['\Magento\Framework\App\EntryPointInterface', '\Magento\Framework\App\Bootstrap'], + ['Magento\Framework\Module\FrontController\Plugin\Install', '\Magento\Framework\Module\Plugin\DbStatusValidator'], + ['Magento\Framework\Module\UpdaterInterface'], + ['Magento\Framework\App\EntryPoint\EntryPoint', 'Magento\Framework\App\Bootstrap'], + ['Magento\Framework\App\EntryPointInterface', 'Magento\Framework\App\Bootstrap'], + ['Magento\Install\Model\Installer\AbstractInstaller', 'Magento\Install\Model\Installer\Console'], + ['Magento\Install\App\Action\Plugin\Install', 'Magento\Framework\App\Bootstrap'], + ['\Magento\Cron\App\Cron\Plugin\ApplicationInitializer', 'Magento\Framework\App\Bootstrap'], + ['Magento\Framework\App\Error\Handler', 'Magento\Framework\App\Http'], + ['Magento\Framework\App\State\MaintenanceMode', 'Magento\Framework\App\MaintenanceMode'], + ['Magento\Framework\Error\Handler', 'Magento\Framework\App\ErrorHandler'], + ['Magento\Framework\Error\HandlerInterface', 'Magento\Framework\App\ErrorHandler'], ['\Magento\Framework\Service\Data\Eav\AbstractObject', 'Magento\Framework\Service\Data\AbstractExtensibleObject'], ['\Magento\Framework\Service\Data\AbstractObject', 'Magento\Framework\Service\Data\AbstractSimpleObject'], [ @@ -2747,4 +2806,5 @@ return array( '\Magento\Framework\Service\Data\AbstractObjectBuilder', 'Magento\Framework\Service\Data\AbstractSimpleObjectBuilder' ], + ['\Magento\Sales\Model\Observer'], ); 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 7d70048ad83..4881dc98477 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 @@ -1035,8 +1035,8 @@ return array( array('getMigrationInstance', 'Magento\Customer\Model\Resource\Setup', '$this->_migrationFactory->create()'), array('turnOnReadCommittedMode', 'Magento\Backup\Model\Resource\Db'), array('turnOnSerializableMode', 'Magento\Backup\Model\Resource\Db', 'prepareTransactionIsolationLevel'), - array('turnOnMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\State::turnOnMaintenanceMode'), - array('turnOffMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\State::turnOffMaintenanceMode'), + array('turnOnMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'), + array('turnOffMaintenanceMode', 'Magento\Backup\Helper\Data', 'Magento\Framework\App\MaintenanceMode::set'), array('getMaintenanceFlagFilePath', 'Magento\Backup\Helper\Data',), array('_getResourceModel', '\Magento\Webapi\Model\Source\Acl\Role', '$this->_resource'), array('_getSession', '\Magento\GiftMessage\Model\Save', '$this->_session'), @@ -1688,9 +1688,9 @@ return array( 'getRatingSummary', 'Magento\Catalog\Model\Product' ), - ['getCurrentStore', 'Magento\Store\Model\StoreManagerInterface'], - ['getAnyStoreView', 'Magento\Store\Model\StoreManagerInterface'], - ['throwStoreException', 'Magento\Store\Model\StoreManagerInterface'], + ['getCurrentStore', 'Magento\Framework\StoreManagerInterface'], + ['getAnyStoreView', 'Magento\Framework\StoreManagerInterface'], + ['throwStoreException', 'Magento\Framework\StoreManagerInterface'], ['getCustomer', 'Magento\ProductAlert\Helper\Data'], ['addCustomerFilter', 'Magento\ProductAlert\Model\Resource\Stock\Collection'], ['addCustomerFilter', 'Magento\ProductAlert\Model\Resource\Price\Collection'], @@ -1804,6 +1804,7 @@ return array( ['getCalculator', '\Magento\Tax\Helper\Data'], ['getRatesForAllProductTaxClasses', 'Magento\Tax\Model\Calculation'], ['getRatesForAllCustomerTaxClasses', 'Magento\Tax\Model\Calculation'], + ['getMaxRecipients', 'Magento\Catalog\Block\Product\Send'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Observer'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Resource\Stock\Status'], ['prepareCatalogProductIndexSelect', 'Magento\CatalogInventory\Model\Stock\Status'], @@ -1916,4 +1917,5 @@ return array( ['addTag', 'Magento\UrlRewrite\Model\UrlRewrite'], ['loadByTags', 'Magento\UrlRewrite\Model\UrlRewrite'], ['getMethodFormBlock', 'Magento\Centinel\Helper\Data'], + ['login', 'Magento\Customer\Model\Session'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php index 5756c6e27ef..5b203315d30 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php @@ -205,7 +205,6 @@ return array( array('_filesystem', 'Magento\Index\Model\Lock\Storage'), array('_coreDir', 'Magento\Sales\Model\Order\Pdf\AbstractPdf'), array('_coreDir', 'Magento\ScheduledImportExport\Model\Scheduled\Operation'), - array('_dir', 'Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler'), array('_dirs', 'Magento\Core\Block\Template'), array('_applicationDirs', 'Magento\Framework\App\Config\FileResolver'), array('_dir', 'Magento\Core\Model\File\Storage'), @@ -343,4 +342,7 @@ return array( ['_usageFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], ['_couponFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], ['_customerFactory', 'Magento\SalesRule\Model\Validator', 'Magento\SalesRule\Model\Validator\Utility'], + ['_skipModuleUpdate', '\Magento\Framework\Module\Updater'], + ['_factory', 'Magento\Framework\Module\Updater'], + ['_resourceList', 'Magento\Framework\Module\Updater'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index 273663ecf30..3e71f00bc9e 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -41,6 +41,11 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase */ protected static $reportDir = ''; + /** + * @var string + */ + protected static $pathToSource = ''; + /** * @var array */ @@ -58,7 +63,8 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase */ public static function setUpBeforeClass() { - self::$reportDir = Utility\Files::init()->getPathToSource() . '/dev/tests/static/report'; + self::$pathToSource = Utility\Files::init()->getPathToSource(); + self::$reportDir = self::$pathToSource . '/dev/tests/static/report'; if (!is_dir(self::$reportDir)) { mkdir(self::$reportDir, 0777); } @@ -163,23 +169,59 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase /** * Run mess detector on code * + * @param array $whiteList * @return void + * @dataProvider whiteListDataProvider */ - public function testCodeMess() + public function testCodeMess($whiteList) { - $reportFile = self::$reportDir . '/phpmd_report.xml'; + if (count($whiteList) == 1) { + $formattedPath = preg_replace('~/~', '_', preg_replace('~' . self::$pathToSource . '~', '', $whiteList[0])); + } else { + $formattedPath = '_app_lib'; + } + $reportFile = self::$reportDir . '/phpmd_report' . $formattedPath . '.xml'; $codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile); if (!$codeMessDetector->canRun()) { $this->markTestSkipped('PHP Mess Detector is not available.'); } - self::setupFileLists(); $this->assertEquals( PHP_PMD_TextUI_Command::EXIT_SUCCESS, - $codeMessDetector->run(self::$whiteList, self::$blackList), + $codeMessDetector->run($whiteList, self::$blackList), "PHP Code Mess has found error(s): See detailed report in {$reportFile}" ); + + // delete empty reports + unlink($reportFile); + } + + /** + * To improve the test execution performance the whitelist is split into smaller parts: + * - in case of dev code (tests, tools, etc) each whitelist entry is fed separately to phpmd + * - app/lib code is still being executed within a single whitelist to make sure that all design + * metrics (depth of inheritance, number of children, etc.) are being calculated in a correct way. + * @return array + */ + public function whiteListDataProvider() + { + $whiteList = array(); + $testCodePattern = '~' . self::$pathToSource . '/dev/~'; + $nonTestCode = array(); + + self::setupFileLists(); + + foreach (self::$whiteList as $path) { + if (!preg_match($testCodePattern, $path)) { + $nonTestCode[] = $path; + } else { + $whiteList[] = array(array($path)); + } + } + $whiteList[] = array($nonTestCode); + + return $whiteList; } /** 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 d3afb38c3ad..e232e29d865 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 @@ -55,6 +55,8 @@ app/code/Magento/Directory/Helper app/code/Magento/Customer/Block app/code/Magento/Customer/Controller app/code/Magento/Customer/Helper +app/code/Magento/Customer/Model/Visitor.php +app/code/Magento/Customer/Model/Resource/Visitor.php app/code/Magento/Customer/Model/Address/Config app/code/Magento/Customer/Model/Address/Config.php app/code/Magento/Customer/Service @@ -111,6 +113,7 @@ app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php app/code/Magento/Sales/Model/Observer app/code/Magento/Sales/Model/Quote/Address/*Interface.php app/code/Magento/SalesRule/Model/Plugin +app/code/Magento/Sendfriend/Block/Plugin/Catalog/Product/View.php app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/Invoice.php app/code/Magento/Shipping/Model/Observer.php app/code/Magento/Shipping/Model/Order/Track.php @@ -123,12 +126,14 @@ app/code/Magento/UrlRedirect app/code/Magento/Wishlist/Block/Link.php dev/shell dev/tests/functional -dev/tests/integration +dev/tests/integration/* dev/tests/js dev/tests/performance dev/tests/static -dev/tests/unit +dev/tests/unit/framework +dev/tests/unit/testsuite/Magento/* dev/tools +lib/internal/Magento/Framework/App lib/internal/Magento/Framework/Backup/Db lib/internal/Magento/Framework/Backup/Factory.php lib/internal/Magento/Framework/Cache/Core.php @@ -136,13 +141,10 @@ lib/internal/Magento/Framework/Convert lib/internal/Magento/Framework/Exception lib/internal/Magento/Framework/Stdlib/DateTime.php lib/internal/Magento/Framework/Object.php -lib/internal/Magento/Framework/App lib/internal/Magento/Framework/Data/Argument lib/internal/Magento/Framework/ObjectManager lib/internal/Magento/Framework/Service 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/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index 0c1c92c6fb5..ece247a7124 100755 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -23,12 +23,10 @@ */ if (!defined('TESTS_TEMP_DIR')) { - define('BP', realpath(__DIR__ . '/../../../../')); define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } - +require __DIR__ . '/../../../../app/autoload.php'; require BP . '/app/functions.php'; -require BP . '/app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array( __DIR__, 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 4caf84c382a..da98e1d5f05 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 @@ -66,7 +66,7 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase $this->_configMock = $this->getMock('Magento\Framework\App\Config', array(), array(), '', false); $this->_urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface'); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $configFactoryMock = $this->getMock( 'Magento\Framework\App\Config\ValueFactory', array('create'), diff --git a/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php index 2033b7d3282..b82649a3438 100644 --- a/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorization/Model/CompositeUserContextTest.php @@ -24,16 +24,41 @@ namespace Magento\Authorization\Model; +use Magento\TestFramework\Helper\ObjectManager; +use \Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + class CompositeUserContextTest extends \PHPUnit_Framework_TestCase { /** * @var CompositeUserContext */ - protected $_model; + protected $userContext; + + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; protected function setUp() { - $this->_model = new CompositeUserContext(); + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock] + ); } public function testConstructor() @@ -45,7 +70,10 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $model = new CompositeUserContext($contexts); + $model = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); $this->verifyUserContextIsAdded($model, $userContextMock); } @@ -63,8 +91,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserId = $this->_model->getUserId(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserId = $this->userContext->getUserId(); $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); } @@ -82,8 +113,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $actualUserType = $this->_model->getUserType(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserType = $this->userContext->getUserType(); $this->assertEquals($expectedUserType, $actualUserType, 'User Type is defined incorrectly.'); } @@ -103,11 +137,14 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase 'type' => $userContextMock ] ]; - $this->_model = new CompositeUserContext($contexts); - $this->_model->getUserId(); - $this->_model->getUserId(); - $this->_model->getUserType(); - $this->_model->getUserType(); + $this->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $this->userContext->getUserId(); + $this->userContext->getUserId(); + $this->userContext->getUserType(); + $this->userContext->getUserType(); } public function testEmptyUserContext() @@ -123,45 +160,11 @@ class CompositeUserContextTest extends \PHPUnit_Framework_TestCase '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->userContext = $this->objectManager->getObject( + 'Magento\Authorization\Model\CompositeUserContext', + ['compositeHelper' => $this->compositeHelperMock, 'userContexts' => $contexts] + ); + $actualUserId = $this->userContext->getUserId(); $this->assertEquals($expectedUserId, $actualUserId, 'User ID is defined incorrectly.'); } diff --git a/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php index 6334978d52b..5c21e4ed6eb 100644 --- a/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Authorizenet/Model/Directpost/ObserverTest.php @@ -45,7 +45,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->coreRegistry = $this->getMock('Magento\Framework\Registry', array()); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $payment = $this->getMock('Magento\Authorizenet\Model\Directpost', null, array(), '', false); $this->coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php index a0dbec84e05..aa990ca1064 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/AdminConfigTest.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Test class for \Magento\Backend\AdminConfig - */ namespace Magento\Backend; -use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; +/** + * Test class for \Magento\Backend\AdminConfig + * + */ class AdminConfigTest extends \PHPUnit_Framework_TestCase { /** @@ -38,9 +38,9 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase private $requestMock; /** - * @var \Magento\Framework\App\State + * @var \Magento\TestFramework\Helper\ObjectManager */ - private $appState; + private $objectManager; protected function setUp() @@ -61,9 +61,7 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue('init.host') ); - $this->appState = $this->getMock('\Magento\Framework\App\State', - ['isInstalled'], [], '', false, false); - $this->appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true)); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); } public function testSetCookiePathNonDefault() @@ -72,20 +70,35 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $mockFrontNameResolver + $mockFrontNameResolver->expects($this->once()) ->method('getFrontName') ->will($this->returnValue('backend')); - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $adminConfig = $objectManager->getObject( + $adminConfig = $this->objectManager->getObject( 'Magento\Backend\AdminConfig', [ 'request' => $this->requestMock, - 'appState' => $this->appState, 'frontNameResolver' => $mockFrontNameResolver, ] ); $this->assertEquals('/backend', $adminConfig->getCookiePath()); } + + /** + * Test for setting session name for admin + * + */ + public function testSetSessionNameByConstructor() + { + $sessionName = 'admin'; + $adminConfig = $this->objectManager->getObject( + 'Magento\Backend\AdminConfig', + [ + 'request' => $this->requestMock, + 'sessionName' => $sessionName + ] + ); + $this->assertSame($sessionName, $adminConfig->getName()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php index a4bbdaf3b6e..ee7a5c05ea7 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php @@ -67,7 +67,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_localeMock = $this->getMock('Magento\Framework\Locale\CurrencyInterface'); $this->_requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php index e3f89ef4225..1b33c677fd2 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php @@ -66,7 +66,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_dataFactoryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -130,7 +130,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase false ); - $this->_storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\Backend\Model\Config( $this->_appConfigMock, diff --git a/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php index a15a786a7db..7bd62bd4ec6 100644 --- a/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Backup/Helper/DataTest.php @@ -24,7 +24,7 @@ namespace Magento\Backup\Helper; use Magento\Framework\App\Filesystem; -use Magento\Framework\App\State\MaintenanceMode; +use Magento\Framework\App\MaintenanceMode; class DataTest extends \PHPUnit_Framework_TestCase { @@ -92,7 +92,7 @@ class DataTest extends \PHPUnit_Framework_TestCase [ '.git', '.svn', - 'var/maintenance.flag', + 'var/' . MaintenanceMode::FLAG_FILENAME, Filesystem::SESSION_DIR, Filesystem::CACHE_DIR, Filesystem::LOG_DIR, @@ -119,7 +119,7 @@ class DataTest extends \PHPUnit_Framework_TestCase [ '.svn', '.git', - 'var/maintenance.flag', + 'var/' . MaintenanceMode::FLAG_FILENAME, Filesystem::SESSION_DIR, Filesystem::LOG_DIR, Filesystem::VAR_DIR . '/locks', diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php index 81bfb88cce5..c3910a8d66c 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php @@ -57,7 +57,7 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->commonPriceMock = $this->getMock( 'Magento\Catalog\Model\Product\CatalogPrice', array(), diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php index 16b3a626b3f..407ae918420 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/PriceTest.php @@ -74,7 +74,7 @@ class PriceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->localeDateMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.php new file mode 100644 index 00000000000..ee717b611c0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductLoadProcessorTest.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\Bundle\Service\V1\Product; + +use Magento\TestFramework\Helper\ObjectManager; + +class BundleProductLoadProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor + */ + private $model; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionReadService; + + /** + * @var \Magento\Catalog\Service\V1\Data\ProductBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $productBuilder; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->optionReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->productBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->setMethods(['setCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $helper->getObject( + 'Magento\Bundle\Service\V1\Product\BundleProductLoadProcessor', + [ + 'optionReadService' => $this->optionReadService, + 'productRepository' => $this->productRepository, + ] + ); + } + + public function testLoadNotBundleProduct() + { + $productId = 'test_id'; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($productId) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)); + + $this->model->load($productId, $this->productBuilder); + } + + public function testLoadBundleProduct() + { + $productId = 'test_id'; + $productSku = 'test_sku'; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($productId) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)); + $this->product->expects($this->once()) + ->method('getSku') + ->will($this->returnValue($productSku)); + + $optionCustomAttributeValue = ['a', 'b']; + $this->optionReadService->expects($this->once()) + ->method('getList') + ->with($productSku) + ->will($this->returnValue($optionCustomAttributeValue)); + $this->productBuilder->expects($this->at(0)) + ->method('setCustomAttribute') + ->with('bundle_product_options', $optionCustomAttributeValue); + + $this->model->load($productId, $this->productBuilder); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php new file mode 100644 index 00000000000..bfde3221bcc --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/BundleProductSaveProcessorTest.php @@ -0,0 +1,302 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Catalog\Model\Product\Type as ProductType; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class BundleProductSaveProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor + */ + private $saveProcessor; + + /** + * @var \Magento\Catalog\Model\ProductRepository|\PHPUnit_Framework_MockObject_MockObject + */ + private $productRepository; + + /** + * @var \Magento\Catalog\Service\V1\Data\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $productData; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + private $product; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink1; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink2; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject + */ + private $productLink3; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $productOption1; + + /** + * @var \Magento\Bundle\Service\V1\Data\Product\Option|\PHPUnit_Framework_MockObject_MockObject + */ + private $productOption2; + + /** + * @var \Magento\Bundle\Service\V1\Product\Link\WriteService|\PHPUnit_Framework_MockObject_MockObject + */ + private $linkWriteService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\WriteService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionWriteService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Link\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $linkReadService; + + /** + * @var \Magento\Bundle\Service\V1\Product\Option\ReadService|\PHPUnit_Framework_MockObject_MockObject + */ + private $optionReadService; + + /** + * @var \Magento\Catalog\Service\V1\Data\ProductBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $productBuilder; + + /** + * @var \Magento\Framework\Service\Data\Eav\AttributeValue|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeValue; + + protected function setup() + { + $helper = new ObjectManager($this); + + $this->productRepository = $this->getMockBuilder('Magento\Catalog\Model\ProductRepository') + ->setMethods(['get']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productData = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup', 'getCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->setMethods(['getSku', 'getTypeId', '__wakeup']) + ->disableOriginalConstructor() + ->getMock(); + + $this->productLink1 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku', 'getOptionId']) + ->getMock(); + $this->productLink1->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink1Sku')); + $this->productLink2 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku', 'getOptionId']) + ->getMock(); + $this->productLink2->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink2Sku')); + $this->productLink3 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') + ->disableOriginalConstructor() + ->setMethods(['getId', 'getSku']) + ->getMock(); + $this->productLink3->expects($this->any()) + ->method('getSku') + ->will($this->returnValue('productLink3Sku')); + + $this->productOption1 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->disableOriginalConstructor() + ->getMock(); + $this->productOption1->expects($this->any()) + ->method('getId') + ->will($this->returnValue('productOption1Sku')); + $this->productOption2 = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Option') + ->disableOriginalConstructor() + ->getMock(); + $this->productOption2->expects($this->any()) + ->method('getId') + ->will($this->returnValue('productOption2Sku')); + + $this->linkWriteService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Link\WriteService') + ->disableOriginalConstructor() + ->getMock(); + + $this->optionWriteService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\WriteService') + ->disableOriginalConstructor() + ->getMock(); + + $this->linkReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Link\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->optionReadService = $this->getMockBuilder('Magento\Bundle\Service\V1\Product\Option\ReadService') + ->disableOriginalConstructor() + ->getMock(); + + $this->productBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->setMethods(['setCustomAttribute']) + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeValue = $this->getMockBuilder('Magento\Framework\Service\Data\Eav\AttributeValue') + ->setMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->saveProcessor = $helper->getObject( + 'Magento\Bundle\Service\V1\Product\BundleProductSaveProcessor', + [ + 'linkWriteService' => $this->linkWriteService, + 'optionWriteService' => $this->optionWriteService, + 'linkReadService' => $this->linkReadService, + 'optionReadService' => $this->optionReadService, + 'productRepository' => $this->productRepository, + ] + ); + } + + public function testCreate() + { + $productSku = 'sku'; + $productOptions = [$this->productOption1, $this->productOption2]; + + $this->product->expects($this->any()) + ->method('getSku') + ->will($this->returnValue($productSku)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($productOptions)); + + $this->optionWriteService->expects($this->at(0)) + ->method('add') + ->with($productSku, $this->productOption1) + ->will($this->returnValue(1)); + $this->optionWriteService->expects($this->at(1)) + ->method('add') + ->with($productSku, $this->productOption2) + ->will($this->returnValue(2)); + + $this->assertEquals($productSku, $this->saveProcessor->create($this->product, $this->productData)); + $this->assertEquals($productSku, $this->saveProcessor->afterCreate($this->product, $this->productData)); + } + + public function testUpdate() + { + $product1Sku = 'sku1'; + $productOption1Sku = 'productOption1Sku'; + $productOption2Sku = 'productOption2Sku'; + $product1Options = [$this->productOption1, $this->productOption2]; + + $product2Options = [$this->productOption1]; + + $this->productRepository->expects($this->once()) + ->method('get') + ->with($product1Sku, true) + ->will($this->returnValue($this->product)); + $this->product->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + + $this->optionReadService->expects($this->once()) + ->method('getList') + ->with($product1Sku) + ->will($this->returnValue($product1Options)); + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($product2Options)); + $this->productOption1->expects($this->any()) + ->method('getId') + ->will($this->returnValue($productOption1Sku)); + $this->productOption2->expects($this->any()) + ->method('getId') + ->will($this->returnValue($productOption2Sku)); + $this->optionWriteService->expects($this->once()) + ->method('remove') + ->with($product1Sku, $productOption2Sku) + ->will($this->returnValue(1)); + + $this->assertEquals($product1Sku, $this->saveProcessor->update($product1Sku, $this->productData)); + } + + public function testDelete() + { + $productSku = 'sku1'; + $productOptions = [$this->productOption1]; + $productOption1Sku = 'productOption1Sku'; + + $this->productData->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(ProductType::TYPE_BUNDLE)); + $this->productData->expects($this->once()) + ->method('getSku') + ->will($this->returnValue($productSku)); + $this->productData->expects($this->once()) + ->method('getCustomAttribute') + ->with('bundle_product_options') + ->will($this->returnValue($this->attributeValue)); + $this->attributeValue->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($productOptions)); + $this->optionWriteService->expects($this->once()) + ->method('remove') + ->with($productSku, $productOption1Sku) + ->will($this->returnValue(1)); + $this->saveProcessor->delete($this->productData); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php index 2f262ccd0ac..64a8228cbf0 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Service/V1/Product/Link/ReadServiceTest.php @@ -44,9 +44,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase private $product; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Bundle\Service\V1\Data\Product\LinkConverter|\PHPUnit_Framework_MockObject_MockObject */ - private $metadataConverter; + private $linkConverter; /** * @var \Magento\Bundle\Model\Product\Type\Interceptor|\PHPUnit_Framework_MockObject_MockObject @@ -69,9 +69,9 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase private $option; /** - * @var \Magento\Bundle\Service\V1\Data\Product\Link\Metadata|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Bundle\Service\V1\Data\Product\Link|\PHPUnit_Framework_MockObject_MockObject */ - private $metadata; + private $link; private $storeId = 2; @@ -110,12 +110,12 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->metadata = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link\Metadata') + $this->link = $this->getMockBuilder('Magento\Bundle\Service\V1\Data\Product\Link') ->disableOriginalConstructor() ->getMock(); - $this->metadataConverter = $this->getMockBuilder( - 'Magento\Bundle\Service\V1\Data\Product\Link\MetadataConverter' + $this->linkConverter = $this->getMockBuilder( + 'Magento\Bundle\Service\V1\Data\Product\LinkConverter' ) ->setMethods(['createDataFromModel']) ->disableOriginalConstructor() @@ -125,7 +125,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase 'Magento\Bundle\Service\V1\Product\Link\ReadService', [ 'productRepository' => $this->productRepository, - 'metadataConverter' => $this->metadataConverter + 'linkConverter' => $this->linkConverter ] ); } @@ -157,11 +157,11 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->option->expects($this->any())->method('getSelections')->will($this->returnValue([$this->product])); - $this->metadataConverter->expects($this->once())->method('createDataFromModel') + $this->linkConverter->expects($this->once())->method('createDataFromModel') ->with($this->equalTo($this->product), $this->equalTo($this->product)) - ->will($this->returnValue($this->metadata)); + ->will($this->returnValue($this->link)); - $this->assertEquals([$this->metadata], $this->model->getChildren($productSku)); + $this->assertEquals([$this->link], $this->model->getChildren($productSku)); } /** @@ -177,7 +177,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue('simple')); - $this->assertEquals([$this->metadata], $this->model->getChildren($productSku)); + $this->assertEquals([$this->link], $this->model->getChildren($productSku)); } private function getOptions() 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 5b8e693b8bd..b59a8aba9dd 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 @@ -52,7 +52,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected $optionCollectionFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -97,7 +97,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') @@ -137,8 +137,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildToNotBundleProduct() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -158,8 +159,9 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildNonExistingOption() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -208,9 +210,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildLinkedProductIsComposite() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -274,9 +277,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildProductAlreadyExistsInOption() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -344,9 +348,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChildCouldNotSave() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( @@ -421,9 +426,10 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase public function testAddChild() { $productLink = $this->getMock( - 'Magento\Bundle\Service\V1\Product\Link\Data\ProductLink', array(), array(), '', false + 'Magento\Bundle\Service\V1\Data\Product\Link', array(), array(), '', false ); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); + $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( 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 index 0a6a3a975d1..e734af2def4 100644 --- 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 @@ -82,7 +82,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product') - ->setMethods(['__wakeup', 'getTypeId', 'getTypeInstance']) + ->setMethods(['__wakeup', 'getTypeId', 'getTypeInstance', 'getStoreId']) ->disableOriginalConstructor() ->getMock(); @@ -106,6 +106,28 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $productType = $this->getMockBuilder('Magento\Bundle\Model\Product\Type') + ->setMethods(['setStoreFilter', 'getSelectionsCollection']) + ->disableOriginalConstructor() + ->getMock(); + $this->product->expects($this->any()) + ->method('getTypeInstance') + ->will($this->returnValue($productType)); + $selectionsCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Selection\Collection') + ->setMethods(['getIterator']) + ->disableOriginalConstructor() + ->getMock(); + $productType->expects($this->any()) + ->method('getSelectionsCollection') + ->will($this->returnValue($selectionsCollection)); + $iterator = $this->getMockBuilder('Iterator') + ->setMethods(['getNext']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $selectionsCollection->expects($this->any()) + ->method('getIterator') + ->will($this->returnValue($iterator)); + $this->model = $objectManager->getObject( 'Magento\Bundle\Service\V1\Product\Option\ReadService', [ 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 4c7620a2bb5..4079abca16e 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 @@ -81,7 +81,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase $this->jsHelperMock = $this->getMock('Magento\Backend\Helper\Js', array(), array(), '', false); $this->storeMock = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->stockFilterMock = $this->getMock( 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php index 73a8d6c9984..362131c7965 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Category/ViewTest.php @@ -93,7 +93,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected $store; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -154,7 +154,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase $this->categoryFactory = $this->getMock('Magento\Catalog\Model\CategoryFactory', ['create'], [], '', false); $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->catalogDesign = $this->getMock('Magento\Catalog\Model\Design', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php index f8c70e06c0d..4b959c1ab33 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Helper/Product/Flat/IndexerTest.php @@ -36,7 +36,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -91,7 +91,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase $eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', array(), array(), '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_connectionMock = $this->getMock( 'Magento\Framework\DB\Adapter\Pdo\Mysql', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php index 69fab2654ee..1e52ec3d6e5 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ConfigTest.php @@ -240,7 +240,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $attribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue($storeLabel)); $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue($storeId)); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php index f21da8f4874..55f333c5a79 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/EraserTest.php @@ -64,7 +64,7 @@ class EraserTest extends \PHPUnit_Framework_TestCase array(2, 'store_2_flat'), ))); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Action\Eraser( $resource, $this->indexerHelper, diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index a85f6a2a6c5..bf9a82905cf 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -81,7 +81,7 @@ class RowTest extends \PHPUnit_Framework_TestCase $this->resource->expects($this->any())->method('getConnection') ->with('default') ->will($this->returnValue($this->connection)); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->store->expects($this->any())->method('getId')->will($this->returnValue('store_id_1')); $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue(array($this->store))); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php index bec88d18600..e72ca34b3d6 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/ObserverTest.php @@ -36,7 +36,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -70,7 +70,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php index ef9bb39d977..e1e7dc87034 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScopeTest.php @@ -55,7 +55,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock('Magento\Framework\Model\Context', array(), array(), '', false); $registryMock = $this->getMock('Magento\Framework\Registry', array(), array(), '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php index 7cd6d53bb37..aa3305eff96 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/FilterableAttributeListTest.php @@ -52,7 +52,7 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase '\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', array('create'), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->layerMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php index 7552c2b6d8b..274ef3f54e1 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Category/StateKeyTest.php @@ -43,7 +43,7 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock); } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php index 4e669792348..a2ba39af8f3 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/CollectionFilterTest.php @@ -56,7 +56,7 @@ class CollectionFilterTest extends \PHPUnit_Framework_TestCase $this->visibilityMock = $this->getMock('Magento\Catalog\Model\Product\Visibility', array(), array(), '', false); $this->catalogConfigMock = $this->getMock('\Magento\Catalog\Model\Config', array(), array(), '', false); $this->helperMock = $this->getMock('\Magento\CatalogSearch\Helper\Data', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->model = new CollectionFilter( $this->catalogConfigMock, $this->helperMock, $this->storeManagerMock, $this->visibilityMock diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php index 33c8811c8c5..61fb9fca6ac 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/FilterableAttributeListTest.php @@ -52,7 +52,7 @@ class FilterableAttributeListTest extends \PHPUnit_Framework_TestCase '\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory', array('create'), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false + '\Magento\Framework\StoreManagerInterface', array(), array(), '', false ); $this->layerMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php index a799898a55d..849614cd903 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Layer/Search/StateKeyTest.php @@ -48,7 +48,7 @@ class StateKeyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', array(), array(), '', false); $this->helperMock = $this->getMock('\Magento\CatalogSearch\Helper\Data', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php index 5c75256055c..2ef6965d466 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/LayerTest.php @@ -51,7 +51,7 @@ class LayerTest extends \PHPUnit_Framework_TestCase private $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $storeManager; @@ -131,7 +131,7 @@ class LayerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php index 6c4de178bc8..a11d85e686c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php @@ -44,7 +44,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $loggerMock = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); $currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); $configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php index 5def7e22bc2..6015c8d1211 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Frontend/ImageTest.php @@ -68,13 +68,13 @@ class ImageTest extends \PHPUnit_Framework_TestCase } /** - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ private function getMockedStoreManager() { $mockedStore = $this->getMockedStore(); - $mockBuilder = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface'); + $mockBuilder = $this->getMockBuilder('\Magento\Framework\StoreManagerInterface'); $mock = $mockBuilder->setMethods(['getStore']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php index 40bba460bfc..15d148650c1 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Source/CountryofmanufactureTest.php @@ -26,7 +26,7 @@ namespace Magento\Catalog\Model\Product\Attribute\Source; class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -47,7 +47,7 @@ class CountryofmanufactureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); $this->cacheConfig = $this->getMock('\Magento\Framework\App\Cache\Type\Config', array(), array(), '', false); $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php index 924d39fe481..09819abf92b 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ImageTest.php @@ -48,7 +48,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php index 3f440009fd9..0e4140e5b1a 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -92,7 +92,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase $store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index 0ee7ff05b41..6803d90bc60 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -184,7 +184,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMockForAbstractClass(); $storeManager->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php index bd83e808003..80c2c68ba0d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php @@ -106,7 +106,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Locale\FormatInterface'), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false, false), $this->getMock('Magento\Framework\Validator\UniversalFactory', array(), array(), '', false, false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\Factory', array(), array(), '', false), array() ) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php index 9be7df61744..76c0505d3c8 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php @@ -96,7 +96,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Entity\TypeFactory', array(), array(), '', false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\Framework\Validator\UniversalFactory', array(), array(), '', false), $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php index b7ef3e30b3e..444e06eb0da 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php @@ -36,7 +36,7 @@ class FlatTest extends \PHPUnit_Framework_TestCase protected $_store; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerInterface; @@ -44,7 +44,7 @@ class FlatTest extends \PHPUnit_Framework_TestCase { $this->_store = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); - $this->_storeManagerInterface = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerInterface = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->_storeManagerInterface->expects( $this->any() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php index 05b4c4a99e8..75895715421 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Link/Product/CollectionTest.php @@ -65,7 +65,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $universalFactoryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ @@ -108,7 +108,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $entity->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([])); $this->universalFactoryMock = $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false); $this->universalFactoryMock->expects($this->any())->method('create')->will($this->returnValue($entity)); - $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->storeManagerMock ->expects($this->any()) ->method('getStore') diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php index 3a0a0bdfe1e..4dc6aaa0f19 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/CollectionTest.php @@ -56,7 +56,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $optionsFactoryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; 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 469d333c07f..9c2faa09e2d 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 @@ -35,7 +35,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase protected $categoryTreeMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -74,7 +74,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php index 48506b08ed7..013f4a66419 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/Attribute/Media/ReadServiceTest.php @@ -124,7 +124,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase $this->storeMock = $this->getMock('\Magento\Store\Model\Store', array(), array(), '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock)); $this->setFactoryMock = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php index f65de7c8249..eaebb534794 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/GroupPriceServiceTest.php @@ -88,7 +88,7 @@ class GroupPriceServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('\Magento\Framework\StoreManagerInterface') ->setMethods(['getWebsite']) ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php new file mode 100644 index 00000000000..d08fe87792a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductLoadProcessorCompositeTest.php @@ -0,0 +1,140 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; +use Magento\TestFramework\Helper\ObjectManager; + +class ProductLoadProcessorCompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; + + /** @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite $loadProcessor */ + protected $loadProcessor; + + /** @var \Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite $loadProcessorMock */ + protected $loadProcessorMock; + + protected $processors; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->loadProcessorMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $this->processors = [ + [ + 'sortOrder' => 10, + 'type' => $this->loadProcessorMock + ] + ]; + $this->loadProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $this->processors] + ); + } + + public function testConstructor() + { + $loadProcessorMock = $this->createProductLoadProcessorCompositeMock(); + $processors = [ + [ + 'sortOrder' => 10, + 'type' => $loadProcessorMock + ] + ]; + $compositeProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $processors] + ); + $this->verifyLoadProcessorIsAdded($compositeProcessor, $loadProcessorMock); + } + + public function testLoad() + { + $productSku = '5'; + $productDataBuilder = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\ProductBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->loadProcessorMock + ->expects($this->once()) + ->method('load') + ->with($productSku, $productDataBuilder); + $loadProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'loadProcessors' => $this->processors] + ); + $loadProcessor->load($productSku, $productDataBuilder); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createProductLoadProcessorCompositeMock() + { + $productLoadProcessorCompositeMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['load']) + ->getMock(); + $productLoadProcessorCompositeMock->expects($this->any())->method('load'); + return $productLoadProcessorCompositeMock; + } + + /** + * @param ProductLoadProcessorInterface $compositeProcessor + * @param ProductLoadProcessorInterface $loadProcessorMock + */ + protected function verifyLoadProcessorIsAdded($compositeProcessor, $loadProcessorMock) + { + $loadProcessor = new \ReflectionProperty( + 'Magento\Catalog\Service\V1\Product\ProductLoadProcessorComposite', + 'productLoadProcessors' + ); + $loadProcessor->setAccessible(true); + $values = $loadProcessor->getValue($compositeProcessor); + $this->assertCount(1, $values, 'Load Processor is not registered.'); + $this->assertEquals($loadProcessorMock, $values[0], 'Load Processor is registered incorrectly.'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php new file mode 100644 index 00000000000..c109c97e5ea --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/ProductSaveProcessorCompositeTest.php @@ -0,0 +1,200 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Service\V1\Product; + +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; +use Magento\TestFramework\Helper\ObjectManager; + +class ProductSaveProcessorCompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelperMock; + + /** + * @var ObjectManager + */ + protected $objectManager; + + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + protected $saveProcessor; + + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessorMock */ + protected $saveProcessorMock; + + protected $processors; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelperMock = $this->getMockBuilder('Magento\Framework\ObjectManager\Helper\Composite') + ->disableOriginalConstructor() + ->setMethods(['filterAndSortDeclaredComponents']) + ->getMock(); + $this->compositeHelperMock + ->expects($this->any()) + ->method('filterAndSortDeclaredComponents') + ->will($this->returnArgument(0)); + $this->saveProcessorMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['create', 'update', 'delete']) + ->getMock(); + $this->processors = [ + [ + 'sortOrder' => 10, + 'type' => $this->saveProcessorMock + ] + ]; + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $this->saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + } + + public function testConstructor() + { + $saveProcessorMock = $this->createProductSaveProcessorCompositeMock(); + $processors = [ + [ + 'sortOrder' => 10, + 'type' => $saveProcessorMock + ] + ]; + $model = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $processors] + ); + $this->verifySaveProcessorIsAdded($model, $saveProcessorMock); + } + + + public function testCreate() + { + $expectedSku = 'test'; + $product = $this + ->getMockBuilder('\Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData->expects($this->once())->method('getSku')->will($this->returnValue($expectedSku)); + + $this->saveProcessorMock + ->expects($this->once()) + ->method('create') + ->with($product, $productData) + ->will($this->returnValue($expectedSku)); + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + + $actualSku = $saveProcessor->create($product, $productData); + $this->assertEquals($expectedSku, $actualSku, 'Save processor is not created'); + } + + public function testDelete() + { + $expectedSku = 'test'; + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->saveProcessorMock + ->expects($this->once()) + ->method('delete') + ->with($productData) + ->will($this->returnValue($expectedSku)); + /** @var \Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite $saveProcessor */ + $saveProcessor = $this->objectManager->getObject( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + ['compositeHelper' => $this->compositeHelperMock, 'saveProcessors' => $this->processors] + ); + $saveProcessor->delete($productData); + } + + public function testUpdate() + { + $expectedSku = 'test'; + $actualSku = '5'; + $productData = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $productData->expects($this->once())->method('getSku')->will($this->returnValue($expectedSku)); + + $this->saveProcessorMock + ->expects($this->once()) + ->method('update') + ->with($actualSku, $productData) + ->will($this->returnValue($expectedSku)); + + $this->assertEquals( + $expectedSku, + $this->saveProcessor->update(5, $productData), + 'Save processor is updated incorrectly' + ); + } + + /** + * @param string|null $sku + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function createProductSaveProcessorCompositeMock($sku = null) + { + $productSaveProcessorCompositeMock = $this + ->getMockBuilder('Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite') + ->disableOriginalConstructor() + ->setMethods(['create', 'update']) + ->getMock(); + if (!is_null($sku)) { + $productSaveProcessorCompositeMock->expects($this->any())->method('create')->will($this->returnValue($sku)); + $productSaveProcessorCompositeMock->expects($this->any())->method('update')->will($this->returnValue($sku)); + } + return $productSaveProcessorCompositeMock; + } + + /** + * @param ProductSaveProcessorInterface $model + * @param ProductSaveProcessorInterface $saveProcessorMock + */ + protected function verifySaveProcessorIsAdded($model, $saveProcessorMock) + { + $saveProcessor = new \ReflectionProperty( + 'Magento\Catalog\Service\V1\Product\ProductSaveProcessorComposite', + 'productSaveProcessors' + ); + $saveProcessor->setAccessible(true); + $values = $saveProcessor->getValue($model); + $this->assertCount(1, $values, 'Save Processor is not registered.'); + $this->assertEquals($saveProcessorMock, $values[0], 'Save Processor is registered incorrectly.'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php index b8e46e76971..8fd0c94936d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Product/TierPriceServiceTest.php @@ -88,7 +88,7 @@ class TierPriceServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->groupServiceMock = $this->getMock('\Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', array('getId', '__wakeup'), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php index 5630dc19d69..f7a41371eb7 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/ProductServiceTest.php @@ -130,7 +130,22 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->_productMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue($productId)); $this->_productMock->expects($this->at(1))->method('load')->with($productId); - $productService = $this->_createService(); + + $productData = $this->getMockBuilder('Magento\Catalog\Service\V1\Data\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->converterMock->expects($this->once()) + ->method('createProductDataFromModel') + ->with($this->_productMock) + ->will($this->returnValue($productData)); + + $productService = $this->_objectManager->getObject( + 'Magento\Catalog\Service\V1\ProductService', + [ + 'productLoader' => $this->_productLoaderMock, + 'converter' => $this->converterMock, + ] + ); $this->assertTrue($productService->delete($productSku)); } @@ -200,8 +215,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $productDataBuilder->setSku('test'); $productDataBuilder->setStoreId(10); $this->converterMock->expects($this->once()) - ->method('createProductDataFromModel') - ->will($this->returnValue($productDataBuilder->create())); + ->method('createProductBuilderFromModel') + ->will($this->returnValue($productDataBuilder)); $this->searchResultsBuilderMock->expects($this->once()) ->method('setItems') @@ -243,7 +258,13 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $this->_productMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue($productId)); $this->_productMock->expects($this->at(1))->method('load')->with($productId); - $this->converterMock->expects($this->once())->method('createProductDataFromModel')->with($this->_productMock); + $productDataBuilder = $this->getMockBuilder('\Magento\Catalog\Service\V1\Data\ProductBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->converterMock->expects($this->once()) + ->method('createProductBuilderFromModel') + ->with($this->_productMock) + ->will($this->returnValue($productDataBuilder)); $productService = $this->_objectManager->getObject( 'Magento\Catalog\Service\V1\ProductService', @@ -312,8 +333,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $initializationHelper->expects($this->once())->method('initialize')->with($productModel); - $productModel->expects($this->once())->method('validate'); - $productModel->expects($this->once())->method('save'); + $productModel->expects($this->any())->method('validate'); + $productModel->expects($this->any())->method('save'); $productSku = 'sku-001'; $productModel->expects($this->once())->method('getId')->will($this->returnValue(100)); @@ -481,8 +502,8 @@ class ProductServiceTest extends \PHPUnit_Framework_TestCase $initializationHelper->expects($this->once())->method('initialize')->with($productModel); $productTypeManager->expects($this->once())->method('processProduct')->with($productModel); - $productModel->expects($this->once())->method('validate'); - $productModel->expects($this->once())->method('save'); + $productModel->expects($this->any())->method('validate'); + $productModel->expects($this->any())->method('save'); $productSku = 'sku-001'; $productModel->expects($this->any())->method('getSku')->will($this->returnValue($productSku)); diff --git a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php index 4a9fc61ffaf..fadb811e344 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Import/Product/Type/OptionTest.php @@ -242,7 +242,7 @@ class OptionTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\ImportExport\Model\Resource\Import\Data', array(), array(), '', false), $this->getMock('Magento\Framework\App\Resource', array(), array(), '', false), $this->getMock('Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false), - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\ProductFactory', array(), array(), '', false), $this->getMock( 'Magento\Catalog\Model\Resource\Product\Option\CollectionFactory', diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php index 6bb83f07178..884e9acce54 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Stock/ItemTest.php @@ -62,7 +62,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogInventory\Helper\Minsaleqty|\PHPUnit_Framework_MockObject_MockObject */ protected $catalogInventoryMinsaleqty; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \Magento\CatalogInventory\Model\Stock\ItemRegistry|\PHPUnit_Framework_MockObject_MockObject */ @@ -113,7 +113,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase false ); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $this->stockItemRegistry = $this->getMock( '\Magento\CatalogInventory\Model\Stock\ItemRegistry', diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php index a8420516f5d..fdc6ff3dedd 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/RuleTest.php @@ -34,7 +34,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase /** @var ObjectManagerHelper */ protected $objectManagerHelper; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \PHPUnit_Framework_MockObject_MockObject */ @@ -51,7 +51,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeModel = $this->getMock('Magento\Store\Model\Store', array('__wakeup', 'getId'), array(), '', false); $this->combineFactory = $this->getMock( 'Magento\CatalogRule\Model\Rule\Condition\CombineFactory', diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php index a262d043754..92993c9df6b 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Helper/DataTest.php @@ -64,7 +64,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected $_filterManagerMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; @@ -76,7 +76,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->_escaperMock = $this->getMock('Magento\Framework\Escaper'); $this->_filterManagerMock = $this->getMock('Magento\Framework\Filter\FilterManager', [], [], '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\CatalogSearch\Helper\Data( $this->_contextMock, diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php index 1d41272b6b9..d8eba0c3fff 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Controller/CartTest.php @@ -36,7 +36,7 @@ class CartTest extends \PHPUnit_Framework_TestCase public function testGoBack() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', array(), array(), '', false); $responseMock->headersSentThrowsException = false; diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php new file mode 100644 index 00000000000..c1bcb590b01 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Controller/Onepage/IndexTest.php @@ -0,0 +1,217 @@ +<?php +/** + * Test for \Magento\Checkout\Controller\Onepage\Index + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Controller\Onepage; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManager; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + private $objectManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $dataMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $onepageMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $redirectMock; + + /** + * @var \Magento\Checkout\Controller\Onepage\Index + */ + private $model; + + public function setUp() + { + // mock objects + $this->objectManager = new ObjectManager($this); + $this->objectManagerMock = $this->basicMock('\Magento\Framework\ObjectManager'); + $this->dataMock = $this->basicMock('Magento\Checkout\Helper\Data'); + $this->quoteMock = $this->basicMock('\Magento\Sales\Model\Quote'); + $this->contextMock = $this->basicMock('\Magento\Framework\App\Action\Context'); + $this->sessionMock = $this->basicMock('\Magento\Customer\Model\Session'); + $this->onepageMock = $this->basicMock('\Magento\Checkout\Model\Type\Onepage'); + $this->viewMock = $this->basicMock('\Magento\Framework\App\ViewInterface'); + $this->layoutMock = $this->basicMock('\Magento\Framework\View\Layout'); + $this->requestMock = $this->basicMock('\Magento\Framework\App\RequestInterface'); + $this->responseMock = $this->basicMock('\Magento\Framework\App\ResponseInterface'); + $this->redirectMock = $this->basicMock('\Magento\Framework\App\Response\RedirectInterface'); + + // stubs + $this->basicStub($this->onepageMock, 'getQuote')->willReturn($this->quoteMock); + $this->basicStub($this->viewMock, 'getLayout')->willReturn($this->layoutMock); + $this->basicStub($this->layoutMock, 'getBlock') + ->willReturn($this->basicMock('Magento\Theme\Block\Html\Head')); + + // objectManagerMock + $objectManagerReturns = [ + ['Magento\Checkout\Helper\Data', $this->dataMock], + ['Magento\Checkout\Model\Type\Onepage', $this->onepageMock], + ['Magento\Checkout\Model\Session', $this->basicMock('Magento\Checkout\Model\Session')], + ['Magento\Customer\Model\Session', $this->basicMock('Magento\Customer\Model\Session')], + + ]; + $this->objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($objectManagerReturns)); + $this->basicStub($this->objectManagerMock, 'create') + ->willReturn($this->basicMock('Magento\Framework\UrlInterface')); + // context stubs + $this->basicStub($this->contextMock, 'getObjectManager')->willReturn($this->objectManagerMock); + $this->basicStub($this->contextMock, 'getView')->willReturn($this->viewMock); + $this->basicStub($this->contextMock, 'getRequest')->willReturn($this->requestMock); + $this->basicStub($this->contextMock, 'getResponse')->willReturn($this->responseMock); + $this->basicStub($this->contextMock, 'getMessageManager') + ->willReturn($this->basicMock('\Magento\Framework\Message\ManagerInterface')); + $this->basicStub($this->contextMock, 'getRedirect')->willReturn($this->redirectMock); + + + // SUT + $this->model = $this->objectManager->getObject('\Magento\Checkout\Controller\Onepage\Index', + [ + 'context' => $this->contextMock, + 'customerSession' => $this->sessionMock, + ] + ); + } + + public function testRegenerateSessionIdOnExecute() + { + //Stubs to control execution flow + $this->basicStub($this->dataMock, 'canOnepageCheckout')->willReturn(true); + $this->basicStub($this->quoteMock, 'hasItems')->willReturn(true); + $this->basicStub($this->quoteMock, 'getHasError')->willReturn(false); + $this->basicStub($this->quoteMock, 'validateMinimumAmount')->willReturn(true); + + //Expected outcomes + $this->sessionMock->expects($this->once()) + ->method('regenerateId'); + $this->viewMock->expects($this->once()) + ->method('renderLayout'); + + $this->model->execute(); + } + + public function testOnepageCheckoutNotAvailable() + { + + $this->basicStub($this->dataMock, 'canOnepageCheckout')->willReturn(false); + + $expectedPath = 'checkout/cart'; + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, $expectedPath, []); + + $this->model->execute(); + } + + public function testInvalidQuote() + { + $this->basicStub($this->quoteMock, 'hasError')->willReturn(true); + + $expectedPath = 'checkout/cart'; + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, $expectedPath, []); + + $this->model->execute(); + } + + /** + * @param \PHPUnit_Framework_MockObject_MockObject $mock + * @param string $method + * + * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker + */ + private function basicStub($mock, $method) + { + return $mock->expects($this->any()) + ->method($method) + ->withAnyParameters(); + } + + /** + * @param string $className + * @return \PHPUnit_Framework_MockObject_MockObject + */ + private function basicMock($className) + { + return $this->getMockBuilder($className) + ->disableOriginalConstructor() + ->getMock(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php index b3c40a76ad5..d3e1ff07b15 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php @@ -88,7 +88,7 @@ class CartTest extends \PHPUnit_Framework_TestCase $contextMock = $this->getMock('\Magento\Framework\App\Helper\Context', [], [], '', false); $contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilderMock)); $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->coreHelperMock = $this->getMock('\Magento\Core\Helper\Data', [], [], '', false); $this->scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); $this->cartMock = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); @@ -219,7 +219,7 @@ class CartTest extends \PHPUnit_Framework_TestCase */ public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $coreData = $this->getMock('\Magento\Core\Helper\Data', [], [], '', false); $scopeConfig = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface'); $checkoutCart = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index d1adc7cb5b2..47c9115bf63 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -141,7 +141,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ) ); - $this->_storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $this->_checkoutSession = $this->getMock('\Magento\Checkout\Model\Session', array(), array(), '', false); @@ -379,7 +379,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $rowTotal = 15; $roundPrice = 17; $expected = 17; - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', @@ -444,7 +444,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testGetBasePriceInclTaxWithoutQty() { - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', @@ -466,7 +466,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testGetBasePriceInclTax() { - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', array(), array(), '', false); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( '\Magento\Checkout\Helper\Data', diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php index ea5e864eba9..147c7fe1436 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php @@ -177,7 +177,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase $quoteFactory = $this->getMock('Magento\Sales\Model\QuoteFactory', array('create'), array(), '', false); $storage = $this->getMock('Magento\Framework\Session\Storage', null); $store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\ManagerInterface'); @@ -299,7 +299,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('getWebsiteId') ->will($this->returnValue($websiteId)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($store)); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php index 93c4e8b2c07..17d9a4bdd58 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -56,7 +56,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ protected $customerSessionMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -113,7 +113,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase $this->checkoutSessionMock = $this->getMock('Magento\Checkout\Model\Session', ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData'], [], '', false); $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->requestMock = $this->getMock( 'Magento\Framework\App\RequestInterface', ['isAjax', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'] 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 index 8dc87b47f2f..58b0718f83b 100644 --- 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 @@ -50,7 +50,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); $this->service = new ReadService($this->quoteLoaderMock, $this->converterMock, $this->storeManagerMock); 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 index 64bb4c6ffab..93bf3f8e14d 100644 --- 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 @@ -70,7 +70,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); 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 index 9c9f4f83871..180ebe59144 100644 --- 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 @@ -50,7 +50,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->converterMock = $this->getMock('\Magento\Checkout\Service\V1\Address\Converter', [], [], '', false); $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); 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 index f51418ace43..c25c0e7b708 100644 --- 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 @@ -70,7 +70,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->addressFactoryMock = $this->getMock( '\Magento\Sales\Model\Quote\AddressFactory', ['create', '__wakeup'], [], '', false ); 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 index cdfe50596c6..5b5a3fa5a51 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Cart/WriteServiceTest.php @@ -71,7 +71,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $this->quoteFactoryMock = $this->getMock( '\Magento\Sales\Model\QuoteFactory', ['create', '__wakeup'], [], '', false ); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); $this->quoteMock = diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php index b6a5e41231e..c88416c1b27 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/ReadServiceTest.php @@ -53,7 +53,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->couponBuilderMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php index 30585e2f9b6..584de65681b 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Coupon/WriteServiceTest.php @@ -71,7 +71,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->couponBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\CouponBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php index 746adf0ee7f..09d3eb7aa21 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/Data/Cart/ShippingMethodConverterTest.php @@ -67,7 +67,7 @@ class ShippingMethodConverterTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->builderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->currencyMock = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $this->shippingMethodMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethod', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php index 15278615af6..fe9d54fe9bf 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/ReadServiceTest.php @@ -66,7 +66,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMethodConverterMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Converter', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php index 86888e9abc7..28767afa987 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/PaymentMethod/WriteServiceTest.php @@ -66,7 +66,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->paymentMethodBuilderMock = $this->getMock( '\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod\Builder', [], [], '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php index ebcf79294b9..8d805647cca 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/ReadServiceTest.php @@ -79,7 +79,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new ObjectManager($this); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->methodBuilderMock = $this->getMock('\Magento\Checkout\Service\V1\Data\Cart\ShippingMethodBuilder', [], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php index 26e8390fd82..cdea76c91af 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Service/V1/ShippingMethod/WriteServiceTest.php @@ -67,7 +67,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->addressFactoryMock = $this->getMock('\Magento\Sales\Model\Quote\AddressFactory', [], [], '', false); $this->quoteLoaderMock = $this->getMock('\Magento\Checkout\Service\V1\QuoteLoader', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMock = $this->getMock( '\Magento\Sales\Model\Quote', [ diff --git a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php index acea4656774..c6711a9e705 100644 --- a/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/CheckoutAgreements/Service/V1/Agreement/ReadServiceTest.php @@ -76,7 +76,7 @@ class ReadServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->service = new ReadService( $this->factoryMock, diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php index ffc5ba421f7..189639f8ab2 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php @@ -239,7 +239,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_model->canUseAttribute($attribute)); } - public function testgetUsedProducts() + public function testGetUsedProducts() { $attributeCollection = $this->getMockBuilder( '\Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection' @@ -290,4 +290,81 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($productCollection)); $this->_model->getUsedProducts($product); } -} \ No newline at end of file + + /** + * @param int $productStore + * @param int $attributeStore + * + * @dataProvider getConfigurableAttributesAsArrayDataProvider + */ + public function testGetConfigurableAttributesAsArray($productStore, $attributeStore) + { + $attributeSource = $this->getMockForAbstractClass( + 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', + array(), + '', + false, + true, + true, + array('getAllOptions') + ); + $attributeSource->expects($this->any())->method('getAllOptions')->will($this->returnValue([])); + + $attributeFrontend = $this->getMockForAbstractClass( + 'Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend', + array(), + '', + false, + true, + true, + array('getLabel') + ); + $attributeFrontend->expects($this->any())->method('getLabel')->will($this->returnValue('Label')); + + $eavAttribute = $this->getMock( + 'Magento\Catalog\Model\Resource\Eav\Attribute', + array('getFrontend', 'getSource', 'getStoreLabel', '__wakeup', 'setStoreId', '__sleep'), + array(), + '', + false + ); + $eavAttribute->expects($this->any())->method('getFrontend')->will($this->returnValue($attributeFrontend)); + $eavAttribute->expects($this->any())->method('getSource')->will($this->returnValue($attributeSource)); + $eavAttribute->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Store Label')); + $eavAttribute->expects($this->any())->method('setStoreId')->with($attributeStore); + + $attribute = $this->getMockBuilder('\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute') + ->disableOriginalConstructor() + ->setMethods(['getProductAttribute', '__wakeup', '__sleep']) + ->getMock(); + $attribute->expects($this->any())->method('getProductAttribute')->will($this->returnValue($eavAttribute)); + + $product = $this->getMockBuilder('\Magento\Catalog\Model\Product') + ->setMethods(['getStoreId', 'getData', 'hasData', '__wakeup', '__sleep']) + ->disableOriginalConstructor() + ->getMock(); + $product->expects($this->any())->method('getStoreId')->will($this->returnValue($productStore)); + $product->expects($this->any())->method('hasData') + ->will($this->returnValueMap([ + ['_cache_instance_configurable_attributes', 1], + ])); + $product->expects($this->any())->method('getData') + ->will($this->returnValueMap([ + ['_cache_instance_configurable_attributes', null, [$attribute]], + ])); + + $result = $this->_model->getConfigurableAttributesAsArray($product); + $this->assertCount(1, $result); + } + + /** + * @return array + */ + public function getConfigurableAttributesAsArrayDataProvider() + { + return array( + array(5, 5), + array(null, 0), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php index 53e459fceeb..02a37672126 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Pricing/Price/AttributePriceTest.php @@ -65,7 +65,7 @@ class AttributePriceTest extends \PHPUnit_Framework_TestCase protected $regularPriceMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php index 9c311e2a7b5..feaaac019cd 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceTest.php @@ -147,7 +147,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue(new \Magento\Framework\Object())); diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php new file mode 100644 index 00000000000..9d67a7f81ff --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/IndexTest.php @@ -0,0 +1,136 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Contact\Controller\Index; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_view; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_url; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse', 'getView', 'getUrl'], + [], + '', + false + ); + + $this->_url = $this->getMockForAbstractClass('\Magento\Framework\UrlInterface', [], '', false); + + $context->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($this->_url)); + + $context->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + )); + + $context->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + )); + + $this->_view = $this->getMock( + '\Magento\Framework\App\ViewInterface', + [], + [], + '', + false + ); + + $context->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->_view)); + + $this->_controller = new \Magento\Contact\Controller\Index\Index( + $context, + $this->getMock('\Magento\Framework\Mail\Template\TransportBuilder', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Translate\Inline\StateInterface', [], '', false), + $this->_scopeConfig, + $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface', [], '', false) + ); + } + + public function testExecute() + { + $layout = $this->getMock( + '\Magento\Framework\View\Layout', + ['getBlock', 'initMessages'], + [], + '', + false + ); + $block = $this->getMockForAbstractClass( + '\Magento\Framework\View\Element\AbstractBlock', + ['setFormAction'], + '', + false + ); + $layout->expects($this->once()) + ->method('getBlock') + ->with('contactForm') + ->will($this->returnValue($block)); + + $this->_view->expects($this->once()) + ->method('loadLayout'); + + $this->_view->expects($this->exactly(2)) + ->method('getLayout') + ->will($this->returnValue($layout)); + + $layout->expects($this->once()) + ->method('initMessages'); + + $this->_view->expects($this->once()) + ->method('renderLayout'); + + $this->_controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.php new file mode 100644 index 00000000000..3e40b619580 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/Index/PostTest.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\Contact\Controller\Index; + +class PostTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_view; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_url; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_request; + + /** + * @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_redirect; + + /** + * @var \Magento\Framework\Mail\Template\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_transportBuilder; + + /** + * @var \Magento\Framework\Translate\Inline\StateInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_inlineTranslation; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_messageManager; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_storeManager; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', + ['isSetFlag'], + '', + false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse', 'getView', 'getUrl', 'getRedirect', 'getMessageManager'], + [], + '', + false + ); + $this->_url = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); + $this->_messageManager = $this->getMock('\Magento\Framework\Message\ManagerInterface', [], [], '', false); + $this->_request = $this->getMock('\Magento\Framework\App\Request\Http', ['getPost'], [], '', false); + $this->_redirect = $this->getMock('\Magento\Framework\App\Response\RedirectInterface', [], [], '', false); + $this->_view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false); + $this->_storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface', [], [], '', false); + $this->_transportBuilder = $this->getMock( + '\Magento\Framework\Mail\Template\TransportBuilder', + [], + [], + '', + false + ); + $this->_inlineTranslation = $this->getMock( + '\Magento\Framework\Translate\Inline\StateInterface', + [], + [], + '', + false + ); + $context->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($this->_request)); + + $context->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue( + $this->getMock('\Magento\Framework\App\ResponseInterface', [], [], '', false) + )); + + $context->expects($this->any()) + ->method('getMessageManager') + ->will($this->returnValue($this->_messageManager)); + + $context->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue($this->_url)); + + $context->expects($this->any()) + ->method('getRedirect') + ->will($this->returnValue($this->_redirect)); + + $context->expects($this->once()) + ->method('getView') + ->will($this->returnValue($this->_view)); + + $this->_controller = new \Magento\Contact\Controller\Index\Post( + $context, + $this->_transportBuilder, + $this->_inlineTranslation, + $this->_scopeConfig, + $this->_storeManager + ); + } + + public function testExecuteEmptyPost() + { + $this->_request->expects($this->once())->method('getPost')->will($this->returnValue([])); + $this->_redirect->expects($this->once())->method('redirect'); + $this->_controller->execute(); + } + + /** + * @dataProvider testPostDataProvider + */ + public function testExecutePostValidation($postData, $exceptionExpected) + { + $this->_request->expects($this->any()) + ->method('getPost') + ->will($this->returnValue($postData)); + + if ($exceptionExpected) { + $this->_messageManager->expects($this->once()) + ->method('addError'); + } + $this->_inlineTranslation->expects($this->once()) + ->method('resume'); + + $this->_inlineTranslation->expects($this->once()) + ->method('suspend'); + + $this->_controller->execute(); + } + + public function testPostDataProvider() + { + return [ + [['name' => null, 'comment' => null, 'email' => '', 'hideit' => 'no'], true], + [['name' => 'test', 'comment' => '', 'email' => '', 'hideit' => 'no'], true], + [['name' => '', 'comment' => 'test', 'email' => '', 'hideit' => 'no'], true], + [['name' => '', 'comment' => '', 'email' => 'test', 'hideit' => 'no'], true], + [['name' => '', 'comment' => '', 'email' => '', 'hideit' => 'no'], true], + [['name' => 'Name', 'comment' => 'Name', 'email' => 'invalidmail', 'hideit' => 'no'], true], + ]; + } + + public function testExecuteValidPost() + { + $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => 'valid@mail.com', 'hideit' => null]; + + $this->_request->expects($this->any()) + ->method('getPost') + ->will($this->returnValue($post)); + + $store = $this->getMock('\Magento\Store\Model\Store', ['getId', '__sleep', '__wakeup'], [], '', false); + + $store->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + + $this->_storeManager->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($store)); + + $transport = $this->getMock('\Magento\Framework\Mail\TransportInterface', [], [], '', false); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateIdentifier') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateOptions') + ->with([ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => 1 + ]) + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setTemplateVars') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setFrom') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('addTo') + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('setReplyTo') + ->with($post['email']) + ->will($this->returnSelf()); + + $this->_transportBuilder->expects($this->once()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + $transport->expects($this->once()) + ->method('sendMessage'); + + $this->_inlineTranslation->expects($this->once()) + ->method('resume'); + + $this->_inlineTranslation->expects($this->once()) + ->method('suspend'); + + $this->_controller->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php b/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.php new file mode 100644 index 00000000000..0617d59b394 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Controller/IndexTest.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\Contact\Controller; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Controller\Index|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_controller; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['isSetFlag'], '', false + ); + $context = $this->getMock( + '\Magento\Framework\App\Action\Context', + ['getRequest', 'getResponse'], + [], + '', + false + ); + + $context->expects( + $this->any() + )->method( + 'getRequest' + )->will( + $this->returnValue($this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false)) + ); + + $context->expects( + $this->any() + )->method( + 'getResponse' + )->will( + $this->returnValue( + $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface', [], '', false) + ) + ); + + $this->_controller = new \Magento\Contact\Controller\Index( + $context, + $this->getMock('\Magento\Framework\Mail\Template\TransportBuilder', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Translate\Inline\StateInterface', [], '', false), + $this->_scopeConfig, + $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface', [], '', false) + ); + } + + /** + * @expectedException \Magento\Framework\App\Action\NotFoundException + */ + public function testDispatch() + { + $this->_scopeConfig->expects( + $this->once() + )->method( + 'isSetFlag' + )->with( + \Magento\Contact\Controller\Index::XML_PATH_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will( + $this->returnValue(false) + ); + $this->_controller->dispatch( + $this->getMockForAbstractClass('\Magento\Framework\App\RequestInterface', [], '', false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php new file mode 100644 index 00000000000..b4c0a4cbc35 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.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\Contact\Helper; + +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_helper; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_scopeConfig; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerSession; + + /** + * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerViewHelper; + + public function setUp() + { + $this->_scopeConfig = $this->getMockForAbstractClass( + '\Magento\Framework\App\Config\ScopeConfigInterface', ['getValue'], '', false + ); + $this->_customerSession = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); + $this->_customerViewHelper = $this->getMock('\Magento\Customer\Helper\View', [], [], '', false); + + $this->_helper = new Data( + $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false), + $this->_scopeConfig, + $this->_customerSession, + $this->_customerViewHelper + ); + } + + public function testIsEnabled() + { + $this->_scopeConfig->expects($this->once()) + ->method('getValue') + ->will($this->returnValue('1')); + + $this->assertTrue(is_string($this->_helper->isEnabled())); + } + + public function testIsNotEnabled() + { + $this->_scopeConfig->expects($this->once()) + ->method('getValue') + ->will($this->returnValue(null)); + + $this->assertTrue(is_null($this->_helper->isEnabled())); + } + + public function testGetUserNameNotLoggedIn() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->assertEmpty($this->_helper->getUserName()); + } + + public function testGetUserName() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + + $objectBuilder = $this->getMockForAbstractClass( + '\Magento\Framework\Service\Data\AbstractSimpleObjectBuilder', + ['getData'], + '', + false + ); + $customerDataObject = new \Magento\Customer\Service\V1\Data\Customer($objectBuilder); + $this->_customerSession->expects($this->once()) + ->method('getCustomerDataObject') + ->will($this->returnValue($customerDataObject)); + + $this->_customerViewHelper->expects($this->once()) + ->method('getCustomerName') + ->will($this->returnValue(' customer name ')); + + $this->assertEquals('customer name', $this->_helper->getUserName()); + } + + public function testGetUserEmailNotLoggedIn() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->assertEmpty($this->_helper->getUserEmail()); + } + + public function testGetUserEmail() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + $customerDataObject = $this->getMock('\Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $customerDataObject->expects($this->once())->method('getEmail')->will($this->returnValue('customer@email.com')); + $this->_customerSession->expects($this->once()) + ->method('getCustomerDataObject') + ->will($this->returnValue($customerDataObject)); + + $this->assertEquals('customer@email.com', $this->_helper->getUserEmail()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php b/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.php new file mode 100644 index 00000000000..64763857927 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Contact/Model/System/Config/Backend/LinksTest.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\Contact\Model\System\Config\Backend; + +class LinksTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Contact\Model\System\Config\Backend\Links|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + public function setUp() + { + $this->_model = new Links( + $this->getMock('\Magento\Framework\Model\Context', [], [], '', false), + $this->getMock('\Magento\Framework\Registry', [], [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface', [], '', false), + $this->getMockForAbstractClass('\Magento\Framework\Model\Resource\AbstractResource', [], '', false), + $this->getMock('\Magento\Framework\Data\Collection\Db', [], [], '', false) + ); + } + + public function testGetIdentities() + { + $this->assertTrue(is_array($this->_model->getIdentities())); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php deleted file mode 100644 index 03ef891c9ea..00000000000 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.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\Core\App\FrontController\Plugin; - -class InstallTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Module\FrontController\Plugin\Install - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_dbUpdaterMock; - - /** - * @var \Closure - */ - protected $closureMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->_appStateMock = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); - $this->_cacheMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); - $this->_dbUpdaterMock = $this->getMock('\Magento\Framework\Module\UpdaterInterface'); - $this->closureMock = function () { - return 'Expected'; - }; - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); - $this->_model = new \Magento\Framework\Module\FrontController\Plugin\Install( - $this->_appStateMock, - $this->_cacheMock, - $this->_dbUpdaterMock - ); - } - - public function testAroundDispatch() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_cacheMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'data_upgrade' - )->will( - $this->returnValue(false) - ); - $this->_dbUpdaterMock->expects($this->once())->method('updateScheme'); - $this->_dbUpdaterMock->expects($this->once())->method('updateData'); - $this->_cacheMock->expects($this->once())->method('save')->with('true', 'data_upgrade'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php index d2e8053308b..b9cee5eb4bc 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php @@ -40,11 +40,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appState; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -92,7 +87,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase return true; }; $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); $this->_configMock = $this->getMock('Magento\Core\Model\File\Storage\Config', array(), array(), '', false); $this->_sync = $this->getMock('Magento\Core\Model\File\Storage\Synchronization', array(), array(), '', false); $this->_dirVerificationMock = $this->getMock( @@ -126,12 +120,10 @@ class MediaTest extends \PHPUnit_Framework_TestCase $map = array( array('Magento\Framework\App\Filesystem\DirectoryList\Verification', $this->_dirVerificationMock), - array('Magento\Framework\App\State', $this->_appState), array('Magento\Core\Model\File\Storage\Request', $this->_requestMock), array('Magento\Core\Model\File\Storage\Synchronization', $this->_sync) ); $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -150,18 +142,13 @@ class MediaTest extends \PHPUnit_Framework_TestCase unset($this->_model); } - public function testProcessRequestDoesNothingIfApplicationIsNotInstalled() - { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); - $this->_requestMock->expects($this->never())->method('getPathInfo'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); - } - + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not within media directory. + */ public function testProcessRequestCreatesConfigFileMediaDirectoryIsNotProvided() { $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -172,7 +159,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase 'params', $this->filesystemMock ); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_objectManagerMock->expects( $this->once() )->method( @@ -183,16 +169,19 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_configMock) ); $this->_configMock->expects($this->once())->method('save'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not allowed. + */ public function testProcessRequestReturnsNotFoundResponseIfResourceIsNotAllowed() { $this->_closure = function () { return false; }; $this->_model = new \Magento\Core\App\Media( - $this->_appState, $this->_objectManagerMock, $this->_requestMock, $this->_responseMock, @@ -203,8 +192,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase 'params', $this->filesystemMock ); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->once())->method('getPathInfo'); $this->_objectManagerMock->expects( $this->once() @@ -216,24 +203,25 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->_configMock) ); $this->_configMock->expects($this->once())->method('getAllowedResources')->will($this->returnValue(false)); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The specified path is not within media directory. + */ public function testProcessRequestReturnsNotFoundIfFileIsNotAllowed() { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_configMock->expects($this->never())->method('save'); $this->_requestMock->expects($this->once())->method('getPathInfo'); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->never())->method('getFilePath'); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->_model->launch(); } public function testProcessRequestReturnsFileIfItsProperlySynchronized() { $relativeFilePath = '_files'; $filePath = str_replace('\\', '/', __DIR__ . '/' . $relativeFilePath); - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects( $this->any() )->method( @@ -264,12 +252,11 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue(true) ); $this->_responseMock->expects($this->once())->method('setFilePath')->with($filePath); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->assertSame($this->_responseMock, $this->_model->launch()); } public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized() { - $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects( $this->any() )->method( @@ -286,6 +273,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->returnValue('non_existing_file_name') ); $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); - $this->assertEquals($this->_responseMock, $this->_model->launch()); + $this->assertSame($this->_responseMock, $this->_model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php index 29dcfbf615d..6be6a06216a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php @@ -88,7 +88,7 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->_store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_store->expects($this->any())->method('getId')->will($this->returnValue(20)); - $storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->once())->method('getStore')->with(null)->will($this->returnValue($this->_store)); $this->_resource = $this->getMock('Magento\Core\Model\Resource\Layout\Update', array(), array(), '', false); @@ -292,13 +292,19 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(self::FIXTURE_LAYOUT_XML, $this->_model->asString()); } - public function testLoadDbAppInstalled() + public function testLoadDbApp() { - $this->_appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $this->_resource->expects($this->once())->method('fetchUpdatesByHandle') - ->with('fixture_handle', $this->_theme, $this->_store) - ->will($this->returnValue(self::FIXTURE_LAYOUT_XML)); - + $this->_resource->expects( + $this->once() + )->method( + 'fetchUpdatesByHandle' + )->with( + 'fixture_handle', + $this->_theme, + $this->_store + )->will( + $this->returnValue(self::FIXTURE_LAYOUT_XML) + ); $this->assertEmpty($this->_model->getHandles()); $this->assertEmpty($this->_model->asString()); $handles = array('fixture_handle'); @@ -307,18 +313,6 @@ class MergeTest extends \PHPUnit_Framework_TestCase $this->assertXmlStringEqualsXmlString(self::FIXTURE_LAYOUT_XML, $this->_model->asString()); } - public function testLoadDbAppNotInstalled() - { - $this->_appState->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $this->_resource->expects($this->never())->method('fetchUpdatesByHandle'); - $this->assertEmpty($this->_model->getHandles()); - $this->assertEmpty($this->_model->asString()); - $handles = array('fixture_handle'); - $this->_model->load($handles); - $this->assertEquals($handles, $this->_model->getHandles()); - $this->assertEmpty($this->_model->asString()); - } - public function testGetFileLayoutUpdatesXml() { $errorString = "Theme layout update file '" . __DIR__ . "/_files/layout/file_wrong.xml' is not valid."; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php index 2fdb5b607e4..12163c3f448 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php @@ -38,7 +38,7 @@ class ScopeResolverTest extends \PHPUnit_Framework_TestCase public function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')->getMock(); + $this->_storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface')->getMock(); $this->_object = $objectManager->getObject( 'Magento\Core\Model\Url\ScopeResolver', array('storeManager' => $this->_storeManagerMock) diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php index df8df8bf3cb..12c28eeb161 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/View/DesignTest.php @@ -37,7 +37,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $flyweightThemeFactory = $this->getMock( '\Magento\Framework\View\Design\Theme\FlyweightFactory', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php deleted file mode 100644 index d28693237c0..00000000000 --- a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.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\Cron\App\Cron\Plugin; - -class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Cron\App\Cron\Plugin\ApplicationInitializer - */ - protected $model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $sidResolverMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - protected function setUp() - { - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->sidResolverMock = $this->getMock( - '\Magento\Framework\Session\SidResolverInterface', - array(), - array(), - '', - false - ); - $this->subjectMock = $this->getMock('Magento\Framework\App\Cron', array(), array(), '', false); - $this->model = new ApplicationInitializer( - $this->appStateMock, - $this->sidResolverMock - ); - } - - public function testBeforeExecutePerformsRequiredChecks() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); - $this->model->beforeLaunch($this->subjectMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php new file mode 100644 index 00000000000..e16e1861eee --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.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\Customer\Block\Adminhtml\Edit\Tab; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class ViewTest + * @package Magento\Customer\Block\Adminhtml\Edit\Tab + */ +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Block\Adminhtml\Edit\Tab\View + */ + protected $view; + + protected function setUp() + { + $customerAccountService = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $customerAddressService = $this->getMock('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); + $customerGroupService = $this->getMock('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); + $customerBuilder = $this->getMock('Magento\Customer\Service\V1\Data\CustomerBuilder', [], [], '', false); + $customerAddressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false); + $registry = $this->getMock('Magento\Framework\Registry'); + + $objectManagerHelper = new ObjectManagerHelper($this); + $this->view = $objectManagerHelper->getObject( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View', + [ + 'accountService' => $customerAccountService, + 'addressService' => $customerAddressService, + 'groupService' => $customerGroupService, + 'customerBuilder' => $customerBuilder, + 'addressHelper' => $customerAddressHelper, + 'registry' => $registry + ] + ); + } + + public function testGetTabLabel() + { + $this->assertEquals('Customer View', $this->view->getTabLabel()); + } + + public function testGetTabTitle() + { + $this->assertEquals('Customer View', $this->view->getTabTitle()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php index a27dad2bfbc..71ecdf4a58e 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php @@ -24,6 +24,8 @@ namespace Magento\Customer\Block\Widget; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; class DobTest extends \PHPUnit_Framework_TestCase { @@ -340,12 +342,30 @@ class DobTest extends \PHPUnit_Framework_TestCase */ public function getMinDateRangeDataProvider() { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); return array( array( - array(Dob::MIN_DATE_RANGE_KEY => strtotime(self::MIN_DATE)), + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => Dob::MIN_DATE_RANGE_KEY, + 'value' => strtotime(self::MIN_DATE) + ) + ) + ) + ), date('Y/m/d', strtotime(self::MIN_DATE)) ), - array(array(), null) + array( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ) + ), + null + ) ); } @@ -388,12 +408,30 @@ class DobTest extends \PHPUnit_Framework_TestCase */ public function getMaxDateRangeDataProvider() { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); return array( array( - array(Dob::MAX_DATE_RANGE_KEY => strtotime(self::MAX_DATE)), + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => Dob::MAX_DATE_RANGE_KEY, + 'value' => strtotime(self::MAX_DATE) + ) + ) + ) + ), date('Y/m/d', strtotime(self::MAX_DATE)) ), - array(array(), null) + array( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ) + ), + null + ) ); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php index 02e30e8900c..c4e1925ed7e 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php @@ -56,6 +56,21 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase */ protected $response; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlMock; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -63,7 +78,16 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase $this->customerHelperMock = $this->getMock('\Magento\Customer\Helper\Data', [], [], '', false); $this->redirectMock = $this->getMock('Magento\Framework\App\Response\RedirectInterface'); $this->accountServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); - $this->response = $this->getMock('Magento\Framework\App\ResponseInterface'); + $this->response = $this->getMock('Magento\Webapi\Controller\Response'); + $this->request = $this->getMockBuilder('Magento\Webapi\Controller\Request') + ->disableOriginalConstructor() + ->getMock(); + $this->urlFactoryMock = $this->getMockBuilder('\Magento\Framework\UrlFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->urlMock = $this->getMockBuilder('\Magento\Backend\Model\Url') + ->disableOriginalConstructor() + ->getMock(); $this->object = $objectManager->getObject('Magento\Customer\Controller\Account\CreatePost', [ 'response' => $this->response, @@ -71,6 +95,8 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase 'customerHelperData' => $this->customerHelperMock, 'redirect' => $this->redirectMock, 'customerAccountService' => $this->accountServiceMock, + 'request' => $this->request, + 'urlFactory' => $this->urlFactoryMock, ] ); } @@ -98,4 +124,24 @@ class CreatePostTest extends \PHPUnit_Framework_TestCase $this->object->execute(); } + + public function testRegenerateIdOnExecution() + { + $this->customerSession->expects($this->once()) + ->method('regenerateId'); + $this->customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + + $this->customerHelperMock->expects($this->once()) + ->method('isRegistrationAllowed') + ->will($this->returnValue(true)); + $this->request->expects($this->once()) + ->method('isPost') + ->will($this->returnValue(true)); + $this->urlFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->urlMock)); + $this->object->execute(); + } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php new file mode 100644 index 00000000000..e43e35c3a7c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.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\Customer\Controller\Adminhtml\Index; + +/** + * Class IndexTest + */ +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFlagMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $titleMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $breadcrumbsBlockMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $menuBlockMock; + + /** + * @var \Magento\Customer\Controller\Adminhtml\Index\Index + */ + protected $controller; + + protected function setUp() + { + $this->requestMock = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods(['setRedirect', 'getHeader', '__wakeup']) + ->getMock(); + $this->sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['unsCustomerData', '__wakeup', 'setIsUrlNotice']) + ->getMock(); + $this->actionFlagMock = $this->getMockBuilder('Magento\Framework\App\ActionFlag') + ->disableOriginalConstructor() + ->getMock(); + $this->titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') + ->disableOriginalConstructor() + ->getMock(); + + $this->breadcrumbsBlockMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Breadcrumbs') + ->disableOriginalConstructor() + ->getMock(); + + $this->menuBlockMock = $this->getMockBuilder('Magento\Backend\Block\Menu') + ->disableOriginalConstructor() + ->setMethods(['getMenuModel', 'getParentItems']) + ->getMock(); + $this->menuBlockMock->expects($this->any()) + ->method('getMenuModel') + ->willReturnSelf(); + $this->menuBlockMock->expects($this->any()) + ->method('getParentItems') + ->willReturn([]); + + $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $this->viewMock = $this->getMockBuilder('Magento\Backend\Model\View') + ->disableOriginalConstructor() + ->getMock(); + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->willReturn($this->layoutMock); + + $this->contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->willReturn($this->requestMock); + $this->contextMock->expects($this->any()) + ->method('getResponse') + ->willReturn($this->responseMock); + $this->contextMock->expects($this->any()) + ->method('getSession') + ->willReturn($this->sessionMock); + $this->contextMock->expects($this->any()) + ->method('getActionFlag') + ->willReturn($this->actionFlagMock); + $this->contextMock->expects($this->any()) + ->method('getTitle') + ->willReturn($this->titleMock); + $this->contextMock->expects($this->any()) + ->method('getView') + ->willReturn($this->viewMock); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->controller = $objectManager->getObject( + 'Magento\Customer\Controller\Adminhtml\Index\Index', + [ + 'context' => $this->contextMock, + ] + ); + } + + public function testExecuteAjax() + { + $this->requestMock->expects($this->once()) + ->method('getQuery') + ->with('ajax') + ->willReturn(true); + $this->assertNull($this->controller->execute()); + } + + public function testExecute() + { + $this->layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with('menu') + ->willReturn($this->menuBlockMock); + + $this->layoutMock->expects($this->at(1)) + ->method('getBlock') + ->with('breadcrumbs') + ->willReturn($this->breadcrumbsBlockMock); + $this->layoutMock->expects($this->at(2)) + ->method('getBlock') + ->with('breadcrumbs') + ->willReturn($this->breadcrumbsBlockMock); + + $this->requestMock->expects($this->once()) + ->method('getQuery') + ->with('ajax') + ->willReturn(false); + $this->sessionMock->expects($this->once()) + ->method('unsCustomerData'); + $this->assertNull($this->controller->execute()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php index ba2dea22266..b876104a7fd 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Helper/AddressTest.php @@ -37,7 +37,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\View\Element\BlockFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $blockFactory; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -61,7 +61,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\View\Element\BlockFactory' )->disableOriginalConstructor()->getMock(); $this->storeManager = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->scopeConfig = $this->getMockBuilder( 'Magento\Framework\App\Config\ScopeConfigInterface' diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php index 0fa79ebedf3..c61edf98034 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php @@ -44,7 +44,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected $_objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -108,7 +108,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase false ); $this->storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php index e640635f3d0..11cfa14ff07 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/StoreTest.php @@ -32,7 +32,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected $testable; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -40,9 +40,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); /** @var \Magento\Framework\Logger $logger */ - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ $this->testable = new Store($logger, $storeManager); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php index ac31a29e4e2..7247b735f50 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/WebsiteTest.php @@ -32,7 +32,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected $testable; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -40,9 +40,9 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase { $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); /** @var \Magento\Framework\Logger $logger */ - $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ + /** @var \Magento\Framework\StoreManagerInterface $storeManager */ $this->testable = new Website($logger, $storeManager); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php index 9866b13038b..826708a45bf 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php @@ -115,7 +115,7 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase false ); $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', array(), array(), '', false); - $this->visitorMock = $this->getMock('Magento\Log\Model\Visitor', array(), array(), '', false); + $this->visitorMock = $this->getMock('Magento\Customer\Model\Visitor', array(), array(), '', false); $this->customerFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->customerMock)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php index 242bf8ce56a..f63294001f5 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php @@ -25,6 +25,9 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; + class AbstractDataTest extends \PHPUnit_Framework_TestCase { const MODEL = 'MODEL'; @@ -221,13 +224,26 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase */ public function testValidateInputRule($value, $label, $inputValidation, $expectedOutput) { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue($label)); $this->_attributeMock->expects( $this->any() )->method( 'getValidationRules' )->will( - $this->returnValue(array('input_validation' => $inputValidation)) + $this->returnValue( + array( + new ValidationRule( + $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder') + ->populateWithArray( + array( + 'name' => 'input_validation', + 'value' => $inputValidation + ) + ) + ) + ) + ) ); $this->assertEquals($expectedOutput, $this->_model->validateInputRule($value)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php index 09cbf32f610..62ed6d46317 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php @@ -25,6 +25,9 @@ */ namespace Magento\Customer\Model\Metadata\Form; +use Magento\Customer\Service\V1\Data\Eav\ValidationRule; +use Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder; + class DateTest extends AbstractFormTestCase { /** @var \Magento\Customer\Model\Metadata\Form\Date */ @@ -86,12 +89,24 @@ class DateTest extends AbstractFormTestCase */ public function testValidateValue($value, $validation, $required, $expected) { + $validationRules = array(); + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $ruleBuilder = $helper->getObject('\Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder'); + $ruleBuilder->populateWithArray(array('name' => 'input_validation', 'value' => 'date')); + $validationRules[] = new ValidationRule($ruleBuilder); + if (is_array($validation)) { + foreach ($validation as $ruleName => $ruleValue) { + $ruleBuilder->populateWithArray(array('name' => $ruleName, 'value' => $ruleValue)); + $validationRules[] = new ValidationRule($ruleBuilder); + } + } + $this->attributeMetadataMock->expects( $this->any() )->method( 'getValidationRules' )->will( - $this->returnValue(array_merge(array('input_validation' => 'date'), $validation)) + $this->returnValue($validationRules) ); $this->attributeMetadataMock->expects($this->any())->method('isRequired')->will($this->returnValue($required)); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php index e7306a6aadb..2326f369cb7 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/SessionTest.php @@ -177,22 +177,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_model->loginById($customerId)); } - public function testLogin() - { - $customerId = 1; - $username = 'TestName'; - $password = 'TestPassword'; - - $customerDataMock = $this->prepareLoginDataMock($customerId); - - $this->customerAccountServiceMock->expects($this->once()) - ->method('authenticate') - ->with($this->equalTo($username), $this->equalTo($password)) - ->will($this->returnValue($customerDataMock)); - - $this->assertTrue($this->_model->login($username, $password)); - } - /** * @param $customerId * @return \PHPUnit_Framework_MockObject_MockObject diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php new file mode 100644 index 00000000000..2a29852f17b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/VisitorTest.php @@ -0,0 +1,182 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class VisitorTest + * @package Magento\Customer\Model + */ +class VisitorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Model\Visitor + */ + protected $visitor; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Customer\Model\Resource\Visitor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $session; + + protected function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->session = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData']) + ->getMock(); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods([ + 'beginTransaction', + '__sleep', + '__wakeup', + 'getIdFieldName', + 'save', + 'addCommitCallback', + 'commit' + ])->disableOriginalConstructor()->getMock(); + $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); + + $arguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\Customer\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->session, + 'resource' => $this->resource + ] + ); + + $this->visitor = $this->objectManagerHelper->getObject('Magento\Customer\Model\Visitor', $arguments); + } + + public function testInitByRequest() + { + $this->session->expects($this->once())->method('getSessionId') + ->will($this->returnValue('asdfhasdfjhkj2198sadf8sdf897')); + $this->visitor->initByRequest(null); + $this->assertEquals('asdfhasdfjhkj2198sadf8sdf897', $this->visitor->getSessionId()); + + $this->visitor->setData(['visitor_id' => 1]); + $this->visitor->initByRequest(null); + $this->assertNull($this->visitor->getSessionId()); + } + + public function testSaveByRequest() + { + $this->session->expects($this->once())->method('setVisitorData')->will($this->returnSelf()); + $this->assertSame($this->visitor, $this->visitor->saveByRequest(null)); + } + + public function testIsModuleIgnored() + { + $this->visitor = $this->objectManagerHelper->getObject( + 'Magento\Customer\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->session, + 'resource' => $this->resource, + 'ignores' => array('test_route_name' => true) + ] + ); + $request = new \Magento\Framework\Object(['route_name' => 'test_route_name']); + $action = new \Magento\Framework\Object(['request' => $request]); + $event = new \Magento\Framework\Object(['controller_action' => $action]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertTrue($this->visitor->isModuleIgnored($observer)); + } + + + public function testBindCustomerLogin() + { + $customer = new \Magento\Framework\Object(['id' => '1']); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['customer' => $customer]) + ]); + + $this->visitor->bindCustomerLogin($observer); + $this->assertTrue($this->visitor->getDoCustomerLogin()); + $this->assertEquals($customer->getId(), $this->visitor->getCustomerId()); + + $this->visitor->unsetData(); + $this->visitor->setCustomerId('2'); + $this->visitor->bindCustomerLogin($observer); + $this->assertNull($this->visitor->getDoCustomerLogin()); + $this->assertEquals('2', $this->visitor->getCustomerId()); + } + + public function testBindCustomerLogout() + { + $observer = new \Magento\Framework\Object(); + + $this->visitor->setCustomerId('1'); + $this->visitor->bindCustomerLogout($observer); + $this->assertTrue($this->visitor->getDoCustomerLogout()); + + $this->visitor->unsetData(); + $this->visitor->bindCustomerLogout($observer); + $this->assertNull($this->visitor->getDoCustomerLogout()); + } + + public function testBindQuoteCreate() + { + $quote = new \Magento\Framework\Object(['id' => '1', 'is_checkout_cart' => true]); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['quote' => $quote]) + ]); + $this->visitor->bindQuoteCreate($observer); + $this->assertTrue($this->visitor->getDoQuoteCreate()); + } + + public function testBindQuoteDestroy() + { + $quote = new \Magento\Framework\Object(['id' => '1']); + $observer = new \Magento\Framework\Object([ + 'event' => new \Magento\Framework\Object(['quote' => $quote]) + ]); + $this->visitor->bindQuoteDestroy($observer); + $this->assertTrue($this->visitor->getDoQuoteDestroy()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 976ff4fe3e0..3455908ed9d 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -72,7 +72,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase private $_eventManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ private $_storeManagerMock; @@ -2125,7 +2125,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase private function _setupStoreMock() { $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->_storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php index 4f2087e54b0..a6c0127f987 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php @@ -95,7 +95,7 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase private $_customerModelMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\StoreManagerInterface */ private $_storeManagerMock; @@ -849,7 +849,7 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase private function _setupStoreMock() { $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMock(); $this->_storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php index 062464a2d1f..0c7494afa2a 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataConverterTest.php @@ -101,16 +101,16 @@ class AttributeMetadataConverterTest extends \PHPUnit_Framework_TestCase $frontendInput = 'frontendInput'; $inputFilter = 'inputFilter'; $storeLabel = 'storeLabel'; - $isVisible = 'isVisible'; - $isRequired = 'isRequired'; - $multilineCount = 'multilineCount'; + $isVisible = true; + $isRequired = true; + $multilineCount = 0; $dataModel = 'dataModel'; $frontendLabel = 'frontendLabel'; $backendType = 'backendType'; $note = 'note'; - $isSystem = 'isSystem'; - $isUserDefined = 'isUserDefined'; - $sortOrder = 'sortOrder'; + $isSystem = true; + $isUserDefined = true; + $sortOrder = 0; $attribute->expects($this->once())->method('getAttributeCode')->will($this->returnValue($attributeCode)); $attribute->expects($this->once())->method('getFrontendInput')->will($this->returnValue($frontendInput)); diff --git a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php index ed75a2751b1..6b6cd3fd380 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php @@ -95,7 +95,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_coreHelper = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); $this->_store = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->_store)); $currencyFactory = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php index 9752806fb31..e9e77e8a278 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/PriceCurrencyTest.php @@ -32,7 +32,7 @@ class PriceCurrencyTest extends \PHPUnit_Framework_TestCase protected $priceCurrency; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php index 6513fe96cb4..21df0fce084 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php @@ -26,23 +26,127 @@ namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Download class LinksTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable_Links + * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links */ - protected $_block; + protected $block; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productModel; + + /** + * @var \Magento\Downloadable\Model\Product\Type + */ + protected $downloadableProductModel; + + /** + * @var \Magento\Downloadable\Model\Link + */ + protected $downloadableLinkModel; + + /** + * @var \Magento\Framework\Escaper + */ + protected $escaper; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @var \Magento\Backend\Model\Url + */ + protected $urlBuilder; protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $urlBuilder = $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false); + $this->urlBuilder = $this->getMock('Magento\Backend\Model\Url', array('getUrl'), array(), '', false); $attributeFactory = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', array(), array(), '', false); $urlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', array(), array(), '', false); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath', + 'ensureFileInFilesystem', + 'getFileSize' + ), + array(), + '', + false + ); + $this->productModel = $this->getMock( + 'Magento\Catalog\Model\Product', + array( + '__wakeup', + 'getTypeId', + 'getTypeInstance', + 'getStoreId' + ), + array(), + '', + false + ); + $this->downloadableProductModel = $this->getMock( + '\Magento\Downloadable\Model\Product\Type', + array( + '__wakeup', + 'getLinks' + ), + array(), + '', + false + ); + $this->downloadableLinkModel = $this->getMock( + '\Magento\Downloadable\Model\Link', + array( + '__wakeup', + 'getId', + 'getTitle', + 'getPrice', + 'getNumberOfDownloads', + 'getLinkUrl', + 'getLinkType', + 'getSampleFile', + 'getSampleType', + 'getSortOrder', + 'getLinkFile', + 'getStoreTitle' + ), + array(), + '', + false + ); + + $this->coreRegistry = $this->getMock( + '\Magento\Framework\Registry', + array( + '__wakeup', + 'registry' + ), + array(), + '', + false + ); + + $this->escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); - $this->_block = $objectManagerHelper->getObject( + $this->block = $objectManagerHelper->getObject( 'Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links', array( - 'urlBuilder' => $urlBuilder, - 'Magento\Eav\Model\Entity\AttributeFactory' => $attributeFactory, - 'Magento\Backend\Model\UrlFactory' => $urlFactory + 'urlBuilder' => $this->urlBuilder, + 'attributeFactory' => $attributeFactory, + 'urlFactory' => $urlFactory, + 'coreRegistry' => $this->coreRegistry, + 'escaper' => $this->escaper, + 'downloadableFile' => $this->fileHelper ) ); } @@ -52,6 +156,75 @@ class LinksTest extends \PHPUnit_Framework_TestCase */ public function testGetConfig() { - $this->assertInstanceOf('Magento\Framework\Object', $this->_block->getConfig()); + $this->assertInstanceOf('Magento\Framework\Object', $this->block->getConfig()); + } + + public function testGetLinkData() + { + $expectingFileData = array( + 'file' => array( + 'file' => 'file/link.gif', + 'name' => '<a href="final_url">link.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ), + 'sample_file' => array( + 'file' => 'file/sample.gif', + 'name' => '<a href="final_url">sample.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ) + ); + + $this->productModel->expects($this->any())->method('getTypeId') + ->will($this->returnValue('downloadable')); + $this->productModel->expects($this->any())->method('getTypeInstance') + ->will($this->returnValue($this->downloadableProductModel)); + $this->productModel->expects($this->any())->method('getStoreId') + ->will($this->returnValue(0)); + $this->downloadableProductModel->expects($this->any())->method('getLinks') + ->will($this->returnValue(array($this->downloadableLinkModel))); + $this->coreRegistry->expects($this->any())->method('registry') + ->will($this->returnValue($this->productModel)); + $this->downloadableLinkModel->expects($this->any())->method('getId') + ->will($this->returnValue(1)); + $this->downloadableLinkModel->expects($this->any())->method('getTitle') + ->will($this->returnValue('Link Title')); + $this->downloadableLinkModel->expects($this->any())->method('getPrice') + ->will($this->returnValue('10')); + $this->downloadableLinkModel->expects($this->any())->method('getNumberOfDownloads') + ->will($this->returnValue('6')); + $this->downloadableLinkModel->expects($this->any())->method('getLinkUrl') + ->will($this->returnValue(null)); + $this->downloadableLinkModel->expects($this->any())->method('getLinkType') + ->will($this->returnValue('file')); + $this->downloadableLinkModel->expects($this->any())->method('getSampleFile') + ->will($this->returnValue('file/sample.gif')); + $this->downloadableLinkModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->downloadableLinkModel->expects($this->any())->method('getSortOrder') + ->will($this->returnValue(0)); + $this->downloadableLinkModel->expects($this->any())->method('getLinkFile') + ->will($this->returnValue('file/link.gif')); + $this->downloadableLinkModel->expects($this->any())->method('getStoreTitle') + ->will($this->returnValue('Store Title')); + $this->escaper->expects($this->any())->method('escapeHtml') + ->will($this->returnValue('Link Title')); + $this->fileHelper->expects($this->any())->method('getFilePath') + ->will($this->returnValue('/file/path/link.gif')); + $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem') + ->will($this->returnValue(true)); + $this->fileHelper->expects($this->any())->method('getFileSize') + ->will($this->returnValue('1.1')); + $this->urlBuilder->expects($this->any())->method('getUrl') + ->will($this->returnValue('final_url')); + $linkData = $this->block->getLinkData(); + foreach ($linkData as $link) { + $fileSave = $link->getFileSave(0); + $sampleFileSave = $link->getSampleFileSave(0); + $this->assertEquals($expectingFileData['file'], $fileSave); + $this->assertEquals($expectingFileData['sample_file'], $sampleFileSave); + + } } } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php index 7bbd7748a9f..ee80025890f 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php @@ -26,16 +26,117 @@ namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Download class SamplesTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links + * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples */ - protected $_block; + protected $block; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productModel; + + /** + * @var \Magento\Downloadable\Model\Product\Type + */ + protected $downloadableProductModel; + + /** + * @var \Magento\Downloadable\Model\Sample + */ + protected $downloadableSampleModel; + + /** + * @var \Magento\Framework\Escaper + */ + protected $escaper; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Framework\Registry + */ + protected $coreRegistry; + + /** + * @var \Magento\Backend\Model\Url + */ + protected $urlBuilder; protected function setUp() { $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_block = $objectManagerHelper->getObject( + + $this->urlBuilder = $this->getMock('Magento\Backend\Model\Url', array('getUrl'), array(), '', false); + $urlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', array(), array(), '', false); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath', + 'ensureFileInFilesystem', + 'getFileSize' + ), + array(), + '', + false + ); + $this->productModel = $this->getMock( + 'Magento\Catalog\Model\Product', + array( + '__wakeup', + 'getTypeId', + 'getTypeInstance', + 'getStoreId' + ), + array(), + '', + false + ); + $this->downloadableProductModel = $this->getMock( + '\Magento\Downloadable\Model\Product\Type', + array( + '__wakeup', + 'getSamples' + ), + array(), + '', + false + ); + $this->downloadableSampleModel = $this->getMock( + '\Magento\Downloadable\Model\Sample', + array( + '__wakeup', + 'getId', + 'getTitle', + 'getSampleFile', + 'getSampleType', + 'getSortOrder' + ), + array(), + '', + false + ); + $this->coreRegistry = $this->getMock( + '\Magento\Framework\Registry', + array( + '__wakeup', + 'registry' + ), + array(), + '', + false + ); + $this->escaper = $this->getMock('\Magento\Framework\Escaper', array('escapeHtml'), array(), '', false); + $this->block = $objectManagerHelper->getObject( 'Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples', - array('urlBuilder' => $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false)) + array( + 'urlBuilder' => $this->urlBuilder, + 'urlFactory' => $urlFactory, + 'coreRegistry' => $this->coreRegistry, + 'escaper' => $this->escaper, + 'downloadableFile' => $this->fileHelper) ); } @@ -44,6 +145,56 @@ class SamplesTest extends \PHPUnit_Framework_TestCase */ public function testGetConfig() { - $this->assertInstanceOf('Magento\Framework\Object', $this->_block->getConfig()); + $this->assertInstanceOf('Magento\Framework\Object', $this->block->getConfig()); + } + + public function testGetSampleData() + { + $expectingFileData = array( + 'sample_file' => array( + 'file' => 'file/sample.gif', + 'name' => '<a href="final_url">sample.gif</a>', + 'size' => '1.1', + 'status' => 'old' + ) + ); + + $this->productModel->expects($this->any())->method('getTypeId') + ->will($this->returnValue('downloadable')); + $this->productModel->expects($this->any())->method('getTypeInstance') + ->will($this->returnValue($this->downloadableProductModel)); + $this->productModel->expects($this->any())->method('getStoreId') + ->will($this->returnValue(0)); + $this->downloadableProductModel->expects($this->any())->method('getSamples') + ->will($this->returnValue(array($this->downloadableSampleModel))); + $this->coreRegistry->expects($this->any())->method('registry') + ->will($this->returnValue($this->productModel)); + $this->downloadableSampleModel->expects($this->any())->method('getId') + ->will($this->returnValue(1)); + $this->downloadableSampleModel->expects($this->any())->method('getTitle') + ->will($this->returnValue('Sample Title')); + $this->downloadableSampleModel->expects($this->any())->method('getSampleUrl') + ->will($this->returnValue(null)); + $this->downloadableSampleModel->expects($this->any())->method('getSampleFile') + ->will($this->returnValue('file/sample.gif')); + $this->downloadableSampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->downloadableSampleModel->expects($this->any())->method('getSortOrder') + ->will($this->returnValue(0)); + $this->escaper->expects($this->any())->method('escapeHtml') + ->will($this->returnValue('Sample Title')); + $this->fileHelper->expects($this->any())->method('getFilePath') + ->will($this->returnValue('/file/path/sample.gif')); + $this->fileHelper->expects($this->any())->method('ensureFileInFilesystem') + ->will($this->returnValue(true)); + $this->fileHelper->expects($this->any())->method('getFileSize') + ->will($this->returnValue('1.1')); + $this->urlBuilder->expects($this->any())->method('getUrl') + ->will($this->returnValue('final_url')); + $sampleData = $this->block->getSampleData(); + foreach ($sampleData as $sample) { + $fileSave = $sample->getFileSave(0); + $this->assertEquals($expectingFileData['sample_file'], $fileSave); + } } } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php new file mode 100644 index 00000000000..1f67f12178b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php @@ -0,0 +1,261 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class LinkTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link */ + protected $link; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface + */ + protected $response; + + /** + * @var \Magento\Downloadable\Model\Link + */ + protected $linkModel; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Downloadable\Helper\Download + */ + protected $downloadHelper; + + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + array( + 'getParam', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getCookie' + ) + ); + $this->response = $this->getMock( + '\Magento\Framework\App\ResponseInterface', + array( + 'setHttpResponseCode', + 'clearBody', + 'sendHeaders', + 'sendResponse', + 'setHeader' + ) + ); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath' + ), + array(), + '', + false + ); + $this->downloadHelper = $this->getMock( + 'Magento\Downloadable\Helper\Download', + array( + 'setResource', + 'getFilename', + 'getContentType', + 'output', + 'getFileSize', + 'getContentDisposition' + ), + array(), + '', + false + ); + $this->linkModel = $this->getMock( + '\Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link', + array( + 'load', + 'getId', + 'getLinkType', + 'getLinkUrl', + 'getSampleUrl', + 'getSampleType', + 'getBasePath', + 'getBaseSamplePath', + 'getLinkFile', + 'getSampleFile' + ), + array(), + '', + false + ); + $this->objectManager = $this->getMock( + '\Magento\Framework\ObjectManager\ObjectManager', + array( + 'create', + 'get' + ), + array(), + '', + false + ); + + $this->link = $this->objectManagerHelper->getObject( + 'Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link', + [ + 'objectManager' => $this->objectManager, + 'request' => $this->request, + 'response' => $this->response + ] + ); + } + + /** + * @dataProvider executeDataProvider + * @param string $fileType + */ + public function testExecuteFile($fileType) + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->request->expects($this->at(1))->method('getParam')->with('type', 0) + ->will($this->returnValue($fileType)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\File') + ->will($this->returnValue($this->fileHelper)); + $this->objectManager->expects($this->at(2))->method('get')->with('Magento\Downloadable\Model\Link') + ->will($this->returnValue($this->linkModel)); + $this->objectManager->expects($this->at(3))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->fileHelper->expects($this->once())->method('getFilePath') + ->will($this->returnValue('filepath/'. $fileType . '.jpg')); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('link.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('file')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->linkModel->expects($this->any())->method('get' . $fileType . 'Type') + ->will($this->returnValue('file')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->linkModel)); + + $this->link->execute(); + } + + /** + * @dataProvider executeDataProvider + * @param string $fileType + */ + public function testExecuteUrl($fileType) + { + $this->request->expects($this->at(0))->method('getParam') + ->with('id', 0)->will($this->returnValue(1)); + $this->request->expects($this->at(1))->method('getParam') + ->with('type', 0)->will($this->returnValue($fileType)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('link.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('url')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->linkModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->linkModel->expects($this->once())->method('get' . $fileType . 'Type') + ->will($this->returnValue('url')); + $this->linkModel->expects($this->once())->method('get' . $fileType . 'Url') + ->will($this->returnValue('http://url.magento.com')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->linkModel)); + + $this->link->execute(); + } + + /** + * @return array + */ + public function executeDataProvider() + { + return array( + array('link'), + array('sample') + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php new file mode 100644 index 00000000000..e61e06da409 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.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\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class SampleTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample */ + protected $sample; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Framework\App\ResponseInterface + */ + protected $response; + + /** + * @var \Magento\Downloadable\Model\Sample + */ + protected $sampleModel; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\Downloadable\Helper\File + */ + protected $fileHelper; + + /** + * @var \Magento\Downloadable\Helper\Download + */ + protected $downloadHelper; + + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + + $this->request = $this->getMock( + 'Magento\Framework\App\RequestInterface', + array( + 'getParam', + 'getModuleName', + 'setModuleName', + 'getActionName', + 'setActionName', + 'getCookie' + ) + ); + $this->response = $this->getMock( + '\Magento\Framework\App\ResponseInterface', + array( + 'setHttpResponseCode', + 'clearBody', + 'sendHeaders', + 'sendResponse', + 'setHeader' + ) + ); + $this->fileHelper = $this->getMock( + '\Magento\Downloadable\Helper\File', + array( + 'getFilePath' + ), + array(), + '', + false + ); + $this->downloadHelper = $this->getMock( + 'Magento\Downloadable\Helper\Download', + array( + 'setResource', + 'getFilename', + 'getContentType', + 'output', + 'getFileSize', + 'getContentDisposition' + ), + array(), + '', + false + ); + $this->sampleModel = $this->getMock( + '\Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample', + array( + 'load', + 'getId', + 'getSampleType', + 'getSampleUrl', + 'getBasePath', + 'getBaseSamplePath', + 'getSampleFile', + ), + array(), + '', + false + ); + $this->objectManager = $this->getMock( + '\Magento\Framework\ObjectManager\ObjectManager', + array( + 'create', + 'get' + ), + array(), + '', + false + ); + $this->sample = $this->objectManagerHelper->getObject( + 'Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample', + array( + 'objectManager' => $this->objectManager, + 'request' => $this->request, + 'response' => $this->response + ) + ); + } + + /** + * Execute download sample file action + */ + public function testExecuteFile() + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\File') + ->will($this->returnValue($this->fileHelper)); + $this->objectManager->expects($this->at(2))->method('get')->with('Magento\Downloadable\Model\Sample') + ->will($this->returnValue($this->sampleModel)); + $this->objectManager->expects($this->at(3))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->fileHelper->expects($this->once())->method('getFilePath') + ->will($this->returnValue('filepath/sample.jpg')); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('sample.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('file')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->sampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('file')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->sampleModel)); + + $this->sample->execute(); + } + + /** + * Execute download sample url action + */ + public function testExecuteUrl() + { + $this->request->expects($this->at(0))->method('getParam')->with('id', 0) + ->will($this->returnValue(1)); + $this->response->expects($this->once())->method('setHttpResponseCode') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('clearBody') + ->will($this->returnSelf()); + $this->response->expects($this->any())->method('setHeader') + ->will($this->returnSelf()); + $this->response->expects($this->once())->method('sendHeaders') + ->will($this->returnSelf()); + $this->objectManager->expects($this->at(1))->method('get')->with('Magento\Downloadable\Helper\Download') + ->will($this->returnValue($this->downloadHelper)); + $this->downloadHelper->expects($this->once())->method('setResource') + ->will($this->returnSelf()); + $this->downloadHelper->expects($this->once())->method('getFilename') + ->will($this->returnValue('sample.jpg')); + $this->downloadHelper->expects($this->once())->method('getContentType') + ->will($this->returnSelf('url')); + $this->downloadHelper->expects($this->once())->method('getFileSize') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('getContentDisposition') + ->will($this->returnValue(null)); + $this->downloadHelper->expects($this->once())->method('output') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('load') + ->will($this->returnSelf()); + $this->sampleModel->expects($this->once())->method('getId') + ->will($this->returnValue('1')); + $this->sampleModel->expects($this->any())->method('getSampleType') + ->will($this->returnValue('url')); + $this->objectManager->expects($this->once())->method('create') + ->will($this->returnValue($this->sampleModel)); + + $this->sample->execute(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php index f0a63231c88..f7e4cd0e1b0 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Helper/DownloadTest.php @@ -30,7 +30,14 @@ use Magento\Framework\Filesystem\Directory\ReadInterface as DirReadInterface; use Magento\Downloadable\Helper\File as DownloadableFile; /** - * @runInSeparateProcess + * @bug https://github.com/sebastianbergmann/phpunit/issues/314 + * Workaround: use the "require_once" below and declare "preserveGlobalState disabled" in the test class + */ +require_once __DIR__ . '/../../../../framework/bootstrap.php'; + +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled */ class DownloadTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php index 8e005ca910a..da4bbfb6efa 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Attribute/CollectionTest.php @@ -61,7 +61,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $entityTypeMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -94,7 +94,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase ->method('getEntityType') ->will($this->returnValue($this->entityTypeMock)); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnSelf()); diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php index e67ba201eca..efcf54deb8e 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/Option/CollectionTest.php @@ -56,7 +56,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected $coreResourceMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -101,7 +101,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase false ); $this->storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php b/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php index 5cc0a39112c..aae7ab9a9f4 100644 --- a/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Email/Block/Adminhtml/Template/PreviewTest.php @@ -71,7 +71,7 @@ class PreviewTest extends \PHPUnit_Framework_TestCase $design = $this->getMock('Magento\Framework\View\DesignInterface'); $store = $this->getMock('Magento\Store\Model\Store', array('getId', '__wakeup'), array(), '', false); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue(null)); $storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$store])); @@ -158,7 +158,7 @@ class PreviewTest extends \PHPUnit_Framework_TestCase $eventManage = $this->getMock('Magento\Framework\Event\ManagerInterface'); $scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $design = $this->getMock('Magento\Framework\View\DesignInterface'); - $storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue(null)); $storeManager->expects($this->any())->method('getStores')->will($this->returnValue([])); diff --git a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php index 9736c734575..627a354c85d 100644 --- a/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php +++ b/dev/tests/unit/testsuite/Magento/Fedex/Model/CarrierTest.php @@ -68,7 +68,7 @@ class CarrierTest extends \PHPUnit_Framework_TestCase $store = $this->getMock('Magento\Store\Model\Store', ['getBaseCurrencyCode', '__wakeup'], [], '', false); $storeManager = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', [ 'getStore', 'setIsSingleStoreModeAllowed', diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php new file mode 100644 index 00000000000..2fd488c5459 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/BootstrapTest.php @@ -0,0 +1,248 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\App; + +class BootstrapTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\AppInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $application; + + /** + * @var \Magento\Framework\App\ObjectManagerFactory | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerFactory; + + /** + * @var \Magento\Framework\ObjectManager\ObjectManager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManager; + + /** + * @var \Magento\Framework\Logger | \PHPUnit_Framework_MockObject_MockObject + */ + protected $logger; + + /** + * @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject + */ + protected $dirs; + + /** + * @var \Magento\Framework\Filesystem\Directory\ReadInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $configDir; + + /** + * @var MaintenanceMode | \PHPUnit_Framework_MockObject_MockObject + */ + protected $maintenanceMode; + + /** + * @var \Magento\Framework\App\Bootstrap | \PHPUnit_Framework_MockObject_MockObject + */ + protected $bootstrapMock; + + public function setUp() + { + $this->objectManagerFactory = $this->getMock('\Magento\Framework\App\ObjectManagerFactory', [], [], '', false); + $this->objectManager = $this->getMockForAbstractClass('\Magento\Framework\ObjectManager'); + $this->dirs = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', ['getDir'], [], '', false); + $this->maintenanceMode = $this->getMock('\Magento\Framework\App\MaintenanceMode', ['isOn'], [], '', false); + $filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); + + $this->logger = $this->getMock('Magento\Framework\Logger', [], [], '', false); + + $mapObjectManager = [ + ['Magento\Framework\App\Filesystem\DirectoryList', $this->dirs], + ['Magento\Framework\App\MaintenanceMode', $this->maintenanceMode], + ['Magento\Framework\App\Filesystem', $filesystem], + ['Magento\Framework\Logger', $this->logger] + ]; + + $this->objectManager->expects($this->any())->method('get') + ->will(($this->returnValueMap($mapObjectManager))); + + $this->configDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\ReadInterface'); + + $filesystem->expects($this->any())->method('getDirectoryRead') + ->will(($this->returnValue($this->configDir))); + + $this->application = $this->getMockForAbstractClass('\Magento\Framework\AppInterface'); + + $this->objectManager->expects($this->any())->method('create') + ->will(($this->returnValue($this->application))); + + $this->objectManagerFactory->expects($this->any())->method('create') + ->will(($this->returnValue($this->objectManager))); + + $this->bootstrapMock = $this->getMock('\Magento\Framework\App\Bootstrap', + ['assertMaintenance', 'assertInstalled', 'getIsExpected', 'isInstalled', 'terminate'], + [$this->objectManagerFactory, '', ['value1', 'value2']] + ); + } + + public function testGetParams() + { + $testParams = ['testValue1', 'testValue2']; + $bootstrap = self::createBootstrap($testParams); + $this->assertSame($testParams, $bootstrap->getParams()); + } + + /** + * Creates a bootstrap object + * + * @param array $testParams + * @return Bootstrap + */ + private function createBootstrap($testParams = ['value1', 'value2']) + { + return new Bootstrap($this->objectManagerFactory, '', $testParams); + } + + public function testCreateApplication() + { + $bootstrap = self::createBootstrap(); + $testArgs = ['arg1', 'arg2']; + $this->assertSame($this->application, $bootstrap->createApplication('someApplicationType', $testArgs)); + } + + public function testGetObjectManager() + { + $bootstrap = self::createBootstrap(); + $this->assertSame($this->objectManager, $bootstrap->getObjectManager()); + } + + public function testGetDirList() + { + $bootstrap = self::createBootstrap(); + $this->assertSame($this->dirs, $bootstrap->getDirList()); + } + + public function testIsDeveloperMode() + { + $bootstrap = self::createBootstrap(); + $this->assertFalse($bootstrap->isDeveloperMode()); + $testParams = [State::PARAM_MODE => State::MODE_DEVELOPER]; + $bootstrap = self::createBootstrap($testParams); + $this->assertTrue($bootstrap->isDeveloperMode()); + } + + public function testRunNoErrors() + { + $responseMock = $this->getMockForAbstractClass('\Magento\Framework\App\ResponseInterface'); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance')->will($this->returnValue(null)); + $this->bootstrapMock->expects($this->once())->method('assertInstalled')->will($this->returnValue(null)); + $this->application->expects($this->once())->method('launch')->willReturn($responseMock); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithMaintenanceErrors() + { + $expectedException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance') + ->will($this->throwException($expectedException)); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithInstallErrors() + { + $expectedException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance')->will($this->returnValue(null)); + $this->bootstrapMock->expects($this->once())->method('assertInstalled') + ->will($this->throwException($expectedException)); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + public function testRunWithBothErrors() + { + $expectedMaintenanceException = new \Exception(''); + $this->bootstrapMock->expects($this->once())->method('assertMaintenance') + ->will($this->throwException($expectedMaintenanceException)); + $this->bootstrapMock->expects($this->never())->method('assertInstalled'); + $this->bootstrapMock->expects($this->once())->method('terminate')->with($expectedMaintenanceException); + $this->application->expects($this->once())->method('catchException')->willReturn(false); + $this->bootstrapMock->run($this->application); + } + + /** + * @param bool $isOn + * @param bool $isExpected + * + * @dataProvider assertMaintenanceDataProvider + */ + public function testAssertMaintenance($isOn, $isExpected) + { + $bootstrap = self::createBootstrap([Bootstrap::PARAM_REQUIRE_MAINTENANCE => $isExpected]); + $this->maintenanceMode->expects($this->once())->method('isOn')->willReturn($isOn); + $this->application->expects($this->never())->method('launch'); + $this->application->expects($this->once())->method('catchException')->willReturn(true); + $bootstrap->run($this->application); + $this->assertEquals(Bootstrap::ERR_MAINTENANCE, $bootstrap->getErrorCode()); + } + + /** + * @return array + */ + public function assertMaintenanceDataProvider() + { + return [ + [true, false], + [false, true] + ]; + } + + /** + * @param bool $isInstalled + * @param bool $isExpected + * + * @dataProvider assertInstalledDataProvider + */ + public function testAssertInstalled($isInstalled, $isExpected) + { + $bootstrap = self::createBootstrap([Bootstrap::PARAM_REQUIRE_IS_INSTALLED => $isExpected]); + $this->configDir->expects($this->once())->method('isExist')->willReturn($isInstalled); + $this->application->expects($this->never())->method('launch'); + $this->application->expects($this->once())->method('catchException')->willReturn(true); + $bootstrap->run($this->application); + $this->assertEquals(Bootstrap::ERR_IS_INSTALLED, $bootstrap->getErrorCode()); + } + + /** + * @return array + */ + public function assertInstalledDataProvider() + { + return [ + [false, true], + [true, false], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php index 14344781c3e..3562b981dc9 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Cache/StateTest.php @@ -43,14 +43,13 @@ class StateTest extends \PHPUnit_Framework_TestCase /** * @param string $cacheType * @param array $typeOptions - * @param bool $appInstalled * @param bool $banAll * @param bool $expectedIsEnabled * @dataProvider isEnabledDataProvider */ - public function testIsEnabled($cacheType, $typeOptions, $appInstalled, $banAll, $expectedIsEnabled) + public function testIsEnabled($cacheType, $typeOptions, $banAll, $expectedIsEnabled) { - $model = $this->_buildModel($typeOptions, array(), $appInstalled, $banAll); + $model = $this->_buildModel($typeOptions, array(), $banAll); $actualIsEnabled = $model->isEnabled($cacheType); $this->assertEquals($expectedIsEnabled, $actualIsEnabled); } @@ -64,35 +63,24 @@ class StateTest extends \PHPUnit_Framework_TestCase 'enabled' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('some_type' => false, 'cache_type' => true), - 'appInstalled' => true, 'banAll' => false, 'expectedIsEnabled' => true ), 'disabled' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('some_type' => true, 'cache_type' => false), - 'appInstalled' => true, 'banAll' => false, 'expectedIsEnabled' => false ), 'unknown is disabled' => array( 'cacheType' => 'unknown_cache_type', 'typeOptions' => array('some_type' => true), - 'appInstalled' => true, - 'banAll' => false, - 'expectedIsEnabled' => false - ), - 'disabled, when app is not installed' => array( - 'cacheType' => 'cache_type', - 'typeOptions' => array('cache_type' => true), - 'appInstalled' => false, 'banAll' => false, 'expectedIsEnabled' => false ), 'disabled, when all caches are banned' => array( 'cacheType' => 'cache_type', 'typeOptions' => array('cache_type' => true), - 'appInstalled' => true, 'banAll' => true, 'expectedIsEnabled' => false ) @@ -104,14 +92,12 @@ class StateTest extends \PHPUnit_Framework_TestCase * * @param array|false $cacheTypeOptions * @param array|false $resourceTypeOptions - * @param bool $appInstalled * @param bool $banAll * @return \Magento\Framework\App\Cache\StateInterface */ protected function _buildModel( $cacheTypeOptions, $resourceTypeOptions = false, - $appInstalled = true, $banAll = false ) { $this->_cacheFrontend = $this->getMock('Magento\Framework\Cache\FrontendInterface'); @@ -144,13 +130,9 @@ class StateTest extends \PHPUnit_Framework_TestCase $this->returnValue($resourceTypeOptions) ); - $appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $appState->expects($this->any())->method('isInstalled')->will($this->returnValue($appInstalled)); - $this->_model = new \Magento\Framework\App\Cache\State( $this->_resource, $cacheFrontendPool, - $appState, $banAll ); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php deleted file mode 100644 index 6a743df42d8..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/EntryPoint/EntryPointTest.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\EntryPoint; - -class EntryPointTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\App\EntryPoint\EntryPoint - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_objectManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_responseMock; - - /** - * @var string - */ - protected $_rootDir; - - /** - * @return void - */ - protected function setUp() - { - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_responseMock = $this->getMock('Magento\Framework\App\Response\Http', array(), array(), '', false); - $this->_rootDir = realpath(__DIR__ . '/../../../../../../../'); - } - - /** - * @return void - */ - public function testRunExecutesApplication() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array(), - $this->_objectManagerMock - ); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects($this->once())->method('launch')->will($this->returnValue($this->_responseMock)); - $this->_objectManagerMock->expects( - $this->once() - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - $this->assertNull($this->_model->run($applicationName)); - } - - /** - * @return void - */ - public function testRunCatchesExceptionThrownByApplicationDeveloperMode() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array('MAGE_MODE' => 'developer'), - $this->_objectManagerMock - ); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects( - $this->once() - )->method( - 'launch' - )->will( - $this->throwException(new \Exception('Something went wrong.')) - ); - $this->_objectManagerMock->expects( - $this->once() - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - // clean output - ob_start(); - $this->assertNull($this->_model->run($applicationName)); - ob_end_clean(); - } - - /** - * @return void - */ - public function testRunCatchesExceptionThrownByApplicationNonDeveloperMode() - { - $this->_model = new \Magento\Framework\App\EntryPoint\EntryPoint( - $this->_rootDir, - array(), - $this->_objectManagerMock - ); - - $exception = new \Exception('Something went wrong.'); - - $applicationName = '\Magento\Framework\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\Framework\AppInterface'); - $applicationMock->expects( - $this->once() - )->method( - 'launch' - )->will( - $this->throwException($exception) - ); - - $loggerMock = $this->getMock( - '\Magento\Framework\Logger', - array(), - array(), - '', - false - ); - $loggerMock->expects( - $this->once() - )->method( - 'logException' - )->will( - $this->throwException($exception) - ); - - $this->_objectManagerMock->expects( - $this->at(0) - )->method( - 'create' - )->with( - $applicationName, - array() - )->will( - $this->returnValue($applicationMock) - ); - $this->_objectManagerMock->expects( - $this->at(1) - )->method( - 'get' - )->with( - 'Magento\Framework\Logger' - )->will( - $this->returnValue($loggerMock) - ); - - // clean output - ob_start(); - $this->assertNull($this->_model->run($applicationName)); - ob_end_clean(); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php deleted file mode 100644 index da7af2a173e..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Error/HandlerTest.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php -/** - * Unit Test for \Magento\Framework\App\Error\Handler - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 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\App\Error; - -class HandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * Logger mock - * - * @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject - */ - protected $logger; - - /** - * Filesystem mock - * - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystem; - - /** - * App state mock - * - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject - */ - protected $appState; - - /** - * Handler instance - * - * @var \Magento\Framework\App\Error\Handler - */ - protected $handler; - - protected function setUp() - { - $this->logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); - $this->filesystem = $this->getMock('Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->handler = new \Magento\Framework\App\Error\Handler($this->logger, $this->filesystem, $this->appState); - } - - /** - * Test for processException method print - * - * @covers \Magento\Framework\Error\Handler::processException - */ - public function testProcessExceptionPrint() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - $exception = new \Exception('TestMessage'); - - ob_start(); - $this->handler->processException($exception); - $actualResult = ob_get_contents(); - ob_end_clean(); - $this->assertRegExp('/TestMessage/', $actualResult); - } - - /** - * Test for processException method report - * - * @covers \Magento\Framework\Error\Handler::processException - * @runInSeparateProcess - */ - public function testProcessExceptionReport() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT) - ); - $this->filesystem->expects( - $this->atLeastOnce() - )->method( - 'getPath' - )->with( - \Magento\Framework\App\Filesystem::PUB_DIR - )->will( - $this->returnValue(dirname(__DIR__) . '/../../_files') - ); - - $exception = new \Exception('TestMessage'); - $this->handler->processException($exception); - } - - /** - * Test for setting error handler and logging - * - * @covers \Magento\Framework\Error\Handler::handler - * @throws \Exception - */ - public function testErrorHandlerLogging() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT) - ); - $this->logger->expects( - $this->once() - )->method( - 'log' - )->with( - $this->stringContains('testErrorHandlerLogging'), - \Zend_Log::ERR - ); - set_error_handler(array($this->handler, 'handler')); - try { - trigger_error('testErrorHandlerLogging', E_USER_NOTICE); - restore_error_handler(); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - } - - /** - * Test for setting error handler and printing - * - * @covers \Magento\Framework\Error\Handler::handler - * @expectedException \Exception - * @throws \Exception - */ - public function testErrorHandlerPrint() - { - $this->appState->expects( - $this->any() - )->method( - 'getMode' - )->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - set_error_handler(array($this->handler, 'handler')); - try { - trigger_error('testErrorHandlerPrint', E_USER_NOTICE); - } catch (\Exception $e) { - restore_error_handler(); - throw $e; - } - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php similarity index 78% rename from dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php rename to dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php index 06f2dd04a68..e231e27ebc6 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Error/HandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/ErrorHandlerTest.php @@ -21,29 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\Error; -/** - * Class HandlerTest - */ -class HandlerTest extends \PHPUnit_Framework_TestCase +namespace Magento\Framework\App; + +class ErrorHandlerTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Error\Handler + * @var \Magento\Framework\App\ErrorHandler */ protected $object; protected function setUp() { - $this->object = new Handler(); - } - - public function testProcessException() - { - $expectedMessage = 'test message'; - - $this->expectOutputRegex('/(' . $expectedMessage . ')\s*?.*(internal function)((.*\s.*)*)({main})/'); - $this->object->processException(new \Exception($expectedMessage), []); + $this->object = new ErrorHandler(); } /** @@ -61,13 +51,6 @@ class HandlerTest extends \PHPUnit_Framework_TestCase public function handlerProvider() { return [ - [E_STRICT, 'error_string', 'pear', true], - [E_DEPRECATED, 'error_string', 'pear', true], - [E_STRICT, 'pear', 0, true], - [E_DEPRECATED, 'pear', 0, true], - [E_STRICT, 'pear', 'pear', true], - [E_DEPRECATED, 'pear', 'pear', true], - [E_WARNING, 'open_basedir', 'pear', true], [0, 'DateTimeZone::__construct', 0, false], [0, 0, 0, false] ]; diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php index 542006ab7cb..ef893a633d0 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Filesystem/DirectoryList/VerificationTest.php @@ -81,7 +81,7 @@ class VerificationTest extends \PHPUnit_Framework_TestCase * @param string $mode * @param array $expectedDirs * @dataProvider notWritableDataProvider - * @expectedException \Magento\Framework\BootstrapException + * @expectedException \Magento\Framework\App\InitException */ public function testNotWritable($mode, $expectedDirs) { @@ -114,7 +114,7 @@ class VerificationTest extends \PHPUnit_Framework_TestCase * @param string $mode * @param array $expectedDirs * @dataProvider createExceptionDataProvider - * @expectedException \Magento\Framework\BootstrapException + * @expectedException \Magento\Framework\App\InitException */ public function testCreateException($mode, $expectedDirs) { diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php index 96fb6af315d..8deeb7f74a7 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/HttpTest.php @@ -31,11 +31,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected $_objectManager; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_stateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -82,11 +77,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase $areaListMock->expects($this->once())->method('getCodeByFrontName')->with($frontName)->will( $this->returnValue($areaCode) ); - $this->_stateMock = $this->getMockBuilder('Magento\Framework\App\State') - ->disableOriginalConstructor() - ->setMethods(['setAreaCode', 'getMode']) - ->getMock(); - $this->_stateMock->expects($this->once())->method('setAreaCode')->with($areaCode); $areaConfig = []; $configLoaderMock = $this->getMockBuilder( 'Magento\Framework\App\ObjectManager\ConfigLoader' @@ -133,12 +123,11 @@ class HttpTest extends \PHPUnit_Framework_TestCase 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'configLoader' => $configLoaderMock, - 'state' => $this->_stateMock, 'filesystem' => $this->_filesystemMock ] ); } - + public function testLaunchSuccess() { $this->_eventManagerMock->expects($this->once())->method('dispatch')->with( @@ -148,7 +137,11 @@ class HttpTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->_responseMock, $this->_http->launch()); } - public function testLaunchDispatchException() + /** + * @expectedException \Exception + * @expectedExceptionMessage Message + */ + public function testLaunchException() { $this->_frontControllerMock->expects($this->once())->method('dispatch')->with($this->_requestMock)->will( $this->returnCallback( @@ -157,14 +150,6 @@ class HttpTest extends \PHPUnit_Framework_TestCase } ) ); - $this->_stateMock->expects($this->once())->method('getMode')->will( - $this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER) - ); - $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(500); - - $this->_responseMock->expects($this->once())->method('setBody')->with( - $this->matchesRegularExpression('/Message[\n]+<pre>Message[\n]*(.|\n)*<\/pre>/') - ); - $this->assertSame($this->_responseMock, $this->_http->launch()); + $this->_http->launch(); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php new file mode 100644 index 00000000000..c7b0e0ffa90 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/App/MaintenanceModeTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\App; + +class MaintenanceModeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var MaintenanceMode + */ + protected $model; + + /** + * @var \Magento\Framework\Filesystem\Directory\WriteInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $flagDir ; + + protected function setUp() + { + $this->flagDir = $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface'); + $filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); + $filesystem->expects($this->any()) + ->method('getDirectoryWrite') + ->will($this->returnValue($this->flagDir)); + + $this->model = new MaintenanceMode($filesystem); + } + + public function testIsOnInitial() + { + $this->flagDir->expects($this->once())->method('isExist') + ->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->assertFalse($this->model->isOn()); + } + + public function testSetMaintenanceModeOn() + { + $this->flagDir->expects($this->at(0))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->flagDir->expects($this->at(1))->method('touch')->will($this->returnValue(true)); + $this->flagDir->expects($this->at(2))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(true)); + $this->flagDir->expects($this->at(3))->method('isExist')->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue(false)); + + + $this->assertFalse($this->model->isOn()); + $this->assertTrue($this->model->set(true)); + $this->assertTrue($this->model->isOn()); + } + + public function testSetMaintenanceModeOff() + { + $this->flagDir->expects($this->at(0))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(true)); + $this->flagDir->expects($this->at(1))->method('delete')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + $this->flagDir->expects($this->at(2))->method('isExist')->with(MaintenanceMode::FLAG_FILENAME) + ->will($this->returnValue(false)); + + $this->assertFalse($this->model->set(false)); + $this->assertFalse($this->model->isOn()); + } + + public function testSetAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('writeFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue(true)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('')); + + $this->model->setAddresses(''); + $this->assertEquals([''], $this->model->getAddressInfo()); + } + + public function testSetSingleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('writeFile') + ->will($this->returnValue(10)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1')); + + $this->model->setAddresses('address1'); + $this->assertEquals(['address1'], $this->model->getAddressInfo()); + } + + public function testOnSetMultipleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, true], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('writeFile') + ->will($this->returnValue(10)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1,10.50.60.123')); + + $expectedArray = ['address1', '10.50.60.123']; + $this->model->setAddresses('address1,10.50.60.123'); + $this->assertEquals($expectedArray, $this->model->getAddressInfo()); + $this->assertFalse($this->model->isOn('address1')); + $this->assertTrue($this->model->isOn('address3')); + } + + public function testOffSetMultipleAddresses() + { + $mapIsExist = [ + [MaintenanceMode::FLAG_FILENAME, false], + [MaintenanceMode::IP_FILENAME, true] + ]; + $this->flagDir->expects($this->any())->method('isExist')->will($this->returnValueMap($mapIsExist)); + $this->flagDir->expects($this->any())->method('delete')->will($this->returnValueMap($mapIsExist)); + + $this->flagDir->expects($this->any())->method('readFile') + ->with(MaintenanceMode::IP_FILENAME) + ->will($this->returnValue('address1,10.50.60.123')); + + $expectedArray = ['address1', '10.50.60.123']; + $this->model->setAddresses('address1,10.50.60.123'); + $this->assertEquals($expectedArray, $this->model->getAddressInfo()); + $this->assertFalse($this->model->isOn('address1')); + $this->assertFalse($this->model->isOn('address3')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php index 971325cc79f..e3e0e1de7ac 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/PageCache/VersionTest.php @@ -104,6 +104,11 @@ class VersionTest extends \PHPUnit_Framework_TestCase ->with(Version::COOKIE_PERIOD) ->will($this->returnSelf()); + $publicCookieMetadataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(false) + ->will($this->returnSelf()); + $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') ->with() diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php index ef6d099e019..0af640c1449 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/Response/HttpTest.php @@ -93,8 +93,10 @@ class HttpTest extends \PHPUnit_Framework_TestCase $data = ['some-vary-key' => 'some-vary-value']; $expectedCookieName = Http::COOKIE_VARY_STRING; $expectedCookieValue = sha1(serialize($data)); - $publicCookieMetadataMock = $this->getMock('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata'); - $publicCookieMetadataMock->expects($this->once()) + $sensitiveCookieMetadataMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata') + ->disableOriginalConstructor() + ->getMock(); + $sensitiveCookieMetadataMock->expects($this->once()) ->method('setPath') ->with('/') ->will($this->returnSelf()); @@ -107,15 +109,15 @@ class HttpTest extends \PHPUnit_Framework_TestCase ); $this->cookieMetadataFactoryMock->expects($this->once()) - ->method('createPublicCookieMetadata') + ->method('createSensitiveCookieMetadata') ->with() ->will( - $this->returnValue($publicCookieMetadataMock) + $this->returnValue($sensitiveCookieMetadataMock) ); $this->cookieManagerMock->expects($this->once()) - ->method('setPublicCookie') - ->with($expectedCookieName, $expectedCookieValue, $publicCookieMetadataMock); + ->method('setSensitiveCookie') + ->with($expectedCookieName, $expectedCookieValue, $sensitiveCookieMetadataMock); $this->model->sendVary(); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php deleted file mode 100644 index b64a61335c4..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/App/State/MaintenanceModeTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\State; - -class MaintenanceModeTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\App\State\MaintenanceMode - */ - protected $model; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write | \PHPUnit_Framework_MockObject_MockObject - */ - protected $directoryWrite; - - /** - * @var \Magento\Framework\App\Filesystem | \PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystem; - - protected function setUp() - { - $this->directoryWrite = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $this->filesystem = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); - - $this->model = (new \Magento\TestFramework\Helper\ObjectManager($this))->getObject( - 'Magento\Framework\App\State\MaintenanceMode', - ['filesystem' => $this->filesystem] - ); - } - - protected function getDirectory() - { - $this->filesystem->expects($this->once())->method('getDirectoryWrite')->with(MaintenanceMode::FLAG_DIR) - ->will($this->returnValue($this->directoryWrite)); - } - - public function testTurnOnMaintenanceMode() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('writeFile') - ->with(MaintenanceMode::FLAG_FILENAME, 'data') - ->will($this->returnValue(123)); - - $this->assertTrue($this->model->turnOn('data')); - } - - public function testTurnOnMaintenanceModeFailed() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('writeFile') - ->with(MaintenanceMode::FLAG_FILENAME, 'data') - ->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException('failed'))); - - $this->assertFalse($this->model->turnOn('data')); - } - - public function testTurnOffMaintenanceMode() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('delete')->with(MaintenanceMode::FLAG_FILENAME); - - $this->assertTrue($this->model->turnOff()); - } - - public function testTurnOffMaintenanceModeFailed() - { - $this->getDirectory(); - $this->directoryWrite->expects($this->once())->method('delete')->with(MaintenanceMode::FLAG_FILENAME) - ->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException('failed'))); - - $this->assertFalse($this->model->turnOff()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php index 0a281b70b90..5bf35551dd1 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/StaticResourceTest.php @@ -73,7 +73,7 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->state = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->response = $this->getMockForAbstractClass('Magento\Framework\App\Response\FileInterface'); + $this->response = $this->getMock('Magento\Core\Model\File\Storage\Response', array(), array(), '', false); $this->request = $this->getMock('Magento\Framework\App\Request\Http', array(), array(), '', false); $this->publisher = $this->getMock('Magento\Framework\App\View\Asset\Publisher', array(), array(), '', false); $this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', array(), array(), '', false); @@ -202,4 +202,18 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('short/path.js')); $this->object->launch(); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $bootstrap->expects($this->at(0))->method('isDeveloperMode')->willReturn(false); + $bootstrap->expects($this->at(1))->method('isDeveloperMode')->willReturn(true); + $exception = new \Exception('message'); + $this->response->expects($this->exactly(2))->method('setHttpResponseCode')->with(404); + $this->response->expects($this->exactly(2))->method('setHeader')->with('Content-Type', 'text/plain'); + $this->response->expects($this->exactly(2))->method('sendResponse'); + $this->response->expects($this->once())->method('setBody')->with($this->stringStartsWith('message')); + $this->assertTrue($this->object->catchException($bootstrap, $exception)); + $this->assertTrue($this->object->catchException($bootstrap, $exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php b/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php index e348385cab3..7ea99ba9d5a 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Backup/MediaTest.php @@ -26,7 +26,6 @@ namespace Magento\Framework\Backup; require_once __DIR__ . '/_files/Fs.php'; require_once __DIR__ . '/_files/Helper.php'; require_once __DIR__ . '/_files/io.php'; -require_once __DIR__ . '/_files/app_dirs.php'; class MediaTest extends \PHPUnit_Framework_TestCase { @@ -45,6 +44,11 @@ class MediaTest extends \PHPUnit_Framework_TestCase */ protected $_backupDbMock; + public static function setUpBeforeClass() + { + require __DIR__ . '/_files/app_dirs.php'; + } + protected function setUp() { $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php b/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php index a5c598c3fec..b7381a0a0df 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Backup/NomediaTest.php @@ -26,7 +26,6 @@ namespace Magento\Framework\Backup; require_once __DIR__ . '/_files/Fs.php'; require_once __DIR__ . '/_files/Helper.php'; require_once __DIR__ . '/_files/io.php'; -require_once __DIR__ . '/_files/app_dirs.php'; class NomediaTest extends \PHPUnit_Framework_TestCase { @@ -45,6 +44,11 @@ class NomediaTest extends \PHPUnit_Framework_TestCase */ protected $_backupDbMock; + public static function setUpBeforeClass() + { + require __DIR__ . '/_files/app_dirs.php'; + } + protected function setUp() { $this->_backupDbMock = $this->getMock('Magento\Framework\Backup\Db', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php b/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php index 46c23a85d43..517a5f11c14 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php @@ -169,7 +169,7 @@ class MysqlTest extends \PHPUnit_Framework_TestCase * Test DDL query inside transaction in Developer mode * * @dataProvider ddlSqlQueryProvider - * @expectedException \PHPUnit_Framework_Error + * @expectedException \Exception * @expectedExceptionMessage DDL statements are not allowed in transactions */ public function testCheckDdlTransaction($ddlQuery) diff --git a/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php b/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php index db2cbe5e709..d20fb2ef087 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/DB/SelectTest.php @@ -23,27 +23,75 @@ */ namespace Magento\Framework\DB; +use Magento\TestFramework\Helper\ObjectManager; + class SelectTest extends \PHPUnit_Framework_TestCase { + public function testGetMatchQuery() + { + /** @var Select $select */ + $select = (new ObjectManager($this))->getObject('Magento\Framework\DB\Select'); + + $result = $select->getMatchQuery( + ['title', 'description'], + 'some searchable text', + Select::FULLTEXT_MODE_NATURAL + ); + $expectedResult = "MATCH (title, description) AGAINST ('some searchable text' IN NATURAL LANGUAGE MODE)"; + + $this->assertEquals($expectedResult, $result); + } + + public function testMatch() + { + $adapter = $this->getMock( + 'Zend_Db_Adapter_Pdo_Mysql', + array('supportStraightJoin', 'quote'), + array(), + '', + false + ); + $adapter->expects($this->at(0))->method('quote') + ->with($this->equalTo('some searchable text')) + ->will($this->returnValue("'some searchable text'")); + $adapter->expects($this->at(1))->method('quote') + ->will($this->returnValue('')); + + /** @var Select $select */ + $select = (new ObjectManager($this))->getObject( + 'Magento\Framework\DB\Select', + ['adapter' => $adapter] + ); + + $select->from('test'); + $select->match(['title', 'description'], 'some searchable text', true, Select::FULLTEXT_MODE_NATURAL); + + $expectedResult = "SELECT `test`.* FROM `test` WHERE (MATCH (title, description) " . + "AGAINST ('some searchable text' IN NATURAL LANGUAGE MODE))"; + $result = $select->assemble(); + + $this->assertEquals($expectedResult, $result); + } + public function testWhere() { - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'5'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'5'")); $select->from('test')->where('field = ?', 5); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field = '5')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "''")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "''")); $select->from('test')->where('field = ?'); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field = '')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'%?%'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'%?%'")); $select->from('test')->where('field LIKE ?', '%value?%'); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field LIKE '%?%')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(0)); - $select->from('test')->where("field LIKE '%value?%'", null, \Magento\Framework\DB\Select::TYPE_CONDITION); + $select = new Select($this->_getAdapterMockWithMockedQuote(0)); + $select->from('test')->where("field LIKE '%value?%'", null, Select::TYPE_CONDITION); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (field LIKE '%value?%')", $select->assemble()); - $select = new \Magento\Framework\DB\Select($this->_getAdapterMockWithMockedQuote(1, "'1', '2', '4', '8'")); + $select = new Select($this->_getAdapterMockWithMockedQuote(1, "'1', '2', '4', '8'")); $select->from('test')->where("id IN (?)", array(1, 2, 4, 8)); $this->assertEquals("SELECT `test`.* FROM `test` WHERE (id IN ('1', '2', '4', '8'))", $select->assemble()); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php deleted file mode 100644 index 78443ac9623..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/Event/Config/DataTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\Event\Config; - -class DataTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Event\Config\Data - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_readerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configScopeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - protected function setUp() - { - $this->_readerMock = $this->getMock('Magento\Framework\Event\Config\Reader', array(), array(), '', false); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface'); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_model = new \Magento\Framework\Event\Config\Data( - $this->_readerMock, - $this->_configScopeMock, - $this->_cacheMock, - $this->_appStateMock - ); - } - - public function testGet() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_configScopeMock->expects($this->once())->method('getCurrentScope')->will($this->returnValue('value')); - $this->assertEquals(null, $this->_model->get()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php b/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php index 7361d84815a..8dc8eb5a911 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Less/PreProcessor/Instruction/MagentoImportTest.php @@ -52,9 +52,9 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase private $assetRepo; /** - * @var \Magento\Framework\View\Design\Theme\Provider|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\View\Design\Theme\ListInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\Less\PreProcessor\Instruction\Import @@ -71,13 +71,13 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); $this->asset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); $this->assetRepo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->themeProvider = $this->getMock('\Magento\Framework\View\Design\Theme\Provider', [], [], '', false); + $this->themeList = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Theme\ListInterface'); $this->object = new \Magento\Framework\Less\PreProcessor\Instruction\MagentoImport( $this->design, $this->fileSource, $this->errorHandler, $this->assetRepo, - $this->themeProvider + $this->themeList ); } @@ -104,7 +104,7 @@ class MagentoImportTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($relatedAsset)); $relatedAsset->expects($this->once())->method('getContext')->will($this->returnValue($context)); $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface'); - $this->themeProvider->expects($this->once())->method('getThemeModel')->will($this->returnValue($theme)); + $this->themeList->expects($this->once())->method('getThemeByFullPath')->will($this->returnValue($theme)); $files = []; foreach ($foundFiles as $file) { $fileObject = $this->getMock('Magento\Framework\View\File', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php index 1375f86eaac..fcea02f8df3 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php @@ -31,11 +31,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase */ protected $listsModel; - /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\State - */ - protected $mockAppState; - /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\ScopeResolverInterface */ @@ -53,9 +48,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockAppState = $this->getMockBuilder('\Magento\Framework\App\State') - ->disableOriginalConstructor() - ->getMock(); $this->mockScopeResolver = $this->getMockBuilder('\Magento\Framework\App\ScopeResolverInterface') ->disableOriginalConstructor() ->getMock(); @@ -71,7 +63,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase ->with($locale); $this->listsModel = new \Magento\Framework\Locale\Lists( - $this->mockAppState, $this->mockScopeResolver, $this->mockConfig, $this->mockLocaleResolver, @@ -169,10 +160,6 @@ class ListsTest extends \PHPUnit_Framework_TestCase ->method('getLocale') ->will($this->returnValue($locale)); - $this->mockAppState->expects($this->once()) - ->method('isInstalled') - ->will($this->returnValue(false)); - $allowedCurrencies = ['USD', 'GBP', 'EUR']; $this->mockConfig->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php b/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php index 76509bb84a0..4bb5fed7538 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/LoggerTest.php @@ -47,9 +47,28 @@ class LoggerTest extends \PHPUnit_Framework_TestCase */ protected $directory; + /** + * @var string + */ + private static $logDir; + + public static function setUpBeforeClass() + { + self::$logDir = TESTS_TEMP_DIR . '/var/log'; + if (!is_dir(self::$logDir)) { + mkdir(self::$logDir, 0777, true); + } + } + + public static function tearDownAfterClass() + { + $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); + $filesystemAdapter->deleteDirectory(self::$logDir); + } + protected function setUp() { - $logDir = TESTS_TEMP_DIR . '/var/log'; + $logDir = self::$logDir; $this->filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); $this->directory = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); $this->filesystemMock->expects($this->any()) @@ -66,15 +85,16 @@ class LoggerTest extends \PHPUnit_Framework_TestCase ) ); - if (!is_dir($logDir)) { - mkdir($logDir, 0777, true); - } - $this->model = new \Magento\Framework\Logger($this->filesystemMock); $this->loggersProperty = new \ReflectionProperty($this->model, '_loggers'); $this->loggersProperty->setAccessible(true); } + protected function tearDown() + { + $this->model = null; // will cause __descruct() in the underlying log class, which will close the open log files + } + /** * @param string $key * @param string $fileOrWrapper @@ -206,4 +226,4 @@ class LoggerTest extends \PHPUnit_Framework_TestCase $this->model->logFile($message, \Zend_Log::DEBUG, $filename); $this->assertTrue($this->model->hasLog($filename)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php index ad681ab3427..52f19ed5882 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/Declaration/Reader/FilesystemTest.php @@ -43,9 +43,6 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase ); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $dependencyManager = $this->getMock('Magento\Framework\Module\DependencyManagerInterface'); $dependencyManager->expects( $this->any() @@ -60,7 +57,6 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase $converter, $schemaLocatorMock, $validationStateMock, - $appStateMock, $dependencyManager ); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php index 2af2740373d..151fd28cfa2 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/ManagerTest.php @@ -45,41 +45,47 @@ class ManagerTest extends \PHPUnit_Framework_TestCase */ private $_outputConfig; + /** + * @var \Magento\Framework\Module\ResourceInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleResource; + protected function setUp() { $this->_moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); + $this->_moduleList->expects($this->any()) + ->method('getModule') + ->will($this->returnValueMap([ + ['Module_One', ['name' => 'One_Module', 'schema_version' => '1']], + ['Module_Two', ['name' => 'Two_Module', 'schema_version' => '2']], + ['Module_Three', ['name' => 'Two_Three']], + ])); $this->_outputConfig = $this->getMockForAbstractClass('Magento\Framework\Module\Output\ConfigInterface'); + $this->moduleResource = $this->getMockForAbstractClass('\Magento\Framework\Module\ResourceInterface'); $this->_model = new \Magento\Framework\Module\Manager( $this->_outputConfig, $this->_moduleList, + $this->moduleResource, array( - 'Fixture_Module' => self::XML_PATH_OUTPUT_ENABLED, + 'Module_Two' => self::XML_PATH_OUTPUT_ENABLED, ) ); } public function testIsEnabledReturnsTrueForActiveModule() { - $this->_moduleList->expects( - $this->once() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => 'Some_Module')) - ); - $this->assertTrue($this->_model->isEnabled('Some_Module')); + $this->assertTrue($this->_model->isEnabled('Module_One')); } public function testIsEnabledReturnsFalseForInactiveModule() { - $this->_moduleList->expects($this->once())->method('getModule'); - $this->assertFalse($this->_model->isEnabled('Some_Module')); + $this->assertFalse($this->_model->isEnabled('Disabled_Module')); } public function testIsOutputEnabledReturnsFalseForDisabledModule() { $this->_outputConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); - $this->assertFalse($this->_model->isOutputEnabled('Nonexisting_Module')); + $this->assertFalse($this->_model->isOutputEnabled('Disabled_Module')); } /** @@ -89,23 +95,12 @@ class ManagerTest extends \PHPUnit_Framework_TestCase */ public function testIsOutputEnabledGenericConfigPath($configValue, $expectedResult) { - $this->_moduleList->expects( - $this->any() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => 'Module_EnabledOne')) - ); - $this->_outputConfig->expects( - $this->once() - )->method( - 'isEnabled' - )->with( - 'Module_EnabledOne' - )->will( - $this->returnValue($configValue) - ); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_EnabledOne')); + $this->_outputConfig->expects($this->once()) + ->method('isEnabled') + ->with('Module_One') + ->will($this->returnValue($configValue)) + ; + $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_One')); } public function isOutputEnabledGenericConfigPathDataProvider() @@ -115,36 +110,89 @@ class ManagerTest extends \PHPUnit_Framework_TestCase /** * @param bool $configValue - * @param string $moduleName * @param bool $expectedResult * @dataProvider isOutputEnabledCustomConfigPathDataProvider */ - public function testIsOutputEnabledCustomConfigPath($configValue, $moduleName, $expectedResult) + public function testIsOutputEnabledCustomConfigPath($configValue, $expectedResult) { - $this->_moduleList->expects( - $this->any() - )->method( - 'getModule' - )->will( - $this->returnValue(array('name' => $moduleName)) - ); - $this->_outputConfig->expects( - $this->at(0) - )->method( - 'isSetFlag' - )->with( - self::XML_PATH_OUTPUT_ENABLED - )->will( - $this->returnValue($configValue) - ); - $this->assertEquals($expectedResult, $this->_model->isOutputEnabled($moduleName)); + $this->_outputConfig->expects($this->at(0)) + ->method('isSetFlag') + ->with(self::XML_PATH_OUTPUT_ENABLED) + ->will($this->returnValue($configValue)) + ; + $this->assertEquals($expectedResult, $this->_model->isOutputEnabled('Module_Two')); } public function isOutputEnabledCustomConfigPathDataProvider() { return array( - 'path literal, output disabled' => array(false, 'Fixture_Module', false), - 'path literal, output enabled' => array(true, 'Fixture_Module', true), + 'path literal, output disabled' => array(false, false), + 'path literal, output enabled' => array(true, true), ); } + + /** + * @param string $moduleName + * @param string|bool $dbVersion + * @param bool $expectedResult + * + * @dataProvider isDbUpToDateDataProvider + */ + public function testIsDbSchemaUpToDate($moduleName, $dbVersion, $expectedResult) + { + $resourceName = 'resource'; + $this->moduleResource->expects($this->once()) + ->method('getDbVersion') + ->with($resourceName) + ->will($this->returnValue($dbVersion)); + $this->assertSame($expectedResult, $this->_model->isDbSchemaUpToDate($moduleName, $resourceName)); + } + + /** + * @param string $moduleName + * @param string|bool $dbVersion + * @param bool $expectedResult + * + * @dataProvider isDbUpToDateDataProvider + */ + public function testIsDbDataUpToDate($moduleName, $dbVersion, $expectedResult) + { + $resourceName = 'resource'; + $this->moduleResource->expects($this->once()) + ->method('getDataVersion') + ->with($resourceName) + ->will($this->returnValue($dbVersion)); + $this->assertSame($expectedResult, $this->_model->isDbDataUpToDate($moduleName, $resourceName)); + } + + /** + * @return array + */ + public function isDbUpToDateDataProvider() + { + return [ + 'version in config == version in db' => ['Module_One', '1', true], + 'version in config < version in db' => ['Module_One', '2', false], + 'version in config > version in db' => ['Module_Two', '1', false], + 'no version in db' => ['Module_One', false, false], + ]; + } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Schema version for module 'Module_Three' is not specified + */ + public function testIsDbSchemaUpToDateException() + { + $this->_model->isDbSchemaUpToDate('Module_Three', 'resource'); + } + + /** + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage Schema version for module 'Module_Three' is not specified + */ + public function testIsDbDataUpToDateException() + { + $this->_model->isDbDataUpToDate('Module_Three', 'resource'); + } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.php new file mode 100644 index 00000000000..56b2fb365ae --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/Plugin/DbStatusValidatorTest.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\Framework\Module\Plugin; + +class DbStatusValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Module\Plugin\DbStatusValidator + */ + protected $_model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_cacheMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_dbUpdaterMock; + + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleManager; + + protected function setUp() + { + $this->_cacheMock = $this->getMock('\Magento\Framework\Cache\FrontendInterface'); + $this->_dbUpdaterMock = $this->getMock('\Magento\Framework\Module\Updater', [], [], '', false); + $this->closureMock = function () { + return 'Expected'; + }; + $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); + $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); + $moduleList = $this->getMockForAbstractClass('\Magento\Framework\Module\ModuleListInterface'); + $moduleList->expects($this->any()) + ->method('getModules') + ->will($this->returnValue([ + 'Module_One' => 'module_one', + 'Module_Two' => 'module_two', + ])); + $resourceResolver = $this->getMockForAbstractClass('\Magento\Framework\Module\ResourceResolverInterface'); + $resourceResolver->expects($this->any()) + ->method('getResourceList') + ->will($this->returnCallback(function ($moduleName) { + return ['resource_' . $moduleName]; + })); + $this->moduleManager = $this->getMock('\Magento\Framework\Module\Manager', [], [], '', false); + $this->_model = new DbStatusValidator( + $this->_cacheMock, + $moduleList, + $resourceResolver, + $this->moduleManager + ); + } + + public function testAroundDispatch() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(false)) + ; + $returnMap = [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ]; + $this->moduleManager->expects($this->any()) + ->method('isDbSchemaUpToDate') + ->will($this->returnValueMap($returnMap)); + $this->moduleManager->expects($this->any()) + ->method('isDbDataUpToDate') + ->will($this->returnValueMap($returnMap)); + + $this->assertEquals( + 'Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) + ); + } + + public function testAroundDispatchCached() + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(true)) + ; + $this->moduleManager->expects($this->never()) + ->method('isDbSchemaUpToDate'); + $this->moduleManager->expects($this->never()) + ->method('isDbDataUpToDate'); + $this->assertEquals( + 'Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) + ); + } + + /** + * @param array $schemaValueMap + * @param array $dataValueMap + * + * @dataProvider aroundDispatchExceptionDataProvider + * @expectedException \Magento\Framework\Module\Exception + * @expectedExceptionMessage Looks like database is outdated. Please, use setup tool to perform update + */ + public function testAroundDispatchException(array $schemaValueMap, array $dataValueMap) + { + $this->_cacheMock->expects($this->once()) + ->method('load') + ->with('db_is_up_to_date') + ->will($this->returnValue(false)) + ; + $this->_cacheMock->expects($this->never())->method('save'); + $this->moduleManager->expects($this->any()) + ->method('isDbSchemaUpToDate') + ->will($this->returnValueMap($schemaValueMap)); + $this->moduleManager->expects($this->any()) + ->method('isDbDataUpToDate') + ->will($this->returnValueMap($dataValueMap)); + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock); + } + + /** + * @return array + */ + public function aroundDispatchExceptionDataProvider() + { + return [ + 'schema is outdated' => [ + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', true], + ], + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ], + ], + 'data is outdated' => [ + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', true], + ], + [ + ['Module_One', 'resource_Module_One', true], + ['Module_Two', 'resource_Module_Two', false], + ], + ], + 'both schema and data are outdated' => [ + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', false], + ], + [ + ['Module_One', 'resource_Module_One', false], + ['Module_Two', 'resource_Module_Two', false], + ], + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php b/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php index 2b75fe0a8f6..4ba40bc456d 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Module/UpdaterTest.php @@ -50,6 +50,11 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase */ protected $_resourceSetupMock; + /** + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + private $moduleManager; + /** * @var \Magento\Framework\Module\Updater */ @@ -79,101 +84,110 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase $this->_moduleListMock->expects($this->any())->method('getModules')->will($this->returnValue($moduleList)); $resourceList = array('catalog_setup'); - $this->_resourceResolver->expects( - $this->any() - )->method( - 'getResourceList' - )->with( - 'Test_Module' - )->will( - $this->returnValue($resourceList) - ); + $this->_resourceResolver->expects($this->any()) + ->method('getResourceList') + ->with('Test_Module') + ->will($this->returnValue($resourceList)) + ; - $this->_factoryMock->expects( - $this->any() - )->method( - 'create' - )->with( - 'catalog_setup', - 'Test_Module' - )->will( - $this->returnValue($this->_resourceSetupMock) - ); + $this->moduleManager = $this->getMock('\Magento\Framework\Module\Manager', [], [], '', false); $this->_model = new \Magento\Framework\Module\Updater( $this->_factoryMock, $this->_appStateMock, $this->_moduleListMock, $this->_resourceResolver, - true + $this->moduleManager ); } - /** - * @covers \Magento\Framework\Module\Updater::updateScheme - */ - public function testUpdateSchemeWithUpdateSkip() + public function testUpdateScheme() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - - $this->_appStateMock->expects($this->never())->method('setUpdateMode'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(false)); + $this->_factoryMock->expects($this->any()) + ->method('create') + ->with('catalog_setup', 'Test_Module') + ->will($this->returnValue($this->_resourceSetupMock)) + ; + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); + $this->_resourceSetupMock->expects($this->once()) + ->method('getCallAfterApplyAllUpdates') + ->will($this->returnValue(true)); + $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); $this->_model->updateScheme(); } - public function testUpdateSchemeDoesNotApplyUpdatesIfApplicationIsInstalledButUpdatesCanBeSkipped() + public function testUpdateSchemeNoUpdates() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_resourceSetupMock->expects($this->never())->method('applyUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); $this->_model->updateScheme(); } /** - * @covers \Magento\Framework\Module\Updater::updateScheme + * @covers \Magento\Framework\Module\Updater::updateData */ - public function testUpdateSchemeAppliesUpdatesIfApplicationIsNotInstalled() + public function testUpdateDataNotApplied() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - - $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(true); - - $this->_appStateMock->expects($this->at(2))->method('setUpdateMode')->with(false); - - $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); - $this->_resourceSetupMock->expects( - $this->once() - )->method( - 'getCallAfterApplyAllUpdates' - )->will( - $this->returnValue(true) - ); - $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); - - $this->_model->updateScheme(); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); + $this->_model->updateData(); } - /** - * @covers \Magento\Framework\Module\Updater::updateData - */ - public function testUpdateDataDoesNotApplyDataUpdatesIfSchemaIsNotUpdated() + public function testUpdateData() { - $this->_resourceSetupMock->expects($this->never())->method('applyDataUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(false)); + $this->_factoryMock->expects($this->any()) + ->method('create') + ->with('catalog_setup', 'Test_Module') + ->will($this->returnValue($this->_resourceSetupMock)) + ; + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_resourceSetupMock->expects($this->once()) + ->method('applyDataUpdates'); + $this->_model->updateScheme(); $this->_model->updateData(); } - public function testUpdateDataAppliesDataUpdatesIfSchemaIsUpdated() + public function testUpdateDataNoUpdates() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(true); - $this->_appStateMock->expects($this->at(2))->method('setUpdateMode')->with(false); - $this->_resourceSetupMock->expects($this->once())->method('applyUpdates'); - $this->_resourceSetupMock->expects($this->once())->method('getCallAfterApplyAllUpdates') + $this->moduleManager->expects($this->once()) + ->method('isDbSchemaUpToDate') + ->with('Test_Module', 'catalog_setup') ->will($this->returnValue(true)); - $this->_resourceSetupMock->expects($this->once())->method('afterApplyAllUpdates'); - - $this->_resourceSetupMock->expects($this->once()) - ->method('applyDataUpdates'); + $this->moduleManager->expects($this->once()) + ->method('isDbDataUpToDate') + ->with('Test_Module', 'catalog_setup') + ->will($this->returnValue(true)); + $this->_factoryMock->expects($this->never()) + ->method('create'); + $this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true); + $this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false); + $this->_factoryMock->expects($this->never()) + ->method('create'); $this->_model->updateScheme(); $this->_model->updateData(); diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php index fc07ca170e0..5dde6b26e2e 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php @@ -23,7 +23,7 @@ */ return array( 'preferences' => array( - 'Magento\Framework\Module\UpdaterInterface' => 'Magento\Framework\Module\Updaterter', + 'Magento\Framework\Module\SomeInterface' => 'Magento\Framework\Module\ClassOne', 'Magento\Framework\App\RequestInterface' => 'Magento\Framework\App\Request\Http\Proxy', ), 'Magento\Framework\App\State' => array('arguments' => array('test name' => 'test value')), diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml index 0b7ea68ae8f..7a27c467059 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Config/Mapper/_files/simple_di_config.xml @@ -25,7 +25,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <!-- Comment within root node --> - <preference for="Magento\Framework\Module\UpdaterInterface" type="Magento\Framework\Module\Updaterter" /> + <preference for="Magento\Framework\Module\SomeInterface" type="Magento\Framework\Module\ClassOne" /> <preference for="Magento\Framework\App\RequestInterface" type="Magento\Framework\App\Request\Http\Proxy" /> <!--Arguments only--> <type name="Magento\Framework\App\State"> diff --git a/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.php new file mode 100644 index 00000000000..4d974f7aefa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Helper/CompositeTest.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\ObjectManager\Helper; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; + +class CompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var CompositeHelper + */ + protected $compositeHelper; + + /** + * @var ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + $this->compositeHelper = $this->objectManager->getObject('Magento\Framework\ObjectManager\Helper\Composite'); + } + + public function testFilterAndSortDeclaredComponents() + { + $firstComponent = new \Magento\Framework\Object(); + $secondComponent = new \Magento\Framework\Object(); + $thirdComponent = new \Magento\Framework\Object(); + $contexts = [ + [ + 'type' => new \Magento\Framework\Object(), + ], + [ + 'sortOrder' => 50, + ], + [ + 'sortOrder' => 20, + 'type' => $firstComponent + ], + [ + 'sortOrder' => 30, + 'type' => $secondComponent, + ], + [ + 'sortOrder' => 10, + 'type' => $thirdComponent + ], + ]; + + $result = $this->compositeHelper->filterAndSortDeclaredComponents($contexts); + + /** Ensure that misconfigured components were filtered out correctly */ + $this->assertCount(3, $result, 'Misconfigured components filtration does not work as expected.'); + + /** Verify that components were ordered according to the defined sort order */ + $incorrectSortingMessage = "Registered components were sorted incorrectly"; + $this->assertSame($thirdComponent, $result[0]['type'], $incorrectSortingMessage); + $this->assertSame($firstComponent, $result[1]['type'], $incorrectSortingMessage); + $this->assertSame($secondComponent, $result[2]['type'], $incorrectSortingMessage); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php new file mode 100644 index 00000000000..0ade1982c2e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.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\Search\Adapter\Mysql; + + +use Magento\Framework\App\Resource\Config; +use Magento\Framework\App\Resource; +use Magento\TestFramework\Helper\ObjectManager; + +class AdapterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ResponseFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseFactory; + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $connectionAdapter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Mapper|\PHPUnit_Framework_MockObject_MockObject + */ + private $mapper; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Adapter + */ + private $adapter; + /** + * @var ObjectManager + */ + private $objectManager; + /** + * @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $request; + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + private $select; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + $this->connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['fetchAssoc']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->connectionAdapter)); + + $this->mapper = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Mapper') + ->setMethods(['buildQuery']) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseFactory = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\ResponseFactory') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->objectManager->getObject( + '\Magento\Framework\Search\Adapter\Mysql\Adapter', + [ + 'mapper' => $this->mapper, + 'responseFactory' => $this->responseFactory, + 'resource' => $this->resource, + ] + ); + } + + public function testQuery() + { + $selectResult = [ + 'documents' => [ + 'id' => 1, + 'sku' => 'Product' + ], + 'aggregations' => [] + ]; + + $this->connectionAdapter->expects($this->once()) + ->method('fetchAssoc') + ->will($this->returnValue($selectResult['documents'])); + $this->mapper->expects($this->once()) + ->method('buildQuery') + ->with($this->request) + ->will($this->returnValue($this->select)); + $this->responseFactory->expects($this->once()) + ->method('create') + ->with($selectResult) + ->will($this->returnArgument(0)); + $response = $this->adapter->query($this->request); + $this->assertEquals($selectResult, $response); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.php new file mode 100644 index 00000000000..c8e7a7c2b4b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Builder/Query/MatchTest.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\Framework\Search\Adapter\Mysql\Builder\Query; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\TestFramework\Helper\ObjectManager; + +class MatchTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match + */ + private $match; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + ->setMethods(['addCondition']) + ->disableOriginalConstructor() + ->getMock(); + + $this->match = $helper->getObject('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match'); + } + + public function testBuildQuery() + { + $boost = 3.14; + + /** @var Select|\PHPUnit_Framework_MockObject_MockObject $select */ + $select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods(['getMatchQuery', 'match']) + ->disableOriginalConstructor() + ->getMock(); + $select->expects($this->once())->method('getMatchQuery') + ->with($this->equalTo('some_field'), $this->equalTo('-some_value')) + ->will($this->returnValue('matchedQuery')); + $select->expects($this->once())->method('match') + ->with( + $this->equalTo('some_field'), + $this->equalTo('-some_value'), + $this->equalTo(true), + $this->equalTo(Select::FULLTEXT_MODE_BOOLEAN) + ); + + /** @var \Magento\Framework\Search\Request\Query\Match|\PHPUnit_Framework_MockObject_MockObject $query */ + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + ->setMethods(['getMatches']) + ->disableOriginalConstructor() + ->getMock(); + $query->expects($this->once())->method('getMatches')->will( + $this->returnValue([['field' => 'some_field', 'value' => 'some_value', 'boost' => $boost]]) + ); + + $this->scoreBuilder->expects($this->once())->method('addCondition') + ->with( + $this->equalTo('matchedQuery'), + $this->equalTo($boost) + ); + + $result = $this->match->build($this->scoreBuilder, $select, $query, Bool::QUERY_CONDITION_NOT); + + $this->assertEquals($select, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.php new file mode 100644 index 00000000000..797a53395a3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/DimensionsTest.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\Framework\Search\Adapter\Mysql; + +use Magento\Framework\Search\Adapter\Mysql\Dimensions as DimensionsBuilder; +use Magento\TestFramework\Helper\ObjectManager; + +class DimensionsTest extends \PHPUnit_Framework_TestCase +{ + + /** @var \Magento\TestFramework\Helper\ObjectManager */ + private $objectManager; + /** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $adapter; + /** @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject */ + private $resource; + /** @var \Magento\Framework\App\ScopeInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $scope; + /** @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $scopeResolver; + /** @var \Magento\Framework\Search\Request\Dimension|\PHPUnit_Framework_MockObject_MockObject */ + private $dimension; + /** @var DimensionsBuilder */ + private $builder; + + protected function setUp() + { + $this->objectManager = new ObjectManager($this); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->disableOriginalConstructor() + ->setMethods(['quote', 'quoteIdentifier']) + ->getMockForAbstractClass(); + + $escapeValueCallback = function ($value) { + return '`' . $value . '`'; + }; + + $this->adapter->expects($this->once()) + ->method('quote') + ->will($this->returnCallback($escapeValueCallback)); + $this->adapter->expects($this->once()) + ->method('quoteIdentifier') + ->will($this->returnCallback($escapeValueCallback)); + + $this->resource = $this->getMockBuilder('\Magento\Framework\App\Resource') + ->disableOriginalConstructor() + ->setMethods(['getConnection']) + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->scope = $this->getMockBuilder('\Magento\Framework\App\ScopeInterface') + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + + $this->scopeResolver = $this->getMockBuilder('\Magento\Framework\App\ScopeResolverInterface') + ->disableOriginalConstructor() + ->setMethods(['getScope']) + ->getMockForAbstractClass(); + + $this->dimension = $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + ->disableOriginalConstructor() + ->setMethods(['getName', 'getValue']) + ->getMock(); + + $this->builder = $this->objectManager->getObject( + '\Magento\Framework\Search\Adapter\Mysql\Dimensions', + [ + 'resource' => $this->resource, + 'scopeResolver' => $this->scopeResolver + ] + ); + } + + public function testBuildDimensionWithCustomScope() + { + $name = 'customScopeName'; + $value = 'customScopeId'; + + $this->dimension->expects($this->once()) + ->method('getName') + ->will($this->returnValue($name)); + $this->dimension->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + + $this->scope->expects($this->never()) + ->method('getId'); + + $this->scopeResolver->expects($this->never()) + ->method('getScope'); + + $query = $this->builder->build($this->dimension); + $this->assertEquals( + sprintf('`%s` = `%s`', $name, $value), + $query + ); + } + + public function testBuildDimensionWithDefaultScope() + { + $name = 'scope'; + $value = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT; + $scopeId = -123456; + + $this->dimension->expects($this->once()) + ->method('getName') + ->will($this->returnValue($name)); + $this->dimension->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + + $this->scope->expects($this->once()) + ->method('getId') + ->will($this->returnValue($scopeId)); + + $this->scopeResolver->expects($this->once()) + ->method('getScope') + ->with($value) + ->will($this->returnValue($this->scope)); + + $query = $this->builder->build($this->dimension); + $this->assertEquals( + sprintf('`%s` = `%s`', \Magento\Framework\Search\Adapter\Mysql\Dimensions::STORE_FIELD_NAME, $scopeId), + $query + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.php new file mode 100644 index 00000000000..644ed1ee919 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/RangeTest.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\Search\Adapter\Mysql\Filter\Builder; + +use Magento\TestFramework\Helper\ObjectManager; + +class RangeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + /** + * @var \Magento\Framework\Search\Request\Filter\Term|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestFilter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range + */ + private $filter; + + /** + * Set Up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + ->setMethods(['getField', 'getFrom', 'getTo']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->filter = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range', + [ + 'resource' => $this->resource, + ] + ); + } + + /** + * @param string $field + * @param string $from + * @param string $to + * @param string $expectedResult + * @dataProvider buildQueryDataProvider + */ + public function testBuildQuery($field, $from, $to, $expectedResult) + { + $this->requestFilter->expects($this->once()) + ->method('getField') + ->will($this->returnValue($field)); + $this->requestFilter->expects($this->once()) + ->method('getFrom') + ->will($this->returnValue($from)); + $this->requestFilter->expects($this->once()) + ->method('getTo') + ->will($this->returnValue($to)); + $this->adapter->expects($this->any()) + ->method('quote') + ->will( + $this->returnCallback( + function ($value) { + return '\'' . $value . '\''; + } + ) + ); + + $actualResult = $this->filter->buildFilter($this->requestFilter); + $this->assertEquals($expectedResult, $actualResult); + } + + /** + * Data provider for BuildQuery + * @return array + */ + public function buildQueryDataProvider() + { + return [ + 'rangeWithStrings' => [ + 'field' => 'testField', + 'from' => '0', + 'to' => '10', + 'expectedResult' => 'testField >= \'0\' AND testField < \'10\'', + ], + 'rangeWithIntegers' => [ + 'field' => 'testField', + 'from' => 50, + 'to' => 50, + 'expectedResult' => 'testField >= \'50\' AND testField < \'50\'', + ], + 'rangeWithFloats' => [ + 'field' => 'testField', + 'from' => 50.5, + 'to' => 55.5, + 'expectedResult' => 'testField >= \'50.5\' AND testField < \'55.5\'', + ], + 'rangeWithoutFromValue' => [ + 'field' => 'testField', + 'from' => null, + 'to' => 50, + 'expectedResult' => 'testField < \'50\'', + ], + 'rangeWithoutToValue' => [ + 'field' => 'testField', + 'from' => 50, + 'to' => null, + 'expectedResult' => 'testField >= \'50\'', + ], + 'rangeWithEmptyValues' => [ + 'field' => 'testField', + 'from' => null, + 'to' => null, + 'expectedResult' => '', + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.php new file mode 100644 index 00000000000..b51d66be798 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/TermTest.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\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\TestFramework\Helper\ObjectManager; + +class TermTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + /** + * @var \Magento\Framework\Search\Request\Filter\Term|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestFilter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term + */ + private $filter; + + /** + * Set up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->requestFilter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + ->setMethods(['getField', 'getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->once()) + ->method('getConnection') + ->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($this->adapter)); + + $this->filter = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term', + [ + 'resource' => $this->resource, + ] + ); + } + + /** + * @param string $field + * @param string $value + * @param string $expectedResult + * @dataProvider buildQueryDataProvider + */ + public function testBuildQuery($field, $value, $expectedResult) + { + $this->requestFilter->expects($this->once()) + ->method('getField') + ->will($this->returnValue($field)); + $this->requestFilter->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + $this->adapter->expects($this->once()) + ->method('quote') + ->will($this->returnArgument(0)); + + $actualResult = $this->filter->buildFilter($this->requestFilter); + $this->assertEquals($expectedResult, $actualResult); + } + + /** + * Data provider for BuildQuery + * @return array + */ + public function buildQueryDataProvider() + { + return [ + [ + 'field' => 'testField', + 'value' => 'testValue', + 'expectedResult' => 'testField = testValue', + ], + [ + 'field' => 'testField2', + 'value' => 'testValue2', + 'expectedResult' => 'testField2 = testValue2', + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php new file mode 100644 index 00000000000..8c1713f8d4a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderTest.php @@ -0,0 +1,340 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Framework\Search\Adapter\Mysql\Filter; + +use Magento\TestFramework\Helper\ObjectManager; + +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $adapter; + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder + */ + private $builder; + + /** + * Set up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + + $this->adapter = $adapter = $this->getMockBuilder('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['quote']) + ->getMockForAbstractClass(); + $this->adapter->expects($this->any()) + ->method('quote') + ->will($this->returnArgument(0)); + + $rangeBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range') + ->setMethods(['buildFilter']) + ->disableOriginalConstructor() + ->getMock(); + $rangeBuilder->expects($this->any()) + ->method('buildFilter') + ->will( + $this->returnCallback( + function (\Magento\Framework\Search\Request\FilterInterface $filter) use ($adapter) { + /** + * @var \Magento\Framework\Search\Request\Filter\Range $filter + * @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter + */ + return sprintf( + '%s >= %s AND %s < %s', + $filter->getField(), + $adapter->quote($filter->getFrom()), + $filter->getField(), + $adapter->quote($filter->getTo()) + ); + } + ) + ); + + $termBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term') + ->setMethods(['buildFilter']) + ->disableOriginalConstructor() + ->getMock(); + $termBuilder->expects($this->any()) + ->method('buildFilter') + ->will( + $this->returnCallback( + function (\Magento\Framework\Search\Request\FilterInterface $filter) use ($adapter) { + /** + * @var \Magento\Framework\Search\Request\Filter\Term $filter + * @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter + */ + return sprintf( + '%s = %s', + $filter->getField(), + $adapter->quote($filter->getValue()) + ); + } + ) + ); + + $this->builder = $objectManager->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Filter\Builder', + [ + 'range' => $rangeBuilder, + 'term' => $termBuilder, + ] + ); + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject $filter + * @param string $expectedResult + * @dataProvider buildFilterDataProvider + */ + public function testBuildFilter($filter, $expectedResult) + { + $actualResult = $this->builder->build($filter); + $this->assertEquals($expectedResult, $actualResult); + } + + public function buildFilterDataProvider() + { + return array_merge( + $this->buildTermFilterDataProvider(), + $this->buildRangeFilterDataProvider(), + $this->buildBoolFilterDataProvider() + ); + } + + /** + * Data provider for BuildFilter + * @return array + */ + public function buildRangeFilterDataProvider() + { + return [ + 'rangeFilter' => [ + 'filter' => $this->createRangeFilter('range1', 0, 10), + 'expectedResult' => '(range1 >= 0 AND range1 < 10)', + ] + ]; + } + + public function buildTermFilterDataProvider() + { + return [ + 'termFilter' => [ + 'filter' => $this->createTermFilter('term1', 123), + 'expectedResult' => '(term1 = 123)', + ], + ]; + } + + public function buildBoolFilterDataProvider() + { + return [ + 'boolFilterWithMust' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [], //should + [] // mustNot + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10))', + ], + 'boolFilterWithShould' => [ + 'filter' => $this->createBoolFilter( + [], //must + [ //should + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [] // mustNot + ), + 'expectedResult' => '(((term1 = 1) OR (range1 >= 0 AND range1 < 10)))', + ], + 'boolFilterWithMustNot' => [ + 'filter' => $this->createBoolFilter( + [], //must + [], //should + [ // mustNot + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ] + ), + 'expectedResult' => '(!((term1 = 1) AND (range1 >= 0 AND range1 < 10)))', + ], + 'boolFilterWithAllFields' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [ //should + $this->createTermFilter('term2', 1), + $this->createRangeFilter('range2', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term3', 1), + $this->createRangeFilter('range3', 0, 10), + ] + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10)' + . ' AND ((term2 = 1) OR (range2 >= 0 AND range2 < 10))' + . ' AND !((term3 = 1) AND (range3 >= 0 AND range3 < 10)))', + ], + 'boolFilterInBoolFilter' => [ + 'filter' => $this->createBoolFilter( + [ //must + $this->createTermFilter('term1', 1), + $this->createRangeFilter('range1', 0, 10), + ], + [ //should + $this->createTermFilter('term2', 1), + $this->createRangeFilter('range2', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term3', 1), + $this->createRangeFilter('range3', 0, 10), + $this->createBoolFilter( + [ //must + $this->createTermFilter('term4', 1), + $this->createRangeFilter('range4', 0, 10), + ], + [ //should + $this->createTermFilter('term5', 1), + $this->createRangeFilter('range5', 0, 10), + ], + [ // mustNot + $this->createTermFilter('term6', 1), + $this->createRangeFilter('range6', 0, 10), + ] + ), + ] + ), + 'expectedResult' => '((term1 = 1) AND (range1 >= 0 AND range1 < 10)' + . ' AND ((term2 = 1) OR (range2 >= 0 AND range2 < 10))' + . ' AND !((term3 = 1) AND (range3 >= 0 AND range3 < 10)' + . ' AND ((term4 = 1) AND (range4 >= 0 AND range4 < 10)' + . ' AND ((term5 = 1) OR (range5 >= 0 AND range5 < 10))' + . ' AND !((term6 = 1) AND (range6 >= 0 AND range6 < 10)))' + . '))', + + ], + 'boolEmpty' => [ + 'filter' => $this->createBoolFilter([], [], []), + 'expectedResult' => '', + ] + ]; + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown filter type 'unknownType' + */ + public function testUnknownFilterType() + { + /** @var \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject $filter */ + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + ->setMethods(['getType']) + ->getMockForAbstractClass(); + $filter->expects($this->exactly(2)) + ->method('getType') + ->will($this->returnValue('unknownType')); + $this->builder->build($filter); + } + + /** + * @param $field + * @param $from + * @param $to + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createRangeFilter($field, $from, $to) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Range') + ->setMethods(['getField', 'getFrom', 'getTo']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->exactly(2)) + ->method('getField') + ->will($this->returnValue($field)); + $filter->expects($this->once()) + ->method('getFrom') + ->will($this->returnValue($from)); + $filter->expects($this->once()) + ->method('getTo') + ->will($this->returnValue($to)); + return $filter; + } + + /** + * @param $field + * @param $value + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createTermFilter($field, $value) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Term') + ->setMethods(['getField', 'getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->exactly(1)) + ->method('getField') + ->will($this->returnValue($field)); + $filter->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($value)); + return $filter; + } + + /** + * @param array $must + * @param array $should + * @param array $mustNot + * @return \Magento\Framework\Search\Request\Filter\Bool|\PHPUnit_Framework_MockObject_MockObject + */ + private function createBoolFilter(array $must, array $should, array $mustNot) + { + $filter = $this->getMockBuilder('Magento\Framework\Search\Request\Filter\Bool') + ->setMethods(['getMust', 'getShould', 'getMustNot']) + ->disableOriginalConstructor() + ->getMock(); + + $filter->expects($this->once()) + ->method('getMust') + ->will($this->returnValue($must)); + $filter->expects($this->once()) + ->method('getShould') + ->will($this->returnValue($should)); + $filter->expects($this->once()) + ->method('getMustNot') + ->will($this->returnValue($mustNot)); + return $filter; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php new file mode 100644 index 00000000000..fad795c9f70 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/MapperTest.php @@ -0,0 +1,354 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\Framework\App\Resource; +use Magento\Framework\App\Resource\Config; +use Magento\Framework\Search\Request\Query\Filter; +use Magento\Framework\Search\Request\QueryInterface; +use Magento\TestFramework\Helper\ObjectManager; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class MapperTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Dimensions|\PHPUnit_Framework_MockObject_MockObject + */ + private $dimensionsBuilder; + /** + * @var \Magento\Framework\Search\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $request; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + private $select; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $scoreBuilderFactory; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match|\PHPUnit_Framework_MockObject_MockObject + */ + private $matchQueryBuilder; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Filter\Builder|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterBuilder; + + /** + * @var \Magento\Framework\Search\Request\FilterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $filter; + + /** + * @var Mapper + */ + private $mapper; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->select = $this->getMockBuilder('Magento\Framework\DB\Select') + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + + $connectionAdapter = $this->getMockBuilder('Magento\Framework\DB\Adapter\AdapterInterface') + ->setMethods(['select']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $connectionAdapter->expects($this->any())->method('select')->will($this->returnValue($this->select)); + + $this->resource = $this->getMockBuilder('Magento\Framework\App\Resource') + ->setMethods(['getConnection']) + ->disableOriginalConstructor() + ->getMock(); + $this->resource->expects($this->any())->method('getConnection') + ->with(Resource::DEFAULT_READ_RESOURCE) + ->will($this->returnValue($connectionAdapter)); + + $this->scoreBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder') + ->setMethods(['clear']) + ->disableOriginalConstructor() + ->getMock(); + $this->scoreBuilderFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\ScoreBuilderFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->scoreBuilderFactory->expects($this->any())->method('create') + ->will($this->returnValue($this->scoreBuilder)); + + $this->dimensionsBuilder = $this->getMockBuilder('\Magento\Framework\Search\Adapter\Mysql\Dimensions') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->request = $this->getMockBuilder('Magento\Framework\Search\RequestInterface') + ->setMethods(['getQuery', 'getDimensions']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->matchQueryBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->filter = $this->getMockBuilder('Magento\Framework\Search\Request\FilterInterface') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\Filter\Builder') + ->setMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + + $this->mapper = $helper->getObject( + 'Magento\Framework\Search\Adapter\Mysql\Mapper', + [ + 'resource' => $this->resource, + 'scoreBuilderFactory' => $this->scoreBuilderFactory, + 'matchQueryBuilder' => $this->matchQueryBuilder, + 'filterBuilder' => $this->filterBuilder, + 'dimensionsBuilder' => $this->dimensionsBuilder, + ] + ); + } + + public function testBuildMatchQuery() + { + $query = $this->createMatchQuery(); + + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $this->matchQueryBuilder->expects($this->once())->method('build') + ->with( + $this->equalTo($this->scoreBuilder), + $this->equalTo($this->select), + $this->equalTo($query), + $this->equalTo(Mapper::BOOL_MUST) + ) + ->will($this->returnValue($this->select)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + public function testBuildFilterQuery() + { + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $query = $this->createFilterQuery(); + $query->expects($this->once())->method('getReferenceType')->will($this->returnValue(Filter::REFERENCE_FILTER)); + $query->expects($this->once())->method('getReference')->will($this->returnValue($this->filter)); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->filterBuilder->expects($this->once())->method('build')->will($this->returnValue('(1)')); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + public function testBuildBoolQuery() + { + $query = $this->createBoolQuery(); + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->matchQueryBuilder->expects($this->exactly(4))->method('build') + ->will($this->returnValue($this->select)); + + $matchQuery = $this->createMatchQuery(); + $filterMatchQuery = $this->createFilterQuery(); + $filterMatchQuery->expects($this->once())->method('getReferenceType') + ->will($this->returnValue(Filter::REFERENCE_QUERY)); + $filterMatchQuery->expects($this->once())->method('getReference')->will($this->returnValue($matchQuery)); + + $filterQuery = $this->createFilterQuery(); + $filterQuery->expects($this->once())->method('getReferenceType') + ->will($this->returnValue(Filter::REFERENCE_FILTER)); + $filterQuery->expects($this->once())->method('getReference')->will($this->returnValue($this->filter)); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->filterBuilder->expects($this->once())->method('build')->will($this->returnValue('(1)')); + + $this->select->expects($this->once())->method('from')->will($this->returnValue($this->select)); + $this->select->expects($this->once())->method('columns')->will($this->returnValue($this->select)); + + $query->expects($this->once()) + ->method('getMust') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $this->createFilterQuery(), + ] + ) + ); + + $query->expects($this->once()) + ->method('getShould') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $filterMatchQuery, + ] + ) + ); + + $query->expects($this->once()) + ->method('getMustNot') + ->will( + $this->returnValue( + [ + $this->createMatchQuery(), + $filterQuery, + ] + ) + ); + + $response = $this->mapper->buildQuery($this->request); + + $this->assertEquals($this->select, $response); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown query type 'unknownQuery' + */ + public function testGetUnknownQueryType() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\QueryInterface') + ->setMethods(['getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(2)) + ->method('getType') + ->will($this->returnValue('unknownQuery')); + + $this->request->expects($this->once())->method('getQuery')->will($this->returnValue($query)); + + $this->mapper->buildQuery($this->request); + } + + private function createMatchQuery() + { + $this->request->expects($this->once()) + ->method('getDimensions') + ->will( + $this->returnValue([$this->createDimension()]) + ); + $this->dimensionsBuilder->expects($this->once()) + ->method('build') + ->will($this->returnValue('a = b')); + + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Match') + ->setMethods(['getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->once())->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_MATCH)); + return $query; + } + + /** + * @return \Magento\Framework\Search\Request\Dimension|\PHPUnit_Framework_MockObject_MockObject + */ + private function createDimension() + { + return $this->getMockBuilder('\Magento\Framework\Search\Request\Dimension') + ->disableOriginalConstructor() + ->getMock(); + } + + private function createFilterQuery() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Filter') + ->setMethods(['getType', 'getReferenceType', 'getReference']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(1)) + ->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_FILTER)); + return $query; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + private function createBoolQuery() + { + $query = $this->getMockBuilder('Magento\Framework\Search\Request\Query\Bool') + ->setMethods(['getMust', 'getShould', 'getMustNot', 'getType']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $query->expects($this->exactly(1)) + ->method('getType') + ->will($this->returnValue(QueryInterface::TYPE_BOOL)); + return $query; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php new file mode 100644 index 00000000000..272bc41b340 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ResponseFactoryTest.php @@ -0,0 +1,105 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\ObjectManager; + +class ResponseFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Search\Adapter\Mysql\ResponseFactory + */ + private $factory; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\DocumentFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $documentFactory; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $objectManager; + + protected function setUp() + { + $helper = new ObjectManager($this); + + $this->documentFactory = $this->getMockBuilder('Magento\Framework\Search\Adapter\Mysql\DocumentFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManager') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->factory = $helper->getObject( + 'Magento\Framework\Search\Adapter\Mysql\ResponseFactory', + ['documentFactory' => $this->documentFactory, 'objectManager' => $this->objectManager] + ); + } + + public function testCreate() + { + $rawResponse = [ + 'documents' => [ + ['title' => 'oneTitle', 'description' => 'oneDescription'], + ['title' => 'twoTitle', 'description' => 'twoDescription'] + ], + 'aggregations' => [] + ]; + $exceptedResponse = [ + 'documents' => [ + [ + ['name' => 'title', 'value' => 'oneTitle'], + ['name' => 'description', 'value' => 'oneDescription'], + ], + [ + ['name' => 'title', 'value' => 'twoTitle'], + ['name' => 'description', 'value' => 'twoDescription'], + ] + ], + 'aggregations' => [] + ]; + + $this->documentFactory->expects($this->at(0))->method('create') + ->with($this->equalTo($exceptedResponse['documents'][0])) + ->will($this->returnValue('document1')); + $this->documentFactory->expects($this->at(1))->method('create') + ->with($exceptedResponse['documents'][1]) + ->will($this->returnValue('document2')); + + $this->objectManager->expects($this->once())->method('create') + ->with( + $this->equalTo('\Magento\Framework\Search\QueryResponse'), + $this->equalTo(['documents' => ['document1', 'document2'], 'aggregations' => null]) + ) + ->will($this->returnValue('QueryResponseObject')); + + $result = $this->factory->create($rawResponse); + $this->assertEquals('QueryResponseObject', $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.php new file mode 100644 index 00000000000..73e066efbbd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderTest.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\Search\Adapter\Mysql; + +use Magento\TestFramework\Helper\ObjectManager; + +class ScoreBuilderTest extends \PHPUnit_Framework_TestCase +{ + public function testBuild() + { + /** @var \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $builder */ + $builder = (new ObjectManager($this))->getObject('Magento\Framework\Search\Adapter\Mysql\ScoreBuilder'); + + $builder->startQuery(); // start one query + + $builder->addCondition('someCondition1', 1.1); + + $builder->startQuery(); // start two query + + $builder->addCondition('someCondition2', 1.2); + $builder->addCondition('someCondition3', 1.3); + + $builder->startQuery(); // start three query + + $builder->addCondition('someCondition4', 1.4); + $builder->addCondition('someCondition5', 1.5); + + $builder->endQuery(10.1); // end three query + + $builder->startQuery(); // start four query + + $builder->addCondition('someCondition6', 1.6); + $builder->addCondition('someCondition7', 1.7); + + $builder->endQuery(10.2); // end four query + $builder->endQuery(10.3); // start two query + $builder->endQuery(10.4); // start one query + + $result = $builder->build(); + + $expected = '((someCondition1 * 1.1 + (someCondition2 * 1.2 + someCondition3 * 1.3 + ' . + '(someCondition4 * 1.4 + someCondition5 * 1.5) * 10.1 + (someCondition6 * 1.6 + ' . + 'someCondition7 * 1.7) * 10.2) * 10.3) * 10.4) AS global_score'; + + $this->assertEquals($expected, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php index fcedf7e9e19..ae4829bb53b 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/DocumentTest.php @@ -43,7 +43,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase ->getMock(); $field->expects($this->any())->method('getName')->will($this->returnValue("$count")); - $field->expects($this->any())->method('getValues')->will($this->returnValue([$count])); + $field->expects($this->any())->method('getValue')->will($this->returnValue($count)); $documentFields[] = $field; } @@ -61,7 +61,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $count = 0; foreach ($this->document as $field) { $this->assertEquals($field->getName(), "$count"); - $this->assertEquals($field->getValues(), [$count]); + $this->assertEquals($field->getValue(), $count); $count++; } } @@ -77,6 +77,6 @@ class DocumentTest extends \PHPUnit_Framework_TestCase public function testGetField() { $field = $this->document->getField('3'); - $this->assertEquals($field->getValues(), [3]); + $this->assertEquals($field->getValue(), 3); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php index a6dbd0334e9..f88a20bc67e 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/QueryResponseTest.php @@ -33,7 +33,7 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase private $documents = []; /** - * @var \Magento\Framework\Search\Aggregation[] + * @var \Magento\Framework\Search\Aggregation */ private $aggregations = []; @@ -55,12 +55,9 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase $this->documents[] = $document; } - for ($count = 0; $count < 3; $count++) { - $aggregation = $this->getMockBuilder('Magento\Framework\Search\Aggregation') - ->disableOriginalConstructor() - ->getMock(); - $this->aggregations[] = $aggregation; - } + $this->aggregations = $this->getMockBuilder('Magento\Framework\Search\Aggregation') + ->disableOriginalConstructor() + ->getMock(); $this->queryResponse = $helper->getObject( 'Magento\Framework\Search\QueryResponse', @@ -75,8 +72,8 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase { $count = 0; foreach ($this->queryResponse as $document) { - $this->assertEquals($document->getId(), $count); - $count++; + $this->assertEquals($document->getId(), $count); + $count++; } } @@ -88,8 +85,6 @@ class QueryResponseTest extends \PHPUnit_Framework_TestCase public function testGetAggregations() { $aggregations = $this->queryResponse->getAggregations(); - foreach ($aggregations as $aggregation) { - $this->assertInstanceOf('Magento\Framework\Search\Aggregation', $aggregation); - } + $this->assertInstanceOf('Magento\Framework\Search\Aggregation', $aggregations); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php index 651ec06f746..3b5b018bbb4 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Search/RequestFactoryTest.php @@ -72,12 +72,12 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'queries' => ':str', 'filters' => 'f', 'query' => 'q', - 'aggregation' => 'a', + 'aggregations' => 'a', 'index' => 'i', 'from' => '1', 'size' => '15', - 'demensions' => [ - 'name' => ['name' =>'', 'value' => ''] + 'dimensions' => [ + 'name' => ['name' => '', 'value' => ''] ] ]; $mappedQuery = $configData['query'] . 'Mapped'; @@ -103,7 +103,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'objectManager' => $this->objectManager, 'queries' => $bindValues[':str'], 'rootQueryName' => $configData['query'], - 'aggregation' => $configData['aggregation'], + 'aggregations' => $configData['aggregations'], 'filters' => $configData['filters'] ] ) @@ -137,7 +137,7 @@ class RequestFactoryTest extends \PHPUnit_Framework_TestCase 'from' => $configData['from'], 'size' => $configData['size'], 'query' => $mappedQuery, - 'demensions' => [ + 'dimensions' => [ 'name' => $dimension ], 'buckets' => [], diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php index 281a22b2fb1..ac9bdfcdd78 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/ConfigTest.php @@ -49,11 +49,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\Filesystem */ @@ -80,15 +75,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase )->will( $this->returnValue('init.host') ); - $this->_appState = $this->getMock('\Magento\Framework\App\State', array('isInstalled'), array(), '', false, false); - $this->_appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true)); $this->_filesystem = $this->getMock('\Magento\Framework\App\Filesystem', array(), array(), '', false, false); $this->config = new \Magento\Framework\Session\Config( $this->_configMock, $this->_stringHelperMock, $this->_requestMock, - $this->_appState, $this->_filesystem, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, @@ -332,7 +324,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_configMock, $this->_stringHelperMock, $this->_requestMock, - $this->_appState, $this->_filesystem, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, diff --git a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php index 0c2c5cec0c9..08ebd40d1eb 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Session/SessionManagerTest.php @@ -63,7 +63,7 @@ namespace Magento\Framework\Session { } return call_user_func_array('\session_regenerate_id', func_get_args()); } - + /** * Test SessionManager * diff --git a/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php index 77a9cbd11c3..177d023e36d 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Simplexml/ConfigTest.php @@ -59,7 +59,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->config->loadString($xml)); $this->assertXmlStringEqualsXmlString($xml, $this->config->getXmlString()); $this->setExpectedException( - 'PHPUnit_Framework_Error_Warning', + '\Exception', 'simplexml_load_string(): Entity: line 1: parser error : Start tag expected,' ); $this->assertFalse($this->config->loadString('wrong_path')); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php index 6122770c291..475e4505682 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/CookieScopeTest.php @@ -67,7 +67,13 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase { $cookieScope = $this->createCookieScope(); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); } /** @@ -110,7 +116,14 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($cookieScope->getPublicCookieMetadata()->__toArray()); $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); - $this->assertEquals($defaultValues, $cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'default path', + SensitiveCookieMetadata::KEY_DOMAIN => 'default domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray()); } /** @@ -134,7 +147,13 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase ] ); - $this->assertEmpty($cookieScope->getSensitiveCookieMetadata()->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata()->__toArray() + ); $this->assertEmpty($cookieScope->getCookieMetadata()->__toArray()); $this->assertEquals($defaultValues, $cookieScope->getPublicCookieMetadata()->__toArray()); } @@ -185,7 +204,15 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($cookieScope->getPublicCookieMetadata($this->createPublicMetadata())->__toArray()); $this->assertEmpty($cookieScope->getCookieMetadata($this->createCookieMetadata())->__toArray()); - $this->assertEquals($overrideValues, $cookieScope->getSensitiveCookieMetadata($override)->__toArray()); + $this->assertEquals( + [ + SensitiveCookieMetadata::KEY_PATH => 'override path', + SensitiveCookieMetadata::KEY_DOMAIN => 'override domain', + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], + $cookieScope->getSensitiveCookieMetadata($override)->__toArray() + ); } /** @@ -243,7 +270,10 @@ class CookieScopeTest extends \PHPUnit_Framework_TestCase $override = $this->createCookieMetadata($overrideValues); $this->assertEquals( - [], + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => true, + SensitiveCookieMetadata::KEY_SECURE => true, + ], $cookieScope->getSensitiveCookieMetadata($this->createSensitiveMetadata())->__toArray() ); $this->assertEquals( diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php index 9859a781e29..6ea0db48493 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/PhpCookieManagerTest.php @@ -63,7 +63,8 @@ namespace Magento\Framework\Stdlib\Cookie { 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_METADATA_HTTPS = 'sensitive_cookie_name_no_metadata_https'; + const SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS = 'sensitive_cookie_name_no_metadata_not_https'; 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'; @@ -89,7 +90,8 @@ namespace Magento\Framework\Stdlib\Cookie { 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_METADATA_HTTPS => 'self::assertSensitiveCookieWithNoMetaDataHttps', + self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS => 'self::assertSensitiveCookieWithNoMetaDataNotHttps', 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', @@ -113,7 +115,7 @@ namespace Magento\Framework\Stdlib\Cookie { */ protected $cookieManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Stdlib\Cookie\CookieScope + * @var \PHPUnit_Framework_MockObject_MockObject|CookieScopeInterface */ protected $scopeMock; @@ -122,13 +124,23 @@ namespace Magento\Framework\Stdlib\Cookie { */ public static $isSetCookieInvoked; + /** + * @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Store\Model\Store| \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + 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') + $this->scopeMock = $this->getMockBuilder('Magento\Framework\Stdlib\Cookie\CookieScopeInterface') ->setMethods(['getPublicCookieMetadata', 'getCookieMetadata', 'getSensitiveCookieMetadata']) ->disableOriginalConstructor() ->getMock(); @@ -136,6 +148,15 @@ namespace Magento\Framework\Stdlib\Cookie { 'Magento\Framework\Stdlib\Cookie\PhpCookieManager', ['scope' => $this->scopeMock] ); + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); } public function testGetCookie() @@ -230,12 +251,22 @@ namespace Magento\Framework\Stdlib\Cookie { } } - public function testSetSensitiveCookieNoMetadata() + /** + * @param string $cookieName + * @param bool $secure + * @dataProvider isCurrentlySecureDataProvider + */ + public function testSetSensitiveCookieNoMetadata($cookieName, $secure) { self::$isSetCookieInvoked = false; /** @var SensitiveCookieMetadata $sensitiveCookieMetadata */ $sensitiveCookieMetadata = $this->objectManager - ->getObject('Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata'); + ->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock + ] + ); $this->scopeMock->expects($this->once()) ->method('getSensitiveCookieMetadata') @@ -244,13 +275,25 @@ namespace Magento\Framework\Stdlib\Cookie { $this->returnValue($sensitiveCookieMetadata) ); + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue($secure)); + $this->cookieManager->setSensitiveCookie( - self::SENSITIVE_COOKIE_NAME_NO_METADATA, + $cookieName, 'cookie_value' ); $this->assertTrue(self::$isSetCookieInvoked); } + public function isCurrentlySecureDataProvider() + { + return [ + [self::SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS, true], + [self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS, false] + ]; + } + public function testSetSensitiveCookieNullDomainAndPath() { self::$isSetCookieInvoked = false; @@ -259,6 +302,7 @@ namespace Magento\Framework\Stdlib\Cookie { ->getObject( 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', [ + 'storeManager' => $this->storeManagerMock, 'metadata' => [ 'domain' => null, 'path' => null, @@ -275,6 +319,10 @@ namespace Magento\Framework\Stdlib\Cookie { $this->returnValue($sensitiveCookieMetadata) ); + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue(true)); + $this->cookieManager->setSensitiveCookie( self::SENSITIVE_COOKIE_NAME_NO_DOMAIN_NO_PATH, 'cookie_value', @@ -291,6 +339,7 @@ namespace Magento\Framework\Stdlib\Cookie { ->getObject( 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', [ + 'storeManager' => $this->storeManagerMock, 'metadata' => [ 'domain' => 'magento.url', 'path' => '/backend', @@ -304,6 +353,11 @@ namespace Magento\Framework\Stdlib\Cookie { ->will( $this->returnValue($sensitiveCookieMetadata) ); + + $this->storeMock->expects($this->once()) + ->method('isCurrentlySecure') + ->will($this->returnValue(false)); + $this->cookieManager->setSensitiveCookie( self::SENSITIVE_COOKIE_NAME_WITH_DOMAIN_AND_PATH, 'cookie_value', @@ -587,7 +641,7 @@ namespace Magento\Framework\Stdlib\Cookie { * Suppressing UnusedPrivateMethod, since PHPMD doesn't detect callback method use. * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private static function assertSensitiveCookieWithNoMetaData( + private static function assertSensitiveCookieWithNoMetaDataHttps( $name, $value, $expiry, @@ -596,7 +650,7 @@ namespace Magento\Framework\Stdlib\Cookie { $secure, $httpOnly ) { - self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA, $name); + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA_HTTPS, $name); self::assertEquals(self::COOKIE_VALUE, $value); self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); self::assertTrue($secure); @@ -605,6 +659,30 @@ namespace Magento\Framework\Stdlib\Cookie { 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 assertSensitiveCookieWithNoMetaDataNotHttps( + $name, + $value, + $expiry, + $path, + $domain, + $secure, + $httpOnly + ) { + self::assertEquals(self::SENSITIVE_COOKIE_NAME_NO_METADATA_NOT_HTTPS, $name); + self::assertEquals(self::COOKIE_VALUE, $value); + self::assertEquals(PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME, $expiry); + self::assertFalse($secure); + self::assertTrue($httpOnly); + self::assertEquals('', $domain); + self::assertEquals('', $path); + } + /** * Assert sensitive cookie with no domain and path * @@ -647,7 +725,7 @@ namespace Magento\Framework\Stdlib\Cookie { 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::assertFalse($secure); self::assertTrue($httpOnly); self::assertEquals('magento.url', $domain); self::assertEquals('/backend', $path); diff --git a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php index ce9c1b8e4f0..4b6aafa9f83 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadataTest.php @@ -31,15 +31,208 @@ use Magento\TestFramework\Helper\ObjectManager; */ class SensitiveCookieMetadataTest extends \PHPUnit_Framework_TestCase { + /** @var ObjectManager */ + private $objectManager; + /** @var SensitiveCookieMetadata */ private $sensitiveCookieMetadata; + /** @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ + private $storeManagerMock; + public function setUp() { - $objectManager = new ObjectManager($this); - $this->sensitiveCookieMetadata = $objectManager->getObject( - 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata' + $this->objectManager = new ObjectManager($this); + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->sensitiveCookieMetadata = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + ] + ); + } + + /** + * @param array $metadata + * @param bool $httpOnly + * @dataProvider constructorAndGetHttpOnlyTestDataProvider + */ + public function testConstructorAndGetHttpOnly($metadata, $httpOnly) + { + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + + ] + ); + $this->assertEquals($httpOnly, $object->getHttpOnly()); + $this->assertEquals('domain', $object->getDomain()); + $this->assertEquals('path', $object->getPath()); + } + + public function constructorAndGetHttpOnlyTestDataProvider() + { + return [ + 'with httpOnly' => [ + [ + SensitiveCookieMetadata::KEY_HTTP_ONLY => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + ], + 'without httpOnly' => [ + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + true, + ], + ]; + } + + /** + * @param bool $isCurrentlySecure + * @param array $metadata + * @param bool $expected + * @param int $callNum + * @dataProvider getSecureDataProvider + */ + public function testGetSecure($isCurrentlySecure, $metadata, $expected, $callNum = 1) + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->exactly($callNum)) + ->method('getStore') + ->will($this->returnValue($storeMock)); + $storeMock->expects($this->exactly($callNum)) + ->method('isCurrentlySecure') + ->willReturn($isCurrentlySecure); + + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + ] ); + $this->assertEquals($expected, $object->getSecure()); + } + + public function getSecureDataProvider() + { + return [ + 'with secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + 0, + ], + 'without secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + true, + ], + 'without secure 2' => [ + false, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + false, + ], + ]; + } + + /** + * @param bool $isCurrentlySecure + * @param array $metadata + * @param bool $expected + * @param int $callNum + * @dataProvider toArrayDataProvider + */ + public function testToArray($isCurrentlySecure, $metadata, $expected, $callNum = 1) + { + $storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManagerMock->expects($this->exactly($callNum)) + ->method('getStore') + ->will($this->returnValue($storeMock)); + $storeMock->expects($this->exactly($callNum)) + ->method('isCurrentlySecure') + ->willReturn($isCurrentlySecure); + + /** @var \Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata $object */ + $object = $this->objectManager->getObject( + 'Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata', + [ + 'storeManager' => $this->storeManagerMock, + 'metadata' => $metadata, + ] + ); + $this->assertEquals($expected, $object->__toArray()); + } + + public function toArrayDataProvider() + { + return [ + 'with secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + 0, + ], + 'without secure' => [ + true, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => true, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + ], + 'without secure 2' => [ + false, + [ + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + ], + [ + SensitiveCookieMetadata::KEY_SECURE => false, + SensitiveCookieMetadata::KEY_DOMAIN => 'domain', + SensitiveCookieMetadata::KEY_PATH => 'path', + SensitiveCookieMetadata::KEY_HTTP_ONLY => 1, + ], + ], + ]; } /** diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php index 5557fbb9a34..b93f8e87cd1 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/RepositoryTest.php @@ -37,9 +37,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase private $design; /** - * @var \Magento\Framework\View\Design\Theme\Provider|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\View\Design\Theme\ListInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\View\Asset\Source|\PHPUnit_Framework_MockObject_MockObject @@ -58,16 +58,14 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->themeProvider = $this->getMock( - '\Magento\Framework\View\Design\Theme\Provider', array(), array(), '', false - ); + $this->themeList = $this->getMockForAbstractClass('\Magento\Framework\View\Design\Theme\ListInterface'); $this->source = $this->getMock( 'Magento\Framework\View\Asset\Source', array('getFile', 'getContent'), array(), '', false ); $this->baseUrl = $this->getMockForAbstractClass('Magento\Framework\UrlInterface'); $this->design = $this->getMockForAbstractClass('Magento\Framework\View\DesignInterface'); $this->theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); - $this->object = new Repository($this->baseUrl, $this->design, $this->themeProvider, $this->source); + $this->object = new Repository($this->baseUrl, $this->design, $this->themeList, $this->source); } /** @@ -77,9 +75,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase public function testUpdateDesignParamsWrongTheme() { $params = array('area' => 'area', 'theme' => 'nonexistent_theme'); - $this->themeProvider->expects($this->once()) - ->method('getThemeModel') - ->with('nonexistent_theme', 'area') + $this->themeList->expects($this->once()) + ->method('getThemeByFullPath') + ->with('area/nonexistent_theme') ->will($this->returnValue(null)); $this->object->updateDesignParams($params); } @@ -303,8 +301,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->method('getThemePath') ->with($this->theme) ->will($this->returnValue('theme')); - $this->themeProvider->expects($this->any())->method('getThemeModel')->will($this->returnValue($this->theme)); - + $this->themeList->expects($this->any())->method('getThemeByFullPath')->will($this->returnValue($this->theme)); } /** diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php index 9de5079188e..96d75f9928c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/Asset/SourceTest.php @@ -87,10 +87,10 @@ class SourceTest extends \PHPUnit_Framework_TestCase ); $this->theme = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); - $themeProvider = $this->getMock('Magento\Framework\View\Design\Theme\Provider', array(), array(), '', false); - $themeProvider->expects($this->any()) - ->method('getThemeModel') - ->with('magento_theme', 'frontend') + $themeList = $this->getMockForAbstractClass('Magento\Framework\View\Design\Theme\ListInterface'); + $themeList->expects($this->any()) + ->method('getThemeByFullPath') + ->with('frontend/magento_theme') ->will($this->returnValue($this->theme)); $this->initFilesystem(); @@ -100,7 +100,7 @@ class SourceTest extends \PHPUnit_Framework_TestCase $this->filesystem, $this->preProcessorPool, $this->viewFileResolution, - $themeProvider + $themeList ); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php b/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php index 5ff334888c3..dead68e22fc 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/View/TemplateEngine/PhpTest.php @@ -73,11 +73,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase * Test the render() function with a nonexistent filename. * * Expect an exception if the specified file does not exist. - * We should really expect a generic \Exception, but PHPUnit will fail - * with: "You must not expect the generic exception class". This has been fixed in more recent versions of - * PHPUnit, but until all build agents get updated with PHPUnit 3.7.20, the workaround is - * to specify \PHPUnit_Framework_Error_Warning - * @expectedException \PHPUnit_Framework_Error_Warning + * @expectedException \Exception * @expectedExceptionMessage include(This_is_not_a_file): failed to open stream: No such file or directory */ public function testRenderException() diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php index df56cbcaaa0..b8715e4191a 100644 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Service/V1/WriteServiceTest.php @@ -87,7 +87,7 @@ class WriteServiceTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteRepositoryMock = $this->getMock('\Magento\Sales\Model\QuoteRepository', [], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->giftMessageManagerMock = $this->getMock('\Magento\GiftMessage\Model\GiftMessageManager', [], [], '', false); $this->helperMock = $this->getMock('\Magento\GiftMessage\Helper\Message', [], [], '', false); 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 index 92d2ca223a7..83606c52a13 100644 --- 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 @@ -71,14 +71,14 @@ class MassAddTest extends \PHPUnit_Framework_TestCase ->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 = $this->getMock('Magento\Framework\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') + ->expects($this->at(1))->method('get')->with('Magento\Framework\StoreManagerInterface') ->will($this->returnValue($storeManager)); $this->controller = $this->objectManagerHelper->getObject( diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.php new file mode 100644 index 00000000000..3e1d9743dd9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/ConfigTest.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\GoogleShopping\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + /** + * @var \Magento\GoogleShopping\Model\Config + */ + protected $model; + + public function setUp() + { + $this->scopeConfig = $this->getMock( + 'Magento\Framework\App\Config\ScopeConfigInterface', + ['getValue', 'isSetFlag'], + [], + '', + false + ); + $this->model = (new ObjectManagerHelper($this))->getObject( + 'Magento\GoogleShopping\Model\Config', + [ + 'scopeConfig' => $this->scopeConfig, + ] + ); + } + + public function testGetAccountPassword() + { + $storeId = 1; + $configPasswordKey = 'password'; + $password = 'foopass'; + $this->scopeConfig + ->expects($this->once()) + ->method('getValue') + ->with( + 'google/googleshopping/' . $configPasswordKey, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + )->will($this->returnValue($password)); + $this->assertEquals($password, $this->model->getAccountPassword($storeId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php index abc62510be2..a722982f41e 100644 --- a/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php +++ b/dev/tests/unit/testsuite/Magento/GoogleShopping/Model/MassOperationsTest.php @@ -46,7 +46,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Notification\NotifierInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $notificationInterface; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerInterface; /** @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject */ @@ -67,7 +67,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $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->storeManagerInterface = $this->getMock('Magento\Framework\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'); diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php index 925c51ffed6..42f80ad1fea 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Product/Composite/Fieldset/GroupedTest.php @@ -56,7 +56,7 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); $this->coreHelperMock = $this->getMock('\Magento\Core\Helper\Data', array(), array(), '', false); $this->storeManagerMock = $this->getMock( - '\Magento\Store\Model\StoreManagerInterface', + '\Magento\Framework\StoreManagerInterface', array(), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php index b8a69ad3217..460e8728ba7 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php @@ -62,7 +62,7 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->commonPriceMock = $this->getMock( 'Magento\Catalog\Model\Product\CatalogPrice', array(), diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php index 1957cb012fa..3de604ce7bf 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php @@ -67,7 +67,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase protected $_resourceHelper; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php index e08e7aa591c..a799d189971 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php @@ -33,7 +33,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Index\Model\IndexerFactory */ - protected $_indexFactoryMock; + protected $_indexFactory; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -43,35 +43,14 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_responseMock; + protected $_response; protected function setUp() { - $this->_filesystem = - $this->getMock('Magento\Framework\App\Filesystem', array('getDirectoryWrite'), array(), '', false); - $directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', array(), array(), '', false); - $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); - $this->_filesystem->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($directoryMock) - ); - $this->_indexFactoryMock = $this->getMock( - 'Magento\Index\Model\IndexerFactory', - array('create'), - array(), - '', - false - ); - $this->_responseMock = $this->getMock('Magento\Framework\App\Console\Response', array(), array(), '', false); - $this->_entryPoint = new \Magento\Index\App\Indexer( - 'reportDir', - $this->_filesystem, - $this->_indexFactoryMock, - $this->_responseMock - ); + $this->_filesystem = $this->getMock('Magento\Framework\App\Filesystem', ['getDirectoryWrite'], [], '', false); + $this->_indexFactory = $this->getMock('Magento\Index\Model\IndexerFactory', ['create'], [], '', false); + $this->_response = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false); + $this->_entryPoint = new Indexer('reportDir', $this->_filesystem, $this->_indexFactory, $this->_response); } /** @@ -80,16 +59,19 @@ class IndexerTest extends \PHPUnit_Framework_TestCase */ public function testLaunch($value) { + $dir = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); + $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir)); $process = $this->getMock( 'Magento\Index\Model\Process', - array('getIndexer', 'reindexEverything', '__wakeup'), - array(), + ['getIndexer', 'reindexEverything', '__wakeup'], + [], '', false ); - $indexer = $this->getMock('Magento\Index\Model\Indexer', array('getProcessesCollection'), array(), '', false); + $indexer = $this->getMock('Magento\Index\Model\Indexer', array('getProcessesCollection'), [], '', false); $indexerInterface = $this->getMock('Magento\Index\Model\IndexerInterface'); - $this->_indexFactoryMock->expects($this->once())->method('create')->will($this->returnValue($indexer)); + $this->_indexFactory->expects($this->once())->method('create')->will($this->returnValue($indexer)); $indexer->expects($this->once())->method('getProcessesCollection')->will($this->returnValue(array($process))); $process->expects($this->any())->method('getIndexer')->will($this->returnValue($indexerInterface)); @@ -100,7 +82,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false)); $process->expects($this->never())->method('reindexEverything'); } - $this->assertEquals($this->_responseMock, $this->_entryPoint->launch()); + $this->assertEquals($this->_response, $this->_entryPoint->launch()); } /** @@ -108,6 +90,12 @@ class IndexerTest extends \PHPUnit_Framework_TestCase */ public function executeDataProvider() { - return array(array(true), array(false)); + return [[true], [false]]; + } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $this->assertFalse($this->_entryPoint->catchException($bootstrap, new \Exception)); } } diff --git a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php index 37ae7a11824..033629a976a 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php @@ -73,4 +73,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase { return array(array(true), array(false)); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->_entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php index 01b557b0edd..1a6df7fa72a 100644 --- a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php @@ -33,38 +33,32 @@ class IndexerTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Processor */ - protected $processorMock; + protected $processor; /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem */ - protected $filesystemMock; + protected $filesystem; protected function setUp() { - $this->filesystemMock = $this->getMock( - 'Magento\Framework\Filesystem', - array('getDirectoryWrite'), - array(), - '', - false - ); - $directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', array(), array(), '', false); - $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); - $this->filesystemMock->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($directoryMock) - ); - $this->processorMock = $this->getMock('Magento\Indexer\Model\Processor', array(), array(), '', false); - $this->entryPoint = new \Magento\Indexer\App\Indexer('reportDir', $this->filesystemMock, $this->processorMock); + $this->filesystem = $this->getMock('Magento\Framework\Filesystem', ['getDirectoryWrite'], [], '', false); + $this->processor = $this->getMock('Magento\Indexer\Model\Processor', [], [], '', false); + $this->entryPoint = new Indexer('reportDir', $this->filesystem, $this->processor); } public function testExecute() { - $this->processorMock->expects($this->once())->method('reindexAll'); + $dir = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); + $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); + $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir)); + $this->processor->expects($this->once())->method('reindexAll'); $this->assertEquals('0', $this->entryPoint->launch()); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', [], [], '', false); + $this->assertFalse($this->entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php index f0fb2505ed5..655bf3a6d9f 100644 --- a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php @@ -78,4 +78,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase { return array(array(true), array(false)); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->entryPoint->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php deleted file mode 100644 index 937a39034c7..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php +++ /dev/null @@ -1,114 +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\Install\App\Action\Plugin; - -class DirTest extends \PHPUnit_Framework_TestCase -{ - /** - * Dir plugin - * - * @var \Magento\Install\App\Action\Plugin\Dir - */ - protected $plugin; - - /** - * App state mock - * - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\State - */ - protected $appStateMock; - - /** - * Var directory - * - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem\Directory\Write - */ - protected $varDirectory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $filesystem = - $this->getMock('Magento\Framework\App\Filesystem', array('getDirectoryWrite'), array(), '', false); - $this->varDirectory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', - array('read', 'isDirectory', 'delete'), - array(), - '', - false - ); - $filesystem->expects( - $this->once() - )->method( - 'getDirectoryWrite' - )->with( - \Magento\Framework\App\Filesystem::VAR_DIR - )->will( - $this->returnValue($this->varDirectory) - ); - $logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); - $this->subjectMock = $this->getMock('Magento\Install\Controller\Index\Index', array(), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->plugin = new \Magento\Install\App\Action\Plugin\Dir($this->appStateMock, $filesystem, $logger); - } - - /** - * Test when app is installed - */ - public function testBeforeDispatchWhenAppIsInstalled() - { - $directories = array('dir1', 'dir2'); - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->varDirectory->expects($this->once())->method('read')->will($this->returnValue($directories)); - $this->varDirectory->expects( - $this->exactly(count($directories)) - )->method( - 'isDirectory' - )->will( - $this->returnValue(true) - ); - $this->varDirectory->expects($this->exactly(count($directories)))->method('delete'); - $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); - } - - /** - * Test when app is not installed - */ - public function testBeforeDispatchWhenAppIsNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->varDirectory->expects($this->never())->method('read'); - $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php deleted file mode 100644 index 941c1c06449..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.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\Install\App\Action\Plugin; - -class InstallTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\App\Action\Plugin\Install - */ - protected $_plugin; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_response; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_urlMock; - - /** - * @var \Closure - */ - protected $closureMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - protected function setUp() - { - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_response = - $this->getMock('Magento\Framework\App\ResponseInterface', array('setRedirect', 'sendResponse')); - $this->_urlMock = $this->getMock('Magento\Framework\Url', array(), array(), '', false); - $this->closureMock = function () { - return 'ExpectedValue'; - }; - $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', array(), array(), '', false); - $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->_plugin = new \Magento\Install\App\Action\Plugin\Install( - $this->_appStateMock, - $this->_response, - $this->_urlMock, - $this->getMock('Magento\Framework\App\ActionFlag', array(), array(), '', false) - ); - } - - public function testAroundDispatchWhenApplicationIsNotInstalled() - { - $url = 'http://example.com'; - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_urlMock->expects($this->once())->method('getUrl')->with('install')->will($this->returnValue($url)); - $this->_response->expects($this->once())->method('setRedirect')->with($url); - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock); - } - - public function testAroundDispatchWhenApplicationIsInstalled() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - - $this->assertEquals( - 'ExpectedValue', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php deleted file mode 100644 index 7514f813693..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php +++ /dev/null @@ -1,276 +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\Install\App; - -class ConsoleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\App\Console - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\Model\Installer\Console - */ - protected $_installerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Filesystem\DirectoryList\Verification - */ - protected $_dirVerifierMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\App\Output - */ - protected $_outputMock; - - /** \PHPUnit_Framework_MockObject_MockObject|\Magento\Install\Model\Installer\ConsoleFactory */ - protected $_instFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configLoaderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_objectManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_responseMock; - - protected function setUp() - { - $this->_instFactoryMock = $this->getMock( - '\Magento\Install\Model\Installer\ConsoleFactory', - array('create'), - array(), - '', - false - ); - $this->_installerMock = $this->getMock('Magento\Install\Model\Installer\Console', array(), array(), '', false); - $this->_dirVerifierMock = $this->getMock( - 'Magento\Framework\App\Filesystem\DirectoryList\Verification', - array(), - array(), - '', - false - ); - $this->_outputMock = $this->getMock('Magento\Install\App\Output', array(), array(), '', false); - $this->_appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_configLoaderMock = $this->getMockBuilder( - 'Magento\Framework\App\ObjectManager\ConfigLoader' - )->disableOriginalConstructor()->getMock(); - $this->_instFactoryMock->expects( - $this->any() - )->method( - 'create' - )->will( - $this->returnValue($this->_installerMock) - ); - - $this->_configLoaderMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'install' - )->will( - $this->returnValue(array('di' => 'config')) - ); - - $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); - $this->_objectManagerMock->expects($this->once())->method('configure')->with(array('di' => 'config')); - } - - protected function _createModel($params = array()) - { - $directory = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Read', - array('isExist', 'getRelativePath'), - array(), - '', - false - ); - $filesystem = $this->getMock( - 'Magento\Framework\App\Filesystem', - array('getDirectoryRead', '__wakeup'), - array(), - '', - false - ); - $filesystem->expects( - $this->once() - )->method( - 'getDirectoryRead' - )->with( - \Magento\Framework\App\Filesystem::ROOT_DIR - )->will( - $this->returnValue($directory) - ); - if (isset($params['config'])) { - $directory->expects( - $this->once() - )->method( - 'getRelativePath' - )->with( - $params['config'] - )->will( - $this->returnValue($params['config']) - ); - $directory->expects( - $this->once() - )->method( - 'isExist' - )->with( - $params['config'] - )->will( - $this->returnValue(true) - ); - } - $this->_responseMock = $this->getMock('Magento\Framework\App\Console\Response', array(), array(), '', false); - return new \Magento\Install\App\Console( - $this->_instFactoryMock, - $this->_outputMock, - $this->_appStateMock, - $this->_configLoaderMock, - $this->_objectManagerMock, - $filesystem, - $this->_responseMock, - $params - ); - } - - /** - * @param string $param - * @param string $method - * @param string $testValue - * @dataProvider executeShowsRequestedDataProvider - */ - public function testLaunchShowsRequestedData($param, $method, $testValue) - { - $model = $this->_createModel(array($param => true)); - $this->_installerMock->expects($this->once())->method($method)->will($this->returnValue($testValue)); - $this->_outputMock->expects($this->once())->method('readableOutput')->with($testValue); - $this->_outputMock->expects( - $this->once() - )->method( - 'prepareArray' - )->with( - $testValue - )->will( - $this->returnArgument(0) - ); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function executeShowsRequestedDataProvider() - { - return array( - array('show_locales', 'getAvailableLocales', array('locales')), - array('show_currencies', 'getAvailableCurrencies', array('currencies')), - array('show_timezones', 'getAvailableTimezones', array('timezones')) - ); - } - - public function testLaunchShowsInstallOptions() - { - $required = array('required params'); - $optional = array('optional params'); - - $model = $this->_createModel(array('show_install_options' => true)); - $this->_installerMock->expects( - $this->once() - )->method( - 'getRequiredParams' - )->will( - $this->returnValue($required) - ); - $this->_installerMock->expects( - $this->once() - )->method( - 'getOptionalParams' - )->will( - $this->returnValue($optional) - ); - $this->_outputMock->expects($this->exactly(2))->method('alignArrayKeys'); - $this->_outputMock->expects($this->at(1))->method('alignArrayKeys')->with($required); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testInstallReportsSuccessMessage() - { - $model = $this->_createModel(array()); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('successfully')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testInstallReportsEncryptionKey() - { - $model = $this->_createModel(array()); - $this->_installerMock->expects($this->once())->method('install')->will($this->returnValue('enc_key')); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('enc_key')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testUninstallReportsSuccess() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('Uninstalled')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testUninstallReportsIgnoreIfApplicationIsNotInstalled() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(false)); - $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('non-installed')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testExecuteReportsErrors() - { - $model = $this->_createModel(array('uninstall' => true)); - $this->_installerMock->expects($this->once())->method('hasErrors')->will($this->returnValue(true)); - $this->_installerMock->expects($this->once())->method('getErrors')->will($this->returnValue(array('error1'))); - $this->_outputMock->expects($this->once())->method('error')->with($this->stringContains('error1')); - $this->assertEquals($this->_responseMock, $model->launch()); - } - - public function testExecuteLoadsExtraConfig() - { - $model = $this->_createModel(array('config' => realpath(__DIR__ . '/_files/config.php'))); - $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); - $this->assertEquals($this->_responseMock, $model->launch()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php b/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php deleted file mode 100644 index f456fcc56f7..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Controller/Wizard/LocaleTest.php +++ /dev/null @@ -1,301 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Test class for \Magento\Install\Block\Wizard - */ -namespace Magento\Install\Controller\Wizard; - -/** - * Class WizardTest - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class LocaleTest extends \PHPUnit_Framework_TestCase -{ - /** - * Locale to test - */ - const LOCALE = 'xx_XX'; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Install\Block\Locale - */ - protected $_block; - - /** - * @var \Magento\Framework\App\ViewInterface - */ - protected $_viewMock; - - /** - * @var \Magento\Install\Model\Installer - */ - protected $_installerMock; - - /** - * @var \Magento\Framework\View\LayoutInterface - */ - protected $_layoutMock; - - /** - * @var \Magento\Install\Controller\Wizard - */ - protected $_controller; - - /** - * @var \Magento\Framework\App\Action\Context - */ - protected $_contextMock; - - /** - * @var \Magento\Install\Model\Wizard - */ - protected $_wizardMock; - - /** - * @var \Magento\Framework\Session\Generic - */ - protected $_sessionMock; - - /** - * @var \Magento\Framework\App\RequestInterface - */ - protected $_requestMock; - - /** - * @var \Magento\Framework\App\ResponseInterface - */ - protected $_responseMock; - - /** - * @var \Magento\Framework\App\ActionFlag - */ - protected $_actionFlagMock; - - /** - * @var \Magento\Framework\View\Element\Template\Context - */ - protected $_blockContextMock; - - /** - * Set up before test - * - * @return void - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $this->_installerMock = $this->getMock( - '\Magento\Install\Model\Installer', - array('isApplicationInstalled'), - array(), - '', - false - ); - $this->_installerMock->expects($this->any())->method('isApplicationInstalled')->will($this->returnValue(true)); - - - $this->_blockMock = $this->getMock('\Magento\Install\Block\Locale', array(), array(), '', false); - - - - $this->_layoutMock = $this->getMock( - '\Magento\Framework\View\Layout', - array('getBlock', 'initMessages', 'addBlock'), - array(), - '', - false - ); - - $this->_layoutMock->expects( - $this->any() - )->method( - 'initMessages' - )->withAnyParameters()->will( - $this->returnValue(true) - ); - $this->_layoutMock->expects( - $this->any() - )->method( - 'addBlock' - )->withAnyParameters()->will( - $this->returnValue(true) - ); - - - $this->_viewMock = $this->getMockForAbstractClass( - '\Magento\Framework\App\ViewInterface', - array(), - '', - false, - false, - true, - array('getLayout') - ); - $this->_viewMock->expects( - $this->any() - )->method( - 'getLayout' - )->withAnyParameters()->will( - $this->returnValue($this->_layoutMock) - ); - - $this->_requestMock = $this->_getClearMock('\Magento\Framework\App\RequestInterface'); - $this->_responseMock = $this->_getClearMock('\Magento\Framework\App\ResponseInterface'); - $this->_actionFlagMock = $this->_getClearMock('\Magento\Framework\App\ActionFlag'); - - $this->_contextMock = $this->getMock( - '\Magento\Framework\App\Action\Context', - array('getView', 'getRequest', 'getResponse', 'getActionFlag'), - array(), - '', - false - ); - $this->_contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->_viewMock)); - $this->_contextMock->expects( - $this->any() - )->method( - 'getRequest' - )->will( - $this->returnValue($this->_requestMock) - ); - $this->_contextMock->expects( - $this->any() - )->method( - 'getResponse' - )->will( - $this->returnValue($this->_responseMock) - ); - $this->_contextMock->expects( - $this->any() - )->method( - 'getActionFlag' - )->will( - $this->returnValue($this->_actionFlagMock) - ); - - - $this->_blockContextMock = $this->getMock( - '\Magento\Framework\View\Element\Template\Context', - array(), - array(), - '', - false - ); - - - - $this->_wizardMock = $this->getMock( - '\Magento\Install\Model\Wizard', - array('getStepByRequest'), - array(), - '', - false - ); - $this->_wizardMock->expects( - $this->any() - )->method( - 'getStepByRequest' - )->withAnyParameters()->will( - $this->returnValue(false) - ); - - $this->_sessionMock = $this->getMock( - '\Magento\Framework\Session\Generic', - array('getLocale'), - array(), - '', - false - ); - $this->_sessionMock->expects($this->any())->method('getLocale')->will($this->returnValue(self::LOCALE)); - - $this->_block = $this->_objectManager->getObject( - 'Magento\Install\Block\Locale', - array( - 'context' => $this->_blockContextMock, - 'installer' => $this->_installerMock, - 'installWizard' => $this->_wizardMock, - 'session' => $this->_sessionMock, - 'data' => array() - ) - ); - - $this->_layoutMock->expects( - $this->any() - )->method( - 'getBlock' - )->with( - 'install.locale' - )->will( - $this->returnValue($this->_block) - ); - - $this->_controller = $this->_objectManager->getObject( - 'Magento\Install\Controller\Wizard\Locale', - array( - 'context' => $this->_contextMock, - 'configScope' => $this->_getClearMock('Magento\Framework\Config\Scope'), - 'installer' => $this->_getClearMock('Magento\Install\Model\Installer'), - 'wizard' => $this->_wizardMock, - 'session' => $this->_sessionMock, - 'dbUpdater' => $this->_getClearMock('Magento\Framework\Module\UpdaterInterface'), - 'storeManager' => $this->_getClearMock('Magento\Store\Model\StoreManagerInterface'), - 'appState' => $this->_getClearMock('Magento\Framework\App\State') - ) - ); - } - - /** - * Get clear mock - * - * @param string $className - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function _getClearMock($className) - { - return $this->getMock($className, array(), array(), '', false); - } - - /** - * Test setting locale from session - */ - public function testExecute() - { - $this->_controller->execute(); - $this->assertEquals( - $this->_block->getLocaleCode(), - self::LOCALE, - 'Failed asserting that locale is set from session' - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php deleted file mode 100644 index 5142ba2a297..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConfigTest.php +++ /dev/null @@ -1,159 +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\Install\Model\Installer; - -class ConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var string - */ - protected $_tmpConfigFile = 'local.xml'; - - /** - * @var \Magento\Install\Model\Installer\Config - */ - protected $_model; - - /** - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_filesystemMock; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_directoryMock; - - /** - * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_messageManager; - - protected function setUp() - { - $this->_directoryMock = $this->getMock( - 'Magento\Framework\Filesystem\Directory\Write', - array(), - array(), - '', - false - ); - - $this->_filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->_filesystemMock->expects( - $this->any() - )->method( - 'getPath' - )->with( - \Magento\Framework\App\Filesystem::CONFIG_DIR - )->will( - $this->returnValue(TESTS_TEMP_DIR) - ); - $this->_filesystemMock->expects( - $this->any() - )->method( - 'getDirectoryWrite' - )->will( - $this->returnValue($this->_directoryMock) - ); - - $this->_messageManager = $this->getMock( - '\Magento\Framework\Message\ManagerInterface', - array(), - array(), - '', - false - ); - $this->_model = new \Magento\Install\Model\Installer\Config( - $this->getMock('Magento\Install\Model\Installer', array(), array(), '', false), - $this->getMock('Magento\Framework\App\RequestInterface', array(), array(), '', false), - $this->_filesystemMock, - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), - $this->_messageManager - ); - } - - protected function tearDown() - { - $this->_model = null; - } - - public function testReplaceTmpInstallDate() - { - $datePlaceholder = \Magento\Install\Model\Installer\Config::TMP_INSTALL_DATE_VALUE; - $fixtureConfigData = "<date>{$datePlaceholder}</date>"; - $expectedConfigData = '<date>Sat, 19 Jan 2013 18:50:39 -0800</date>'; - - $this->_directoryMock->expects( - $this->once() - )->method( - 'readFile' - )->with( - $this->equalTo($this->_tmpConfigFile) - )->will( - $this->returnValue($fixtureConfigData) - ); - $this->_directoryMock->expects( - $this->once() - )->method( - 'writeFile' - )->with( - $this->equalTo($this->_tmpConfigFile), - $this->equalTo($expectedConfigData) - )->will( - $this->returnValue($fixtureConfigData) - ); - - $this->_model->replaceTmpInstallDate('Sat, 19 Jan 2013 18:50:39 -0800'); - } - - public function testReplaceTmpEncryptKey() - { - $keyPlaceholder = \Magento\Install\Model\Installer\Config::TMP_ENCRYPT_KEY_VALUE; - $fixtureConfigData = "<key>{$keyPlaceholder}</key>"; - $expectedConfigData = '<key>3c7cf2e909fd5e2268a6e1539ae3c835</key>'; - - $this->_directoryMock->expects( - $this->once() - )->method( - 'readFile' - )->with( - $this->equalTo($this->_tmpConfigFile) - )->will( - $this->returnValue($fixtureConfigData) - ); - $this->_directoryMock->expects( - $this->once() - )->method( - 'writeFile' - )->with( - $this->equalTo($this->_tmpConfigFile), - $this->equalTo($expectedConfigData) - )->will( - $this->returnValue($fixtureConfigData) - ); - - $this->_model->replaceTmpEncryptKey('3c7cf2e909fd5e2268a6e1539ae3c835'); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php deleted file mode 100644 index fb13b45e3d5..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/ConsoleTest.php +++ /dev/null @@ -1,229 +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\Install\Model\Installer; - -class ConsoleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\Model\Installer\Console - */ - protected $model; - - /** - * @var \Magento\Framework\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystemMock; - - /** - * @var \Magento\Framework\Filesystem\Directory\Write|\PHPUnit_Framework_MockObject_MockObject - */ - protected $directoryMock; - - protected $defaultRenderer; - - protected function setUp() - { - $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); - } - - /** - * {inheritdoc} - */ - protected function tearDown() - { - $this->model = null; - \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); - } - - /** - * Test uninstall() - */ - public function testUninstall() - { - $this->model = $this->getModelMock(); - - $this->directoryMock->expects($this->exactly(2)) - ->method('delete')->with($this->logicalOr($this->equalTo(TESTS_TEMP_DIR), $this->equalTo('local.xml'))) - ->will($this->returnValue(true)); - - $this->assertTrue($this->model->uninstall()); - - } - - /** - * Test uninstall() when error is triggered - */ - public function testUninstallWithError() - { - $this->model = $this->getModelMock(); - - $this->directoryMock->expects($this->exactly(2)) - ->method('delete')->with($this->logicalOr($this->equalTo(TESTS_TEMP_DIR), $this->equalTo('local.xml'))) - ->will( - $this->throwException( - new \Magento\Framework\Filesystem\FilesystemException(sprintf( - 'The file "%s" cannot be deleted %s', - TESTS_TEMP_DIR, - "Warning" - )) - ) - ); - $expectedString = str_repeat(sprintf('Please delete the file manually : "%s" ' . "\n", TESTS_TEMP_DIR), 2); - - $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->will( - $this->returnValue($this->directoryMock) - ); - $this->expectOutputString($expectedString); - $result = $this->model->uninstall(); - - $this->assertTrue($result); - - } - - /** - * @param array $items - * @param array $expectedResult - * @dataProvider checkServerDataProvider - */ - public function testCheckServer($items, $expectedResult) - { - // 1. Create mocks - /** @var \Magento\Install\Model\Installer\Data|\PHPUnit_Framework_MockObject_MockObject $installerData */ - list($this->model, $installerData) = $this->getMocks($items); - - // 2. Set expectations - for ($i = 0; $i < count($items); $i++) { - $text = $expectedResult[$i]; - $installerData->expects($this->at($i))->method('addError')->with($text); - } - - // 3. Run tested method - $this->model->checkServer(); - } - - /** - * @return array - */ - public function checkServerDataProvider() - { - $messageA = $this->getMockBuilder('SomeClass')->setMethods(['toString'])->getMock(); - $messageA->expects($this->any())->method('toString')->will($this->returnValue('textA')); - - $messageB = $this->getMockBuilder('SomeClass')->setMethods(['toString'])->getMock(); - $messageB->expects($this->any())->method('toString')->will($this->returnValue('textB')); - - return [ - [[$messageA, $messageB], ['textA', 'textB']], - [[$messageB, $messageA], ['textB', 'textA']], - ]; - } - - protected function getModelMock() - { - $dbModelName = 'Magento\Install\Model\Installer\Db\Mysql4'; - $this->directoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); - $this->directoryMock->expects( - $this->once() - )->method('read')->will($this->returnValue([TESTS_TEMP_DIR])); - - $this->directoryMock->expects( - $this->any() - )->method('isDirectory')->will($this->returnValue(true)); - - $this->filesystemMock = $this->getMock('Magento\Framework\App\Filesystem', [], [], '', false); - $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->with()->will( - $this->returnValue($this->directoryMock) - ); - /** - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject - */ - $appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - - $dbModelMock = $this->getMock($dbModelName, [], [], '', false); - $dbModelMock->expects($this->any())->method('cleanUpDatabase')->will($this->returnValue($this)); - /** - * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject - */ - $objectManagerMock = $this->getMock('Magento\Framework\ObjectManager', [], [], '', false); - $objectManagerMock->expects($this->any())->method('get')->with($dbModelName)->will( - $this->returnValue($dbModelMock) - ); - - return new \Magento\Install\Model\Installer\Console( - $this->getMock('Magento\Install\Model\Installer', [], [], '', false), - $this->getMock('Magento\Framework\App\Resource\Config', [], [], '', false), - $this->getMock('Magento\Framework\Module\UpdaterInterface', [], [], '', false), - $this->filesystemMock, - $this->getMock('Magento\Install\Model\Installer\Data', [], [], '', false), - $appStateMock, - $this->getMock('Magento\Framework\Locale\ListsInterface', [], [], '', false), - $objectManagerMock - ); - } - - /** - * @param array $items - * @return array - */ - protected function getMocks($items) - { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - - $installerData = $this->getMockBuilder('Magento\Install\Model\Installer\Data') - ->disableOriginalConstructor() - ->setMethods(['addError']) - ->getMock(); - - $phraseRenderer = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') - ->disableOriginalConstructor() - ->getMock(); - - $messageCollection = $this->getMockBuilder('SomeClass') - ->setMethods(['getItems']) - ->getMock(); - - $messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - - $objectManager = $this->getMockBuilder('Magento\Framework\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $messageCollection->expects($this->any())->method('getItems')->will($this->returnValue($items)); - $messageManager->expects($this->any())->method('getMessages')->will($this->returnValue($messageCollection)); - $objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - ['Magento\Framework\Phrase\RendererInterface', $phraseRenderer], - ['Magento\Framework\Message\ManagerInterface', $messageManager], - ])); - - $consoleInstaller = $helper->getObject('Magento\Install\Model\Installer\Console', [ - 'objectManager' => $objectManager, - 'installerData' => $installerData, - ]); - - return [$consoleInstaller, $installerData]; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php deleted file mode 100644 index 5356c819102..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Install\Model\Installer\Db; - -class Mysql4Test extends \PHPUnit_Framework_TestCase -{ - /** - * Test possible ways of declaring InnoDB engine by MySQL - * - * @dataProvider possibleEngines - * @param array $supportedEngines - * @param $expectedResult - * @return void - */ - public function testSupportEngine(array $supportedEngines, $expectedResult) - { - $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); - $connectionMock->expects($this->once())->method('fetchPairs')->will($this->returnValue($supportedEngines)); - - $adapterFactory = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\MysqlFactory', - array('create'), - array(), - '', - false - ); - $adapterMock = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\Mysql', - array('getConnection'), - array(), - '', - false - ); - $adapterMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock)); - $adapterFactory->expects($this->once())->method('create')->will($this->returnValue($adapterMock)); - - $localConfig = - $this->getMockBuilder('\Magento\Framework\App\Arguments')->disableOriginalConstructor()->getMock(); - - $installer = new \Magento\Install\Model\Installer\Db\Mysql4($adapterFactory, $localConfig); - $this->assertEquals($expectedResult, $installer->supportEngine()); - } - - /** - * Data provider for returned engines from mysql and expectations. - * @return array - */ - public function possibleEngines() - { - return array( - array(array('InnoDB' => 'DEFAULT'), true), - array(array('InnoDB' => 'YES'), true), - array(array('wrongEngine' => '123'), false) - ); - } - - /** - * @dataProvider getRequiredExtensionsDataProvider - * - * @param $config - * @param $dbExtensions - * @param $expectedResult - */ - public function testGetRequiredExtensions($config, $dbExtensions, $expectedResult) - { - $adapterFactory = $this->getMock( - 'Magento\Framework\Model\Resource\Type\Db\Pdo\MysqlFactory', - array('create'), - array(), - '', - false - ); - $localConfig = - $this->getMockBuilder('\Magento\Framework\App\Arguments')->disableOriginalConstructor()->getMock(); - $installer = new \Magento\Install\Model\Installer\Db\Mysql4($adapterFactory, $localConfig, $dbExtensions); - $installer->setConfig($config); - $this->assertEquals($expectedResult, $installer->getRequiredExtensions()); - } - - /** - * Data provider for testGetRequiredExtensions - * - * @return array - */ - public function getRequiredExtensionsDataProvider() - { - return array( - 'wrong model' => array(array('db_model' => 'mysql66'), array('mysql' => array('pdo_test1')), array()), - 'full extensions' => array( - array('db_model' => 'mysql'), - array('mysql' => array('pdo' => 'pdo_ext1', 'pdo_ext2', 'pdo2' => 'pdo_ext3')), - array('pdo' => 'pdo_ext1', 'pdo_ext2', 'pdo2' => 'pdo_ext3') - ), - 'empty extensions' => array( - array('db_model' => 'mysql'), - array('mysql' => array(), 'mysql2' => array('pdo_ext1', 'pdo_ext2')), - array() - ) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php deleted file mode 100644 index d198583f8b1..00000000000 --- a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php +++ /dev/null @@ -1,137 +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\Install\Model; - -class InstallerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Install\Model\Installer - */ - protected $_model; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * Application chache model - * - * @var \Magento\Framework\App\CacheInterface - */ - protected $_cache; - - /** - * Application config model - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_config; - - /** - * @var \Magento\Framework\App\Cache\StateInterface - */ - protected $_cacheState; - - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var \Magento\Framework\App\Cache\TypeListInterface - */ - protected $_cacheTypeList; - - /** - * @var \Magento\Install\Model\Installer\Config - */ - protected $_installerConfig; - - /** - * Set up before test - */ - public function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_cache = $this->getMock('\Magento\Framework\App\CacheInterface', array(), array(), '', false); - $this->_config = - $this->getMock('\Magento\Framework\App\Config\ReinitableConfigInterface', array(), array(), '', false); - $this->_cacheState = $this->getMock('\Magento\Framework\App\Cache\StateInterface', array(), array(), '', false); - $this->_cacheTypeList = - $this->getMock('\Magento\Framework\App\Cache\TypeListInterface', array(), array(), '', false); - $this->_appState = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); - $this->_installerConfig = $this->getMock( - '\Magento\Install\Model\Installer\Config', - array(), - array(), - '', - false - ); - - $this->_model = $this->_objectManager->getObject( - 'Magento\Install\Model\Installer', - array( - 'cache' => $this->_cache, - 'config' => $this->_config, - 'cacheState' => $this->_cacheState, - 'cacheTypeList' => $this->_cacheTypeList, - 'appState' => $this->_appState, - 'installerConfig' => $this->_installerConfig - ) - ); - } - - public function testFinish() - { - $cacheTypeListArray = array('one', 'two'); - - $this->_cache->expects($this->once())->method('clean'); - - $this->_config->expects($this->once())->method('reinit'); - - $this->_cacheState->expects($this->once())->method('persist'); - $this->_cacheState->expects($this->exactly(count($cacheTypeListArray)))->method('setEnabled'); - - $this->_cacheTypeList->expects( - $this->once() - )->method( - 'getTypes' - )->will( - $this->returnValue($cacheTypeListArray) - ); - - $this->_appState->expects($this->once())->method('setInstallDate')->with($this->greaterThanOrEqual(date('r'))); - - $this->_installerConfig->expects( - $this->once() - )->method( - 'replaceTmpInstallDate' - )->with( - $this->greaterThanOrEqual(date('r')) - ); - - $this->assertSame($this->_model, $this->_model->finish()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php b/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php index e5c33c55864..1fb606b462c 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Helper/Oauth/ConsumerTest.php @@ -25,7 +25,7 @@ namespace Magento\Integration\Helper\Oauth; class ConsumerTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Integration\Model\Oauth\Consumer\Factory */ @@ -80,7 +80,7 @@ class ConsumerTest extends \PHPUnit_Framework_TestCase $this->_tokenFactory->expects($this->any())->method('create')->will($this->returnValue($this->_tokenMock)); $this->_storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->getMockForAbstractClass(); $this->_storeMock = $this->getMockBuilder( 'Magento\Store\Model\Store' diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php index 32ac2a83407..e592aeee44b 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/AdminTokenServiceTest.php @@ -1,6 +1,6 @@ <?php /** - * Test for \Magento\Integration\Service\V1\TokenService + * Test for \Magento\Integration\Service\V1\AdminTokenService * * Magento * @@ -31,7 +31,7 @@ use Magento\Integration\Model\Oauth\Token; class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase { - /** \Magento\Integration\Service\V1\TokenService */ + /** \Magento\Integration\Service\V1\AdminTokenService */ protected $_tokenService; /** \Magento\Integration\Model\Oauth\Token\Factory|\PHPUnit_Framework_MockObject_MockObject */ @@ -46,9 +46,10 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase /** \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelCollectionFactoryMock; - /** - * @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject - */ + /** @var \Magento\Integration\Helper\Validator|\PHPUnit_Framework_MockObject_MockObject */ + protected $validatorHelperMock; + + /** @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject */ private $_tokenMock; protected function setUp() @@ -62,11 +63,6 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_customerAccountServiceMock = $this - ->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->_tokenMock = $this->getMockBuilder('Magento\Integration\Model\Oauth\Token') ->disableOriginalConstructor() ->setMethods(['getToken', 'loadByAdminId', 'setRevoked', 'save', '__wakeup'])->getMock(); @@ -74,8 +70,8 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase $this->_tokenModelCollectionMock = $this->getMockBuilder( 'Magento\Integration\Model\Resource\Oauth\Token\Collection' )->disableOriginalConstructor()->setMethods( - ['addFilterByAdminId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] - )->getMock(); + ['addFilterByAdminId', 'getSize', '__wakeup', '_beforeLoad', '_afterLoad', 'getIterator'] + )->getMock(); $this->_tokenModelCollectionFactoryMock = $this->getMockBuilder( 'Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory' @@ -85,11 +81,15 @@ class AdminTokenServiceTest extends \PHPUnit_Framework_TestCase ->method('create') ->will($this->returnValue($this->_tokenModelCollectionMock)); - $this->_tokenService = new \Magento\Integration\Service\V1\TokenService( + $this->validatorHelperMock = $this->getMockBuilder( + 'Magento\Integration\Helper\Validator' + )->disableOriginalConstructor()->getMock(); + + $this->_tokenService = new \Magento\Integration\Service\V1\AdminTokenService( $this->_tokenModelFactoryMock, $this->_userModelMock, - $this->_customerAccountServiceMock, - $this->_tokenModelCollectionFactoryMock + $this->_tokenModelCollectionFactoryMock, + $this->validatorHelperMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php similarity index 89% rename from dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php rename to dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php index 3c381a05d0c..47e28378949 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/TokenServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/CustomerTokenServiceTest.php @@ -1,6 +1,6 @@ <?php /** - * Test for \Magento\Integration\Service\V1\TokenService + * Test for \Magento\Integration\Service\V1\CustomerTokenService * * Magento * @@ -29,17 +29,14 @@ namespace Magento\Integration\Service\V1; use Magento\Integration\Model\Integration; use Magento\Integration\Model\Oauth\Token; -class TokenServiceTest extends \PHPUnit_Framework_TestCase +class CustomerTokenServiceTest extends \PHPUnit_Framework_TestCase { - /** \Magento\Integration\Service\V1\TokenService */ + /** \Magento\Integration\Service\V1\CustomerTokenService */ protected $_tokenService; /** \Magento\Integration\Model\Oauth\Token\Factory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelFactoryMock; - /** \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject */ - protected $_userModelMock; - /** \Magento\Customer\Service\V1\CustomerAccountServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_customerAccountServiceMock; @@ -49,9 +46,10 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase /** \Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $_tokenModelCollectionFactoryMock; - /** - * @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject - */ + /** @var \Magento\Integration\Helper\Validator|\PHPUnit_Framework_MockObject_MockObject */ + protected $validatorHelperMock; + + /** @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject */ private $_tokenMock; protected function setUp() @@ -61,10 +59,6 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_userModelMock = $this->getMockBuilder('Magento\User\Model\User') - ->disableOriginalConstructor() - ->getMock(); - $this->_customerAccountServiceMock = $this ->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') ->disableOriginalConstructor() @@ -88,11 +82,15 @@ class TokenServiceTest extends \PHPUnit_Framework_TestCase ->method('create') ->will($this->returnValue($this->_tokenModelCollectionMock)); - $this->_tokenService = new \Magento\Integration\Service\V1\TokenService( + $this->validatorHelperMock = $this->getMockBuilder( + 'Magento\Integration\Helper\Validator' + )->disableOriginalConstructor()->getMock(); + + $this->_tokenService = new \Magento\Integration\Service\V1\CustomerTokenService( $this->_tokenModelFactoryMock, - $this->_userModelMock, $this->_customerAccountServiceMock, - $this->_tokenModelCollectionFactoryMock + $this->_tokenModelCollectionFactoryMock, + $this->validatorHelperMock ); } 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 199ccae56c8..ededc36d2ad 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Service/V1/OauthTest.php @@ -108,7 +108,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase ); $this->_service = new \Magento\Integration\Service\V1\Oauth( - $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false), + $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false), $this->_consumerFactory, $this->_tokenFactoryMock, $this->getMock('Magento\Integration\Helper\Oauth\Data', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php index da687ffb30d..509d48f3ad2 100644 --- a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php @@ -68,4 +68,10 @@ class ShellTest extends \PHPUnit_Framework_TestCase $shellMock->expects($this->once())->method('run'); $this->assertEquals($this->_responseMock, $this->_model->launch()); } + + public function testCatchException() + { + $bootstrap = $this->getMock('Magento\Framework\App\Bootstrap', array(), array(), '', false); + $this->assertFalse($this->_model->catchException($bootstrap, new \Exception)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php b/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php new file mode 100644 index 00000000000..8baa4509989 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.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\Log\Block\Adminhtml\Customer\Edit\Tab\View; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class StatusTest + * @package Magento\Log\Block\Adminhtml\Edit\Tab\View + */ +class StatusTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status + */ + protected $block; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $logFactory; + + /** + * @var \Magento\Log\Model\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerLog; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDate; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + protected function setUp() + { + $log = $this->getMock('Magento\Log\Model\Log', ['getOnlineMinutesInterval'], [], '', false); + $log->expects($this->any())->method('getOnlineMinutesInterval')->will($this->returnValue(1)); + + $this->customerLog = $this->getMockBuilder('Magento\Log\Model\Customer')->disableOriginalConstructor() + ->setMethods(['getLoginAt', 'getLoginAtTimestamp', 'loadByCustomer', 'getLogoutAt', 'getLastVisitAt']) + ->getMock(); + $this->customerLog->expects($this->any())->method('loadByCustomer')->will($this->returnSelf()); + + $this->logFactory = $this->getMockBuilder('Magento\Log\Model\CustomerFactory')->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->logFactory->expects($this->any())->method('create')->will($this->returnValue($this->customerLog)); + + $dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime')->setMethods(['now']) + ->disableOriginalConstructor() + ->getMock(); + $dateTime->expects($this->any())->method('now')->will($this->returnCallback(function () { + return date('Y-m-d H:i:s'); + })); + + $customer = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Customer') + ->setMethods(['getId', 'getStoreId']) + ->disableOriginalConstructor()->getMock(); + $customer->expects($this->any())->method('getId')->will($this->returnValue(1)); + $customer->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); + + $customerData = array('account' => ['id' => 1, 'store_id' => 1]); + $customerBuilder = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\CustomerBuilder') + ->setMethods(['populateWithArray', 'create']) + ->disableOriginalConstructor() + ->getMock(); + $customerBuilder->expects($this->any())->method('populateWithArray') + ->will($this->returnSelf()); + $customerBuilder->expects($this->any())->method('create') + ->will($this->returnValue($customer)); + + $backendSession = $this->getMockBuilder('\Magento\Backend\Model\Session') + ->setMethods(['getCustomerData'])->disableOriginalConstructor()->getMock(); + $backendSession->expects($this->any())->method('getCustomerData')->will($this->returnValue($customerData)); + + $this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Timezone') + ->setMethods(['scopeDate', 'formatDate', 'getDefaultTimezonePath']) + ->disableOriginalConstructor()->getMock(); + $this->localeDate->expects($this->any())->method('getDefaultTimezonePath') + ->will($this->returnValue('path/to/default/timezone')); + + $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config') + ->setMethods(['getValue']) + ->disableOriginalConstructor()->getMock(); + + $objectManagerHelper = new ObjectManagerHelper($this); + $this->block = $objectManagerHelper->getObject( + 'Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status', + [ + 'logFactory' => $this->logFactory, + 'localeDate' => $this->localeDate, + 'scopeConfig' => $this->scopeConfig, + 'modelLog' => $log, + 'dateTime' => $dateTime, + 'customerBuilder' => $customerBuilder, + 'backendSession' => $backendSession + ] + ); + } + + public function testGetCustomerLog() + { + $this->logFactory->expects($this->once())->method('create')->will($this->returnValue($this->customerLog)); + $this->assertSame($this->customerLog, $this->block->getCustomerLog()); + } + + public function testGetCurrentStatusOffline() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue($date)); + $this->assertEquals('Offline', $this->block->getCurrentStatus()); + } + + public function testGetCurrentStatusOnline() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue(0)); + $this->customerLog->expects($this->any())->method('getLastVisitAt')->will($this->returnValue($date)); + $this->assertEquals('Online', $this->block->getCurrentStatus()); + } + + public function testGetLastLoginDate() + { + $date = date('Y-m-d H:i:s'); + $this->customerLog->expects($this->any())->method('getLoginAt')->will($this->returnValue($date)); + $this->localeDate->expects($this->once())->method('formatDate')->will($this->returnValue($date)); + $this->assertEquals($date, $this->block->getLastLoginDate()); + } + + public function testAfterGetLastLoginDateNever() + { + $this->assertEquals('Never', $this->block->getLastLoginDate()); + } + + public function testGetStoreLastLoginDate() + { + $date = date('Y-m-d H:i:s'); + $time = strtotime($date); + + $this->localeDate->expects($this->once())->method('scopeDate')->will($this->returnValue($date)); + $this->localeDate->expects($this->once())->method('formatDate')->will($this->returnValue($date)); + + $this->customerLog->expects($this->any())->method('getLoginAtTimestamp')->will($this->returnValue($time)); + $this->assertEquals($date, $this->block->getStoreLastLoginDate()); + } + + public function testGetStoreLastLoginDateNever() + { + $this->assertEquals('Never', $this->block->getStoreLastLoginDate()); + } + + public function testGetStoreLastLoginDateTimezone() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with('path/to/default/timezone', 'store', 1) + ->will($this->returnValue('America/Los_Angeles')); + $this->block->getStoreLastLoginDateTimezone(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php b/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.php new file mode 100644 index 00000000000..f16c957f892 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Log/Model/LogTest.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. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Log\Model; + +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class LogTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Log\Model\Log + */ + protected $log; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + protected function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods(['clean', 'getIdFieldName']) + ->disableOriginalConstructor() + ->getMock(); + $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $resource->expects($this->any())->method('clean')->will($this->returnSelf()); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $arguments = $this->objectManagerHelper->getConstructArguments( + 'Magento\Log\Model\Log', + [ + 'registry' => $this->registry, + 'scopeConfig' => $this->scopeConfig, + 'resource' => $resource + ] + ); + $this->log = $this->objectManagerHelper->getObject('Magento\Log\Model\Log', $arguments); + } + + public function testGetLogCleanTime() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with(Log::XML_LOG_CLEAN_DAYS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ->will($this->returnValue(30)); + $this->assertEquals(2592000, $this->log->getLogCleanTime()); + } + + public function testClean() + { + $this->assertSame($this->log, $this->log->clean()); + } + + public function testGetOnlineMinutesInterval() + { + $this->scopeConfig->expects($this->once())->method('getValue') + ->with( + 'customer/online_customers/online_minutes_interval', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->will($this->returnValue(10)); + + $this->assertEquals(10, $this->log->getOnlineMinutesInterval()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php b/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php index f3831db35cd..3f5f3360230 100644 --- a/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/Model/VisitorTest.php @@ -21,49 +21,151 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Log\Model; +use \Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + class VisitorTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Log\Model\Visitor */ - protected $_model; + protected $visitor; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Framework\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionManagerInterface; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerInterface; + + /** + * @var \Magento\Framework\HTTP\Header|\PHPUnit_Framework_MockObject_MockObject + */ + protected $header; + + /** + * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress|\PHPUnit_Framework_MockObject_MockObject + */ + protected $remoteAddress; + + /** + * @var \Magento\Framework\HTTP\PhpEnvironment\ServerAddress|\PHPUnit_Framework_MockObject_MockObject + */ + protected $serverAddress; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTime; + + public function setUp() + { + $this->registry = $this->getMock('Magento\Framework\Registry'); + $this->sessionManagerInterface = $this->getMock('Magento\Framework\Session\SessionManagerInterface'); + $this->storeManagerInterface = $this->getMock('Magento\Framework\StoreManagerInterface'); + $this->header = $this->getMock('Magento\Framework\HTTP\Header', [], [], '', false); + $this->remoteAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\RemoteAddress', [], [], '', false); + $this->serverAddress = $this->getMock('Magento\Framework\HTTP\PhpEnvironment\ServerAddress', [], [], '', false); + $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); + + $store = $this->getMock('\Magento\Store\Model\Store', [], [], '', false, false); + $this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($store)); + $this->dateTime->expects($this->any())->method('now')->will($this->returnValue(time())); + + $resource = $this->getMockBuilder('Magento\Customer\Model\Resource\Visitor') + ->setMethods([ + 'beginTransaction', + '__sleep', + '__wakeup', + 'getIdFieldName', + 'save', + 'addCommitCallback', + 'commit' + ])->disableOriginalConstructor()->getMock(); + $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id')); + $resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); - protected function setUp() + $objectManagerHelper = new ObjectManagerHelper($this); + $arguments = $objectManagerHelper->getConstructArguments( + 'Magento\Log\Model\Visitor', + [ + 'registry' => $this->registry, + 'session' => $this->sessionManagerInterface, + 'storeManager' => $this->storeManagerInterface, + 'httpHeader' => $this->header, + 'remoteAddress' => $this->remoteAddress, + 'serverAddress' => $this->serverAddress, + 'dateTime' => $this->dateTime, + 'resource' => $resource + ] + ); + + $this->visitor = $objectManagerHelper->getObject('Magento\Log\Model\Visitor', $arguments); + } + + public function testInitServerData() { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_model = $helper->getObject('Magento\Log\Model\Visitor'); + $data = array( + 'server_addr', 'remote_addr', 'http_secure', 'http_host', 'http_user_agent', + 'http_accept_language', 'http_accept_charset', 'request_uri', 'http_referer' + ); + $result = array_diff($data, array_keys($this->visitor->initServerData()->getData())); + $this->assertEmpty($result); } - public function testBindCustomerLogin() + public function testGetUrl() { - $customer = new \Magento\Framework\Object(['id' => '1']); - $observer = new \Magento\Framework\Object([ - 'event' => new \Magento\Framework\Object(['customer' => $customer]) + $this->visitor->setData([ + 'http_secure' => false, + 'http_host' => 'magento.com', + 'request_uri' => '/?some=query' ]); + $this->assertEquals('http://magento.com/?some=query', $this->visitor->getUrl()); + } - $this->_model->bindCustomerLogin($observer); - $this->assertTrue($this->_model->getDoCustomerLogin()); - $this->assertEquals($customer->getId(), $this->_model->getCustomerId()); + public function testGetFirstVisitAt() + { + $time = time(); + $this->assertEquals($time, $this->visitor->getFirstVisitAt()); + } - $this->_model->unsetData(); - $this->_model->setCustomerId('2'); - $this->_model->bindCustomerLogin($observer); - $this->assertNull($this->_model->getDoCustomerLogin()); - $this->assertEquals('2', $this->_model->getCustomerId()); + public function testGetLastVisitAt() + { + $time = time(); + $this->dateTime->expects($this->once())->method('now')->will($this->returnValue($time)); + $this->assertEquals($time, $this->visitor->getLastVisitAt()); } - public function testBindCustomerLogout() + public function testLogNewVisitor() { - $observer = new \Magento\Framework\Object(); + $visitor = $this->getMockBuilder('Magento\Customer\Model\Visitor') + ->disableOriginalConstructor()->getMock(); + $visitor->expects($this->once())->method('setData')->will($this->returnSelf()); + $visitor->expects($this->once())->method('getData')->will($this->returnValue([])); + $event = new \Magento\Framework\Object(['visitor' => $visitor]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertSame($this->visitor, $this->visitor->logNewVisitor($observer)); + } - $this->_model->setCustomerId('1'); - $this->_model->bindCustomerLogout($observer); - $this->assertTrue($this->_model->getDoCustomerLogout()); + public function testLogVisitorActivity() + { + $visitor = $this->getMockBuilder('Magento\Customer\Model\Visitor') + ->disableOriginalConstructor()->getMock(); + $visitor->expects($this->once())->method('setData')->will($this->returnSelf()); + $visitor->expects($this->once())->method('getData')->will($this->returnValue(['visitor_id' => 1])); - $this->_model->unsetData(); - $this->_model->bindCustomerLogout($observer); - $this->assertNull($this->_model->getDoCustomerLogout()); + $event = new \Magento\Framework\Object(['visitor' => $visitor]); + $observer = new \Magento\Framework\Object(['event' => $event]); + $this->assertSame($this->visitor, $this->visitor->logVisitorActivity($observer)); } } diff --git a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php index 50edbe9aa7c..baa5925050e 100644 --- a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php +++ b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php @@ -36,7 +36,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase $sourceString = 'Ë£'; // Test protected method via reflection - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $localeResolver = $this->getMock('\Magento\Framework\Locale\ResolverInterface', array(), array(), '', false); $urlBuilder = $this->getMock('Magento\Framework\UrlInterface', array(), array(), '', false); $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php index dff4e4e7ef8..af1a4607909 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/MessageBoxTest.php @@ -138,6 +138,10 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase ->method('setPath') ->with('/') ->will($this->returnValue($this->publicCookieMetadataMock)); + $this->publicCookieMetadataMock->expects(($this->exactly($numOfCalls))) + ->method('setHttpOnly') + ->with(false) + ->will($this->returnValue($this->publicCookieMetadataMock)); $this->cookieManagerMock->expects($this->exactly($numOfCalls)) ->method('setPublicCookie') ->with( diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php index 03085b85ebe..d85615fdb7d 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FreeTest.php @@ -40,7 +40,7 @@ class FreeTest extends \PHPUnit_Framework_TestCase $paymentData = $this->getMock('Magento\Payment\Helper\Data', [], [], '', false); $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); $logAdapterFactory = $this->getMock('Magento\Framework\Logger\AdapterFactory', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $this->methodFree = new \Magento\Payment\Model\Method\Free( $eventManager, diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php index e8d5e987d61..dfe08cdc4e6 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php @@ -27,28 +27,95 @@ namespace Magento\Paypal\Model\Express; class CheckoutTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Paypal\Model\Express\Checkout + * @var \Magento\Paypal\Model\Express\Checkout | \Magento\Paypal\Model\Express\Checkout */ - protected $_checkoutModel; + protected $checkoutModel; /** * @var \Magento\TestFramework\Helper\ObjectManager */ - protected $_objectManager; + protected $objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject | \'Magento\Sales\Model\Quote */ - protected $_quoteMock; + protected $quoteMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Sales\Model\Service\Quote + */ + protected $serviceQuote; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Sales\Model\Service\QuoteFactory + */ + protected $quoteFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $customerAccountServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Service\V1\Data\AddressBuilderFactory + */ + protected $addressBuilderFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Framework\Object\Copy + */ + protected $objectCopyServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \\Magento\Customer\Model\Session + */ + protected $customerSessionMock; protected function setUp() { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $this->serviceQuote = $this->getMock('\Magento\Sales\Model\Service\Quote', [], [], '', false); + $this->quoteFactoryMock = $this->getMock( + '\Magento\Sales\Model\Service\QuoteFactory', + ['create'], + [], + '', + false + ); + $this->customerAccountServiceMock = $this->getMock( + '\Magento\Customer\Service\V1\CustomerAccountServiceInterface', + [], + [], + '', + false + ); + $this->addressBuilderFactoryMock = $this->getMockBuilder( + '\Magento\Customer\Service\V1\Data\AddressBuilderFactory' + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->objectCopyServiceMock = $this->getMockBuilder('\Magento\Framework\Object\Copy') + ->disableOriginalConstructor() + ->getMock(); + $this->customerSessionMock = $this->getMockBuilder('\Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); $paypalConfigMock = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); - $this->_quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); - $this->_checkoutModel = $this->_objectManager->getObject( + $this->checkoutModel = $this->objectManager->getObject( 'Magento\Paypal\Model\Express\Checkout', - ['params' => ['quote' => $this->_quoteMock, 'config' => $paypalConfigMock]] + [ + 'params' => [ + 'quote' => $this->quoteMock, + 'config' => $paypalConfigMock, + 'session' => $this->customerSessionMock + ], + 'customerAccountService' => $this->customerAccountServiceMock, + 'serviceQuoteFactory' => $this->quoteFactoryMock, + 'addressBuilderFactory' => $this->addressBuilderFactoryMock, + 'objectCopyService' => $this->objectCopyServiceMock + ] ); parent::setUp(); } @@ -57,9 +124,9 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Customer\Service\V1\Data\Customer $customerDataMock */ $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); - $this->_quoteMock->expects($this->once())->method('assignCustomer')->with($customerDataMock); + $this->quoteMock->expects($this->once())->method('assignCustomer')->with($customerDataMock); $customerDataMock->expects($this->once())->method('getId'); - $this->_checkoutModel->setCustomerData($customerDataMock); + $this->checkoutModel->setCustomerData($customerDataMock); } public function testSetCustomerWithAddressChange() @@ -68,11 +135,85 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); /** @var \Magento\Sales\Model\Quote\Address $customerDataMock */ $quoteAddressMock = $this->getMock('Magento\Sales\Model\Quote\Address', [], [], '', false); - $this->_quoteMock + $this->quoteMock ->expects($this->once()) ->method('assignCustomerWithAddressChange') ->with($customerDataMock, $quoteAddressMock, $quoteAddressMock); $customerDataMock->expects($this->once())->method('getId'); - $this->_checkoutModel->setCustomerWithAddressChange($customerDataMock, $quoteAddressMock, $quoteAddressMock); + $this->checkoutModel->setCustomerWithAddressChange($customerDataMock, $quoteAddressMock, $quoteAddressMock); + } + + public function testPrepareNewCustomerQuote() + { + $this->quoteMock->expects($this->any()) + ->method('getCheckoutMethod') + ->willReturn(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); + $this->quoteMock->expects($this->once()) + ->method('setCustomerData') + ->willReturnSelf(); + + $this->quoteFactoryMock->expects($this->once()) + ->method('create') + ->withAnyParameters() + ->willReturn($this->serviceQuote); + + $this->objectCopyServiceMock->expects($this->once()) + ->method('getDataFromFieldset') + ->withAnyParameters() + ->willReturn([]); + + $this->customerSessionMock->expects($this->once()) + ->method('regenerateId'); + + $addressDataBuilderMock = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\AddressBuilder') + ->disableOriginalConstructor() + ->getMock(); + $this->addressBuilderFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($addressDataBuilderMock); + $addressDataBuilderMock->expects($this->any()) + ->method('populate') + ->withAnyParameters() + ->willReturnSelf(); + $addressDataBuilderMock->expects($this->any()) + ->method('setDefaultShipping') + ->withAnyParameters() + ->willReturnSelf(); + $addressDataBuilderMock->expects($this->any()) + ->method('setDefaultBilling') + ->withAnyParameters() + ->willReturnSelf(); + + $addressDataMock = $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Address') + ->disableOriginalConstructor() + ->getMock(); + $addressDataBuilderMock->expects($this->any()) + ->method('create') + ->willReturn($addressDataMock); + + $addressMock = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $this->quoteMock->expects($this->any()) + ->method('getBillingAddress') + ->willReturn($addressMock); + $this->quoteMock->expects($this->any()) + ->method('getShippingAddress') + ->willReturn($addressMock); + $addressMock->expects($this->any()) + ->method('exportCustomerAddressData') + ->willReturn( + $this->getMockBuilder('\Magento\Customer\Service\V1\Data\Address')->disableOriginalConstructor() + ->getMock() + ); + + $customerDataMock = $this->getMock('Magento\Customer\Service\V1\Data\Customer', [], [], '', false); + $this->customerAccountServiceMock->expects($this->any()) + ->method('getCustomer') + ->willReturn($customerDataMock); + $this->quoteMock->expects($this->any()) + ->method('getCustomerData') + ->willReturn($customerDataMock); + + $this->checkoutModel->setCustomerData($customerDataMock); + $this->checkoutModel->place('token'); } } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php index b2eb2eba5e8..12577017263 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/PayflowlinkTest.php @@ -46,7 +46,7 @@ class PayflowlinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->paypalConfig = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false); $configFactory = $this->getMock('Magento\Paypal\Model\ConfigFactory', ['create']); diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php index 04d046fccae..2ae45f8ba6b 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/SessionTest.php @@ -150,6 +150,10 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('setDuration') ->with($duration) ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') ->will($this->returnValue($cookieMetadataMock)); @@ -189,6 +193,10 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->method('setDuration') ->with($cookieDuration) ->will($this->returnSelf()); + $cookieMetadataMock->expects($this->exactly($numCalls)) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->exactly($numCalls)) ->method('createPublicCookieMetadata') ->will($this->returnValue($cookieMetadataMock)); diff --git a/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php index d9822720aa2..94a73d8be82 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringPayment/Block/Payment/Related/Orders/GridTest.php @@ -39,7 +39,7 @@ class GridTest extends \PHPUnit_Framework_TestCase protected $registry; /** - * @var \Magento\Store\Model\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; @@ -68,7 +68,7 @@ class GridTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->collection = $this->getMock('Magento\Sales\Model\Resource\Order\Collection', [], [], '', false); $this->locale = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); $this->helper = $this->getMock('Magento\Core\Helper\Data', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php b/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php index 1447ab7a6ec..ee93f49934a 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Block/Customer/RecentTest.php @@ -45,12 +45,12 @@ class RecentTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Helper\Session\CurrentCustomer|\PHPUnit_Framework_MockObject_MockObject */ protected $currentCustomer; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManager; protected function setUp() { - $this->storeManager = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManager = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->context = $this->getMock('Magento\Framework\View\Element\Template\Context', array(), array(), '', false); $this->context->expects( $this->any() diff --git a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php index c131a2f30ae..8ad7ed218d6 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Controller/Adminhtml/Product/PostTest.php @@ -153,7 +153,7 @@ class PostTest extends \PHPUnit_Framework_TestCase '\Magento\Framework\ObjectManager', array('get', 'create', 'configure'), array(), '', false ); $this->_messageManagerMock = $this->getMock('\Magento\Framework\Message\Manager', array(), array(), '', false); - $this->_storeManagerInterfaceMock = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerInterfaceMock = $this->getMockForAbstractClass('Magento\Framework\StoreManagerInterface'); $this->_storeModelMock = $this->getMock( 'Magento\Store\Model\Store', array('__wakeup', 'getId'), array(), '', false ); @@ -203,7 +203,7 @@ class PostTest extends \PHPUnit_Framework_TestCase $this->_requestMock->expects($this->once())->method('getPost') ->will($this->returnValue(array('status_id' => 1))); $this->_objectManagerMock->expects($this->at(0))->method('get') - ->with('Magento\Store\Model\StoreManagerInterface') + ->with('Magento\Framework\StoreManagerInterface') ->will($this->returnValue($this->_storeManagerInterfaceMock)); $this->_reviewFactoryMock->expects($this->once())->method('create') ->will($this->returnValue($this->_reviewModelMock)); diff --git a/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php b/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php index 7d31c946bfb..6f4beff55b6 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Model/ReviewTest.php @@ -55,7 +55,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Review\Model\Review\Summary|\PHPUnit_Framework_MockObject_MockObject */ protected $summaryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -82,7 +82,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase $this->reviewSummaryMock = $this->getMock('Magento\Review\Model\Resource\Review\Summary\CollectionFactory'); $this->summaryModMock = $this->getMock('Magento\Review\Model\Review\SummaryFactory', ['create']); $this->summaryMock = $this->getMock('Magento\Review\Model\Review\Summary', [], [], '', false); - $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->urlInterfaceMock = $this->getMock('Magento\Framework\UrlInterface'); $this->resource = $this->getMock('Magento\Review\Model\Resource\Review', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php index fe3e665b7a4..7d92ee2e721 100644 --- a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php +++ b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/ReviewTest.php @@ -46,7 +46,7 @@ class ReviewTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $reviewFactoryMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\UrlInterface */ diff --git a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php index a459721a1fc..ead8fc8130c 100644 --- a/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php +++ b/dev/tests/unit/testsuite/Magento/Rss/Block/Catalog/SpecialTest.php @@ -97,7 +97,7 @@ class SpecialTest extends \PHPUnit_Framework_TestCase $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); $requestMock = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.php new file mode 100644 index 00000000000..7ccc9c55de7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/ActionFactoryTest.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\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ActionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\ActionFactory + */ + protected $actionFactory; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->actionFactory = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\ActionFactory', + [ + 'objectManager' => $this->objectManagerMock + ] + ); + } + + public function testCreate() + { + $type = '1'; + $data = ['data2', 'data3']; + $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data); + $this->actionFactory->create($type, $data); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php index 4fa1edea8b0..9320cabcfb8 100644 --- a/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php @@ -28,13 +28,19 @@ use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; class CombineTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Rule\Model\Condition\Combine */ + /** + * @var \Magento\Rule\Model\Condition\Combine + */ protected $_combine; - /** @var ObjectManagerHelper */ + /** + * @var ObjectManagerHelper + */ protected $_objectManagerHelper; - /** @var \Magento\Rule\Model\Condition\Context|\PHPUnit_Framework_MockObject_MockObject */ + /** + * @var \Magento\Rule\Model\Condition\Context|\PHPUnit_Framework_MockObject_MockObject + */ protected $_contextMock; protected function setUp() diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php new file mode 100644 index 00000000000..c9189658941 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.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\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConditionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\ConditionFactory + */ + protected $conditionFactory; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager'); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->conditionFactory = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\ConditionFactory', + [ + 'objectManager' => $this->objectManagerMock + ] + ); + } + + public function testCreate() + { + $type = '1'; + $data = ['data2', 'data3']; + $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data); + $this->conditionFactory->create($type, $data); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.php new file mode 100644 index 00000000000..25379e64341 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ActionsTest.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\Rule\Model\Renderer; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ActionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Renderer\Actions + */ + protected $actions; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_element; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->actions = $this->objectManagerHelper->getObject('Magento\Rule\Model\Renderer\Actions'); + $this->_element = $this->getMock( + '\Magento\Framework\Data\Form\Element\AbstractElement', + ['getRule'], + [], + '', + false + ); + } + + public function testRender() + { + $rule = $this->getMock('\Magento\Rule\Model\Rule', ['getActions', '__sleep', '__wakeup'], [], '', false); + $actions = $this->getMock('\Magento\Rule\Model\Action\Collection', ['asHtmlRecursive'], [], '', false); + + $this->_element->expects($this->any()) + ->method('getRule') + ->will($this->returnValue($rule)); + + $rule->expects($this->any()) + ->method('getActions') + ->will($this->returnValue($actions)); + + $actions->expects($this->once()) + ->method('asHtmlRecursive') + ->will($this->returnValue('action html')); + + $this->assertEquals('action html', $this->actions->render($this->_element)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.php new file mode 100644 index 00000000000..425d5a19251 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Renderer/ConditionsTest.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\Rule\Model\Renderer; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ConditionsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Renderer\Conditions + */ + protected $conditions; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_element; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->conditions = $this->objectManagerHelper->getObject('Magento\Rule\Model\Renderer\Conditions'); + $this->_element = $this->getMock( + '\Magento\Framework\Data\Form\Element\AbstractElement', + ['getRule'], + [], + '', + false + ); + } + + public function testRender() + { + $rule = $this->getMock('\Magento\Rule\Model\Rule', ['getConditions', '__sleep', '__wakeup'], [], '', false); + $conditions = $this->getMock('\Magento\Rule\Model\Condition\Combine', ['asHtmlRecursive'], [], '', false); + + $this->_element->expects($this->any()) + ->method('getRule') + ->will($this->returnValue($rule)); + + $rule->expects($this->any()) + ->method('getConditions') + ->will($this->returnValue($conditions)); + + $conditions->expects($this->once()) + ->method('asHtmlRecursive') + ->will($this->returnValue('conditions html')); + + $this->assertEquals('conditions html', $this->conditions->render($this->_element)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php new file mode 100644 index 00000000000..26305d5db96 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Resource/Rule/Collection/AbstractCollectionTest.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model\Resource\Rule\Collection; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class AbstractCollectionTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $abstractCollection; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Data\Collection\EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_entityFactoryMock; + + /** + * @var \Magento\Framework\Logger|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_loggerMock; + + /** + * @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_fetchStrategyMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_managerMock; + + /** + * @var \Magento\Framework\Model\Resource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_db; + + protected function setUp() + { + $this->_entityFactoryMock = $this->getMock('Magento\Framework\Data\Collection\EntityFactoryInterface'); + $this->_loggerMock = $this->getMock('Magento\Framework\Logger', [], [], '', false); + $this->_fetchStrategyMock = $this->getMock('Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $this->_managerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->_db = $this->getMockForAbstractClass( + '\Magento\Framework\Model\Resource\Db\AbstractDb', + [], + '', + false, + false, + true, + ['__sleep', '__wakeup'] + ); + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->abstractCollection = $this->getMockForAbstractClass( + '\Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection', + [ + 'entityFactory' => $this->_entityFactoryMock, + 'logger' => $this->_loggerMock, + 'fetchStrategy' => $this->_fetchStrategyMock, + 'eventManager' => $this->_managerMock, + null, + $this->_db + ], + '', + false, + false, + true, + ['__sleep', '__wakeup', '_getAssociatedEntityInfo', 'getConnection', 'getSelect', 'getTable'] + ); + } + + public function testAddWebsitesToResultDataProvider() + { + return [ + [null, true], + [true, true], + [false, false] + ]; + } + + /** + * @dataProvider testAddWebsitesToResultDataProvider + */ + public function testAddWebsitesToResult($flag, $expectedResult) + { + $this->abstractCollection->addWebsitesToResult($flag); + $this->assertEquals($expectedResult, $this->abstractCollection->getFlag('add_websites_to_result')); + } + + protected function _prepareAddFilterStubs() + { + $entityInfo = []; + $entityInfo['entity_id_field'] = 'entity_id'; + $entityInfo['rule_id_field'] = 'rule_id'; + $entityInfo['associations_table'] = 'assoc_table'; + + $connection = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'); + $select = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + $collectionSelect = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false); + + $connection->expects($this->any()) + ->method('select') + ->will($this->returnValue($select)); + + $select->expects($this->any()) + ->method('from') + ->will($this->returnSelf()); + + $select->expects($this->any()) + ->method('where') + ->will($this->returnSelf()); + + $collectionSelect->expects($this->once()) + ->method('exists'); + + $this->abstractCollection->expects($this->any()) + ->method('getConnection') + ->will($this->returnValue($connection)); + + $this->_db->expects($this->any()) + ->method('getTable') + ->will($this->returnArgument(0)); + + $this->abstractCollection->expects($this->any()) + ->method('getSelect') + ->will($this->returnValue($collectionSelect)); + + $this->abstractCollection->expects($this->any()) + ->method('_getAssociatedEntityInfo') + ->will($this->returnValue($entityInfo)); + } + + public function testAddWebsiteFilter() + { + $this->_prepareAddFilterStubs(); + $website = $this->getMock('\Magento\Store\Model\Website', ['getId', '__sleep', '__wakeup'], [], '', false); + + $website->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + + $this->assertInstanceOf( + '\Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection', + $this->abstractCollection->addWebsiteFilter($website) + ); + } + + public function testAddFieldToFilter() + { + $this->_prepareAddFilterStubs(); + $this->abstractCollection->addFieldToFilter('website_ids', []); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php new file mode 100644 index 00000000000..9c1ba6b8341 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/RuleTest.php @@ -0,0 +1,125 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Rule\Model; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class RuleTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Rule\Model\Rule + */ + protected $rule; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \Magento\Framework\Data\FormFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $formFactoryMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $timezoneMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $combineFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionFactoryMock; + + protected function setUp() + { + $this->contextMock = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); + $this->registryMock = $this->getMock('Magento\Framework\Registry'); + $this->formFactoryMock = $this->getMock('Magento\Framework\Data\FormFactory', [], [], '', false); + $this->timezoneMock = $this->getMock('Magento\Framework\Stdlib\DateTime\TimezoneInterface'); + $this->combineFactoryMock = $this->getMock( + 'Magento\Rule\Model\Condition\CombineFactory', + ['create'], + [], + '', + false + ); + $this->collectionFactoryMock = $this->getMock( + 'Magento\Rule\Model\Action\CollectionFactory', + ['create'], + [], + '', + false + ); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->rule = $this->objectManagerHelper->getObject( + 'Magento\Rule\Model\Rule', + [ + 'context' => $this->contextMock, + 'registry' => $this->registryMock, + 'formFactory' => $this->formFactoryMock, + 'localeDate' => $this->timezoneMock, + 'conditionsFactory' => $this->combineFactoryMock, + 'actionsFactory' => $this->collectionFactoryMock + ] + ); + } + + public function testGetConditionsInstance() + { + $this->combineFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue( + $this->getMock('\Magento\Rule\Model\Condition\Combine', [], [], '', false) + )); + $this->assertInstanceOf('\Magento\Rule\Model\Condition\Combine', $this->rule->getConditionsInstance()); + } + + public function testGetActionsInstance() + { + $this->collectionFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue( + $this->getMock('\Magento\Rule\Model\Action\Collection', [], [], '', false) + )); + $this->assertInstanceOf('\Magento\Rule\Model\Action\Collection', $this->rule->getActionsInstance()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php index 824d7c00769..e894cf00b6b 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/AdminTest.php @@ -33,7 +33,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase protected $contextMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; @@ -62,7 +62,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase $this->contextMock = $this->getMockBuilder('Magento\Framework\App\Helper\Context') ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); $this->salesConfigMock = $this->getMockBuilder('Magento\Sales\Model\Config') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php index 433b70301f7..dbfe647e681 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/DataTest.php @@ -55,7 +55,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php index ebf3e20e2de..4e58251dc92 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/GuestTest.php @@ -44,7 +44,7 @@ class GuestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $scopeConfigInterfaceMock; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerInterfaceMock; /** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ @@ -75,13 +75,13 @@ class GuestTest extends \PHPUnit_Framework_TestCase { $this->appContextHelperMock = $this->getMock('Magento\Framework\App\Helper\Context', [], [], '', false); $this->scopeConfigInterfaceMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->storeManagerInterfaceMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerInterfaceMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->stateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); $this->registryMock = $this->getMock('Magento\Framework\Registry'); $this->sessionMock = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); $this->cookieMetadataFactoryMock = $this->getMock( - '\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', [], [], '', @@ -153,13 +153,31 @@ class GuestTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); $protectedCode = 'protectedCode'; $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $metaDataMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $metaDataMock->expects($this->once()) + ->method('setPath') + ->with(Guest::COOKIE_PATH) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setDuration') + ->with(Guest::COOKIE_LIFETIME) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') - ->will($this->returnValue($metaData)); + ->will($this->returnValue($metaDataMock)); $this->cookieManagerMock->expects($this->once()) ->method('setPublicCookie') - ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); + ->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); $this->assertTrue($this->guest->loadValidOrder($requestMock, $responseMock)); } @@ -186,13 +204,31 @@ class GuestTest extends \PHPUnit_Framework_TestCase $orderMock->expects($this->once())->method('loadByIncrementId')->with($incrementId); $orderMock->expects($this->exactly(1))->method('getId')->will($this->returnValue($incrementId)); $orderMock->expects($this->once())->method('getProtectCode')->will($this->returnValue($protectedCode)); - $metaData = new \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata(); + $metaDataMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $metaDataMock->expects($this->once()) + ->method('setPath') + ->with(Guest::COOKIE_PATH) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setDuration') + ->with(Guest::COOKIE_LIFETIME) + ->will($this->returnSelf()); + $metaDataMock->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->will($this->returnSelf()); $this->cookieMetadataFactoryMock->expects($this->once()) ->method('createPublicCookieMetadata') - ->will($this->returnValue($metaData)); + ->will($this->returnValue($metaDataMock)); $this->cookieManagerMock->expects($this->once()) ->method('setPublicCookie') - ->with(Guest::COOKIE_NAME, $this->anything(), $metaData); + ->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); $requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php index 67c17e48bb5..a7c77fcac8e 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Helper/ReorderTest.php @@ -65,7 +65,7 @@ class ReorderTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Install/Controller/Wizard/Download.php b/dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/Download.php rename to dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php index 377c77f9600..af39f91adfe 100644 --- a/app/code/Magento/Install/Controller/Wizard/Download.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/AbstractModelTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,25 +21,31 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Sales\Model; -class Download extends \Magento\Install\Controller\Wizard +/** + * Class AbstractModelTest + */ +class AbstractModelTest extends \PHPUnit_Framework_TestCase { /** - * Download page action - * - * @return void + * @var \Magento\Sales\Model\Order */ - public function execute() + protected $model; + + public function setUp() { - $this->_checkIfInstalled(); - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->model = $objectManager->getObject('Magento\Sales\Model\Order'); + } - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); - $this->_view->getLayout()->addBlock('Magento\Install\Block\Download', 'install.download', 'content'); + public function testGetEventPrefix() + { + $this->assertEquals('sales_order', $this->model->getEventPrefix()); + } - $this->_view->renderLayout(); + public function testGetEventObject() + { + $this->assertEquals('order', $this->model->getEventObject()); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.php new file mode 100644 index 00000000000..7be1ab86c28 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/IncrementTest.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\Model; + +/** + * Class IncrementTest + */ +class IncrementTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Increment + */ + protected $model; + + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfig; + + /** + * @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject + */ + protected $type; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', ['getEntityType'], [], '', false); + $this->model = $objectManager->getObject('Magento\Sales\Model\Increment', ['eavConfig' => $this->eavConfig]); + $this->type = $this->getMock('Magento\Eav\Model\Entity\Type', ['fetchNewIncrementId'], [], '', false); + } + + public function testGetCurrentValue() + { + $this->type->expects($this->once()) + ->method('fetchNewIncrementId') + ->with(1) + ->willReturn(2); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with('order') + ->willReturn($this->type); + $this->model->getNextValue(1); + $this->assertEquals(2, $this->model->getCurrentValue()); + } + + public function testNextValue() + { + $this->type->expects($this->once()) + ->method('fetchNewIncrementId') + ->with(1) + ->willReturn(2); + $this->eavConfig->expects($this->once()) + ->method('getEntityType') + ->with('order') + ->willReturn($this->type); + $this->assertEquals(2, $this->model->getNextValue(1)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php new file mode 100644 index 00000000000..57c33fdc766 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportBestsellersDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportBestsellersDataTest + */ +class AggregateSalesReportBestsellersDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $bestsellersFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportBestsellersData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->bestsellersFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\BestsellersFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportBestsellersData( + $this->localeResolverMock, + $this->localeDateMock, + $this->bestsellersFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $bestsellersMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Bestsellers') + ->disableOriginalConstructor() + ->getMock(); + $bestsellersMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->bestsellersFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($bestsellersMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php new file mode 100644 index 00000000000..cb05422bb01 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportInvoicedDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportInvoicedDataTest + */ +class AggregateSalesReportInvoicedDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoicedFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportInvoicedData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->invoicedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\InvoicedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportInvoicedData( + $this->localeResolverMock, + $this->localeDateMock, + $this->invoicedFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $invoicedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Invoiced') + ->disableOriginalConstructor() + ->getMock(); + $invoicedMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->invoicedFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($invoicedMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php new file mode 100644 index 00000000000..3f5555f10b3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportOrderDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportOrderDataTest + */ +class AggregateSalesReportOrderDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\OrderFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportOrderData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\OrderFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportOrderData( + $this->localeResolverMock, + $this->localeDateMock, + $this->orderFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Order') + ->disableOriginalConstructor() + ->getMock(); + $orderMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->orderFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($orderMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php new file mode 100644 index 00000000000..4e4d952327e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/AggregateSalesReportRefundedDataTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\AggregateSalesReportRefundedDataTest + */ +class AggregateSalesReportRefundedDataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeResolverMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Sales\Model\Resource\Report\RefundedFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $refundedFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\AggregateSalesReportRefundedData + */ + protected $observer; + + protected function setUp() + { + $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->refundedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\RefundedFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AggregateSalesReportRefundedData( + $this->localeResolverMock, + $this->localeDateMock, + $this->refundedFactoryMock + ); + } + + + public function testExecute() + { + $date = $this->setupAggregate(); + $refundedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Refunded') + ->disableOriginalConstructor() + ->getMock(); + $refundedMock->expects($this->once()) + ->method('aggregate') + ->with($date); + $this->refundedFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($refundedMock)); + $this->observer->execute(); + } + + /** + * Set up aggregate + * + * @return \Magento\Framework\Stdlib\DateTime\DateInterface + */ + protected function setupAggregate() + { + $date = $this->getMock('Magento\Framework\Stdlib\DateTime\Date', ['emulate', 'revert'], [], '', false); + $this->localeResolverMock->expects($this->once()) + ->method('emulate') + ->with(0); + $this->localeResolverMock->expects($this->once()) + ->method('revert'); + $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') + ->disableOriginalConstructor() + ->getMock(); + $dateMock->expects($this->once()) + ->method('subHour') + ->with(25) + ->will($this->returnValue($date)); + $this->localeDateMock->expects($this->once()) + ->method('date') + ->will($this->returnValue($dateMock)); + return $date; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php index 72d4e4d6997..a95b40b74f3 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/CustomerQuoteTest.php @@ -31,7 +31,7 @@ class CustomerQuoteTest extends \PHPUnit_Framework_TestCase protected $customerQuote; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\StoreManagerInterface */ protected $storeManagerMock; @@ -57,7 +57,7 @@ class CustomerQuoteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor() ->getMock(); $this->configMock = $this->getMockBuilder('Magento\Customer\Model\Config\Share') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php new file mode 100644 index 00000000000..b436927742b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/CleanExpiredQuotesTest.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer; + +/** + * Tests Magento\Sales\Model\Observer\CleanExpiredQuotes + */ +class CleanExpiredQuotesTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Store\Model\StoresConfig|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storesConfigMock; + + /** + * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + + /** + * @var \Magento\Sales\Model\Observer\CleanExpiredQuotes + */ + protected $observer; + + protected function setUp() + { + $this->storesConfigMock = $this->getMock('Magento\Store\Model\StoresConfig', [], [], '', false); + + $this->quoteFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->observer = new CleanExpiredQuotes($this->storesConfigMock, $this->quoteFactoryMock); + } + + /** + * @param array $lifetimes + * @param array $additionalFilterFields + * @dataProvider cleanExpiredQuotesDataProvider + */ + public function testExecute($lifetimes, $additionalFilterFields) + { + $this->storesConfigMock->expects($this->once()) + ->method('getStoresConfigByPath') + ->with($this->equalTo('checkout/cart/delete_quote_after')) + ->will($this->returnValue($lifetimes)); + + $quotesMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) + ->method('create') + ->will($this->returnValue($quotesMock)); + $quotesMock->expects($this->exactly((3 + count($additionalFilterFields)) * count($lifetimes))) + ->method('addFieldToFilter'); + if (!empty($lifetimes)) { + $quotesMock->expects($this->exactly(count($lifetimes))) + ->method('walk') + ->with('delete'); + } + $this->observer->setExpireQuotesAdditionalFilterFields($additionalFilterFields); + $this->observer->execute(); + } + + public function cleanExpiredQuotesDataProvider() + { + return [ + [[], []], + [[1 => 100, 2 => 200], []], + [[1 => 100, 2 => 200], ['field1' => 'condition1', 'field2' => 'condition2']], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.php new file mode 100644 index 00000000000..c6d91b96e0b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/AddVatRequestParamsOrderCommentTest.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\Observer\Frontend\Quote; + +/** + * Tests Magento\Sales\Model\Observer\Frontend\Quote\AddVatRequestParamsOrderComment + */ +class AddVatRequestParamsOrderCommentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAddressHelperMock; + + /** + * @var AddVatRequestParamsOrderComment + */ + protected $observer; + + protected function setUp() + { + $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') + ->disableOriginalConstructor() + ->getMock(); + + $this->observer = new AddVatRequestParamsOrderComment( + $this->customerAddressHelperMock + ); + } + + /** + * @param string $configAddressType + * @param string|int $vatRequestId + * @param string|int $vatRequestDate + * @param string $orderHistoryComment + * @dataProvider addVatRequestParamsOrderCommentDataProvider + */ + public function testAddVatRequestParamsOrderComment( + $configAddressType, + $vatRequestId, + $vatRequestDate, + $orderHistoryComment + ) { + $this->customerAddressHelperMock->expects($this->once()) + ->method('getTaxCalculationAddressType') + ->will($this->returnValue($configAddressType)); + + $orderAddressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + ['getVatRequestId', 'getVatRequestDate', '__wakeup'], + [], + '', + false + ); + $orderAddressMock->expects($this->any()) + ->method('getVatRequestId') + ->will($this->returnValue($vatRequestId)); + $orderAddressMock->expects($this->any()) + ->method('getVatRequestDate') + ->will($this->returnValue($vatRequestDate)); + + $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') + ->disableOriginalConstructor() + ->setMethods(['getShippingAddress', '__wakeup', 'addStatusHistoryComment', 'getBillingAddress']) + ->getMock(); + $orderMock->expects($this->any()) + ->method('getShippingAddress') + ->will($this->returnValue($orderAddressMock)); + if (is_null($orderHistoryComment)) { + $orderMock->expects($this->never()) + ->method('addStatusHistoryComment'); + } else { + $orderMock->expects($this->once()) + ->method('addStatusHistoryComment') + ->with($orderHistoryComment, false); + } + $observer = $this->getMock('Magento\Framework\Event\Observer', ['getOrder'], [], '', false); + $observer->expects($this->once()) + ->method('getOrder') + ->will($this->returnValue($orderMock)); + + $this->assertNull($this->observer->execute($observer)); + } + + public function addVatRequestParamsOrderCommentDataProvider() + { + return [ + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 'vatRequestId', + 'vatRequestDate', + 'VAT Request Identifier: vatRequestId<br />VAT Request Date: vatRequestDate', + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 1, + 'vatRequestDate', + null, + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, + 'vatRequestId', + 1, + null, + ], + [ + null, + 'vatRequestId', + 'vatRequestDate', + null, + ], + [ + \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, + 'vatRequestId', + 'vatRequestDate', + null, + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php new file mode 100644 index 00000000000..b927acfbda0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/RestoreCustomerGroupIdTest.php @@ -0,0 +1,94 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Sales\Model\Observer\Frontend\Quote; + +/** + * Tests Magento\Sales\Model\Observer\Frontend\Quote\RestoreCustomerGroupIdTest + */ +class RestoreCustomerGroupIdTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAddressHelperMock; + + /** + * @var RestoreCustomerGroupId + */ + protected $quote; + + protected function setUp() + { + $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') + ->disableOriginalConstructor() + ->getMock(); + + $this->quote = new RestoreCustomerGroupId( + $this->customerAddressHelperMock + ); + } + + /** + * @param string|null $configAddressType + * @dataProvider restoreCustomerGroupIdDataProvider + */ + public function testExecute($configAddressType) + { + $quoteAddress = $this->getMock( + 'Magento\Sales\Model\Quote\Address', + [ + 'getQuote', 'setCustomerGroupId', 'getPrevQuoteCustomerGroupId', + 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId' + ], + [], + '', + false + ); + $observer = $this->getMock('Magento\Framework\Event\Observer', ['getQuoteAddress'], [], '', false); + $observer->expects($this->once()) + ->method('getQuoteAddress') + ->will($this->returnValue($quoteAddress)); + + $this->customerAddressHelperMock->expects($this->once()) + ->method('getTaxCalculationAddressType') + ->will($this->returnValue($configAddressType)); + + $quoteAddress->expects($this->once())->method('hasPrevQuoteCustomerGroupId'); + $id = $quoteAddress->expects($this->any())->method('getPrevQuoteCustomerGroupId'); + $quoteAddress->expects($this->any())->method('setCustomerGroupId')->with($id); + $quoteAddress->expects($this->any())->method('getQuote'); + $quoteAddress->expects($this->any())->method('unsPrevQuoteCustomerGroupId'); + + $this->assertNull($this->quote->execute($observer)); + } + + public function restoreCustomerGroupIdDataProvider() + { + return [ + [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING], + [null], + [\Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php deleted file mode 100644 index 535c1d78381..00000000000 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/ObserverTest.php +++ /dev/null @@ -1,456 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Sales\Model; - -use Magento\Framework\Object; -use Magento\TestFramework\Helper\ObjectManager; -use Magento\Sales\Model\Quote\Address; - -/** - * Tests Magento\Sales\Model\Observer - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class ObserverTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eventManagerMock; - - /** - * @var \Magento\Store\Model\StoresConfig|\PHPUnit_Framework_MockObject_MockObject - */ - protected $storesConfigMock; - - /** - * @var \Magento\Sales\Model\Resource\Quote\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteFactoryMock; - - /** - * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $localeResolverMock; - - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $localeDateMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\OrderFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $orderFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\InvoicedFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $invoiceFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\RefundedFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $refundedFactoryMock; - - /** - * @var \Magento\Sales\Model\Resource\Report\BestsellersFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $bestsellersFactoryMock; - - /** - * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject - */ - protected $catalogDataMock; - - /** - * @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerAddressHelperMock; - - /** - * @var \Magento\Sales\Model\Observer - */ - protected $observer; - - protected function setUp() - { - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->storesConfigMock = $this->getMockBuilder('Magento\Store\Model\StoresConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\CollectionFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->orderFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\OrderFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->invoiceFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\InvoicedFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->refundedFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\RefundedFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->bestsellersFactoryMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\BestsellersFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->catalogDataMock = $this->getMockBuilder('Magento\Catalog\Helper\Data') - ->disableOriginalConstructor() - ->getMock(); - $this->customerAddressHelperMock = $this->getMockBuilder('Magento\Customer\Helper\Address') - ->disableOriginalConstructor() - ->getMock(); - $this->observer = (new ObjectManager($this)) - ->getObject( - 'Magento\Sales\Model\Observer', - [ - 'eventManager' => $this->eventManagerMock, - 'storesConfig' => $this->storesConfigMock, - 'quoteFactory' => $this->quoteFactoryMock, - 'localeDate' => $this->localeDateMock, - 'localeResolver' => $this->localeResolverMock, - 'orderFactory' => $this->orderFactoryMock, - 'invoicedFactory' => $this->invoiceFactoryMock, - 'refundedFactory' => $this->refundedFactoryMock, - 'bestsellersFactory' => $this->bestsellersFactoryMock, - 'catalogData' => $this->catalogDataMock, - 'customerAddressHelper' => $this->customerAddressHelperMock, - ] - ); - } - - /** - * @param array $lifetimes - * @param array $additionalFilterFields - * @dataProvider cleanExpiredQuotesDataProvider - */ - public function testCleanExpiredQuotes($lifetimes, $additionalFilterFields) - { - $this->eventManagerMock->expects($this->once()) - ->method('dispatch'); - $this->storesConfigMock->expects($this->once()) - ->method('getStoresConfigByPath') - ->will($this->returnValue($lifetimes)); - $quotesMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Quote\Collection') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) - ->method('create') - ->will($this->returnValue($quotesMock)); - $quotesMock->expects($this->exactly((3 + count($additionalFilterFields)) * count($lifetimes))) - ->method('addFieldToFilter'); - if (!empty($lifetimes)) { - $quotesMock->expects($this->exactly(count($lifetimes))) - ->method('walk') - ->with('delete'); - } - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->setExpireQuotesAdditionalFilterFields($additionalFilterFields); - $this->observer->cleanExpiredQuotes($schedule); - } - - public function cleanExpiredQuotesDataProvider() - { - return [ - [[], []], - [[1 => 100, 2 => 200], []], - [[1 => 100, 2 => 200], ['field1' => 'condition1', 'field2' => 'condition2']], - ]; - } - - public function testAggregateSalesReportOrderData() - { - $date = $this->setupAggregate(); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Order') - ->disableOriginalConstructor() - ->getMock(); - $orderMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->orderFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($orderMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportOrderData($schedule); - } - - public function testAggregateSalesReportInvoicedData() - { - $date = $this->setupAggregate(); - $invoicedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Invoiced') - ->disableOriginalConstructor() - ->getMock(); - $invoicedMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->invoiceFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($invoicedMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportInvoicedData($schedule); - } - - public function testAggregateSalesReportRefundedData() - { - $date = $this->setupAggregate(); - $refundedMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Refunded') - ->disableOriginalConstructor() - ->getMock(); - $refundedMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->refundedFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($refundedMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportRefundedData($schedule); - } - - public function testAggregateSalesReportBestsellersData() - { - $date = $this->setupAggregate(); - $bestsellersMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Report\Bestsellers') - ->disableOriginalConstructor() - ->getMock(); - $bestsellersMock->expects($this->once()) - ->method('aggregate') - ->with($date); - $this->bestsellersFactoryMock->expects($this->once()) - ->method('create') - ->will($this->returnValue($bestsellersMock)); - $schedule = (new ObjectManager($this))->getObject('Magento\Cron\Model\Schedule'); - $this->observer->aggregateSalesReportBestsellersData($schedule); - } - /** - * Set up aggregate - * - * @return \Magento\Framework\Stdlib\DateTime\DateInterface - */ - protected function setupAggregate() - { - $date = (new ObjectManager($this))->getObject('Magento\Framework\Stdlib\DateTime\Date'); - $this->localeResolverMock->expects($this->once()) - ->method('emulate') - ->with(0); - $this->localeResolverMock->expects($this->once()) - ->method('revert'); - $dateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateInterface') - ->disableOriginalConstructor() - ->getMock(); - $dateMock->expects($this->once()) - ->method('subHour') - ->with(25) - ->will($this->returnValue($date)); - $this->localeDateMock->expects($this->once()) - ->method('date') - ->will($this->returnValue($dateMock)); - return $date; - } - - /** - * @param bool $isMsrpEnabled - * @param bool $canApplyMsrp - * @dataProvider setQuoteCanApplyMsrpDataProvider - */ - public function testSetQuoteCanApplyMsrp($isMsrpEnabled, $canApplyMsrp) - { - $eventMock = $this->getMockBuilder('Magento\Framework\Event') - ->disableOriginalConstructor() - ->setMethods(['getQuote']) - ->getMock(); - $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(['__wakeup', 'setCanApplyMsrp', 'getAllAddresses']) - ->getMock(); - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') - ->disableOriginalConstructor() - ->getMock(); - $observerMock->expects($this->once()) - ->method('getEvent') - ->will($this->returnValue($eventMock)); - $eventMock->expects($this->once()) - ->method('getQuote') - ->will($this->returnValue($quoteMock)); - $this->catalogDataMock->expects($this->once()) - ->method('isMsrpEnabled') - ->will($this->returnValue($isMsrpEnabled)); - $quoteMock->expects($this->once()) - ->method('setCanApplyMsrp') - ->with($canApplyMsrp); - $addressMock1 = $this->getMockBuilder('Magento\Customer\Model\Address\AbstractAddress') - ->disableOriginalConstructor() - ->setMethods(['__wakeup']) - ->getMockForAbstractClass(); - $addressMock1->setCanApplyMsrp($canApplyMsrp); - $addressMock2 = $this->getMockBuilder('Magento\Customer\Model\Address\AbstractAddress') - ->disableOriginalConstructor() - ->setMethods(['__wakeup']) - ->getMockForAbstractClass(); - $addressMock2->setCanApplyMsrp(false); - $quoteMock->expects($this->any()) - ->method('getAllAddresses') - ->will($this->returnValue([$addressMock1, $addressMock2])); - $this->observer->setQuoteCanApplyMsrp($observerMock); - } - - public function setQuoteCanApplyMsrpDataProvider() - { - return [ - [false, false], - [true, true], - [true, false] - ]; - } - - /** - * @param string $configAddressType - * @param string|int $vatRequestId - * @param string|int $vatRequestDate - * @param string $orderHistoryComment - * @dataProvider addVatRequestParamsOrderCommentDataProvider - */ - public function testAddVatRequestParamsOrderComment( - $configAddressType, - $vatRequestId, - $vatRequestDate, - $orderHistoryComment - ) { - $this->customerAddressHelperMock->expects($this->once()) - ->method('getTaxCalculationAddressType') - ->will($this->returnValue($configAddressType)); - $objectManager = new ObjectManager($this); - $orderAddressMock = $objectManager->getObject('Magento\Sales\Model\Order\Address'); - $orderAddressMock->setVatRequestId($vatRequestId); - $orderAddressMock->setVatRequestDate($vatRequestDate); - $orderMock = $this->getMockBuilder('Magento\Sales\Model\Order') - ->disableOriginalConstructor() - ->getMock(); - $orderMock->expects($this->any()) - ->method('getShippingAddress') - ->will($this->returnValue($orderAddressMock)); - if (is_null($orderHistoryComment)) { - $orderMock->expects($this->never()) - ->method('addStatusHistoryComment'); - } else { - $orderMock->expects($this->once()) - ->method('addStatusHistoryComment') - ->with($orderHistoryComment, false); - } - $observer = $objectManager->getObject('Magento\Framework\Event\Observer'); - $observer->setOrder($orderMock); - $this->observer->addVatRequestParamsOrderComment($observer); - - } - - public function addVatRequestParamsOrderCommentDataProvider() - { - return [ - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 'vatRequestId', - 'vatRequestDate', - 'VAT Request Identifier: vatRequestId<br />VAT Request Date: vatRequestDate', - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 1, - 'vatRequestDate', - null, - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, - 'vatRequestId', - 1, - null, - ], - [ - null, - 'vatRequestId', - 'vatRequestDate', - null, - ], - [ - \Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, - 'vatRequestId', - 'vatRequestDate', - null, - ], - ]; - } - /** - * @param string $configAddressType - * @param int $groupId - * @param int $expectedPrevGroupId - * @param int $expectedGroupId - * @dataProvider restoreQuoteCustomerGroupIdDataProvider - */ - public function testRestoreQuoteCustomerGroupId( - $configAddressType, - $groupId, - $expectedPrevGroupId, - $expectedGroupId - ) { - $quote = (new ObjectManager($this))->getObject('Magento\Sales\Model\Quote'); - $quoteAddress = (new ObjectManager($this))->getObject('Magento\Sales\Model\Quote\Address'); - $quoteAddress->setQuote($quote); - if (!empty($groupId)) { - $quoteAddress->setPrevQuoteCustomerGroupId($groupId); - } - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') - ->disableOriginalConstructor() - ->setMethods(['getQuoteAddress']) - ->getMock(); - $observerMock->expects($this->once()) - ->method('getQuoteAddress') - ->will($this->returnValue($quoteAddress)); - $this->customerAddressHelperMock->expects($this->once()) - ->method('getTaxCalculationAddressType') - ->will($this->returnValue($configAddressType)); - $this->observer->restoreQuoteCustomerGroupId($observerMock); - $this->assertEquals($expectedGroupId, $quote->getCustomerGroupId()); - $this->assertEquals($expectedPrevGroupId, $quoteAddress->getPrevQuoteCustomerGroupId()); - } - - public function restoreQuoteCustomerGroupIdDataProvider() - { - return [ - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, 1, null, 1], - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING, null, null, null], - [\Magento\Customer\Model\Address\AbstractAddress::TYPE_BILLING, 1, 1, null], - ]; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php index 9839f9c0af0..fc57a081e33 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/CreditmemoTest.php @@ -67,7 +67,7 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase false ), 'calculatorFactory' => $this->getMock('Magento\Framework\Math\CalculatorFactory', [], [], '', false), - 'storeManager' => $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false), + 'storeManager' => $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false), 'commentFactory' => $this->getMock( 'Magento\Sales\Model\Order\Creditmemo\CommentFactory', [], @@ -141,4 +141,10 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase $this->creditmemo->setGrandTotal(1); $this->assertTrue($this->creditmemo->isValidGrandTotal()); } + + public function testGetIncrementId() + { + $this->creditmemo->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->creditmemo->getIncrementId()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php index 7271f5739cf..8d970d51643 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/InvoiceTest.php @@ -171,4 +171,10 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('invoice', $this->model->getEntityType()); } + + public function testGetIncrementId() + { + $this->model->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->model->getIncrementId()); + } } diff --git a/app/code/Magento/Install/Controller/Wizard/Begin.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/Begin.php rename to dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php index d1a03dad1d7..249669c7988 100644 --- a/app/code/Magento/Install/Controller/Wizard/Begin.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/ShipmentTest.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,27 +21,25 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Sales\Model\Order; -class Begin extends \Magento\Install\Controller\Wizard +class ShipmentTest extends \PHPUnit_Framework_TestCase { /** - * Begin installation action - * - * @return void + * @var \Magento\Sales\Model\Order\shipment */ - public function execute() - { - $this->_checkIfInstalled(); - - $this->_actionFlag->set('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true); - $this->_actionFlag->set('', self::FLAG_NO_POST_DISPATCH, true); - - $this->_prepareLayout(); - $this->_view->getLayout()->initMessages(); + protected $shipmentModel; - $this->_view->getLayout()->addBlock('Magento\Install\Block\Begin', 'install.begin', 'content'); + protected function setUp() + { + $helperManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $arguments = []; + $this->shipmentModel = $helperManager->getObject('Magento\Sales\Model\Order\shipment', $arguments); + } - $this->_view->renderLayout(); + public function testGetIncrementId() + { + $this->shipmentModel->setIncrementId('test_increment_id'); + $this->assertEquals('test_increment_id', $this->shipmentModel->getIncrementId()); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php index d4bd6704053..2fa3a6d37f9 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/OrderTest.php @@ -21,13 +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\Sales\Model; /** * Test class for \Magento\Sales\Model\Order - * - * @package Magento\Sales\Model */ class OrderTest extends \PHPUnit_Framework_TestCase { @@ -46,6 +43,11 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ protected $order; + /** + * @var string + */ + protected $incrementId; + protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -63,12 +65,13 @@ class OrderTest extends \PHPUnit_Framework_TestCase '', false ); - + $this->incrementId = '#00000001'; $this->order = $helper->getObject( 'Magento\Sales\Model\Order', [ 'paymentCollectionFactory' => $this->paymentCollectionFactoryMock, - 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock + 'orderItemCollectionFactory' => $this->orderItemCollectionFactoryMock, + 'data' => ['increment_id' => $this->incrementId] ] ); } @@ -99,7 +102,6 @@ class OrderTest extends \PHPUnit_Framework_TestCase $paymentMock->expects($this->any()) ->method('canFetchTransactionInfo') ->will($this->returnValue(true)); - $this->preparePaymentMock($paymentMock); $this->order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD, false); $this->order->setState(\Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW); @@ -357,6 +359,14 @@ class OrderTest extends \PHPUnit_Framework_TestCase ]; } + /** + * test method getIncrementId() + */ + public function testGetIncrementId() + { + $this->assertEquals($this->incrementId, $this->order->getIncrementId()); + } + public function testGetEntityType() { $this->assertEquals('order', $this->order->getEntityType()); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php index 6558883fbb5..591a6416c36 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/ProcessorTest.php @@ -26,7 +26,7 @@ namespace Magento\Sales\Model\Quote\Item; use \Magento\Catalog\Model\Product; use \Magento\Sales\Model\Quote\ItemFactory; use \Magento\Sales\Model\Quote\Item; -use \Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\StoreManagerInterface; use \Magento\Store\Model\Store; use \Magento\Framework\App\State; use \Magento\Framework\Object; diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php index c5dce844e9d..3950ab01ec8 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteRepositoryTest.php @@ -57,7 +57,7 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase $objectManager =new \Magento\TestFramework\Helper\ObjectManager($this); $this->quoteFactoryMock = $this->getMock('\Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); - $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->quoteMock = $this->getMock('\Magento\Sales\Model\Quote', ['load', 'getIsActive', 'getId', '__wakeup'], [], '', false); $this->storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.php new file mode 100644 index 00000000000..2740edef88b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/AttributeTest.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\Sales\Model\Resource; + +/** + * Class AttributeTest + */ +class AttributeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attribute; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + /** + * @var \Magento\Sales\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject + */ + protected $modelMock; + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId', 'getEventPrefix', 'getEventObject'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['describeTable', 'insert', 'lastInsertId', 'beginTransaction', 'rollback', 'commit'], + [], + '', + false + ); + $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->attribute = new \Magento\Sales\Model\Resource\Attribute( + $this->appResourceMock, + $this->eventManagerMock + ); + } + + /** + * @throws \Exception + */ + public function testSave() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->modelMock->expects($this->any()) + ->method('getEventPrefix') + ->will($this->returnValue('event_prefix')); + $this->modelMock->expects($this->any()) + ->method('getEventObject') + ->will($this->returnValue('event_object')); + $this->eventManagerMock->expects($this->at(0)) + ->method('dispatch') + ->with('event_prefix_save_attribute_before', [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ]); + $this->eventManagerMock->expects($this->at(1)) + ->method('dispatch') + ->with('event_prefix_save_attribute_after', [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ]); + $this->adapterMock->expects($this->once()) + ->method('beginTransaction'); + $this->adapterMock->expects($this->once()) + ->method('commit'); + $this->assertEquals($this->attribute, $this->attribute->saveAttribute($this->modelMock, 'attribute')); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Expected Exception + * @throws \Exception + */ + public function testSaveFailed() + { + $this->modelMock->expects($this->any()) + ->method('getEventPrefix') + ->will($this->returnValue('event_prefix')); + $this->modelMock->expects($this->any()) + ->method('getEventObject') + ->will($this->returnValue('event_object')); + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $exception = new \Exception('Expected Exception'); + $this->modelMock->expects($this->any()) + ->method('getId') + ->will($this->throwException($exception )); + $this->adapterMock->expects($this->once()) + ->method('beginTransaction'); + $this->adapterMock->expects($this->once()) + ->method('rollback'); + $this->eventManagerMock->expects($this->once()) + ->method('dispatch') + ->with( + 'event_prefix_save_attribute_before', + [ + 'event_object' => $this->attribute, + 'object' => $this->modelMock, + 'attribute' => ['attribute'] + ] + ); + $this->attribute->saveAttribute($this->modelMock, 'attribute'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.php new file mode 100644 index 00000000000..650848560f1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/GridPoolTest.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\Resource; + +/** + * Class GridPoolTest + */ +class GridPoolTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\GridPool + */ + protected $gridPool; + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Invoice\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $shipmentGridMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoGridMock; + /** + * @var \Zend_Db_Statement_Interface + */ + protected $statementMock; + + /** + * Prepare mock objects + */ + public function setUp() + { + $this->orderGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Grid', [], [], '', false + ); + $this->invoiceGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Invoice\Grid', [], [], '', false + ); + $this->shipmentGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Shipment\Grid', [], [], '', false + ); + $this->creditmemoGridMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Creditmemo\Grid', [], [], '', false + ); + $this->statementMock = $this->getMockForAbstractClass('Zend_Db_Statement_Interface'); + $this->gridPool = new \Magento\Sales\Model\Resource\GridPool( + $this->orderGridMock, $this->invoiceGridMock, $this->shipmentGridMock, $this->creditmemoGridMock + ); + } + + /** + * Test method refreshByOrderId() + */ + public function testRefreshByOrderId() + { + $orderId = 1; + $this->orderGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->invoiceGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->shipmentGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->creditmemoGridMock->expects($this->once()) + ->method('refresh') + ->with($this->equalTo($orderId), $this->equalTo('sfo.entity_id')) + ->will($this->returnValue($this->statementMock)); + $this->assertEquals($this->gridPool, $this->gridPool->refreshByOrderId($orderId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php index f7e827e77ad..9f671e07b89 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/AddressTest.php @@ -54,13 +54,15 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected $validatorMock; /** - * Set up + * @var \Magento\Sales\Model\Resource\GridPool|\PHPUnit_Framework_MockObject_MockObject */ + protected $gridPoolMock; + public function setUp() { $this->addressMock = $this->getMock( 'Magento\Sales\Model\Order\Address', - [], + ['__wakeup', 'getOrderId', 'hasDataChanges'], [], '', false @@ -86,6 +88,13 @@ class AddressTest extends \PHPUnit_Framework_TestCase '', false ); + $this->gridPoolMock = $this->getMock( + 'Magento\Sales\Model\Resource\GridPool', + ['refreshByOrderId'], + [], + '', + false + ); $this->appResourceMock->expects($this->any()) ->method('getConnection') ->will($this->returnValue($this->adapterMock)); @@ -101,7 +110,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'Magento\Sales\Model\Resource\Order\Address', [ 'resource' => $this->appResourceMock, - 'validator' => $this->validatorMock + 'validator' => $this->validatorMock, + 'gridPool' => $this->gridPoolMock ] ); } @@ -115,6 +125,17 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->method('validate') ->with($this->equalTo($this->addressMock)) ->will($this->returnValue([])); + $this->addressMock->expects($this->once()) + ->method('hasDataChanges') + ->will($this->returnValue(true)); + $this->addressMock->expects($this->exactly(2)) + ->method('getOrderId') + ->will($this->returnValue(2)); + $this->gridPoolMock->expects($this->once()) + ->method('refreshByOrderId') + ->with($this->equalTo(2)) + ->will($this->returnSelf()); + $this->addressResource->save($this->addressMock); $this->assertTrue(true); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php new file mode 100644 index 00000000000..de530ce459e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.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\Resource\Order\Creditmemo; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Creditmemo\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Creditmemo\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_creditmemo_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_creditmemo_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_creditmemo_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_creditmemo_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php new file mode 100644 index 00000000000..cc1f2f4b558 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php @@ -0,0 +1,166 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.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 GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_order_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->exactly(2)) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_order_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_order_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_order_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.php new file mode 100644 index 00000000000..b91634f1cc8 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/AddressTest.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\Model\Resource\Order\Handler; + +/** + * Class AddressTest + */ +class AddressTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\Address + */ + protected $address; + /** + * @var \Magento\Sales\Model\Resource\Order\Address\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attributeMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressMock; + + public function setUp() + { + $this->attributeMock = $this->getMock( + 'Magento\Sales\Model\Resource\Attribute', + [], + [], + '', + false + ); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', + 'getAddressesCollection', + 'save', + 'getBillingAddress', + 'getShippingAddress', + 'hasBillingAddressId', + 'getBillingAddressId', + 'setBillingAddressId', + 'unsBillingAddressId', + 'hasShippingAddressId', + 'getShippingAddressId', + 'setShippingAddressId', + 'unsShippingAddressId' + ], + [], + '', + false + ); + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + $this->addressCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Address\Collection', + [], + [], + '', + false + ); + $this->address = new \Magento\Sales\Model\Resource\Order\Handler\Address( + $this->attributeMock + ); + } + + /** + * Test process method with billing_address + */ + public function testProcessBillingAddress() + { + $this->orderMock->expects($this->exactly(2)) + ->method('getAddressesCollection') + ->will($this->returnValue($this->addressCollectionMock)); + $this->addressCollectionMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue($this->addressMock)); + $this->addressMock->expects($this->exactly(2)) + ->method('getId') + ->will($this->returnValue(2)); + $this->orderMock->expects($this->once()) + ->method('getBillingAddressId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('setBillingAddressId') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue(null)); + $this->attributeMock->expects($this->once()) + ->method('saveAttribute') + ->with($this->orderMock, ['billing_address_id']) + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->process($this->orderMock)); + } + + /** + * Test process method with shipping_address + */ + public function testProcessShippingAddress() + { + $this->orderMock->expects($this->exactly(2)) + ->method('getAddressesCollection') + ->will($this->returnValue($this->addressCollectionMock)); + $this->addressCollectionMock->expects($this->once()) + ->method('save') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('getBillingAddress') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('getShippingAddress') + ->will($this->returnValue($this->addressMock)); + $this->addressMock->expects($this->exactly(2)) + ->method('getId') + ->will($this->returnValue(2)); + $this->orderMock->expects($this->once()) + ->method('setShippingAddressId') + ->will($this->returnSelf()); + $this->attributeMock->expects($this->once()) + ->method('saveAttribute') + ->with($this->orderMock, ['shipping_address_id']) + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->process($this->orderMock)); + } + + /** + * Test method removeEmptyAddresses + */ + public function testRemoveEmptyAddresses() + { + $this->orderMock->expects($this->once()) + ->method('hasBillingAddressId') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getBillingAddressId') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('unsBillingAddressId') + ->will($this->returnSelf()); + $this->orderMock->expects($this->once()) + ->method('hasShippingAddressId') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getShippingAddressId') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('unsShippingAddressId') + ->will($this->returnSelf()); + $this->assertEquals($this->address, $this->address->removeEmptyAddresses($this->orderMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php new file mode 100644 index 00000000000..513ca8998fb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Handler/StateTest.php @@ -0,0 +1,223 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.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\Handler; + +use Magento\Sales\Model\Order; + +/** + * Class StateTest + */ +class StateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\State + */ + protected $state; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + + public function setUp() + { + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', + 'getId', + 'hasCustomerNoteNotify', + 'getCustomerNoteNotify', + 'isCanceled', + 'canUnhold', + 'canInvoice', + 'canShip', + 'getBaseGrandTotal', + 'canCreditmemo', + 'getState', + 'setState', + 'getTotalRefunded', + 'hasForcedCanCreditmemo', + 'getIsInProcess' + ], + [], + '', + false + ); + $this->addressMock = $this->getMock( + 'Magento\Sales\Model\Order\Address', + [], + [], + '', + false + ); + $this->addressCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Address\Collection', + [], + [], + '', + false + ); + $this->state = new \Magento\Sales\Model\Resource\Order\Handler\State(); + } + + /** + * test check order - order without id + */ + public function testCheckOrderEmpty() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(null)); + $this->assertEquals($this->orderMock, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state complete + */ + public function testCheckSetStateComplete() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->will($this->returnValue(100)); + $this->orderMock->expects($this->once()) + ->method('canCreditmemo') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->exactly(2)) + ->method('getState') + ->will($this->returnValue(Order::STATE_PROCESSING)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_COMPLETE, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state closed + */ + public function testCheckSetStateClosed() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->will($this->returnValue(100)); + $this->orderMock->expects($this->once()) + ->method('canCreditmemo') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->exactly(2)) + ->method('getTotalRefunded') + ->will($this->returnValue(null)); + $this->orderMock->expects($this->once()) + ->method('hasForcedCanCreditmemo') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->exactly(2)) + ->method('getState') + ->will($this->returnValue(Order::STATE_PROCESSING)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_CLOSED, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } + + /** + * test check order - set state processing + */ + public function testCheckSetStateProcessing() + { + $this->orderMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('hasCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getCustomerNoteNotify') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('isCanceled') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canUnhold') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canInvoice') + ->will($this->returnValue(false)); + $this->orderMock->expects($this->once()) + ->method('canShip') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('getState') + ->will($this->returnValue(Order::STATE_NEW)); + $this->orderMock->expects($this->once()) + ->method('getIsInProcess') + ->will($this->returnValue(true)); + $this->orderMock->expects($this->once()) + ->method('setState') + ->with(Order::STATE_PROCESSING, true, '', true) + ->will($this->returnSelf()); + $this->assertEquals($this->state, $this->state->check($this->orderMock)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php new file mode 100644 index 00000000000..f769982945d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.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\Resource\Order\Invoice; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Invoice\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Invoice\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_invoice_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_invoice_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_invoice_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_invoice_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php new file mode 100644 index 00000000000..bcc51895cf1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.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\Resource\Order\Shipment; + +/** + * Class GridTest + */ +class GridTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order\Shipment\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $grid; + + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appResourceMock; + + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var \Zend_Db_Statement_Interface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statementMock; + + public function setUp() + { + $this->appResourceMock = $this->getMock( + 'Magento\Framework\App\Resource', + [], + [], + '', + false + ); + $this->eventManagerMock = $this->getMockForAbstractClass( + 'Magento\Framework\Event\ManagerInterface', + [], + '', + false, + false, + true, + [] + ); + $this->modelMock = $this->getMockForAbstractClass( + 'Magento\Sales\Model\AbstractModel', + [], + '', + false, + false, + true, + ['__wakeup', 'getId'] + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + ['select', 'query', 'insertFromSelect', 'delete'], + [], + '', + false + ); + $this->selectMock = $this->getMock( + 'Magento\Framework\DB\Select', + [], + [], + '', + false + ); + $this->statementMock = $this->getMockForAbstractClass( + 'Zend_Db_Statement_Interface', + [], + '', + false, + false, + true, + [] + ); + $this->grid = new \Magento\Sales\Model\Resource\Order\Shipment\Grid( + $this->appResourceMock + ); + } + + /** + * Test refresh method + */ + public function testRefresh() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->any()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_shipment_grid')); + $this->adapterMock->expects($this->once()) + ->method('select') + ->will($this->returnValue($this->selectMock)); + $this->selectMock->expects($this->once()) + ->method('from') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('join') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('joinLeft') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('columns') + ->will($this->returnSelf()); + $this->selectMock->expects($this->once()) + ->method('where') + ->with('fi.field = ?', 1, null) + ->will($this->returnSelf()); + $this->adapterMock->expects($this->once()) + ->method('query') + ->with('sql-query') + ->will($this->returnValue($this->statementMock)); + $this->adapterMock->expects($this->once()) + ->method('insertFromSelect') + ->with($this->selectMock, 'sales_flat_shipment_grid', [], 1) + ->will($this->returnValue('sql-query')); + $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); + } + + /** + * Test purge method + */ + public function testPurge() + { + $this->appResourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->adapterMock)); + $this->appResourceMock->expects($this->once()) + ->method('getTableName') + ->will($this->returnValue('sales_flat_shipment_grid')); + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with('sales_flat_shipment_grid', ['fi.field = ?' => 1]) + ->will($this->returnValue(1)); + $this->assertEquals(1, $this->grid->purge(1, 'fi.field')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php new file mode 100644 index 00000000000..974cf66e58e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php @@ -0,0 +1,215 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.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; + +/** + * Class OrderTest + * + * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class OrderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Resource\Order + */ + protected $resource; + /** + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTimeMock; + /** + * @var \Magento\Sales\Model\Resource\Attribute|\PHPUnit_Framework_MockObject_MockObject + */ + protected $attributeMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $addressHandlerMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Handler\State|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stateHandlerMock; + /** + * @var \Magento\Sales\Model\Increment|\PHPUnit_Framework_MockObject_MockObject + */ + protected $salesIncrementMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Grid|\PHPUnit_Framework_MockObject_MockObject + */ + protected $gridAggregatorMock; + /** + * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderMock; + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + /** + * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeGroupMock; + /** + * \Magento\Sales\Model\Website|\PHPUnit_Framework_MockObject_MockObject + */ + protected $websiteMock; + /** + * @var \Magento\Customer\Model\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Item\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderItemCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Payment\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderPaymentCollectionMock; + /** + * @var \Magento\Sales\Model\Resource\Order\Status\History\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $orderStatusHistoryCollectionMock; + /** + * @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapterMock; + + /** + * Mock class dependencies + */ + public function setUp() + { + $this->resourceMock = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $this->dateTimeMock = $this->getMock('Magento\Framework\Stdlib\DateTime', [], [], '', false); + $this->attributeMock = $this->getMock('Magento\Sales\Model\Resource\Attribute', [], [], '', false); + $this->addressHandlerMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Handler\Address', + [], + [], + '', + false + ); + $this->stateHandlerMock = $this->getMock('Magento\Sales\Model\Resource\Order\Handler\State', [], [], '', false); + $this->salesIncrementMock = $this->getMock('Magento\Sales\Model\Increment', [], [], '', false); + $this->gridAggregatorMock = $this->getMock('Magento\Sales\Model\Resource\Order\Grid', [], [], '', false); + $this->orderMock = $this->getMock( + 'Magento\Sales\Model\Order', + [ + '__wakeup', 'getId', 'getStore', 'getGroup', 'getName', 'setStoreName', 'setTotalItemCount', 'setData', + 'getCustomerId', 'getCustomer', 'setCustomerId', 'getItemsCollection', 'getPaymentsCollection', + 'getStatusHistoryCollection', 'getRelatedObjects', 'save' + ], + [], + '', + false + ); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', ['__wakeup'], [], '', false); + $this->storeGroupMock = $this->getMock('Magento\Store\Model\Group', ['__wakeup'], [], '', false); + $this->websiteMock = $this->getMock('Magento\Sales\Model\Website', ['__wakeup'], [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Model\Customer', ['__wakeup'], [], '', false); + $this->orderItemCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Item\Collection', + [], + [], + '', + false + ); + $this->orderPaymentCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Payment\Collection', + [], + [], + '', + false + ); + $this->orderStatusHistoryCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection', + [], + [], + '', + false + ); + $this->adapterMock = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo\Mysql', + [ + 'describeTable', + 'insert', + 'lastInsertId', + 'beginTransaction', + 'rollback', + 'commit', + 'quoteInto', + 'update' + ], + [], + '', + false + ); + + $this->resource = new Order( + $this->resourceMock, + $this->dateTimeMock, + $this->attributeMock, + $this->salesIncrementMock, + $this->addressHandlerMock, + $this->stateHandlerMock, + $this->gridAggregatorMock + ); + } + + public function testSave() + { + $this->resourceMock->expects($this->any()) + ->method('getConnection') + ->willReturn($this->adapterMock); + $this->adapterMock->expects($this->any()) + ->method('quoteInto'); + $this->adapterMock->expects($this->any()) + ->method('describeTable') + ->will($this->returnValue([])); + $this->adapterMock->expects($this->any()) + ->method('update'); + $this->adapterMock->expects($this->any()) + ->method('lastInsertId'); + $this->addressHandlerMock->expects($this->once()) + ->method('removeEmptyAddresses') + ->with($this->equalTo($this->orderMock)) + ->will($this->returnSelf()); + $this->stateHandlerMock->expects($this->once()) + ->method('check') + ->with($this->equalTo($this->orderMock)) + ->will($this->returnSelf()); + $this->orderMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + $this->orderMock->expects($this->once()) + ->method('getRelatedObjects') + ->willReturn([]); + $this->resource->save($this->orderMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php index 39d37780a8c..3edf5c38050 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Service/V1/Data/TransactionMapperTest.php @@ -64,7 +64,22 @@ class TransactionMapperTest extends \PHPUnit_Framework_TestCase ); $this->transactionBuilderMock = $this->getMock( 'Magento\Sales\Service\V1\Data\TransactionBuilder', - ['populateWithArray', 'setAdditionalInformation', 'setIncrementId', 'setChildTransactions', 'create'], + [ + 'setTransactionId', + 'setParentId', + 'setOrderId', + 'setTxnId', + 'setPaymentId', + 'setParentTxnId', + 'setTxnType', + 'setIsClosed', + 'setCreatedAt', + 'setMethod', + 'setAdditionalInformation', + 'setIncrementId', + 'setChildTransactions', + 'create' + ], [], '', false @@ -183,15 +198,23 @@ class TransactionMapperTest extends \PHPUnit_Framework_TestCase */ public function testExtractDto($lazy) { - list($id, $data) = [1, []]; + $id = 1; $transactionModelMock = $this->getMockBuilder('Magento\Sales\Model\Order\Payment\Transaction') ->disableOriginalConstructor()->setMethods([])->getMock(); $transactionDtoMock = $this->getMockBuilder('Magento\Sales\Service\V1\Data\Transaction') ->disableOriginalConstructor()->setMethods([])->getMock(); $this->prepareTransactionOrder($transactionModelMock, $id); - $transactionModelMock->expects($this->once())->method('getData')->will($this->returnValue($data)); - $this->transactionBuilderMock->expects($this->once())->method('populateWithArray')->with($data); + $this->transactionBuilderMock->expects($this->once())->method('setTransactionId'); + $this->transactionBuilderMock->expects($this->once())->method('setParentId'); + $this->transactionBuilderMock->expects($this->once())->method('setOrderId'); + $this->transactionBuilderMock->expects($this->once())->method('setTxnId'); + $this->transactionBuilderMock->expects($this->once())->method('setPaymentId'); + $this->transactionBuilderMock->expects($this->once())->method('setParentTxnId'); + $this->transactionBuilderMock->expects($this->once())->method('setTxnType'); + $this->transactionBuilderMock->expects($this->once())->method('setIsClosed'); + $this->transactionBuilderMock->expects($this->once())->method('setCreatedAt'); + $this->transactionBuilderMock->expects($this->once())->method('setMethod'); $transactionModelMock->expects($this->once())->method('getAdditionalInformation')->will($this->returnValue([])); $this->transactionBuilderMock->expects($this->once())->method('setAdditionalInformation')->with([]); $this->transactionBuilderMock->expects($this->once())->method('setIncrementId')->with($id); diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php index 7be3f123aaa..ea2fe33f3c9 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/DiscountTest.php @@ -70,7 +70,8 @@ class DiscountTest extends \PHPUnit_Framework_TestCase 'sortItemsByPriority', 'setSkipActionsValidation', 'process', - 'processShippingAmount' + 'processShippingAmount', + 'canApplyDiscount' ] ) ->getMock(); @@ -147,6 +148,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getParentItemId') ->willReturn(true); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); @@ -217,6 +222,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getChildren') ->willReturn([$child]); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); @@ -271,6 +280,10 @@ class DiscountTest extends \PHPUnit_Framework_TestCase ->method('getHasChildren') ->willReturn(false); + $this->validatorMock->expects($this->any()) + ->method('canApplyDiscount') + ->willReturn(true); + $this->validatorMock->expects($this->any()) ->method('sortItemsByPriority') ->willReturnArgument(0); diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.php new file mode 100644 index 00000000000..eaeb3a8fab7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Validator/PoolTest.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\SalesRule\Model\Validator; + +/** + * Test Class PoolTest + */ +class PoolTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\SalesRule\Model\Validator\Pool; + */ + protected $pool; + + /** + * @var array + */ + protected $validators = []; + + public function setUp() + { + $this->validators = ['discount' => ['validator1', 'validator2']]; + $this->pool = new Pool($this->validators); + } + + public function testGetValidators() + { + $this->assertContains($this->validators['discount'][0], $this->pool->getValidators('discount')); + $this->assertEquals([], $this->pool->getValidators('fake')); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php index b5cf5ffdeaa..80651335dd6 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php @@ -23,31 +23,107 @@ */ namespace Magento\SalesRule\Model; +/** + * Class ValidatorTest + * @@SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ValidatorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $helper; + + /** + * @var \Magento\SalesRule\Model\Validator */ protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $item; + + /** + * @var \Magento\SalesRule\Model\RulesApplier|\PHPUnit_Framework_MockObject_MockObject + */ + protected $rulesApplier; + + /** + * @var \Magento\SalesRule\Model\Validator\Pool|\PHPUnit_Framework_MockObject_MockObject + */ + protected $validators; + + /** + * @var \Magento\SalesRule\Model\Utility|\PHPUnit_Framework_MockObject_MockObject + */ + protected $utility; + + /** + * @var \Magento\SalesRule\Model\Resource\Rule\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleCollection; + + /** + * @var \Magento\Catalog\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogData; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $utilityMock; + protected $messageManager; protected function setUp() { - // @TODO Re-write test according to standards of writing test (e.g do not mock tested class) - $this->model = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('_getRules', '_getItemOriginalPrice', '_getItemBaseOriginalPrice', '__wakeup'), - array(), + $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->rulesApplier = $this->getMock( + 'Magento\SalesRule\Model\RulesApplier', + ['setAppliedRuleIds', 'applyRules', 'addDiscountDescription', '__wakeup'], + [], '', false ); - $this->model->expects($this->any())->method('_getRules')->will($this->returnValue(array())); - $this->model->expects($this->any())->method('_getItemOriginalPrice')->will($this->returnValue(1)); - $this->model->expects($this->any())->method('_getItemBaseOriginalPrice')->will($this->returnValue(1)); + + /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ + $this->item = $this->getMock('Magento\Sales\Model\Quote\Item', ['__wakeup'], [], '', false); + + $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); + $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->catalogData = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); + $this->utility = $this->getMock('Magento\SalesRule\Model\Utility', [], [], '', false); + $this->validators = $this->getMock('Magento\SalesRule\Model\Validator\Pool', ['getValidators'], [], '', false); + $this->messageManager = $this->getMock('\Magento\Framework\Message\Manager', [], [], '', false); + $this->ruleCollection = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') + ->disableOriginalConstructor() + ->getMock(); + $ruleCollectionFactoryMock = $this->prepareRuleCollectionMock($this->ruleCollection); + + /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ + $this->model = $this->helper->getObject( + 'Magento\SalesRule\Model\Validator', + [ + 'context' => $context, + 'registry' => $registry, + 'collectionFactory' => $ruleCollectionFactoryMock, + 'catalogData' => $this->catalogData, + 'utility' => $this->utility, + 'rulesApplier' => $this->rulesApplier, + 'validators' => $this->validators, + 'messageManager' => $this->messageManager + ] + ); + $this->model->setWebsiteId(1); + $this->model->setCustomerGroupId(2); + $this->model->setCouponCode('code'); + $this->ruleCollection->expects($this->at(0)) + ->method('setValidationFilter') + ->with( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ) + ->willReturnSelf(); } /** @@ -58,8 +134,8 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $fixturePath = __DIR__ . '/_files/'; $itemDownloadable = $this->getMock( 'Magento\Sales\Model\Quote\Item', - array('getAddress', '__wakeup'), - array(), + ['getAddress', '__wakeup'], + [], '', false ); @@ -67,15 +143,15 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $itemSimple = $this->getMock( 'Magento\Sales\Model\Quote\Item', - array('getAddress', '__wakeup'), - array(), + ['getAddress', '__wakeup'], + [], '', false ); $itemSimple->expects($this->any())->method('getAddress')->will($this->returnValue(new \stdClass())); /** @var $quote \Magento\Sales\Model\Quote */ - $quote = $this->getMock('Magento\Sales\Model\Quote', array('hasNominalItems', '__wakeup'), array(), '', false); + $quote = $this->getMock('Magento\Sales\Model\Quote', ['hasNominalItems', '__wakeup'], [], '', false); $quote->expects($this->any())->method('hasNominalItems')->will($this->returnValue(false)); $itemData = include $fixturePath . 'quote_item_downloadable.php'; @@ -91,7 +167,36 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function testCanApplyRules() { + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $item = $this->getQuoteItemMock(); + $rule = $this->getMock( + 'Magento\SalesRule\Model\Rule', + [], + [], + '', + false + ); + $actionsCollection = $this->getMock('Magento\Rule\Model\Action\Collection', ['validate'], [], '', false); + $actionsCollection->expects($this->any()) + ->method('validate') + ->with($item) + ->willReturn(true); + $rule->expects($this->any()) + ->method('getActions') + ->willReturn($actionsCollection); + $iterator = new \ArrayIterator([$rule]); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + + $this->utility->expects($this->any()) + ->method('canProcessRule') + ->with($rule, $this->anything()) + ->willReturn(true); $quote = $item->getQuote(); $quote->setItemsQty(2); @@ -109,71 +214,41 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase { $negativePrice = -1; - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('__wakeup'), - array(), - '', - false - ); - $rulesApplier = $this->getMock( - 'Magento\SalesRule\Model\Validator\RulesApplier', - ['applyRules', '__wakeup'], - [], - '', - false - ); - - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('__wakeup'), array(), '', false); - - // 2. Set fixtures - $item->setDiscountCalculationPrice($negativePrice); - $item->setData('calculation_price', $negativePrice); + $this->item->setDiscountCalculationPrice($negativePrice); + $this->item->setData('calculation_price', $negativePrice); - // 3. Set expectations - $rulesApplier->expects($this->never())->method('applyRules'); + $this->rulesApplier->expects($this->never())->method('applyRules'); - // 4. Run tested method - $validator->process($item); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->process($this->item); } public function testProcessWhenItemPriceIsNegativeDiscountsAreZeroed() { $negativePrice = -1; $nonZeroDiscount = 123; - - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - array('__wakeup'), - array(), - '', - false + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('__wakeup'), array(), '', false); - - // 2. Set fixtures - $item->setDiscountCalculationPrice($negativePrice); - $item->setData('calculation_price', $negativePrice); + $this->item->setDiscountCalculationPrice($negativePrice); + $this->item->setData('calculation_price', $negativePrice); - // Discounts that could be set before running tested method - $item->setDiscountAmount($nonZeroDiscount); - $item->setBaseDiscountAmount($nonZeroDiscount); - $item->setDiscountPercent($nonZeroDiscount); + $this->item->setDiscountAmount($nonZeroDiscount); + $this->item->setBaseDiscountAmount($nonZeroDiscount); + $this->item->setDiscountPercent($nonZeroDiscount); - // 3. Run tested method - $validator->process($item); + $this->model->process($this->item); - // 4. Check expected result - $this->assertEquals(0, $item->getDiscountAmount()); - $this->assertEquals(0, $item->getBaseDiscountAmount()); - $this->assertEquals(0, $item->getDiscountPercent()); + $this->assertEquals(0, $this->item->getDiscountAmount()); + $this->assertEquals(0, $this->item->getBaseDiscountAmount()); + $this->assertEquals(0, $this->item->getDiscountPercent()); } public function testApplyRulesThatAppliedRuleIdsAreCollected() @@ -181,167 +256,160 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $positivePrice = 1; $ruleId1 = 123; $ruleId2 = 234; - $expectedRuleIds = array($ruleId1 => $ruleId1, $ruleId2 => $ruleId2); - - // 1. Get mocks - $rulesApplier = $this->getMock( - 'Magento\SalesRule\Model\RulesApplier', - ['applyRules', 'setAppliedRuleIds'], - [], - '', - false - ); - $context = $this->getMock('Magento\Framework\Model\Context', [], [], '', false); - $registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); - $collectionFactory = $this->getMock( - 'Magento\SalesRule\Model\Resource\Rule\CollectionFactory', - [], - [], - '', - false + $expectedRuleIds = [$ruleId1 => $ruleId1, $ruleId2 => $ruleId2]; + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - $catalogData = $this->getMock('Magento\Catalog\Helper\Data', [], [], '', false); - $utility = $this->getMock('Magento\SalesRule\Model\Utility', [], [], '', false); - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMock( - 'Magento\SalesRule\Model\Validator', - ['_getRules', '_canProcessRule', '__wakeup'], - [ - 'context' => $context, - 'registry' => $registry, - 'collectionFactory' => $collectionFactory, - 'catalogData' => $catalogData, - 'utility' => $utility, - 'rulesApplier' => $rulesApplier - ], - '', - true - ); + $this->item->setDiscountCalculationPrice($positivePrice); + $this->item->setData('calculation_price', $positivePrice); + $this->model->setSkipActionsValidation(true); - /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('getAddress', '__wakeup'), array(), '', false); - /** @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $rule */ - $rule = $this->getMock('Magento\SalesRule\Model\Rule', array('__wakeup'), array(), '', false); - $rule->setRuleId($ruleId1); - /** @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $rule2 */ - $rule2 = $this->getMock('Magento\SalesRule\Model\Rule', array('__wakeup'), array(), '', false); - $rule2->setRuleId($ruleId2); - $rules = array($rule, $rule2); - $validator->expects($this->any())->method('_getRules')->will($this->returnValue($rules)); - - // 2. Set fixtures, provide tested code isolation - $item->setDiscountCalculationPrice($positivePrice); - $item->setData('calculation_price', $positivePrice); - $validator->setSkipActionsValidation(true); - - // 3. Set expectations - $rulesApplier->expects($this->once()) + $this->rulesApplier->expects($this->once()) ->method('applyRules') ->with( - $this->equalTo($item), - $this->equalTo($rules), + $this->equalTo($this->item), + $this->equalTo($this->ruleCollection), $this->anything(), $this->anything() ) ->will($this->returnValue($expectedRuleIds)); - $rulesApplier->expects($this->once())->method('setAppliedRuleIds')->with($this->anything(), $expectedRuleIds); + $this->rulesApplier->expects($this->once()) + ->method('setAppliedRuleIds') + ->with( + $this->anything(), + $expectedRuleIds + ); - // 4. Run tested method again - $validator->process($item); + $this->model->process($this->item); } - /** - * @param $expectedMergedRuleIds - * @param \Magento\Sales\Model\Quote\Address|\Magento\Sales\Model\Quote $object - * @return $this - */ - protected function assertObjectHasRuleIdsSet($expectedMergedRuleIds, $object) + public function testInit() { - $array = explode(',', $object->getAppliedRuleIds()); - sort($array); - $this->assertEquals($expectedMergedRuleIds, join(',', $array)); - - return $this; + $this->assertInstanceOf( + 'Magento\SalesRule\Model\Validator', + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ) + ); } - protected function getValidator() + public function testCanApplyDiscount() { - // 1. Get mocks - /** @var \Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface $calculator */ - $calculator = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface' - )->setMethods( - array('fixQuantity', 'calculate') - )->getMock(); - - $discountData = $this->getMockBuilder('Magento\SalesRule\Model\Rule\Action\Discount\Data')->getMock(); - - /** @var \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory */ - $calculatorFactory = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory' - )->disableOriginalConstructor()->setMethods( - array('create') - )->getMock(); - - $calculator->expects($this->any())->method('fixQuantity'); - $calculator->expects($this->any())->method('calculate')->will($this->returnValue($discountData)); - $calculatorFactory->expects($this->any())->method('create')->will($this->returnValue($calculator)); - - $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $args = $objectManagerHelper->getConstructArguments( - 'Magento\SalesRule\Model\Validator', - array('calculatorFactory' => $calculatorFactory) + $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator') + ->setMethods(['isValid']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->validators->expects($this->any()) + ->method('getValidators') + ->with('discount') + ->willReturn([$validator]); + $validator->expects($this->any()) + ->method('isValid') + ->with($this->item) + ->willReturn(false); + + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); + $this->assertFalse($this->model->canApplyDiscount($this->item)); + } - /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */ - $validator = $this->getMockBuilder( - 'Magento\SalesRule\Model\Validator' - )->setMethods( - array( - 'getDiscountData', - 'setDiscountData', - '_addDiscountDescription', - '_maintainAddressCouponCode', - '_getItemQty', - '_canProcessRule', - 'setAppliedRuleIds', - '_getRules', - '__wakeup' - ) - )->setConstructorArgs( - $args - )->getMock(); - - $rule = $this->getMockBuilder( - 'Magento\SalesRule\Model\Rule' - )->disableOriginalConstructor()->setMethods( - array() - )->getMock(); - $validator->expects($this->any())->method('_getRules')->will($this->returnValue(array($rule))); - + public function testInitTotalsCanApplyDiscount() + { + $address = $this->getMock('Magento\Sales\Model\Quote\Address', [], [], '', false); + $rule = $this->getMock( + 'Magento\SalesRule\Model\Rule', + ['getSimpleAction', 'getActions', 'getId'], + [], + '', + false + ); + $item1 = $this->getMockForAbstractClass( + 'Magento\Sales\Model\Quote\Item\AbstractItem', + [], + '', + false, + true, + true, + ['__clone', 'getDiscountCalculationPrice', 'getBaseDiscountCalculationPrice', 'getCalculationPrice'] + ); + $item2 = clone $item1; + $items = [$item1, $item2]; - return $validator; + $rule->expects($this->any()) + ->method('getSimpleAction') + ->willReturn(\Magento\SalesRule\Model\Rule::CART_FIXED_ACTION); + $iterator = new \ArrayIterator([$rule]); + $this->ruleCollection->expects($this->once())->method('getIterator')->willReturn($iterator); + $validator = $this->getMockBuilder('Magento\Framework\Validator\AbstractValidator') + ->setMethods(['isValid']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->validators->expects($this->atLeastOnce())->method('getValidators')->with('discount') + ->willReturn([$validator]); + $validator->expects($this->at(0))->method('isValid')->with($item1)->willReturn(false); + $validator->expects($this->at(1))->method('isValid')->with($item2)->willReturn(true); + + $item1->expects($this->any())->method('getParentItemId')->willReturn(false); + $item1->expects($this->never())->method('getDiscountCalculationPrice'); + $item1->expects($this->never())->method('getBaseDiscountCalculationPrice'); + $item2->expects($this->any())->method('getParentItemId')->willReturn(false); + $item2->expects($this->any())->method('getDiscountCalculationPrice')->willReturn(50); + $item2->expects($this->once())->method('getBaseDiscountCalculationPrice')->willReturn(50); + $this->utility->expects($this->once())->method('getItemQty')->willReturn(1); + $this->utility->expects($this->any())->method('canProcessRule')->willReturn(true); + + $actionsCollection = $this->getMock('Magento\Rule\Model\Action\Collection', ['validate'], [], '', false); + $actionsCollection->expects($this->at(0))->method('validate')->with($item1)->willReturn(true); + $actionsCollection->expects($this->at(1))->method('validate')->with($item2)->willReturn(true); + $rule->expects($this->any())->method('getActions')->willReturn($actionsCollection); + $rule->expects($this->any())->method('getId')->willReturn(1); + + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->initTotals($items, $address); + $this->assertArrayHasKey('items_price', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertArrayHasKey('base_items_price', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertArrayHasKey('items_count', $this->model->getRuleItemTotalsInfo($rule->getId())); + $this->assertEquals(1, $this->model->getRuleItemTotalsInfo($rule->getId())['items_count']); } - public function testInit() + public function testInitTotalsNoItems() { - $websiteId = 1; - $customerGroupId = 2; - $couponCode = 'code'; + $address = $this->getMock('\Magento\Sales\Model\Quote\Address', [], [], '', false); + $this->item->expects($this->never()) + ->method('getParentItemId'); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); + $this->model->initTotals([], $address); + } - $ruleCollection = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') - ->disableOriginalConstructor() - ->getMock(); - $ruleCollection->expects($this->once()) - ->method('setValidationFilter') - ->with($websiteId, $customerGroupId, $couponCode) - ->will($this->returnSelf()); - $ruleCollection->expects($this->once()) + /** + * @param $ruleCollection + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function prepareRuleCollectionMock($ruleCollection) + { + $this->ruleCollection->expects($this->once()) ->method('addFieldToFilter') ->with('is_active', 1) ->will($this->returnSelf()); - $ruleCollection->expects($this->once()) + $this->ruleCollection->expects($this->once()) ->method('load') ->will($this->returnSelf()); @@ -352,53 +420,44 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $ruleCollectionFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($ruleCollection)); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $model = $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'collectionFactory' => $ruleCollectionFactoryMock - ] - ); - - $this->assertInstanceOf( - 'Magento\SalesRule\Model\Validator', - $model->init($websiteId, $customerGroupId, $couponCode) - ); + return $ruleCollectionFactoryMock; } public function testProcessShippingAmountNoRules() { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; - $iterator = new \ArrayIterator([]); - $model = $this->getModel($iterator); - $model->init($websiteId, $customerGroupId, $code); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock()) + $this->model->processShippingAmount($this->getAddressMock()) ); } public function testProcessShippingAmountProcessDisabled() { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; - $ruleMock = $this->getMockBuilder('Magento\SalesRule\Model\Rule') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $iterator = new \ArrayIterator([$ruleMock]); - - $model = $this->getModel($iterator); - $model->init($websiteId, $customerGroupId, $code); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock()) + $this->model->processShippingAmount($this->getAddressMock()) ); } @@ -408,9 +467,6 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase */ public function testProcessShippingAmountActions($action) { - $websiteId = 1; - $customerGroupId = 1; - $code = 'test'; $discountAmount = 50; $ruleMock = $this->getMockBuilder('Magento\SalesRule\Model\Rule') @@ -428,17 +484,22 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase ->willReturn($action); $iterator = new \ArrayIterator([$ruleMock]); + $this->ruleCollection->expects($this->any()) + ->method('getIterator') + ->willReturn($iterator); - $model = $this->getModel($iterator); - - $this->utilityMock->expects($this->any()) + $this->utility->expects($this->any()) ->method('canProcessRule') ->willReturn(true); - $model->init($websiteId, $customerGroupId, $code); + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() + ); $this->assertInstanceOf( 'Magento\SalesRule\Model\Validator', - $model->processShippingAmount($this->getAddressMock(5)) + $this->model->processShippingAmount($this->getAddressMock(5)) ); } @@ -487,60 +548,9 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase return $addressMock; } - protected function getModel($collectionIterator = null) - { - $this->utilityMock = $this->getMockBuilder('Magento\SalesRule\Model\Utility') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $rulesApplierMock = $this->getMockBuilder('Magento\SalesRule\Model\RulesApplier') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - - $collectionMock = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\Collection') - ->disableOriginalConstructor() - ->setMethods(['setValidationFilter', 'addFieldToFilter', 'load', 'getIterator']) - ->getMock(); - $collectionMock->expects($this->any()) - ->method('setValidationFilter') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('addFieldToFilter') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('load') - ->willReturnSelf(); - $collectionMock->expects($this->any()) - ->method('getIterator') - ->willReturn($collectionIterator); - - $collectionFactoryMock = $this->getMockBuilder('Magento\SalesRule\Model\Resource\Rule\CollectionFactory') - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $collectionFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($collectionMock); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - return $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'utility' => $this->utilityMock, - 'rulesApplier' => $rulesApplierMock, - 'collectionFactory' => $collectionFactoryMock - ] - ); - } - public function testReset() { - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $utilityMock = $this->getMockBuilder('Magento\SalesRule\Model\Utility') - ->disableOriginalConstructor() - ->getMock(); - $utilityMock->expects($this->once()) + $this->utility->expects($this->once()) ->method('resetRoundingDeltas'); $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') ->disableOriginalConstructor() @@ -551,14 +561,11 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase $addressMock->expects($this->once()) ->method('getQuote') ->willReturn($quoteMock); - - /** @var \Magento\SalesRule\Model\Validator $model */ - $model = $helper->getObject( - 'Magento\SalesRule\Model\Validator', - [ - 'utility' => $utilityMock - ] + $this->model->init( + $this->model->getWebsiteId(), + $this->model->getCustomerGroupId(), + $this->model->getCouponCode() ); - $this->assertInstanceOf('\Magento\SalesRule\Model\Validator', $model->reset($addressMock)); + $this->assertInstanceOf('\Magento\SalesRule\Model\Validator', $this->model->reset($addressMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php b/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.php new file mode 100644 index 00000000000..320d7a8c616 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sendfriend/Block/Plugin/Catalog/Product/ViewTest.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\Sendfriend\Block\Plugin\Catalog\Product; + +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Sendfriend\Block\Plugin\Catalog\Product\View */ + protected $view; + + /** @var ObjectManagerHelper */ + protected $objectManagerHelper; + + /** @var \Magento\Sendfriend\Model\Sendfriend|\PHPUnit_Framework_MockObject_MockObject */ + protected $sendfriendModel; + + /** @var \Magento\Catalog\Block\Product\View|\PHPUnit_Framework_MockObject_MockObject */ + protected $productView; + + + protected function setUp() + { + $this->sendfriendModel = $this->getMock( + 'Magento\Sendfriend\Model\Sendfriend', + array('__wakeup', 'canEmailToFriend'), + array(), + '', + false + ); + $this->productView = $this->getMock('Magento\Catalog\Block\Product\View', array(), array(), '', false); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->view = $this->objectManagerHelper->getObject( + 'Magento\Sendfriend\Block\Plugin\Catalog\Product\View', + [ + 'sendfriend' => $this->sendfriendModel + ] + ); + + } + + /** + * @dataProvider afterCanEmailToFriendDataSet + * @param bool $result + * @param string $callSendfriend + */ + public function testAfterCanEmailToFriend($result, $callSendfriend) + { + $this->sendfriendModel->expects($this->$callSendfriend())->method('canEmailToFriend') + ->will($this->returnValue(true)); + + $this->assertTrue($this->view->afterCanEmailToFriend($this->productView, $result)); + } + + public function afterCanEmailToFriendDataSet() + { + return array( + array(true, 'never'), + array(false, 'once') + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php index 0cfbe11413d..60c58bc33bc 100644 --- a/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php +++ b/dev/tests/unit/testsuite/Magento/Sendfriend/Model/SendfriendTest.php @@ -89,7 +89,7 @@ class SendfriendTest extends \PHPUnit_Framework_TestCase ); $this->cookieManagerMock->expects($this->once())->method('getCookie')->with($cookieName); - $this->cookieManagerMock->expects($this->once())->method('setPublicCookie'); + $this->cookieManagerMock->expects($this->once())->method('setSensitiveCookie'); $sendFriendClass = new \ReflectionClass('Magento\Sendfriend\Model\Sendfriend'); $method = $sendFriendClass->getMethod('_sentCountByCookies'); $method->setAccessible(true); diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php index 365e06d976e..94ede48caef 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/ContextTest.php @@ -85,11 +85,6 @@ class ContextTest extends \PHPUnit_Framework_TestCase */ protected $requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieManagerMock; - /** * Set up */ @@ -103,8 +98,7 @@ class ContextTest extends \PHPUnit_Framework_TestCase ['getParam'], [], '', false); $this->storeManagerMock = $this->getMock('Magento\Store\Model\StoreManager', ['getWebsite', '__wakeup'], [], '', false); - $this->storeMock = $this->getMock('Magento\Store\Model\Store', - ['__wakeup', 'getDefaultCurrency'], [], '', false); + $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); $this->currencyMock = $this->getMock('Magento\Directory\Model\Currency', ['getCode', '__wakeup'], [], '', false); $this->websiteMock = $this->getMock('Magento\Store\Model\Website', @@ -112,15 +106,13 @@ class ContextTest extends \PHPUnit_Framework_TestCase $this->closureMock = function () { return 'ExpectedValue'; }; - $this->cookieManagerMock = $this->getMock('\Magento\Framework\Stdlib\CookieManager'); $this->subjectMock = $this->getMock('Magento\Framework\App\Action\Action', [], [], '', false); $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); $this->plugin = new \Magento\Store\App\Action\Plugin\Context( $this->sessionMock, $this->httpContextMock, $this->httpRequestMock, - $this->storeManagerMock, - $this->cookieManagerMock + $this->storeManagerMock ); } @@ -138,6 +130,9 @@ class ContextTest extends \PHPUnit_Framework_TestCase $this->storeMock->expects($this->once()) ->method('getDefaultCurrency') ->will($this->returnValue($this->currencyMock)); + $this->storeMock->expects($this->once()) + ->method('getStoreCodeFromCookie') + ->will($this->returnValue('storeCookie')); $this->currencyMock->expects($this->once()) ->method('getCode') ->will($this->returnValue('UAH')); @@ -150,11 +145,6 @@ class ContextTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('___store')) ->will($this->returnValue('default')); - $this->cookieManagerMock->expects($this->once()) - ->method('getCookie') - ->with($this->equalTo(\Magento\Store\Model\Store::COOKIE_NAME)) - ->will($this->returnValue(null)); - $this->httpContextMock->expects($this->atLeastOnce()) ->method('setValue') ->will($this->returnValueMap([ diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php index f01031eaf55..49b3b7c6145 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Action/Plugin/StoreCheckTest.php @@ -50,11 +50,6 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -62,7 +57,7 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_storeMock = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_storeManagerMock->expects( $this->any() @@ -76,18 +71,16 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase return 'Expected'; }; $this->requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->appStateMock = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); - $this->_plugin = new \Magento\Store\App\Action\Plugin\StoreCheck($this->_storeManagerMock, $this->appStateMock); + $this->_plugin = new \Magento\Store\App\Action\Plugin\StoreCheck($this->_storeManagerMock); } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException * @expectedExceptionMessage Current store is not active. */ - public function testAroundDispatchWhenStoreNotActiveAppInstalled() + public function testAroundDispatchWhenStoreNotActive() { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(false)); $this->assertEquals( 'Expected', @@ -95,9 +88,8 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchWhenStoreIsActiveAppInstalled() + public function testAroundDispatchWhenStoreIsActive() { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(true)); $this->assertEquals( 'Expected', @@ -105,23 +97,4 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchWhenStoreNotActiveAppNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_storeMock->expects($this->never())->method('getIsActive'); - $this->assertEquals( - 'Expected', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } - - public function testAroundDispatchWhenStoreIsActiveAppNotInstalled() - { - $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_storeMock->expects($this->never())->method('getIsActive'); - $this->assertEquals( - 'Expected', - $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock) - ); - } } diff --git a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php deleted file mode 100644 index 6a742aa4241..00000000000 --- a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/DispatchExceptionHandlerTest.php +++ /dev/null @@ -1,72 +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\Store\App\FrontController\Plugin; - -class DispatchExceptionHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Store\App\FrontController\Plugin\DispatchExceptionHandler - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_filesystemMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $subjectMock; - - /** - * @var \Closure - */ - protected $closureMock; - - protected function setUp() - { - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', array(), array(), '', false); - $this->_filesystemMock = $this->getMock('\Magento\Framework\App\Filesystem', array(), array(), '', false); - $this->closureMock = function () { - return 'Expected'; - }; - $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); - $this->_model = new DispatchExceptionHandler($this->_storeManagerMock, $this->_filesystemMock); - } - - public function testAroundDispatch() - { - $requestMock = $this->getMock('Magento\Framework\App\RequestInterface'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $requestMock) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php index 4b6c9f833ee..c094b7a07a1 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php @@ -35,11 +35,6 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase */ protected $_storeManagerMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -78,33 +73,19 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase return 'Expected'; }; $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManager', array(), array(), '', false); - $this->_appStateMock = $this->getMock('\Magento\Framework\App\State', array(), array(), '', false); $this->_urlMock = $this->getMock('\Magento\Framework\Url', array(), array(), '', false); $this->_scopeConfigMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); $this->subjectMock = $this->getMock('Magento\Framework\App\FrontController', array(), array(), '', false); $this->_model = new \Magento\Store\App\FrontController\Plugin\RequestPreprocessor( $this->_storeManagerMock, - $this->_appStateMock, $this->_urlMock, $this->_scopeConfigMock, $this->getMock('\Magento\Framework\App\ResponseFactory', array(), array(), '', false) ); } - public function testAroundDispatchIfNotInstalled() - { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); - $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); - $this->_scopeConfigMock->expects($this->never())->method('getValue'); - $this->assertEquals( - 'Expected', - $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) - ); - } - - public function testAroundDispatchIfInstalledAndRedirectCodeNotExist() + public function testAroundDispatchIfRedirectCodeNotExist() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects($this->once())->method('getValue')->with('web/url/redirect_to_base'); $this->_requestMock->expects($this->never())->method('getRequestUri'); @@ -114,9 +95,8 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase ); } - public function testAroundDispatchIfInstalledAndRedirectCodeExist() + public function testAroundDispatchIfRedirectCodeExist() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects( $this->once() @@ -144,7 +124,6 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase public function testAroundDispatchIfBaseUrlNotExists() { - $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_scopeConfigMock->expects( $this->once() diff --git a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php index 52048dd9f3b..5b5cc6185d4 100644 --- a/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/App/Response/RedirectTest.php @@ -76,7 +76,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase 'getCookie' ) ); - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $this->_urlCoderMock = $this->getMock( '\Magento\Framework\Encryption\UrlCoder', array(), diff --git a/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php b/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php index 9d0447f17fa..8ecbdca177c 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Block/SwitchTest.php @@ -42,7 +42,7 @@ class SwitchTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('\Magento\Framework\StoreManagerInterface'); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_block = $helper->getObject( diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php index b471118fa3d..f763f4dd951 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Config/Reader/StoreTest.php @@ -58,7 +58,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_scopePullMock = $this->getMock('Magento\Framework\App\Config\ScopePool', [], [], '', false); - $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_initialConfigMock = $this->getMock('Magento\Framework\App\Config\Initial', [], [], '', false); $this->_collectionFactory = $this->getMock( 'Magento\Store\Model\Resource\Config\Collection\ScopedFactory', diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php index 0f995328543..d68c9f8f53f 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/StoreTest.php @@ -42,7 +42,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', @@ -71,7 +71,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetScopeWithInvalidScope() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php index 0bc15428b18..f13377811ea 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Resolver/WebsiteTest.php @@ -42,7 +42,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManagerMock = $this->getMock( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), array(), '', @@ -71,7 +71,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetScopeWithInvalidScope() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php index 5afae729e73..4b264695e01 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/Storage/DbTest.php @@ -116,7 +116,7 @@ class DbTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetWebsiteInvalidId() { @@ -162,7 +162,7 @@ class DbTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetGroupInvalidId() { diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php index 81400abe380..c28ada75cde 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StorageFactoryTest.php @@ -122,16 +122,6 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase */ protected $request; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cookieMetadataFactoryMock; - /** * @var \Magento\TestFramework\Helper\ObjectManager */ @@ -159,17 +149,10 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->_storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_httpContext = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false); $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->request = $this->getMock('Magento\Framework\App\RequestInterface', [], [], '', false); - $this->cookieMetadataFactoryMock = $this->getMock('Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', - [], - [], - '', - false - ); $this->_model = $this->helper->getObject('\Magento\Store\Model\StorageFactory', [ 'objectManager' => $this->_objectManagerMock, @@ -177,11 +160,9 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase 'logger' => $this->_logMock, 'sidResolver' => $this->_sidResolverMock, 'appState' => $this->_appStateMock, - 'cookieManager' => $this->cookieManagerMock, 'httpContext' => $this->_httpContext, 'scopeConfig' => $this->_scopeConfig, 'request' => $this->request, - 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock ]); $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); @@ -383,7 +364,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Store\Model\Exception + * @expectedException \Magento\Framework\App\InitException */ public function testGetWithStoresReinitUnknownScopeType() { @@ -416,16 +397,12 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->store->expects($this->once())->method('getId')->will($this->returnValue(21)); $this->store->expects($this->once())->method('getIsActive')->will($this->returnValue(true)); + $this->store->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('store1')); $this->storage->expects($this->any())->method('setCurrentStore')->with('store1'); $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); - $this->cookieManagerMock->expects($this->atLeastOnce()) - ->method('getCookie') - ->with(Store::COOKIE_NAME) - ->will($this->returnValue('store1')); - $this->assertEquals($this->storage, $this->_model->get($this->_arguments)); } @@ -450,8 +427,9 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase * * @param bool $isActiveStore * @param bool $isDefault + * @param string $cookieCall */ - public function testGetFromRequest($isActiveStore, $isDefault) + public function testGetFromRequest($isActiveStore, $isDefault, $cookieCall = '') { $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); @@ -475,15 +453,13 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->store->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(21)); $this->store->expects($this->once())->method('getIsActive')->will($this->returnValue($isActiveStore)); $this->store->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website)); - + if (!empty($cookieCall)) { + $this->store->expects($this->once())->method($cookieCall); + } $this->storage->expects($this->any())->method('setCurrentStore')->with('store1'); $numCreateCookieCalls = $isDefault ? 0 : 1; $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage)); - $cookieMetadata = $this->helper->getObject('Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', []); - $this->cookieMetadataFactoryMock->expects($this->exactly($numCreateCookieCalls)) - ->method('createPublicCookieMetadata') - ->will($this->returnValue($cookieMetadata)); $this->request->expects($this->atLeastOnce()) ->method('getParam') @@ -500,8 +476,8 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase { return [ [false, true], - [true, true], - [true, false], + [true, true, 'deleteCookie'], + [true, false, 'setCookie'], ]; } } diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php index ae7589476e3..a128399e79f 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreManagerTest.php @@ -63,7 +63,7 @@ class StoreManagerTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_storage = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storage = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_model = new \Magento\Store\Model\StoreManager( $this->_factoryMock, diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php index 61001e986b6..30993b8d447 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoreTest.php @@ -39,6 +39,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ protected $requestMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Stdlib\CookieManager + */ + protected $cookieManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory + */ + protected $cookieMetadataFactoryMock; + public function setUp() { $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -53,6 +63,14 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'getCookie', 'getDistroBaseUrl', ], [], '', false); + $this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManager', [], [], '', false); + $this->cookieMetadataFactoryMock = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory', + [], + [], + '', + false + ); } /** @@ -66,7 +84,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Resource\Store $resource */ $resource = $this->getMock( '\Magento\Store\Model\Resource\Store', - array('load', 'getIdFieldName', '__wakeup'), + ['load', 'getIdFieldName', '__wakeup'], [], '', false @@ -76,21 +94,21 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $resource->expects($this->atLeastOnce())->method('getIdFieldName')->will($this->returnValue('store_id')); /** @var \Magento\Store\Model\Store $model */ - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', array('resource' => $resource)); + $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', ['resource' => $resource]); $model->load($key); } public function loadDataProvider() { - return array( - array(1, null), - array('default', 'code'), - ); + return [ + [1, null], + ['default', 'code'], + ]; } public function testSetWebsite() { - $website = $this->getMock('\Magento\Store\Model\Website', array('getId', '__wakeup'), [], '', false); + $website = $this->getMock('\Magento\Store\Model\Website', ['getId', '__wakeup'], [], '', false); $website->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(2)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store'); @@ -106,7 +124,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetWebsite($websiteId, $website) { - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getWebsite') ->with($websiteId) @@ -114,7 +132,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array('storeManager' => $storeManager) + ['storeManager' => $storeManager] ); $model->setWebsiteId($websiteId); $this->assertEquals($website, $model->getWebsite()); @@ -122,17 +140,17 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getWebsiteDataProvider() { - $website = $this->getMock('\Magento\Store\Model\Website', array('__wakeup'), [], '', false); - return array( - array(null, false), - array(2, $website) - ); + $website = $this->getMock('\Magento\Store\Model\Website', ['__wakeup'], [], '', false); + return [ + [null, false], + [2, $website] + ]; } public function testGetUrl() { - $params = array('_scope_to_url' => true); - $defaultStore = $this->getMock('\Magento\Store\Model\Store', array('getId', '__wakeup'), [], '', false); + $params = ['_scope_to_url' => true]; + $defaultStore = $this->getMock('\Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); @@ -142,7 +160,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('test/route'), $this->equalTo($params)) ->will($this->returnValue('http://test/url')); - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($defaultStore)); @@ -150,7 +168,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array('storeManager' => $storeManager, 'url' => $url) + ['storeManager' => $storeManager, 'url' => $url] ); $model->setStoreId(2); $this->assertEquals('http://test/url', $model->getUrl('test/route')); @@ -188,11 +206,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array( + [ 'config' => $configMock, 'request' => $this->requestMock, 'isCustomEntryPoint' => !$secure, - ) + ] ); $model->setCode('scopeCode'); $this->assertEquals($expectedBaseUrl, $model->getBaseUrl($type, $secure)); @@ -200,56 +218,56 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getBaseUrlDataProvider() { - return array( - array( + return [ + [ \Magento\Framework\UrlInterface::URL_TYPE_WEB, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_LINK, false, 'web/unsecure/base_link_url', 'http://domain.com/web/unsecure/base_link_url/index.php/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_DIRECT_LINK, false, 'web/unsecure/base_link_url', 'http://domain.com/web/unsecure/base_link_url/index.php/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, 'web/unsecure/base_media_url', 'http://domain.com/web/unsecure/base_media_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, 'web/unsecure/base_static_url', 'http://domain.com/web/unsecure/base_static_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_STATIC, false, 'web/unsecure/base_url', 'http://domain.com/web/unsecure/base_url/' - ), - array( + ], + [ \Magento\Framework\UrlInterface::URL_TYPE_WEB, true, 'web/secure/base_url', 'http://distro.com/web/secure/base_url/' - ), - ); + ], + ]; } public function testGetBaseUrlEntryPoint() @@ -268,10 +286,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject( 'Magento\Store\Model\Store', - array( + [ 'config' => $configMock, 'isCustomEntryPoint' => false, - ) + ] ); $model->setCode('scopeCode'); $server = $_SERVER; @@ -304,11 +322,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testGetCurrentUrl($secure, $url, $expected) { - $defaultStore = $this->getMock('\Magento\Store\Model\Store', array( + $defaultStore = $this->getMock('\Magento\Store\Model\Store', [ 'getId', 'isCurrentlySecure', '__wakeup' - ), [], '', false); + ], [], '', false); $defaultStore->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5)); $defaultStore->expects($this->atLeastOnce())->method('isCurrentlySecure')->will($this->returnValue($secure)); @@ -319,9 +337,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->atLeastOnce())->method('getRequestString')->will($this->returnValue('')); - $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue(array( + $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->will($this->returnValue([ 'SID' => 'sid' - ))); + ])); $urlMock = $this->getMockForAbstractClass('\Magento\Framework\UrlInterface'); @@ -329,7 +347,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $urlMock->expects($this->any())->method('getUrl') ->will($this->returnValue($url)); - $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); + $storeManager = $this->getMockForAbstractClass('\Magento\Framework\StoreManagerInterface'); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($defaultStore)); @@ -350,11 +368,11 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getCurrentUrlDataProvider() { - return array( - array(true, 'http://test/url', 'http://test/url?SID=sid&___store=scope_code'), - array(true, 'http://test/url?SID=sid1&___store=scope', 'http://test/url?SID=sid&___store=scope_code'), - array(false, 'https://test/url', 'https://test/url?SID=sid&___store=scope_code') - ); + return [ + [true, 'http://test/url', 'http://test/url?SID=sid&___store=scope_code'], + [true, 'http://test/url?SID=sid1&___store=scope', 'http://test/url?SID=sid&___store=scope_code'], + [false, 'https://test/url', 'https://test/url?SID=sid&___store=scope_code'] + ]; } public function testGetPriceFilter() @@ -403,18 +421,18 @@ class StoreTest extends \PHPUnit_Framework_TestCase $config = $this->getMockForAbstractClass('\Magento\Framework\App\Config\ReinitableConfigInterface'); $config->expects($this->any()) ->method('getValue') - ->will($this->returnValueMap(array( - array('catalog/price/scope', ScopeInterface::SCOPE_STORE, 'scope_code', $priceScope), - array('currency/options/base', \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null, 'USD'), - array('currency/options/base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'scope_code', 'UAH'), - ))); + ->will($this->returnValueMap([ + ['catalog/price/scope', ScopeInterface::SCOPE_STORE, 'scope_code', $priceScope], + ['currency/options/base', \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT, null, 'USD'], + ['currency/options/base', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'scope_code', 'UAH'], + ])); $currency = $this->getMock('\Magento\Directory\Model\Currency', [], [], '', false); $currency->expects($this->any())->method('load')->with($currencyCode)->will($this->returnSelf()); $currencyFactory = $this->getMock( '\Magento\Directory\Model\CurrencyFactory', - array('create', 'load') + ['create', 'load'] ); $currencyFactory->expects($this->any())->method('create')->will($this->returnValue($currency)); @@ -422,7 +440,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); /** @var \Magento\Store\Model\Store $model */ $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', - array('currencyFactory' => $currencyFactory, 'config' => $config, 'appState' => $appState) + ['currencyFactory' => $currencyFactory, 'config' => $config, 'appState' => $appState] ); $model->setCode('scope_code'); $this->assertEquals($currency, $model->getBaseCurrency()); @@ -433,16 +451,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function getBaseCurrencyDataProvider() { - return array( - array(0, 'USD'), - array(1, 'UAH'), - ); + return [ + [0, 'USD'], + [1, 'UAH'], + ]; } public function testGetAllowedCurrencies() { $currencyPath = 'cur/ren/cy/path'; - $expectedResult = array('EUR', 'USD'); + $expectedResult = ['EUR', 'USD']; $configMock = $this->getMockForAbstractClass( 'Magento\Framework\App\Config\ReinitableConfigInterface', @@ -456,11 +474,75 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('EUR,USD')); /** @var \Magento\Store\Model\Store $model */ - $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', array( + $model = $this->objectManagerHelper->getObject('Magento\Store\Model\Store', [ 'config' => $configMock, 'currencyInstalled' => $currencyPath, - )); + ]); $this->assertEquals($expectedResult, $model->getAllowedCurrencies()); } + + public function testSetCookie() + { + $storeCode = 'store code'; + $cookieMetadata = $this->getMock( + 'Magento\Framework\Stdlib\Cookie\PublicCookieMetadata', + [], + [], + '', + false + ); + $cookieMetadata->expects($this->once()) + ->method('setHttpOnly') + ->with(true) + ->willReturnSelf(); + $cookieMetadata->expects($this->once()) + ->method('setDurationOneYear') + ->willReturnSelf(); + $this->cookieMetadataFactoryMock->expects($this->once()) + ->method('createPublicCookieMetadata') + ->will($this->returnValue($cookieMetadata)); + $this->cookieManagerMock->expects($this->once()) + ->method('setPublicCookie') + ->with(Store::COOKIE_NAME, $storeCode, $cookieMetadata); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->setCode($storeCode); + $model->setCookie(); + } + + public function testGetStoreCodeFromCookie() + { + $this->cookieManagerMock->expects($this->once()) + ->method('getCookie') + ->with(Store::COOKIE_NAME); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->getStoreCodeFromCookie(); + } + + public function testDeleteCookie() + { + $this->cookieManagerMock->expects($this->once()) + ->method('deleteCookie') + ->with(Store::COOKIE_NAME); + /** @var \Magento\Store\Model\Store $model */ + $model = $this->objectManagerHelper->getObject( + 'Magento\Store\Model\Store', + [ + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + ]); + $model->deleteCookie(); + } } diff --git a/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php b/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php index 4653c596eda..7890dd4efc6 100644 --- a/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Store/Model/StoresConfigTest.php @@ -57,7 +57,7 @@ class StoresConfigTest extends \PHPUnit_Framework_TestCase { $this->_storeOne = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); $this->_storeTwo = $this->getMock('Magento\Store\Model\Store', array(), array(), '', false); - $this->_storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $this->_storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); $this->_config = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); $this->_model = new \Magento\Store\Model\StoresConfig( diff --git a/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php index a611c653ae3..70df030b661 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Model/Resource/CalculationTest.php @@ -38,7 +38,7 @@ class CalculationTest extends \PHPUnit_Framework_TestCase { // create the mocks $resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', [], [], '', false); $taxData = $this->getMock('Magento\Tax\Helper\Data', ['getPostCodeSubStringLength'], [], '', false); $taxData diff --git a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php index b13cd650e6f..ddfee97f6a1 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxCalculationServiceTest.php @@ -46,7 +46,7 @@ class TaxCalculationServiceTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Tax\Service\V1\Data\TaxDetailsBuilder */ private $taxDetailsBuilder; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\StoreManagerInterface */ private $storeManager; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Tax\Model\Calculation\CalculatorFactory */ @@ -56,7 +56,7 @@ class TaxCalculationServiceTest extends \PHPUnit_Framework_TestCase { $objectManager = new ObjectManager($this); $this->quoteDetailsBuilder = $objectManager->getObject('Magento\Tax\Service\V1\Data\QuoteDetailsBuilder'); - $this->storeManager = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->disableOriginalConstructor()->getMock(); $this->calculatorFactory = $this->getMockBuilder('Magento\Tax\Model\Calculation\CalculatorFactory') ->disableOriginalConstructor()->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php index 032fde9d4de..f1f4e2abd0a 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/Config/CustomizationTest.php @@ -30,7 +30,7 @@ namespace Magento\Theme\Model\Config; class CustomizationTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -57,7 +57,7 @@ class CustomizationTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManager = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), '', true, diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php index 1c769115191..e79991c8712 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php @@ -69,7 +69,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** @var $this->_themeMock \Magento\Core\Model\Theme */ $this->_themeMock = $this->getMock('Magento\Core\Model\Theme', array(), array(), '', false); $this->_storeManagerMock = $this->getMockForAbstractClass( - 'Magento\Store\Model\StoreManagerInterface', + 'Magento\Framework\StoreManagerInterface', array(), '', true, diff --git a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php index d1646b52df9..a698b79d63b 100644 --- a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php @@ -55,7 +55,7 @@ class UserTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Mail\TransportInterface|PHPUnit_Framework_MockObject_MockObject */ protected $_transportMock; - /** @var \Magento\Store\Model\StoreManagerInterface|PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|PHPUnit_Framework_MockObject_MockObject */ protected $_storeManagerMock; /** @var \Magento\Store\Model\Store|PHPUnit_Framework_MockObject_MockObject */ @@ -130,7 +130,7 @@ class UserTest extends \PHPUnit_Framework_TestCase array() )->getMock(); $this->_storeManagerMock = $this->getMockBuilder( - '\Magento\Store\Model\StoreManagerInterface' + '\Magento\Framework\StoreManagerInterface' )->disableOriginalConstructor()->setMethods( array() )->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php index b3da4eb68bc..680ddc7fe1c 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php @@ -33,34 +33,49 @@ use Magento\Framework\Exception\AuthorizationException; */ class RestTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Webapi\Controller\Rest */ + /** + * @var \Magento\Webapi\Controller\Rest + */ protected $_restController; - /** @var \Magento\Webapi\Controller\Rest\Request */ + /** + * @var \Magento\Webapi\Controller\Rest\Request + */ protected $_requestMock; - /** @var \Magento\Webapi\Controller\Rest\Response */ + /** + * @var \Magento\Webapi\Controller\Rest\Response + */ protected $_responseMock; - /** @var \Magento\Webapi\Controller\Rest\Router */ + /** + * @var \Magento\Webapi\Controller\Rest\Router + */ protected $_routerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Webapi\Controller\Rest\Router\Route */ + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Webapi\Controller\Rest\Router\Route + */ protected $_routeMock; - /** @var \Magento\Framework\ObjectManager */ + /** + * @var \Magento\Framework\ObjectManager + */ protected $_objectManagerMock; - /** @var \stdClass */ + /** + * @var \stdClass + */ protected $_serviceMock; - /** @var \Magento\Framework\App\State */ - protected $_appStateMock; - - /** @var \Magento\Framework\Oauth\OauthInterface */ + /** + * @var \Magento\Framework\Oauth\OauthInterface + */ protected $_oauthServiceMock; - /** @var \Magento\Framework\AuthorizationInterface */ + /** + * @var \Magento\Framework\AuthorizationInterface + */ protected $_authorizationMock; /** @@ -155,20 +170,6 @@ class RestTest extends \PHPUnit_Framework_TestCase parent::setUp(); } - /** - * Test redirected to install page - */ - public function testRedirectToInstallPage() - { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $expectedMsg = 'Magento is not yet installed'; - - $this->_restController->dispatch($this->_requestMock); - $this->assertTrue($this->_responseMock->isException()); - $exceptionArray = $this->_responseMock->getException(); - $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage()); - } - /** * Test Secure Request and Secure route combinations * @@ -176,7 +177,6 @@ class RestTest extends \PHPUnit_Framework_TestCase */ public function testSecureRouteAndRequest($isSecureRoute, $isSecureRequest) { - $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($isSecureRoute)); $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue([])); @@ -205,7 +205,6 @@ class RestTest extends \PHPUnit_Framework_TestCase */ public function testInSecureRequestOverSecureRoute() { - $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'])); @@ -224,11 +223,10 @@ class RestTest extends \PHPUnit_Framework_TestCase public function testAuthorizationFailed() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); $this->_oauthServiceMock->expects( $this->any())->method('validateAccessTokenRequest')->will($this->returnValue('fred') - ); + ); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['5', '6'])); $this->_restController->dispatch($this->_requestMock); @@ -253,7 +251,6 @@ class RestTest extends \PHPUnit_Framework_TestCase { $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->_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)); @@ -328,4 +325,4 @@ class TestService { return null; } -} +} \ No newline at end of file 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 ee5bca50ada..25f780582dd 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 @@ -96,7 +96,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase $className = 'Magento\Framework\Object'; $methodName = 'testMethod'; $isSecure = false; - $aclResources = array('Magento_TestModule::resourceA'); + $aclResources = array(array('Magento_TestModule::resourceA')); $this->_apiConfigMock->expects($this->once()) ->method('getServiceMethodInfo') ->with($operationName, $requestedServices) diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index a84ec784d38..20bf1714915 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -27,27 +27,36 @@ namespace Magento\Webapi\Controller; class SoapTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Webapi\Controller\Soap */ + /** + * @var \Magento\Webapi\Controller\Soap + */ protected $_soapController; - /** @var \Magento\Webapi\Model\Soap\Server */ + /** + * @var \Magento\Webapi\Model\Soap\Server + */ protected $_soapServerMock; - /** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */ + /** + * @var \Magento\Webapi\Model\Soap\Wsdl\Generator + */ protected $_wsdlGeneratorMock; - /** @var \Magento\Webapi\Controller\Soap\Request */ + /** + * @var \Magento\Webapi\Controller\Soap\Request + */ protected $_requestMock; - /** @var \Magento\Webapi\Controller\Response */ + /** + * @var \Magento\Webapi\Controller\Response + */ protected $_responseMock; - /** @var \Magento\Webapi\Controller\ErrorProcessor */ + /** + * @var \Magento\Webapi\Controller\ErrorProcessor + */ protected $_errorProcessorMock; - /** @var \Magento\Framework\App\State */ - protected $_appStateMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Locale\ResolverInterface */ @@ -118,42 +127,11 @@ class SoapTest extends \PHPUnit_Framework_TestCase ); } - /** - * Test redirected to install page - */ - public function testRedirectToInstallPage() - { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(false)); - $this->_errorProcessorMock->expects($this->any())->method('maskException')->will($this->returnArgument(0)); - $encoding = "utf-8"; - $this->_soapServerMock->expects($this->any())->method('getApiCharset')->will($this->returnValue($encoding)); - - $this->_soapController->dispatch($this->_requestMock); - $expectedMessage = <<<EXPECTED_MESSAGE -<?xml version="1.0" encoding="{$encoding}"?> -<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" > - <env:Body> - <env:Fault> - <env:Code> - <env:Value>env:Sender</env:Value> - </env:Code> - <env:Reason> - <env:Text xml:lang="en">Magento is not yet installed</env:Text> - </env:Reason> - </env:Fault> - </env:Body> -</env:Envelope> -EXPECTED_MESSAGE; - - $this->assertXmlStringEqualsXmlString($expectedMessage, $this->_responseMock->getBody()); - } - /** * Test successful WSDL content generation. */ public function testDispatchWsdl() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_mockGetParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL, 1); $wsdl = 'Some WSDL content'; $this->_wsdlGeneratorMock->expects($this->any())->method('generate')->will($this->returnValue($wsdl)); @@ -167,7 +145,6 @@ EXPECTED_MESSAGE; */ public function testDispatchSoapRequest() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_soapServerMock->expects($this->once())->method('handle'); $response = $this->_soapController->dispatch($this->_requestMock); $this->assertEquals(200, $response->getHttpResponseCode()); @@ -178,7 +155,6 @@ EXPECTED_MESSAGE; */ public function testDispatchWithException() { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $exceptionMessage = 'some error message'; $exception = new \Magento\Webapi\Exception($exceptionMessage); $this->_soapServerMock->expects($this->any())->method('handle')->will($this->throwException($exception)); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index eb66ff88f74..97b6eb20476 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -39,7 +39,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\DomDocument\Factory */ protected $_domDocumentFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** @var \Magento\Framework\StoreManagerInterface */ protected $_storeManagerMock; /** @var \Magento\Webapi\Model\Soap\Server\Factory */ diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php index 51316482330..29679944e47 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php @@ -42,7 +42,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $_typeProcessor; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $storeManagerMock; protected function setUp() @@ -91,7 +91,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ); $this->storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManagerInterface' + 'Magento\Framework\StoreManagerInterface' )->setMethods(['getStore'])->disableOriginalConstructor()->getMockForAbstractClass(); $storeMock = $this->getMockBuilder( diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php index f1aecef20a5..31a891d2017 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DataFromArrayTest.php @@ -37,7 +37,10 @@ class DataFromArrayTest extends \PHPUnit_Framework_TestCase $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $objectFactory = new \Magento\Webapi\Service\Entity\WebapiObjectManager($objectManager); $typeProcessor = $objectManager->getObject('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor'); - $this->serializer = new ServiceArgsSerializer($typeProcessor, $objectFactory); + $this->serializer = $objectManager->getObject( + 'Magento\Webapi\Controller\ServiceArgsSerializer', + ['typeProcessor' => $typeProcessor, 'objectManager' => $objectFactory] + ); } public function testSimpleProperties() diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php index 6e3b32a5270..70b58ed5e57 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Helper/DataTest.php @@ -42,7 +42,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->with('wishlist/index/cart', array('item' => '%item%', 'uenc' => $encoded)) ->will($this->returnValue($url)); - $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', array(), array(), '', false); + $storeManager = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $storeManager->expects($this->any()) ->method('getStore') ->will($this->returnValue($store)); diff --git a/app/code/Magento/Install/Controller/Wizard/Index.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php similarity index 80% rename from app/code/Magento/Install/Controller/Wizard/Index.php rename to dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php index 2c1bd21c85b..62d0c563b58 100644 --- a/app/code/Magento/Install/Controller/Wizard/Index.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/AuthenticationStateTest.php @@ -22,17 +22,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Wishlist\Model; -class Index extends \Magento\Install\Controller\Wizard +class AuthenticationStateTest extends \PHPUnit_Framework_TestCase { - /** - * Index action - * - * @return void - */ - public function execute() + public function testIsEnabled() { - $this->_redirect('*/*/begin'); + $this->assertTrue((new AuthenticationState())->isEnabled()); } } + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php index b2bcb25f598..69665d3a4b8 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ConfigTest.php @@ -28,60 +28,58 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Wishlist\Model\Config */ - protected $_model; + protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_catalogConfig; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Attribute\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_attributeConfig; protected function setUp() { - $this->_scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->_catalogConfig = $this->getMock('Magento\Catalog\Model\Config', array(), array(), '', false); - $this->_attributeConfig = $this->getMock( - 'Magento\Catalog\Model\Attribute\Config', - array(), - array(), - '', - false - ); - $this->_model = new \Magento\Wishlist\Model\Config( - $this->_scopeConfig, - $this->_catalogConfig, - $this->_attributeConfig - ); + $this->_scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); + $this->_catalogConfig = $this->getMockBuilder('Magento\Catalog\Model\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->_attributeConfig = $this->getMockBuilder('Magento\Catalog\Model\Attribute\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new Config($this->_scopeConfig, $this->_catalogConfig, $this->_attributeConfig); } public function testGetProductAttributes() { - $this->_catalogConfig->expects( - $this->once() - )->method( - 'getProductAttributes' - )->will( - $this->returnValue(array('attribute_one', 'attribute_two')) - ); - $this->_attributeConfig->expects( - $this->once() - )->method( - 'getAttributeNames' - )->with( - 'wishlist_item' - )->will( - $this->returnValue(array('attribute_three')) - ); - $expectedResult = array('attribute_one', 'attribute_two', 'attribute_three'); - $this->assertEquals($expectedResult, $this->_model->getProductAttributes()); + $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three']; + + $this->_catalogConfig->expects($this->once()) + ->method('getProductAttributes') + ->willReturn(['attribute_one', 'attribute_two']); + $this->_attributeConfig->expects($this->once()) + ->method('getAttributeNames') + ->with('wishlist_item') + ->willReturn(['attribute_three']); + + $this->assertEquals($expectedResult, $this->model->getProductAttributes()); + } + + public function testGetSharingEmailLimit() + { + $this->assertEquals(Config::SHARING_EMAIL_LIMIT, $this->model->getSharingEmailLimit()); + } + + public function testGetSharingTextLimit() + { + $this->assertEquals(Config::SHARING_TEXT_LIMIT, $this->model->getSharingTextLimit()); } } diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php index 6f710677573..b3b9a875fdf 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ItemTest.php @@ -24,56 +24,188 @@ namespace Magento\Wishlist\Model; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ItemTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\TestFramework\Helper\ObjectManager + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Catalog\Model\Resource\Url|\PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogUrl; + + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productTypeConfig; + + /** + * @var \Magento\Wishlist\Model\Resource\Item|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collection; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $date; + + /** + * @var \Magento\Wishlist\Model\Item\OptionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $optionFactory; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemOptFactory; + + /** + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; + protected $productFactory; /** - * @var \Magento\Wishlist\Model\Item + * @var Item */ - protected $wishlistItem; + protected $model; - protected function setUp() + public function setUp() { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); - $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], ''); - $dateMock = $this->getMock('\Magento\Framework\Stdlib\DateTime\DateTime', [], [], '', false); - $productFactoryMock = $this->getMock('\Magento\Catalog\Model\ProductFactory', [], [], '', false); - $catalogUrlMock = $this->getMock('\Magento\Catalog\Model\Resource\Url', [], [], '', false); - $wishlistOptFactoryMock = $this->getMock('\Magento\Wishlist\Model\Item\OptionFactory', [], [], '', false); - $wishlOptionCollectionFactoryMock = $this->getMock( - 'Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory', - [], - [], - '', - false - ); - $productTypeConfigMock = $this->getMock( - '\Magento\Catalog\Model\ProductTypes\ConfigInterface', - [], - [], - '' + $context = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->getMock(); + $this->date = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + ->disableOriginalConstructor() + ->getMock(); + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->catalogUrl = $this->getMockBuilder('Magento\Catalog\Model\Resource\Url') + ->disableOriginalConstructor() + ->getMock(); + $this->optionFactory = $this->getMockBuilder('Magento\Wishlist\Model\Item\OptionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->itemOptFactory = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->productTypeConfig = $this->getMockBuilder('Magento\Catalog\Model\ProductTypes\ConfigInterface') + ->getMock(); + $this->resource = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item') + ->disableOriginalConstructor() + ->getMock(); + $this->collection = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new Item( + $context, + $this->registry, + $this->storeManager, + $this->date, + $this->productFactory, + $this->catalogUrl, + $this->optionFactory, + $this->itemOptFactory, + $this->productTypeConfig, + $this->resource, + $this->collection, + array() ); + } + + /** + * @dataProvider getOptionsDataProvider + */ + public function testAddGetOptions($code, $option) + { + $this->assertEmpty($this->model->getOptions()); + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('setData', 'getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('setData') + ->willReturnSelf(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn($code); + + $this->optionFactory->expects($this->any()) + ->method('create') + ->willReturn($optionMock); + $this->model->addOption($option); + $this->assertEquals(1, count($this->model->getOptions())); + } - $this->wishlistItem = $this->objectManager->getObject( - '\Magento\Wishlist\Model\Item', - [ - 'context' => $contextMock, - 'registry' => $registryMock, - 'storeManager' => $storeManagerMock, - 'date' => $dateMock, - 'productFactory' => $productFactoryMock, - 'catalogUrl' => $catalogUrlMock, - 'wishlistOptFactory' => $wishlistOptFactoryMock, - 'wishlOptionCollectionFactory' => $wishlOptionCollectionFactoryMock, - 'productTypeConfig' => $productTypeConfigMock, - ] + /** + * @dataProvider getOptionsDataProvider + */ + public function testRemoveOptionByCode($code, $option) + { + $this->assertEmpty($this->model->getOptions()); + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('setData', 'getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('setData') + ->willReturnSelf(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn($code); + + $this->optionFactory->expects($this->any()) + ->method('create') + ->willReturn($optionMock); + $this->model->addOption($option); + $this->assertEquals(1, count($this->model->getOptions())); + $this->model->removeOption($code); + $actualOptions = $this->model->getOptions(); + $actualOption = array_pop($actualOptions); + $this->assertTrue($actualOption->isDeleted()); + } + + public function getOptionsDataProvider() + { + $optionMock = $this->getMockBuilder('Magento\Wishlist\Model\Item\Option') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup')) + ->getMock(); + $optionMock->expects($this->any()) + ->method('getCode') + ->willReturn('second_key'); + + $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + return array( + array('first_key', array('code' => 'first_key', 'value' => 'first_data')), + array('second_key',$optionMock), + array('third_key', new \Magento\Framework\Object(array('code' => 'third_key', 'product' => $productMock))), ); } @@ -81,28 +213,22 @@ class ItemTest extends \PHPUnit_Framework_TestCase { $code = 'someOption'; $optionValue = 100; - $optionsOneMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getCode', '__wakeup', 'getValue'], - [], - '', - false - ); - $optionsTwoMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getValue', '__wakeup'], - [], - '', - false - ); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup', 'getValue')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup', 'getValue')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); $optionsOneMock->expects($this->once())->method('getValue')->will($this->returnValue($optionValue)); $optionsTwoMock->expects($this->once())->method('getValue')->will($this->returnValue($optionValue)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - [$code => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array($code => $optionsTwoMock) ); $this->assertTrue($result); @@ -113,28 +239,22 @@ class ItemTest extends \PHPUnit_Framework_TestCase $code = 'someOption'; $optionOneValue = 100; $optionTwoValue = 200; - $optionsOneMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getCode', '__wakeup', 'getValue'], - [], - '', - false - ); - $optionsTwoMock = $this->getMock( - '\Magento\Sales\Model\Quote\Item', - ['getValue', '__wakeup'], - [], - '', - false - ); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup', 'getValue')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup', 'getValue')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); $optionsOneMock->expects($this->once())->method('getValue')->will($this->returnValue($optionOneValue)); $optionsTwoMock->expects($this->once())->method('getValue')->will($this->returnValue($optionTwoValue)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - [$code => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array($code => $optionsTwoMock) ); $this->assertFalse($result); @@ -143,14 +263,20 @@ class ItemTest extends \PHPUnit_Framework_TestCase public function testCompareOptionsNegativeOptionsTwoHaveNotOption() { $code = 'someOption'; - $optionsOneMock = $this->getMock('\Magento\Sales\Model\Quote\Item', ['getCode', '__wakeup'], [], '', false); - $optionsTwoMock = $this->getMock('\Magento\Sales\Model\Quote\Item', [], [], '', false); + $optionsOneMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('getCode', '__wakeup')) + ->getMock(); + $optionsTwoMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(array('__wakeup')) + ->getMock(); $optionsOneMock->expects($this->once())->method('getCode')->will($this->returnValue($code)); - $result = $this->wishlistItem->compareOptions( - [$code => $optionsOneMock], - ['someOneElse' => $optionsTwoMock] + $result = $this->model->compareOptions( + array($code => $optionsOneMock), + array('someOneElse' => $optionsTwoMock) ); $this->assertFalse($result); diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.php new file mode 100644 index 00000000000..f3e9742bed2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/LocaleQuantityProcessorTest.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\Wishlist\Model; + + +class LocaleQuantityProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var LocaleQuantityProcessor + */ + protected $processor; + + /** + * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resolver; + + /** + * @var \Magento\Framework\Filter\LocalizedToNormalized|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filter; + + public function setUp() + { + $this->resolver = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')->getMock(); + $this->filter = $this->getMockBuilder('Magento\Framework\Filter\LocalizedToNormalized') + ->disableOriginalConstructor() + ->getMock(); + $this->processor = new LocaleQuantityProcessor($this->resolver, $this->filter); + } + + /** + * @param int $qtyResult + * @param int|null $expectedResult + * @dataProvider processDataProvider + */ + public function testProcess($qtyResult, $expectedResult) + { + $qty = 10; + $localCode = 'en_US'; + + $this->resolver->expects($this->once()) + ->method('getLocaleCode') + ->willReturn($localCode); + + $this->filter->expects($this->once()) + ->method('setOptions') + ->with(['locale' => $localCode]) + ->willReturnSelf(); + + $this->filter->expects($this->once()) + ->method('filter') + ->with($qty) + ->willReturn($qtyResult); + + $this->assertEquals($expectedResult, $this->processor->process($qty)); + } + + public function processDataProvider() + { + return [ + 'positive' => [10.00, 10.00], + 'negative' => [0, null], + ]; + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.php new file mode 100644 index 00000000000..54c346b2fb1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/ObserverTest.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\Wishlist\Model; + + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Observer + */ + protected $observer; + + /** + * @var \Magento\Wishlist\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Checkout\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSession; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSession; + + /** + * @var \Magento\Wishlist\Model\WishlistFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlistFactory; + + /** + * @var \Magento\Wishlist\Model\Wishlist|\PHPUnit_Framework_MockObject_MockObject + */ + protected $wishlist; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + public function setUp() + { + $this->helper = $this->getMockBuilder('Magento\Wishlist\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->checkoutSession = $this->getMockBuilder('Magento\Checkout\Model\Session') + ->setMethods( + [ + 'getSharedWishlist', + 'getWishlistPendingMessages', + 'getWishlistPendingUrls', + 'getWishlistIds', + 'getSingleWishlistId', + 'setSingleWishlistId', + 'setWishlistIds', + 'setWishlistPendingUrls', + 'setWishlistPendingMessages', + 'setNoCartRedirect', + ] + ) + ->disableOriginalConstructor() + ->getMock(); + $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['setWishlistItemCount', 'isLoggedIn', 'getCustomerId']) + ->getMock(); + $this->wishlistFactory = $this->getMockBuilder('Magento\Wishlist\Model\WishlistFactory') + ->setMethods(['create']) + ->getMock(); + $this->wishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + ->getMock(); + + $this->wishlistFactory->expects($this->any()) + ->method('create') + ->willReturn($this->wishlist); + + $this->observer = new Observer( + $this->helper, + $this->checkoutSession, + $this->customerSession, + $this->wishlistFactory, + $this->messageManager + ); + } + + public function testCustomerLogin() + { + $event = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + /** @var $event \Magento\Framework\Event\Observer */ + + $this->helper->expects($this->once()) + ->method('calculate'); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->customerLogin($event) + ); + } + + public function testCustomerLogout() + { + $event = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + /** @var $event \Magento\Framework\Event\Observer */ + + $this->customerSession->expects($this->once()) + ->method('setWishlistItemCount') + ->with($this->equalTo(0)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->customerLogout($event) + ); + } + + public function testProcessCartUpdateBefore() + { + $customerId = 1; + $itemId = 5; + $itemQty = 123; + $productId = 321; + + $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + + $event = $this->getMockBuilder('Magento\Framework\Event') + ->setMethods(['getCart', 'getInfo']) + ->disableOriginalConstructor() + ->getMock(); + + $eventObserver->expects($this->any()) + ->method('getEvent') + ->willReturn($event); + + $quoteItem = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->setMethods(['getProductId', 'getBuyRequest']) + ->disableOriginalConstructor() + ->getMock(); + + $buyRequest = $this->getMockBuilder('Magento\Framework\Object') + ->setMethods(['setQty']) + ->disableOriginalConstructor() + ->getMock(); + + $cart = $this->getMockBuilder('Magento\Checkout\Model\Cart')->disableOriginalConstructor()->getMock(); + $quote = $this->getMockBuilder('Magento\Sales\Model\Quote') + ->setMethods(['getCustomerId', 'getItemById', 'removeItem']) + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->once()) + ->method('getCart') + ->willReturn($cart); + + $event->expects($this->once()) + ->method('getInfo') + ->willReturn([$itemId => ['qty' => $itemQty, 'wishlist' => true]]); + + $cart->expects($this->any()) + ->method('getQuote') + ->willReturn($quote); + + $quoteItem->expects($this->once()) + ->method('getProductId') + ->willReturn($productId); + $quoteItem->expects($this->once()) + ->method('getBuyRequest') + ->willReturn($buyRequest); + + $buyRequest->expects($this->once()) + ->method('setQty') + ->with($itemQty) + ->willReturnSelf(); + + $quote->expects($this->once()) + ->method('getCustomerId') + ->willReturn($customerId); + + $quote->expects($this->once()) + ->method('getItemById') + ->with($itemId) + ->willReturn($quoteItem); + + $quote->expects($this->once()) + ->method('removeItem') + ->with($itemId); + + $this->wishlist->expects($this->once()) + ->method('loadByCustomerId') + ->with($this->logicalOr($customerId, true)) + ->willReturnSelf(); + + $this->wishlist->expects($this->once()) + ->method('addNewItem') + ->with($this->logicalOr($productId, $buyRequest)); + + $this->wishlist->expects($this->once()) + ->method('save'); + + $this->helper->expects($this->once()) + ->method('calculate'); + + /** @var $eventObserver \Magento\Framework\Event\Observer */ + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Observer', + $this->observer->processCartUpdateBefore($eventObserver) + ); + } + + public function testProcessAddToCart() + { + $wishlistId = 1; + $customerId = 2; + $url = 'http://some.pending/url'; + $message = 'some error msg'; + + $eventObserver = $this->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + $event = $this->getMockBuilder('Magento\Framework\Event') + ->setMethods(['getRequest', 'getResponse']) + ->disableOriginalConstructor() + ->getMock(); + $request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')->getMock(); + $response = $this->getMockBuilder('Magento\Framework\App\ResponseInterface') + ->setMethods(['setRedirect']) + ->getMockForAbstractClass(); + $wishlists = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist\Collection') + ->disableOriginalConstructor() + ->getMock(); + $loadedWishlist = $this->getMockBuilder('Magento\Wishlist\Model\Wishlist\Item') + ->setMethods(['getId', 'delete']) + ->disableOriginalConstructor() + ->getMock(); + + $eventObserver->expects($this->any())->method('getEvent')->willReturn($event); + + $request->expects($this->any())->method('getParam')->with('wishlist_next')->willReturn(true); + $event->expects($this->once())->method('getRequest')->willReturn($request); + + $this->checkoutSession->expects($this->once())->method('getSharedWishlist'); + $this->checkoutSession->expects($this->once())->method('getWishlistPendingMessages')->willReturn([$message]); + $this->checkoutSession->expects($this->once())->method('getWishlistPendingUrls')->willReturn([$url]); + $this->checkoutSession->expects($this->once())->method('getWishlistIds'); + $this->checkoutSession->expects($this->once())->method('getSingleWishlistId')->willReturn($wishlistId); + + $this->customerSession->expects($this->once()) + ->method('isLoggedIn') + ->willReturn(true); + $this->customerSession->expects($this->once()) + ->method('getCustomerId') + ->willReturn($customerId); + $this->wishlist->expects($this->once()) + ->method('loadByCustomerId') + ->with($this->logicalOr($customerId, true)) + ->willReturnSelf(); + $this->wishlist->expects($this->once()) + ->method('getItemCollection') + ->willReturn($wishlists); + $loadedWishlist->expects($this->once()) + ->method('getId') + ->willReturn($wishlistId); + $loadedWishlist->expects($this->once()) + ->method('delete'); + $wishlists->expects($this->once()) + ->method('load') + ->willReturn([$loadedWishlist]); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistIds') + ->with([]) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setSingleWishlistId') + ->with(null) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistPendingUrls') + ->with([]) + ->willReturnSelf(); + $this->checkoutSession->expects($this->once()) + ->method('setWishlistPendingMessages') + ->with([]) + ->willReturnSelf(); + $this->messageManager->expects($this->once()) + ->method('addError') + ->with($message) + ->willReturnSelf(); + $event->expects($this->once()) + ->method('getResponse') + ->willReturn($response); + $response->expects($this->once()) + ->method('setRedirect') + ->with($url); + $this->checkoutSession->expects($this->once()) + ->method('setNoCartRedirect') + ->with(true); + + /** @var $eventObserver \Magento\Framework\Event\Observer */ + $this->observer->processAddToCart($eventObserver); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php new file mode 100644 index 00000000000..01fadaf9e72 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Model/WishlistTest.php @@ -0,0 +1,303 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Model; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class WishlistTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \Magento\Catalog\Helper\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productHelper; + + /** + * @var \Magento\Wishlist\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helper; + + /** + * @var \Magento\Wishlist\Model\Resource\Wishlist|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * @var \Magento\Wishlist\Model\Resource\Wishlist\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collection; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $date; + + /** + * @var \Magento\Wishlist\Model\ItemFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemFactory; + + /** + * @var \Magento\Wishlist\Model\Resource\Item\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $itemsFactory; + + /** + * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productFactory; + + /** + * @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject + */ + protected $mathRandom; + + /** + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dateTime; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventDispatcher; + + /** + * @var Wishlist + */ + protected $wishlist; + + public function setUp() + { + $context = $this->getMockBuilder('Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->getMock(); + $this->registry = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->productHelper = $this->getMockBuilder('Magento\Catalog\Helper\Product') + ->disableOriginalConstructor() + ->getMock(); + $this->helper = $this->getMockBuilder('Magento\Wishlist\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + $this->resource = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist') + ->disableOriginalConstructor() + ->getMock(); + $this->collection = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Wishlist\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->getMock(); + $this->date = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTime') + ->disableOriginalConstructor() + ->getMock(); + $this->itemFactory = $this->getMockBuilder('Magento\Wishlist\Model\ItemFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->itemsFactory = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + $this->mathRandom = $this->getMockBuilder('Magento\Framework\Math\Random') + ->disableOriginalConstructor() + ->getMock(); + $this->dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime') + ->disableOriginalConstructor() + ->getMock(); + + $context->expects($this->once()) + ->method('getEventDispatcher') + ->will($this->returnValue($this->eventDispatcher)); + + $this->wishlist = new Wishlist( + $context, + $this->registry, + $this->productHelper, + $this->helper, + $this->resource, + $this->collection, + $this->storeManager, + $this->date, + $this->itemFactory, + $this->itemsFactory, + $this->productFactory, + $this->mathRandom, + $this->dateTime, + false + ); + } + + public function testLoadByCustomerId() + { + $customerId = 1; + $customerIdFieldName = 'customer_id'; + $sharingCode = 'expected_sharing_code'; + $this->eventDispatcher->expects($this->any()) + ->method('dispatch'); + $this->resource->expects($this->once()) + ->method('addCommitCallback') + ->will($this->returnSelf()); + $this->resource->expects($this->once()) + ->method('commit'); + $this->resource->expects($this->any()) + ->method('getCustomerIdFieldName'); + $this->resource->expects($this->once()) + ->method('load') + ->with($this->logicalOr($this->wishlist, $customerId, $customerIdFieldName)); + $this->mathRandom->expects($this->once()) + ->method('getUniqueHash') + ->will($this->returnValue($sharingCode)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Wishlist', + $this->wishlist->loadByCustomerId($customerId, true) + ); + $this->assertEquals($customerId, $this->wishlist->getCustomerId()); + $this->assertEquals($sharingCode, $this->wishlist->getSharingCode()); + } + + /** + * @param int|\Magento\Wishlist\Model\Item|\PHPUnit_Framework_MockObject_MockObject $itemId + * @param \Magento\Framework\Object $buyRequest + * @param null|array|\Magento\Framework\Object $param + * @throws \Magento\Framework\Model\Exception + * + * @dataProvider updateItemDataProvider + */ + public function testUpdateItem($itemId, $buyRequest, $param) + { + $storeId = 1; + $productId = 1; + $stores = [(new \Magento\Framework\Object)->setId($storeId)]; + + $newItem = $this->getMockBuilder('Magento\Wishlist\Model\Item')->disableOriginalConstructor()->getMock(); + $newItem->expects($this->any())->method('setProductId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setWishlistId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setStoreId')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setOptions')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setProduct')->will($this->returnSelf()); + $newItem->expects($this->any())->method('setQty')->will($this->returnSelf()); + $newItem->expects($this->any())->method('getItem')->will($this->returnValue(2)); + + $this->itemFactory->expects($this->once())->method('create')->will($this->returnValue($newItem)); + + $this->storeManager->expects($this->any())->method('getStores')->will($this->returnValue($stores)); + $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($stores[0])); + + $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); + + $instanceType = $this->getMockBuilder('Magento\Catalog\Model\Product\Type\AbstractType') + ->disableOriginalConstructor() + ->getMock(); + $instanceType->expects($this->once()) + ->method('processConfiguration') + ->will( + $this->returnValue( + $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock() + ) + ); + + $newProduct = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()->getMock(); + $newProduct->expects($this->any()) + ->method('setStoreId') + ->with($storeId) + ->will($this->returnSelf()); + $newProduct->expects($this->once()) + ->method('load') + ->with($productId) + ->will($this->returnSelf()); + $newProduct->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($instanceType)); + + $item = $this->getMockBuilder('Magento\Wishlist\Model\Item')->disableOriginalConstructor()->getMock(); + $item->expects($this->once()) + ->method('getProduct') + ->will($this->returnValue($product)); + + $items = $this->getMockBuilder('Magento\Wishlist\Model\Resource\Item\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $items->expects($this->once()) + ->method('addWishlistFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('addStoreFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('setVisibilityFilter') + ->will($this->returnSelf()); + $items->expects($this->once()) + ->method('getItemById') + ->will($this->returnValue($item)); + $items->expects($this->any()) + ->method('getIterator') + ->will($this->returnValue(new \ArrayIterator([$item]))); + + $this->itemsFactory->expects($this->any()) + ->method('create') + ->will($this->returnValue($items)); + + $this->productFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($newProduct)); + + $this->assertInstanceOf( + 'Magento\Wishlist\Model\Wishlist', + $this->wishlist->updateItem($itemId, $buyRequest, $param) + ); + } + + /** + * @return array + */ + public function updateItemDataProvider() + { + return [ + '0' => [1, new \Magento\Framework\Object(), null], + ]; + } +} + \ No newline at end of file diff --git a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php b/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php index 88d4e6ed57b..feb6edff6de 100644 --- a/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php +++ b/dev/tools/Magento/Tools/Dependency/generate/bootstrap.php @@ -22,9 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('BP', realpath(__DIR__ . '/../../../../../../') . '/'); - -require_once BP . 'app/autoload.php'; +require_once __DIR__ . '/../../../../../../app/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( - array(BP . 'dev/tests/static/framework', BP . 'dev/tools', BP . '/lib') + array(BP . '/dev/tests/static/framework', BP . '/dev/tools') ); diff --git a/dev/tools/Magento/Tools/Migration/themes_view.php b/dev/tools/Magento/Tools/Migration/themes_view.php index 0a74b86fc7f..e74ee0f2007 100644 --- a/dev/tools/Magento/Tools/Migration/themes_view.php +++ b/dev/tools/Magento/Tools/Migration/themes_view.php @@ -21,12 +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) */ + require_once __DIR__ . '/../../../../../app/bootstrap.php'; -$rootDir = realpath(__DIR__ . '/../../../../..'); +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); try { - $entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint($rootDir, array()); - - $objectManager = new \Magento\Framework\App\ObjectManager(); + $objectManager = $bootstrap->getObjectManager(); /** @var $configModel \Magento\Framework\App\Config\ReinitableConfigInterface */ $configModel = $objectManager->get('Magento\Framework\App\Config\ReinitableConfigInterface'); $configModel->reinit(); diff --git a/dev/tools/Magento/Tools/View/deploy.php b/dev/tools/Magento/Tools/View/deploy.php index f0735222f46..741fd25f77e 100644 --- a/dev/tools/Magento/Tools/View/deploy.php +++ b/dev/tools/Magento/Tools/View/deploy.php @@ -30,7 +30,6 @@ $baseName = basename(__FILE__); $options = getopt('', array('langs::', 'dry-run', 'verbose::', 'help')); define('USAGE', "USAGE:\n\tphp -f {$baseName} -- [--langs=en_US,de_DE,...] [--verbose=0|1] [--dry-run] [--help]\n"); -define('BARE_BOOTSTRAP', 1); require __DIR__ . '/../../../../../app/bootstrap.php'; $autoloader = new \Magento\Framework\Autoload\IncludePath(); $autoloader->addIncludePath([BP . '/dev/tests/static/framework', realpath(__DIR__ . '/../../..')]); diff --git a/dev/tools/bootstrap.php b/dev/tools/bootstrap.php index 445c23378b0..06ca15114a4 100644 --- a/dev/tools/bootstrap.php +++ b/dev/tools/bootstrap.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require_once __DIR__ . '/../../app/autoload.php'; -define('BP', __DIR__ . '/../..'); (new \Magento\Framework\Autoload\IncludePath())->addIncludePath( array( BP . '/app/code', diff --git a/index.php b/index.php index 6eada12c902..9aa971b7efd 100644 --- a/index.php +++ b/index.php @@ -4,11 +4,10 @@ * * Example - run a particular store or website: * -------------------------------------------- - * $params = $_SERVER; - * $params['MAGE_RUN_CODE'] = 'website2'; - * $params['MAGE_RUN_TYPE'] = 'website'; - * ... - * $entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); + * $extra = ['MAGE_RUN_CODE' => 'website2', 'MAGE_RUN_TYPE' => 'website']; + * $bootstrap = new \Magento\Framework\App\Bootstrap(BP, $_SERVER, $extra); + * $app = $bootstrap->createApplication('Magento\Framework\App\Http'); + * $bootstrap->run($app); * -------------------------------------------- * * Magento @@ -32,6 +31,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) */ + require __DIR__ . '/app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Framework\App\Http'); +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER, null); +/** @var \Magento\Framework\App\Http $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$bootstrap->run($app); diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php new file mode 100644 index 00000000000..3e1e88961bc --- /dev/null +++ b/lib/internal/Magento/Framework/App/Bootstrap.php @@ -0,0 +1,391 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\App; + +use Magento\Framework\Profiler; +use \Magento\Framework\AppInterface; + +/** + * A bootstrap of Magento application + * + * Performs basic initialization root function: injects init parameters and creates object manager + * Can create/run applications + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class Bootstrap +{ + /**#+ + * Possible errors that can be triggered by the bootstrap + */ + const ERR_MAINTENANCE = 901; + const ERR_IS_INSTALLED = 902; + /**#- */ + + /**#+ + * Initialization parameters that allow control bootstrap behavior of asserting maintenance mode or is installed + * + * Possible values: + * - true -- set expectation that it is required + * - false -- set expectation that is required not to + * - null -- bypass the assertion completely + * + * If key is absent in the parameters array, the default behavior will be used + * @see DEFAULT_REQUIRE_MAINTENANCE + * @see DEFAULT_REQUIRE_IS_INSTALLED + */ + const PARAM_REQUIRE_MAINTENANCE = 'MAGE_REQUIRE_MAINTENANCE'; + const PARAM_REQUIRE_IS_INSTALLED = 'MAGE_REQUIRE_IS_INSTALLED'; + /**#- */ + + /**#+ + * Default behavior of bootstrap assertions + */ + const DEFAULT_REQUIRE_MAINTENANCE = false; + const DEFAULT_REQUIRE_IS_INSTALLED = true; + /**#- */ + + /** + * The initialization parameters (normally come from the $_SERVER) + * + * @var array + */ + private $server; + + /** + * Root directory + * + * @var string + */ + private $rootDir; + + /** + * Object manager + * + * @var \Magento\Framework\ObjectManager + */ + private $objectManager; + + /** + * Directory list + * + * @var Filesystem\DirectoryList + */ + private $dirList; + + /** + * Configuration directory + * + * @var \Magento\Framework\Filesystem\Directory\ReadInterface + */ + private $configDir; + + /** + * Maintenance mode manager + * + * @var \Magento\Framework\App\MaintenanceMode + */ + private $maintenance; + + /** + * Bootstrap-specific error code that may have been set in runtime + * + * @var int + */ + private $errorCode = 0; + + /** + * Attribute for creating object manager + * + * @var ObjectManagerFactory + */ + private $factory; + + /** + * Static method so that client code does not have to create Object Manager Factory every time Bootstrap is called + * + * @param string $rootDir + * @param array $initParams + * @param ObjectManagerFactory $factory + * @return Bootstrap + */ + public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null) + { + if ($factory === null) { + $factory = new ObjectManagerFactory; + } + return new self($factory, $rootDir, $initParams); + } + + /** + * Constructor + * + * @param ObjectManagerFactory $factory + * @param string $rootDir + * @param array $initParams + */ + public function __construct(ObjectManagerFactory $factory, $rootDir, array $initParams) + { + $this->factory = $factory; + $this->rootDir = $rootDir; + $this->server = $initParams; + } + + /** + * Gets the current parameters + * + * @return array + */ + public function getParams() + { + return $this->server; + } + + /** + * Factory method for creating application instances + * + * @param string $type + * @param array $arguments + * @return \Magento\Framework\AppInterface + * @throws \InvalidArgumentException + */ + public function createApplication($type, $arguments = []) + { + try { + $this->init(); + $application = $this->objectManager->create($type, $arguments); + if (!($application instanceof AppInterface)) { + throw new \InvalidArgumentException("The provided class doesn't implement AppInterface: {$type}"); + } + return $application; + } catch (\Exception $e) { + $this->terminate($e); + } + } + + /** + * Runs an application + * + * @param \Magento\Framework\AppInterface $application + * @return void + */ + public function run(AppInterface $application) + { + try { + try { + \Magento\Framework\Profiler::start('magento'); + $this->initErrorHandler(); + $this->init(); + $this->assertMaintenance(); + $this->assertInstalled(); + $response = $application->launch(); + $response->sendResponse(); + \Magento\Framework\Profiler::stop('magento'); + } catch (\Exception $e) { + \Magento\Framework\Profiler::stop('magento'); + if (!$application->catchException($this, $e)) { + throw $e; + } + } + } catch (\Exception $e) { + $this->terminate($e); + } + } + + /** + * Asserts maintenance mode + * + * @return void + * @throws \Exception + */ + protected function assertMaintenance() + { + $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_MAINTENANCE, self::DEFAULT_REQUIRE_MAINTENANCE); + if (null === $isExpected) { + return; + } + $this->init(); + $isOn = $this->maintenance->isOn(isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''); + if ($isOn && !$isExpected) { + $this->errorCode = self::ERR_MAINTENANCE; + throw new \Exception('Unable to proceed: the maintenance mode is enabled.'); + } + if (!$isOn && $isExpected) { + $this->errorCode = self::ERR_MAINTENANCE; + throw new \Exception('Unable to proceed: the maintenance mode must be enabled first.'); + } + } + + /** + * Asserts whether application is installed + * + * @return void + * @throws \Exception + */ + protected function assertInstalled() + { + $isExpected = $this->getIsExpected(self::PARAM_REQUIRE_IS_INSTALLED, self::DEFAULT_REQUIRE_IS_INSTALLED); + if (null === $isExpected) { + return; + } + $this->init(); + $isInstalled = $this->isInstalled(); + if (!$isInstalled && $isExpected) { + $this->errorCode = self::ERR_IS_INSTALLED; + throw new \Exception('Application is not installed yet.'); + } + if ($isInstalled && !$isExpected) { + $this->errorCode = self::ERR_IS_INSTALLED; + throw new \Exception('Application is already installed.'); + } + } + + /** + * Analyze a key in the initialization parameters as "is expected" parameter + * + * If there is no such key, returns default value. Otherwise casts it to boolean, unless it is null + * + * @param string $key + * @param bool $default + * @return bool|null + */ + private function getIsExpected($key, $default) + { + if (array_key_exists($key, $this->server)) { + if (isset($this->server[$key])) { + return (bool)(int)$this->server[$key]; + } + return null; + } + return $default; + } + + /** + * Determines whether application is installed + * + * @return bool + */ + private function isInstalled() + { + $this->init(); + return $this->configDir->isExist('local.xml'); + } + + /** + * Gets the object manager instance + * + * @return \Magento\Framework\ObjectManager + */ + public function getObjectManager() + { + $this->init(); + return $this->objectManager; + } + + /** + * Gets the directory list instance + * + * @return Filesystem\DirectoryList + */ + public function getDirList() + { + $this->init(); + return $this->dirList; + } + + /** + * Sets a custom error handler + * + * @return void + */ + private function initErrorHandler() + { + $handler = new ErrorHandler; + set_error_handler([$handler, 'handler']); + } + + /** + * Initializes the essential objects + * + * @return void + */ + private function init() + { + if (!$this->objectManager) { + $this->objectManager = $this->factory->create($this->rootDir, $this->server); + $this->dirList = $this->objectManager->get('Magento\Framework\App\Filesystem\DirectoryList'); + $this->maintenance = $this->objectManager->get('Magento\Framework\App\MaintenanceMode'); + /** @var $fileSystem \Magento\Framework\App\Filesystem */ + $fileSystem = $this->objectManager->get('Magento\Framework\App\Filesystem'); + $this->configDir = $fileSystem->getDirectoryRead(Filesystem::CONFIG_DIR); + } + } + + /** + * Getter for error code + * + * @return int + */ + public function getErrorCode() + { + return $this->errorCode; + } + + /** + * Checks whether developer mode is set in the initialization parameters + * + * @return bool + */ + public function isDeveloperMode() + { + return isset($this->server[State::PARAM_MODE]) && $this->server[State::PARAM_MODE] == State::MODE_DEVELOPER; + } + + /** + * Display an exception and terminate program execution + * + * @param \Exception $e + * @return void + * @SuppressWarnings(PHPMD.ExitExpression) + */ + protected function terminate(\Exception $e) + { + if ($this->isDeveloperMode()) { + echo $e; + } else { + $message = "An error has happened during application run. See debug log for details.\n"; + try { + if (!$this->objectManager) { + throw new \DomainException(); + } + $this->objectManager->get('Magento\Framework\Logger')->logException($e); + } catch (\Exception $e) { + $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; + } + echo $message; + } + exit(1); + } +} diff --git a/lib/internal/Magento/Framework/App/Cache/State.php b/lib/internal/Magento/Framework/App/Cache/State.php index 76521cdb5c4..b74851cca90 100644 --- a/lib/internal/Magento/Framework/App/Cache/State.php +++ b/lib/internal/Magento/Framework/App/Cache/State.php @@ -61,21 +61,17 @@ class State implements StateInterface /** * @param State\OptionsInterface $options * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool - * @param \Magento\Framework\App\State $appState * @param bool $banAll Whether all cache types are forced to be disabled */ public function __construct( State\OptionsInterface $options, \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, - \Magento\Framework\App\State $appState, $banAll = false ) { $this->_options = $options; $this->_cacheFrontend = $cacheFrontendPool->get(\Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID); - if ($appState->isInstalled()) { - $this->_loadTypeStatuses($banAll); - } + $this->_loadTypeStatuses($banAll); } /** diff --git a/lib/internal/Magento/Framework/App/Config/Element.php b/lib/internal/Magento/Framework/App/Config/Element.php index 77a1c91e4a5..cae7d6fe1ea 100644 --- a/lib/internal/Magento/Framework/App/Config/Element.php +++ b/lib/internal/Magento/Framework/App/Config/Element.php @@ -35,6 +35,7 @@ class Element extends \Magento\Framework\Simplexml\Element * @param string $var * @param boolean $value * @return boolean + * @SuppressWarnings(PHPMD.ShortMethodName) */ public function is($var, $value = true) { diff --git a/lib/internal/Magento/Framework/App/Cron.php b/lib/internal/Magento/Framework/App/Cron.php index 2157b253281..f4e4597e7e6 100644 --- a/lib/internal/Magento/Framework/App/Cron.php +++ b/lib/internal/Magento/Framework/App/Cron.php @@ -25,6 +25,7 @@ */ namespace Magento\Framework\App; +use Magento\Framework\App; use Magento\Framework\Event\ManagerInterface; class Cron implements \Magento\Framework\AppInterface @@ -82,4 +83,12 @@ class Cron implements \Magento\Framework\AppInterface $this->_response->setCode(0); return $this->_response; } + + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + return false; + } } diff --git a/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php b/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php deleted file mode 100644 index ebc7082fe4c..00000000000 --- a/lib/internal/Magento/Framework/App/EntryPoint/EntryPoint.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Application entry point, used to bootstrap and run application - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 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\App\EntryPoint; - -use Magento\Framework\App\State; -use Magento\Framework\App\EntryPointInterface; -use Magento\Framework\ObjectManager; - -class EntryPoint implements EntryPointInterface -{ - /** - * @var string - */ - protected $_rootDir; - - /** - * @var array - */ - protected $_parameters; - - /** - * Application object manager - * - * @var ObjectManager - */ - protected $_locator; - - /** - * @param string $rootDir - * @param array $parameters - * @param ObjectManager $objectManager - * @SuppressWarnings(PHPMD.ExitExpression) - */ - public function __construct($rootDir, array $parameters = array(), ObjectManager $objectManager = null) - { - $this->_rootDir = $rootDir; - $this->_parameters = $parameters; - $this->_locator = $objectManager; - } - - /** - * Run application - * - * @param string $applicationName - * @param array $arguments - * @return void - */ - public function run($applicationName, array $arguments = array()) - { - try { - \Magento\Framework\Profiler::start('magento'); - if (!$this->_locator) { - $locatorFactory = new \Magento\Framework\App\ObjectManagerFactory(); - $this->_locator = $locatorFactory->create($this->_rootDir, $this->_parameters); - } - $application = $this->_locator->create($applicationName, $arguments); - $response = $application->launch(); - \Magento\Framework\Profiler::stop('magento'); - $response->sendResponse(); - } catch (\Exception $exception) { - if (isset( - $this->_parameters[State::PARAM_MODE] - ) && $this->_parameters[State::PARAM_MODE] == State::MODE_DEVELOPER - ) { - echo $exception->getMessage() . "\n\n"; - echo $exception->getTraceAsString(); - } else { - $message = "Error happened during application run.\n"; - try { - if (!$this->_locator) { - throw new \DomainException(); - } - $this->_locator->get('Magento\Framework\Logger')->logException($exception); - } catch (\Exception $e) { - $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; - } - echo $message; - } - } - } -} diff --git a/lib/internal/Magento/Framework/App/Error/Handler.php b/lib/internal/Magento/Framework/App/Error/Handler.php deleted file mode 100644 index b3e2186a501..00000000000 --- a/lib/internal/Magento/Framework/App/Error/Handler.php +++ /dev/null @@ -1,105 +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) - */ - -/** - * Default Error Handler - */ -namespace Magento\Framework\App\Error; - -class Handler extends \Magento\Framework\Error\Handler -{ - /** - * @var \Magento\Framework\Logger - */ - protected $_logger; - - /** - * @var \Magento\Framework\App\Filesystem - */ - protected $_filesystem; - - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @param \Magento\Framework\Logger $logger - * @param \Magento\Framework\App\Filesystem $filesystem - * @param \Magento\Framework\App\State $appState - */ - public function __construct( - \Magento\Framework\Logger $logger, - \Magento\Framework\App\Filesystem $filesystem, - \Magento\Framework\App\State $appState - ) { - $this->_logger = $logger; - $this->_filesystem = $filesystem; - $this->_appState = $appState; - } - - /** - * Process exception - * - * @param \Exception $exception - * @param array $params - * @return void - */ - public function processException(\Exception $exception, array $params = array()) - { - if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { - parent::processException($exception, $params); - } else { - $reportData = array($exception->getMessage(), $exception->getTraceAsString()) + $params; - // retrieve server data - if (isset($_SERVER)) { - if (isset($_SERVER['REQUEST_URI'])) { - $reportData['url'] = $_SERVER['REQUEST_URI']; - } - if (isset($_SERVER['SCRIPT_NAME'])) { - $reportData['script_name'] = $_SERVER['SCRIPT_NAME']; - } - } - require_once $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::PUB_DIR) . '/errors/report.php'; - } - } - - /** - * Show error as exception or log it - * - * @param string $errorMessage - * @throws \Exception - * @return void - */ - protected function _processError($errorMessage) - { - if ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) { - parent::_processError($errorMessage); - } else { - $exception = new \Exception($errorMessage); - $errorMessage .= $exception->getTraceAsString(); - $this->_logger->log($errorMessage, \Zend_Log::ERR); - } - } -} diff --git a/lib/internal/Magento/Framework/Error/Handler.php b/lib/internal/Magento/Framework/App/ErrorHandler.php similarity index 60% rename from lib/internal/Magento/Framework/Error/Handler.php rename to lib/internal/Magento/Framework/App/ErrorHandler.php index f56e38fce06..79339fcac80 100644 --- a/lib/internal/Magento/Framework/Error/Handler.php +++ b/lib/internal/Magento/Framework/App/ErrorHandler.php @@ -21,12 +21,13 @@ * @copyright Copyright (c) 2014 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\Error; + +namespace Magento\Framework\App; /** - * Default Error Handler + * An error handler that converts runtime errors into exceptions */ -class Handler implements HandlerInterface +class ErrorHandler { /** * Error messages @@ -51,33 +52,6 @@ class Handler implements HandlerInterface E_USER_DEPRECATED => 'User Deprecated Functionality' ); - /** - * Process exception - * - * @param \Exception $exception - * @param string[] $params - * @return void - */ - public function processException(\Exception $exception, array $params = array()) - { - echo '<pre>'; - echo $exception->getMessage() . "\n\n"; - echo $exception->getTraceAsString(); - echo '</pre>'; - } - - /** - * Show error as exception - * - * @param string $errorMessage - * @return void - * @throws \Exception - */ - protected function _processError($errorMessage) - { - throw new \Exception($errorMessage); - } - /** * Custom error handler * @@ -86,6 +60,7 @@ class Handler implements HandlerInterface * @param string $errorFile * @param int $errorLine * @return bool + * @throws \Exception */ public function handler($errorNo, $errorStr, $errorFile, $errorLine) { @@ -97,23 +72,8 @@ class Handler implements HandlerInterface if ($errorNo == 0) { return false; } - - // PEAR specific message handling - if (stripos($errorFile . $errorStr, 'pear') !== false) { - // ignore strict and deprecated notices - if ($errorNo == E_STRICT || $errorNo == E_DEPRECATED) { - return true; - } - // ignore attempts to read system files when open_basedir is set - if ($errorNo == E_WARNING && stripos($errorStr, 'open_basedir') !== false) { - return true; - } - } - $errorMessage = isset( - $this->errorPhrases[$errorNo] - ) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})"; - $errorMessage .= ": {$errorStr} in {$errorFile} on line {$errorLine}"; - $this->_processError($errorMessage); - return true; + $msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})"; + $msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}"; + throw new \Exception($msg); } } diff --git a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php index 6b02df42e47..90fd518e9ac 100644 --- a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php +++ b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList/Verification.php @@ -26,7 +26,7 @@ namespace Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\State; -use Magento\Framework\BootstrapException; +use Magento\Framework\App\InitException; use Magento\Framework\App\Filesystem; use Magento\Framework\Filesystem\FilesystemException; @@ -86,7 +86,7 @@ class Verification * Create the required directories, if they don't exist, and verify write access for existing directories * * @return void - * @throws BootstrapException + * @throws InitException */ public function createAndVerifyDirectories() { @@ -108,7 +108,7 @@ class Verification if ($fails) { $dirList = implode(', ', $fails); - throw new BootstrapException("Cannot create or verify write access: {$dirList}"); + throw new InitException("Cannot create or verify write access: {$dirList}"); } } } diff --git a/lib/internal/Magento/Framework/App/Http.php b/lib/internal/Magento/Framework/App/Http.php index 042a858d312..c20801d4c1b 100644 --- a/lib/internal/Magento/Framework/App/Http.php +++ b/lib/internal/Magento/Framework/App/Http.php @@ -35,6 +35,14 @@ use Magento\Framework\Event; */ class Http implements \Magento\Framework\AppInterface { + /**#@+ + * Parameters for redirecting if the application is not installed + */ + const NOT_INSTALLED_URL_PATH_PARAM = 'MAGE_NOT_INSTALLED_URL_PATH'; + const NOT_INSTALLED_URL_PARAM = 'MAGE_NOT_INSTALLED_URL'; + const NOT_INSTALLED_URL_PATH = 'setup/'; + /**#@-*/ + /** * @var \Magento\Framework\ObjectManager */ @@ -71,7 +79,7 @@ class Http implements \Magento\Framework\AppInterface protected $_filesystem; /** - * @var Response\Http + * @var ResponseHttp */ protected $_response; @@ -112,45 +120,162 @@ class Http implements \Magento\Framework\AppInterface */ public function launch() { - try { - $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); - $this->_state->setAreaCode($areaCode); - $this->_objectManager->configure($this->_configLoader->load($areaCode)); - $this->_response = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface') - ->dispatch($this->_request); - // This event gives possibility to launch something before sending output (allow cookie setting) - $eventParams = array('request' => $this->_request, 'response' => $this->_response); - $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); - } catch (\Exception $exception) { - $message = $exception->getMessage() . "\n"; - try { - if ($this->_state->getMode() == State::MODE_DEVELOPER) { - $message .= '<pre>'; - $message .= $exception->getMessage() . "\n\n"; - $message .= $exception->getTraceAsString(); - $message .= '</pre>'; - } else { - $reportData = array($exception->getMessage(), $exception->getTraceAsString()); - // retrieve server data - if (isset($_SERVER)) { - if (isset($_SERVER['REQUEST_URI'])) { - $reportData['url'] = $_SERVER['REQUEST_URI']; - } - if (isset($_SERVER['SCRIPT_NAME'])) { - $reportData['script_name'] = $_SERVER['SCRIPT_NAME']; - } - } - require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php'; - $processor = new \Magento\Framework\Error\Processor($this->_response); - $processor->saveReport($reportData); - $this->_response = $processor->processReport(); - } - } catch (\Exception $exception) { - $message .= "Unknown error happened."; - } + $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); + $this->_state->setAreaCode($areaCode); + $this->_objectManager->configure($this->_configLoader->load($areaCode)); + $this->_response = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface') + ->dispatch($this->_request); + // This event gives possibility to launch something before sending output (allow cookie setting) + $eventParams = array('request' => $this->_request, 'response' => $this->_response); + $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); + return $this->_response; + } + + /** + * {@inheritdoc} + */ + public function catchException(Bootstrap $bootstrap, \Exception $exception) + { + $result = $this->handleDeveloperMode($bootstrap, $exception) + || $this->handleBootstrapErrors($bootstrap) + || $this->handleSessionException($bootstrap, $exception) + || $this->handleInitException($exception) + || $this->handleGenericReport($bootstrap, $exception); + return $result; + } + + /** + * Error handler for developer mode + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleDeveloperMode(Bootstrap $bootstrap, \Exception $exception) + { + if ($bootstrap->isDeveloperMode()) { $this->_response->setHttpResponseCode(500); - $this->_response->setBody($message); + $this->_response->setHeader('Content-Type', 'text/plain'); + $this->_response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString()); + $this->_response->sendResponse(); + return true; } - return $this->_response; + return false; + } + + /** + * Handler for bootstrap errors + * + * @param Bootstrap $bootstrap + * @return bool + */ + private function handleBootstrapErrors(Bootstrap $bootstrap) + { + $bootstrapCode = $bootstrap->getErrorCode(); + if (Bootstrap::ERR_MAINTENANCE == $bootstrapCode) { + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/503.php'; + return true; + } + if (Bootstrap::ERR_IS_INSTALLED == $bootstrapCode) { + $path = $this->getInstallerRedirectPath($bootstrap->getParams()); + $this->_response->setRedirect($path); + $this->_response->sendHeaders(); + return true; + } + return false; + } + + /** + * Handler for session errors + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleSessionException(Bootstrap $bootstrap, \Exception $exception) + { + if ($exception instanceof \Magento\Framework\Session\Exception) { + $path = $this->getBaseUrlPath($bootstrap->getParams()); + $this->_response->setRedirect($path); + $this->_response->sendHeaders(); + return true; + } + return false; + } + + /** + * Handler for application initialization errors + * + * @param \Exception $exception + * @return bool + */ + private function handleInitException(\Exception $exception) + { + if ($exception instanceof \Magento\Framework\App\InitException) { + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php'; + return true; + } + return false; + } + + /** + * Handle for any other errors + * + * @param Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + private function handleGenericReport(Bootstrap $bootstrap, \Exception $exception) + { + $reportData = array($exception->getMessage(), $exception->getTraceAsString()); + $params = $bootstrap->getParams(); + if (isset($params['REQUEST_URI'])) { + $reportData['url'] = $params['REQUEST_URI']; + } + if (isset($params['SCRIPT_NAME'])) { + $reportData['script_name'] = $params['SCRIPT_NAME']; + } + require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php'; + return true; + } + + /** + * Determines redirect URL when application is not installed + * + * @param array $server + * @return string + */ + public function getInstallerRedirectPath($server) + { + if (isset($server[self::NOT_INSTALLED_URL_PARAM])) { + return $server[self::NOT_INSTALLED_URL_PARAM]; + } + if (isset($server[self::NOT_INSTALLED_URL_PATH_PARAM])) { + $urlPath = $server[self::NOT_INSTALLED_URL_PATH_PARAM]; + } else { + $urlPath = self::NOT_INSTALLED_URL_PATH; + } + return $this->getBaseUrlPath($server) . $urlPath; + } + + /** + * Determines a base URL path from the environment + * + * @param string $server + * @return string + */ + private function getBaseUrlPath($server) + { + $result = ''; + if (isset($server['SCRIPT_NAME'])) { + $envPath = str_replace('\\', '/', dirname($server['SCRIPT_NAME'])); + if ($envPath != '.' && $envPath != '/') { + $result = $envPath; + } + } + if (!preg_match('/\/$/', $result)) { + $result .= '/'; + } + return $result; } } diff --git a/dev/tests/unit/testsuite/Magento/Install/App/_files/config.php b/lib/internal/Magento/Framework/App/InitException.php similarity index 69% rename from dev/tests/unit/testsuite/Magento/Install/App/_files/config.php rename to lib/internal/Magento/Framework/App/InitException.php index d4c98f15f4d..0edd0c7e09a 100644 --- a/dev/tests/unit/testsuite/Magento/Install/App/_files/config.php +++ b/lib/internal/Magento/Framework/App/InitException.php @@ -17,8 +17,16 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * + * @copyright Copyright (c) 2014 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\App; + +/** + * An exception that indicates application initialization error */ -return array('uninstall' => 1); +class InitException extends \Exception +{ +} diff --git a/lib/internal/Magento/Framework/App/MaintenanceMode.php b/lib/internal/Magento/Framework/App/MaintenanceMode.php new file mode 100644 index 00000000000..92107be0019 --- /dev/null +++ b/lib/internal/Magento/Framework/App/MaintenanceMode.php @@ -0,0 +1,140 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\App; + +use Magento\Framework\App\Filesystem; +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * Application Maintenance Mode + */ +class MaintenanceMode +{ + /** + * Maintenance flag file name + * + * DO NOT consolidate this file and the IP white list into one. + * It is going to work much faster in 99% of cases: the isOn() will return false whenever file doesn't exist. + */ + const FLAG_FILENAME = '.maintenance.flag'; + + /** + * IP-addresses file name + */ + const IP_FILENAME = '.maintenance.ip'; + + /** + * Maintenance flag dir + */ + const FLAG_DIR = Filesystem::VAR_DIR; + + /** + * Path to store files + * + * @var \Magento\Framework\Filesystem\Directory\WriteInterface + */ + protected $flagDir; + + /** + * Constructor + * + * @param \Magento\Framework\App\Filesystem $filesystem + */ + public function __construct(Filesystem $filesystem) + { + $this->flagDir = $filesystem->getDirectoryWrite(self::FLAG_DIR); + } + + /** + * Checks whether mode is on + * + * Optionally specify an IP-address to compare against the white list + * + * @param string $remoteAddr + * @return bool + */ + public function isOn($remoteAddr = '') + { + if (!$this->flagDir->isExist(self::FLAG_FILENAME)) { + return false; + } + $info = $this->getAddressInfo(); + return !in_array($remoteAddr, $info); + } + + /** + * Sets maintenance mode "on" or "off" + * + * @param bool $isOn + * @return bool + */ + public function set($isOn) + { + if ($isOn) { + return $this->flagDir->touch(self::FLAG_FILENAME); + } + if ($this->flagDir->isExist(self::FLAG_FILENAME)) { + return $this->flagDir->delete(self::FLAG_FILENAME); + } + return true; + } + + /** + * Sets list of allowed IP addresses + * + * @param string $addresses + * @return bool + * @throws \InvalidArgumentException + */ + public function setAddresses($addresses) + { + $addresses = (string)$addresses; + if (empty($addresses)) { + if ($this->flagDir->isExist(self::IP_FILENAME)) { + return $this->flagDir->delete(self::IP_FILENAME); + } + return true; + } + if (!preg_match('/^[^\s,]+(,[^\s,]+)*$/', $addresses)) { + throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n"); + } + $result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses); + return false !== $result ? true : false; + } + + /** + * Get list of IP addresses effective for maintenance mode + * + * @return string[] + */ + public function getAddressInfo() + { + if ($this->flagDir->isExist(self::IP_FILENAME)) { + $temp = $this->flagDir->readFile(self::IP_FILENAME); + return explode(',', trim($temp)); + } else { + return []; + } + } +} diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index 2d929ce6b78..e6d138d1454 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -214,7 +214,7 @@ class ObjectManagerFactory * @param mixed $argumentMapper * @param string $appMode * @return array - * @throws \Magento\Framework\BootstrapException + * @throws \Magento\Framework\App\InitException */ protected function _loadPrimaryConfig(DirectoryList $directoryList, $argumentMapper, $appMode) { @@ -239,7 +239,7 @@ class ObjectManagerFactory ); $configData = $reader->read('primary'); } catch (\Exception $e) { - throw new \Magento\Framework\BootstrapException($e->getMessage()); + throw new \Magento\Framework\App\InitException($e->getMessage(), $e->getCode(), $e); } return $configData; } diff --git a/lib/internal/Magento/Framework/App/PageCache/Version.php b/lib/internal/Magento/Framework/App/PageCache/Version.php index 55705dd2d3c..e593e82b500 100644 --- a/lib/internal/Magento/Framework/App/PageCache/Version.php +++ b/lib/internal/Magento/Framework/App/PageCache/Version.php @@ -96,7 +96,8 @@ class Version if ($this->request->isPost()) { $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() ->setDuration(self::COOKIE_PERIOD) - ->setPath('/'); + ->setPath('/') + ->setHttpOnly(false); $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $this->generateValue(), $publicCookieMetadata); } } diff --git a/lib/internal/Magento/Framework/App/Response/Http.php b/lib/internal/Magento/Framework/App/Response/Http.php index 76eeceb2411..28e5a33a17a 100644 --- a/lib/internal/Magento/Framework/App/Response/Http.php +++ b/lib/internal/Magento/Framework/App/Response/Http.php @@ -97,9 +97,9 @@ class Http extends \Zend_Controller_Response_Http implements HttpInterface if (!empty($data)) { ksort($data); $cookieValue = sha1(serialize($data)); - $publicCookMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + $sensitiveCookMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata() ->setPath('/'); - $this->cookieManager->setPublicCookie(self::COOKIE_VARY_STRING, $cookieValue, $publicCookMetadata); + $this->cookieManager->setSensitiveCookie(self::COOKIE_VARY_STRING, $cookieValue, $sensitiveCookMetadata); } else { $cookieMetadata = $this->cookieMetadataFactory->createCookieMetadata() ->setPath('/'); diff --git a/lib/internal/Magento/Framework/App/State/MaintenanceMode.php b/lib/internal/Magento/Framework/App/State/MaintenanceMode.php deleted file mode 100644 index adc1bb357a6..00000000000 --- a/lib/internal/Magento/Framework/App/State/MaintenanceMode.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\App\State; - -use Magento\Framework\App\Filesystem; - -/** - * Application Maintenance Mode - */ -class MaintenanceMode -{ - /** - * Maintenance flag name - */ - const FLAG_FILENAME = 'maintenance.flag'; - - /** - * Maintenance flag dir - */ - const FLAG_DIR = Filesystem::VAR_DIR; - - /** - * @var \Magento\Framework\App\Filesystem - */ - protected $filesystem; - - /** - * @param \Magento\Framework\App\Filesystem $filesystem - */ - public function __construct(Filesystem $filesystem) - { - $this->filesystem = $filesystem; - } - - /** - * Turn on store maintenance mode - * - * @param string $data - * @return bool - */ - public function turnOn($data = 'maintenance') - { - try { - $this->filesystem->getDirectoryWrite(self::FLAG_DIR) - ->writeFile(self::FLAG_FILENAME, $data); - } catch (\Exception $e) { - return false; - } - return true; - } - - /** - * Turn off store maintenance mode - * - * @return bool - */ - public function turnOff() - { - try { - $this->filesystem->getDirectoryWrite(self::FLAG_DIR)->delete(self::FLAG_FILENAME); - } catch (\Exception $e) { - return false; - } - return true; - } -} diff --git a/lib/internal/Magento/Framework/App/StaticResource.php b/lib/internal/Magento/Framework/App/StaticResource.php index 3b4999e4dd8..c22c0f71910 100644 --- a/lib/internal/Magento/Framework/App/StaticResource.php +++ b/lib/internal/Magento/Framework/App/StaticResource.php @@ -26,6 +26,7 @@ namespace Magento\Framework\App; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Request; use Magento\Framework\App\Response; +use Magento\Framework\App; /** * Entry point for retrieving static resources like JS, CSS, images by requested public path @@ -40,7 +41,7 @@ class StaticResource implements \Magento\Framework\AppInterface private $state; /** - * @var Response\FileInterface + * @var \Magento\Framework\App\Response\FileInterface */ private $response; @@ -116,26 +117,33 @@ class StaticResource implements \Magento\Framework\AppInterface if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); } else { - try { - $path = $this->request->get('resource'); - $params = $this->parsePath($path); - $this->state->setAreaCode($params['area']); - $this->objectManager->configure($this->configLoader->load($params['area'])); - $file = $params['file']; - unset($params['file']); - $asset = $this->assetRepo->createAsset($file, $params); - $this->response->setFilePath($asset->getSourceFile()); - $this->publisher->publish($asset); - } catch (\Exception $e) { - if ($appMode == \Magento\Framework\App\State::MODE_DEVELOPER) { - throw $e; - } - $this->response->setHttpResponseCode(404); - } + $path = $this->request->get('resource'); + $params = $this->parsePath($path); + $this->state->setAreaCode($params['area']); + $this->objectManager->configure($this->configLoader->load($params['area'])); + $file = $params['file']; + unset($params['file']); + $asset = $this->assetRepo->createAsset($file, $params); + $this->response->setFilePath($asset->getSourceFile()); + $this->publisher->publish($asset); } return $this->response; } + /** + * {@inheritdoc} + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception) + { + $this->response->setHttpResponseCode(404); + $this->response->setHeader('Content-Type', 'text/plain'); + if ($bootstrap->isDeveloperMode()) { + $this->response->setBody($exception->getMessage() . "\n" . $exception->getTraceAsString()); + } + $this->response->sendResponse(); + return true; + } + /** * Parse path to identify parts needed for searching original file * diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index 9a1447c397e..6acd25180d6 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-alpha94'; + const VERSION = '0.1.0-alpha95'; /** * Launch application @@ -43,4 +43,17 @@ interface AppInterface * @return \Magento\Framework\App\ResponseInterface */ public function launch(); + + /** + * Ability to handle exceptions that may have occurred during bootstrap and launch + * + * Return values: + * - true: exception has been handled, no additional action is needed + * - false: exception has not been handled - pass the control to Bootstrap + * + * @param App\Bootstrap $bootstrap + * @param \Exception $exception + * @return bool + */ + public function catchException(App\Bootstrap $bootstrap, \Exception $exception); } diff --git a/lib/internal/Magento/Framework/BootstrapException.php b/lib/internal/Magento/Framework/BootstrapException.php deleted file mode 100644 index cd37ed0e063..00000000000 --- a/lib/internal/Magento/Framework/BootstrapException.php +++ /dev/null @@ -1,33 +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) - */ - -/** - * Error of not fulfilling basic requirements necessary for the application bootstrap. - * \Exception handling should not rely on any part of the application because it has not been initialized yet. - */ -namespace Magento\Framework; - -class BootstrapException extends \Magento\Framework\Exception -{ -} diff --git a/lib/internal/Magento/Framework/DB/Select.php b/lib/internal/Magento/Framework/DB/Select.php index a7c26c5682c..ca7232661d6 100644 --- a/lib/internal/Magento/Framework/DB/Select.php +++ b/lib/internal/Magento/Framework/DB/Select.php @@ -28,8 +28,6 @@ use Magento\Framework\DB\Adapter\AdapterInterface; /** * Class for SQL SELECT generation and results. * - * @method \Magento\Framework\DB\Adapter\AdapterInterface|Zend_Db_Adapter_Abstract getAdapter() - * @property \Magento\Framework\DB\Adapter\AdapterInterface|Zend_Db_Adapter_Abstract $_adapter * @method \Magento\Framework\DB\Select from($name, $cols = '*', $schema = null) * @method \Magento\Framework\DB\Select join($name, $cond, $cols = '*', $schema = null) * @method \Magento\Framework\DB\Select joinInner($name, $cond, $cols = '*', $schema = null) @@ -66,6 +64,36 @@ class Select extends \Zend_Db_Select */ const SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN'; + /** + * FULLTEXT search in MySQL search mode "natural language" + */ + const FULLTEXT_MODE_NATURAL = 'IN NATURAL LANGUAGE MODE'; + + /** + * FULLTEXT search in MySQL search mode "natural language with query expansion" + */ + const FULLTEXT_MODE_NATURAL_QUERY = 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION'; + + /** + * FULLTEXT search in MySQL search mode "boolean" + */ + const FULLTEXT_MODE_BOOLEAN = 'IN BOOLEAN MODE'; + + /** + * FULLTEXT search in MySQL search mode "query expansion" + */ + const FULLTEXT_MODE_QUERY = 'WITH QUERY EXPANSION'; + + /** + * FULLTEXT search in MySQL MATCH method + */ + const MATCH = 'MATCH'; + + /** + * FULLTEXT search in MySQL AGAINST method + */ + const AGAINST = 'AGAINST'; + /** * Class constructor * Add straight join support @@ -121,12 +149,55 @@ class Select extends \Zend_Db_Select $type = null; } if (is_array($value)) { - $cond = $this->_adapter->quoteInto($cond, $value); + $cond = $this->getAdapter()->quoteInto($cond, $value); $value = null; } return parent::where($cond, $value, $type); } + /** + * Method for FULLTEXT search in Mysql, will generated MATCH ($columns) AGAINST ('$expression' $mode) + * + * @param string|string[] $columns Columns which add to MATCH () + * @param string $expression Expression which add to AGAINST () + * @param string $mode + * @return string + */ + public function getMatchQuery($columns, $expression, $mode = self::FULLTEXT_MODE_NATURAL) + { + if (is_array($columns)) { + $columns = implode(', ', $columns); + } + + $expression = $this->getAdapter()->quote($expression); + + $condition = self::MATCH . " ({$columns}) " . self::AGAINST . " ({$expression} {$mode})"; + return $condition; + } + + /** + * Method for FULLTEXT search in Mysql, will added generated + * MATCH ($columns) AGAINST ('$expression' $mode) to where clause + * + * @param string|string[] $columns Columns which add to MATCH () + * @param string $expression Expression which add to AGAINST () + * @param bool $isCondition true=AND, false=OR + * @param string $mode + * @return $this + */ + public function match($columns, $expression, $isCondition = true, $mode = self::FULLTEXT_MODE_NATURAL) + { + $fullCondition = $this->getMatchQuery($columns, $expression, $mode); + + if ($isCondition) { + $this->where($fullCondition); + } else { + $this->orWhere($fullCondition); + } + + return $this; + } + /** * Reset unused LEFT JOIN(s) * diff --git a/lib/internal/Magento/Framework/Event/Config/Data.php b/lib/internal/Magento/Framework/Event/Config/Data.php index 13733d86d43..f22612ba5f2 100644 --- a/lib/internal/Magento/Framework/Event/Config/Data.php +++ b/lib/internal/Magento/Framework/Event/Config/Data.php @@ -34,45 +34,18 @@ class Data extends \Magento\Framework\Config\Data\Scoped */ protected $_scopePriorityScheme = array('global'); - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @param \Magento\Framework\Event\Config\Reader $reader * @param \Magento\Framework\Config\ScopeInterface $configScope * @param \Magento\Framework\Config\CacheInterface $cache - * @param \Magento\Framework\App\State $appState * @param string $cacheId */ public function __construct( \Magento\Framework\Event\Config\Reader $reader, \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Framework\Config\CacheInterface $cache, - \Magento\Framework\App\State $appState, $cacheId = 'event_config_cache' ) { - $this->_appState = $appState; parent::__construct($reader, $configScope, $cache, $cacheId); } - - /** - * Get config value by key - * - * @param null|string $path - * @param null|mixed $default - * @return null|mixed - */ - public function get($path = null, $default = null) - { - if (!$this->_appState->isInstalled() && !in_array( - $this->_configScope->getCurrentScope(), - array('global', 'install') - ) - ) { - return $default; - } - return parent::get($path, $default); - } } diff --git a/dev/tests/unit/testsuite/Magento/_files/errors/report.php b/lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php similarity index 72% rename from dev/tests/unit/testsuite/Magento/_files/errors/report.php rename to lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php index 2c5136b1fbc..f4ee9f7e5ee 100644 --- a/dev/tests/unit/testsuite/Magento/_files/errors/report.php +++ b/lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php @@ -18,9 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 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\Filter; -/** @var $reportData array */ -\Magento\Framework\App\Error\HandlerTest::assertNotEmpty($reportData); +class LocalizedToNormalized extends \Zend_Filter_LocalizedToNormalized +{ + +} diff --git a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php index b81ba96350b..68def390817 100644 --- a/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php +++ b/lib/internal/Magento/Framework/Less/PreProcessor/Instruction/MagentoImport.php @@ -61,29 +61,29 @@ class MagentoImport implements PreProcessorInterface protected $assetRepo; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - protected $themeProvider; + protected $themeList; /** * @param DesignInterface $design * @param CollectorInterface $fileSource * @param ErrorHandlerInterface $errorHandler * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList */ public function __construct( DesignInterface $design, CollectorInterface $fileSource, ErrorHandlerInterface $errorHandler, \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Framework\View\Design\Theme\Provider $themeProvider + \Magento\Framework\View\Design\Theme\ListInterface $themeList ) { $this->design = $design; $this->fileSource = $fileSource; $this->errorHandler = $errorHandler; $this->assetRepo = $assetRepo; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; } /** @@ -135,7 +135,7 @@ class MagentoImport implements PreProcessorInterface { $context = $asset->getContext(); if ($context instanceof FallbackContext) { - return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); + return $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); } return $this->design->getDesignTheme(); } diff --git a/lib/internal/Magento/Framework/Locale/Lists.php b/lib/internal/Magento/Framework/Locale/Lists.php index 6fc19cce6fb..14ccdd46be1 100644 --- a/lib/internal/Magento/Framework/Locale/Lists.php +++ b/lib/internal/Magento/Framework/Locale/Lists.php @@ -25,11 +25,6 @@ namespace Magento\Framework\Locale; class Lists implements \Magento\Framework\Locale\ListsInterface { - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\ScopeResolverInterface */ @@ -46,20 +41,17 @@ class Lists implements \Magento\Framework\Locale\ListsInterface protected $_localeResolver; /** - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param \Magento\Framework\Locale\ConfigInterface $config * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param string $locale */ public function __construct( - \Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, \Magento\Framework\Locale\ConfigInterface $config, \Magento\Framework\Locale\ResolverInterface $localeResolver, $locale = null ) { - $this->_appState = $appState; $this->_scopeResolver = $scopeResolver; $this->_config = $config; $this->_localeResolver = $localeResolver; @@ -181,7 +173,7 @@ class Lists implements \Magento\Framework\Locale\ListsInterface { $currencies = $this->getTranslationList('currencytoname'); $options = array(); - $allowed = $this->_getAllowedCurrencies(); + $allowed = $this->_config->getAllowedCurrencies(); foreach ($currencies as $name => $code) { if (!in_array($code, $allowed)) { @@ -193,21 +185,6 @@ class Lists implements \Magento\Framework\Locale\ListsInterface return $this->_sortOptionArray($options); } - /** - * Retrieve array of allowed currencies - * - * @return array - */ - protected function _getAllowedCurrencies() - { - if ($this->_appState->isInstalled()) { - $allowed = $this->_scopeResolver->getScope()->getAllowedCurrencies(); - } else { - $allowed = $this->_config->getAllowedCurrencies(); - } - return $allowed; - } - /** * @inheritdoc */ diff --git a/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php b/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php index 6c60c93ee92..bbb3cd229d0 100644 --- a/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Module/Declaration/Reader/Filesystem.php @@ -30,7 +30,6 @@ use Magento\Framework\Module\Declaration\Converter\Dom; use Magento\Framework\Module\Declaration\SchemaLocator; use Magento\Framework\Module\DependencyManagerInterface; use Magento\Framework\Config\ValidationStateInterface; -use Magento\Framework\App\State; class Filesystem extends \Magento\Framework\Config\Reader\Filesystem { @@ -45,11 +44,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem */ protected $_allowedModules; - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - /** * @var \Magento\Framework\Module\DependencyManagerInterface */ @@ -70,7 +64,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem * @param Dom $converter * @param SchemaLocator $schemaLocator * @param ValidationStateInterface $validationState - * @param State $appState * @param DependencyManagerInterface $dependencyManager * @param string $fileName * @param array $idAttributes @@ -83,7 +76,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem Dom $converter, SchemaLocator $schemaLocator, ValidationStateInterface $validationState, - State $appState, DependencyManagerInterface $dependencyManager, $fileName = 'module.xml', $idAttributes = array(), @@ -102,7 +94,6 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem $defaultScope ); $this->_allowedModules = $allowedModules; - $this->appState = $appState; $this->dependencyManager = $dependencyManager; } @@ -112,11 +103,8 @@ class Filesystem extends \Magento\Framework\Config\Reader\Filesystem public function read($scope = null) { $activeModules = $this->_filterActiveModules(parent::read($scope)); - - if ($this->appState->isInstalled()) { - foreach ($activeModules as $moduleConfig) { - $this->dependencyManager->checkModuleDependencies($moduleConfig, $activeModules); - } + foreach ($activeModules as $moduleConfig) { + $this->dependencyManager->checkModuleDependencies($moduleConfig, $activeModules); } return $this->_sortModules($activeModules); } diff --git a/app/code/Magento/Store/Model/Exception.php b/lib/internal/Magento/Framework/Module/Exception.php similarity index 88% rename from app/code/Magento/Store/Model/Exception.php rename to lib/internal/Magento/Framework/Module/Exception.php index 60415d42c81..b8e7c64b64e 100644 --- a/app/code/Magento/Store/Model/Exception.php +++ b/lib/internal/Magento/Framework/Module/Exception.php @@ -22,11 +22,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Store exception - */ -namespace Magento\Store\Model; -class Exception extends \Magento\Framework\Model\Exception +namespace Magento\Framework\Module; + + +class Exception extends \Exception { } diff --git a/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php b/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php deleted file mode 100644 index 814091521e7..00000000000 --- a/lib/internal/Magento/Framework/Module/FrontController/Plugin/Install.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -/** - * Application installation plugin. Should be used by applications that require module install/upgrade. - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 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\Module\FrontController\Plugin; - -use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Module\UpdaterInterface; -use Magento\Framework\App\State; - -class Install -{ - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - - /** - * @var FrontendInterface - */ - protected $_cache; - - /** - * @var UpdaterInterface - */ - protected $_updater; - - /** - * @param State $appState - * @param FrontendInterface $cache - * @param UpdaterInterface $dbUpdater - */ - public function __construct(State $appState, FrontendInterface $cache, UpdaterInterface $dbUpdater) - { - $this->_appState = $appState; - $this->_cache = $cache; - $this->_dbUpdater = $dbUpdater; - } - - /** - * @param \Magento\Framework\App\FrontController $subject - * @param callable $proceed - * @param \Magento\Framework\App\RequestInterface $request - * - * @return \Magento\Framework\App\ResponseInterface - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function aroundDispatch( - \Magento\Framework\App\FrontController $subject, - \Closure $proceed, - \Magento\Framework\App\RequestInterface $request - ) { - if ($this->_appState->isInstalled() && !$this->_cache->load('data_upgrade')) { - $this->_dbUpdater->updateScheme(); - $this->_dbUpdater->updateData(); - $this->_cache->save('true', 'data_upgrade'); - } - return $proceed($request); - } -} diff --git a/lib/internal/Magento/Framework/Module/Manager.php b/lib/internal/Magento/Framework/Module/Manager.php index 92149b13172..f1f19465e74 100644 --- a/lib/internal/Magento/Framework/Module/Manager.php +++ b/lib/internal/Magento/Framework/Module/Manager.php @@ -27,10 +27,12 @@ */ namespace Magento\Framework\Module; +use \Magento\Framework\Module\Updater\SetupInterface; + class Manager { /** - * @var ConfigInterface + * @var Output\ConfigInterface */ private $_outputConfig; @@ -44,19 +46,27 @@ class Manager */ private $_outputConfigPaths; + /** + * @var ResourceInterface + */ + private $_moduleResource; + /** * @param Output\ConfigInterface $outputConfig * @param ModuleListInterface $moduleList + * @param ResourceInterface $moduleResource * @param array $outputConfigPaths */ public function __construct( Output\ConfigInterface $outputConfig, ModuleListInterface $moduleList, + ResourceInterface $moduleResource, array $outputConfigPaths = array() ) { $this->_outputConfig = $outputConfig; $this->_moduleList = $moduleList; $this->_outputConfigPaths = $outputConfigPaths; + $this->_moduleResource = $moduleResource; } /** @@ -107,4 +117,47 @@ class Manager } return true; } + + /** + * Check if DB schema is up to date + * + * @param string $moduleName + * @param string $resourceName + * @return bool + */ + public function isDbSchemaUpToDate($moduleName, $resourceName) + { + $dbVer = $this->_moduleResource->getDbVersion($resourceName); + return $this->isModuleVersionEqual($moduleName, $dbVer); + } + + /** + * @param string $moduleName + * @param string $resourceName + * @return bool + */ + public function isDbDataUpToDate($moduleName, $resourceName) + { + $dataVer = $this->_moduleResource->getDataVersion($resourceName); + return $this->isModuleVersionEqual($moduleName, $dataVer); + } + + /** + * Check if DB data is up to date + * + * @param string $moduleName + * @param string|bool $version + * @return bool + * @throws \UnexpectedValueException + */ + private function isModuleVersionEqual($moduleName, $version) + { + $module = $this->_moduleList->getModule($moduleName); + if (empty($module['schema_version'])) { + throw new \UnexpectedValueException("Schema version for module '$moduleName' is not specified"); + } + $configVer = $module['schema_version']; + + return ($version !== false && version_compare($configVer, $version) === SetupInterface::VERSION_COMPARE_EQUAL); + } } diff --git a/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php b/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php new file mode 100644 index 00000000000..a837f4dc1dc --- /dev/null +++ b/lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php @@ -0,0 +1,116 @@ +<?php +/** + * Validation of DB up to date state + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 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\Module\Plugin; + +use Magento\Framework\Cache\FrontendInterface; +use Magento\Framework\Module\Updater; +use Magento\Framework\App\State; + +class DbStatusValidator +{ + /** + * @var FrontendInterface + */ + private $cache; + + /** + * @var \Magento\Framework\Module\ModuleListInterface + */ + private $moduleList; + + /** + * @var \Magento\Framework\Module\ResourceResolverInterface + */ + private $resourceResolver; + + /** + * @var \Magento\Framework\Module\Manager + */ + private $moduleManager; + + /** + * @param FrontendInterface $cache + * @param \Magento\Framework\Module\ModuleListInterface $moduleList + * @param \Magento\Framework\Module\ResourceResolverInterface $resourceResolver + * @param \Magento\Framework\Module\Manager $moduleManager + */ + public function __construct( + FrontendInterface $cache, + \Magento\Framework\Module\ModuleListInterface $moduleList, + \Magento\Framework\Module\ResourceResolverInterface $resourceResolver, + \Magento\Framework\Module\Manager $moduleManager + ) { + $this->cache = $cache; + $this->moduleList = $moduleList; + $this->resourceResolver = $resourceResolver; + $this->moduleManager = $moduleManager; + } + + /** + * @param \Magento\Framework\App\FrontController $subject + * @param \Closure $proceed + * @param \Magento\Framework\App\RequestInterface $request + * + * @throws \Magento\Framework\Module\Exception + * @return \Magento\Framework\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundDispatch( + \Magento\Framework\App\FrontController $subject, + \Closure $proceed, + \Magento\Framework\App\RequestInterface $request + ) { + if (!$this->cache->load('db_is_up_to_date')) { + if (!$this->isDbUpToDate()) { + throw new \Magento\Framework\Module\Exception( + 'Looks like database is outdated. Please, use setup tool to perform update' + ); + } else { + $this->cache->save('true', 'db_is_up_to_date'); + } + } + return $proceed($request); + } + + /** + * Check if DB is up to date + * + * @return bool + */ + private function isDbUpToDate() + { + foreach (array_keys($this->moduleList->getModules()) as $moduleName) { + foreach ($this->resourceResolver->getResourceList($moduleName) as $resourceName) { + $isSchemaUpToDate = $this->moduleManager->isDbSchemaUpToDate($moduleName, $resourceName); + $isDataUpToDate = $this->moduleManager->isDbDataUpToDate($moduleName, $resourceName); + if (!$isSchemaUpToDate || !$isDataUpToDate) { + return false; + } + } + } + return true; + } +} diff --git a/lib/internal/Magento/Framework/Module/Updater.php b/lib/internal/Magento/Framework/Module/Updater.php index b7d40cdba08..bc19c5b7ee5 100644 --- a/lib/internal/Magento/Framework/Module/Updater.php +++ b/lib/internal/Magento/Framework/Module/Updater.php @@ -26,17 +26,9 @@ namespace Magento\Framework\Module; use Magento\Framework\App\State; -use Magento\Framework\Module\Updater\SetupFactory; -class Updater implements \Magento\Framework\Module\UpdaterInterface +class Updater { - /** - * Setup model factory - * - * @var SetupFactory - */ - protected $_factory; - /** * Flag which allow run data install/upgrade * @@ -51,20 +43,6 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ protected $_appState; - /** - * If it set to true, we will ignore applying scheme updates - * - * @var bool - */ - protected $_skipModuleUpdate; - - /** - * Map that contains setup model names per resource name - * - * @var array - */ - protected $_resourceList; - /** * @var ModuleListInterface */ @@ -80,39 +58,30 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ protected $_setupFactory; + /** + * @var \Magento\Framework\Module\Manager + */ + private $_moduleManager; + /** * @param Updater\SetupFactory $setupFactory * @param State $appState * @param ModuleListInterface $moduleList * @param ResourceResolverInterface $resourceResolver - * @param bool $skipModuleUpdate + * @param Manager $moduleManager */ public function __construct( Updater\SetupFactory $setupFactory, State $appState, ModuleListInterface $moduleList, ResourceResolverInterface $resourceResolver, - $skipModuleUpdate = false + \Magento\Framework\Module\Manager $moduleManager ) { $this->_appState = $appState; $this->_moduleList = $moduleList; $this->_resourceResolver = $resourceResolver; $this->_setupFactory = $setupFactory; - $this->_skipModuleUpdate = $skipModuleUpdate; - } - - /** - * Check whether modules updates processing should be skipped - * - * @return bool - */ - protected function _shouldSkipProcessModulesUpdates() - { - if (!$this->_appState->isInstalled()) { - return false; - } - - return $this->_skipModuleUpdate; + $this->_moduleManager = $moduleManager; } /** @@ -122,21 +91,19 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ public function updateScheme() { - if ($this->_shouldSkipProcessModulesUpdates()) { - return; - } - \Magento\Framework\Profiler::start('apply_db_schema_updates'); $this->_appState->setUpdateMode(true); $afterApplyUpdates = array(); foreach (array_keys($this->_moduleList->getModules()) as $moduleName) { foreach ($this->_resourceResolver->getResourceList($moduleName) as $resourceName) { - $setup = $this->_setupFactory->create($resourceName, $moduleName); - $setup->applyUpdates(); + if (!$this->_moduleManager->isDbSchemaUpToDate($moduleName, $resourceName)) { + $setup = $this->_setupFactory->create($resourceName, $moduleName); + $setup->applyUpdates(); - if ($setup->getCallAfterApplyAllUpdates()) { - $afterApplyUpdates[] = $setup; + if ($setup->getCallAfterApplyAllUpdates()) { + $afterApplyUpdates[] = $setup; + } } } } @@ -158,12 +125,11 @@ class Updater implements \Magento\Framework\Module\UpdaterInterface */ public function updateData() { - if (!$this->_isUpdatedSchema) { - return; - } foreach (array_keys($this->_moduleList->getModules()) as $moduleName) { foreach ($this->_resourceResolver->getResourceList($moduleName) as $resourceName) { - $this->_setupFactory->create($resourceName, $moduleName)->applyDataUpdates(); + if (!$this->_moduleManager->isDbDataUpToDate($moduleName, $resourceName)) { + $this->_setupFactory->create($resourceName, $moduleName)->applyDataUpdates(); + } } } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php b/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.php new file mode 100644 index 00000000000..003e5727252 --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Helper/Composite.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\Framework\ObjectManager\Helper; + +/** + * Helper for classes which implement Composite pattern. + */ +class Composite +{ + /** + * @param array $declaredComponents Array of the components which should be registered in the following format: + * <pre> + * [ + * ['type' => $firstComponentObject, 'sortOrder' => 15], + * ['type' => $secondComponentObject, 'sortOrder' => 10], + * ... + * ] + * </pre> + * @return array Array of components declarations. Items are sorted and misconfigured ones are removed. + */ + public function filterAndSortDeclaredComponents($declaredComponents) + { + /** Eliminate misconfigured components */ + $declaredComponents = array_filter( + $declaredComponents, + function ($component) { + return (isset($component['type']) && isset($component['sortOrder'])); + } + ); + /** Sort all components according to the provided sort order */ + uasort( + $declaredComponents, + function ($firstComponent, $secondComponent) { + $firstComponentSortOrder = (int)$firstComponent['sortOrder']; + $secondComponentSortOrder = (int)$secondComponent['sortOrder']; + if ($firstComponentSortOrder == $secondComponentSortOrder) { + return 0; + } else if ($firstComponentSortOrder < $secondComponentSortOrder) { + return -1; + } else { + return 1; + } + } + ); + $declaredComponents = array_values($declaredComponents); + return $declaredComponents; + } +} diff --git a/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php b/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.php new file mode 100644 index 00000000000..a93d6f7c690 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/AbstractKeyValuePair.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\Framework\Search; + +class AbstractKeyValuePair +{ + /** + * Field name + * + * @var string + */ + protected $name; + + /** + * Field values + * + * @var mixed + */ + protected $value; + + /** + * @param string $name + * @param mixed $value + */ + public function __construct($name, $value) + { + $this->name = $name; + $this->value = $value; + } + + /** + * Get field name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get field values + * + * @return array + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php index 0f39d132f71..8af39b9b05a 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php @@ -1,7 +1,5 @@ <?php /** - * MySQL Search Adapter - * * Magento * * NOTICE OF LICENSE @@ -25,9 +23,14 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; -use Magento\Framework\Search\AdapterInterface; +use Magento\Framework\App\Resource; +use Magento\Framework\DB\Select; use Magento\Framework\Search\RequestInterface; +use Magento\Framework\Search\AdapterInterface; +/** + * MySQL Search Adapter + */ class Adapter implements AdapterInterface { /** @@ -44,16 +47,24 @@ class Adapter implements AdapterInterface */ protected $responseFactory; + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + /** * @param Mapper $mapper * @param ResponseFactory $responseFactory + * @param \Magento\Framework\App\Resource $resource */ public function __construct( Mapper $mapper, - ResponseFactory $responseFactory + ResponseFactory $responseFactory, + Resource $resource ) { $this->mapper = $mapper; $this->responseFactory = $responseFactory; + $this->resource = $resource; } /** @@ -61,17 +72,40 @@ class Adapter implements AdapterInterface */ public function query(RequestInterface $request) { + /** @var Select $query */ $query = $this->mapper->buildQuery($request); - $response = $this->executeQuery($query); + $response = [ + 'documents' => $this->executeDocuments($query), + 'aggregations' => $this->executeAggregations($query), + ]; return $this->responseFactory->create($response); } /** * Executes query and return raw response + * @param Select $select * - * @return mixed + * @return array + */ + private function executeDocuments(Select $select) + { + return $this->getConnection()->fetchAssoc($select); + } + + /** + * @param Select $select + * @return array + */ + private function executeAggregations(Select $select) + { + return []; + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface */ - private function executeQuery() + private function getConnection() { + return $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php index 855cc50bf85..5c3f84a7612 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php @@ -1,7 +1,5 @@ <?php /** - * Aggregation Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +/** + * Aggregation Factory + */ class AggregationFactory { /** @@ -62,6 +63,6 @@ class AggregationFactory ] ); } - return $this->objectManager->create('\Magento\Framework\Search\Aggregation', $buckets); + return $this->objectManager->create('\Magento\Framework\Search\Aggregation', ['buckets' => $buckets]); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.php new file mode 100644 index 00000000000..520975451b3 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Dimensions.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\Search\Adapter\Mysql; + +use Magento\Framework\App\ScopeResolverInterface; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Search\Request\Dimension; + +class Dimensions +{ + const DEFAULT_DIMENSION_NAME = 'scope'; + + const STORE_FIELD_NAME = 'store_id'; + + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + /** + * @var ScopeResolverInterface + */ + private $scopeResolver; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param ScopeResolverInterface $scopeResolver + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + ScopeResolverInterface $scopeResolver + ) { + $this->resource = $resource; + $this->scopeResolver = $scopeResolver; + } + + /** + * @param Dimension $dimension + * @return string + */ + public function build(Dimension $dimension) + { + /** @var AdapterInterface $adapter */ + $adapter = $this->resource->getConnection(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE); + + return $this->generateExpression($dimension, $adapter); + } + + /** + * @param Dimension $dimension + * @param AdapterInterface $adapter + * @return string + */ + private function generateExpression(Dimension $dimension, AdapterInterface $adapter) + { + $identifier = $dimension->getName(); + $value = $dimension->getValue(); + + if (self::DEFAULT_DIMENSION_NAME === $identifier) { + $identifier = self::STORE_FIELD_NAME; + $value = $this->scopeResolver->getScope($value)->getId(); + } + + return sprintf( + '%s = %s', + $adapter->quoteIdentifier($identifier), + $adapter->quote($value) + ); + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php index 5d28d026424..c8d2d27fef0 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php @@ -1,7 +1,5 @@ <?php /** - * Response Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +/** + * Document Factory + */ class DocumentFactory { /** @@ -33,14 +34,21 @@ class DocumentFactory * @var \Magento\Framework\ObjectManager */ protected $objectManager; + /** + * @var \Magento\Framework\Search\EntityMetadata + */ + private $entityId; /** * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Framework\Search\EntityMetadata $entityId */ public function __construct( - \Magento\Framework\ObjectManager $objectManager + \Magento\Framework\ObjectManager $objectManager, + \Magento\Framework\Search\EntityMetadata $entityId ) { $this->objectManager = $objectManager; + $this->entityId = $entityId; } /** @@ -51,17 +59,20 @@ class DocumentFactory */ public function create($rawDocument) { - $fields = array(); + /** @var \Magento\Framework\Search\DocumentField[] $fields */ + $fields = []; + $documentId = null; + $entityId = $this->entityId->getEntityId(); foreach ($rawDocument as $rawField) { - /** @var \Magento\Framework\Search\DocumentField[] $fields */ - $fields[] = $this->objectManager->create( - '\Magento\Framework\Search\DocumentField', - [ - $rawField['name'], - $rawField['values'] - ] - ); + if ($rawField['name'] == $entityId) { + $documentId = $rawField['value']; + } else { + $fields[] = $this->objectManager->create('\Magento\Framework\Search\DocumentField', $rawField); + } } - return $this->objectManager->create('\Magento\Framework\Search\Document', $fields); + return $this->objectManager->create( + '\Magento\Framework\Search\Document', + ['documentFields' => $fields, 'documentId' => $documentId] + ); } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php new file mode 100644 index 00000000000..117849c1af6 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.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\Framework\Search\Adapter\Mysql\Filter; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Range; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder\Term; +use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; + +class Builder implements BuilderInterface +{ + /** + * @var Range + */ + private $range; + /** + * @var Term + */ + private $term; + + /** + * @param Range $range + * @param Term $term + */ + public function __construct( + Range $range, + Term $term + ) { + $this->range = $range; + $this->term = $term; + } + + /** + * {@inheritdoc} + */ + public function build(RequestFilterInterface $filter) + { + switch ($filter->getType()) { + case RequestFilterInterface::TYPE_BOOL: + /** @var \Magento\Framework\Search\Request\Filter\Bool $filter */ + $queries = []; + $must = $this->buildFilters($filter->getMust(), Select::SQL_AND); + if (!empty($must)) { + $queries[] = $must; + } + $should = $this->buildFilters($filter->getShould(), Select::SQL_OR); + if (!empty($should)) { + $queries[] = $this->wrapBrackets($should); + } + $mustNot = $this->buildFilters($filter->getMustNot(), Select::SQL_AND); + if (!empty($mustNot)) { + $queries[] = '!' . $this->wrapBrackets($mustNot); + } + $query = $this->generateQuery($queries, Select::SQL_AND); + break; + case RequestFilterInterface::TYPE_TERM: + /** @var \Magento\Framework\Search\Request\Filter\Term $filter */ + $query = $this->term->buildFilter($filter); + break; + case RequestFilterInterface::TYPE_RANGE: + /** @var \Magento\Framework\Search\Request\Filter\Range $filter */ + $query = $this->range->buildFilter($filter); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown filter type \'%s\'', $filter->getType())); + } + return $this->wrapBrackets($query); + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface[] $filters + * @param string $unionOperator + * @return string + */ + private function buildFilters(array $filters, $unionOperator) + { + $queries = []; + foreach ($filters as $filter) { + $queries[] = $this->build($filter); + } + return $this->generateQuery($queries, $unionOperator); + } + + /** + * @param string[] $queries + * @param string $unionOperator + * @return string + */ + private function generateQuery(array $queries, $unionOperator) + { + $query = implode( + ' ' . $unionOperator . ' ', + $queries + ); + return $query; + } + + /** + * @param string $query + * @return string + */ + private function wrapBrackets($query) + { + return empty($query) + ? $query + : '(' . $query . ')'; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php new file mode 100644 index 00000000000..aa987061745 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php @@ -0,0 +1,35 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +interface FilterInterface +{ + /** + * @param \Magento\Framework\Search\Request\FilterInterface $filter + * @return \Magento\Framework\DB\Select + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ); +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php new file mode 100644 index 00000000000..19637d02d64 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.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\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\Framework\App\Resource; +use Magento\Framework\DB\Adapter\AdapterInterface; + +class Range implements FilterInterface +{ + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @param \Magento\Framework\App\Resource $resource + */ + public function __construct(\Magento\Framework\App\Resource $resource) + { + $this->resource = $resource; + } + + /** + * @param \Magento\Framework\Search\Request\FilterInterface $filter + * @return \Magento\Framework\DB\Select + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ) { + $adapter = $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); + /** @var \Magento\Framework\Search\Request\Filter\Range $filter */ + return $this->generateCondition($filter->getField(), $filter->getFrom(), $filter->getTo(), $adapter); + } + + private function generateCondition($field, $from, $to, AdapterInterface $adapter) + { + $hasFromValue = !is_null($from); + $hasToValue = !is_null($to); + + $condition = ''; + + if ($hasFromValue and $hasToValue) { + $condition = sprintf( + '%s >= %s %s %s < %s', + $field, + $adapter->quote($from), + \Zend_Db_Select::SQL_AND, + $field, + $adapter->quote($to) + ); + } elseif ($hasFromValue and !$hasToValue) { + $condition = sprintf( + '%s >= %s', + $field, + $adapter->quote($from) + ); + } elseif (!$hasFromValue and $hasToValue) { + $condition = sprintf( + '%s < %s', + $field, + $adapter->quote($to) + ); + } + return $condition; + } +} diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php new file mode 100644 index 00000000000..940e4aef6b4 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Filter\Builder; + +use Magento\Framework\App\Resource; + +class Term implements FilterInterface +{ + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @param \Magento\Framework\App\Resource $resource + */ + public function __construct(\Magento\Framework\App\Resource $resource) + { + $this->resource = $resource; + } + + /** + * {@inheritdoc} + */ + public function buildFilter( + \Magento\Framework\Search\Request\FilterInterface $filter + ) { + $adapter = $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE); + + /** @var \Magento\Framework\Search\Request\Filter\Term $filter */ + $condition = sprintf( + '%s = %s', + $filter->getField(), + $adapter->quote($filter->getValue()) + ); + return $condition; + } +} diff --git a/lib/internal/Magento/Framework/App/EntryPointInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php similarity index 76% rename from lib/internal/Magento/Framework/App/EntryPointInterface.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php index 83c57a3b99b..1b21f97e170 100644 --- a/lib/internal/Magento/Framework/App/EntryPointInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php @@ -1,7 +1,5 @@ <?php /** - * Application entry point. Bootstraps and runs application - * * Magento * * NOTICE OF LICENSE @@ -23,14 +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\Framework\App; +namespace Magento\Framework\Search\Adapter\Mysql\Filter; + +use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; -interface EntryPointInterface +interface BuilderInterface { /** - * @param string $applicationName - * @param array $arguments - * @return void + * @param RequestFilterInterface $filter + * @return string */ - public function run($applicationName, array $arguments = array()); + public function build(RequestFilterInterface $filter); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php index 938d160486d..818b9d061b9 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php @@ -1,7 +1,5 @@ <?php /** - * Mapper class. Maps library request to specific adapter dependent query - * * Magento * * NOTICE OF LICENSE @@ -25,18 +23,249 @@ */ namespace Magento\Framework\Search\Adapter\Mysql; +use Magento\Framework\App\Resource\Config; +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\Filter\Builder; +use Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match as MatchQueryBuilder; +use Magento\Framework\Search\Request\Query\Bool as BoolQuery; +use Magento\Framework\Search\Request\Query\Filter as FilterQuery; +use Magento\Framework\Search\Request\Query\Match as MatchQuery; +use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; use Magento\Framework\Search\RequestInterface; +/** + * Mapper class. Maps library request to specific adapter dependent query + */ class Mapper { + const BOOL_MUST_NOT = true; + const BOOL_MUST = false; + + /** + * @var \Magento\Framework\App\Resource + */ + private $resource; + + /** + * @var ScoreBuilder + */ + private $scoreBuilderFactory; + + /** + * @var \Magento\Framework\Search\Adapter\Mysql\Query\Builder\Match + */ + private $matchQueryBuilder; + /** + * @var Filter\Builder + */ + private $filterBuilder; + /** + * @var Dimensions + */ + private $dimensionsBuilder; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param ScoreBuilderFactory $scoreBuilderFactory + * @param MatchQueryBuilder $matchQueryBuilder + * @param Builder $filterBuilder + * @param Dimensions $dimensionsBuilder + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + ScoreBuilderFactory $scoreBuilderFactory, + MatchQueryBuilder $matchQueryBuilder, + Builder $filterBuilder, + Dimensions $dimensionsBuilder + ) { + $this->resource = $resource; + $this->scoreBuilderFactory = $scoreBuilderFactory; + $this->matchQueryBuilder = $matchQueryBuilder; + $this->filterBuilder = $filterBuilder; + $this->dimensionsBuilder = $dimensionsBuilder; + } + /** * Build adapter dependent query * * @param RequestInterface $request - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @return mixed + * @return Select */ public function buildQuery(RequestInterface $request) { + /** @var ScoreBuilder $scoreBuilder */ + $scoreBuilder = $this->scoreBuilderFactory->create(); + $select = $this->processQuery($scoreBuilder, $request->getQuery(), $this->getSelect(), self::BOOL_MUST); + $select = $this->processDimensions($request, $select); + $tableName = $this->resource->getTableName($request->getIndex()); + $select->from($tableName) + ->columns($scoreBuilder->build()) + ->order($scoreBuilder->getScoreAlias() . ' ' . Select::SQL_DESC); + return $select; + } + + /** + * Process query + * + * @param ScoreBuilder $scoreBuilder + * @param RequestQueryInterface $query + * @param Select $select + * @param bool $isNot + * @return Select + * @throws \InvalidArgumentException + */ + protected function processQuery( + ScoreBuilder $scoreBuilder, + RequestQueryInterface $query, + Select $select, + $isNot + ) { + switch ($query->getType()) { + case RequestQueryInterface::TYPE_MATCH: + /** @var MatchQuery $query */ + $scoreBuilder->startQuery(); + $select = $this->matchQueryBuilder->build( + $scoreBuilder, + $select, + $query, + $isNot + ); + $scoreBuilder->endQuery($query->getBoost()); + break; + case RequestQueryInterface::TYPE_BOOL: + /** @var BoolQuery $query */ + $select = $this->processBoolQuery($scoreBuilder, $query, $select); + break; + case RequestQueryInterface::TYPE_FILTER: + /** @var FilterQuery $query */ + $select = $this->processFilterQuery($scoreBuilder, $query, $select, $isNot); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown query type \'%s\'', $query->getType())); + } + return $select; + } + + /** + * Process bool query + * + * @param ScoreBuilder $scoreBuilder + * @param BoolQuery $query + * @param Select $select + * @return Select + */ + private function processBoolQuery(ScoreBuilder $scoreBuilder, BoolQuery $query, Select $select) + { + $scoreBuilder->startQuery(); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getMust(), + $select, + self::BOOL_MUST + ); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getShould(), + $select, + self::BOOL_MUST + ); + + $select = $this->processBoolQueryCondition( + $scoreBuilder, + $query->getMustNot(), + $select, + self::BOOL_MUST_NOT + ); + + $scoreBuilder->endQuery($query->getBoost()); + + return $select; + } + + /** + * Process bool query condition (must, should, must_not) + * + * @param ScoreBuilder $scoreBuilder + * @param RequestQueryInterface[] $subQueryList + * @param Select $select + * @param bool $isNot + * @return Select + */ + private function processBoolQueryCondition( + ScoreBuilder $scoreBuilder, + array $subQueryList, + Select $select, + $isNot + ) { + foreach ($subQueryList as $subQuery) { + $select = $this->processQuery($scoreBuilder, $subQuery, $select, $isNot); + } + return $select; + } + + /** + * Process filter query + * + * @param ScoreBuilder $scoreBuilder + * @param FilterQuery $query + * @param Select $select + * @param bool $isNot + * @return Select + */ + private function processFilterQuery(ScoreBuilder $scoreBuilder, FilterQuery $query, Select $select, $isNot) + { + switch ($query->getReferenceType()) { + case FilterQuery::REFERENCE_QUERY: + $scoreBuilder->startQuery(); + $select = $this->processQuery($scoreBuilder, $query->getReference(), $select, $isNot); + $scoreBuilder->endQuery($query->getBoost()); + break; + case FilterQuery::REFERENCE_FILTER: + $filterCondition = $this->filterBuilder->build($query->getReference()); + if ($isNot === true) { + $filterCondition = '!' . $filterCondition; + } + $select->where($filterCondition); + $scoreBuilder->addCondition(1, $query->getBoost()); + break; + } + return $select; + } + + /** + * Get empty Select + * + * @return Select + */ + private function getSelect() + { + return $this->resource->getConnection(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->select(); + } + + /** + * Add filtering by dimensions + * + * @param RequestInterface $request + * @param Select $select + * @return \Magento\Framework\DB\Select + */ + private function processDimensions(RequestInterface $request, Select $select) + { + $dimensions = []; + foreach ($request->getDimensions() as $dimension) { + $dimensions[] = $this->dimensionsBuilder->build($dimension); + } + + if (!empty($dimensions)) { + $query = sprintf( + '(%s)', + implode(' ' . Select::SQL_OR . ' ', $dimensions) + ); + $select->where($query); + } + + return $select; } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php new file mode 100644 index 00000000000..2c57d1bc522 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql\Query\Builder; + +use Magento\Framework\DB\Select; +use Magento\Framework\Search\Adapter\Mysql\ScoreBuilder; +use Magento\Framework\Search\Request\Query\Bool; +use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; + +class Match implements QueryInterface +{ + /** + * {@inheritdoc} + */ + public function build( + ScoreBuilder $scoreBuilder, + Select $select, + RequestQueryInterface $query, + $conditionType + ) { + /** @var $query \Magento\Framework\Search\Request\Query\Match */ + foreach ($query->getMatches() as $match) { + $mode = Select::FULLTEXT_MODE_NATURAL; + if ($conditionType === Bool::QUERY_CONDITION_NOT) { + $match['value'] = '-' . $match['value']; + $mode = Select::FULLTEXT_MODE_BOOLEAN; + } + + $scoreBuilder->addCondition( + $select->getMatchQuery($match['field'], $match['value'], $mode), + isset($match['boost']) ? $match['boost'] : 1 + ); + + $select->match($match['field'], $match['value'], true, $mode); + } + return $select; + } +} diff --git a/app/code/Magento/Install/Controller/Wizard/LocaleChange.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php similarity index 60% rename from app/code/Magento/Install/Controller/Wizard/LocaleChange.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php index 1b5428d1dae..98107060318 100644 --- a/app/code/Magento/Install/Controller/Wizard/LocaleChange.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,26 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; +namespace Magento\Framework\Search\Adapter\Mysql\Query\Builder; + +use Magento\Framework\Search\Adapter\Mysql\ScoreBuilder; -class LocaleChange extends \Magento\Install\Controller\Wizard +interface QueryInterface { /** - * Change current locale - * - * @return void + * @param \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $scoreBuilder + * @param \Magento\Framework\DB\Select $select + * @param \Magento\Framework\Search\Request\QueryInterface $query + * @param bool $isNot + * @return \Magento\Framework\DB\Select */ - public function execute() - { - $this->_checkIfInstalled(); - - $locale = $this->getRequest()->getParam('locale'); - $timezone = $this->getRequest()->getParam('timezone'); - $currency = $this->getRequest()->getParam('currency'); - if ($locale) { - $this->_session->setLocale($locale)->setTimezone($timezone)->setCurrency($currency); - } - - $this->_redirect('*/*/locale'); - } + public function build( + ScoreBuilder $scoreBuilder, + \Magento\Framework\DB\Select $select, + \Magento\Framework\Search\Request\QueryInterface $query, + $isNot + ); } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php index 1040b48b5d9..25f71db383e 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php @@ -1,7 +1,5 @@ <?php /** - * Response Factory - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Adapter\Mysql; use Magento\Framework\Search\QueryResponse; +/** + * Response Factory + */ class ResponseFactory { /** @@ -73,13 +74,14 @@ class ResponseFactory */ public function create($rawResponse) { + $rawResponse = $this->prepareData($rawResponse); $documents = array(); foreach ($rawResponse['documents'] as $rawDocument) { /** @var \Magento\Framework\Search\Document[] $documents */ $documents[] = $this->documentFactory->create($rawDocument); } /** @var \Magento\Framework\Search\Aggregation $aggregations */ - $aggregations = $this->documentFactory->create($rawResponse['aggregation']); + $aggregations = $this->aggregationFactory->create($rawResponse['aggregations']); return $this->objectManager->create( '\Magento\Framework\Search\QueryResponse', [ @@ -88,4 +90,51 @@ class ResponseFactory ] ); } + + /** + * Preparing + * + * @param array $rawResponse + * @return array + */ + private function prepareData(array $rawResponse) + { + $preparedResponse = []; + $preparedResponse['documents'] = $this->prepareDocuments($rawResponse['documents']); + $preparedResponse['aggregations'] = $this->prepareAggregations($rawResponse['aggregations']); + return $preparedResponse; + } + + /** + * Prepare Documents + * + * @param array $rawDocumentList + * @return array + */ + private function prepareDocuments(array $rawDocumentList) + { + $documentList = []; + foreach ($rawDocumentList as $document) { + $documentFieldList = []; + foreach ($document as $name => $values) { + $documentFieldList[] = [ + 'name' => $name, + 'value' => $values + ]; + } + $documentList[] = $documentFieldList; + } + return $documentList; + } + + /** + * Prepare Aggregations + * + * @param array $rawAggregations + * @return array + */ + private function prepareAggregations(array $rawAggregations) + { + return $rawAggregations; // Prepare aggregations here + } } diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php new file mode 100644 index 00000000000..554d2a0768d --- /dev/null +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php @@ -0,0 +1,116 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Search\Adapter\Mysql; + +/** + * Class for generating sql condition for calculating store manager + */ +class ScoreBuilder +{ + /** + * @var string + */ + private $scoreCondition = ''; + + /** + * Get column alias for global score query in sql + * + * @return string + */ + public function getScoreAlias() + { + return 'global_score'; + } + + /** + * Get generated sql condition for global score + * + * @return string + */ + public function build() + { + $scoreCondition = $this->scoreCondition; + $this->clear(); + $scoreAlias = $this->getScoreAlias(); + + return "({$scoreCondition}) AS {$scoreAlias}"; + } + + /** + * Start Query + * + * @return void + */ + public function startQuery() + { + $this->addPlus(); + $this->scoreCondition .= '('; + } + + /** + * End Query + * + * @param float $boost + * @return void + */ + public function endQuery($boost) + { + $this->scoreCondition .= ") * {$boost}"; + } + + /** + * Add Condition for score calculation + * + * @param string $score + * @param float $boost + * @return void + */ + public function addCondition($score, $boost) + { + $this->addPlus(); + $this->scoreCondition .= "{$score} * {$boost}"; + } + + /** + * Add Plus sign for Score calculation + * + * @return void + */ + private function addPlus() + { + if (!empty($this->scoreCondition) && substr($this->scoreCondition, -1) != '(') { + $this->scoreCondition .= ' + '; + } + } + + /** + * Clear score manager + * + * @return void + */ + private function clear() + { + $this->scoreCondition = ''; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Factory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php similarity index 68% rename from app/code/Magento/Sales/Model/Resource/Factory.php rename to lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php index fe617ed0191..fc6ea871c61 100644 --- a/app/code/Magento/Sales/Model/Resource/Factory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.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\Sales\Model\Resource; +namespace Magento\Framework\Search\Adapter\Mysql; /** - * Factory class for \Magento\Sales\Model\Resource\Order\AbstractOrder + * ScoreBuilder Factory */ -class Factory +class ScoreBuilderFactory { /** * Object Manager instance @@ -35,25 +35,35 @@ class Factory */ protected $_objectManager = null; + /** + * Instance name to create + * + * @var string + */ + protected $_instanceName = null; + /** * Factory constructor * * @param \Magento\Framework\ObjectManager $objectManager + * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManager $objectManager) - { + public function __construct( + \Magento\Framework\ObjectManager $objectManager, + $instanceName = 'Magento\Framework\Search\Adapter\Mysql\ScoreBuilder' + ) { $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; } /** * Create class instance with specified parameters * - * @param string $instanceName * @param array $data - * @return \Magento\Sales\Model\Resource\Order\AbstractOrder + * @return \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder */ - public function create($instanceName, array $data = array()) + public function create(array $data = array()) { - return $this->_objectManager->create($instanceName, $data); + return $this->_objectManager->create($this->_instanceName, $data); } } diff --git a/lib/internal/Magento/Framework/Search/AdapterFactory.php b/lib/internal/Magento/Framework/Search/AdapterFactory.php index 72af3424bd6..3540caf6280 100644 --- a/lib/internal/Magento/Framework/Search/AdapterFactory.php +++ b/lib/internal/Magento/Framework/Search/AdapterFactory.php @@ -1,7 +1,5 @@ <?php /** - * Adapter Factory - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Adapter Factory + */ class AdapterFactory { /** diff --git a/lib/internal/Magento/Framework/Search/AdapterInterface.php b/lib/internal/Magento/Framework/Search/AdapterInterface.php index b439981f00e..33d98c49f52 100644 --- a/lib/internal/Magento/Framework/Search/AdapterInterface.php +++ b/lib/internal/Magento/Framework/Search/AdapterInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Adapter interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Adapter interface + */ interface AdapterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Aggregation.php b/lib/internal/Magento/Framework/Search/Aggregation.php index b9a065fb599..8c5f8ca7fb5 100644 --- a/lib/internal/Magento/Framework/Search/Aggregation.php +++ b/lib/internal/Magento/Framework/Search/Aggregation.php @@ -1,7 +1,5 @@ <?php /** - * Faceted data - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Faceted data + */ class Aggregation implements \IteratorAggregate { /** diff --git a/lib/internal/Magento/Framework/Search/Bucket.php b/lib/internal/Magento/Framework/Search/Bucket.php index 17e7f27a704..94816110351 100644 --- a/lib/internal/Magento/Framework/Search/Bucket.php +++ b/lib/internal/Magento/Framework/Search/Bucket.php @@ -1,7 +1,5 @@ <?php /** - * Facet Bucket - * * Magento * * NOTICE OF LICENSE @@ -25,49 +23,9 @@ */ namespace Magento\Framework\Search; -class Bucket +/** + * Facet Bucket + */ +class Bucket extends AbstractKeyValuePair { - /** - * Bucket name - * - * @var string - */ - protected $name; - - /** - * Bucket value - * - * @var mixed - */ - protected $value; - - /** - * @param string $name - * @param mixed $value - */ - public function __construct($name, $value) - { - $this->name = $name; - $this->value = $value; - } - - /** - * Get bucket name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get bucket values - * - * @return mixed - */ - public function getValue() - { - return $this->value; - } } diff --git a/lib/internal/Magento/Framework/Search/Document.php b/lib/internal/Magento/Framework/Search/Document.php index ea540197a39..1d0ba3c7316 100644 --- a/lib/internal/Magento/Framework/Search/Document.php +++ b/lib/internal/Magento/Framework/Search/Document.php @@ -1,7 +1,5 @@ <?php /** - * Search Document - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Document + */ class Document implements \IteratorAggregate { /** diff --git a/lib/internal/Magento/Framework/Search/DocumentField.php b/lib/internal/Magento/Framework/Search/DocumentField.php index 5e8af0f3cfe..195ecbdc7d8 100644 --- a/lib/internal/Magento/Framework/Search/DocumentField.php +++ b/lib/internal/Magento/Framework/Search/DocumentField.php @@ -1,7 +1,5 @@ <?php /** - * Search Document Field - * * Magento * * NOTICE OF LICENSE @@ -25,49 +23,9 @@ */ namespace Magento\Framework\Search; -class DocumentField +/** + * Search Document Field + */ +class DocumentField extends AbstractKeyValuePair { - /** - * Document field name - * - * @var string - */ - protected $name; - - /** - * Document field values - * - * @var array - */ - protected $values; - - /** - * @param string $name - * @param array $values - */ - public function __construct($name, array $values) - { - $this->name = $name; - $this->values = $values; - } - - /** - * Get field name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get field values - * - * @return array - */ - public function getValues() - { - return $this->values; - } } diff --git a/lib/internal/Magento/Framework/Search/EntityMetadata.php b/lib/internal/Magento/Framework/Search/EntityMetadata.php new file mode 100644 index 00000000000..7b732606833 --- /dev/null +++ b/lib/internal/Magento/Framework/Search/EntityMetadata.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\Framework\Search; + +/** + * Entity metadata + */ +class EntityMetadata +{ + /** + * @var string + */ + private $entityId; + + /** + * @param string $entityId + */ + public function __construct($entityId) + { + $this->entityId = $entityId; + } + + /** + * Get entity id + * + * @return string + */ + public function getEntityId() + { + return $this->entityId; + } +} diff --git a/lib/internal/Magento/Framework/Search/QueryResponse.php b/lib/internal/Magento/Framework/Search/QueryResponse.php index f93bb915642..b3188a55599 100644 --- a/lib/internal/Magento/Framework/Search/QueryResponse.php +++ b/lib/internal/Magento/Framework/Search/QueryResponse.php @@ -1,7 +1,5 @@ <?php /** - * Search Response - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Response + */ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable { /** @@ -37,15 +38,15 @@ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable /** * Aggregation Collection * - * @var Aggregation[] + * @var Aggregation */ protected $aggregations; /** * @param Document[] $documents - * @param Aggregation[] $aggregations + * @param Aggregation $aggregations */ - public function __construct(array $documents, array $aggregations) + public function __construct(array $documents, Aggregation $aggregations) { $this->documents = $documents; $this->aggregations = $aggregations; @@ -73,7 +74,7 @@ class QueryResponse implements ResponseInterface, \IteratorAggregate, \Countable /** * Return Aggregation Collection * - * @return Aggregation[] + * @return Aggregation */ public function getAggregations() { diff --git a/lib/internal/Magento/Framework/Search/Request.php b/lib/internal/Magento/Framework/Search/Request.php index 787aed2417a..939805ff3ba 100644 --- a/lib/internal/Magento/Framework/Search/Request.php +++ b/lib/internal/Magento/Framework/Search/Request.php @@ -1,6 +1,5 @@ <?php /** - * Search Request * Magento * * NOTICE OF LICENSE @@ -29,6 +28,8 @@ use Magento\Framework\Search\Request\Dimension; use Magento\Framework\Search\Request\QueryInterface; /** + * Search Request + * * @codeCoverageIgnore */ class Request implements RequestInterface @@ -118,7 +119,7 @@ class Request implements RequestInterface */ public function getDimensions() { - $this->dimensions; + return $this->dimensions; } /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php index ac529f8ed12..b4902e8cec0 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Metric.php @@ -1,7 +1,5 @@ <?php /** - * Metric - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Aggregation; +/** + * Metric + */ class Metric { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php index 705ec8ea551..6735b84f53d 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/Range.php @@ -1,7 +1,5 @@ <?php /** - * Range - * * Magento * * NOTICE OF LICENSE @@ -26,6 +24,7 @@ namespace Magento\Framework\Search\Request\Aggregation; /** + * Range * @SuppressWarnings(PHPMD.ShortVariable) */ class Range diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php index 22028dfe329..f4b8b846193 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/RangeBucket.php @@ -1,7 +1,5 @@ <?php /** - * Range Buckets - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Aggregation; use Magento\Framework\Search\Request\BucketInterface; +/** + * Range Buckets + */ class RangeBucket implements BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php index 6c4fca13c4d..650c93b4910 100644 --- a/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php +++ b/lib/internal/Magento/Framework/Search/Request/Aggregation/TermBucket.php @@ -1,7 +1,5 @@ <?php /** - * Term Buckets - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Aggregation; use Magento\Framework\Search\Request\BucketInterface; +/** + * Term Buckets + */ class TermBucket implements BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php index 3457b288179..eb060564761 100644 --- a/lib/internal/Magento/Framework/Search/Request/BucketInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/BucketInterface.php @@ -1,7 +1,5 @@ <?php /** - * Aggregation Bucket Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Aggregation Bucket Interface + */ interface BucketInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php index 9c244774944..2cd3ded1c81 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/Converter.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/Converter.php @@ -1,6 +1,5 @@ <?php /** - * Search Request xml converter * Magento * * NOTICE OF LICENSE @@ -24,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Config; +/** + * Search Request xml converter + */ class Converter implements \Magento\Framework\Config\ConverterInterface { /** @@ -45,7 +47,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface $request['dimensions'] = $this->convertNodes($simpleXmlNode->dimensions, 'name'); $request['queries'] = $this->convertNodes($simpleXmlNode->queries, 'name'); $request['filters'] = $this->convertNodes($simpleXmlNode->filters, 'name'); - $request['aggregation'] = $this->convertNodes($simpleXmlNode->aggregation, 'name'); + $request['aggregations'] = $this->convertNodes($simpleXmlNode->aggregations, 'name'); $requests[$name] = $request; } return $requests; @@ -66,17 +68,6 @@ class Converter implements \Magento\Framework\Config\ConverterInterface 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 * @@ -87,22 +78,35 @@ class Converter implements \Magento\Framework\Config\ConverterInterface protected function convertNodes(\SimpleXMLElement $nodes, $name) { $list = []; - /** @var \SimpleXMLElement $node */ - foreach ($nodes->children() as $node) { - $element = $this->convertToArray($node->attributes()); - if ($node->count() > 0) { - $element = $this->convertChildNodes($element, $node); - } - $type = (string)$node->attributes('xsi', true)['type']; - if (!empty($type)) { - $element['type'] = $type; - } + if (!empty($nodes)) { + /** @var \SimpleXMLElement $node */ + foreach ($nodes->children() as $node) { + $element = $this->convertToArray($node->attributes()); + if ($node->count() > 0) { + $element = $this->convertChildNodes($element, $node); + } + $type = (string)$node->attributes('xsi', true)['type']; + if (!empty($type)) { + $element['type'] = $type; + } - $list[$element[$name]] = $element; + $list[$element[$name]] = $element; + } } return $list; } + /** + * 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 child nodes to array * diff --git a/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php index f76772e36be..103b7fe0f7b 100644 --- a/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php +++ b/lib/internal/Magento/Framework/Search/Request/Config/SchemaLocator.php @@ -1,7 +1,5 @@ <?php /** - * Search Request schema locator - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request\Config; +/** + * Search Request schema locator + */ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Dimension.php b/lib/internal/Magento/Framework/Search/Request/Dimension.php index 1cdc73a0b24..e391198ac02 100644 --- a/lib/internal/Magento/Framework/Search/Request/Dimension.php +++ b/lib/internal/Magento/Framework/Search/Request/Dimension.php @@ -23,37 +23,11 @@ */ namespace Magento\Framework\Search\Request; -class Dimension -{ - /** @var string */ - private $name; - - /** @var string */ - private $value; - - /** - * @param string $name - * @param string $value - */ - public function __construct($name, $value) - { - $this->name = $name; - $this->value = $value; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } +use Magento\Framework\Search\AbstractKeyValuePair; - /** - * @return string - */ - public function getName() - { - return $this->name; - } +/** + * Search Request Dimension + */ +class Dimension extends AbstractKeyValuePair +{ } diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php index b83fdf3df44..fe86bd5cc66 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Bool.php @@ -1,6 +1,5 @@ <?php /** - * Bool Filter * Magento * * NOTICE OF LICENSE @@ -26,6 +25,9 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; +/** + * Bool Filter + */ class Bool implements FilterInterface { /** @@ -87,7 +89,7 @@ class Bool implements FilterInterface /** * Get Must filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getMust() { @@ -97,7 +99,7 @@ class Bool implements FilterInterface /** * Get Should filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getShould() { @@ -107,7 +109,7 @@ class Bool implements FilterInterface /** * Get Must Not filters * - * @return array + * @return \Magento\Framework\Search\Request\FilterInterface[] */ public function getMustNot() { diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Range.php b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php index db64a3894f8..50c7fe8cbcf 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Range.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Range.php @@ -1,7 +1,5 @@ <?php /** - * Range Filter - * * Magento * * NOTICE OF LICENSE @@ -28,6 +26,7 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; /** + * Range Filter * @SuppressWarnings(PHPMD.ShortVariable) */ class Range implements FilterInterface diff --git a/lib/internal/Magento/Framework/Search/Request/Filter/Term.php b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php index 1ee1e062838..98518dee352 100644 --- a/lib/internal/Magento/Framework/Search/Request/Filter/Term.php +++ b/lib/internal/Magento/Framework/Search/Request/Filter/Term.php @@ -1,7 +1,5 @@ <?php /** - * Term Filter - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Filter; use Magento\Framework\Search\Request\FilterInterface; +/** + * Term Filter + */ class Term implements FilterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/FilterInterface.php b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php index 4f7df883ff3..d1b594594b4 100644 --- a/lib/internal/Magento/Framework/Search/Request/FilterInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/FilterInterface.php @@ -1,7 +1,5 @@ <?php /** - * Filter Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Filter Interface + */ interface FilterInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php index 8b76ac54787..6a35bbae6fa 100644 --- a/lib/internal/Magento/Framework/Search/Request/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php @@ -51,7 +51,7 @@ class Mapper /** * @var array */ - private $aggregation; + private $aggregations; /** * @var \Magento\Framework\ObjectManager @@ -67,7 +67,7 @@ class Mapper * @param \Magento\Framework\ObjectManager $objectManager * @param array $queries * @param string $rootQueryName - * @param array $aggregation + * @param array $aggregations * @param array $filters * @throws \Exception * @throws \InvalidArgumentException @@ -77,12 +77,12 @@ class Mapper \Magento\Framework\ObjectManager $objectManager, array $queries, $rootQueryName, - array $aggregation, + array $aggregations = [], array $filters = [] ) { $this->objectManager = $objectManager; $this->queries = $queries; - $this->aggregation = $aggregation; + $this->aggregations = $aggregations; $this->filters = $filters; $this->rootQuery = $this->get($rootQueryName); @@ -245,8 +245,8 @@ class Mapper [ 'name' => $filter['name'], 'field' => $filter['field'], - 'from' => $filter['from'], - 'to' => $filter['to'] + 'from' => isset($filter['from']) ? $filter['from'] : null, + 'to' => isset($filter['to']) ? $filter['to'] : null, ] ); @@ -283,7 +283,7 @@ class Mapper */ private function validateQueries() { - $this->validateNotUsed($this->queries, $this->mappedQueries, 'Query %1 not used in request hierarchy'); + $this->validateNotUsed($this->queries, $this->mappedQueries, 'Query %1 is not used in request hierarchy'); } /** @@ -292,7 +292,7 @@ class Mapper */ private function validateFilters() { - $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 not used in request hierarchy'); + $this->validateNotUsed($this->filters, $this->mappedFilters, 'Filter %1 is not used in request hierarchy'); } /** @@ -320,7 +320,7 @@ class Mapper public function getBuckets() { $buckets = array(); - foreach ($this->aggregation as $bucketData) { + foreach ($this->aggregations as $bucketData) { $arguments = [ 'name' => $bucketData['name'], diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Bool.php b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php index 186c96acf9b..ea48a2f2c09 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Bool.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Bool.php @@ -1,6 +1,5 @@ <?php /** - * Bool Query * Magento * * NOTICE OF LICENSE @@ -26,8 +25,15 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Bool Query + */ class Bool implements QueryInterface { + const QUERY_CONDITION_MUST = 'must'; + const QUERY_CONDITION_SHOULD = 'should'; + const QUERY_CONDITION_NOT = 'not'; + /** * Boost * @@ -106,7 +112,7 @@ class Bool implements QueryInterface /** * Get Should queries * - * @return array + * @return QueryInterface[] */ public function getShould() { @@ -116,7 +122,7 @@ class Bool implements QueryInterface /** * Get Must queries * - * @return array + * @return QueryInterface[] */ public function getMust() { @@ -126,7 +132,7 @@ class Bool implements QueryInterface /** * Get Must Not queries * - * @return array + * @return QueryInterface[] */ public function getMustNot() { diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Filter.php b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php index 480daadb74b..151e4c098af 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Filter.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Filter.php @@ -1,7 +1,5 @@ <?php /** - * Term Query - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Term Query + */ class Filter implements QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/Query/Match.php b/lib/internal/Magento/Framework/Search/Request/Query/Match.php index da0d3df4849..e32b458a435 100644 --- a/lib/internal/Magento/Framework/Search/Request/Query/Match.php +++ b/lib/internal/Magento/Framework/Search/Request/Query/Match.php @@ -1,7 +1,5 @@ <?php /** - * Match Query - * * Magento * * NOTICE OF LICENSE @@ -27,6 +25,9 @@ namespace Magento\Framework\Search\Request\Query; use Magento\Framework\Search\Request\QueryInterface; +/** + * Match Query + */ class Match implements QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/Request/QueryInterface.php b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php index 8b709d05717..45a55363954 100644 --- a/lib/internal/Magento/Framework/Search/Request/QueryInterface.php +++ b/lib/internal/Magento/Framework/Search/Request/QueryInterface.php @@ -1,7 +1,5 @@ <?php /** - * Query Interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search\Request; +/** + * Query Interface + */ interface QueryInterface { /** diff --git a/lib/internal/Magento/Framework/Search/RequestFactory.php b/lib/internal/Magento/Framework/Search/RequestFactory.php index a83c16c9c6f..0846e0e7488 100644 --- a/lib/internal/Magento/Framework/Search/RequestFactory.php +++ b/lib/internal/Magento/Framework/Search/RequestFactory.php @@ -1,6 +1,5 @@ <?php /** - * Search Request Pool * Magento * * NOTICE OF LICENSE @@ -24,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Request Pool + */ class RequestFactory { const CACHE_PREFIX = 'search_request::'; @@ -103,7 +105,7 @@ class RequestFactory 'objectManager' => $this->objectManager, 'rootQueryName' => $data['query'], 'queries' => $data['queries'], - 'aggregation' => $data['aggregation'], + 'aggregations' => $data['aggregations'], 'filters' => $data['filters'] ] ); @@ -115,14 +117,14 @@ class RequestFactory 'from' => $data['from'], 'size' => $data['size'], 'query' => $mapper->getRootQuery(), - 'demensions' => array_map( + 'dimensions' => array_map( function ($data) { return $this->objectManager->create( 'Magento\Framework\Search\Request\Dimension', $data ); }, - isset($data['demensions']) ? $data['demensions'] : [] + isset($data['dimensions']) ? $data['dimensions'] : [] ), 'buckets' => $mapper->getBuckets() ] diff --git a/lib/internal/Magento/Framework/Search/RequestInterface.php b/lib/internal/Magento/Framework/Search/RequestInterface.php index 822b29af80d..5de079c302e 100644 --- a/lib/internal/Magento/Framework/Search/RequestInterface.php +++ b/lib/internal/Magento/Framework/Search/RequestInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Request - * * Magento * * NOTICE OF LICENSE @@ -29,6 +27,9 @@ use Magento\Framework\Search\Request\BucketInterface; use Magento\Framework\Search\Request\QueryInterface; use Magento\Framework\Search\Request\Dimension; +/** + * Search Request + */ interface RequestInterface { /** diff --git a/lib/internal/Magento/Framework/Search/ResponseInterface.php b/lib/internal/Magento/Framework/Search/ResponseInterface.php index 9b058362b33..13192b32fe1 100644 --- a/lib/internal/Magento/Framework/Search/ResponseInterface.php +++ b/lib/internal/Magento/Framework/Search/ResponseInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Request - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Request + */ interface ResponseInterface { } diff --git a/lib/internal/Magento/Framework/Search/SearchEngine.php b/lib/internal/Magento/Framework/Search/SearchEngine.php index 8297585cd90..6fee0377130 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngine.php +++ b/lib/internal/Magento/Framework/Search/SearchEngine.php @@ -1,7 +1,5 @@ <?php /** - * Search Engine - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Engine + */ class SearchEngine implements SearchEngineInterface { /** diff --git a/lib/internal/Magento/Framework/Search/SearchEngineInterface.php b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php index aab97f19941..5c01556a462 100644 --- a/lib/internal/Magento/Framework/Search/SearchEngineInterface.php +++ b/lib/internal/Magento/Framework/Search/SearchEngineInterface.php @@ -1,7 +1,5 @@ <?php /** - * Search Engine interface - * * Magento * * NOTICE OF LICENSE @@ -25,6 +23,9 @@ */ namespace Magento\Framework\Search; +/** + * Search Engine interface + */ interface SearchEngineInterface { /** diff --git a/lib/internal/Magento/Framework/Search/etc/requests.xsd b/lib/internal/Magento/Framework/Search/etc/requests.xsd index cfdd133b458..f24cbc813f3 100644 --- a/lib/internal/Magento/Framework/Search/etc/requests.xsd +++ b/lib/internal/Magento/Framework/Search/etc/requests.xsd @@ -34,13 +34,13 @@ <xs:field xpath="@name" /> </xs:key> </xs:element> - <xs:element type="filters" name="filters"> + <xs:element type="filters" name="filters" minOccurs="0"> <xs:key name="filterName"> <xs:selector xpath="filter" /> <xs:field xpath="@name" /> </xs:key> </xs:element> - <xs:element type="aggregation" name="aggregation" > + <xs:element type="aggregation" name="aggregation" minOccurs="0"> <xs:key name="aggregationName"> <xs:selector xpath="bucket" /> <xs:field xpath="@name" /> @@ -168,8 +168,8 @@ <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:attribute type="xs:string" name="from" use="optional" /> + <xs:attribute type="xs:string" name="to" use="optional" /> </xs:extension> </xs:complexContent> </xs:complexType> @@ -289,4 +289,4 @@ <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 +</xs:schema> diff --git a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd index dfedcfe2742..797fdd6d38d 100644 --- a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd +++ b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd @@ -44,5 +44,10 @@ </xs:element> </xs:sequence> </xs:complexType> - <xs:element name="requests" type="requests"/> + <xs:element name="requests" type="requests"> + <xs:unique name="uniqueRequest"> + <xs:selector xpath="./*" /> + <xs:field xpath="@query" /> + </xs:unique> + </xs:element> </xs:schema> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Service/ArrayObjectSearch.php b/lib/internal/Magento/Framework/Service/ArrayObjectSearch.php new file mode 100644 index 00000000000..3a0d400fbfc --- /dev/null +++ b/lib/internal/Magento/Framework/Service/ArrayObjectSearch.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\Framework\Service; + +/** + * Class to provide possibility to search for any object's property value by the name and value of another property + */ +class ArrayObjectSearch +{ + /** + * Search for the value's value by specified key's name-value pair in the object + * <pre> + * Example of usage: + * $data = array( + * ValidationRuleBuilderObject('name' => 'min_text_length', 'value' => 0) + * ValidationRuleBuilderObject('name' => 'max_text_length', 'value' => 255) + * ValidationRuleBuilderObject('anyOtherName' => 'customName', 'anyOtherValue' => 'customValue') + * ); + * + * Call: + * $maxDateValue = ArrayObjectSearch::getArrayElementByName( + * $data, + * 'max_text_length' + * ); + * By default function looks for `value`'s value by the `name`'s value + * Result: 255 + * + * Call: + * $customValue = ArrayObjectSearch::getArrayElementByName( + * $data, + * 'customName', //what key value to look for + * 'anyOtherName', //where to look for + * 'anyOtherValue' //where to return from + * ); + * Result: 'customValue' + * </pre> + * @param object $data Object to search in + * @param string $keyValue Value of the key property to search for + * @param string $keyName Name of the key property to search for + * @param string $valueName Name of the value property name + * @return null|mixed + */ + public static function getArrayElementByName($data, $keyValue, $keyName = 'name', $valueName = 'value') + { + $getter = 'get' . ucfirst($keyName); + if (is_array($data)) { + foreach ($data as $dataObject) { + if (is_object($dataObject) && $dataObject->$getter() == $keyValue) { + $valueGetter = 'get' . ucfirst($valueName); + return $dataObject->$valueGetter(); + } + } + } + return null; + } +} diff --git a/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php b/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php index dbea342f083..972541d4a7e 100644 --- a/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php +++ b/lib/internal/Magento/Framework/Service/Config/MetadataConfig.php @@ -47,7 +47,7 @@ class MetadataConfig implements MetadataServiceInterface * Initialize dependencies. * * @param ServiceConfigReader $serviceConfigReader - * @param AttributeMetadataBuilderInterface|null $attributeMetadataBuilder + * @param AttributeMetadataBuilderInterface $attributeMetadataBuilder */ public function __construct( ServiceConfigReader $serviceConfigReader, diff --git a/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php b/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php index 47e60fabb2d..2607389e112 100644 --- a/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Service/Data/AbstractExtensibleObjectBuilder.php @@ -134,7 +134,7 @@ abstract class AbstractExtensibleObjectBuilder extends AbstractSimpleObjectBuild $dataObjectMethods = get_class_methods($this->_getDataObjectType()); foreach ($data as $key => $value) { /* First, verify is there any getter for the key on the Service Data Object */ - $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key); + $camelCaseKey = \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); $possibleMethods = array( 'get' . $camelCaseKey, 'is' . $camelCaseKey diff --git a/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php index 11226935bbc..44adce498d4 100644 --- a/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Service/Data/AbstractSimpleObjectBuilder.php @@ -91,8 +91,8 @@ abstract class AbstractSimpleObjectBuilder foreach ($data as $key => $value) { /* First, verify is there any getter for the key on the Service Data Object */ $possibleMethods = array( - 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key), - 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToCamelCase($key) + 'get' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key), + 'is' . \Magento\Framework\Service\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key) ); if (array_intersect($possibleMethods, $dataObjectMethods)) { $this->_data[$key] = $value; diff --git a/app/code/Magento/Install/Controller/Wizard/DownloadManual.php b/lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php similarity index 71% rename from app/code/Magento/Install/Controller/Wizard/DownloadManual.php rename to lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php index 2e2d7833ac3..e95966363dc 100644 --- a/app/code/Magento/Install/Controller/Wizard/DownloadManual.php +++ b/lib/internal/Magento/Framework/Service/Data/AttributeMetadata.php @@ -1,6 +1,5 @@ <?php /** - * * Magento * * NOTICE OF LICENSE @@ -22,18 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Install\Controller\Wizard; -class DownloadManual extends \Magento\Install\Controller\Wizard +namespace Magento\Framework\Service\Data; + +/** + * Base data object for custom attribute metadata + */ +class AttributeMetadata extends AbstractSimpleObject implements MetadataObjectInterface { + const ATTRIBUTE_CODE = 'attribute_code'; + /** - * Download manual action + * Retrieve code of the attribute. * - * @return void + * @return string|null */ - public function execute() + public function getAttributeCode() { - $step = $this->_getWizard()->getStepByName('download'); - $this->getResponse()->setRedirect($step->getNextUrl()); + return $this->_get(self::ATTRIBUTE_CODE); } } diff --git a/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php b/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php index 9839e08b724..f1f0afb02e4 100644 --- a/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php +++ b/lib/internal/Magento/Framework/Service/ExtensibleDataObjectConverter.php @@ -37,9 +37,10 @@ class ExtensibleDataObjectConverter * Convert AbstractExtensibleObject into flat array. * * @param AbstractExtensibleObject $dataObject + * @param string[] $skipCustomAttributes * @return array */ - public static function toFlatArray(AbstractExtensibleObject $dataObject) + public static function toFlatArray(AbstractExtensibleObject $dataObject, $skipCustomAttributes = array()) { $dataObjectArray = $dataObject->__toArray(); //process custom attributes if present @@ -48,8 +49,10 @@ class ExtensibleDataObjectConverter $customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]; unset ($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]); foreach ($customAttributes as $attributeValue) { - $dataObjectArray[$attributeValue[AttributeValue::ATTRIBUTE_CODE]] - = $attributeValue[AttributeValue::VALUE]; + if (!in_array($attributeValue[AttributeValue::ATTRIBUTE_CODE], $skipCustomAttributes)) { + $dataObjectArray[$attributeValue[AttributeValue::ATTRIBUTE_CODE]] + = $attributeValue[AttributeValue::VALUE]; + } } } return ConvertArray::toFlatArray($dataObjectArray); diff --git a/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php b/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php index ea4322f5026..d1e4ec78535 100644 --- a/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php +++ b/lib/internal/Magento/Framework/Service/SimpleDataObjectConverter.php @@ -25,6 +25,7 @@ namespace Magento\Framework\Service; use Magento\Framework\Convert\ConvertArray; use Magento\Framework\Service\Data\AbstractExtensibleObject; +use Magento\Framework\Service\Data\AbstractSimpleObject; class SimpleDataObjectConverter { @@ -107,9 +108,31 @@ class SimpleDataObjectConverter $result[$key] = $value; } } - return $result; + return $this->_unpackAssociativeArray($result); } + /** + * Unpack associative array packed by SOAP server into key-value + * + * @param mixed $data + * @return array Unpacked associative array if array was passed as argument or original value otherwise + */ + protected function _unpackAssociativeArray($data) + { + if (!is_array($data)) { + return $data; + } else { + foreach ($data as $key => $value) { + if (is_array($value) && count($value) == 2 && isset($value['key']) && isset($value['value'])) { + $data[$value['key']] = $this->_unpackAssociativeArray($value['value']); + unset($data[$key]); + } else { + $data[$key] = $this->_unpackAssociativeArray($value); + } + } + return $data; + } + } /** * Converts an input string from snake_case to upper CamelCase. @@ -117,13 +140,63 @@ class SimpleDataObjectConverter * @param string $input * @return string */ - public static function snakeCaseToCamelCase($input) + public static function snakeCaseToUpperCamelCase($input) { - $output = ''; - $segments = explode('_', $input); - foreach ($segments as $segment) { - $output .= ucfirst($segment); + return str_replace(' ', '', ucwords(str_replace('_', ' ', $input))); + } + + /** + * Converts the incoming data into scalar or an array of scalars format. + * + * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is + * assumed to be a Data Object and converted to an associative array with keys representing the properties of the + * Data Object. + * Nested Data Objects are also converted. If the data provided is itself an array, then we iterate through the + * contents and convert each piece individually. + * + * @param mixed $data + * @return array|int|string|bool|float Scalar or array of scalars + */ + public function processServiceOutput($data) + { + if (is_array($data)) { + $result = []; + foreach ($data as $datum) { + if ($datum instanceof AbstractSimpleObject) { + $datum = $this->processDataObject($datum->__toArray()); + } + $result[] = $datum; + } + return $result; + } else if ($data instanceof AbstractSimpleObject) { + return $this->processDataObject($data->__toArray()); + } else if (is_null($data)) { + return []; + } else { + /** No processing is required for scalar types */ + return $data; + } + } + + /** + * Convert data object to array and process available custom attributes + * + * @param array $dataObjectArray + * @return array + */ + protected function processDataObject($dataObjectArray) + { + if (isset($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY])) { + $dataObjectArray = ExtensibleDataObjectConverter::convertCustomAttributesToSequentialArray( + $dataObjectArray + ); + } + //Check for nested custom_attributes + foreach ($dataObjectArray as $key => $value) { + if (is_array($value)) { + $dataObjectArray[$key] = $this->processDataObject($value); + } } - return $output; + return $dataObjectArray; } } diff --git a/lib/internal/Magento/Framework/Session/Config.php b/lib/internal/Magento/Framework/Session/Config.php index 33f8d7047db..289fc2e25be 100644 --- a/lib/internal/Magento/Framework/Session/Config.php +++ b/lib/internal/Magento/Framework/Session/Config.php @@ -108,11 +108,6 @@ class Config implements ConfigInterface 'session.cookie_httponly' ); - /** - * @var \Magento\Framework\App\State - */ - protected $_appState; - /** * @var \Magento\Framework\App\Filesystem */ @@ -127,7 +122,6 @@ class Config implements ConfigInterface * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\String $stringHelper * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\Filesystem $filesystem * @param string $scopeType * @param string $saveMethod @@ -139,7 +133,6 @@ class Config implements ConfigInterface \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, @@ -150,13 +143,12 @@ class Config implements ConfigInterface $this->_scopeConfig = $scopeConfig; $this->_stringHelper = $stringHelper; $this->_httpRequest = $request; - $this->_appState = $appState; $this->_filesystem = $filesystem; $this->_scopeType = $scopeType; $this->setSaveHandler($saveMethod === 'db' ? 'user' : $saveMethod); - if (!$this->_appState->isInstalled() || !$savePath) { + if (!$savePath) { $savePath = $this->_filesystem->getPath('session'); } $this->setSavePath($savePath); diff --git a/lib/internal/Magento/Framework/Session/Generic.php b/lib/internal/Magento/Framework/Session/Generic.php index d429ec02720..db8344c12ee 100644 --- a/lib/internal/Magento/Framework/Session/Generic.php +++ b/lib/internal/Magento/Framework/Session/Generic.php @@ -36,7 +36,6 @@ class Generic extends SessionManager * @param StorageInterface $storage * @param \Magento\Framework\Stdlib\CookieManager $cookieManager * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory - * @param null $sessionName */ public function __construct( \Magento\Framework\App\Request\Http $request, @@ -46,8 +45,7 @@ class Generic extends SessionManager ValidatorInterface $validator, StorageInterface $storage, \Magento\Framework\Stdlib\CookieManager $cookieManager, - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, - $sessionName = null + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory ) { parent::__construct( $request, @@ -59,6 +57,6 @@ class Generic extends SessionManager $cookieManager, $cookieMetadataFactory ); - $this->start($sessionName); + $this->start(); } } diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php index a2f3461f0f8..810ad100962 100644 --- a/lib/internal/Magento/Framework/Session/SessionManager.php +++ b/lib/internal/Magento/Framework/Session/SessionManager.php @@ -170,18 +170,14 @@ class SessionManager implements SessionManagerInterface /** * Configure session handler and start session * - * @param string $sessionName * @return $this */ - public function start($sessionName = null) + public function start() { if (!$this->isSessionExists()) { \Magento\Framework\Profiler::start('session_start'); // Need to apply the config options so they can be ready by session_start $this->initIniOptions(); - if (!empty($sessionName)) { - $this->setName($sessionName); - } $this->registerSaveHandler(); // potential custom logic for session id (ex. switching between hosts) diff --git a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php index 5a54bf8e8a6..55e5d262e2b 100644 --- a/lib/internal/Magento/Framework/Session/SessionManagerInterface.php +++ b/lib/internal/Magento/Framework/Session/SessionManagerInterface.php @@ -38,10 +38,9 @@ interface SessionManagerInterface /** * Start session * - * @param string $sessionName * @return SessionManagerInterface */ - public function start($sessionName = null); + public function start(); /** * Session write close diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php index ad73a649e29..b78c8f5236b 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieMetadata.php @@ -34,6 +34,9 @@ class CookieMetadata */ const KEY_DOMAIN = 'domain'; const KEY_PATH = 'path'; + const KEY_SECURE = 'secure'; + const KEY_HTTP_ONLY = 'http_only'; + const KEY_DURATION = 'duration'; /**#@-*/ /** @@ -134,4 +137,24 @@ class CookieMetadata $this->metadata[$name] = $value; return $this; } + + /** + * Get HTTP Only flag + * + * @return bool|null + */ + public function getHttpOnly() + { + return $this->get(self::KEY_HTTP_ONLY); + } + + /** + * 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/CookieScope.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php index 34640b77f07..718f3aab192 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScope.php @@ -27,7 +27,7 @@ namespace Magento\Framework\Stdlib\Cookie; /** * CookieScope is used to store default scope metadata. */ -class CookieScope +class CookieScope implements CookieScopeInterface { /** * @var SensitiveCookieMetadata diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.php new file mode 100644 index 00000000000..0d66a547845 --- /dev/null +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieScopeInterface.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\Framework\Stdlib\Cookie; + + +/** + * CookieScope is used to store default scope metadata. + */ +interface CookieScopeInterface +{ + /** + * 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); + + /** + * 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); + + /** + * 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); +} diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index 90ba0fa4077..68d1e07ec4b 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -56,14 +56,14 @@ class PhpCookieManager implements CookieManager /** - * @var CookieScope + * @var CookieScopeInterface */ private $scope; /** - * @param CookieScope $scope + * @param CookieScopeInterface $scope */ - public function __construct(CookieScope $scope) + public function __construct(CookieScopeInterface $scope) { $this->scope = $scope; } @@ -85,9 +85,6 @@ class PhpCookieManager implements CookieManager 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); } @@ -134,8 +131,8 @@ class PhpCookieManager implements CookieManager $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) + $this->extractValue(CookieMetadata::KEY_SECURE, $metadataArray, false), + $this->extractValue(CookieMetadata::KEY_HTTP_ONLY, $metadataArray, false) ); if (!$phpSetcookieSuccess) { @@ -219,8 +216,8 @@ class PhpCookieManager implements CookieManager ) { $expireTime = $metadataArray[PhpCookieManager::KEY_EXPIRE_TIME]; } else { - if (isset($metadataArray[PublicCookieMetadata::KEY_DURATION])) { - $expireTime = $metadataArray[PublicCookieMetadata::KEY_DURATION] + time(); + if (isset($metadataArray[CookieMetadata::KEY_DURATION])) { + $expireTime = $metadataArray[CookieMetadata::KEY_DURATION] + time(); } else { $expireTime = PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME; } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php index f8d146701ab..d42c1593200 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PublicCookieMetadata.php @@ -30,14 +30,6 @@ namespace Magento\Framework\Stdlib\Cookie; */ 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 * @@ -84,16 +76,6 @@ class PublicCookieMetadata extends CookieMetadata 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 * @@ -104,14 +86,4 @@ class PublicCookieMetadata extends CookieMetadata { 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 index 428c4f22b75..b053bcd83e1 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/SensitiveCookieMetadata.php @@ -24,6 +24,8 @@ namespace Magento\Framework\Stdlib\Cookie; +use Magento\Framework\StoreManagerInterface; + /** * Class SensitiveCookieMetadata * @@ -32,5 +34,57 @@ namespace Magento\Framework\Stdlib\Cookie; */ class SensitiveCookieMetadata extends CookieMetadata { + /** + * @var StoreManagerInterface + */ + protected $storeManager; + + /** + * @param StoreManagerInterface $storeManager + * @param array $metadata + */ + public function __construct(StoreManagerInterface $storeManager, $metadata = []) + { + if (!isset($metadata[self::KEY_HTTP_ONLY])) { + $metadata[self::KEY_HTTP_ONLY] = true; + } + $this->storeManager = $storeManager; + parent::__construct($metadata); + } + + + /** + * {@inheritdoc} + */ + public function getSecure() + { + $this->updateSecureValue(); + return $this->get(self::KEY_SECURE); + } + + /** + * {@inheritdoc} + */ + public function __toArray() + { + $this->updateSecureValue(); + return parent::__toArray(); + } + /** + * Update secure value, set it to store setting if it has no explicit value assigned. + * + * @return void + */ + private function updateSecureValue() + { + if (null === $this->get(self::KEY_SECURE)) { + $store = $this->storeManager->getStore(); + if (empty($store)) { + $this->set(self::KEY_SECURE, true); + } else { + $this->set(self::KEY_SECURE, $store->isCurrentlySecure()); + } + } + } } diff --git a/app/code/Magento/Store/Model/StoreManagerInterface.php b/lib/internal/Magento/Framework/StoreManagerInterface.php similarity index 95% rename from app/code/Magento/Store/Model/StoreManagerInterface.php rename to lib/internal/Magento/Framework/StoreManagerInterface.php index 42ea5ed3e50..e46867b09aa 100644 --- a/app/code/Magento/Store/Model/StoreManagerInterface.php +++ b/lib/internal/Magento/Framework/StoreManagerInterface.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\Store\Model; +namespace Magento\Framework; interface StoreManagerInterface { @@ -52,7 +52,6 @@ interface StoreManagerInterface * * @param null|string|bool|int|\Magento\Store\Model\Store $storeId * @return \Magento\Store\Model\Store - * @throws \Magento\Store\Model\Exception */ public function getStore($storeId = null); @@ -102,8 +101,6 @@ interface StoreManagerInterface * * @param null|\Magento\Store\Model\Group|string $groupId * @return \Magento\Store\Model\Group - * @throws \Magento\Store\Model\Exception - * @throws \Magento\Framework\Model\Exception */ public function getGroup($groupId = null); diff --git a/lib/internal/Magento/Framework/View/Asset/Repository.php b/lib/internal/Magento/Framework/View/Asset/Repository.php index 667a5ce4f06..24b217b509c 100644 --- a/lib/internal/Magento/Framework/View/Asset/Repository.php +++ b/lib/internal/Magento/Framework/View/Asset/Repository.php @@ -50,9 +50,9 @@ class Repository private $design; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - private $themeProvider; + private $themeList; /** * @var \Magento\Framework\View\Asset\Source @@ -72,18 +72,18 @@ class Repository /** * @param \Magento\Framework\UrlInterface $baseUrl * @param \Magento\Framework\View\DesignInterface $design - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList * @param \Magento\Framework\View\Asset\Source $assetSource */ public function __construct( \Magento\Framework\UrlInterface $baseUrl, \Magento\Framework\View\DesignInterface $design, - \Magento\Framework\View\Design\Theme\Provider $themeProvider, + \Magento\Framework\View\Design\Theme\ListInterface $themeList, \Magento\Framework\View\Asset\Source $assetSource ) { $this->baseUrl = $baseUrl; $this->design = $design; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; $this->assetSource = $assetSource; } @@ -117,7 +117,7 @@ class Repository } if ($theme) { - $params['themeModel'] = $this->themeProvider->getThemeModel($theme, $area); + $params['themeModel'] = $this->themeList->getThemeByFullPath($area . '/' . $theme); if (!$params['themeModel']) { throw new \UnexpectedValueException("Could not find theme '$theme' for area '$area'"); } diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index 5d40493a79b..205eb255872 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -69,23 +69,23 @@ class Source protected $fallback; /** - * @var \Magento\Framework\View\Design\Theme\Provider + * @var \Magento\Framework\View\Design\Theme\ListInterface */ - protected $themeProvider; + protected $themeList; /** * @param PreProcessor\Cache $cache * @param \Magento\Framework\App\Filesystem $filesystem * @param PreProcessor\Pool $preProcessorPool * @param \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback - * @param \Magento\Framework\View\Design\Theme\Provider $themeProvider + * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList */ public function __construct( PreProcessor\Cache $cache, \Magento\Framework\App\Filesystem $filesystem, PreProcessor\Pool $preProcessorPool, \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback, - \Magento\Framework\View\Design\Theme\Provider $themeProvider + \Magento\Framework\View\Design\Theme\ListInterface $themeList ) { $this->cache = $cache; $this->filesystem = $filesystem; @@ -93,7 +93,7 @@ class Source $this->varDir = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR); $this->preProcessorPool = $preProcessorPool; $this->fallback = $fallback; - $this->themeProvider = $themeProvider; + $this->themeList = $themeList; } /** @@ -217,7 +217,7 @@ class Source LocalInterface $asset, \Magento\Framework\View\Asset\File\FallbackContext $context ) { - $themeModel = $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); + $themeModel = $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); $sourceFile = $this->fallback->getFile( $context->getAreaCode(), $themeModel, diff --git a/lib/internal/Magento/Framework/View/Design/Theme/Provider.php b/lib/internal/Magento/Framework/View/Design/Theme/Provider.php deleted file mode 100644 index 80476a21788..00000000000 --- a/lib/internal/Magento/Framework/View/Design/Theme/Provider.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Framework\View\Design\Theme; - -class Provider -{ - /** - * @var \Magento\Framework\App\State - */ - protected $appState; - - /** - * @var FlyweightFactory - */ - private $flyweightFactory; - - /** - * @var ListInterface - */ - private $themeList; - - /** - * @param \Magento\Framework\App\State $appState - * @param FlyweightFactory $flyweightFactory - * @param ListInterface $themeList - */ - public function __construct( - \Magento\Framework\App\State $appState, - FlyweightFactory $flyweightFactory, - ListInterface $themeList - ) { - $this->appState = $appState; - $this->flyweightFactory = $flyweightFactory; - $this->themeList = $themeList; - } - - /** - * Get theme model by theme path and area code - * - * @param string $themePath - * @param string $areaCode - * @return \Magento\Framework\View\Design\ThemeInterface - */ - public function getThemeModel($themePath, $areaCode) - { - if ($this->appState->isInstalled()) { - $themeModel = $this->flyweightFactory->create($themePath, $areaCode); - } else { - $themeModel = $this->themeList->getThemeByFullPath($areaCode . '/' . $themePath); - } - return $themeModel; - } -} diff --git a/lib/internal/Magento/Framework/View/Element/Template.php b/lib/internal/Magento/Framework/View/Element/Template.php index ac2a1d39b2b..1ea5a982430 100644 --- a/lib/internal/Magento/Framework/View/Element/Template.php +++ b/lib/internal/Magento/Framework/View/Element/Template.php @@ -95,7 +95,7 @@ class Template extends AbstractBlock /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; diff --git a/lib/internal/Magento/Framework/View/Element/Template/Context.php b/lib/internal/Magento/Framework/View/Element/Template/Context.php index b19e30b060d..dd248e7b8d5 100644 --- a/lib/internal/Magento/Framework/View/Element/Template/Context.php +++ b/lib/internal/Magento/Framework/View/Element/Template/Context.php @@ -54,7 +54,7 @@ class Context extends \Magento\Framework\View\Element\Context /** * Store manager * - * @var \Magento\Store\Model\StoreManagerInterface + * @var \Magento\Framework\StoreManagerInterface */ protected $_storeManager; @@ -81,7 +81,7 @@ class Context extends \Magento\Framework\View\Element\Context * @param \Magento\Framework\View\FileSystem $viewFileSystem * @param \Magento\Framework\View\TemplateEnginePool $enginePool * @param \Magento\Framework\App\State $appState - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\StoreManagerInterface $storeManager * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -108,7 +108,7 @@ class Context extends \Magento\Framework\View\Element\Context \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\View\TemplateEnginePool $enginePool, \Magento\Framework\App\State $appState, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\StoreManagerInterface $storeManager ) { parent::__construct( $request, @@ -192,7 +192,7 @@ class Context extends \Magento\Framework\View\Element\Context /** * Get store manager * - * @return \Magento\Store\Model\StoreManagerInterface + * @return \Magento\Framework\StoreManagerInterface */ public function getStoreManager() { diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 57bec853356..fa8a2103ab5 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -2,7 +2,7 @@ "name": "magento/framework", "description": "N/A", "type": "magento2-library", - "version": "0.1.0-alpha94", + "version": "0.1.0-alpha95", "require": { "php": "~5.4.11|~5.5.0", "ext-spl": "*", diff --git a/lib/web/tiny_mce/plugins/media/img/flv_player.swf b/lib/web/tiny_mce/plugins/media/img/flv_player.swf deleted file mode 100644 index 042c2ab969e98a6fdbe08848c4a73bd2c41de906..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11668 zcmV;FEo;(4S5pYUVE_PloV|PrTvNvr@V+F3a36As0Rb-#MGjBSfQpD35b>z>Admpj zkkAkitwp@*Rqv`rs-o6<w_0jjtro1cYQ44I7iz7xYOA%ae`}R*cK5yH<-ot~_x(Tp z@px}{W_EUFc4qcqOOSIFLdy_pDL}nF5d7;UXliOo7Pf`gW%dXSHYf^JNV?1mq0)SX zMm12UR3W6*4aOfR6E%6d0VIP&jCf3`LR$(S0yNoEND5_>9lDZ&@y{HKo3{JcK8Rt^ z72Hab0Fi(9n@~bYkV2y_)Fy`HtF#7{J|rojb4e1a7ekY%Jp<T>qu!GtXQ6#>m0qvY zqk05XkPr<=DTomvJ9PBuQB+V+fX0s>j}|Rjgg*T6Llosb@Z|f-K0(8m{He?6zo^!s zgW%o|yBiCa{N=g3_eV+xKc?-B?2)mXBGanczVGz$;(Jq8W!}yB$#d7jwz;Cki@c`f zWnSDHobzK#aT@9u=8^8x_Ib_e#Xl4Y`Zer+8u>-bA6`uVXi-Ep^6uWh%d8KaJS&g= z)KA}qY1=qz((;kczfDdZmcI1pls2gC!tgBV;pBqfKiK7u7MDbR)&C>$gyc05A7uO} zTU6zl(L392O7^D-J^u?tL2<ukc@O}H!8r-x%U;eYYI1M~iHblkZ;QnY2oTAzCLA`w z(+;_#*|=1Myer34$)IYH*p5L5#yak_J22KM<5?Dyj&SijTs-|SLJi1kDi8A8rB5=R z5y<RDL?GY6#YZrpV~V@X9Przvf9|x)LSOJm9>G}Nl|dGb6UZS!lq5p+9>gp}0$|zy zkSG#qbPA<fTZkALN)~>fg3zp?lIyJ5j#n!UMW{%nE-W&j!ZI})Q-KC5ph&MP(<)Js zTB%fN`{MEmC|{-4pi+ZEZ<v6_uqdTPy75^W#RQGI)R0<cFzB?TXfQVrN>QoGP^zA& zLSxF+rRqEl+hmTqSfx>GRVc3zjiF2!xFY<5N}=@<mM}8tN>HB8fb_IYAXlu?mZ7o| zrNW>xk}{1xtqwkmRR+Z{LK(lMQ+^9H<w#wOdp@Ruz(dFAZ_=@Tq^eM5NS$C%mFDOS z3Jp@~$}rmmi_#;nEJ4hpqEMlReorXQ)3E}=rC8*IG$$XZ(yJ83DkTCZkcS%>0Gff% zJX2#B5lWP0dWAs^!o=T2Duogl*TKM!LUG8TsxY9=AQJ=bIZ~7vbc1o5C@Ly0DylPi zB6X=;AxGtErAn8jC@Te$;}vQ{nof_KL}N>PDKwfqMgBNcpw_5zCX}d9MX?4f1q5BH zQjIf;K8tpwpGg@hdc9%-(x|kBAc=g9I)9w8e;9<cHWar@K1=W?(rL3*8kGXx^eQ4B z3IO(&l5bF#tB^)fY8a>k(1AMm0;^LIo2w|sWvCp)nqQ>Q7OIBoG-c3dwN`BaqJ6M4 zOw%ihS>0nCrK&(trZKR9V0>jIgTY<~VtawF!NoeAp$Mx6j|!@8ZhRE#47wDpaxk_w zZ9bB#483$(tty`=BA>qE(!oTHNMSH2@{4Fs^2!PdRC?S%DtRNC0b9$_Vc`%-0KWsl z4tpyM3N%(xt|-mdt4j=V07SGG+5vUw2tQ$nS`eWC^bEjRP@go6ZIn-bkt%;2?kwgU zO4Mu->COPIH>?q}HbxaOMi1RbgUQ$i;+&MUN@8Pb=p;x%p_xEbqg59ZRT$-mKTO69 z!yNNKBTkW_Sd)Vd6GVm$l)xKwg@qbbTA4-zomHu{D2EgTnM#5}(?In_K|MQ0b&T%O zv0GG-P9IbR152e3<CE%VP!$vXWM&RVX_|7(g-Rb(9uyrJ)iEe<0<>=^iR;{1rz?#t z)>Wug`QQd3^L53YQGQveL060kl%kTdQtS=buB4W!HHLm#TBTH%Vl9C#4A_6@i(xPp z0H1>?=P*pb)<C7eE&EZ5`f7CJ(`ZGh(XQwlHH$R0A;_Q$8m87Nb>mTQ;z)w9I8i3J zGPPErp<mQ0gD8?3_Z2_J7(kw&Z#^2L(3BJ@Kw}!DR?<OdR0@nOoko+1!PwU_gK5CQ zM=4Mx^rFZ!nml8WqO=6tGyaI>tgE+fycR@b$bnIc#*`@ZkZw?a&b6jj<qsb?0O21< zNOXGDFaXB`ocI;MC{^J)Y?vS>eW{^Wky@if#fot%>Nv=V<QoYoFj`eU8EUvQDy;&f z1--=t<Rp~9h|{a{%D||R77zL|y#^VI%8K)}3NA8{*r6;d0TF>B$=K+nQI}A85~NO@ z;yQJrXo!Rj&atr$y{rUU0DqzfQ5x9-^=WZ&iLR8b!m3t6j%Nl|TsjW-XP^RpW0y9R zhP+-d-V8_q17$oKlV7ICVlAL<ix)moLTb`ronAj7IH7ZDQbKBW64;h1E(nSdE(y}= z3_%5W=tiRPdgxFeGV%=iGH^8t4UBFY581pkZ!A_XHUtuW6-wm*XhfwYc9I2txD*wG zptHCDqtq)3vFYGK;vh&VpkXTqz2kE7T3VI|feZ%s0Nr?%z8CiDSlw9d^W9C37$K){ z)X`;`07)P@h9@JR38|{DsX%}WguakNi-h(MF~TxCWRKHc7pM@C3W2?hv8b>kB!tps zE=VF0Ble%j&I#b{0T@Z_2zhaKCjMnF^;{`HJ&_4XA`*&3d`O3Er%bk5gd~pmH+)It znbiW+kwX*{M7GXJ?zGGS*{0%58U#Gx`7~4m%Z`L)7pW(%aUnJJTn)6*ft2iR7Iw3Z znpPZN@N|_gb3zg~qbxEpv+g2+$k8dl1mz*ez4H_aGEHSIXqm)a$}99Dg(4FOJVoT` zF71o?!4380A$b2cghV3(70zUH=6T58JY;@}r<@RyTD0u*Pmm=98RR|u-!^aAaUUze z8>@VclI3idkLdT(+Lr%Ko{SN}U&;q{HG$&s0FdcqSlJvH{+vyVL<BUy8Bix=?4P7n zqOWO8`5+hr#yT)i1{<>nPq<EUQi@-tq#&T*0E`)oe1UC|KoTe|Bn9rYKqz9IFj#A8 zAub)o;Ey0Fl~o|MQTpiwFx;mD^uoRZv)9@vP8Zx05o3C{ApnXhvaiK8f##?-z=New zE(x($a*Cz}ZA=AirOUvf_46cMY7JfDi!PYZYL|_hff+j@JuF8oAyXfMS;_sAo&@uI zLJ4@vU)CSc(@K#^E$yjVVohq{ke#W1T3YJIRFA8}EEHv|wa}PVIbU`ETw~2Z{c|-a zn^(iXmA-AEhYC3X<47j45GpQn@MQ%oKrEEKFMT(`hzXuV<dBY;Z;M#bz-V>?r*F@f zI(GNCT^@`l*P=*lge0iA*jh0`|H2;4^c3_8_W1AAc8TG87F^PSQ{+oVDu`nU;@iG8 z;vq}KLoA|{0}~NhXPUk|O<%OPAYVbc=K!GXi+oKrPI6A?=_HQVB5DyGY*<7n&muwz zb_bqCbdZ{0Y*|FGr9}i=TSTyJiwL%~i2wf{3jYe@=PgD%vZ``2+9<CooQ<JIK=T&O z04<oYq9QS);?z8q=48TAG|4dRU&t_wFT=3^*{F&qmJwkl`(VE8Bg|yaSpznz2y0Y! zSQyL9?JB}dR}szYD&l3jiZIhvMDx0eXhv5Y6_b7<{)K)b`1*->75(sa(J|3?zK`XS zCPH@M=z<8-?L@qnB$6O^CS9QKQF0gO01Oe$hwvg0F;ZM7;PSCftU5c9FPeN}92aNX zJ)&6AELQYC!iqIZVxz4R>u6(Q%}049n>O|k;1Y;#&B3~48`DlBDA67UcD5!;=cNR~ z5z5oqnHR9%RmAkAw8&i4s#egK;)3&KB;EQFr{9-OUIo1A6c~MXkx0^m^tGpyrtWc4 z5*?grbm+;BQz-F5X2{S`cS$@!iI!UM?vTwXBb|=$7L*zfFd>oFNN7!>)a)~f&L*o# zBu$o*Dpy)1BQ2!#BLIGAnzzNWWgo3FGz<}5Q=3N&Ld)DuR!&)>O6ir2rwgqaGZer$ zPe}GAC4I;<P0mevoQU*8iS(1~m;e@%n-Up2-8T`_p2aeUaY9TuR{T)t5r}oN5b@ne zh4}zYPvj}JAJI#Oq(7a7Buif|Bp~1I|AIVq_HJ_A$W)$na3hmHQDmL;|9lYIQ=QvW zoev-ah(ulJk`7K{Bm;?JuGoQM3h5-ztiy6}cwXjfPzZ^_(HF>C4(UcYG&kSQ<n^i( z+fOGRGwxCsZm2jL$E*Mxq_feT(Sh!SH)^>C*iq$#*dZPR6H|7GI$(EUZqD<)EmqGE z5{9GCc>STP37J;w3t2plEqN#;ZX$qVfse+8N}5XAA?!kung=sUpcxnFfSnvE9|X#A zru!@qgVd-snJs3wr&1dnN0c69OC2_K6w$omI*~OLPg_;d%~Ulrf^z5x8e;N&&<it& zp%&l6C`KH0g6TF4kB0FKxp_;&E$HB}3*d>^yATxs&TCd(CJ-oKnKR{%vS@4$o+Gkt zxBzVWE=cmaskM=^fMpWID(ZCtJSv+o5Q#sz&X1M_un~|ep=t6M+DfjeoEor#mgiZP z=V$XGsdByxKDJ;t7KwCuW6@0p$F@L-ZHznszqW=~0ey{u*BCkBAx8SrP)!$wW27|5 zHXo#g|1AuYm1L`0VPA?1JoN<QrD0mwH^7$h1esZv(X+QBq*O2qC!Vr^JX_O`Lh>wH z!O&Q!<|o|V)H|xB{FO2q7z+qVHPmGUurNdj#8o=5l`+x)Ykbl<H|$I$YGWY>XKxu} zY1pIn!8U9Xe8ph7G54UWcVpXwuyBQ>l{AyLir$j2H2_niPKMa%IEhA@Ip2e~ql%Cq z3>gTiwx+y>&JL`{1@#X+v2#PHt*JY7mQkGTYr7jPw_4z%rH#E%@WWx~3eH4``?H(? z>9TFkid>wHRwdx)Sg$mT(h^a1FwUH?#3Z4{*;2qOio%A82Acs;1;+W-c$n|4BQynB zW>)?-axt3wM7%6Zvz4a2Bogx+S4|7cGXV%KC2S>9mm7|-Hx!`eydmpUtH}s_so&(B zE2T|s)dAU=h3FEJagx|=hb$_H-SCbWfR779LVWVThoM4#LvFN2y^QAgPT1ez5^!~; zl!+lCA#cKE9)FFQ25~^m1z`(hgN+S}EK?!}zRw1Rz{V`uf&e!;C)O>n;hM$S#sWTS z87K1jZpJeJWW2|7;S(sAvnY<dOvg#?l*xA+gC*monbe;!0YHp9^+AXYut}^rd=$V_ zX@x~_o{)%H<qk9uS1=z@LgjM$TOv2xVFV>eNHM9RLe4ZRvd)NEI@U5|8|ugIm>8*) z%Xx#>#dM|vvCDS@yAV4XKnIFN?mQ9t<jda$2ByOiQ(RgIlQ4|-CXw7E5tBLJ&w9@t zT;N#rfjP;yWL(ef82n#SNtQDv+uPyVDjD5*CAIJ)nL=u(@@hp!T*TH+<JCg^b;B#0 zB9WavKKclOcsenT8QH$neZP&Z(Z$3OK+Mect#LM<`@oW!7W|T<9%J$}3hg*l<86KN z1fen_7rOI2i?lqO=p-50a<YiXZ<b^ZFZx-}U%;CLB0l(RD~}Cx0&WkTK@!kWK0c1H zknHQ084QSuhD7(qWQ;`DccE59KkWD)B45r<>7p-u2<ZoC&KFB@u1FvfV=0U5!8c)6 zB=3+u&m(=FKbSS-c^K9>uTI5g!rSAg=0sTaM4%LmVC+_ECIlO^vs4JDBLZ&EVS!{J z#9?oX!&jhCh`|D!%Px{EmMoFHOFEUx69E0k3%VG9WIO3(m4I$`E``xZ`m&5&SP_Z@ z@=P1`%gOZNJ@Xi40aI;j2bT{6FDuwJObgVE`FKMaJ1Z~Novbho|C&T!TR86<aayoA z%Q24RJ-RhvtM!$ZG*%gD_?l>#cN9cOdLp7vK^BoISnGxtn8HG0&H;#R4W6qxVVEbs z{H+x}c<sx;+gpLJc^UXxEAVx;!ToKe92DaNqev#ws4pq9_lANHOrpr%i@Z9}u>$g1 zpG_0Fp2+tVpg*KBj6CTEJK)phF7v2Ea!<3fS#%hwmFNUApVN~*M<bIm=v-wXM6zn^ zPUr^{U^QE{=T;s1(FG?AD3t_Q&t;6O)n<V0n*kJB0<N_NG-XrJSL^}!=fV(b&uP$H zYy49d8IlTc4F2Ya3aO0pbdYKF!6ZbC4PQHyzc|Jb+aR@V7xTT02a+gpd`_$vc4Lx_ zCX$=z^mro~T$}BfOw-pE$yOk3THx78n%$O-<FxUJ8<aCF3OqkD4gHTPuN&jZFUu9o zLb~{hn{lQJmh|RL;-EN>#px}TbN-#q9@OR)B3i*0Q?^Cwv)$r*hsAeC%Bl|``w0>2 zQXo(LOr7Nbv;hWhpW1=MeR(JR7~~L+BwBn9`y831_Ay0{0Bc7Nv0osPNOsDpoQS($ zMI0MjC=#%zNQkfdjKF;^H!kgQMQL*5J}6i8g`5UcUePW&jiS7w-SU~-p)!!K2WAHc zPZ5MsAxU6TEu3ioCT^e`kM0=<x(D-8fm%DT=7h>LS8Fq{L3M8t!#5uhW7~Sz@>ejP z3IDH*!`tGFCrshO&}pF=7Ce_)iO1YlxRqRPL=j7o3a|kQAvy}l>Ob~)mQ>;SB|Eor z#91Xi@+81QB$E=l<4t7)PM+7M$)E(1J#-&NBsPa;2Q_O{LYN2Ar4C2p4EGvsO~7sB zh(u(uLLm9Vj0jN^TeI7&M#QUGArfX%YBo)Yk0xNbvLjsC3F(@X4+%qdbjm7_d__c1 zoJ}XP=E2FAJ(o~#)e<STWr9%r(wwL-&WQ-ve@%lV7-}W_{PSc-m_=*_#_5UYKu6MG zuI&Jm+3llgTn!%Mc;U-zec@|1f#ZXkvF%E=MrFz139&gmN!|F^t1Peu=Gf-lU@`Yw zv)BaxY_YiiAF{aLjK%%`jz!SKH@v{x%JSSa^@~ci9xXtorVq&Z+ZD8!%=7sJmrT5E z3}sG}#Fshu%{1YE!$N;U>-bfJCErSUp9k#7yx8jeHd!3lYq2=Mv17SJz*Uk%lnkG1 zvRq(>+w8J{RRtM*afr_=%Cu~Yzjk1Ch``(8uZ}>4;b?`(B+Y}SR{7#Rl<oU+i5oZ7 zx#QcWlnkGf!!oyC-Z$>t8h6EChRp$6lOftRMFA0$ZuGMvhL!{1Vd4Tsq%M#rM4oAw z9iKIpnk}!>m3x~eZYD)?2uzqsw;en&QKMxDB@J{XKdgB=4P;k@hsT$`6F!RKK!+a3 zr8A#t_WTVyH>G9Y(IYTsW&3TEnRl3&TsPkM+-Hp4=01_{%|?*5)NC7AjFsO!Vw5^J z*E3u6wIEAFM1zzbo(rV=o+2aXPR3A2asW%-_rH|){mt;c-v;mdU!8X&Su^_vJgdKI z5c5E2Cf3Z~H?YV2hw+TK`BUC2ZHyUqo8D*`_V{ShTtv??#=jETnJ*<v4qNdCvq(%v zvA`O`e5A8U4OtA992SWJV7_MdcQ7OX?czAJHJ$WfXMhu=ygr&10Ve%#7Xf_uivSiA zRY;og>X_MI$|1bXVa5AVDKCif@+*5fHKbb^HrG6?P;jBm9rosSX{-zLOxtv=$mH}G z6p@{U<EB$JCla}%{2Z*rv|Jz{TgqI8JO0ynNiLZ`;Ux`60+<URbhp!<$l_!_)7pnU z-RF_8AGH6eR$!@ouv8Yzg@B#nfw}NkQe4=RLdjOtlKIq<S!xTdz!vhs7P4S*R*lB- z8;xTd9l{EQ9nE-)2+A_JI(AE_kRCI^LK{K~xO&_BzC%n)2Gy2$E=Y3PWRPd*GRJAc z?DsU0bhlda&SYUYP19k0mVX|B9;!KK9AvG`iJVVlm+{9*&a->Q{4<9cW?!q!XkIYV zbYN4jadEs{(<1A%-dJmvr;8?@E}HRV#O86vFI#1!m4Cx!KYsddA@y`t>U>C3_U_6* zV06h6lqBwa#8tKtFDF{&>^4`>`2PQuSa3CC!S&y;VBrRhg|Etjj~NR-|BMBCp3b&j z`m@bM@L~K+L)v1=By*W3lE_S3=Qv(qZz|vx{cwSkacP3qTp=OxYIXwt#owX#MXWRC z2I4ic$rOZMx>B<}(HAv2;J%CTl_K!FUhE3bZXyiCuooUAyWx{D_V81SDhLd|?4rFG zijE;@0+GuR>dBh~6`@vD2xS3weSJN0ciGl}>_16wwb}LCM(qXmq6`P_q6`VWD5KtP z9y}e<aEvE|N|>qwYSFCDg{O)>u5$QQ<`O({-1kWbW=~p;X14q7^+7)lR35F$=-NUu zvPRh$+wM{~G~fbyuR10#SEy`oDW84jwe{as4Q$Vh8#nX!vp!!s{l4|b<PDL_vuYhq zRtf%G;&gn}$*RsvsyeUe)Zzx$p0})j_badK)_3Zzu3{N=qKx7&#NOx;4^L;@IdX?e zBm;f95a8Pvx}1w8mRAThEpUwxkdYe6+=bi)4^+N5ZSQ6eGyvLk2Sk%s9+bPFF*gTa zpPgwE1e1Vd44%0&?Z%?o!lpG{`ds{7b+1wU=JlpNYghMKhpu;Mx_0DJ*pW+JLIs8( zw0qS1dq$%*V<e<gSc-k8?Ys7HyKdI-9y#1aC9YhzT=?B`d$n%4+Uyoifx0;X4S+Vg z$)X;0Bx9w7T!-T>6A)paKYtztc{PL;U2Hrgo-;L}^M>h-(x}{F(}Fl2JvbY2XKe)G zzv1*mBbH=O3;Gl)F$s6?v02LTIevi;rUCD$H9)igjw5AA@{mFI?%e~3xeHOC*PCnS z_s~YpI0VFf0LTmQ-@(LNpkq<mS&vId6UmaE@btzeJmo)C?_lvWFqqt3kVl|TuN_}V zV`nNCwwBPgo0_q0A5OO3oNRHaucgI9BiK7+p#;3rL}Y^R*1?^^Y)1t+r_Q+lns$%q zb%(E=dxu<|C5ev8OglE$#k))7)rz9FA>X8|S(sH6w)^49?S?t6rsux-nX{<hx`MUy z&ZVuN*GkapGbSfGXl|c@b6r}oJhbF^@MAgiTn;|QA5CZ6Kx0~^Laz*p>OQ7xcTjO4 zib5%<6m3C=kQY<HtYaFPPJ$7F&jli3JE6NvqhKqV6o?*V*-w`Re1>II>$u&1hb&+- zy1(7NxC#mm*bQeMWeGoN2<(Q+LxtZqxE??i7nlpRZmm$f7jv`LUR9NlgTd!i1uVlP zZcber^Vab9D?*uj@om0tK)DIt2If*N;7$Al!;P&<=!hO{2fV~WO!BjaKp2<qu1v}> zS>ORQX&ovbE<9HP_3;{L$MrHM+5l|a&jOa9&C9uzha0&-E50NBF25k$Cv!cE2_BHS z9zo?BfoIweXpr=AeHHKwv~EMM-}GW`<=W4v;(AKRy4j)l9NaZ;1Y`-z6&sn0xj?pJ zIBw<$Zia~GVHOqz{w7_n0g5?H<NJ5!fe@6?ma2-GAluXcLgl#r?H!;53?zi0N82$G zT!oSEOa&!C;Vj`P8Rj(v^E#DqmSsP;0fY+Q!0Bg3PA}C0rwMr&`S_XM%)`1i2V`!d z;|UsM_p@LF79Yse2lL)oi$%n$3Hk;iE5;(b*Mo8Z-PkD$m;)_fV&B=;^$mAGO7ub% zdvFi1YzW)xwP;euLjb=oc0nt|lzw^&RlK$cTAEr2_<}!}QB_2WZcYdkN%~HecZ3=c zC>CtQOv*%goIoeF=mCQI`sf00#FQ{Yapg`Km<rWA=?17U4_gV>&7TiZr9a#b62OAn z&e=44;$C9CRG>}9k9ZA2olqp|3<D(^#h_T!1$9N;P<PY=W`=PHDZ$Bv!hbKQjDhhK zWAWchf|~!2&}7dA2oFw~VAm=ftDBOAg0VPupsBrtY#DxAH6NkBlkgi8XI*O!XZdCe z&eq$875HsRs&KMH7`(JXh4+K(?@JoyMf*caFmvY2CN`l6MP_#i)dMI3w>@~-k8Y9% z&ST3*L|@&W8^77v86`V(0e}Ex=K(IK;!=LD-;2g%*Bwo5?>1#lxiY!q&yq*8qlKfc z%c@hhj@jt(;rH_|uW>|f2cu8WY$Fi-=VtJqOs@cRQHE$%)}mo^$vUZbq033u@3rRq zULfat0}#$zvVeI<sEY;m-Mupqb0e!qN7q)uDKY?w0FYn+sW5@KM0%fy{%c2Uo0<TJ zKb4<%kcNwI-YMumDD9m_XsHGeLO|P~Cz37A7rQdhw6mZJM@#0tdEzu7G<v8C^B_jE z#9|Sx#+PpiAlt*IR%T(KU|c^(?8DXz$n{+2|IOfo%;BAEz~eCVJ3QNPqLAX4jRR^V z-rPA9*I9-fOYN)fB7BS4y}0AsX~@TdinN1X9g2(ML)3RZ@{ruF^q$z&9&&}fcXuN} z%@i4}{V;4!F0OGf)=b|{YtDB)R)VU<u1-*Mh%sa#=PaZ&uX5q49Mxhzy?QaeL$AFX zgfX9~Oe1&oP`%g>^XLJxcV$@knZbuj=$%9)syjFe@Ch(GcSt2FE^S+qcp@yt>)=}+ zp7Rd1*f!OzHYLRWk%PPAzKkx)xrM&N)@G;oJ~=0&(<hHkr@wnSY)^e>pWs=gcaHA; z^6=hWPd2UUC+}7lTOZrh)HBxq*b~>f!^*r~5Q?`AU0+$>`HzW-Yeq)aO_4SH{pisn z?|V-w67uRUPJdADbpD?A=#PEp9l0&oayDb@`FoY0Uw)oEG|*XGQh%MXuT;JE_L-kV zpI@H$qD{}+L$}->ziZ^=aUb3Zzkj0y^;?`<fBnpb2jw|uewBti%J1gq?07;vEu}2r zVnu@M#rtkc=N<4%-w>PQH2+l5Hxu`cp5Yt5)bWqGaf=jwKh$-(Q&1N?>7CyW-dc2S zYEg^qP49l)|EhNRIfwI$4nB^lcHVk^od2mJ=Zd6(J8%5`s3QG9-k{s@D_w8D5pW{s z_nV`$$It4$w&9J0Q3rdT3i5We8!~xQ&f1-6ZioIpUGw&By~ErCQy+SKmp|~0>lFz; zes2%Dcjxib+-^1do<0BY>7a-ckE2$fP?t#USFe`-@#mzZDObYI-6+}kJl20+-nOCZ zUMvj^jb14~n-mgXJ>VN<jQZS9hRIi2e|a^syT8k&&fmY0w0e`z?^SR0T6TBY<EMMB zkKOs=vFjyGx9H_Z_LcPb;Hw>hcbEU(>e7SH-b-)$x6j<$N1m)ZfA6&oXTqlMSIquB zE99D;zJB=P%UjQmt$(^}Y^C7NUbi{ab+qG#f3LQD*HK%tQR-vwQUzA?jKOD9j8+pr z_vbA4gU>@8yM^S9ThqEB&2EQB@{~C~i^pj{9dueUHCGipYvZ=zug(2tSep?a);)Ya z-`~5>fx5!C2j(t+^Ycqnf`dydW1FgDPZd?3?^sY*?KX3N>aLN?ChlGJ{e$uuc{>i- zPfMA5Sozm%mx{fkcZ~jc$%FF#ADxewuy^#`<ws_09U8G?#5Qq4;EAT;yRQGb<k@q1 zLu1&Hn4T-;Ka_uYqx*`%+AjVKnAE7)b3-odzaeYeFJ#-$x%Z#E`N`!6S!W7e7yX$Z zjm>6eYH-(&wm0m!KPE&X`1ahru5lNNy4-v#Y4z7m>$4r6*{y5{>$+}`&)$ogkp6{L zb+u1tC}TD~%-(QjU(bLAeU)pj71XWKcqRJGU9vA%<}=ss#|a66*-5L1JuUxoUP95Z z;XUj-9y}n~|M$KNlahvYN#8Y6es)Z#SIN1P(@uAI|5lG*oZ@SaJ-h;@GJM&PJ9nNu zi~h5+e$nfZ%Qr4n_$h<Ct&|^D#sr_Zv*hH;n=9oTCQeRUH)v~4_=RM@?*;ZlZxjtY zntA;|?-0eQpA2LEJb0tz(9RJqcU<orzf-r_u3Yl-X{o+jjmrhiXOn-ay{h$%t#)qd zI&)*|ADQQ;pS>OLb?Z?@1DMc%n(qEF@fz6fqV(Pw8_r~hFZH}z`KZh1eYTu^@!PMP zpCT7u{}^f}9gJqu-lmx}IRulqCouYb;$GX~NHaq$WPkwmK^MT9!i?55c;J?lL0*6K z4Q<iy!|@GnQ7MOeS5Ao#|C}gnv0IoC)<)P)5#A>MryujzI{$jKq5F--kksSxZ$3G` zt;2~!o6hdKT6g}^xL@lQ$e&znH+<XBFsbX2+xlw5m!nSqWcVR(N2uMjlzn+S_S~A2 zv^sOs`Fn<)BTk+9srRo>;%`<YoIa4ZCTGi#Q}_OOad60+djt25jP&xkzj^cN=arc! z?!>;xUom#wDfh&{6Lp10kL<eqV3}v?-HCh8p;eV#y@oExjj8T2#&JgKrJg0-Yg}&L zyI0eGN!Y{r!y}jb#riq7t-pTaseV(=*Aw@3xbxLbVXg1cn)lP&_E`Pt<>LEiw4a}; zIDuAP)Vv)ChJE<XWB>ZIV}o1o=@sDa)R-{;C&PD%3r9w7c-q;^@xr)`%<nyWOzz?z z+<u9}w=Oe#_4J=N_PLWtQ1NF)!ly}0#pvVqSG3)~E6C9A8hPn?^|6BW*_(2oZ*S;; zZXUc9{Y%FVKiBEn1uk$BPrGsA?;b1VJBMz$F{;;<8zr*NkDp2lCBMbEbgelyr~J$3 zx1HmpuI-i_K3Q46VDH<Nvc31eQrBI~$=mT>QQgIBU$tI$Ds<OXZBNhH3k`7t!FwM4 zv47sBsiQw`dRTh)Ihwe^a~d_3aHFY&HDf9`8HwN`a5!Qu;}%#(N0Vio*uo6*`g1{6 zx5b*meXVn+EuQzcU0TO?3l+WUqSn8=bjITCOPB8K@^r_bWp#BAYf7SLEqwM%&%M<N zdkb%$`{_#cv$yU{x^tzpZ1;)C<70O^-Y6L!zWm4smme&aZ)oE^w@<L2vmX3p!15<g zC+YW&-mvBDoK^A;6YH;^nt!m(sE$7Rog;4V9sTR%k?YUjJ9XrCs$$A8uNl8Qd2?dY z>PM~TZtCLia_!cmJ!8M!6F&aStJ$fNQ6HaQG3CS6elc5S##RpqA0r{AvF=pozs2<z zHKF(Hep!B`U7mQ_l*T8|hJ2M1zI6NOlbdc14)f@lyM1QGR{IN19}diDza*TqkX~P{ zXtigzea*3gjW;IlT|6o2<43P=^Z701S?r5yx5~JcoBh)xm!J9F*U|2N*YD9I=Go@f zV^<7lKdY7N%<PUnXa4e)h#ua5RFONW5xwZy{XeIQdh0%KrHXC$#mLA9FOC+}jog&8 zy>fVM3+IQo9{D96nf>VEXn9-D_xI)gr)#o&!{AM4$5x!LikG@>R3)vx<(x9wr`O?v zx;<C5O{L-h*O~7hRu<J?KRCKqa_#8y>z`iKeD|p0{m(CIbk`T0D)PFb{oHGI@ASBp z?bn88XucBp)SS8ZN9)RucIyr_x^|#O(#dEf9baN3k(`lq;?@whfRS`2>oa(3w>^U( z8G;NAfP}~s=W@QdScEgR_r8=Nr|fA##%od8G)@eO)q(D5L8z0=5%Cf$d}}2OA|W8X zF^F#iFD=7YsMd=y|B;Sddgd~;u@mCK&?{E!#eo>gnS*i~IQ1m2Esd%G!-QZMSDbiq z%<>2sFFR#h^gzA<x0??~(ogorQ@Wzoz6Iokeix_s8Sg!<7vtNL+k3+t#Q*b#G<rEK zUEXZ(1BtNz^M+7zS!}(BH<2Blta-kZz`K2v;cmnYhhZz-RqJNFla}F-I)bjG+Zx<V zSI#nIib0l0ySahRq)31lfAAH#^$1UQqEIgC(TE~~xMjzA*S1zV_}U$vuY4R<-KoF7 z$K7G4#;xp{vSg)e&(m91y!)_(UHpnh>C82hU|g?s{WV}mbgTK#ceruOOfj6{MDrJ) zV!6^5v~;pVdw6z%X<Qe#`wrXZMKS1*#Wc=%jbxJpOmtyp%b?|WLgRq;_`*!-UBt_@ zp+bl&A{Qg3D$BgWj;m-0HLtMeNPU;UtDrph$Fd{F?n#Y379Ebg)wkv#swFo(vgJbP zg4a|>6R-7R7di^MB2Q%&x%H9~#H-8QIUz(Ln45_OAge<!evu*Pku#L6t%#siFUL;o zZI^7J0~Gq$wU*KQF4;m?Qs^zCH)6t6rv-FpUxTO$tw|}O{rM$+ej{gZ-T>~rzKY(Z zN$kU;1MVY}0BlLWpOS+YO}Wd789{x0eG|TgoBS|sCOf3TYY$LYg8hB>#s`+_y5EFy z)CP?zNLLVKC{hI#Xv*>By!Zl9Y?VO+bb3{Bkh&x?G7?nZ1~7U8t+<1>X7Cr9P*hA@ zOf<x$7|3VhO!@DTasGq6zMbaoackOt(4*pqGeYLf+U?;zEYBz8FE_*L$*FhKcC=bD zqfyv$l5)|E-KS?b&i^8#MjbsnWA4JYep>tB<nA7c!`xR?@4nY?`|B&uR{k1aA6u&b zZSpErO!eQZ4lBQEth|4G$@O2G0-VLGuWGwLxj!s&`IehKb6sW~$a7zCa6*LCwH_Sm z0@s<-w#?LYd)9Sn#)HVtoiEnZwE8T2)AsY{&uey#EP#xr|C!&9-+6rXvZh<fu8||3 z_ubkAvx>+zizKzKBewZKps5XY6i;Ke4&Bn>%d3@Tm6gZ+=B0g9S(D!OZdT|wxoI+8 z=+X?B&#f8#aj$Jdr=_iXbU1Iv$@eCYi}L&8uYq0s*DpNME6Ba7pw8jFmRg<e$;8DQ zvO?X*WUS9FhWNN3`L7?36+C|PzDGe_%cFNn8&)Y20{1Ipra*pEwDZ!Q0qtMke0J<d zFYNw!=ls1HhPdZ*o{p)@9dsge>36;}QujUXdwq|5!<T*Ees*R2`0>y7UViX(-j1q2 zCO&6&PS`Pg&$~x%?|G3J=mtUyJTxi2e)?M*&Rl%_>yu~Glc(L^R99CwFDLx=ql49_ zeSLkMV=51<-k$vM;5GI4x;NhV!}+hp7n4G6B~HHC?~~U5@tu31aCUEf*~E$8&FUR; z?a9oyI&W`U-FtGb{9H+o=@2;oY<>5#r{j!=ZqHro>i7MXyK}^XNA^D~_mPOMM+t}3 ze|_=3Wb&TU`%SO6(2ZQZ<J%ioTQ3?Q>qf&|yfMthy(G*fa6>Yl^Hx8=GtqqH9}^n3 z?n|l4A|t<=x|*Yb?<6<<7TA&>f9U>1dpj5?ep3Zerh8l2F(?MB_nTf-LE=C)bwEc0 zd=pU2pqcEdMpN>MhiCy_w@5%<Uj>qF4s?{o$NOgP4-e7%Us?WKuxEPeDVi{|B8v^R zB>cGn?UUW+E~#=aaYWFkwhoKc;CAT!w6v!!;h98w>O^~*NS!XbLWOrSlF@Laq(1%H zwQI=TMN<`1aa?+*WrOkuCFk2^oD7pW8IFQy3V04~Lb8bZ?L&=BI^DTJ=v^#E8S<OY zxofiGBLlzaAVj<nYgR%6IBjAhJW~nt{)pWz`d$jL4k4Z($pVrKb<|17Gjs&Gqu02m zL?pBjp+%`|f>4m$fXGF-bTg^FJ?Eia`h^T<FTt%BJ5!&Wg4p|Z+04fUO320eE=Vxk ec<V0T)n)_7((|=$?6w<?)t0UnBm5tRiv$7?Le_@> diff --git a/pub/cron.php b/pub/cron.php index 17eee445c03..1bc57e79eb6 100644 --- a/pub/cron.php +++ b/pub/cron.php @@ -23,10 +23,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) */ + +use Magento\Framework\App\Bootstrap; +use Magento\Store\Model\Store; use Magento\Store\Model\StoreManager; require dirname(__DIR__) . '/app/bootstrap.php'; -umask(0); -$params = array(StoreManager::PARAM_RUN_CODE => 'admin', \Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM => true); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Framework\App\Cron', array('parameters' => array('group::'))); +$params = $_SERVER; +$params[StoreManager::PARAM_RUN_CODE] = 'admin'; +$params[Store::CUSTOM_ENTRY_POINT_PARAM] = true; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\App\Cron $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Cron', ['parameters' => ['group::']]); +$bootstrap->run($app); diff --git a/pub/errors/default/report.phtml b/pub/errors/default/report.phtml index 2d055b164ea..3c73cbebb71 100644 --- a/pub/errors/default/report.phtml +++ b/pub/errors/default/report.phtml @@ -100,7 +100,7 @@ </div> </div> <?php endif; ?> - <?php if ($this->reportId && $this->reportUrl): ?> - <p>Error log record number: <a href="<?php echo htmlspecialchars($this->reportUrl) ?>"><?php echo $this->reportId ?></a></p> + <?php if ($this->reportId): ?> + <p>Error log record number: <?php echo $this->reportId ?></p> <?php endif; ?> </div> diff --git a/pub/get.php b/pub/get.php index 83c079d35d0..297e40179b4 100644 --- a/pub/get.php +++ b/pub/get.php @@ -80,19 +80,20 @@ if ($mediaDirectory) { // Materialize file in application $params = $_SERVER; if (empty($mediaDirectory)) { - $params[Filesystem::PARAM_ALLOWED_MODULES] = array('Magento_Core'); - $params[Factory::PARAM_CACHE_FORCED_OPTIONS]['frontend_options']['disable_save'] = true; + $params[Filesystem::PARAM_ALLOWED_MODULES] = ['Magento_Core']; + $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]]; } - -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(dirname(__DIR__), $params); -$entryPoint->run( +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Core\App\Media $app */ +$app = $bootstrap->createApplication( 'Magento\Core\App\Media', - array( + [ 'request' => $request, 'workingDirectory' => __DIR__, 'mediaDirectory' => $mediaDirectory, 'configCacheFile' => $configCacheFile, 'isAllowed' => $isAllowed, 'relativeFileName' => $relativeFilename, - ) + ] ); +$bootstrap->run($app); diff --git a/pub/index.php b/pub/index.php index c3a588b2f48..a140566bbe1 100644 --- a/pub/index.php +++ b/pub/index.php @@ -23,15 +23,18 @@ * @copyright Copyright (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__ . '/../app/bootstrap.php'; use Magento\Framework\App\Filesystem; +require __DIR__ . '/../app/bootstrap.php'; $params = $_SERVER; - -$params[Filesystem::PARAM_APP_DIRS][Filesystem::PUB_DIR] = array('uri' => ''); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::MEDIA_DIR] = array('uri' => 'media'); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::STATIC_VIEW_DIR] = array('uri' => 'static'); -$params[Filesystem::PARAM_APP_DIRS][Filesystem::UPLOAD_DIR] = array('uri' => 'media/upload'); -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $params); -$entryPoint->run('Magento\Framework\App\Http'); +$params[Filesystem::PARAM_APP_DIRS] = [ + Filesystem::PUB_DIR => ['uri' => ''], + Filesystem::MEDIA_DIR => ['uri' => 'media'], + Filesystem::STATIC_VIEW_DIR => ['uri' => 'static'], + Filesystem::UPLOAD_DIR => ['uri' => 'media/upload'], +]; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); +/** @var \Magento\Framework\App\Http $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\Http'); +$bootstrap->run($app); diff --git a/pub/static.php b/pub/static.php index 174eee22ac1..2365fde3fcc 100644 --- a/pub/static.php +++ b/pub/static.php @@ -23,7 +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) */ -require __DIR__ . '/../app/bootstrap.php'; -$entryPoint = new \Magento\Framework\App\EntryPoint\EntryPoint(BP, $_SERVER); -$entryPoint->run('Magento\Framework\App\StaticResource'); +require __DIR__ . '/../app/bootstrap.php'; +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); +/** @var \Magento\Framework\App\StaticResource $app */ +$app = $bootstrap->createApplication('Magento\Framework\App\StaticResource'); +$bootstrap->run($app); diff --git a/setup/composer.json b/setup/composer.json index d69927ba5fa..639c6f37b1b 100644 --- a/setup/composer.json +++ b/setup/composer.json @@ -1,5 +1,6 @@ { - "name": "Magento Setup Tool", + "name": "magento/project-setup", + "version": "0.1.0", "require": { "zendframework/zendframework": "2.3.1", "composer/composer": "1.0.*@dev" diff --git a/setup/module/Magento/Setup/src/Controller/Install/StartController.php b/setup/module/Magento/Setup/src/Controller/Install/StartController.php index f70ca86268f..1a5ce07b640 100644 --- a/setup/module/Magento/Setup/src/Controller/Install/StartController.php +++ b/setup/module/Magento/Setup/src/Controller/Install/StartController.php @@ -29,6 +29,7 @@ use Magento\Module\Setup\Config; use Magento\Module\SetupFactory; use Magento\Setup\Model\AdminAccountFactory; use Magento\Setup\Model\Logger; +use Magento\Config\ConfigFactory; use Zend\Json\Json; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; @@ -55,6 +56,11 @@ class StartController extends AbstractActionController */ protected $config; + /** + * @var ConfigFactory + */ + protected $systemConfig; + /** * @var AdminAccountFactory */ @@ -81,13 +87,15 @@ class StartController extends AbstractActionController AdminAccountFactory $adminAccountFactory, Logger $logger, Random $random, - Config $config + Config $config, + ConfigFactory $systemConfig ) { $this->logger = $logger; $this->json = $view; $this->moduleList = $moduleList->getModules(); $this->setupFactory = $setupFactory; $this->config = $config; + $this->systemConfig = $systemConfig; $this->adminAccountFactory = $adminAccountFactory; $this->random = $random; } @@ -112,7 +120,6 @@ class StartController extends AbstractActionController $setup->applyUpdates(); $this->logger->logSuccess($moduleName); } - $this->logger->logSuccess('Artifact'); // Set data to config @@ -120,6 +127,7 @@ class StartController extends AbstractActionController 'web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0 ); + $setup->addConfigData( 'web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}' @@ -163,12 +171,63 @@ class StartController extends AbstractActionController } else { $key = $data['config']['encrypt']['key']; } - $this->config->replaceTmpEncryptKey($key); + $this->config->replaceTmpEncryptKey($key); $this->config->replaceTmpInstallDate(date('r')); - $this->json->setVariable('success', true); + $phpPath = $this->phpExecutablePath(); + exec( + $phpPath . + 'php -f ' . escapeshellarg($this->systemConfig->create()->getMagentoBasePath() . + '/dev/shell/run_data_fixtures.php'), + $output, + $exitCode + ); + if ($exitCode !== 0) { + $outputMsg = implode(PHP_EOL, $output); + $this->logger->logError( + new \Exception('Data Update Failed with Exit Code: ' . $exitCode . PHP_EOL . $outputMsg) + ); + $this->json->setVariable('success', false); + } else { + $this->logger->logSuccess('Data Updates'); + $this->json->setVariable('success', true); + } + $this->json->setVariable('key', $key); return $this->json; } + + /** + * @return string + * @throws \Exception + */ + private function phpExecutablePath() + { + try { + $phpPath = ''; + $iniFile = fopen(php_ini_loaded_file(), 'r'); + while ($line = fgets($iniFile)) { + if ((strpos($line, 'extension_dir') !== false) && (strrpos($line, ";") !==0)) { + $extPath = explode("=", $line); + $pathFull = explode("\"", $extPath[1]); + $pathParts[1] = str_replace('\\', '/', $pathFull[1]); + foreach (explode('/', $pathParts[1]) as $piece) { + $phpPath .= $piece . '/'; + if (strpos($piece, phpversion()) !== false) { + if (file_exists($phpPath.'bin')) { + $phpPath .= 'bin' . '/'; + } + break; + } + } + } + } + fclose($iniFile); + } catch(\Exception $e){ + throw $e; + } + + return $phpPath; + } } diff --git a/setup/module/Magento/Setup/src/Model/AdminAccount.php b/setup/module/Magento/Setup/src/Model/AdminAccount.php index bc882ddb135..6d3b1f60c63 100644 --- a/setup/module/Magento/Setup/src/Model/AdminAccount.php +++ b/setup/module/Magento/Setup/src/Model/AdminAccount.php @@ -102,6 +102,7 @@ class AdminAccount 'sort_order' => 1, 'role_type' => 'G', 'user_id' => 0, + 'user_type' => 2, 'role_name' => 'Administrators', ], 1 => [ @@ -110,6 +111,7 @@ class AdminAccount 'sort_order' => 0, 'role_type' => 'U', 'user_id' => $adminId, + 'user_type' => 2, 'role_name' => $this->config['admin_username'], ] ]; diff --git a/var/.htaccess b/var/.htaccess index 93169e4eb44..896fbc5a341 100644 --- a/var/.htaccess +++ b/var/.htaccess @@ -1,2 +1,2 @@ Order deny,allow -Deny from all +Deny from all \ No newline at end of file -- GitLab