From 02a9a0eafe3cb8b07988721e8c221627d2fb7dc9 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Tue, 18 Nov 2014 06:12:45 -0800 Subject: [PATCH] 0.1.0-alpha104 * Various improvements: * Merge SQL and Data Upgrades for the Sales and SalesRule modules * Add getDefaultBilling and getDefaultShipping to Customer Interface * Stabilized the Bundle module * Stabilized the CatalogSearch module * Stabilized the Cms module * Stabilized the SalesRule module * Performance improvements: * Introduced CatalogRule indexers based on Mview * Significantly decreased the amount of unused objects, mostly in category and product view scenarios: * Got rid of non-shared indexer instances all over the code introducing Magento\Indexer\Model\IndexerRegistry * Magento\Catalog\Pricing\Price\BasePrice being created on demand only, instead of unconditioned creation in constructor * Created proxies for unused objects with big amount of dependencies * Fixed \Magento\Review\Block\Product\Review block which injected backend block context by mistake * A customer model in \Magento\Customer\Model\Layout\DepersonalizePlugin being created on demand only, instead of constructor * Introduced caching for product attribute metadata loading procedure * Improved SavePayment Checkout step to save only payment related data * Speed up all Checkout steps of the One Page Checkout * Updated the benchmark.jmx jmeter script in the performance toolkit * Fixed bugs: * Fixed an issue where performance toolkit generator created Products/Categories without URL rewrites due to install area elimination * Fixed an issue where the Custom Options fieldset on Product Information page was collapsible * Fixed an issue where the Base URL was added to target path for Custom UrlRewrite * Fixed an issue where an invalid Cross-sells amount was displayed in the Shopping Cart * Fixed an issue where the Mage_Catalog_Model_Product_Type_AbstractTest::testBeforeSave integration test failed when Mage_Downloadable module was not available * Fixed an issue where the custom URL rewrite redirected to sub-folder when Request Path contained slash * Fixed an issue where it was impossible to place an order if registering during checkout * Fixed an issue where there was no possibility to save default billing and shipping addresses for customer on the store front * Fixed an issue where a widget of Catalog Category Link type was not displayed on the store front * Fixed an issue where the Versions tab was absent on the CMS page with version control * Fixed an issue where it was impossible to insert Widgets and Images to a CMS page * Added the following functional tests: * Create widget * Print order from guest on frontend * Framework Improvements: * Removed duplicated logic from API Builders and Builder generators. Added support for populating builders from the objects, implementing data interface * Processed GitHub requests: * [#674](https://github.com/magento/magento2/issues/674) -- Widgets in content pages --- .gitignore | 4 + CHANGELOG.md | 41 + README.md | 84 +- .../Magento/AdminNotification/composer.json | 10 +- app/code/Magento/Authorization/composer.json | 6 +- app/code/Magento/Authorizenet/composer.json | 18 +- app/code/Magento/Authorizenet/etc/module.xml | 2 +- app/code/Magento/Backend/composer.json | 34 +- app/code/Magento/Backup/composer.json | 12 +- .../Magento/Bundle/Model/Resource/Bundle.php | 4 +- .../Bundle/Pricing/Price/ConfiguredPrice.php | 2 +- .../Bundle/Pricing/Price/FinalPrice.php | 3 +- app/code/Magento/Bundle/composer.json | 30 +- app/code/Magento/Captcha/composer.json | 14 +- .../Magento/Catalog/Block/Widget/Link.php | 11 +- .../Product/Action/Attribute/Save.php | 1 + .../Controller/Adminhtml/Product/Save.php | 2 - .../Attribute/Backend/Customlayoutupdate.php | 4 +- app/code/Magento/Catalog/Model/Category.php | 72 +- .../Category/Attribute/Backend/Image.php | 7 +- .../Category/Attribute/Backend/Sortby.php | 4 +- app/code/Magento/Catalog/Model/Config.php | 4 +- .../Model/Indexer/AbstractFlatState.php | 32 +- .../Catalog/Model/Indexer/Category/Flat.php | 20 +- .../Category/Flat/Plugin/StoreGroup.php | 27 +- .../Category/Flat/System/Config/Mode.php | 24 +- .../Model/Indexer/Category/Product.php | 18 +- .../Category/Product/Plugin/StoreGroup.php | 27 +- .../Model/Indexer/Product/Category.php | 6 +- .../Catalog/Model/Indexer/Product/Eav.php | 2 +- .../Catalog/Model/Indexer/Product/Flat.php | 2 +- .../Model/Indexer/Product/Flat/Processor.php | 8 +- .../Model/Indexer/Product/Flat/State.php | 9 +- .../Catalog/Model/Indexer/Product/Price.php | 2 +- .../Product/Price/Plugin/AbstractPlugin.php | 27 +- .../Price/System/Config/PriceScope.php | 15 +- app/code/Magento/Catalog/Model/Product.php | 32 +- .../Magento/Catalog/Model/Product/Action.php | 37 +- .../Product/Attribute/Backend/Groupprice.php | 4 +- .../Backend/Groupprice/AbstractGroupprice.php | 4 +- .../Model/Product/Attribute/Backend/Media.php | 3 - .../Model/Product/Attribute/Backend/Price.php | 3 - .../Model/Product/Attribute/Backend/Sku.php | 4 +- .../Product/Attribute/Backend/Startdate.php | 4 +- .../Model/Product/Attribute/Backend/Stock.php | 8 +- .../Product/Attribute/Backend/Tierprice.php | 4 +- .../Catalog/Model/Resource/Category.php | 24 +- .../Catalog/Model/Resource/Category/Tree.php | 38 +- .../Magento/Catalog/Model/Resource/Config.php | 13 +- .../Product/Attribute/Backend/Image.php | 3 - .../Model/Resource/Product/Collection.php | 34 - .../Catalog/Plugin/Model/Resource/Config.php | 103 ++ .../Catalog/Pricing/Price/FinalPrice.php | 31 +- .../Service/V1/Data/CategoryBuilder.php | 6 +- .../V1/Data/Eav/AttributeMetadataBuilder.php | 6 +- .../Eav/Category/Info/MetadataBuilder.php | 6 +- .../Attribute/SearchResultsBuilder.php | 6 +- .../V1/Data/Product/SearchResultsBuilder.php | 6 +- .../Service/V1/Data/ProductBuilder.php | 6 +- .../Data/Option/MetadataBuilder.php | 6 +- .../Product/Link/Data/ProductLinkBuilder.php | 6 +- app/code/Magento/Catalog/composer.json | 48 +- app/code/Magento/Catalog/etc/di.xml | 64 +- .../catalog/product/edit/options.phtml | 6 +- .../Model/Import/Product.php | 23 +- .../Magento/CatalogImportExport/composer.json | 20 +- .../CatalogInventory/Model/Indexer/Stock.php | 2 +- .../CatalogInventory/Model/Observer.php | 1 + .../Service/V1/StockItemService.php | 2 +- .../Magento/CatalogInventory/composer.json | 20 +- .../CatalogRuleException.php} | 13 +- .../Adminhtml/Promo/Catalog/ApplyRules.php | 1 + .../Adminhtml/Promo/Catalog/Delete.php | 1 + app/code/Magento/CatalogRule/Model/Cron.php | 54 ++ .../Model/Indexer/AbstractIndexer.php | 112 +++ .../Model/Indexer/IndexBuilder.php | 706 ++++++++++++++ .../Indexer/Product/ProductRuleIndexer.php | 20 +- .../Indexer/Product/ProductRuleProcessor.php} | 17 +- .../Model/Indexer/Rule/RuleProductIndexer.php | 27 +- .../Indexer/Rule/RuleProductProcessor.php} | 16 +- .../Magento/CatalogRule/Model/Observer.php | 228 +---- .../CatalogRule/Model/Resource/Rule.php | 626 +----------- app/code/Magento/CatalogRule/Model/Rule.php | 43 - .../Model/Rule/Condition/Combine.php | 1 + .../Magento/CatalogRule/Model/Rule/Job.php | 18 +- .../CatalogRule/Plugin/Indexer/Category.php | 77 ++ .../Plugin/Indexer/CustomerGroup.php | 58 ++ .../Plugin/Indexer/ImportExport.php | 58 ++ .../Plugin/Indexer/Product/Attribute.php | 158 +++ .../Plugin/Indexer/Product/PriceIndexer.php} | 74 +- .../Indexer/Product/Save/ApplyRules.php | 62 ++ .../CatalogRule/Plugin/Indexer/Website.php | 59 ++ app/code/Magento/CatalogRule/composer.json | 18 +- .../Magento/CatalogRule/etc/adminhtml/di.xml | 18 + .../CatalogRule/etc/adminhtml/events.xml | 15 - app/code/Magento/CatalogRule/etc/crontab.xml | 2 +- app/code/Magento/CatalogRule/etc/di.xml | 5 +- app/code/Magento/CatalogRule/etc/events.xml | 3 - app/code/Magento/CatalogRule/etc/indexer.xml | 35 + app/code/Magento/CatalogRule/etc/module.xml | 2 + app/code/Magento/CatalogRule/etc/mview.xml | 47 + .../upgrade-1.6.0.3-1.6.0.4.php | 57 ++ .../Model/Config/Backend/Search/Type.php | 20 +- .../CatalogSearch/Model/Indexer/Fulltext.php | 16 +- .../Fulltext/Plugin/AbstractPlugin.php | 35 +- .../Indexer/Fulltext/Plugin/Attribute.php | 6 +- .../Indexer/Fulltext/Plugin/Store/Group.php | 6 +- .../Indexer/Fulltext/Plugin/Store/View.php | 7 +- app/code/Magento/CatalogSearch/composer.json | 24 +- app/code/Magento/CatalogSearch/etc/di.xml | 5 - .../Magento/CatalogUrlRewrite/composer.json | 18 +- app/code/Magento/Centinel/composer.json | 14 +- app/code/Magento/Centinel/etc/module.xml | 2 +- .../Magento/Checkout/Model/Resource/Cart.php | 8 +- .../Magento/Checkout/Model/Type/Onepage.php | 10 +- .../Service/V1/Data/Cart/AddressBuilder.php | 6 +- .../Service/V1/Data/Cart/Totals/Item.php | 2 +- .../V1/Data/CartSearchResultsBuilder.php | 6 +- app/code/Magento/Checkout/composer.json | 36 +- .../Magento/CheckoutAgreements/composer.json | 10 +- .../Cms/Ui/DataProvider/Page/Row/Actions.php | 2 +- app/code/Magento/Cms/composer.json | 20 +- .../layout/cms_wysiwyg_images_index.xml | 20 +- app/code/Magento/CmsUrlRewrite/composer.json | 8 +- .../ConfigurableImportExport/composer.json | 14 +- .../Magento/ConfigurableProduct/composer.json | 28 +- app/code/Magento/Contact/composer.json | 12 +- app/code/Magento/Core/composer.json | 16 +- app/code/Magento/Cron/composer.json | 8 +- app/code/Magento/CurrencySymbol/composer.json | 14 +- .../Api/AccountManagementInterface.php | 21 + .../Customer/Api/Data/AddressInterface.php | 16 + .../Magento/Customer/Block/Address/Edit.php | 3 +- .../Customer/Controller/Account/Edit.php | 3 +- .../Customer/Controller/Address/FormPost.php | 2 + .../Customer/Model/AccountManagement.php | 42 +- app/code/Magento/Customer/Model/Address.php | 4 + .../Customer/Attribute/Backend/Password.php | 4 +- .../Customer/Attribute/Backend/Store.php | 4 +- .../Customer/Attribute/Backend/Website.php | 4 +- .../Magento/Customer/Model/Data/Address.php | 20 + .../Customer/Model/Data/CustomerBuilder.php | 6 +- .../Model/Layout/DepersonalizePlugin.php | 9 +- .../Address/Attribute/Backend/Region.php | 4 +- .../Model/Resource/AddressRepository.php | 3 + .../Model/Resource/CustomerRepository.php | 1 - .../Service/V1/Data/AddressBuilder.php | 6 +- .../Service/V1/Data/CustomerBuilder.php | 10 +- .../V1/Data/CustomerDetailsBuilder.php | 6 +- .../CustomerGroupSearchResultsBuilder.php | 6 +- .../V1/Data/Eav/AttributeMetadataBuilder.php | 6 +- .../Service/V1/Data/SearchResultsBuilder.php | 6 +- app/code/Magento/Customer/composer.json | 36 +- app/code/Magento/Customer/etc/di.xml | 10 +- .../CustomerImportExport/composer.json | 16 +- app/code/Magento/DesignEditor/composer.json | 14 +- app/code/Magento/Dhl/composer.json | 22 +- ...all-2.0.0.0.php => data-install-2.0.0.php} | 0 app/code/Magento/Dhl/etc/module.xml | 2 +- app/code/Magento/Directory/composer.json | 10 +- .../Magento/Downloadable/Model/Observer.php | 34 +- app/code/Magento/Downloadable/composer.json | 34 +- .../downloadable_setup/install-1.6.0.0.php | 8 +- app/code/Magento/Eav/Model/Config.php | 272 ++---- .../Attribute/Backend/AbstractBackend.php | 13 - .../Entity/Attribute/Backend/Datetime.php | 4 +- .../Model/Entity/Attribute/Backend/Store.php | 4 +- .../Entity/Attribute/Backend/Time/Created.php | 4 +- .../Entity/Attribute/Backend/Time/Updated.php | 4 +- app/code/Magento/Eav/Model/Entity/Type.php | 10 - .../Eav/Model/Resource/Entity/Attribute.php | 22 - .../Model/Resource/Entity/Attribute.php | 80 ++ app/code/Magento/Eav/composer.json | 12 +- app/code/Magento/Eav/etc/di.xml | 3 + app/code/Magento/Email/composer.json | 12 +- app/code/Magento/Fedex/composer.json | 18 +- ...all-2.0.0.0.php => data-install-2.0.0.php} | 0 app/code/Magento/Fedex/etc/module.xml | 2 +- app/code/Magento/GiftMessage/composer.json | 22 +- app/code/Magento/GoogleAdwords/composer.json | 8 +- .../Magento/GoogleAnalytics/composer.json | 8 +- .../Magento/GoogleOptimizer/composer.json | 14 +- app/code/Magento/GoogleShopping/composer.json | 20 +- .../Magento/GroupedImportExport/composer.json | 14 +- app/code/Magento/GroupedProduct/composer.json | 24 +- .../Magento/ImportExport/Model/Import.php | 25 +- app/code/Magento/ImportExport/composer.json | 14 +- .../Adminhtml/Indexer/MassChangelog.php | 8 +- .../Adminhtml/Indexer/MassOnTheFly.php | 8 +- .../Magento/Indexer/Model/ActionInterface.php | 2 +- .../Model/Indexer/AbstractProcessor.php | 17 +- .../Magento/Indexer/Model/IndexerRegistry.php | 60 ++ app/code/Magento/Indexer/composer.json | 8 +- app/code/Magento/Integration/composer.json | 16 +- .../Magento/LayeredNavigation/composer.json | 8 +- app/code/Magento/Log/composer.json | 14 +- app/code/Magento/Msrp/composer.json | 24 +- app/code/Magento/Multishipping/composer.json | 20 +- app/code/Magento/Newsletter/composer.json | 22 +- .../Magento/OfflinePayments/composer.json | 6 +- .../Magento/OfflinePayments/etc/module.xml | 2 +- .../Magento/OfflineShipping/composer.json | 20 +- .../Magento/OfflineShipping/etc/module.xml | 2 +- ...{install-2.0.0.0.php => install-2.0.0.php} | 8 +- app/code/Magento/Ogone/composer.json | 12 +- ...all-1.6.0.0.php => data-install-2.0.0.php} | 0 app/code/Magento/Ogone/etc/module.xml | 2 +- app/code/Magento/PageCache/composer.json | 8 +- .../PayPalRecurringPayment/composer.json | 16 +- .../PayPalRecurringPayment/etc/module.xml | 2 +- app/code/Magento/Payment/Model/Info.php | 8 +- app/code/Magento/Payment/composer.json | 14 +- app/code/Magento/Payment/etc/module.xml | 2 +- .../Magento/Paypal/Model/Api/AbstractApi.php | 2 +- app/code/Magento/Paypal/composer.json | 30 +- ...all-1.6.0.0.php => data-install-2.0.0.php} | 6 +- .../data-upgrade-1.6.0.2-1.6.0.3.php | 38 - app/code/Magento/Paypal/etc/module.xml | 2 +- ...{install-1.6.0.0.php => install-2.0.0.php} | 57 +- .../paypal_setup/upgrade-1.6.0.0-1.6.0.1.php | 68 -- app/code/Magento/Persistent/composer.json | 16 +- .../Magento/Persistent/etc/frontend/di.xml | 5 + .../sql/persistent_setup/install-1.0.0.0.php | 4 +- app/code/Magento/ProductAlert/composer.json | 12 +- .../Magento/RecurringPayment/composer.json | 26 +- ...all-1.0.0.0.php => data-install-2.0.0.php} | 0 .../RecurringPayment/etc/frontend/di.xml | 32 + .../Magento/RecurringPayment/etc/module.xml | 2 +- ...{install-1.0.0.0.php => install-2.0.0.php} | 4 +- .../Model/Resource/Customer/Collection.php | 4 +- .../Model/Resource/Order/Collection.php | 6 +- .../Model/Resource/Product/Collection.php | 14 +- .../Model/Resource/Quote/Collection.php | 4 +- app/code/Magento/Reports/composer.json | 36 +- app/code/Magento/RequireJs/composer.json | 4 +- .../Magento/Review/Block/Product/Review.php | 4 +- app/code/Magento/Review/composer.json | 22 +- app/code/Magento/Rss/composer.json | 10 +- .../Magento/Rule/Model/Condition/Combine.php | 47 +- .../Condition/Product/AbstractProduct.php | 36 +- .../Rule/Model/Condition/Sql/Builder.php | 3 +- .../Magento/Rule/Model/ConditionFactory.php | 36 +- app/code/Magento/Rule/composer.json | 12 +- .../Magento/Sales/Model/AdminOrder/Create.php | 8 +- .../Frontend/Quote/Address/CollectTotals.php | 2 +- app/code/Magento/Sales/Model/Quote.php | 19 +- .../Magento/Sales/Model/Quote/Payment.php | 15 +- .../Sales/Model/Resource/AbstractGrid.php | 4 +- .../Magento/Sales/Model/Resource/Order.php | 4 +- .../Sales/Model/Resource/Order/Address.php | 2 +- .../Sales/Model/Resource/Order/Collection.php | 4 +- .../Sales/Model/Resource/Order/Creditmemo.php | 2 +- .../Resource/Order/Creditmemo/Comment.php | 2 +- .../Model/Resource/Order/Creditmemo/Grid.php | 4 +- .../Order/Creditmemo/Grid/Collection.php | 2 +- .../Model/Resource/Order/Creditmemo/Item.php | 2 +- .../Sales/Model/Resource/Order/Grid.php | 2 +- .../Model/Resource/Order/Grid/Collection.php | 2 +- .../Sales/Model/Resource/Order/Invoice.php | 2 +- .../Model/Resource/Order/Invoice/Comment.php | 2 +- .../Model/Resource/Order/Invoice/Grid.php | 4 +- .../Order/Invoice/Grid/Collection.php | 2 +- .../Model/Resource/Order/Invoice/Item.php | 2 +- .../Sales/Model/Resource/Order/Item.php | 2 +- .../Sales/Model/Resource/Order/Payment.php | 2 +- .../Resource/Order/Payment/Transaction.php | 2 +- .../Order/Payment/Transaction/Collection.php | 4 +- .../Model/Resource/Order/Rss/OrderStatus.php | 8 +- .../Sales/Model/Resource/Order/Shipment.php | 2 +- .../Model/Resource/Order/Shipment/Comment.php | 2 +- .../Model/Resource/Order/Shipment/Grid.php | 4 +- .../Order/Shipment/Grid/Collection.php | 2 +- .../Model/Resource/Order/Shipment/Item.php | 2 +- .../Model/Resource/Order/Shipment/Track.php | 2 +- .../Sales/Model/Resource/Order/Status.php | 2 +- .../Model/Resource/Order/Status/History.php | 2 +- .../Magento/Sales/Model/Resource/Quote.php | 16 +- .../Sales/Model/Resource/Quote/Address.php | 2 +- .../Address/Attribute/Backend/Region.php | 4 +- .../Model/Resource/Quote/Address/Item.php | 2 +- .../Model/Resource/Quote/Address/Rate.php | 2 +- .../Sales/Model/Resource/Quote/Item.php | 2 +- .../Model/Resource/Quote/Item/Option.php | 2 +- .../Sales/Model/Resource/Quote/Payment.php | 2 +- .../Model/Resource/Report/Bestsellers.php | 8 +- .../Sales/Model/Resource/Report/Invoiced.php | 6 +- .../Model/Resource/Report/Order/Createdat.php | 8 +- .../Sales/Model/Resource/Report/Refunded.php | 6 +- .../Sales/Model/Resource/Report/Shipping.php | 6 +- .../Magento/Sales/Model/Resource/Setup.php | 50 +- app/code/Magento/Sales/composer.json | 44 +- ...all-1.6.0.0.php => data-install-2.0.0.php} | 37 +- .../data-upgrade-1.6.0.4-1.6.0.5.php | 71 -- .../data-upgrade-1.6.0.5-1.6.0.6.php | 42 - app/code/Magento/Sales/etc/module.xml | 2 +- ...{install-1.6.0.0.php => install-2.0.0.php} | 901 ++++++++++-------- .../sales_setup/upgrade-1.6.0.0-1.6.0.1.php | 37 - .../sales_setup/upgrade-1.6.0.1-1.6.0.2.php | 33 - .../sales_setup/upgrade-1.6.0.11-1.6.0.12.php | 41 - .../sales_setup/upgrade-1.6.0.3-1.6.0.4.php | 37 - .../sales_setup/upgrade-1.6.0.4-1.6.0.5.php | 56 -- .../sales_setup/upgrade-1.6.0.6-1.6.0.7.php | 37 - .../sales_setup/upgrade-1.6.0.7-1.6.0.8.php | 40 - .../sales_setup/upgrade-1.6.0.8-1.6.0.9.php | 51 - .../Model/Resource/Report/Rule/Createdat.php | 2 +- app/code/Magento/SalesRule/composer.json | 34 +- ...0.3-1.6.0.4.php => data-install-2.0.0.php} | 0 app/code/Magento/SalesRule/etc/module.xml | 2 +- ...{install-1.6.0.0.php => install-2.0.0.php} | 282 ++++-- .../upgrade-1.6.0.1-1.6.0.2.php | 118 --- .../upgrade-1.6.0.2-1.6.0.3.php | 135 --- app/code/Magento/Search/composer.json | 8 +- app/code/Magento/Sendfriend/composer.json | 14 +- app/code/Magento/Shipping/composer.json | 26 +- app/code/Magento/Shipping/etc/module.xml | 2 +- app/code/Magento/Sitemap/composer.json | 18 +- app/code/Magento/Store/composer.json | 10 +- .../Model/Resource/Report/Tax/Createdat.php | 6 +- .../V1/Data/OrderTaxDetails/ItemBuilder.php | 6 +- .../V1/Data/OrderTaxDetailsBuilder.php | 6 +- .../V1/Data/QuoteDetails/ItemBuilder.php | 6 +- .../Service/V1/Data/QuoteDetailsBuilder.php | 6 +- .../V1/Data/TaxClassSearchResultsBuilder.php | 6 +- .../V1/Data/TaxDetails/AppliedTaxBuilder.php | 6 +- .../V1/Data/TaxDetails/ItemBuilder.php | 6 +- .../Tax/Service/V1/Data/TaxDetailsBuilder.php | 6 +- .../Tax/Service/V1/Data/TaxRateBuilder.php | 6 +- .../V1/Data/TaxRateSearchResultsBuilder.php | 6 +- .../Tax/Service/V1/Data/TaxRuleBuilder.php | 6 +- .../V1/Data/TaxRuleSearchResultsBuilder.php | 6 +- app/code/Magento/Tax/composer.json | 28 +- app/code/Magento/Tax/etc/frontend/di.xml | 34 + .../sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php | 4 +- .../sql/tax_setup/upgrade-1.6.0.6-1.6.0.7.php | 4 +- .../Magento/TaxImportExport/composer.json | 12 +- app/code/Magento/Theme/composer.json | 16 +- app/code/Magento/Theme/etc/di.xml | 1 - app/code/Magento/Theme/etc/module.xml | 2 +- app/code/Magento/Translation/composer.json | 10 +- app/code/Magento/Ui/composer.json | 8 +- app/code/Magento/Ui/etc/module.xml | 6 +- app/code/Magento/Ups/composer.json | 18 +- app/code/Magento/Ups/etc/module.xml | 2 +- .../Controller/Adminhtml/Url/Rewrite/Save.php | 2 +- .../Magento/UrlRewrite/Controller/Router.php | 34 +- app/code/Magento/UrlRewrite/composer.json | 18 +- app/code/Magento/User/composer.json | 14 +- app/code/Magento/Usps/composer.json | 18 +- ...all-2.0.0.0.php => data-install-2.0.0.php} | 0 app/code/Magento/Usps/etc/module.xml | 2 +- .../Controller/ServiceArgsSerializer.php | 8 +- app/code/Magento/Webapi/composer.json | 16 +- .../Weee/Model/Attribute/Backend/Weee/Tax.php | 4 +- app/code/Magento/Weee/composer.json | 24 +- app/code/Magento/Widget/composer.json | 14 +- app/code/Magento/Wishlist/composer.json | 32 +- .../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/etc/di.xml | 1 - app/i18n/magento/de_de/composer.json | 4 +- app/i18n/magento/en_us/composer.json | 4 +- app/i18n/magento/es_es/composer.json | 4 +- app/i18n/magento/fr_fr/composer.json | 4 +- app/i18n/magento/nl_nl/composer.json | 4 +- app/i18n/magento/pt_br/composer.json | 4 +- app/i18n/magento/zh_cn/composer.json | 4 +- composer.json | 2 +- .../Selenium/Element/ConditionsElement.php | 24 +- .../Test/Block/Catalog/Product/View.php | 2 +- .../AssertTierPriceOnBundleProductPage.php | 4 +- .../Test/Page/Product/CatalogProductView.xml | 5 + .../Test/TestCase/BundleDynamicTest.php | 5 +- .../Bundle/Test/TestCase/BundleFixedTest.php | 3 +- .../Edit/Tab/ProductDetails/CategoryIds.php | 2 +- .../ProductDetails/ProductOnlineSwitcher.php | 9 + .../Catalog/Test/Block/Category/View.php | 35 +- .../Page/Category/CatalogCategoryView.xml | 5 + .../Page/Product/CatalogProductCompare.xml | 5 + .../Test/Page/Product/CatalogProductView.xml | 5 + .../Test/Repository/CatalogProductSimple.php | 7 +- .../Test/Handler/CatalogSearchQuery/Curl.php | 20 +- .../Test/Page/Adminhtml/CatalogSearchEdit.xml | 2 +- .../Page/Adminhtml/CatalogSearchIndex.xml | 4 +- .../Test/Page/AdvancedSearch.xml | 5 + .../TestCase/AdvancedSearchEntityTest.php | 4 +- .../{testSearch.csv => test.csv} | 26 +- .../EditSearchTermEntityTest/test.csv | 2 +- .../Magento/CatalogSearch/Test/etc/page.xml | 4 +- .../app/Magento/Checkout/Test/etc/fixture.xml | 2 +- .../app/Magento/Cms/Test/Page/CmsIndex.xml | 5 + ...figurableAttributesAbsentOnProductPage.php | 8 +- ...leAttributesBlockIsAbsentOnProductPage.php | 6 +- .../AssertConfigurableProductForm.php | 5 + .../Test/TestStep/SetupConfigurationStep.php | 7 +- .../Customer/Test/Block/Address/Renderer.php | 28 +- .../CheckoutData.php | 10 + ...AssertGroupedProductInItemsOrderedGrid.php | 10 +- .../Block/Customer/Wishlist/Items/Product.php | 19 + .../AssertProductDetailsInWishlist.php | 11 +- ...CartFromCustomerWishlistOnFrontendTest.php | 1 + ...roductInCustomerWishlistOnFrontendTest.php | 1 + .../Test/TestCase/ShareWishlistEntityTest.php | 1 + .../Model/Product/Type/AbstractTest.php | 11 +- ...roduct_attribute_with_invalid_apply_to.php | 49 + .../Model/Indexer/IndexerBuilderTest.php | 126 +++ .../Model/Indexer/ProductRuleTest.php | 65 ++ .../Model/Indexer/RuleProductTest.php | 76 ++ .../Magento/CatalogRule/_files/attribute.php | 53 ++ .../_files/catalog_rule_10_off_not_logged.php | 5 +- .../CatalogRule/_files/rule_by_attribute.php | 40 +- .../Adminhtml/Wysiwyg/Images/IndexTest.php | 23 +- .../Customer/Block/Widget/TaxvatTest.php | 7 + .../Customer/Controller/AddressTest.php | 6 +- .../Customer/Model/AccountManagementTest.php | 129 ++- .../V1/Data/CustomerDetailsBuilderTest.php | 5 +- .../Data/Eav/AttributeMetadataBuilderTest.php | 6 +- .../Api/Code/Generator/DataBuilderTest.php | 113 ++- .../Api/Data/FakeAddressInterface.php | 16 + .../Wonderland/Model/Data/FakeAddress.php | 222 +++++ .../Wonderland/Model/Data/FakeRegion.php} | 47 +- .../Magento/Wonderland/Model/FakeAddress.php | 24 +- .../Template/Tokenizer/ParameterTest.php | 114 +++ .../Magento/Paypal/_files/quote_payment.php | 5 +- .../Paypal/_files/quote_payment_payflow.php | 2 +- .../Paypal/_files/quote_payment_standard.php | 2 +- .../Sales/Model/AdminOrder/CreateTest.php | 2 +- .../Magento/Sales/Model/Service/QuoteTest.php | 2 +- .../Model/Resource/Report/CollectionTest.php | 22 +- .../V1/Data/QuoteDetails/ItemBuilderTest.php | 6 +- .../V1/Data/QuoteDetailsBuilderTest.php | 6 +- .../Data/TaxDetails/AppliedTaxBuilderTest.php | 6 +- .../Service/V1/Data/TaxRateBuilderTest.php | 6 +- .../Data/TaxRateSearchResultsBuilderTest.php | 4 +- .../Service/V1/Data/TaxRuleBuilderTest.php | 6 +- .../Data/TaxRuleSearchResultsBuilderTest.php | 6 +- .../Test/Integrity/Di/CompilerTest.php | 4 +- .../Integrity/_files/blacklist/namespace.txt | 2 + .../Integrity/_files/blacklist/reference.txt | 3 + .../_files/dependency_test/tables_ce.php | 58 +- .../Test/Legacy/_files/obsolete_classes.php | 2 + .../Test/Legacy/_files/obsolete_methods.php | 15 + .../Legacy/_files/obsolete_properties.php | 1 + .../TestFramework/Helper/ObjectManager.php | 4 +- .../Magento/Catalog/Block/Widget/LinkTest.php | 29 + .../Product/Action/Attribute/SaveTest.php | 5 +- .../Category/Flat/Plugin/StoreGroupTest.php | 15 +- .../Category/Flat/Plugin/StoreViewTest.php | 13 +- .../Model/Indexer/Category/Flat/StateTest.php | 16 +- .../Category/Flat/System/Config/ModeTest.php | 42 +- .../Model/Indexer/Category/FlatTest.php | 47 +- .../Product/Plugin/StoreGroupTest.php | 14 +- .../Category/Product/Plugin/StoreViewTest.php | 15 +- .../Model/Indexer/Category/ProductTest.php | 37 +- .../Model/Indexer/Product/CategoryTest.php | 37 +- .../Indexer/Product/Flat/ProcessorTest.php | 30 +- .../Product/Price/Plugin/CatalogRuleTest.php | 128 --- .../Price/Plugin/CustomerGroupTest.php | 13 +- .../Price/System/Config/PriceScopeTest.php | 22 +- .../Catalog/Model/Product/ActionTest.php | 37 +- .../Attribute/Backend/CategoryTest.php | 3 +- .../Backend/Groupprice/AbstractTest.php | 2 - .../Magento/Catalog/Model/ProductTest.php | 18 +- .../Plugin/Model/Resource/ConfigTest.php | 199 ++++ .../Service/V1/Data/ProductBuilderTest.php | 4 +- .../Product/Price/Plugin/ImportTest.php | 13 +- .../Service/V1/StockItemServiceTest.php | 19 +- .../Magento/CatalogRule/Model/CronTest.php | 57 ++ .../Model/Indexer/AbstractIndexerTest.php | 97 ++ .../Product/ProductRuleIndexerTest.php | 88 ++ .../Indexer/Rule/RuleProductIndexerTest.php | 66 ++ .../Model/Rule/Condition/ProductTest.php | 3 +- .../CatalogRule/Model/Rule/JobTest.php | 44 +- .../Plugin/Indexer/CategoryTest.php | 81 ++ .../Plugin/Indexer/CustomerGroupTest.php | 62 ++ .../Plugin/Indexer/ImportExportTest.php | 64 ++ .../Indexer/Product/PriceIndexerTest.php | 90 ++ .../Plugin/Indexer/WebsiteTest.php | 62 ++ .../Indexer/Fulltext/Plugin/AttributeTest.php | 23 +- .../Fulltext/Plugin/Product/ActionTest.php | 24 +- .../Indexer/Fulltext/Plugin/ProductTest.php | 25 +- .../Fulltext/Plugin/Store/GroupTest.php | 23 +- .../Fulltext/Plugin/Store/ViewTest.php | 23 +- .../Model/Indexer/FulltextTest.php | 22 +- .../Checkout/Model/Type/OnepageTest.php | 1 + .../Cms/Block/Adminhtml/Block/EditTest.php | 115 +++ .../Adminhtml/Block/Widget/ChooserTest.php | 265 ++++++ .../testsuite/Magento/Cms/Helper/PageTest.php | 550 +++++++++++ .../Cms/Model/Config/Source/PageTest.php | 98 ++ .../Magento/Cms/Model/ObserverTest.php | 207 ++++ .../testsuite/Magento/Cms/Model/PageTest.php | 135 +++ .../Magento/Cms/Model/Wysiwyg/ConfigTest.php | 251 +++++ .../Magento/Contact/Helper/DataTest.php | 2 +- .../Magento/Customer/Model/ConverterTest.php | 2 +- .../Attribute/Backend/PasswordTest.php | 4 +- .../Customer/Attribute/Backend/StoreTest.php | 4 +- .../Attribute/Backend/WebsiteTest.php | 4 +- .../Model/Layout/DepersonalizePluginTest.php | 5 +- .../Service/V1/CustomerAccountServiceTest.php | 2 +- .../Service/V1/CustomerAddressServiceTest.php | 2 +- .../Service/V1/Data/AddressConverterTest.php | 7 +- .../Customer/Service/V1/Data/AddressTest.php | 12 +- .../Service/V1/Data/CustomerBuilderTest.php | 22 +- .../Customer/Service/V1/Data/CustomerTest.php | 2 +- .../Downloadable/Model/ObserverTest.php | 288 ++++++ .../Magento/Eav/Model/Entity/AbstractTest.php | 8 +- .../Model/Resource/Entity/AttributeTest.php | 129 +++ .../Api/Code/Generator/BuilderTest.php | 156 --- .../Api/Code/Generator/DataBuilderTest.php | 5 +- .../Code/Generator/GenerateBuilderTest.php | 84 -- .../GenerateSearchResultsBuilderTest.php | 3 +- .../_files/ExtensibleSampleDataBuilder.txt | 21 +- .../_files/SampleSearchResultsBuilder.txt | 2 +- .../Framework/Api/Data/AttributeValueTest.php | 8 +- .../App/View/Deployment/VersionTest.php | 14 +- .../Template/Tokenizer/ParameterTest.php | 5 +- .../Model/AbstractExtensibleModelTest.php | 8 +- .../Indexer/Model/IndexerRegistryTest.php | 45 + .../Magento/Payment/Model/InfoTest.php | 8 + .../Rule/Model/Condition/CombineTest.php | 125 ++- .../Rule/Model/ConditionFactoryTest.php | 28 +- .../Sales/Model/AdminOrder/CreateTest.php | 2 +- .../Quote/Address/CollectTotalsTest.php | 32 +- .../Magento/Sales/Model/QuoteTest.php | 105 ++ .../Resource/Order/Creditmemo/GridTest.php | 8 +- .../Sales/Model/Resource/Order/GridTest.php | 8 +- .../Model/Resource/Order/Invoice/GridTest.php | 8 +- .../Resource/Order/Shipment/GridTest.php | 8 +- .../Model/Quote/Nominal/DiscountTest.php | 103 +- .../Tax/Service/V1/TaxClassServiceTest.php | 7 +- .../UrlRewrite/Controller/RouterTest.php | 125 ++- .../Service/Entity/WebapiBuilderFactory.php | 2 +- dev/tools/Magento/Tools/Di/compiler.php | 3 +- .../Magento/Tools/Di/entity_generator.php | 4 +- .../factory_table_names/blacklist_ce.php | 2 +- .../factory_table_names/replace_ce.php | 54 +- dev/tools/Magento/Tools/View/Deployer.php | 14 +- dev/tools/performance-toolkit/benchmark.jmx | 673 +++++++------ .../fixtures/eav_variations.php | 6 + .../performance-toolkit/fixtures/stores.php | 17 +- .../Magento/ToolkitFramework/Application.php | 3 +- .../performance-toolkit/framework/labels.xml | 2 +- .../Api/AbstractExtensibleObject.php | 12 +- .../Api/AbstractSearchResultsBuilder.php | 15 +- .../Framework/Api/AbstractSimpleObject.php | 4 +- .../Api/AbstractSimpleObjectBuilder.php | 73 +- .../Framework/Api/AttributeDataBuilder.php | 26 +- .../Magento/Framework/Api/AttributeValue.php | 13 +- ...{ExtensibleDataBuilder.php => Builder.php} | 235 ++++- ...lderInterface.php => BuilderInterface.php} | 39 +- .../Framework/Api/Code/Generator/Builder.php | 158 --- .../Api/Code/Generator/DataBuilder.php | 138 +-- .../Code/Generator/SearchResultsBuilder.php | 2 +- .../Api/CompositeExtensibleDataBuilder.php | 168 ---- .../Framework/Api/ExtensibleDataInterface.php | 5 + .../Framework/Api/ExtensibleObjectBuilder.php | 83 +- lib/internal/Magento/Framework/Api/Filter.php | 2 +- .../Magento/Framework/Api/FilterBuilder.php | 2 +- .../Api/Search/FilterGroupBuilder.php | 38 +- .../Framework/Api/SearchCriteriaBuilder.php | 37 +- .../SimpleBuilderInterface.php} | 20 +- .../Framework/App/View/Deployment/Version.php | 18 +- .../Magento/Framework/AppInterface.php | 2 +- .../Filter/Template/Tokenizer/Parameter.php | 3 + .../Model/AbstractExtensibleModel.php | 28 +- .../Magento/Framework/Model/AbstractModel.php | 2 +- .../ObjectManager/DefinitionFactory.php | 4 +- .../Framework/ObjectManager/Profiler/Log.php | 15 +- .../Reflection/DataObjectProcessor.php | 4 +- .../Serialization/DataBuilderFactory.php | 2 +- lib/internal/Magento/Framework/composer.json | 2 +- .../mage/adminhtml/wysiwyg/tiny_mce/setup.js | 1 + 575 files changed, 10761 insertions(+), 6193 deletions(-) create mode 100644 app/code/Magento/Catalog/Plugin/Model/Resource/Config.php rename app/code/Magento/{SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php => CatalogRule/CatalogRuleException.php} (75%) create mode 100644 app/code/Magento/CatalogRule/Model/Cron.php create mode 100644 app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php create mode 100644 app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php rename lib/internal/Magento/Framework/App/View/Deployment/Version/Generator/Timestamp.php => app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexer.php (70%) rename app/code/Magento/{Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php => CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php} (74%) rename lib/internal/Magento/Framework/Api/AttributeValueBuilder.php => app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexer.php (65%) rename app/code/Magento/{Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php => CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php} (73%) create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/Category.php create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/CustomerGroup.php create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/ImportExport.php create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/Product/Attribute.php rename app/code/Magento/{Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php => CatalogRule/Plugin/Indexer/Product/PriceIndexer.php} (50%) create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/Product/Save/ApplyRules.php create mode 100644 app/code/Magento/CatalogRule/Plugin/Indexer/Website.php create mode 100644 app/code/Magento/CatalogRule/etc/indexer.xml create mode 100644 app/code/Magento/CatalogRule/etc/mview.xml create mode 100644 app/code/Magento/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.3-1.6.0.4.php rename app/code/Magento/Dhl/data/dhl_setup/{data-install-2.0.0.0.php => data-install-2.0.0.php} (100%) create mode 100644 app/code/Magento/Eav/Plugin/Model/Resource/Entity/Attribute.php rename app/code/Magento/Fedex/data/fedex_setup/{data-install-2.0.0.0.php => data-install-2.0.0.php} (100%) create mode 100644 app/code/Magento/Indexer/Model/IndexerRegistry.php rename app/code/Magento/OfflineShipping/sql/offlineshipping_setup/{install-2.0.0.0.php => install-2.0.0.php} (95%) rename app/code/Magento/Ogone/data/ogone_setup/{data-install-1.6.0.0.php => data-install-2.0.0.php} (100%) rename app/code/Magento/Paypal/data/paypal_setup/{data-install-1.6.0.0.php => data-install-2.0.0.php} (91%) delete mode 100644 app/code/Magento/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php rename app/code/Magento/Paypal/sql/paypal_setup/{install-1.6.0.0.php => install-2.0.0.php} (88%) delete mode 100644 app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php rename app/code/Magento/RecurringPayment/data/recurringpayment_setup/{data-install-1.0.0.0.php => data-install-2.0.0.php} (100%) create mode 100644 app/code/Magento/RecurringPayment/etc/frontend/di.xml rename app/code/Magento/RecurringPayment/sql/recurringpayment_setup/{install-1.0.0.0.php => install-2.0.0.php} (99%) rename app/code/Magento/Sales/data/sales_setup/{data-install-1.6.0.0.php => data-install-2.0.0.php} (71%) delete mode 100644 app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php delete mode 100644 app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.5-1.6.0.6.php rename app/code/Magento/Sales/sql/sales_setup/{install-1.6.0.0.php => install-2.0.0.php} (85%) delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.11-1.6.0.12.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php delete mode 100644 app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php rename app/code/Magento/SalesRule/data/salesrule_setup/{data-upgrade-1.6.0.3-1.6.0.4.php => data-install-2.0.0.php} (100%) rename app/code/Magento/SalesRule/sql/salesrule_setup/{install-1.6.0.0.php => install-2.0.0.php} (66%) delete mode 100644 app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php delete mode 100644 app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php create mode 100644 app/code/Magento/Tax/etc/frontend/di.xml rename app/code/Magento/Usps/data/usps_setup/{data-install-2.0.0.0.php => data-install-2.0.0.php} (100%) rename dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/{testSearch.csv => test.csv} (77%) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute_with_invalid_apply_to.php create mode 100644 dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/IndexerBuilderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/ProductRuleTest.php create mode 100644 dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/RuleProductTest.php create mode 100644 dev/tests/integration/testsuite/Magento/CatalogRule/_files/attribute.php rename app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php => dev/tests/integration/testsuite/Magento/CatalogRule/_files/rule_by_attribute.php (50%) rename app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.11-1.6.0.12.php => dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/IndexTest.php (64%) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php rename dev/tests/{unit/testsuite/Magento/Framework/App/View/Deployment/Version/Generator/TimestampTest.php => integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php} (56%) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Plugin/Model/Resource/ConfigTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Model/CronTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/AbstractIndexerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CategoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CustomerGroupTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/ImportExportTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/WebsiteTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/EditTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/Widget/ChooserTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Helper/PageTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Model/Config/Source/PageTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Model/PageTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Downloadable/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Eav/Plugin/Model/Resource/Entity/AttributeTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/BuilderTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateBuilderTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerRegistryTest.php rename lib/internal/Magento/Framework/Api/{ExtensibleDataBuilder.php => Builder.php} (50%) rename lib/internal/Magento/Framework/Api/{ExtensibleDataBuilderInterface.php => BuilderInterface.php} (60%) delete mode 100644 lib/internal/Magento/Framework/Api/Code/Generator/Builder.php delete mode 100644 lib/internal/Magento/Framework/Api/CompositeExtensibleDataBuilder.php rename lib/internal/Magento/Framework/{App/View/Deployment/Version/GeneratorInterface.php => Api/SimpleBuilderInterface.php} (74%) diff --git a/.gitignore b/.gitignore index 90b240f3af0..99db0d98038 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ atlassian* /pub/media/*.* !/pub/media/.htaccess +/pub/media/catalog/* +!/pub/media/catalog/.htaccess /pub/media/customer/* !/pub/media/customer/.htaccess /pub/media/downloadable/* @@ -29,6 +31,8 @@ atlassian* /pub/media/theme/* /pub/media/theme_customization/* !/pub/media/theme_customization/.htaccess +/pub/media/tmp/* +!/pub/media/tmp/.htaccess /pub/static/* !/pub/static/.htaccess diff --git a/CHANGELOG.md b/CHANGELOG.md index 868b7a35b28..4e779e92139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,44 @@ +0.1.0-alpha104 +============= +* Various improvements: + * Merge SQL and Data Upgrades for the Sales and SalesRule modules + * Add getDefaultBilling and getDefaultShipping to Customer Interface + * Stabilized the Bundle module + * Stabilized the CatalogSearch module + * Stabilized the Cms module + * Stabilized the SalesRule module +* Performance improvements: + * Introduced CatalogRule indexers based on Mview + * Significantly decreased the amount of unused objects, mostly in category and product view scenarios: + * Got rid of non-shared indexer instances all over the code introducing Magento\Indexer\Model\IndexerRegistry + * Magento\Catalog\Pricing\Price\BasePrice being created on demand only, instead of unconditioned creation in constructor + * Created proxies for unused objects with big amount of dependencies + * Fixed \Magento\Review\Block\Product\Review block which injected backend block context by mistake + * A customer model in \Magento\Customer\Model\Layout\DepersonalizePlugin being created on demand only, instead of constructor + * Introduced caching for product attribute metadata loading procedure + * Improved SavePayment Checkout step to save only payment related data + * Speed up all Checkout steps of the One Page Checkout + * Updated the benchmark.jmx jmeter script in the performance toolkit +* Fixed bugs: + * Fixed an issue where performance toolkit generator created Products/Categories without URL rewrites due to install area elimination + * Fixed an issue where the Custom Options fieldset on Product Information page was collapsible + * Fixed an issue where the Base URL was added to target path for Custom UrlRewrite + * Fixed an issue where an invalid Cross-sells amount was displayed in the Shopping Cart + * Fixed an issue where the Mage_Catalog_Model_Product_Type_AbstractTest::testBeforeSave integration test failed when Mage_Downloadable module was not available + * Fixed an issue where the custom URL rewrite redirected to sub-folder when Request Path contained slash + * Fixed an issue where it was impossible to place an order if registering during checkout + * Fixed an issue where there was no possibility to save default billing and shipping addresses for customer on the store front + * Fixed an issue where a widget of Catalog Category Link type was not displayed on the store front + * Fixed an issue where the Versions tab was absent on the CMS page with version control + * Fixed an issue where it was impossible to insert Widgets and Images to a CMS page +* Added the following functional tests: + * Create widget + * Print order from guest on frontend +* Framework Improvements: + * Removed duplicated logic from API Builders and Builder generators. Added support for populating builders from the objects, implementing data interface +* Processed GitHub requests: + * [#674](https://github.com/magento/magento2/issues/674) -- Widgets in content pages + 0.1.0-alpha103 ============= * Fixed bugs: diff --git a/README.md b/README.md index 509292e8914..5a4d56047c9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Before you install Magento 2, make sure your system meets or exceeds the followi * <a href="https://getcomposer.org/download/" >Composer</a> (latest stable version) * <a href="http://httpd.apache.org/download.cgi" >Apache 2.2</a> or later -* PHP 5.4.11 or 5.5.x (<a href="http://php.net/downloads.php" >installation</a> instructions, <a href="http://phpave.com/upgrade-php-5-3-php-5-5-ubuntu-12-04-lts/" >upgrade</a> instructions) +* PHP 5.4.11 or 5.5.x * Required PHP extensions: * PDO/MySQL @@ -37,15 +37,13 @@ Before you install Magento 2, make sure your system meets or exceeds the followi * gd2, ImageMagick 6.3.7 (or later) or both * soap -* <a href="http://dev.mysql.com/doc/refman/5.5/en/installing.html" >MySQL 5.5</a> or later +* <a href="http://dev.mysql.com/doc/refman/5.6/en/installing.html" >MySQL 5.6.x</a> * Mail Transfer Agent (MTA) or an SMTP server * Optional but recommended: * <a href="http://xdebug.org/download.php" >php_xdebug2.2.0</a> or later (development environments only; can have an adverse effect on performance) - * PHPUnit (as a command-line tool) 3.7 or later + * PHPUnit (as a command-line tool) 4.1 or later - - <h2 id="instgde-overview-composer">Composer and Magento</h2> We now use <a href="https://getcomposer.org/" >Composer</a> to install the Magento 2 software. Composer enables us to manage Magento 2, extensions, and their dependencies. @@ -87,7 +85,7 @@ Use the following table to verify you have the correct prerequisites to install <td><code>php -v</code></td> <td><a href="#php" >PHP</a></td> </tr> - <tr><td>MySQL 5.5 or later</td> + <tr><td>MySQL 5.6.x</td> <td><code>mysql -u [root user name] -p</code></td> <td><a href="#mysql" >MySQL</a></td> </tr> @@ -142,7 +140,7 @@ Before you install Magento, you must do all of the following: </li> <li>Specify the type of directives that can be used in <code>.htaccess</code>. Magento uses <code>.htaccess</code> for redirects. For guidelines, see: <ul><li>Apache 2.2: The <a href="http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride" target="_blank">Apache 2.2 documentation</a>.</li> -<li>Apache 2.4: The <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html" target="_blank">Apache 2.4 documentation</a>.<br> +<li>Apache 2.4: The <a href="http://httpd.apache.org/docs/current/mod/core.html#allowoverride" target="_blank">Apache 2.4 documentation</a>.<br> Note that in Apache 2.4, the server's default site configuration file is <code>/etc/apache2/sites-available/000-default.conf</code><br> For example, you can add the following to the bottom of <code>000-default.conf</code>:<br> <pre><Directory "/var/www"> @@ -172,13 +170,27 @@ AllowOverride [value from Apache site] <h4>Installing MySQL on Ubuntu</h4> -1. Use the guidelines on the <a href="https://help.ubuntu.com/12.04/serverguide/mysql.html" target="_blank">Ubuntu site</a>. +1. Install MySQL on <a href="https://rtcamp.com/tutorials/mysql/mysql-5-6-ubuntu-12-04/" target="_blank">Ubuntu 12</a> or <a href="http://www.tocker.ca/2014/04/21/installing-mysql-5-6-on-ubuntu-14-04-trusty-tahr.html" target="_blank">Ubuntu 14</a>. 2. Configure the database instance. <h4>Installing and configuring MySQL on CentOS</h4> -1. Install and configure MySQL as discussed on the <a href="http://centoshelp.org/servers/database/installing-configuring-mysql-server/" target="_blank">CentOS help site</a>. -2. Configure the database instance as discussed in the next section. +The following procedure is based on <a href="http://sharadchhetri.com/2013/12/26/install-mysql-server-5-6-in-centos-6-x-and-red-hat-6-x-linux/" target="_blank">Install MySQL Server 5.6 in CentOS 6.x and Red Hat 6.x Linux</a>. + +1. Install the MySQL database: + + <pre>cd /tmp +wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm +rpm -ivh mysql-community-release-el6-5.noarch.rpm +yum -y install mysql-server</pre> + +2. Start MySQL. + + `service mysqld start` + +3. Set a password for the <tt>root</tt> user and set other security-related options. Enter the following command and follow the prompts on your screen to complete the configuration. + + `mysql_secure_installation` <h4>Configuring the Magento database instance</h4> @@ -194,9 +206,7 @@ To configure a MySQL database instance: 3. Enter the MySQL `root` user's password when prompted. 4. Enter the following commands in the order shown to create a database instance named `magento` with user name `magento`: <pre>create database magento; -CREATE USER 'magento'@'localhost' IDENTIFIED BY 'magento'; -GRANT USAGE ON *.* TO magento@localhost IDENTIFIED BY 'magento'; -GRANT ALL ON magento.* TO magento@localhost;</pre> +GRANT ALL ON magento.* TO magento@localhost IDENTIFIED BY 'magento';</pre> 5. Enter `exit` to quit the command prompt. @@ -204,11 +214,11 @@ GRANT ALL ON magento.* TO magento@localhost;</pre> Magento 2 requires PHP 5.4.11 or later or PHP 5.5.x. -**Note**: Magento 2 does not support PHP 5.6. +**Note**: Magento 2 does *not* support PHP 5.6. -<h3>PHP on Ubuntu</h3> +<h3>PHP 5.5 or 5.4 on Ubuntu</h3> -<h4>Install PHP 5.5 on Ubuntu 14</h4> +<h5>Install PHP 5.5 on Ubuntu 14</h5> To install PHP 5.5 on Ubuntu 14: @@ -223,7 +233,22 @@ To install PHP 5.5 on Ubuntu 14: Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies</pre> -<h4>Install PHP 5.4 on Ubuntu 12</h4> +<h5>Install PHP 5.5 on Ubuntu 12</h5> + +1. Use the following commands from <a href="http://www.dev-metal.com/how-to-setup-latest-version-of-php-5-5-on-ubuntu-12-04-lts/" target="_blank">dev-metal</a>: + + <pre>add-apt-repository ppa:ondrej/php5 + apt-get update + sudo apt-get install php5</pre> + +2. Verify the PHP version by entering `php -v`. Messages similar to the following should display: + + <pre>PHP 5.5.18-1+deb.sury.org~precise+1 (cli) (built: Oct 17 2014 15:11:34) + Copyright (c) 1997-2014 The PHP Group + Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies + with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies</pre> + +<h5>Install PHP 5.4 on Ubuntu 12</h5> To install PHP 5.4 on Ubuntu 12: @@ -242,7 +267,7 @@ To install PHP 5.4 on Ubuntu 12: 3. Restart Apache: `service apache2 restart` -<h4>Upgrade to PHP 5.4 on Ubuntu</h4> +<h5>Upgrade to PHP 5.4 on Ubuntu</h5> To upgrade to PHP 5.4 on Ubuntu: @@ -265,7 +290,7 @@ Enter the following command to install required PHP extensions: There is a <a href="https://bugs.launchpad.net/ubuntu/+source/php-mcrypt/+bug/1240590" target="_blank">known issue</a> in Ubuntu 14 with the `mcrypt` PHP extension. To work around the issue, see <a href="http://askubuntu.com/questions/450825/ubuntu-14-04-phpmyadmin-cant-find-mcrypt-extension" target="_blank">askubuntu</a>. -<h4>Upgrade to PHP 5.4 on CentOS</h4> +<h4>PHP 5.5 or 5.4 on CentOS</h4> PHP 5.3 is the default PHP version on CentOS distributions. Upgrade to PHP 5.4 using a repository like <a href="http://blog.famillecollet.com/pages/Config-en" target="_blank">remi</a>. @@ -275,6 +300,27 @@ The following resources are also available: * <a href="http://stackoverflow.com/questions/21502656/upgrading-php-on-centos-6-5-final" target="_blank">stackoverflow</a> * <a href="http://rpms.famillecollet.com/" target="_blank">remi repository</a> +To verify if PHP is installed already, enter `php -v`. If PHP is *not* installed, install it by entering the following command: + +<pre>yum -y install php php-xml</pre> + +<h5>PHP 5.5 on CentOS</h5> + +To upgrade to PHP 5.5: + +There is more than one way to upgrade CentOS 6.5 to PHP 5.5; the following is a suggestion only. Consult a reference for additional options. + +Enter the following commands in the order shown. + +<pre>cd /tmp +rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm +yum -y remove php-common-5.3.3-40.el6_6.x86_64 +yum -y install php55w php55w-opcache</pre> + +Restart Apache: `service httpd restart` + +<h5>PHP 5.4 on CentOS</h5> + To upgrade to PHP 5.4: 1. Enter the following commands: diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index 3dffdb3ab9f..0a12e71e6b9 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json index 5113d36a735..2da1ea7e8af 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-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 37ef6cf7b4d..b70c369f0d1 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-centinel": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-centinel": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Authorizenet/etc/module.xml b/app/code/Magento/Authorizenet/etc/module.xml index 4315ec97143..dd8f3d7b1bb 100644 --- a/app/code/Magento/Authorizenet/etc/module.xml +++ b/app/code/Magento/Authorizenet/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Authorizenet" schema_version="1.5.0.0" active="true"> + <module name="Magento_Authorizenet" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Sales"/> <module name="Magento_Checkout"/> diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index d994c01355c..bdb90397bc7 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-reports": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-user": "0.1.0-alpha103", - "magento/module-backup": "0.1.0-alpha103", - "magento/module-email": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-translation": "0.1.0-alpha103", - "magento/module-require-js": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-reports": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-user": "0.1.0-alpha104", + "magento/module-backup": "0.1.0-alpha104", + "magento/module-email": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-translation": "0.1.0-alpha104", + "magento/module-require-js": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index b6c59756af7..5d96e1b1525 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Bundle/Model/Resource/Bundle.php b/app/code/Magento/Bundle/Model/Resource/Bundle.php index 1d1fcb0c828..06ba75dd60e 100644 --- a/app/code/Magento/Bundle/Model/Resource/Bundle.php +++ b/app/code/Magento/Bundle/Model/Resource/Bundle.php @@ -103,7 +103,7 @@ class Bundle extends \Magento\Framework\Model\Resource\Db\AbstractDb { $quoteItemIds = $this->_getReadAdapter()->fetchCol( $this->_getReadAdapter()->select()->from( - $this->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), array('item_id') )->where( 'product_id = :product_id' @@ -113,7 +113,7 @@ class Bundle extends \Magento\Framework\Model\Resource\Db\AbstractDb if ($quoteItemIds) { $this->_getWriteAdapter()->delete( - $this->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), array('parent_item_id IN(?)' => $quoteItemIds) ); } diff --git a/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php b/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php index fee3a136a41..4b91958ff0b 100644 --- a/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php +++ b/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php @@ -159,6 +159,6 @@ class ConfiguredPrice extends CatalogPrice\FinalPrice implements ConfiguredPrice */ public function getAmount() { - return $this->item ? $this->getConfiguredAmount($this->basePrice->getValue()) : parent::getAmount(); + return $this->item ? $this->getConfiguredAmount($this->getBasePrice()->getValue()) : parent::getAmount(); } } diff --git a/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php b/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php index 20b476821d7..ea0d37e105a 100644 --- a/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php +++ b/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php @@ -44,7 +44,6 @@ class FinalPrice extends \Magento\Catalog\Pricing\Price\FinalPrice CalculatorInterface $calculator ) { parent::__construct($saleableItem, $quantity, $calculator); - $this->basePrice = $this->priceInfo->getPrice(BasePrice::PRICE_CODE); } /** @@ -65,7 +64,7 @@ class FinalPrice extends \Magento\Catalog\Pricing\Price\FinalPrice */ public function getMaximalPrice() { - return $this->calculator->getMaxAmount($this->basePrice->getValue(), $this->product); + return $this->calculator->getMaxAmount($this->getBasePrice()->getValue(), $this->product); } /** diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index d6d155375dc..3da664632b6 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -3,24 +3,24 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-catalog-rule": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-gift-message": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-webapi": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-catalog-rule": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-gift-message": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-webapi": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index cc309049acf..b49a2e0e8a4 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-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/Block/Widget/Link.php b/app/code/Magento/Catalog/Block/Widget/Link.php index 2d94f12ab8c..0646d46f702 100644 --- a/app/code/Magento/Catalog/Block/Widget/Link.php +++ b/app/code/Magento/Catalog/Block/Widget/Link.php @@ -65,15 +65,18 @@ class Link extends \Magento\Framework\View\Element\Html\Link implements \Magento /** * @param \Magento\Framework\View\Element\Template\Context $context * @param UrlFinderInterface $urlFinder + * @param \Magento\Catalog\Model\Resource\AbstractResource $entityResource * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, UrlFinderInterface $urlFinder, + \Magento\Catalog\Model\Resource\AbstractResource $entityResource = null, array $data = [] ) { parent::__construct($context, $data); $this->urlFinder = $urlFinder; + $this->_entityResource = $entityResource; } /** @@ -141,8 +144,10 @@ class Link extends \Magento\Framework\View\Element\Html\Link implements \Magento */ public function getLabel() { - if (!$this->_anchorText && $this->_entityResource) { - if (!$this->getData('label')) { + if (!$this->_anchorText) { + if ($this->getData('anchor_text')) { + $this->_anchorText = $this->getData('anchor_text'); + } else if ($this->_entityResource) { $idPath = explode('/', $this->_getData('id_path')); if (isset($idPath[1])) { $id = $idPath[1]; @@ -154,8 +159,6 @@ class Link extends \Magento\Framework\View\Element\Html\Link implements \Magento ); } } - } else { - $this->_anchorText = $this->getData('label'); } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index e058fd04d23..356305b3381 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -170,6 +170,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut $stockItemService->saveStockItem( $this->stockItemBuilder->mergeDataObjectWithArray($stockItemDo, $inventoryData) + ->create() ); } $this->_stockIndexerProcessor->reindexList($this->attributeHelper->getProductIds()); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php index cafe26ca2e5..4aca282ffe1 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php @@ -111,8 +111,6 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product } } - $this->_objectManager->create('Magento\CatalogRule\Model\Rule')->applyAllRulesToProduct($productId); - $this->messageManager->addSuccess(__('You saved the product.')); if ($product->getSku() != $originalSku) { $this->messageManager->addNotice( diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php index 873eb1a50ab..74583add4bc 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php @@ -43,13 +43,11 @@ class Customlayoutupdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Abs /** * Construct the custom layout update class * - * @param \Magento\Framework\Logger $logger * @param ValidatorFactory $layoutUpdateValidatorFactory */ - public function __construct(\Magento\Framework\Logger $logger, ValidatorFactory $layoutUpdateValidatorFactory) + public function __construct(ValidatorFactory $layoutUpdateValidatorFactory) { $this->_layoutUpdateValidatorFactory = $layoutUpdateValidatorFactory; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index f367d9e74d8..f7f2197b8b5 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -174,22 +174,15 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ */ protected $flatState; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $flatIndexer; - - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $productIndexer; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ protected $categoryUrlPathGenerator; /** @var UrlFinderInterface */ protected $urlFinder; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -203,10 +196,9 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ * @param Config $catalogConfig * @param \Magento\Framework\Filter\FilterManager $filter * @param Indexer\Category\Flat\State $flatState - * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer - * @param \Magento\Indexer\Model\IndexerInterface $productIndexer * @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator * @param UrlFinderInterface $urlFinder + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -224,10 +216,9 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ \Magento\Catalog\Model\Config $catalogConfig, \Magento\Framework\Filter\FilterManager $filter, Indexer\Category\Flat\State $flatState, - \Magento\Indexer\Model\IndexerInterface $flatIndexer, - \Magento\Indexer\Model\IndexerInterface $productIndexer, \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator, UrlFinderInterface $urlFinder, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -239,12 +230,11 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ $this->_url = $url; $this->_productCollectionFactory = $productCollectionFactory; $this->_catalogConfig = $catalogConfig; - $this->productIndexer = $productIndexer; $this->filter = $filter; $this->flatState = $flatState; - $this->flatIndexer = $flatIndexer; $this->categoryUrlPathGenerator = $categoryUrlPathGenerator; $this->urlFinder = $urlFinder; + $this->indexerRegistry = $indexerRegistry; parent::__construct($context, $registry, $storeManager, $resource, $resourceCollection, $data); } @@ -274,32 +264,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ return $this->_useFlatResource; } - /** - * Return flat indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getFlatIndexer() - { - if (!$this->flatIndexer->getId()) { - $this->flatIndexer->load(Indexer\Category\Flat\State::INDEXER_ID); - } - return $this->flatIndexer; - } - - /** - * Return category product indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getProductIndexer() - { - if (!$this->productIndexer->getId()) { - $this->productIndexer->load(Indexer\Category\Product::INDEXER_ID); - } - return $this->productIndexer; - } - /** * Retrieve URL instance * @@ -395,11 +359,15 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ throw $e; } $this->_eventManager->dispatch('category_move', $eventParams); - if ($this->flatState->isFlatEnabled() && !$this->getFlatIndexer()->isScheduled()) { - $this->getFlatIndexer()->reindexList(array($this->getId(), $oldParentId, $parentId)); + if ($this->flatState->isFlatEnabled()) { + $flatIndexer = $this->indexerRegistry->get(Indexer\Category\Flat\State::INDEXER_ID); + if (!$flatIndexer->isScheduled()) { + $flatIndexer->reindexList(array($this->getId(), $oldParentId, $parentId)); + } } - if (!$this->getProductIndexer()->isScheduled()) { - $this->getProductIndexer()->reindexList(array_merge($this->getPathIds(), $oldParentIds)); + $productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID); + if (!$productIndexer->isScheduled()) { + $productIndexer->reindexList(array_merge($this->getPathIds(), $oldParentIds)); } $this->_cacheManager->clean(array(self::CACHE_TAG)); @@ -1036,11 +1004,15 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ */ public function reindex() { - if ($this->flatState->isFlatEnabled() && !$this->getFlatIndexer()->isScheduled()) { - $this->getFlatIndexer()->reindexRow($this->getId()); + if ($this->flatState->isFlatEnabled()) { + $flatIndexer = $this->indexerRegistry->get(Indexer\Category\Flat\State::INDEXER_ID); + if (!$flatIndexer->isScheduled()) { + $flatIndexer->reindexRow($this->getId()); + } } - if (!$this->getProductIndexer()->isScheduled()) { - $this->getProductIndexer()->reindexList($this->getPathIds()); + $productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID); + if (!$productIndexer->isScheduled()) { + $productIndexer->reindexList($this->getPathIds()); } } diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php index 313507ef63b..cd796c39b43 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php @@ -53,6 +53,11 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ protected $_fileUploaderFactory; + /** + * @var \Magento\Framework\Logger + */ + protected $_logger; + /** * Construct * @@ -67,7 +72,7 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend ) { $this->_filesystem = $filesystem; $this->_fileUploaderFactory = $fileUploaderFactory; - parent::__construct($logger); + $this->_logger = $logger; } /** diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php index 3fda0549932..59fc4767a02 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php @@ -40,13 +40,11 @@ class Sortby extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Construct * - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) + public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) { $this->_scopeConfig = $scopeConfig; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php index 28ef8cff07a..b2c5107f42d 100644 --- a/app/code/Magento/Catalog/Model/Config.php +++ b/app/code/Magento/Catalog/Model/Config.php @@ -135,6 +135,7 @@ class Config extends \Magento\Eav\Model\Config * * @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory + * @param \Magento\Eav\Model\Resource\Entity\Type\CollectionFactory $entityTypeCollectionFactory, * @param \Magento\Framework\App\Cache\StateInterface $cacheState * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -150,6 +151,7 @@ class Config extends \Magento\Eav\Model\Config public function __construct( \Magento\Framework\App\CacheInterface $cache, \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory, + \Magento\Eav\Model\Resource\Entity\Type\CollectionFactory $entityTypeCollectionFactory, \Magento\Framework\App\Cache\StateInterface $cacheState, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -168,7 +170,7 @@ class Config extends \Magento\Eav\Model\Config $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; - parent::__construct($cache, $entityTypeFactory, $cacheState, $universalFactory); + parent::__construct($cache, $entityTypeFactory, $entityTypeCollectionFactory, $cacheState, $universalFactory); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php index 0bd094093c3..20db245a69f 100644 --- a/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php +++ b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php @@ -23,6 +23,8 @@ */ namespace Magento\Catalog\Model\Indexer; +use Magento\Store\Model\ScopeInterface; + abstract class AbstractFlatState { /** @@ -45,23 +47,21 @@ abstract class AbstractFlatState */ protected $isAvailable; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $flatIndexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param bool $isAvailable */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Indexer\Model\IndexerInterface $flatIndexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, $isAvailable = false ) { $this->scopeConfig = $scopeConfig; - $this->flatIndexer = $flatIndexer; + $this->indexerRegistry = $indexerRegistry; $this->isAvailable = $isAvailable; } @@ -72,7 +72,7 @@ abstract class AbstractFlatState */ public function isFlatEnabled() { - return $this->scopeConfig->isSetFlag(static::INDEXER_ENABLED_XML_PATH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + return $this->scopeConfig->isSetFlag(static::INDEXER_ENABLED_XML_PATH, ScopeInterface::SCOPE_STORE); } /** @@ -82,19 +82,7 @@ abstract class AbstractFlatState */ public function isAvailable() { - return $this->isAvailable && $this->isFlatEnabled() && $this->getFlatIndexer()->isValid(); - } - - /** - * Return indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getFlatIndexer() - { - if (!$this->flatIndexer->getId()) { - $this->flatIndexer->load(static::INDEXER_ID); - } - return $this->flatIndexer; + return $this->isAvailable && $this->isFlatEnabled() + && $this->indexerRegistry->get(static::INDEXER_ID)->isValid(); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php index a7da30396ba..6475fcefe41 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php @@ -35,24 +35,22 @@ class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework */ protected $rowsActionFactory; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @param Flat\Action\FullFactory $fullActionFactory * @param Flat\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( Flat\Action\FullFactory $fullActionFactory, Flat\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerInterface $indexer + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { $this->fullActionFactory = $fullActionFactory; $this->rowsActionFactory = $rowsActionFactory; - $this->indexer = $indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -63,14 +61,14 @@ class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework */ public function execute($ids) { - $this->indexer->load(Flat\State::INDEXER_ID); - if ($this->indexer->isInvalid()) { + $indexer = $this->indexerRegistry->get(Flat\State::INDEXER_ID); + if ($indexer->isInvalid()) { return; } /** @var Flat\Action\Rows $action */ $action = $this->rowsActionFactory->create(); - if ($this->indexer->isWorking()) { + if ($indexer->isWorking()) { $action->reindex($ids, true); } $action->reindex($ids); @@ -92,7 +90,7 @@ class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->execute($ids); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php index 3073d01df6b..757a2a6e73c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php @@ -25,10 +25,8 @@ namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin; class StoreGroup { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @var \Magento\Catalog\Model\Indexer\Category\Flat\State @@ -36,30 +34,17 @@ class StoreGroup protected $state; /** - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Catalog\Model\Indexer\Category\Flat\State $state */ public function __construct( - \Magento\Indexer\Model\IndexerInterface $indexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Category\Flat\State $state ) { - $this->indexer = $indexer; + $this->indexerRegistry = $indexerRegistry; $this->state = $state; } - /** - * Return own indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getIndexer() - { - if (!$this->indexer->getId()) { - $this->indexer->load(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID); - } - return $this->indexer; - } - /** * Validate changes for invalidating indexer * @@ -87,7 +72,7 @@ class StoreGroup $needInvalidating = $this->validate($group); $objectResource = $proceed($group); if ($needInvalidating && $this->state->isFlatEnabled()) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)->invalidate(); } return $objectResource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php index e13f2aebe8c..42e5c3be739 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php @@ -28,21 +28,17 @@ namespace Magento\Catalog\Model\Indexer\Category\Flat\System\Config; */ class Mode extends \Magento\Framework\App\Config\Value { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $flatIndexer; - - /** - * @var \Magento\Indexer\Model\Indexer\State - */ + /** @var \Magento\Indexer\Model\Indexer\State */ protected $indexerState; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Indexer\Model\Indexer\State $indexerState * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -52,15 +48,15 @@ class Mode extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Indexer\Model\IndexerInterface $flatIndexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Indexer\Model\Indexer\State $indexerState, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->flatIndexer = $flatIndexer; - $this->indexerState = $indexerState; parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + $this->indexerRegistry = $indexerRegistry; + $this->indexerState = $indexerState; } /** @@ -87,8 +83,8 @@ class Mode extends \Magento\Framework\App\Config\Value $this->indexerState->setStatus(\Magento\Indexer\Model\Indexer\State::STATUS_INVALID); $this->indexerState->save(); } else { - $this->flatIndexer->load(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID); - $this->flatIndexer->setScheduled(false); + $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) + ->setScheduled(false); } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php index 0c5c9be366e..d98fa6032f7 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php @@ -40,24 +40,22 @@ class Product implements \Magento\Indexer\Model\ActionInterface, \Magento\Framew */ protected $rowsActionFactory; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @param Product\Action\FullFactory $fullActionFactory * @param Product\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( Product\Action\FullFactory $fullActionFactory, Product\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerInterface $indexer + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { $this->fullActionFactory = $fullActionFactory; $this->rowsActionFactory = $rowsActionFactory; - $this->indexer = $indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -87,7 +85,7 @@ class Product implements \Magento\Indexer\Model\ActionInterface, \Magento\Framew * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->executeAction($ids); } @@ -112,11 +110,11 @@ class Product implements \Magento\Indexer\Model\ActionInterface, \Magento\Framew protected function executeAction($ids) { $ids = array_unique($ids); - $this->indexer->load(static::INDEXER_ID); + $indexer = $this->indexerRegistry->get(static::INDEXER_ID); /** @var Product\Action\Rows $action */ $action = $this->rowsActionFactory->create(); - if ($this->indexer->isWorking()) { + if ($indexer->isWorking()) { $action->execute($ids, true); } $action->execute($ids); diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php index 6479a1619eb..424361b6ffc 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php @@ -25,30 +25,15 @@ namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin; class StoreGroup { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ - public function __construct(\Magento\Indexer\Model\IndexerInterface $indexer) + public function __construct(\Magento\Indexer\Model\IndexerRegistry $indexerRegistry) { - $this->indexer = $indexer; - } - - /** - * Return own indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getIndexer() - { - if (!$this->indexer->getId()) { - $this->indexer->load(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID); - } - return $this->indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -65,7 +50,7 @@ class StoreGroup $needInvalidating = $this->validate($group); $objectResource = $proceed($group); if ($needInvalidating) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID)->invalidate(); } return $objectResource; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category.php index b1585e3866b..91c9da8a91c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Category.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category.php @@ -33,13 +33,13 @@ class Category extends \Magento\Catalog\Model\Indexer\Category\Product /** * @param \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory $fullActionFactory * @param Category\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( \Magento\Catalog\Model\Indexer\Category\Product\Action\FullFactory $fullActionFactory, Category\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerInterface $indexer + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { - parent::__construct($fullActionFactory, $rowsActionFactory, $indexer); + parent::__construct($fullActionFactory, $rowsActionFactory, $indexerRegistry); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php b/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php index b82bc3e5b36..48406c60380 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Eav.php @@ -82,7 +82,7 @@ class Eav implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework\ * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->_productEavIndexerRows->execute($ids); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php index 82f73f78170..52feb5ff1e2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat.php @@ -82,7 +82,7 @@ class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Framework * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->_productFlatIndexerRows->execute($ids); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php index 0a66b0a8a45..c87a0d02819 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Processor.php @@ -36,14 +36,14 @@ class Processor extends \Magento\Indexer\Model\Indexer\AbstractProcessor protected $_state; /** - * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory - * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $state + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry + * @param State $state */ public function __construct( - \Magento\Indexer\Model\IndexerFactory $indexerFactory, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Product\Flat\State $state ) { - $this->_indexer = $indexerFactory->create(); + parent::__construct($indexerRegistry); $this->_state = $state; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php index c1c8e0653fd..681d97b6333 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/State.php @@ -42,21 +42,18 @@ class State extends \Magento\Catalog\Model\Indexer\AbstractFlatState /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Catalog\Helper\Product\Flat\Indexer $flatIndexerHelper * @param bool $isAvailable */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Indexer\Model\IndexerInterface $flatIndexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Catalog\Helper\Product\Flat\Indexer $flatIndexerHelper, $isAvailable = false ) { - $this->scopeConfig = $scopeConfig; - $this->flatIndexer = $flatIndexer; + parent::__construct($scopeConfig, $indexerRegistry, $isAvailable); $this->_productFlatIndexerHelper = $flatIndexerHelper; - $this->isAvailable = $isAvailable; - parent::__construct($scopeConfig, $flatIndexer, $isAvailable); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price.php index 89a23c8246c..b2af851b0e6 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price.php @@ -82,7 +82,7 @@ class Price implements \Magento\Indexer\Model\ActionInterface, \Magento\Framewor * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->_productPriceIndexerRows->execute($ids); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php index d8fda1c8243..ddbec8a7a9b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/AbstractPlugin.php @@ -25,30 +25,15 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; abstract class AbstractPlugin { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; - - /** - * @param \Magento\Indexer\Model\IndexerInterface $indexer - */ - public function __construct(\Magento\Indexer\Model\IndexerInterface $indexer) - { - $this->indexer = $indexer; - } + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** - * Return own indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ - protected function getIndexer() + public function __construct(\Magento\Indexer\Model\IndexerRegistry $indexerRegistry) { - if (!$this->indexer->getId()) { - $this->indexer->load(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); - } - return $this->indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -58,6 +43,6 @@ abstract class AbstractPlugin */ protected function invalidateIndexer() { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)->invalidate(); } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php index 5c129adf54c..5c0235eb97a 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php @@ -28,16 +28,14 @@ namespace Magento\Catalog\Model\Indexer\Product\Price\System\Config; */ class PriceScope extends \Magento\Framework\App\Config\Value { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -46,13 +44,13 @@ class PriceScope extends \Magento\Framework\App\Config\Value \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Indexer\Model\IndexerInterface $indexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->indexer = $indexer; parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + $this->indexerRegistry = $indexerRegistry; } /** @@ -74,7 +72,8 @@ class PriceScope extends \Magento\Framework\App\Config\Value public function processValue() { if ($this->isValueChanged()) { - $this->indexer->load(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)->invalidate(); + $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) + ->invalidate(); } } } diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 3474930ad77..f201d28fd7d 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -236,10 +236,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn */ protected $_filesystem; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $categoryIndexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor @@ -282,10 +280,10 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn * @param Resource\Product\Collection $resourceCollection * @param \Magento\Framework\Data\CollectionFactory $collectionFactory * @param \Magento\Framework\Filesystem $filesystem - * @param \Magento\Indexer\Model\IndexerInterface $categoryIndexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param Indexer\Product\Price\Processor $productPriceIndexerProcessor - * @param \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor + * @param Indexer\Product\Eav\Processor $productEavIndexerProcessor * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -311,7 +309,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn Resource\Product\Collection $resourceCollection, \Magento\Framework\Data\CollectionFactory $collectionFactory, \Magento\Framework\Filesystem $filesystem, - \Magento\Indexer\Model\IndexerInterface $categoryIndexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor, @@ -332,7 +330,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn $this->_urlModel = $url; $this->_linkInstance = $productLink; $this->_filesystem = $filesystem; - $this->categoryIndexer = $categoryIndexer; + $this->indexerRegistry = $indexerRegistry; $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; $this->_productEavIndexerProcessor = $productEavIndexerProcessor; @@ -349,19 +347,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn $this->_init('Magento\Catalog\Model\Resource\Product'); } - /** - * Return product category indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getCategoryIndexer() - { - if (!$this->categoryIndexer->getId()) { - $this->categoryIndexer->load(Indexer\Product\Category::INDEXER_ID); - } - return $this->categoryIndexer; - } - /** * Retrieve Store Id * @@ -804,8 +789,9 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements IdentityIn public function reindex() { $this->_productFlatIndexerProcessor->reindexRow($this->getEntityId()); - if (!$this->getCategoryIndexer()->isScheduled()) { - $this->getCategoryIndexer()->reindexRow($this->getId()); + $categoryIndexer = $this->indexerRegistry->get(Indexer\Product\Category::INDEXER_ID); + if (!$categoryIndexer->isScheduled()) { + $categoryIndexer->reindexRow($this->getId()); } } diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php index 6a77bc1cb88..8c63430174b 100644 --- a/app/code/Magento/Catalog/Model/Product/Action.php +++ b/app/code/Magento/Catalog/Model/Product/Action.php @@ -37,10 +37,8 @@ class Action extends \Magento\Framework\Model\AbstractModel */ protected $_productWebsiteFactory; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $categoryIndexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @var \Magento\Eav\Model\Config @@ -55,8 +53,8 @@ class Action extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Model\Product\WebsiteFactory $productWebsiteFactory - * @param \Magento\Indexer\Model\IndexerInterface $categoryIndexer + * @param WebsiteFactory $productWebsiteFactory + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -67,7 +65,7 @@ class Action extends \Magento\Framework\Model\AbstractModel \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Model\Product\WebsiteFactory $productWebsiteFactory, - \Magento\Indexer\Model\IndexerInterface $categoryIndexer, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, \Magento\Eav\Model\Config $eavConfig, \Magento\Catalog\Model\Indexer\Product\Eav\Processor $productEavIndexerProcessor, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -75,7 +73,7 @@ class Action extends \Magento\Framework\Model\AbstractModel array $data = array() ) { $this->_productWebsiteFactory = $productWebsiteFactory; - $this->categoryIndexer = $categoryIndexer; + $this->indexerRegistry = $indexerRegistry; $this->_eavConfig = $eavConfig; $this->_productEavIndexerProcessor = $productEavIndexerProcessor; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -91,19 +89,6 @@ class Action extends \Magento\Framework\Model\AbstractModel $this->_init('Magento\Catalog\Model\Resource\Product\Action'); } - /** - * Return product category indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getCategoryIndexer() - { - if (!$this->categoryIndexer->getId()) { - $this->categoryIndexer->load(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID); - } - return $this->categoryIndexer; - } - /** * Retrieve resource instance wrapper * @@ -138,8 +123,9 @@ class Action extends \Magento\Framework\Model\AbstractModel $this->_productEavIndexerProcessor->reindexList(array_unique($productIds)); } - if (!$this->getCategoryIndexer()->isScheduled()) { - $this->getCategoryIndexer()->reindexList(array_unique($productIds)); + $categoryIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID); + if (!$categoryIndexer->isScheduled()) { + $categoryIndexer->reindexList(array_unique($productIds)); } return $this; } @@ -199,8 +185,9 @@ class Action extends \Magento\Framework\Model\AbstractModel array('product_ids' => array_unique($productIds), 'website_ids' => $websiteIds, 'action_type' => $type) ); - if (!$this->getCategoryIndexer()->isScheduled()) { - $this->getCategoryIndexer()->reindexList(array_unique($productIds)); + $categoryIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID); + if (!$categoryIndexer->isScheduled()) { + $categoryIndexer->reindexList(array_unique($productIds)); } } } 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 59e690c995c..43ab6908a58 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php @@ -38,7 +38,6 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp protected $_productAttributeBackendGroupprice; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData @@ -47,7 +46,6 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice $productAttributeBackendGroupprice */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, @@ -56,7 +54,7 @@ class Groupprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Groupp \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice $productAttributeBackendGroupprice ) { $this->_productAttributeBackendGroupprice = $productAttributeBackendGroupprice; - parent::__construct($logger, $currencyFactory, $storeManager, $catalogData, $config, $catalogProductType); + parent::__construct($currencyFactory, $storeManager, $catalogData, $config, $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 c519659e4b9..c83318bcf68 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 @@ -54,7 +54,6 @@ abstract class AbstractGroupprice extends Price protected $_catalogProductType; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData @@ -62,7 +61,6 @@ abstract class AbstractGroupprice extends Price * @param \Magento\Catalog\Model\Product\Type $catalogProductType */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, @@ -70,7 +68,7 @@ abstract class AbstractGroupprice extends Price \Magento\Catalog\Model\Product\Type $catalogProductType ) { $this->_catalogProductType = $catalogProductType; - parent::__construct($logger, $currencyFactory, $storeManager, $catalogData, $config); + parent::__construct($currencyFactory, $storeManager, $catalogData, $config); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php index 183594e8200..90dac23eae4 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php @@ -87,7 +87,6 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Construct * - * @param \Magento\Framework\Logger $logger * @param \Magento\Catalog\Model\Resource\ProductFactory $productFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Core\Helper\File\Storage\Database $fileStorageDb @@ -97,7 +96,6 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $resourceProductAttribute */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Catalog\Model\Resource\ProductFactory $productFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Core\Helper\File\Storage\Database $fileStorageDb, @@ -113,7 +111,6 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $this->_resourceModel = $resourceProductAttribute; $this->_mediaConfig = $mediaConfig; $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - parent::__construct($logger); } /** 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 38db2957444..a3944b4bf9e 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -61,14 +61,12 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Construct * - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @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\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, @@ -78,7 +76,6 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $this->_storeManager = $storeManager; $this->_helper = $catalogData; $this->_config = $config; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php index a97a2a7ca01..b8b7c030dc0 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php @@ -48,13 +48,11 @@ class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend protected $string; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\String $string */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\String $string) + public function __construct(\Magento\Framework\Stdlib\String $string) { $this->string = $string; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php index a6aec8f28e8..73d2e82248a 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php @@ -41,17 +41,15 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime /** * Constructor * - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime\DateTime $date */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime\DateTime $date ) { $this->_date = $date; - parent::__construct($logger, $localeDate); + parent::__construct($localeDate); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php index f83fd3ae758..1b8d4c0cd26 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php @@ -41,15 +41,11 @@ class Stock extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Construct * - * @param \Magento\Framework\Logger $logger * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService */ - public function __construct( - \Magento\Framework\Logger $logger, - \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService - ) { + public function __construct(\Magento\CatalogInventory\Service\V1\StockItemService $stockItemService) + { $this->stockItemService = $stockItemService; - parent::__construct($logger); } /** 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 28fc31e5818..6b1b2cc5974 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php @@ -40,7 +40,6 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr protected $_productAttributeBackendTierprice; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData @@ -49,7 +48,6 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice $productAttributeTierprice */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, @@ -58,7 +56,7 @@ class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\Grouppr \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice $productAttributeTierprice ) { $this->_productAttributeBackendTierprice = $productAttributeTierprice; - parent::__construct($logger, $currencyFactory, $storeManager, $catalogData, $config, $catalogProductType); + parent::__construct($currencyFactory, $storeManager, $catalogData, $config, $catalogProductType); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php index 3d002f93e55..36f0515af5d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category.php +++ b/app/code/Magento/Catalog/Model/Resource/Category.php @@ -523,7 +523,7 @@ class Category extends AbstractResource public function getChildrenAmount($category, $isActiveFlag = true) { $storeId = $this->_storeManager->getStore()->getId(); - $attributeId = $this->_getIsActiveAttributeId(); + $attributeId = $this->getIsActiveAttributeId(); $table = $this->getTable(array($this->getEntityTablePrefix(), 'int')); $adapter = $this->_getReadAdapter(); $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); @@ -559,25 +559,13 @@ class Category extends AbstractResource * * @return int */ - protected function _getIsActiveAttributeId() + public function getIsActiveAttributeId() { if ($this->_isActiveAttributeId === null) { - $bind = array('catalog_category' => \Magento\Catalog\Model\Category::ENTITY, 'is_active' => 'is_active'); - $select = $this->_getReadAdapter()->select()->from( - array('a' => $this->getTable('eav_attribute')), - array('attribute_id') - )->join( - array('t' => $this->getTable('eav_entity_type')), - 'a.entity_type_id = t.entity_type_id' - )->where( - 'entity_type_code = :catalog_category' - )->where( - 'attribute_code = :is_active' - ); - - $this->_isActiveAttributeId = $this->_getReadAdapter()->fetchOne($select, $bind); + $this->_isActiveAttributeId = (int)$this->_eavConfig + ->getAttribute($this->getEntityType(), 'is_active') + ->getAttributeId(); } - return $this->_isActiveAttributeId; } @@ -760,7 +748,7 @@ class Category extends AbstractResource */ public function getChildren($category, $recursive = true) { - $attributeId = (int)$this->_getIsActiveAttributeId(); + $attributeId = $this->getIsActiveAttributeId(); $backendTable = $this->getTable(array($this->getEntityTablePrefix(), 'int')); $adapter = $this->_getReadAdapter(); $checkSql = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php index 79bf34f7002..0ba58e25492 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php @@ -55,13 +55,6 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp */ protected $_collection; - /** - * Id of 'is_active' category attribute - * - * @var int - */ - protected $_isActiveAttributeId = null; - /** * Join URL rewrites data to collection flag * @@ -309,35 +302,6 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp return $disabledIds; } - /** - * Returns attribute id for attribute "is_active" - * - * @return int - */ - protected function _getIsActiveAttributeId() - { - if (is_null($this->_isActiveAttributeId)) { - $bind = array( - 'entity_type_code' => \Magento\Catalog\Model\Category::ENTITY, - 'attribute_code' => 'is_active' - ); - $select = $this->_conn->select()->from( - array('a' => $this->_coreResource->getTableName('eav_attribute')), - array('attribute_id') - )->join( - array('t' => $this->_coreResource->getTableName('eav_entity_type')), - 'a.entity_type_id = t.entity_type_id' - )->where( - 'entity_type_code = :entity_type_code' - )->where( - 'attribute_code = :attribute_code' - ); - - $this->_isActiveAttributeId = $this->_conn->fetchOne($select, $bind); - } - return $this->_isActiveAttributeId; - } - /** * Retrieve inactive category item ids * @@ -348,7 +312,7 @@ class Tree extends \Magento\Framework\Data\Tree\Dbp protected function _getInactiveItemIds($collection, $storeId) { $filter = $collection->getAllIdsSql(); - $attributeId = $this->_getIsActiveAttributeId(); + $attributeId = $this->_catalogCategory->getIsActiveAttributeId(); $conditionSql = $this->_conn->getCheckSql('c.value_id > 0', 'c.value', 'd.value'); $table = $this->_coreResource->getTableName('catalog_category_entity_int'); diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php index 174fb186153..c07b975dd6d 100644 --- a/app/code/Magento/Catalog/Model/Resource/Config.php +++ b/app/code/Magento/Catalog/Model/Resource/Config.php @@ -104,7 +104,7 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb public function getStoreId() { if ($this->_storeId === null) { - return $this->_storeManager->getStore()->getId(); + $this->_storeId = (int)$this->_storeManager->getStore()->getId(); } return $this->_storeId; } @@ -117,7 +117,8 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb public function getEntityTypeId() { if ($this->_entityTypeId === null) { - $this->_entityTypeId = $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId(); + $this->_entityTypeId = (int)$this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY) + ->getId(); } return $this->_entityTypeId; } @@ -143,12 +144,11 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb array('store_label' => $storeLabelExpr) )->where( 'main_table.entity_type_id = ?', - (int)$this->getEntityTypeId() + $this->getEntityTypeId() )->where( 'additional_table.used_in_product_listing = ?', 1 ); - return $adapter->fetchAll($select); } @@ -169,16 +169,15 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb array() )->joinLeft( array('al' => $this->getTable('eav_attribute_label')), - 'al.attribute_id = main_table.attribute_id AND al.store_id = ' . (int)$this->getStoreId(), + 'al.attribute_id = main_table.attribute_id AND al.store_id = ' . $this->getStoreId(), array('store_label' => $storeLabelExpr) )->where( 'main_table.entity_type_id = ?', - (int)$this->getEntityTypeId() + $this->getEntityTypeId() )->where( 'additional_table.used_for_sort_by = ?', 1 ); - return $adapter->fetchAll($select); } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php index 4fc18afeaa1..5157da8a52e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php @@ -48,18 +48,15 @@ class Image extends AbstractBackend protected $_fileUploaderFactory; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Core\Model\File\UploaderFactory $fileUploaderFactory */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Framework\Filesystem $filesystem, \Magento\Core\Model\File\UploaderFactory $fileUploaderFactory ) { $this->_filesystem = $filesystem; $this->_fileUploaderFactory = $fileUploaderFactory; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index ecd76ffd110..1c770959368 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -1331,40 +1331,6 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl return $this->addPriceData(); } - /** - * Join prices from price rules to products collection - * - * @return $this - */ - protected function _joinPriceRules() - { - if ($this->isEnabledFlat()) { - $customerGroup = $this->_customerSession->getCustomerGroupId(); - $priceColumn = 'e.display_price_group_' . $customerGroup; - $this->getSelect()->columns(array('_rule_price' => $priceColumn)); - - return $this; - } - if (!$this->moduleManager->isEnabled('Magento_CatalogRule')) { - return $this; - } - $wId = $this->_storeManager->getWebsite()->getId(); - $gId = $this->_customerSession->getCustomerGroupId(); - - $storeDate = $this->_localeDate->scopeTimeStamp($this->getStoreId()); - $conditions = 'price_rule.product_id = e.entity_id AND '; - $conditions .= "price_rule.rule_date = '" . $this->dateTime->formatDate($storeDate, false) . "' AND "; - $conditions .= $this->getConnection()->quoteInto('price_rule.website_id = ? AND', $wId); - $conditions .= $this->getConnection()->quoteInto('price_rule.customer_group_id = ?', $gId); - - $this->getSelect()->joinLeft( - array('price_rule' => $this->getTable('catalogrule_product_price')), - $conditions, - array('rule_price' => 'rule_price') - ); - return $this; - } - /** * Retrieve all ids * diff --git a/app/code/Magento/Catalog/Plugin/Model/Resource/Config.php b/app/code/Magento/Catalog/Plugin/Model/Resource/Config.php new file mode 100644 index 00000000000..033cd7f2bb0 --- /dev/null +++ b/app/code/Magento/Catalog/Plugin/Model/Resource/Config.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\Catalog\Plugin\Model\Resource; + +class Config +{ + /**#@+ + * Product listing attributes cache ids + */ + const PRODUCT_LISTING_ATTRIBUTES_CACHE_ID = 'PRODUCT_LISTING_ATTRIBUTES'; + const PRODUCT_LISTING_SORT_BY_ATTRIBUTES_CACHE_ID = 'PRODUCT_LISTING_SORT_BY_ATTRIBUTES'; + /**#@-*/ + + /** @var \Magento\Framework\App\CacheInterface */ + protected $cache; + + /** @var bool|null */ + protected $isCacheEnabled = null; + + /** + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Magento\Framework\App\Cache\StateInterface $cacheState + */ + public function __construct( + \Magento\Framework\App\CacheInterface $cache, + \Magento\Framework\App\Cache\StateInterface $cacheState + ) { + $this->cache = $cache; + $this->isCacheEnabled = $cacheState->isEnabled(\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER); + } + + /** + * @param \Magento\Catalog\Model\Resource\Config $config + * @param callable $proceed + * @return array + */ + public function aroundGetAttributesUsedInListing(\Magento\Catalog\Model\Resource\Config $config, \Closure $proceed) + { + $cacheId = self::PRODUCT_LISTING_ATTRIBUTES_CACHE_ID . $config->getEntityTypeId() . '_' . $config->getStoreId(); + if ($this->isCacheEnabled && ($attributes = $this->cache->load($cacheId))) { + return unserialize($attributes); + } + $attributes = $proceed(); + if ($this->isCacheEnabled) { + $this->cache->save( + serialize($attributes), + $cacheId, + array( + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ) + ); + } + return $attributes; + } + + /** + * @param \Magento\Catalog\Model\Resource\Config $config + * @param callable $proceed + * @return array + */ + public function aroundGetAttributesUsedForSortBy(\Magento\Catalog\Model\Resource\Config $config, \Closure $proceed) + { + $cacheId = self::PRODUCT_LISTING_SORT_BY_ATTRIBUTES_CACHE_ID . $config->getEntityTypeId() . '_' + . $config->getStoreId(); + if ($this->isCacheEnabled && ($attributes = $this->cache->load($cacheId))) { + return unserialize($attributes); + } + $attributes = $proceed(); + if ($this->isCacheEnabled) { + $this->cache->save( + serialize($attributes), + $cacheId, + array( + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ) + ); + } + return $attributes; + } +} diff --git a/app/code/Magento/Catalog/Pricing/Price/FinalPrice.php b/app/code/Magento/Catalog/Pricing/Price/FinalPrice.php index d5a8454d884..10c5472f8a1 100644 --- a/app/code/Magento/Catalog/Pricing/Price/FinalPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/FinalPrice.php @@ -41,21 +41,7 @@ class FinalPrice extends AbstractPrice implements FinalPriceInterface /** * @var BasePrice */ - protected $basePrice; - - /** - * @param Product $saleableItem - * @param float $quantity - * @param CalculatorInterface $calculator - */ - public function __construct( - Product $saleableItem, - $quantity, - CalculatorInterface $calculator - ) { - parent::__construct($saleableItem, $quantity, $calculator); - $this->basePrice = $this->priceInfo->getPrice(BasePrice::PRICE_CODE); - } + private $basePrice; /** * Get Value @@ -64,7 +50,7 @@ class FinalPrice extends AbstractPrice implements FinalPriceInterface */ public function getValue() { - return max(0, $this->basePrice->getValue()); + return max(0, $this->getBasePrice()->getValue()); } /** @@ -90,4 +76,17 @@ class FinalPrice extends AbstractPrice implements FinalPriceInterface { return $this->calculator->getAmount($this->getValue(), $this->product); } + + /** + * Retrieve base price instance lazily + * + * @return BasePrice|\Magento\Framework\Pricing\Price\PriceInterface + */ + protected function getBasePrice() + { + if (!$this->basePrice) { + $this->basePrice = $this->priceInfo->getPrice(BasePrice::PRICE_CODE); + } + return $this->basePrice; + } } diff --git a/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php index c8d7ba60b02..6a4995dc722 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/CategoryBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Data; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * @codeCoverageIgnore @@ -33,12 +33,12 @@ class CategoryBuilder extends ExtensibleObjectBuilder { /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param \Magento\Catalog\Service\V1\Category\MetadataServiceInterface $metadataService */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, \Magento\Catalog\Service\V1\Category\MetadataServiceInterface $metadataService ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php index 8f8964e48b3..9f88755fa09 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/AttributeMetadataBuilder.php @@ -25,7 +25,7 @@ namespace Magento\Catalog\Service\V1\Data\Eav; use Magento\Framework\Api\ExtensibleObjectBuilder; use Magento\Framework\Api\AttributeMetadataBuilderInterface; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -56,7 +56,7 @@ class AttributeMetadataBuilder extends ExtensibleObjectBuilder implements Attrib * Initializes builder. * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param OptionBuilder $optionBuilder * @param ValidationRuleBuilder $validationRuleBuilder @@ -64,7 +64,7 @@ class AttributeMetadataBuilder extends ExtensibleObjectBuilder implements Attrib */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, OptionBuilder $optionBuilder, ValidationRuleBuilder $validationRuleBuilder, diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Info/MetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Info/MetadataBuilder.php index 1cee62ac05e..af4d11ef633 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Info/MetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Info/MetadataBuilder.php @@ -25,7 +25,7 @@ namespace Magento\Catalog\Service\V1\Data\Eav\Category\Info; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * Class MetadataBuilder @@ -36,12 +36,12 @@ class MetadataBuilder extends ExtensibleObjectBuilder { /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param \Magento\Catalog\Service\V1\Category\MetadataServiceInterface $metadataService */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, \Magento\Catalog\Service\V1\Category\MetadataServiceInterface $metadataService ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php index 3d00f39f349..8bc3ba7c405 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/Attribute/SearchResultsBuilder.php @@ -25,7 +25,7 @@ namespace Magento\Catalog\Service\V1\Data\Product\Attribute; use Magento\Catalog\Service\V1\Data\Eav\AttributeBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -42,14 +42,14 @@ class SearchResultsBuilder extends \Magento\Framework\Api\AbstractSearchResultsB * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param AttributeBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, AttributeBuilder $itemObjectBuilder diff --git a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php index 67ef9d79475..538fc109936 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Product/SearchResultsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Data\Product; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -43,14 +43,14 @@ class SearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param ProductBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, ProductBuilder $itemObjectBuilder diff --git a/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php index f1f7977c173..84518611dc2 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/ProductBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * @codeCoverageIgnore @@ -33,12 +33,12 @@ class ProductBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder { /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param \Magento\Catalog\Service\V1\Product\MetadataServiceInterface $metadataService */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, \Magento\Catalog\Service\V1\Product\MetadataServiceInterface $metadataService ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); diff --git a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php index d11d9083256..45f25f13ef3 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/CustomOptions/Data/Option/MetadataBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * @codeCoverageIgnore @@ -46,13 +46,13 @@ class MetadataBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param \Magento\Framework\Api\Config\MetadataConfig $metadataService * @param array $customAttributeCodes */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, \Magento\Framework\Api\Config\MetadataConfig $metadataService, array $customAttributeCodes = array() ) { diff --git a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php index f74eecf4645..c0c571ba590 100644 --- a/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Product/Link/Data/ProductLinkBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Catalog\Service\V1\Product\Link\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * Builder for the ProductLink Service Data Object @@ -41,13 +41,13 @@ class ProductLinkBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param \Magento\Framework\Api\Config\MetadataConfig $metadataService * @param array $customAttributesCodes */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, \Magento\Framework\Api\Config\MetadataConfig $metadataService, array $customAttributesCodes = array() ) { diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 079a2c51884..4bd91b1c76f 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-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-indexer": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-log": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-msrp": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-catalog-rule": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-product-alert": "0.1.0-alpha103", - "magento/module-url-rewrite": "0.1.0-alpha103", - "magento/module-catalog-url-rewrite": "0.1.0-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-log": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-msrp": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-catalog-rule": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-product-alert": "0.1.0-alpha104", + "magento/module-url-rewrite": "0.1.0-alpha104", + "magento/module-catalog-url-rewrite": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 3ee2a5e3df8..fffae3fe39e 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -113,7 +113,6 @@ <type name="Magento\Catalog\Model\Product"> <arguments> <argument name="catalogProductStatus" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Source\Status\Proxy</argument> - <argument name="categoryIndexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> </arguments> </type> <type name="Magento\Catalog\Model\Resource\Product\Collection"> @@ -180,17 +179,6 @@ <argument name="storage" xsi:type="object">Magento\Catalog\Model\Session\Storage</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Category"> - <arguments> - <argument name="flatIndexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - <argument name="productIndexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> - <type name="Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode"> - <arguments> - <argument name="flatIndexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> <type name="Magento\Store\Model\Resource\Website"> <plugin name="priceIndexerOnWebsiteDelete" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\Website"/> </type> @@ -208,24 +196,11 @@ <type name="Magento\Customer\Service\V1\CustomerGroupServiceInterface"> <plugin name="invalidatePriceIndexerOnCustomerGroup" type="Magento\Catalog\Model\Indexer\Product\Price\Plugin\CustomerGroup"/> </type> - <type name="Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> - <type name="Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> <type name="Magento\Indexer\Model\Config\Data"> <plugin name="indexerCategoryFlatConfigGet" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData" /> <plugin name="indexerProductFlatConfigGet" type="Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData" /> </type> <type name="Magento\Catalog\Model\Indexer\Category\Flat"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> <plugin name="page-cache-indexer-reindex-category-flat" type="Magento\Catalog\Model\Indexer\Category\AffectCache" sortOrder="10"/> </type> @@ -234,17 +209,9 @@ <argument name="defaultPriceIndexer" xsi:type="string">Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Indexer\Category\Product\Plugin\StoreGroup"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> <type name="Magento\Eav\Model\Entity\Attribute\Set"> <plugin name="invalidateEavIndexerOnAttributeSetSave" type="\Magento\Catalog\Model\Indexer\Product\Eav\Plugin\AttributeSet" /> </type> - <type name="Magento\CatalogRule\Model\Rule"> - <plugin name="reindexPriceOnRuleApply" type="\Magento\Catalog\Model\Indexer\Product\Price\Plugin\CatalogRule" /> - </type> <type name="Magento\Catalog\Helper\Product\Flat\Indexer"> <arguments> <argument name="flatAttributeGroups" xsi:type="array"> @@ -253,16 +220,10 @@ </arguments> </type> <type name="Magento\Catalog\Model\Indexer\Category\Product"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> <plugin name="page-cache-indexer-reindex-category-product" type="Magento\Catalog\Model\Indexer\Product\AffectCache" sortOrder="10"/> </type> <type name="Magento\Catalog\Model\Indexer\Product\Category"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> <plugin name="page-cache-indexer-reindex-product-category" type="Magento\Catalog\Model\Indexer\Category\AffectCache" sortOrder="10"/> </type> @@ -290,11 +251,6 @@ </argument> </arguments> </type> - <type name="Magento\Catalog\Model\Product\Action"> - <arguments> - <argument name="categoryIndexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> <virtualType name="rowsFlatTableBuilder" type="Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder"> <arguments> <argument name="tableData" xsi:type="object">Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows\TableData</argument> @@ -335,11 +291,6 @@ <argument name="layer" xsi:type="object">Magento\Catalog\Model\Layer\Search</argument> </arguments> </type> - <type name="Magento\Catalog\Model\Indexer\Product\Price\Processor"> - <arguments> - <argument name="indexer" xsi:type="object" shared="false">Magento\Indexer\Model\IndexerInterface</argument> - </arguments> - </type> <type name="Magento\Catalog\Model\Indexer\Product\Flat"> <plugin name="page-cache-indexer-reindex-product-flat" type="Magento\Catalog\Model\Indexer\Product\AffectCache" sortOrder="10"/> @@ -495,8 +446,16 @@ <type name="Magento\CatalogInventory\Model\Config\Backend\ShowOutOfStock"> <plugin name="showOutOfStockValueChanged" type="\Magento\Catalog\Model\Plugin\ShowOutOfStockConfig"/> </type> - <preference for="Magento\Catalog\Block\Category\Widget\Link" type="Magento\Catalog\Block\Widget\Link" /> - <preference for="Magento\Catalog\Block\Product\Widget\Link" type="Magento\Catalog\Block\Widget\Link" /> + <virtualType name="Magento\Catalog\Block\Category\Widget\Link" type="Magento\Catalog\Block\Widget\Link"> + <arguments> + <argument name="entityResource" xsi:type="object">Magento\Catalog\Model\Resource\Category</argument> + </arguments> + </virtualType> + <virtualType name="Magento\Catalog\Block\Product\Widget\Link" type="Magento\Catalog\Block\Widget\Link"> + <arguments> + <argument name="entityResource" xsi:type="object">Magento\Catalog\Model\Resource\Product</argument> + </arguments> + </virtualType> <type name="Magento\Framework\App\Rss\RssManagerInterface"> <arguments> <argument name="dataProviders" xsi:type="array"> @@ -513,4 +472,7 @@ <argument name="collectionFilter" xsi:type="object">Magento\Catalog\Model\Layer\Search\CollectionFilter</argument> </arguments> </type> + <type name="Magento\Catalog\Model\Resource\Config"> + <plugin name="productListingAttributesCaching" type="Magento\Catalog\Plugin\Model\Resource\Config" /> + </type> </config> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml index 4b3ae570ece..3657a7b9ab3 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options.phtml @@ -24,13 +24,13 @@ ?> <?php /** @var $this \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options */ ?> -<div class="fieldset-wrapper collapsable-wrapper opened" id="product-custom-options-wrapper"> +<div class="fieldset-wrapper" id="product-custom-options-wrapper"> <div class="fieldset-wrapper-title"> - <strong class="title" data-toggle="collapse" data-target="#product-custom-options-content"> + <strong class="title"> <span><?php echo __('Custom Options') ?></span> </strong> </div> - <div class="fieldset-wrapper-content in collapse" id="product-custom-options-content"> + <div class="fieldset-wrapper-content" id="product-custom-options-content"> <fieldset class="fieldset"> <div class="message message-error" id="dynamic-price-warning" style="display: none;"> <div class="message-inner"> diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 17653dfb665..2d7ba877fcc 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -480,9 +480,9 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $dateTime; /** - * @var \Magento\Indexer\Model\IndexerFactory + * @var \Magento\Indexer\Model\IndexerRegistry */ - protected $indexerFactory; + protected $indexerRegistry; /** * @var \Magento\Framework\Logger @@ -506,24 +506,25 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\ImportExport\Model\Import\Config $importConfig - * @param \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceFactory $resourceFactory - * @param \Magento\CatalogImportExport\Model\Import\Product\OptionFactory $optionFactory + * @param Proxy\Product\ResourceFactory $resourceFactory + * @param Product\OptionFactory $optionFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setColFactory * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryColFactory * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\StoreManagerInterface $storeManager - * @param \Magento\CatalogImportExport\Model\Import\Product\Type\Factory $productTypeFactory + * @param Product\Type\Factory $productTypeFactory * @param \Magento\Catalog\Model\Resource\Product\LinkFactory $linkFactory - * @param \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory $proxyProdFactory - * @param \Magento\CatalogImportExport\Model\Import\UploaderFactory $uploaderFactory + * @param Proxy\ProductFactory $proxyProdFactory + * @param UploaderFactory $uploaderFactory * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\CatalogInventory\Model\Resource\Stock\ItemFactory $stockResItemFac * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Logger $logger - * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param array $data + * @throws \Magento\Framework\Model\Exception */ public function __construct( \Magento\Core\Helper\Data $coreData, @@ -553,7 +554,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Logger $logger, - \Magento\Indexer\Model\IndexerFactory $indexerFactory, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, array $data = array() ) { $this->_eventManager = $eventManager; @@ -574,7 +575,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $this->_stockResItemFac = $stockResItemFac; $this->_localeDate = $localeDate; $this->dateTime = $dateTime; - $this->indexerFactory = $indexerFactory; + $this->indexerRegistry = $indexerRegistry; $this->_logger = $logger; parent::__construct($coreData, $importExportData, $importData, $config, $resource, $resourceHelper, $string); $this->_optionEntity = isset( @@ -1759,7 +1760,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ protected function _saveStockItem() { - $indexer = $this->indexerFactory->create()->load('catalog_product_category'); + $indexer = $this->indexerRegistry->get('catalog_product_category'); /** @var $stockResource \Magento\CatalogInventory\Model\Resource\Stock\Item */ $stockResource = $this->_stockResItemFac->create(); $entityTable = $stockResource->getMainTable(); diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 7d98b3c2e29..ce67e7ed780 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-import-export": "0.1.0-alpha103", - "magento/module-indexer": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index 7a3adacfc8a..68634b33f62 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -87,7 +87,7 @@ class Stock implements \Magento\Indexer\Model\ActionInterface, \Magento\Framewor * * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->_productStockIndexerRows->execute($ids); } diff --git a/app/code/Magento/CatalogInventory/Model/Observer.php b/app/code/Magento/CatalogInventory/Model/Observer.php index d063a61a260..42f82adafc3 100644 --- a/app/code/Magento/CatalogInventory/Model/Observer.php +++ b/app/code/Magento/CatalogInventory/Model/Observer.php @@ -290,6 +290,7 @@ class Observer $stockItemDo = $this->stockItemService->getStockItem($product->getId()); $this->stockItemService->saveStockItem( $this->stockItemBuilder->mergeDataObjectWithArray($stockItemDo, $stockItemData) + ->create() ); return $this; diff --git a/app/code/Magento/CatalogInventory/Service/V1/StockItemService.php b/app/code/Magento/CatalogInventory/Service/V1/StockItemService.php index 33297adae80..33e1d8f1f6a 100644 --- a/app/code/Magento/CatalogInventory/Service/V1/StockItemService.php +++ b/app/code/Magento/CatalogInventory/Service/V1/StockItemService.php @@ -134,7 +134,7 @@ class StockItemService implements StockItemServiceInterface $dataToSave = $this->stockItemBuilder->mergeDataObjectWithArray( $stockItemDo, $stockItemDetailsDo->__toArray() - )->__toArray(); + )->create()->__toArray(); return $stockItem->setData($dataToSave)->save()->getId(); } diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 859be9a5e01..44c2b081b7c 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-indexer": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/CatalogRule/CatalogRuleException.php similarity index 75% rename from app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Magento/CatalogRule/CatalogRuleException.php index 3e252381877..fa78a502e1c 100644 --- a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.0-1.6.0.1.php +++ b/app/code/Magento/CatalogRule/CatalogRuleException.php @@ -21,13 +21,8 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogRule; -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$connection = $installer->getConnection(); -$connection->createTable( - $connection->createTableByDdl( - $installer->getTable('coupon_aggregated'), - $installer->getTable('coupon_aggregated_updated') - ) -); +class CatalogRuleException extends \Exception +{ +} diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/ApplyRules.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/ApplyRules.php index 84bd532607d..85e47ce124c 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/ApplyRules.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/ApplyRules.php @@ -48,6 +48,7 @@ class ApplyRules extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog $this->messageManager->addError($errorMessage . ' ' . $ruleJob->getError()); } } catch (\Exception $e) { + $this->_objectManager->create('Magento\Framework\Logger')->logException($e); $this->messageManager->addError($errorMessage); } $this->_redirect('catalog_rule/*'); diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Delete.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Delete.php index d750748978e..c3506013ccf 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Delete.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Delete.php @@ -36,6 +36,7 @@ class Delete extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog $id = $this->getRequest()->getParam('id'); if ($id) { try { + /** @var \Magento\CatalogRule\Model\Rule $model */ $model = $this->_objectManager->create('Magento\CatalogRule\Model\Rule'); $model->load($id); $model->delete(); diff --git a/app/code/Magento/CatalogRule/Model/Cron.php b/app/code/Magento/CatalogRule/Model/Cron.php new file mode 100644 index 00000000000..bb8a302d8ea --- /dev/null +++ b/app/code/Magento/CatalogRule/Model/Cron.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\CatalogRule\Model; + +class Cron +{ + /** + * @var Indexer\Rule\RuleProductProcessor + */ + protected $ruleProductProcessor; + + /** + * @param Indexer\Rule\RuleProductProcessor $ruleProductProcessor + */ + public function __construct(Indexer\Rule\RuleProductProcessor $ruleProductProcessor) + { + $this->ruleProductProcessor = $ruleProductProcessor; + } + + /** + * Daily update catalog price rule by cron + * Update include interval 3 days - current day - 1 days before + 1 days after + * This method is called from cron process, cron is working in UTC time and + * we should generate data for interval -1 day ... +1 day + * + * @return void + */ + public function dailyCatalogUpdate() + { + $this->ruleProductProcessor->markIndexerAsInvalid(); + } +} diff --git a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php new file mode 100644 index 00000000000..ff6f88d3ae7 --- /dev/null +++ b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php @@ -0,0 +1,112 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Model\Indexer; + +use Magento\CatalogRule\CatalogRuleException; +use Magento\Framework\Mview\ActionInterface as MviewActionInterface; +use Magento\Indexer\Model\ActionInterface as IndexerActionInterface; + +abstract class AbstractIndexer implements IndexerActionInterface, MviewActionInterface +{ + /** + * @var IndexBuilder + */ + protected $indexBuilder; + + /** + * @param IndexBuilder $indexBuilder + */ + public function __construct(IndexBuilder $indexBuilder) + { + $this->indexBuilder = $indexBuilder; + } + + /** + * Execute materialization on ids entities + * + * @param int[] $ids + * @return void + */ + public function execute($ids) + { + $this->executeList($ids); + } + + /** + * Execute full indexation + * + * @return void + */ + public function executeFull() + { + $this->indexBuilder->reindexFull(); + } + + /** + * Execute partial indexation by ID list + * + * @param int[] $ids + * @throws CatalogRuleException + * @return void + */ + public function executeList(array $ids) + { + if (!$ids) { + throw new CatalogRuleException(__('Could not rebuild index for empty products array')); + } + $this->doExecuteList($ids); + } + + /** + * Execute partial indexation by ID list. Template method + * + * @param int[] $ids + * @return void + */ + abstract protected function doExecuteList($ids); + + /** + * Execute partial indexation by ID + * + * @param int $id + * @throws CatalogRuleException + * @return void + */ + public function executeRow($id) + { + if (!$id) { + throw new CatalogRuleException(__('Could not rebuild index for undefined product')); + } + $this->doExecuteRow($id); + } + + /** + * Execute partial indexation by ID. Template method + * + * @param int $id + * @throws \Magento\CatalogRule\CatalogRuleException + * @return void + */ + abstract protected function doExecuteRow($id); +} diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php new file mode 100644 index 00000000000..ed866920526 --- /dev/null +++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php @@ -0,0 +1,706 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\CatalogRule\Model\Indexer; + +use Magento\CatalogRule\CatalogRuleException; +use Magento\CatalogRule\Model\Rule; +use Magento\CatalogRule\Model\Resource\Rule\CollectionFactory as RuleCollectionFactory; +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Catalog\Model\Product; + +class IndexBuilder +{ + const SECONDS_IN_DAY = 86400; + + /** + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * @var \Magento\Framework\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var RuleCollectionFactory + */ + protected $ruleCollectionFactory; + + /** + * @var \Magento\Framework\Logger + */ + protected $logger; + + /** + * @var PriceCurrencyInterface + */ + protected $priceCurrency; + + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + + /** + * @var \Magento\Framework\Stdlib\DateTime + */ + protected $dateFormat; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime + */ + protected $dateTime; + + /** + * @var \Magento\Catalog\Model\ProductFactory + */ + protected $productFactory; + + /** + * @var Product[] + */ + protected $loadedProducts; + + /** + * @param RuleCollectionFactory $ruleCollectionFactory + * @param PriceCurrencyInterface $priceCurrency + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\StoreManagerInterface $storeManager + * @param \Magento\Framework\Logger $logger + * @param \Magento\Eav\Model\Config $eavConfig + * @param \Magento\Framework\Stdlib\DateTime $dateFormat + * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime + * @param \Magento\Catalog\Model\ProductFactory $productFactory + */ + public function __construct( + RuleCollectionFactory $ruleCollectionFactory, + PriceCurrencyInterface $priceCurrency, + \Magento\Framework\App\Resource $resource, + \Magento\Framework\StoreManagerInterface $storeManager, + \Magento\Framework\Logger $logger, + \Magento\Eav\Model\Config $eavConfig, + \Magento\Framework\Stdlib\DateTime $dateFormat, + \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, + \Magento\Catalog\Model\ProductFactory $productFactory + ) { + $this->resource = $resource; + $this->storeManager = $storeManager; + $this->ruleCollectionFactory = $ruleCollectionFactory; + $this->logger = $logger; + $this->priceCurrency = $priceCurrency; + $this->eavConfig = $eavConfig; + $this->dateFormat = $dateFormat; + $this->dateTime = $dateTime; + $this->productFactory = $productFactory; + } + + /** + * Reindex by id + * + * @param int $id + * @return void + */ + public function reindexById($id) + { + $this->reindexByIds([$id]); + } + + /** + * Reindex by ids + * + * @param array $ids + * @throws \Magento\CatalogRule\CatalogRuleException + * @return void + */ + public function reindexByIds(array $ids) + { + try { + $this->doReindexByIds($ids); + } catch (\Exception $e) { + $this->logException($e); + throw new CatalogRuleException($e->getMessage(), $e->getCode(), $e); + } + } + + /** + * Reindex by ids. Template method + * + * @param array $ids + * @return void + */ + protected function doReindexByIds($ids) + { + $this->cleanByIds($ids); + + foreach ($this->getActiveRules() as $rule) { + foreach ($ids as $productId) { + $this->applyRule($rule, $this->getProduct($productId)); + } + } + } + + /** + * Full reindex + * + * @throws CatalogRuleException + * @return void + */ + public function reindexFull() + { + try { + $this->doReindexFull(); + } catch (\Exception $e) { + $this->logException($e); + throw new CatalogRuleException($e->getMessage(), $e->getCode(), $e); + } + } + + /** + * Full reindex Template method + * + * @return void + */ + protected function doReindexFull() + { + foreach ($this->getAllRules() as $rule) { + $this->updateRuleProductData($rule); + } + $this->applyAllRules(); + } + + /** + * Clean by product ids + * + * @param array $productIds + * @return void + */ + protected function cleanByIds($productIds) + { + $this->getWriteAdapter()->deleteFromSelect( + $this->getWriteAdapter() + ->select($this->resource->getTableName('catalogrule_product'), 'product_id') + ->distinct() + ->where('product_id IN (?)', $productIds), + $this->resource->getTableName('catalogrule_product') + ); + + $this->getWriteAdapter()->deleteFromSelect( + $this->getWriteAdapter()->select($this->resource->getTableName('catalogrule_product_price'), 'product_id') + ->distinct() + ->where('product_id IN (?)', $productIds), + $this->resource->getTableName('catalogrule_product_price') + ); + } + + /** + * @param Rule $rule + * @param Product $product + * @return $this + * @throws \Exception + */ + protected function applyRule(Rule $rule, $product) + { + $ruleId = $rule->getId(); + $productId = $product->getId(); + $websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds()); + + $write = $this->getWriteAdapter(); + + $write->delete( + $this->resource->getTableName('catalogrule_product'), + array($write->quoteInto('rule_id = ?', $ruleId), $write->quoteInto('product_id = ?', $productId)) + ); + + if (!$rule->getConditions()->validate($product)) { + $write->delete( + $this->resource->getTableName('catalogrule_product_price'), + array($write->quoteInto('product_id = ?', $productId)) + ); + return $this; + } + + $customerGroupIds = $rule->getCustomerGroupIds(); + $fromTime = strtotime($rule->getFromDate()); + $toTime = strtotime($rule->getToDate()); + $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0; + $sortOrder = (int)$rule->getSortOrder(); + $actionOperator = $rule->getSimpleAction(); + $actionAmount = $rule->getDiscountAmount(); + $actionStop = $rule->getStopRulesProcessing(); + $subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : ''; + $subActionAmount = $rule->getSubDiscountAmount(); + + $rows = array(); + try { + foreach ($websiteIds as $websiteId) { + foreach ($customerGroupIds as $customerGroupId) { + $rows[] = array( + 'rule_id' => $ruleId, + 'from_time' => $fromTime, + 'to_time' => $toTime, + 'website_id' => $websiteId, + 'customer_group_id' => $customerGroupId, + 'product_id' => $productId, + 'action_operator' => $actionOperator, + 'action_amount' => $actionAmount, + 'action_stop' => $actionStop, + 'sort_order' => $sortOrder, + 'sub_simple_action' => $subActionOperator, + 'sub_discount_amount' => $subActionAmount + ); + + if (count($rows) == 1000) { + $write->insertMultiple($this->getTable('catalogrule_product'), $rows); + $rows = array(); + } + } + } + + if (!empty($rows)) { + $write->insertMultiple($this->resource->getTableName('catalogrule_product'), $rows); + } + } catch (\Exception $e) { + throw $e; + } + + $this->applyAllRules($product); + + return $this; + } + + /** + * Retrieve connection for read data + * + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected function getReadAdapter() + { + $writeAdapter = $this->getWriteAdapter(); + if ($writeAdapter && $writeAdapter->getTransactionLevel() > 0) { + // if transaction is started we should use write connection for reading + return $writeAdapter; + } + return $this->resource->getConnection('read'); + } + + /** + * Retrieve connection for write data + * + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + protected function getWriteAdapter() + { + return $this->resource->getConnection('write'); + } + + /** + * @param string $tableName + * @return string + */ + protected function getTable($tableName) + { + return $this->resource->getTableName($tableName); + } + + /** + * @param Rule $rule + * @return $this + */ + protected function updateRuleProductData(Rule $rule) + { + $ruleId = $rule->getId(); + $write = $this->getWriteAdapter(); + if ($rule->getProductsFilter()) { + $write->delete( + $this->getTable('catalogrule_product'), + array('rule_id=?' => $ruleId, 'product_id IN (?)' => $rule->getProductsFilter()) + ); + } else { + $write->delete($this->getTable('catalogrule_product'), $write->quoteInto('rule_id=?', $ruleId)); + } + + if (!$rule->getIsActive()) { + return $this; + } + + $websiteIds = $rule->getWebsiteIds(); + if (!is_array($websiteIds)) { + $websiteIds = explode(',', $websiteIds); + } + if (empty($websiteIds)) { + return $this; + } + + \Magento\Framework\Profiler::start('__MATCH_PRODUCTS__'); + $productIds = $rule->getMatchingProductIds(); + \Magento\Framework\Profiler::stop('__MATCH_PRODUCTS__'); + + $customerGroupIds = $rule->getCustomerGroupIds(); + $fromTime = strtotime($rule->getFromDate()); + $toTime = strtotime($rule->getToDate()); + $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0; + $sortOrder = (int)$rule->getSortOrder(); + $actionOperator = $rule->getSimpleAction(); + $actionAmount = $rule->getDiscountAmount(); + $subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : ''; + $subActionAmount = $rule->getSubDiscountAmount(); + $actionStop = $rule->getStopRulesProcessing(); + + $rows = array(); + + foreach ($productIds as $productId => $validationByWebsite) { + foreach ($websiteIds as $websiteId) { + if (empty($validationByWebsite[$websiteId])) { + continue; + } + foreach ($customerGroupIds as $customerGroupId) { + $rows[] = array( + 'rule_id' => $ruleId, + 'from_time' => $fromTime, + 'to_time' => $toTime, + 'website_id' => $websiteId, + 'customer_group_id' => $customerGroupId, + 'product_id' => $productId, + 'action_operator' => $actionOperator, + 'action_amount' => $actionAmount, + 'action_stop' => $actionStop, + 'sort_order' => $sortOrder, + 'sub_simple_action' => $subActionOperator, + 'sub_discount_amount' => $subActionAmount + ); + + if (count($rows) == 1000) { + $write->insertMultiple($this->getTable('catalogrule_product'), $rows); + $rows = array(); + } + } + } + } + if (!empty($rows)) { + $write->insertMultiple($this->getTable('catalogrule_product'), $rows); + } + + return $this; + } + + /** + * @return $this + * @throws \Exception + */ + protected function applyAllRules() + { + $write = $this->getWriteAdapter(); + + $fromDate = mktime(0, 0, 0, date('m'), date('d') - 1); + $toDate = mktime(0, 0, 0, date('m'), date('d') + 1); + + $this->deleteOldData(); + + $dayPrices = array(); + + /** + * Update products rules prices per each website separately + * because of max join limit in mysql + */ + foreach ($this->storeManager->getWebsites(false) as $website) { + $productsStmt = $this->getRuleProductsStmt($website->getId()); + + $dayPrices = array(); + $stopFlags = array(); + $prevKey = null; + + while ($ruleData = $productsStmt->fetch()) { + $ruleProductId = $ruleData['product_id']; + $productKey = $ruleProductId . + '_' . + $ruleData['website_id'] . + '_' . + $ruleData['customer_group_id']; + + if ($prevKey && $prevKey != $productKey) { + $stopFlags = array(); + } + + /** + * Build prices for each day + */ + for ($time = $fromDate; $time <= $toDate; $time += self::SECONDS_IN_DAY) { + if (($ruleData['from_time'] == 0 || + $time >= $ruleData['from_time']) && ($ruleData['to_time'] == 0 || + $time <= $ruleData['to_time']) + ) { + $priceKey = $time . '_' . $productKey; + + if (isset($stopFlags[$priceKey])) { + continue; + } + + if (!isset($dayPrices[$priceKey])) { + $dayPrices[$priceKey] = array( + 'rule_date' => $time, + 'website_id' => $ruleData['website_id'], + 'customer_group_id' => $ruleData['customer_group_id'], + 'product_id' => $ruleProductId, + 'rule_price' => $this->calcRuleProductPrice($ruleData), + 'latest_start_date' => $ruleData['from_time'], + 'earliest_end_date' => $ruleData['to_time'] + ); + } else { + $dayPrices[$priceKey]['rule_price'] = $this->calcRuleProductPrice( + $ruleData, + $dayPrices[$priceKey] + ); + $dayPrices[$priceKey]['latest_start_date'] = max( + $dayPrices[$priceKey]['latest_start_date'], + $ruleData['from_time'] + ); + $dayPrices[$priceKey]['earliest_end_date'] = min( + $dayPrices[$priceKey]['earliest_end_date'], + $ruleData['to_time'] + ); + } + + if ($ruleData['action_stop']) { + $stopFlags[$priceKey] = true; + } + } + } + + $prevKey = $productKey; + if (count($dayPrices) > 1000) { + $this->saveRuleProductPrices($dayPrices); + $dayPrices = array(); + } + } + $this->saveRuleProductPrices($dayPrices); + } + $this->saveRuleProductPrices($dayPrices); + + $write->delete($this->getTable('catalogrule_group_website'), array()); + + $timestamp = $this->dateTime->gmtTimestamp(); + + $select = $write->select()->distinct( + true + )->from( + $this->getTable('catalogrule_product'), + array('rule_id', 'customer_group_id', 'website_id') + )->where( + "{$timestamp} >= from_time AND (({$timestamp} <= to_time AND to_time > 0) OR to_time = 0)" + ); + $query = $select->insertFromSelect($this->getTable('catalogrule_group_website')); + $write->query($query); + + return $this; + } + + /** + * Clean rule price index + * + * @return $this + */ + protected function deleteOldData() + { + $this->getWriteAdapter()->delete($this->getTable('catalogrule_product_price')); + return $this; + } + + /** + * @param array $ruleData + * @param null $productData + * @return float + */ + protected function calcRuleProductPrice($ruleData, $productData = null) + { + if ($productData !== null && isset($productData['rule_price'])) { + $productPrice = $productData['rule_price']; + } else { + $productPrice = $ruleData['default_price']; + } + + switch ($ruleData['action_operator']) { + case 'to_fixed': + $productPrice = min($ruleData['action_amount'], $productPrice); + break; + case 'to_percent': + $productPrice = $productPrice * $ruleData['action_amount'] / 100; + break; + case 'by_fixed': + $productPrice = max(0, $productPrice - $ruleData['action_amount']); + break; + case 'by_percent': + $productPrice = $productPrice * (1 - $ruleData['action_amount'] / 100); + break; + default: + $productPrice = 0; + } + + return $this->priceCurrency->round($productPrice); + } + + /** + * @param int $websiteId + * @return \Zend\Db\Adapter\Driver\StatementInterface|\Zend_Db_Statement_Interface + * @throws \Magento\Eav\Exception + */ + protected function getRuleProductsStmt($websiteId) + { + $read = $this->getReadAdapter(); + /** + * Sort order is important + * It used for check stop price rule condition. + * website_id customer_group_id product_id sort_order + * 1 1 1 0 + * 1 1 1 1 + * 1 1 1 2 + * if row with sort order 1 will have stop flag we should exclude + * all next rows for same product id from price calculation + */ + $select = $read->select()->from( + array('rp' => $this->getTable('catalogrule_product')) + )->order( + array('rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id') + ); + + /** + * Join default price and websites prices to result + */ + $priceAttr = $this->eavConfig->getAttribute(Product::ENTITY, 'price'); + $priceTable = $priceAttr->getBackend()->getTable(); + $attributeId = $priceAttr->getId(); + + $joinCondition = '%1$s.entity_id=rp.product_id AND (%1$s.attribute_id=' + . $attributeId + . ') and %1$s.store_id=%2$s'; + + $select->join( + array('pp_default' => $priceTable), + sprintf($joinCondition, 'pp_default', \Magento\Store\Model\Store::DEFAULT_STORE_ID), + array() + ); + + $website = $this->storeManager->getWebsite($websiteId); + $defaultGroup = $website->getDefaultGroup(); + if ($defaultGroup instanceof \Magento\Store\Model\Group) { + $storeId = $defaultGroup->getDefaultStoreId(); + } else { + $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + } + + $select->joinInner( + array('product_website' => $this->getTable('catalog_product_website')), + 'product_website.product_id=rp.product_id ' + . 'AND product_website.website_id = rp.website_id ' + . 'AND product_website.website_id=' + . $websiteId, + array() + ); + + $tableAlias = 'pp' . $websiteId; + $select->joinLeft( + array($tableAlias => $priceTable), + sprintf($joinCondition, $tableAlias, $storeId), + array() + ); + $select->columns([ + 'default_price' => $this->getReadAdapter()->getIfNullSql($tableAlias . '.value', 'pp_default.value'), + ]); + + return $read->query($select); + } + + /** + * @param array $arrData + * @return $this + * @throws \Exception + */ + protected function saveRuleProductPrices($arrData) + { + if (empty($arrData)) { + return $this; + } + + $adapter = $this->getWriteAdapter(); + $productIds = array(); + + try { + foreach ($arrData as $key => $data) { + $productIds['product_id'] = $data['product_id']; + $arrData[$key]['rule_date'] = $this->dateFormat->formatDate($data['rule_date'], false); + $arrData[$key]['latest_start_date'] = $this->dateFormat->formatDate($data['latest_start_date'], false); + $arrData[$key]['earliest_end_date'] = $this->dateFormat->formatDate($data['earliest_end_date'], false); + } + $adapter->insertOnDuplicate($this->getTable('catalogrule_affected_product'), array_unique($productIds)); + $adapter->insertOnDuplicate($this->getTable('catalogrule_product_price'), $arrData); + } catch (\Exception $e) { + throw $e; + } + + return $this; + } + + /** + * Get active rules + * + * @return array + */ + protected function getActiveRules() + { + return $this->ruleCollectionFactory->create() + ->addFieldToFilter('is_active', 1); + } + + /** + * Get active rules + * + * @return array + */ + protected function getAllRules() + { + return $this->ruleCollectionFactory->create(); + } + + /** + * @param int $productId + * @return Product + */ + protected function getProduct($productId) + { + if (!isset($this->loadedProducts[$productId])) { + $this->loadedProducts[$productId] = $this->productFactory->create()->load($productId); + } + return $this->loadedProducts[$productId]; + } + + /** + * @param \Exception $e + * @return void + */ + protected function logException($e) + { + $this->logger->logException($e); + } +} diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version/Generator/Timestamp.php b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexer.php similarity index 70% rename from lib/internal/Magento/Framework/App/View/Deployment/Version/Generator/Timestamp.php rename to app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexer.php index 830a001c74e..8753fb9eb7a 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version/Generator/Timestamp.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexer.php @@ -21,19 +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\CatalogRule\Model\Indexer\Product; -namespace Magento\Framework\App\View\Deployment\Version\Generator; +use Magento\CatalogRule\Model\Indexer\AbstractIndexer; -/** - * Generation of deployment version of static files using the timestamp - */ -class Timestamp implements \Magento\Framework\App\View\Deployment\Version\GeneratorInterface +class ProductRuleIndexer extends AbstractIndexer { /** * {@inheritdoc} */ - public function generate() + protected function doExecuteList($ids) + { + $this->indexBuilder->reindexByIds(array_unique($ids)); + } + + /** + * {@inheritdoc} + */ + protected function doExecuteRow($id) { - return (string)time(); + $this->indexBuilder->reindexById($id); } } diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php similarity index 74% rename from app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php index 0f316272360..c026b66b2f3 100644 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.2-1.6.0.3.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Product/ProductRuleProcessor.php @@ -21,11 +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\CatalogRule\Model\Indexer\Product; -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_shipment'), - 'shipping_label', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_VARBINARY, 'comment' => 'Shipping Label Content', 'length' => '2m') -); +use Magento\Indexer\Model\Indexer\AbstractProcessor; + +class ProductRuleProcessor extends AbstractProcessor +{ + /** + * Indexer id + */ + const INDEXER_ID = 'catalogrule_product'; +} diff --git a/lib/internal/Magento/Framework/Api/AttributeValueBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexer.php similarity index 65% rename from lib/internal/Magento/Framework/Api/AttributeValueBuilder.php rename to app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexer.php index e4113082c82..5036adebaf5 100644 --- a/lib/internal/Magento/Framework/Api/AttributeValueBuilder.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexer.php @@ -21,32 +21,29 @@ * @copyright Copyright (c) 2014 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\Api; +namespace Magento\CatalogRule\Model\Indexer\Rule; -/** - * Custom Attribute Data object builder - */ -class AttributeValueBuilder extends AbstractSimpleObjectBuilder +use Magento\CatalogRule\Model\Indexer\AbstractIndexer; + +class RuleProductIndexer extends AbstractIndexer { /** - * Set attribute code + * {@inheritdoc} * - * @param string $attributeCode - * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function setAttributeCode($attributeCode) + protected function doExecuteList($ids) { - return $this->_set(AttributeValue::ATTRIBUTE_CODE, $attributeCode); + $this->indexBuilder->reindexFull(); } /** - * Set attribute value + * {@inheritdoc} * - * @param string $value - * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function setValue($value) + protected function doExecuteRow($id) { - return $this->_set(AttributeValue::VALUE, $value); + $this->indexBuilder->reindexFull(); } } diff --git a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php similarity index 73% rename from app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php index 96281ede42f..87dee29c5ca 100644 --- a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/Rule/RuleProductProcessor.php @@ -21,12 +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\CatalogRule\Model\Indexer\Rule; -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; +use Magento\Indexer\Model\Indexer\AbstractProcessor; -$installer->getConnection()->addColumn( - $installer->getTable('paypal_settlement_report_row'), - 'payment_tracking_id', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'comment' => 'Payment Tracking ID', 'length' => '255') -); +class RuleProductProcessor extends AbstractProcessor +{ + /** + * Indexer id + */ + const INDEXER_ID = 'catalogrule_rule'; +} diff --git a/app/code/Magento/CatalogRule/Model/Observer.php b/app/code/Magento/CatalogRule/Model/Observer.php index 57eb2b22bc2..fa99c32fb17 100644 --- a/app/code/Magento/CatalogRule/Model/Observer.php +++ b/app/code/Magento/CatalogRule/Model/Observer.php @@ -30,9 +30,7 @@ namespace Magento\CatalogRule\Model; use Magento\Backend\Model\Session as BackendModelSession; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Resource\Product\Collection as ProductCollection; -use Magento\CatalogRule\Model\Rule\Condition\Combine; 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\Framework\StoreManagerInterface; @@ -40,8 +38,6 @@ use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Customer\Service\V1\CustomerGroupServiceInterface as Group; use Magento\Customer\Model\Session as CustomerModelSession; use Magento\Framework\Event\Observer as EventObserver; -use Magento\Framework\Message\ManagerInterface; -use Magento\Rule\Model\Condition\Product\AbstractProduct; use Magento\Framework\Stdlib\DateTime; class Observer @@ -71,21 +67,6 @@ class Observer */ protected $_productPrice; - /** - * @var BackendModelSession - */ - protected $_backendSession; - - /** - * @var \Magento\CatalogRule\Model\RuleFactory - */ - protected $_ruleFactory; - - /** - * @var \Magento\CatalogRule\Model\FlagFactory - */ - protected $_flagFactory; - /** * @var \Magento\CatalogRule\Model\Resource\Rule\CollectionFactory */ @@ -111,25 +92,16 @@ class Observer */ protected $_resourceRule; - /** - * @var \Magento\Framework\Message\ManagerInterface - */ - protected $messageManager; - /** * @param Resource\RuleFactory $resourceRuleFactory * @param Resource\Rule $resourceRule * @param Resource\Rule\CollectionFactory $ruleCollectionFactory - * @param Rule\Product\Price $productPrice - * @param RuleFactory $ruleFactory - * @param FlagFactory $flagFactory + * @param Price $productPrice * @param StoreManagerInterface $storeManager * @param TimezoneInterface $localeDate * @param CustomerModelSession $customerSession - * @param BackendModelSession $backendSession * @param Registry $coreRegistry * @param DateTime $dateTime - * @param ManagerInterface $messageManager * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -138,87 +110,22 @@ class Observer Resource\Rule $resourceRule, Resource\Rule\CollectionFactory $ruleCollectionFactory, Rule\Product\Price $productPrice, - RuleFactory $ruleFactory, - FlagFactory $flagFactory, StoreManagerInterface $storeManager, TimezoneInterface $localeDate, CustomerModelSession $customerSession, - BackendModelSession $backendSession, Registry $coreRegistry, - DateTime $dateTime, - ManagerInterface $messageManager + DateTime $dateTime ) { $this->_resourceRuleFactory = $resourceRuleFactory; $this->_resourceRule = $resourceRule; $this->_ruleCollectionFactory = $ruleCollectionFactory; $this->_productPrice = $productPrice; - $this->_ruleFactory = $ruleFactory; - $this->_flagFactory = $flagFactory; $this->_storeManager = $storeManager; $this->_localeDate = $localeDate; $this->_customerSession = $customerSession; - $this->_backendSession = $backendSession; $this->_coreRegistry = $coreRegistry; $this->dateTime = $dateTime; - $this->messageManager = $messageManager; - } - - /** - * Apply all catalog price rules for specific product - * - * @param EventObserver $observer - * @return $this|void - */ - public function applyAllRulesOnProduct($observer) - { - $product = $observer->getEvent()->getProduct(); - if ($product->getIsMassupdate()) { - return; - } - - $productWebsiteIds = $product->getWebsiteIds(); - - $rules = $this->_ruleCollectionFactory->create()->addFieldToFilter('is_active', 1); - - foreach ($rules as $rule) { - $websiteIds = array_intersect($productWebsiteIds, $rule->getWebsiteIds()); - $rule->applyToProduct($product, $websiteIds); - } - - return $this; } - - /** - * Apply all price rules for current date. - * Handle cataolg_product_import_after event - * - * @param EventObserver $observer - * @return $this - */ - public function applyAllRules($observer) - { - $this->_resourceRule->applyAllRulesForDateRange($this->dateTime->formatDate(mktime(0, 0, 0))); - $this->_flagFactory->create()->loadSelf()->setState(0)->save(); - - return $this; - } - - /** - * Apply all catalog price rules - * - * Fire the same name process as catalog rule model - * Event name "apply_catalog_price_rules" - * - * @param EventObserver $observer - * @return $this - */ - public function processApplyAll(EventObserver $observer) - { - $this->_ruleFactory->create()->applyAll(); - $this->_flagFactory->create()->loadSelf()->setState(0)->save(); - return $this; - } - /** * Apply catalog price rules to product on frontend * @@ -304,22 +211,6 @@ class Observer return $this; } - /** - * Daily update catalog price rule by cron - * Update include interval 3 days - current day - 1 days before + 1 days after - * This method is called from cron process, cron is working in UTC time and - * we should generate data for interval -1 day ... +1 day - * - * @param EventObserver $observer - * @return $this - */ - public function dailyCatalogUpdate($observer) - { - $this->_resourceRule->applyAllRulesForDateRange(); - - return $this; - } - /** * Clean out calculated catalog rule prices for products * @@ -360,98 +251,6 @@ class Observer return $this; } - /** - * Check rules that contains affected attribute - * If rules were found they will be set to inactive and notice will be add to admin session - * - * @param string $attributeCode - * @return $this - */ - protected function _checkCatalogRulesAvailability($attributeCode) - { - /* @var $collection Collection */ - $collection = $this->_ruleCollectionFactory->create()->addAttributeInConditionFilter($attributeCode); - - $disabledRulesCount = 0; - foreach ($collection as $rule) { - /* @var $rule Rule */ - $rule->setIsActive(0); - /* @var $rule->getConditions() Combine */ - $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode); - $rule->save(); - - $disabledRulesCount++; - } - - if ($disabledRulesCount) { - $this->_ruleFactory->create()->applyAll(); - $this->messageManager->addWarning( - __( - '%1 Catalog Price Rules based on "%2" attribute have been disabled.', - $disabledRulesCount, - $attributeCode - ) - ); - } - - return $this; - } - - /** - * Remove catalog attribute condition by attribute code from rule conditions - * - * @param Combine $combine - * @param string $attributeCode - * @return void - */ - protected function _removeAttributeFromConditions($combine, $attributeCode) - { - $conditions = $combine->getConditions(); - foreach ($conditions as $conditionId => $condition) { - if ($condition instanceof Combine) { - $this->_removeAttributeFromConditions($condition, $attributeCode); - } - if ($condition instanceof AbstractProduct) { - if ($condition->getAttribute() == $attributeCode) { - unset($conditions[$conditionId]); - } - } - } - $combine->setConditions($conditions); - } - - /** - * After save attribute if it is not used for promo rules already check rules for containing this attribute - * - * @param EventObserver $observer - * @return $this - */ - public function catalogAttributeSaveAfter(EventObserver $observer) - { - $attribute = $observer->getEvent()->getAttribute(); - if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { - $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); - } - - return $this; - } - - /** - * After delete attribute check rules that contains deleted attribute - * - * @param EventObserver $observer - * @return $this - */ - public function catalogAttributeDeleteAfter(EventObserver $observer) - { - $attribute = $observer->getEvent()->getAttribute(); - if ($attribute->getIsUsedForPromoRules()) { - $this->_checkCatalogRulesAvailability($attribute->getAttributeCode()); - } - - return $this; - } - /** * @param EventObserver $observer * @return $this @@ -501,27 +300,4 @@ class Observer return $this; } - - /** - * Create catalog rule relations for imported products - * - * @param EventObserver $observer - * @return void - */ - public function createCatalogRulesRelations(EventObserver $observer) - { - $adapter = $observer->getEvent()->getAdapter(); - $affectedEntityIds = $adapter->getAffectedEntityIds(); - - if (empty($affectedEntityIds)) { - return; - } - - $rules = $this->_ruleCollectionFactory->create()->addFieldToFilter('is_active', 1); - - foreach ($rules as $rule) { - $rule->setProductsFilter($affectedEntityIds); - $this->_resourceRule->updateRuleProductData($rule); - } - } } diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 4640667f039..73334bc096c 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -199,514 +199,25 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource } /** - * Update products which are matched for rule - * - * @param ModelRule $rule + * @param \Magento\Framework\Model\AbstractModel $rule * @return $this - * @throws \Exception */ - public function updateRuleProductData(ModelRule $rule) + protected function _afterDelete(\Magento\Framework\Model\AbstractModel $rule) { - $ruleId = $rule->getId(); $write = $this->_getWriteAdapter(); - $write->beginTransaction(); - if ($rule->getProductsFilter()) { - $write->delete( - $this->getTable('catalogrule_product'), - array('rule_id=?' => $ruleId, 'product_id IN (?)' => $rule->getProductsFilter()) - ); - } else { - $write->delete($this->getTable('catalogrule_product'), $write->quoteInto('rule_id=?', $ruleId)); - } - - if (!$rule->getIsActive()) { - $write->commit(); - return $this; - } - - $websiteIds = $rule->getWebsiteIds(); - if (!is_array($websiteIds)) { - $websiteIds = explode(',', $websiteIds); - } - if (empty($websiteIds)) { - return $this; - } - - \Magento\Framework\Profiler::start('__MATCH_PRODUCTS__'); - $productIds = $rule->getMatchingProductIds(); - \Magento\Framework\Profiler::stop('__MATCH_PRODUCTS__'); - - $customerGroupIds = $rule->getCustomerGroupIds(); - $fromTime = strtotime($rule->getFromDate()); - $toTime = strtotime($rule->getToDate()); - $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0; - $sortOrder = (int)$rule->getSortOrder(); - $actionOperator = $rule->getSimpleAction(); - $actionAmount = $rule->getDiscountAmount(); - $subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : ''; - $subActionAmount = $rule->getSubDiscountAmount(); - $actionStop = $rule->getStopRulesProcessing(); - - $rows = array(); - - try { - foreach ($productIds as $productId => $validationByWebsite) { - foreach ($websiteIds as $websiteId) { - foreach ($customerGroupIds as $customerGroupId) { - if (empty($validationByWebsite[$websiteId])) { - continue; - } - $rows[] = array( - 'rule_id' => $ruleId, - 'from_time' => $fromTime, - 'to_time' => $toTime, - 'website_id' => $websiteId, - 'customer_group_id' => $customerGroupId, - 'product_id' => $productId, - 'action_operator' => $actionOperator, - 'action_amount' => $actionAmount, - 'action_stop' => $actionStop, - 'sort_order' => $sortOrder, - 'sub_simple_action' => $subActionOperator, - 'sub_discount_amount' => $subActionAmount - ); - - if (count($rows) == 1000) { - $write->insertMultiple($this->getTable('catalogrule_product'), $rows); - $rows = array(); - } - } - } - } - if (!empty($rows)) { - $write->insertMultiple($this->getTable('catalogrule_product'), $rows); - } - - $write->commit(); - } catch (\Exception $e) { - $write->rollback(); - throw $e; - } - - - return $this; - } - - /** - * Get all product ids matched for rule - * - * @param int $ruleId - * @return array - */ - public function getRuleProductIds($ruleId) - { - $read = $this->_getReadAdapter(); - $select = $read->select()->from( + $write->delete( $this->getTable('catalogrule_product'), - 'product_id' - )->where( - 'rule_id=?', - $ruleId - ); - - return $read->fetchCol($select); - } - - /** - * Remove catalog rules product prices for specified date range and product - * - * @param int|string $fromDate - * @param int|string $toDate - * @param int|null $productId - * @return $this - */ - public function removeCatalogPricesForDateRange($fromDate, $toDate, $productId = null) - { - $write = $this->_getWriteAdapter(); - $conds = array(); - $cond = $write->quoteInto('rule_date between ?', $this->dateTime->formatDate($fromDate)); - $cond = $write->quoteInto($cond . ' and ?', $this->dateTime->formatDate($toDate)); - $conds[] = $cond; - if (!is_null($productId)) { - $conds[] = $write->quoteInto('product_id=?', $productId); - } - - /** - * Add information about affected products - * It can be used in processes which related with product price (like catalog index) - */ - $select = $this->_getWriteAdapter()->select()->from( - $this->getTable('catalogrule_product_price'), - 'product_id' - )->where( - implode(' AND ', $conds) - )->group( - 'product_id' - ); - - $replace = $write->insertFromSelect( - $select, - $this->getTable('catalogrule_affected_product'), - array('product_id'), - true - ); - $write->query($replace); - $write->delete($this->getTable('catalogrule_product_price'), $conds); - return $this; - } - - /** - * Delete old price rules data - * - * @param string $date - * @param int|null $productId - * @return $this - */ - public function deleteOldData($date, $productId = null) - { - $write = $this->_getWriteAdapter(); - $conds = array(); - $conds[] = $write->quoteInto('rule_date<?', $this->dateTime->formatDate($date)); - if (!is_null($productId)) { - $conds[] = $write->quoteInto('product_id=?', $productId); - } - $write->delete($this->getTable('catalogrule_product_price'), $conds); - return $this; - } - - /** - * Get DB resource statement for processing query result - * - * @param int $fromDate - * @param int $toDate - * @param int|null $productId - * @param int|null $websiteId - * @return \Zend_Db_Statement_Interface - */ - protected function _getRuleProductsStmt($fromDate, $toDate, $productId = null, $websiteId = null) - { - $read = $this->_getReadAdapter(); - /** - * Sort order is important - * It used for check stop price rule condition. - * website_id customer_group_id product_id sort_order - * 1 1 1 0 - * 1 1 1 1 - * 1 1 1 2 - * if row with sort order 1 will have stop flag we should exclude - * all next rows for same product id from price calculation - */ - $select = $read->select()->from( - array('rp' => $this->getTable('catalogrule_product')) - )->where( - $read->quoteInto( - 'rp.from_time = 0 or rp.from_time <= ?', - $toDate - ) . ' OR ' . $read->quoteInto( - 'rp.to_time = 0 or rp.to_time >= ?', - $fromDate - ) - )->order( - array('rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id') - ); - - if (!is_null($productId)) { - $select->where('rp.product_id=?', $productId); - } - - /** - * Join default price and websites prices to result - */ - $priceAttr = $this->_eavConfig->getAttribute(Product::ENTITY, 'price'); - $priceTable = $priceAttr->getBackend()->getTable(); - $attributeId = $priceAttr->getId(); - - $joinCondition = '%1$s.entity_id=rp.product_id AND (%1$s.attribute_id=' . - $attributeId . - ') and %1$s.store_id=%2$s'; - - $select->join( - array('pp_default' => $priceTable), - sprintf($joinCondition, 'pp_default', \Magento\Store\Model\Store::DEFAULT_STORE_ID), - array('default_price' => 'pp_default.value') + array('rule_id=?' => $rule->getId()) ); - - if ($websiteId !== null) { - $website = $this->_storeManager->getWebsite($websiteId); - $defaultGroup = $website->getDefaultGroup(); - if ($defaultGroup instanceof \Magento\Store\Model\Group) { - $storeId = $defaultGroup->getDefaultStoreId(); - } else { - $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; - } - - $select->joinInner( - array('product_website' => $this->getTable('catalog_product_website')), - 'product_website.product_id=rp.product_id ' . - 'AND rp.website_id=product_website.website_id ' . - 'AND product_website.website_id=' . - $websiteId, - array() - ); - - $tableAlias = 'pp' . $websiteId; - $fieldAlias = 'website_' . $websiteId . '_price'; - $select->joinLeft( - array($tableAlias => $priceTable), - sprintf($joinCondition, $tableAlias, $storeId), - array($fieldAlias => $tableAlias . '.value') - ); - } else { - foreach ($this->_storeManager->getWebsites() as $website) { - $websiteId = $website->getId(); - $defaultGroup = $website->getDefaultGroup(); - if ($defaultGroup instanceof \Magento\Store\Model\Group) { - $storeId = $defaultGroup->getDefaultStoreId(); - } else { - $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; - } - - $tableAlias = 'pp' . $websiteId; - $fieldAlias = 'website_' . $websiteId . '_price'; - $select->joinLeft( - array($tableAlias => $priceTable), - sprintf($joinCondition, $tableAlias, $storeId), - array($fieldAlias => $tableAlias . '.value') - ); - } - } - - return $read->query($select); - } - - /** - * Generate catalog price rules prices for specified date range - * If from date is not defined - will be used previous day by UTC - * If to date is not defined - will be used next day by UTC - * - * @param int|string|null $fromDate - * @param int|string|null $toDate - * @param int $productId - * @return $this - * @throws \Exception - */ - public function applyAllRulesForDateRange($fromDate = null, $toDate = null, $productId = null) - { - $write = $this->_getWriteAdapter(); - $write->beginTransaction(); - - $this->_eventManager->dispatch('catalogrule_before_apply', array('resource' => $this)); - - $clearOldData = false; - if ($fromDate === null) { - $fromDate = mktime(0, 0, 0, date('m'), date('d') - 1); - /** - * If fromDate not specified we can delete all data oldest than 1 day - * We have run it for clear table in case when cron was not installed - * and old data exist in table - */ - $clearOldData = true; - } - if (is_string($fromDate)) { - $fromDate = strtotime($fromDate); - } - if ($toDate === null) { - $toDate = mktime(0, 0, 0, date('m'), date('d') + 1); - } - if (is_string($toDate)) { - $toDate = strtotime($toDate); - } - - $product = null; - if ($productId instanceof Product) { - $product = $productId; - $productId = $productId->getId(); - } - - $this->removeCatalogPricesForDateRange($fromDate, $toDate, $productId); - if ($clearOldData) { - $this->deleteOldData($fromDate, $productId); - } - - $dayPrices = array(); - - try { - /** - * Update products rules prices per each website separately - * because of max join limit in mysql - */ - foreach ($this->_storeManager->getWebsites(false) as $website) { - $productsStmt = $this->_getRuleProductsStmt($fromDate, $toDate, $productId, $website->getId()); - - $dayPrices = array(); - $stopFlags = array(); - $prevKey = null; - - while ($ruleData = $productsStmt->fetch()) { - $ruleProductId = $ruleData['product_id']; - $productKey = $ruleProductId . - '_' . - $ruleData['website_id'] . - '_' . - $ruleData['customer_group_id']; - - if ($prevKey && $prevKey != $productKey) { - $stopFlags = array(); - } - - /** - * Build prices for each day - */ - for ($time = $fromDate; $time <= $toDate; $time += self::SECONDS_IN_DAY) { - if (($ruleData['from_time'] == 0 || - $time >= $ruleData['from_time']) && ($ruleData['to_time'] == 0 || - $time <= $ruleData['to_time']) - ) { - $priceKey = $time . '_' . $productKey; - - if (isset($stopFlags[$priceKey])) { - continue; - } - - if (!isset($dayPrices[$priceKey])) { - $dayPrices[$priceKey] = array( - 'rule_date' => $time, - 'website_id' => $ruleData['website_id'], - 'customer_group_id' => $ruleData['customer_group_id'], - 'product_id' => $ruleProductId, - 'rule_price' => $this->_calcRuleProductPrice($ruleData), - 'latest_start_date' => $ruleData['from_time'], - 'earliest_end_date' => $ruleData['to_time'] - ); - } else { - $dayPrices[$priceKey]['rule_price'] = $this->_calcRuleProductPrice( - $ruleData, - $dayPrices[$priceKey] - ); - $dayPrices[$priceKey]['latest_start_date'] = max( - $dayPrices[$priceKey]['latest_start_date'], - $ruleData['from_time'] - ); - $dayPrices[$priceKey]['earliest_end_date'] = min( - $dayPrices[$priceKey]['earliest_end_date'], - $ruleData['to_time'] - ); - } - - if ($ruleData['action_stop']) { - $stopFlags[$priceKey] = true; - } - } - } - - $prevKey = $productKey; - if (count($dayPrices) > 1000) { - $this->_saveRuleProductPrices($dayPrices); - $dayPrices = array(); - } - } - $this->_saveRuleProductPrices($dayPrices); - } - $this->_saveRuleProductPrices($dayPrices); - - $write->delete($this->getTable('catalogrule_group_website'), array()); - - $timestamp = $this->_coreDate->gmtTimestamp(); - - $select = $write->select()->distinct( - true - )->from( - $this->getTable('catalogrule_product'), - array('rule_id', 'customer_group_id', 'website_id') - )->where( - "{$timestamp} >= from_time AND (({$timestamp} <= to_time AND to_time > 0) OR to_time = 0)" - ); - $query = $select->insertFromSelect($this->getTable('catalogrule_group_website')); - $write->query($query); - - $write->commit(); - } catch (\Exception $e) { - $this->_logger->logException($e); - $write->rollback(); - throw $e; - } - - $productCondition = $this->_conditionFactory->create()->setTable( - $this->getTable('catalogrule_affected_product') - )->setPkFieldName( - 'product_id' - ); - $this->_eventManager->dispatch( - 'catalogrule_after_apply', - array('product' => $product, 'product_condition' => $productCondition) + $write->delete( + $this->getTable('catalogrule_customer_group'), + array('rule_id=?' => $rule->getId()) ); - $write->delete($this->getTable('catalogrule_affected_product')); - - return $this; - } - - /** - * Calculate product price based on price rule data and previous information - * - * @param array $ruleData - * @param null|array $productData - * @return float - */ - protected function _calcRuleProductPrice($ruleData, $productData = null) - { - if ($productData !== null && isset($productData['rule_price'])) { - $productPrice = $productData['rule_price']; - } else { - $websiteId = $ruleData['website_id']; - if (isset($ruleData['website_' . $websiteId . '_price'])) { - $productPrice = $ruleData['website_' . $websiteId . '_price']; - } else { - $productPrice = $ruleData['default_price']; - } - } - - $productPrice = $this->_catalogRuleData->calcPriceRule( - $ruleData['action_operator'], - $ruleData['action_amount'], - $productPrice + $write->delete( + $this->getTable('catalogrule_group_website'), + array('rule_id=?' => $rule->getId()) ); - - return $this->priceCurrency->round($productPrice); - } - - /** - * Save rule prices for products to DB - * - * @param array $arrData - * @return $this - * @throws \Exception - */ - protected function _saveRuleProductPrices($arrData) - { - if (empty($arrData)) { - return $this; - } - - $adapter = $this->_getWriteAdapter(); - $productIds = array(); - - $adapter->beginTransaction(); - try { - foreach ($arrData as $key => $data) { - $productIds['product_id'] = $data['product_id']; - $arrData[$key]['rule_date'] = $this->dateTime->formatDate($data['rule_date'], false); - $arrData[$key]['latest_start_date'] = $this->dateTime->formatDate($data['latest_start_date'], false); - $arrData[$key]['earliest_end_date'] = $this->dateTime->formatDate($data['earliest_end_date'], false); - } - $adapter->insertOnDuplicate($this->getTable('catalogrule_affected_product'), array_unique($productIds)); - $adapter->insertOnDuplicate($this->getTable('catalogrule_product_price'), $arrData); - } catch (\Exception $e) { - $adapter->rollback(); - throw $e; - } - $adapter->commit(); - - return $this; + return parent::_afterDelete($rule); } /** @@ -797,119 +308,4 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource return $adapter->fetchAll($select); } - - /** - * Retrieve product price data for all customer groups - * - * @param int|string $date - * @param int $wId - * @param int $pId - * @return array - */ - public function getRulesForProduct($date, $wId, $pId) - { - $read = $this->_getReadAdapter(); - $select = $read->select()->from( - $this->getTable('catalogrule_product_price'), - '*' - )->where( - 'rule_date=?', - $this->dateTime->formatDate($date, false) - )->where( - 'website_id=?', - $wId - )->where( - 'product_id=?', - $pId - ); - - return $read->fetchAll($select); - } - - /** - * Apply catalog rule to product - * - * @param ModelRule $rule - * @param Product $product - * @param array $websiteIds - * @return $this - * @throws \Exception - */ - public function applyToProduct($rule, $product, $websiteIds) - { - if (!$rule->getIsActive()) { - return $this; - } - - $ruleId = $rule->getId(); - $productId = $product->getId(); - - $write = $this->_getWriteAdapter(); - $write->beginTransaction(); - - $write->delete( - $this->getTable('catalogrule_product'), - array($write->quoteInto('rule_id=?', $ruleId), $write->quoteInto('product_id=?', $productId)) - ); - - if (!$rule->getConditions()->validate($product)) { - $write->delete( - $this->getTable('catalogrule_product_price'), - array($write->quoteInto('product_id=?', $productId)) - ); - $write->commit(); - return $this; - } - - $customerGroupIds = $rule->getCustomerGroupIds(); - $fromTime = strtotime($rule->getFromDate()); - $toTime = strtotime($rule->getToDate()); - $toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0; - $sortOrder = (int)$rule->getSortOrder(); - $actionOperator = $rule->getSimpleAction(); - $actionAmount = $rule->getDiscountAmount(); - $actionStop = $rule->getStopRulesProcessing(); - $subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : ''; - $subActionAmount = $rule->getSubDiscountAmount(); - - $rows = array(); - try { - foreach ($websiteIds as $websiteId) { - foreach ($customerGroupIds as $customerGroupId) { - $rows[] = array( - 'rule_id' => $ruleId, - 'from_time' => $fromTime, - 'to_time' => $toTime, - 'website_id' => $websiteId, - 'customer_group_id' => $customerGroupId, - 'product_id' => $productId, - 'action_operator' => $actionOperator, - 'action_amount' => $actionAmount, - 'action_stop' => $actionStop, - 'sort_order' => $sortOrder, - 'sub_simple_action' => $subActionOperator, - 'sub_discount_amount' => $subActionAmount - ); - - if (count($rows) == 1000) { - $write->insertMultiple($this->getTable('catalogrule_product'), $rows); - $rows = array(); - } - } - } - - if (!empty($rows)) { - $write->insertMultiple($this->getTable('catalogrule_product'), $rows); - } - } catch (\Exception $e) { - $write->rollback(); - throw $e; - } - - $this->applyAllRulesForDateRange(null, null, $product); - - $write->commit(); - - return $this; - } } diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 9de82512439..e3cf9fef46c 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -353,49 +353,6 @@ class Rule extends \Magento\Rule\Model\AbstractModel return $map; } - /** - * Apply rule to product - * - * @param int|Product $product - * @param array|null $websiteIds - * - * @return void - */ - public function applyToProduct($product, $websiteIds = null) - { - if (is_numeric($product)) { - $product = $this->_productFactory->create()->load($product); - } - if (is_null($websiteIds)) { - $websiteIds = $this->getWebsiteIds(); - } - $this->getResource()->applyToProduct($this, $product, $websiteIds); - } - - /** - * Apply all price rules, invalidate related cache and refresh price index - * - * @return void - */ - public function applyAll() - { - $this->getResourceCollection()->walk(array($this->_getResource(), 'updateRuleProductData')); - $this->_getResource()->applyAllRulesForDateRange(); - $this->_invalidateCache(); - } - - /** - * Apply all price rules to product - * - * @param int|Product $product - * @return void - */ - public function applyAllRulesToProduct($product) - { - $this->_getResource()->applyAllRulesForDateRange(null, null, $product); - $this->_invalidateCache(); - } - /** * Calculate price using catalog price rule of product * diff --git a/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php b/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php index 4bbb44aeb16..a2aba9530c0 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php @@ -83,6 +83,7 @@ class Combine extends \Magento\Rule\Model\Condition\Combine public function collectValidatedAttributes($productCollection) { foreach ($this->getConditions() as $condition) { + /** @var Product|Combine $condition */ $condition->collectValidatedAttributes($productCollection); } return $this; diff --git a/app/code/Magento/CatalogRule/Model/Rule/Job.php b/app/code/Magento/CatalogRule/Model/Rule/Job.php index fa1609f4c96..98201f457b9 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Job.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Job.php @@ -40,23 +40,23 @@ */ namespace Magento\CatalogRule\Model\Rule; +use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; + class Job extends \Magento\Framework\Object { /** - * Instance of event manager model - * - * @var \Magento\Framework\Event\ManagerInterface + * @var RuleProductProcessor */ - protected $_eventManager; + protected $ruleProcessor; /** * Basic object initialization * - * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param RuleProductProcessor $ruleProcessor */ - public function __construct(\Magento\Framework\Event\ManagerInterface $eventManager) + public function __construct(RuleProductProcessor $ruleProcessor) { - $this->_eventManager = $eventManager; + $this->ruleProcessor = $ruleProcessor; } /** @@ -67,8 +67,8 @@ class Job extends \Magento\Framework\Object public function applyAll() { try { - $this->_eventManager->dispatch('catalogrule_apply_all'); - $this->setSuccess(__('The rules have been applied.')); + $this->ruleProcessor->markIndexerAsInvalid(); + $this->setSuccess(__('Updated rules applied.')); } catch (\Magento\Framework\Model\Exception $e) { $this->setError($e->getMessage()); } diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/Category.php b/app/code/Magento/CatalogRule/Plugin/Indexer/Category.php new file mode 100644 index 00000000000..68cd1451cec --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/Category.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\CatalogRule\Plugin\Indexer; + +use Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor; + +class Category +{ + /** + * @var ProductRuleProcessor + */ + protected $productRuleProcessor; + + /** + * @param ProductRuleProcessor $productRuleProcessor + */ + public function __construct( + ProductRuleProcessor $productRuleProcessor + ) { + $this->productRuleProcessor = $productRuleProcessor; + } + + /** + * @param \Magento\Catalog\Model\Category $subject + * @param \Magento\Catalog\Model\Category $result + * @return \Magento\Catalog\Model\Category + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave( + \Magento\Catalog\Model\Category $subject, + \Magento\Catalog\Model\Category $result + ) { + /** @var \Magento\Catalog\Model\Category $result */ + $productIds = $result->getAffectedProductIds(); + if ($productIds) { + $this->productRuleProcessor->reindexList($productIds); + } + return $result; + } + + /** + * @param \Magento\Catalog\Model\Category $subject + * @param \Magento\Catalog\Model\Category $result + * @return \Magento\Catalog\Model\Category + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete( + \Magento\Catalog\Model\Category $subject, + \Magento\Catalog\Model\Category $result + ) { + $this->productRuleProcessor->markIndexerAsInvalid(); + return $result; + } +} diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/CustomerGroup.php b/app/code/Magento/CatalogRule/Plugin/Indexer/CustomerGroup.php new file mode 100644 index 00000000000..9d6624cfb06 --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/CustomerGroup.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\CatalogRule\Plugin\Indexer; + +use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; +use Magento\Customer\Model\Group; + +class CustomerGroup +{ + /** + * @var RuleProductProcessor + */ + protected $ruleProductProcessor; + + /** + * @param RuleProductProcessor $ruleProductProcessor + */ + public function __construct(RuleProductProcessor $ruleProductProcessor) + { + $this->ruleProductProcessor = $ruleProductProcessor; + } + + /** + * @param Group $subject + * @param Group $result + * @return Group + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete( + Group $subject, + Group $result + ) { + $this->ruleProductProcessor->markIndexerAsInvalid(); + return $result; + } +} diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/ImportExport.php b/app/code/Magento/CatalogRule/Plugin/Indexer/ImportExport.php new file mode 100644 index 00000000000..ee191b2bf55 --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/ImportExport.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\CatalogRule\Plugin\Indexer; + +use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; +use Magento\ImportExport\Model\Import; + +class ImportExport +{ + /** + * @var RuleProductProcessor + */ + protected $ruleProductProcessor; + + /** + * @param RuleProductProcessor $ruleProductProcessor + */ + public function __construct(RuleProductProcessor $ruleProductProcessor) + { + $this->ruleProductProcessor = $ruleProductProcessor; + } + + /** + * Invalidate catalog price rule indexer + * + * @param Import $subject + * @param bool $result + * @return bool + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterImportSource(Import $subject, $result) + { + $this->ruleProductProcessor->markIndexerAsInvalid(); + return $result; + } +} diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Attribute.php b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Attribute.php new file mode 100644 index 00000000000..38a192a2112 --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Attribute.php @@ -0,0 +1,158 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Plugin\Indexer\Product; + +use Magento\CatalogRule\Model\Rule; +use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; +use Magento\CatalogRule\Model\Rule\Condition\Combine; +use Magento\CatalogRule\Model\Resource\Rule\CollectionFactory as RuleCollectionFactory; +use Magento\Rule\Model\Condition\Product\AbstractProduct; +use Magento\Framework\Message\ManagerInterface; + +class Attribute +{ + /** + * @var RuleCollectionFactory + */ + protected $ruleCollectionFactory; + + /** + * @var RuleProductProcessor + */ + protected $ruleProductProcessor; + + /** + * @var ManagerInterface + */ + protected $messageManager; + + /** + * @param RuleCollectionFactory $ruleCollectionFactory + * @param RuleProductProcessor $ruleProductProcessor + * @param ManagerInterface $messageManager + */ + public function __construct( + RuleCollectionFactory $ruleCollectionFactory, + RuleProductProcessor $ruleProductProcessor, + ManagerInterface $messageManager + ) { + $this->ruleCollectionFactory = $ruleCollectionFactory; + $this->ruleProductProcessor = $ruleProductProcessor; + $this->messageManager = $messageManager; + } + + /** + * @param \Magento\Catalog\Model\Resource\Eav\Attribute $subject + * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute + * @return \Magento\Catalog\Model\Resource\Eav\Attribute + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave( + \Magento\Catalog\Model\Resource\Eav\Attribute $subject, + \Magento\Catalog\Model\Resource\Eav\Attribute $attribute + ) { + if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { + $this->checkCatalogRulesAvailability($attribute->getAttributeCode()); + } + return $attribute; + } + + /** + * @param \Magento\Catalog\Model\Resource\Eav\Attribute $subject + * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute + * @return \Magento\Catalog\Model\Resource\Eav\Attribute + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete( + \Magento\Catalog\Model\Resource\Eav\Attribute $subject, + \Magento\Catalog\Model\Resource\Eav\Attribute $attribute + ) { + if ($attribute->getIsUsedForPromoRules()) { + $this->checkCatalogRulesAvailability($attribute->getAttributeCode()); + } + return $attribute; + } + + /** + * Check rules that contains affected attribute + * If rules were found they will be set to inactive and notice will be add to admin session + * + * @param string $attributeCode + * @return $this + */ + protected function checkCatalogRulesAvailability($attributeCode) + { + /* @var $collection RuleCollectionFactory */ + $collection = $this->ruleCollectionFactory->create()->addAttributeInConditionFilter($attributeCode); + + $disabledRulesCount = 0; + foreach ($collection as $rule) { + /* @var $rule Rule */ + $rule->setIsActive(0); + /* @var $rule->getConditions() Combine */ + $this->removeAttributeFromConditions($rule->getConditions(), $attributeCode); + $rule->save(); + + $disabledRulesCount++; + } + + if ($disabledRulesCount) { + $this->ruleProductProcessor->markIndexerAsInvalid(); + $this->messageManager->addWarning( + __( + '%1 Catalog Price Rules based on "%2" attribute have been disabled.', + $disabledRulesCount, + $attributeCode + ) + ); + } + + return $this; + } + + /** + * Remove catalog attribute condition by attribute code from rule conditions + * + * @param Combine $combine + * @param string $attributeCode + * @return void + */ + protected function removeAttributeFromConditions(Combine $combine, $attributeCode) + { + $conditions = $combine->getConditions(); + foreach ($conditions as $conditionId => $condition) { + if ($condition instanceof Combine) { + $this->removeAttributeFromConditions($condition, $attributeCode); + } + if ($condition instanceof AbstractProduct) { + if ($condition->getAttribute() == $attributeCode) { + unset($conditions[$conditionId]); + } + } + } + $combine->setConditions($conditions); + } +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexer.php similarity index 50% rename from app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php rename to app/code/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexer.php index 24ca0a08bcc..8c5464a76ce 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRule.php +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexer.php @@ -17,94 +17,72 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; -class CatalogRule +namespace Magento\CatalogRule\Plugin\Indexer\Product; + +class PriceIndexer { /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor */ - protected $_processor; + protected $priceProcessor; /** - * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor + * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $priceProcessor */ - public function __construct( - \Magento\Catalog\Model\Indexer\Product\Price\Processor $processor - ) { - $this->_processor = $processor; + public function __construct(\Magento\Catalog\Model\Indexer\Product\Price\Processor $priceProcessor) + { + $this->priceProcessor = $priceProcessor; } /** * Invalidate price indexer * - * @param \Magento\CatalogRule\Model\Rule $subject - * + * @param \Magento\CatalogRule\Model\Indexer\IndexBuilder $subject * @return void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterApplyAll(\Magento\CatalogRule\Model\Rule $subject) + public function afterReindexFull(\Magento\CatalogRule\Model\Indexer\IndexBuilder $subject) { - $this->_processor->markIndexerAsInvalid(); + $this->priceProcessor->markIndexerAsInvalid(); } /** - * Reindex price for affected product - * - * @param \Magento\CatalogRule\Model\Rule $subject + * @param \Magento\CatalogRule\Model\Indexer\IndexBuilder $subject * @param callable $proceed - * @param int|\Magento\Catalog\Model\Product $product - * @param null|array $websiteIds - * + * @param array $productIds * @return void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundApplyToProduct( - \Magento\CatalogRule\Model\Rule $subject, + public function aroundReindexByIds( + \Magento\CatalogRule\Model\Indexer\IndexBuilder $subject, \Closure $proceed, - $product, - $websiteIds = null + array $productIds ) { - $proceed($product, $websiteIds); - $this->_reindexProduct($product); + $proceed($productIds); + $this->priceProcessor->reindexList($productIds); } /** - * Reindex price for affected product - * - * @param \Magento\CatalogRule\Model\Rule $subject + * @param \Magento\CatalogRule\Model\Indexer\IndexBuilder $subject * @param callable $proceed - * @param int|\Magento\Catalog\Model\Product $product - * + * @param int $productId * @return void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundApplyAllRulesToProduct( - \Magento\CatalogRule\Model\Rule $subject, + public function aroundReindexById( + \Magento\CatalogRule\Model\Indexer\IndexBuilder $subject, \Closure $proceed, - $product + $productId ) { - $proceed($product); - $this->_reindexProduct($product); - } - - /** - * Reindex product price - * - * @param int|\Magento\Catalog\Model\Product $product - * - * @return void - */ - protected function _reindexProduct($product) - { - $productId = is_numeric($product) ? $product : $product->getId(); - $this->_processor->reindexRow($productId); + $proceed($productId); + $this->priceProcessor->reindexRow($productId); } } diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Save/ApplyRules.php b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Save/ApplyRules.php new file mode 100644 index 00000000000..1cc389f0200 --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/Product/Save/ApplyRules.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Plugin\Indexer\Product\Save; + +use Magento\Catalog\Model\Product; +use Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor; + +class ApplyRules +{ + /** + * @var ProductRuleProcessor + */ + protected $productRuleProcessor; + + /** + * @param ProductRuleProcessor $productRuleProcessor + */ + public function __construct(ProductRuleProcessor $productRuleProcessor) + { + $this->productRuleProcessor = $productRuleProcessor; + } + + /** + * Apply catalog rules after product save + * + * @param Product $subject + * @param Product $result + * @return Product + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSave( + Product $subject, + Product $result + ) { + if (!$result->getIsMassupdate()) { + $this->productRuleProcessor->reindexRow($result->getId()); + } + return $result; + } +} diff --git a/app/code/Magento/CatalogRule/Plugin/Indexer/Website.php b/app/code/Magento/CatalogRule/Plugin/Indexer/Website.php new file mode 100644 index 00000000000..14c2f42bd7a --- /dev/null +++ b/app/code/Magento/CatalogRule/Plugin/Indexer/Website.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\CatalogRule\Plugin\Indexer; + +use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; + +class Website +{ + /** + * @var RuleProductProcessor + */ + protected $ruleProductProcessor; + + /** + * @param RuleProductProcessor $ruleProductProcessor + */ + public function __construct(RuleProductProcessor $ruleProductProcessor) + { + $this->ruleProductProcessor = $ruleProductProcessor; + } + + /** + * Invalidate catalog price rule indexer + * + * @param \Magento\Store\Model\Website $subject + * @param \Magento\Store\Model\Website $result + * @return \Magento\Store\Model\Website + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterDelete( + \Magento\Store\Model\Website $subject, + \Magento\Store\Model\Website $result + ) { + $this->ruleProductProcessor->markIndexerAsInvalid(); + return $result; + } +} diff --git a/app/code/Magento/CatalogRule/composer.json b/app/code/Magento/CatalogRule/composer.json index 653131508c7..b27dd420171 100644 --- a/app/code/Magento/CatalogRule/composer.json +++ b/app/code/Magento/CatalogRule/composer.json @@ -3,17 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-rule": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-rule": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogRule/etc/adminhtml/di.xml b/app/code/Magento/CatalogRule/etc/adminhtml/di.xml index 2951c5c618a..2d402151170 100644 --- a/app/code/Magento/CatalogRule/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogRule/etc/adminhtml/di.xml @@ -32,4 +32,22 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Model\Product"> + <plugin name="apply_catalog_rules_after_product_save" type="Magento\CatalogRule\Plugin\Indexer\Product\Save\ApplyRules"/> + </type> + <type name="Magento\Catalog\Model\Category"> + <plugin name="apply_after_products_assign" type="Magento\CatalogRule\Plugin\Indexer\Category"/> + </type> + <type name="Magento\Store\Model\Website"> + <plugin name="reindex_after_delete_website" type="Magento\CatalogRule\Plugin\Indexer\Website"/> + </type> + <type name="Magento\Customer\Model\Group"> + <plugin name="reindex_after_delete_customer_group" type="Magento\CatalogRule\Plugin\Indexer\CustomerGroup"/> + </type> + <type name="Magento\ImportExport\Model\Import"> + <plugin name="reindex_after_import" type="Magento\CatalogRule\Plugin\Indexer\ImportExport"/> + </type> + <type name="Magento\Catalog\Model\Resource\Eav\Attribute"> + <plugin name="change_product_attribute" type="Magento\CatalogRule\Plugin\Indexer\Product\Attribute"/> + </type> </config> diff --git a/app/code/Magento/CatalogRule/etc/adminhtml/events.xml b/app/code/Magento/CatalogRule/etc/adminhtml/events.xml index 1f8dc132df6..dbfa51c8e1c 100644 --- a/app/code/Magento/CatalogRule/etc/adminhtml/events.xml +++ b/app/code/Magento/CatalogRule/etc/adminhtml/events.xml @@ -27,19 +27,4 @@ <event name="catalog_product_get_final_price"> <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="processAdminFinalPrice" /> </event> - <event name="catalog_product_save_after"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="applyAllRulesOnProduct" /> - </event> - <event name="catalog_product_import_finish_before"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="createCatalogRulesRelations" /> - </event> - <event name="catalog_product_import_after"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="applyAllRules" /> - </event> - <event name="catalog_entity_attribute_delete_after"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="catalogAttributeDeleteAfter" /> - </event> - <event name="catalog_entity_attribute_save_after"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="catalogAttributeSaveAfter" /> - </event> </config> diff --git a/app/code/Magento/CatalogRule/etc/crontab.xml b/app/code/Magento/CatalogRule/etc/crontab.xml index c727ac11d8f..0210d925dbf 100644 --- a/app/code/Magento/CatalogRule/etc/crontab.xml +++ b/app/code/Magento/CatalogRule/etc/crontab.xml @@ -25,7 +25,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Cron/etc/crontab.xsd"> <group id="default"> - <job name="catalogrule_apply_all" instance="Magento\CatalogRule\Model\Observer" method="dailyCatalogUpdate"> + <job name="catalogrule_apply_all" instance="Magento\CatalogRule\Model\Cron" method="dailyCatalogUpdate"> <schedule>0 1 * * *</schedule> </job> </group> diff --git a/app/code/Magento/CatalogRule/etc/di.xml b/app/code/Magento/CatalogRule/etc/di.xml index 6bab83ce4c4..07960de9e68 100644 --- a/app/code/Magento/CatalogRule/etc/di.xml +++ b/app/code/Magento/CatalogRule/etc/di.xml @@ -51,7 +51,6 @@ </argument> </arguments> </type> - <virtualType name="Magento\Catalog\Pricing\Price\Pool" type="Magento\Framework\Pricing\Price\Pool"> <arguments> <argument name="prices" xsi:type="array"> @@ -59,5 +58,7 @@ </argument> </arguments> </virtualType> - + <type name="Magento\CatalogRule\Model\Indexer\IndexBuilder"> + <plugin name="invalidate_price_indexer" type="Magento\CatalogRule\Plugin\Indexer\Product\PriceIndexer"/> + </type> </config> diff --git a/app/code/Magento/CatalogRule/etc/events.xml b/app/code/Magento/CatalogRule/etc/events.xml index 939092ebfea..28c5e57be04 100644 --- a/app/code/Magento/CatalogRule/etc/events.xml +++ b/app/code/Magento/CatalogRule/etc/events.xml @@ -27,7 +27,4 @@ <event name="prepare_catalog_product_price_index_table"> <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="prepareCatalogProductPriceIndexTable" /> </event> - <event name="catalogrule_apply_all"> - <observer name="catalogrule" instance="Magento\CatalogRule\Model\Observer" method="processApplyAll" /> - </event> </config> diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml new file mode 100644 index 00000000000..cc9b494a20f --- /dev/null +++ b/app/code/Magento/CatalogRule/etc/indexer.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) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Indexer/etc/indexer.xsd"> + <indexer id="catalogrule_rule" view_id="catalogrule_rule" class="Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer"> + <title translate="true">Catalog Rule Product</title> + <description translate="true">Indexed rule/product association</description> + </indexer> + <indexer id="catalogrule_product" view_id="catalogrule_product" class="Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer"> + <title translate="true">Catalog Product Rule</title> + <description translate="true">Indexed product/rule association</description> + </indexer> +</config> diff --git a/app/code/Magento/CatalogRule/etc/module.xml b/app/code/Magento/CatalogRule/etc/module.xml index 5fda9f6e40c..ca42e637d3a 100644 --- a/app/code/Magento/CatalogRule/etc/module.xml +++ b/app/code/Magento/CatalogRule/etc/module.xml @@ -37,6 +37,8 @@ <module name="Magento_Customer"/> <module name="Magento_Backend"/> <module name="Magento_Eav"/> + <module name="Magento_Indexer"/> + <module name="Magento_ImportExport"/> </depends> </module> </config> diff --git a/app/code/Magento/CatalogRule/etc/mview.xml b/app/code/Magento/CatalogRule/etc/mview.xml new file mode 100644 index 00000000000..db09195083a --- /dev/null +++ b/app/code/Magento/CatalogRule/etc/mview.xml @@ -0,0 +1,47 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Mview/etc/mview.xsd"> + <view id="catalogrule_rule" class="Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer" group="indexer"> + <subscriptions> + <table name="catalogrule" entity_column="rule_id" /> + </subscriptions> + </view> + <view id="catalogrule_product" class="Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer" group="indexer"> + <subscriptions> + <table name="catalog_product_entity" entity_column="entity_id" /> + <table name="catalog_product_entity_datetime" entity_column="entity_id" /> + <table name="catalog_product_entity_decimal" entity_column="entity_id" /> + <table name="catalog_product_entity_gallery" entity_column="entity_id" /> + <table name="catalog_product_entity_group_price" entity_column="entity_id" /> + <table name="catalog_product_entity_int" entity_column="entity_id" /> + <table name="catalog_product_entity_media_gallery" entity_column="entity_id" /> + <table name="catalog_product_entity_text" entity_column="entity_id" /> + <table name="catalog_product_entity_tier_price" entity_column="entity_id" /> + <table name="catalog_product_entity_varchar" entity_column="entity_id" /> + <table name="catalog_category_product" entity_column="product_id" /> + </subscriptions> + </view> +</config> diff --git a/app/code/Magento/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/Magento/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.3-1.6.0.4.php new file mode 100644 index 00000000000..c749227b35e --- /dev/null +++ b/app/code/Magento/CatalogRule/sql/catalogrule_setup/upgrade-1.6.0.3-1.6.0.4.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) + */ + +/* @var $installer \Magento\Framework\Module\Setup */ +$installer = $this; + +$installer->startSetup(); + +$table = $installer->getTable('catalogrule_product_price'); +$installer->getConnection()->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product_price', 'product_id', 'catalog_product_entity', 'entity_id') +)->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product_price', 'customer_group_id', 'customer_group', 'customer_group_id') +)->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product_price', 'website_id', 'store_website', 'website_id') +); + +$table = $installer->getTable('catalogrule_product'); +$installer->getConnection()->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product', 'product_id', 'catalog_product_entity', 'entity_id') +)->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product', 'customer_group_id', 'customer_group', 'customer_group_id') +)->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product', 'website_id', 'store_website', 'website_id') +)->dropForeignKey( + $table, + $installer->getFkName('catalogrule_product', 'rule_id', 'catalogrule', 'rule_id') +); + +$installer->endSetup(); diff --git a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php index 5764354f7a8..778b32adc36 100644 --- a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php +++ b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php @@ -38,7 +38,7 @@ use Magento\Framework\Model\Context; use Magento\Framework\Registry; use Magento\Framework\Model\Resource\AbstractResource; use Magento\Framework\Data\Collection\Db; -use Magento\Indexer\Model\IndexerFactory; +use Magento\Indexer\Model\IndexerRegistry; class Type extends Value { @@ -49,17 +49,15 @@ class Type extends Value */ protected $_catalogSearchFulltext; - /** - * @var \Magento\Indexer\Model\IndexerFactory - */ - protected $indexerFactory; + /** @var IndexerRegistry */ + protected $indexerRegistry; /** * @param Context $context * @param Registry $registry * @param ScopeConfigInterface $config * @param Fulltext $catalogSearchFulltext - * @param IndexerFactory $indexerFactory + * @param IndexerRegistry $indexerRegistry * @param AbstractResource $resource * @param Db $resourceCollection * @param array $data @@ -69,13 +67,13 @@ class Type extends Value Registry $registry, ScopeConfigInterface $config, Fulltext $catalogSearchFulltext, - IndexerFactory $indexerFactory, + IndexerRegistry $indexerRegistry, AbstractResource $resource = null, Db $resourceCollection = null, array $data = array() ) { $this->_catalogSearchFulltext = $catalogSearchFulltext; - $this->indexerFactory = $indexerFactory; + $this->indexerRegistry = $indexerRegistry; parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); } @@ -94,12 +92,8 @@ class Type extends Value ); if ($newValue != $oldValue) { $this->_catalogSearchFulltext->resetSearchResults(); - - $indexer = $this->indexerFactory->create(); - $indexer->load(FulltextIndexer::INDEXER_ID); - $indexer->invalidate(); + $this->indexerRegistry->get(FulltextIndexer::INDEXER_ID)->invalidate(); } - return $this; } } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index b3e8547a1a0..57c05e75711 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -40,24 +40,22 @@ class Fulltext implements \Magento\Indexer\Model\ActionInterface, \Magento\Frame */ protected $rowsActionFactory; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** * @param Fulltext\Action\FullFactory $fullActionFactory * @param Fulltext\Action\RowsFactory $rowsActionFactory - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( Fulltext\Action\FullFactory $fullActionFactory, Fulltext\Action\RowsFactory $rowsActionFactory, - \Magento\Indexer\Model\IndexerInterface $indexer + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { $this->fullActionFactory = $fullActionFactory; $this->rowsActionFactory = $rowsActionFactory; - $this->indexer = $indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -68,7 +66,7 @@ class Fulltext implements \Magento\Indexer\Model\ActionInterface, \Magento\Frame */ public function execute($ids) { - $this->indexer->load(self::INDEXER_ID); + $this->indexerRegistry->get(self::INDEXER_ID); /** @var Fulltext\Action\Rows $action */ $action = $this->rowsActionFactory->create(); @@ -91,7 +89,7 @@ class Fulltext implements \Magento\Indexer\Model\ActionInterface, \Magento\Frame * @param int[] $ids * @return void */ - public function executeList($ids) + public function executeList(array $ids) { $this->execute($ids); } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php index 5f1a512b4ca..47e19697662 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php @@ -27,31 +27,16 @@ use Magento\CatalogSearch\Model\Indexer\Fulltext; abstract class AbstractPlugin { - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerInterface $indexer + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( - \Magento\Indexer\Model\IndexerInterface $indexer + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { - $this->indexer = $indexer; - } - - /** - * Return own indexer object - * - * @return \Magento\Indexer\Model\IndexerInterface - */ - protected function getIndexer() - { - if (!$this->indexer->getId()) { - $this->indexer->load(Fulltext::INDEXER_ID); - } - return $this->indexer; + $this->indexerRegistry = $indexerRegistry; } /** @@ -62,8 +47,9 @@ abstract class AbstractPlugin */ protected function reindexRow($productId) { - if (!$this->getIndexer()->isScheduled()) { - $this->getIndexer()->reindexRow($productId); + $indexer = $this->indexerRegistry->get(Fulltext::INDEXER_ID); + if (!$indexer->isScheduled()) { + $indexer->reindexRow($productId); } } @@ -75,8 +61,9 @@ abstract class AbstractPlugin */ protected function reindexList(array $productIds) { - if (!$this->getIndexer()->isScheduled()) { - $this->getIndexer()->reindexList($productIds); + $indexer = $this->indexerRegistry->get(Fulltext::INDEXER_ID); + if (!$indexer->isScheduled()) { + $indexer->reindexList($productIds); } } } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php index 20200e4e681..3bc0e00bf51 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php @@ -23,6 +23,8 @@ */ namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin; +use Magento\CatalogSearch\Model\Indexer\Fulltext; + class Attribute extends AbstractPlugin { /** @@ -43,7 +45,7 @@ class Attribute extends AbstractPlugin $needInvalidation = !$attribute->isObjectNew() && $attribute->dataHasChangedFor('is_searchable'); $result = $proceed($attribute); if ($needInvalidation) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); } return $result; @@ -67,7 +69,7 @@ class Attribute extends AbstractPlugin $needInvalidation = !$attribute->isObjectNew() && $attribute->getIsSearchable(); $result = $proceed($attribute); if ($needInvalidation) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); } return $result; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php index 7222e6826f5..51cd5afed01 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php @@ -24,6 +24,7 @@ namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Store; use Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\AbstractPlugin; +use Magento\CatalogSearch\Model\Indexer\Fulltext; class Group extends AbstractPlugin { @@ -45,7 +46,7 @@ class Group extends AbstractPlugin $needInvalidation = !$group->isObjectNew() && $group->dataHasChangedFor('website_id'); $result = $proceed($group); if ($needInvalidation) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); } return $result; @@ -64,8 +65,7 @@ class Group extends AbstractPlugin \Magento\Store\Model\Resource\Group $subject, \Magento\Store\Model\Resource\Group $result ) { - $this->getIndexer()->invalidate(); - + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); return $result; } } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php index 6757ba73a85..7c7eca701a7 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php @@ -24,6 +24,7 @@ namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Store; use Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\AbstractPlugin; +use Magento\CatalogSearch\Model\Indexer\Fulltext; class View extends AbstractPlugin { @@ -45,9 +46,8 @@ class View extends AbstractPlugin $needInvalidation = $store->isObjectNew(); $result = $proceed($store); if ($needInvalidation) { - $this->getIndexer()->invalidate(); + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); } - return $result; } @@ -64,8 +64,7 @@ class View extends AbstractPlugin \Magento\Store\Model\Resource\Store $subject, \Magento\Store\Model\Resource\Store $result ) { - $this->getIndexer()->invalidate(); - + $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate(); return $result; } } diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index f5caacd0978..be48aeb8f50 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-search": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-indexer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-search": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index 52a3239ecf4..b3710d4628e 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -66,11 +66,6 @@ <type name="Magento\Catalog\Model\Resource\Attribute"> <plugin name="catalogsearchFulltextIndexerAttribute" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Attribute"/> </type> - <type name="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\AbstractPlugin"> - <arguments> - <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> diff --git a/app/code/Magento/CatalogUrlRewrite/composer.json b/app/code/Magento/CatalogUrlRewrite/composer.json index 3333a8d3f81..1a9acf737b4 100644 --- a/app/code/Magento/CatalogUrlRewrite/composer.json +++ b/app/code/Magento/CatalogUrlRewrite/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-catalog-import-export": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-import-export": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/module-url-rewrite": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-catalog-import-export": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/module-url-rewrite": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/composer.json b/app/code/Magento/Centinel/composer.json index d5b7d880aa0..ed2ea7642a2 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-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Centinel/etc/module.xml b/app/code/Magento/Centinel/etc/module.xml index 6a55692bb70..6c4062ae0fc 100644 --- a/app/code/Magento/Centinel/etc/module.xml +++ b/app/code/Magento/Centinel/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Centinel" schema_version="1.6.0.0" active="true"> + <module name="Magento_Centinel" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Payment"/> <module name="Magento_Checkout"/> diff --git a/app/code/Magento/Checkout/Model/Resource/Cart.php b/app/code/Magento/Checkout/Model/Resource/Cart.php index 0f7e22bafe4..fc62f303dbf 100644 --- a/app/code/Magento/Checkout/Model/Resource/Cart.php +++ b/app/code/Magento/Checkout/Model/Resource/Cart.php @@ -37,7 +37,7 @@ class Cart extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _construct() { - $this->_init('sales_flat_quote', 'entity_id'); + $this->_init('sales_quote', 'entity_id'); } /** @@ -50,7 +50,7 @@ class Cart extends \Magento\Framework\Model\Resource\Db\AbstractDb { $read = $this->_getReadAdapter(); $select = $read->select()->from( - array('q' => $this->getTable('sales_flat_quote')), + array('q' => $this->getTable('sales_quote')), array('items_qty', 'items_count') )->where( 'q.entity_id = :quote_id' @@ -70,7 +70,7 @@ class Cart extends \Magento\Framework\Model\Resource\Db\AbstractDb { $read = $this->_getReadAdapter(); $select = $read->select()->from( - array('qi' => $this->getTable('sales_flat_quote_item')), + array('qi' => $this->getTable('sales_quote_item')), array('id' => 'item_id', 'product_id', 'super_product_id', 'qty', 'created_at') )->where( 'qi.quote_id = :quote_id' @@ -90,7 +90,7 @@ class Cart extends \Magento\Framework\Model\Resource\Db\AbstractDb { $adapter = $this->_getReadAdapter(); $exclusionSelect = $adapter->select()->from( - $this->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), array('product_id') )->where( 'quote_id = ?', diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 8ffe5fbcac0..2e0fef9d013 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -480,7 +480,7 @@ class Onepage } } - $address->save(); + $this->getQuote()->save(); $this->getCheckout()->setStepData( 'billing', @@ -700,11 +700,6 @@ class Onepage } $quote = $this->getQuote(); - // shipping totals may be affected by payment method - if (!$quote->isVirtual() && $quote->getShippingAddress()) { - $quote->getShippingAddress()->setCollectShippingRates(true); - } - $data['checks'] = array( \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT, \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY, @@ -810,7 +805,8 @@ class Onepage $billing->setCustomerAddressData($customerBillingData); $dataArray = $this->_objectCopyService->getDataFromFieldset('checkout_onepage_quote', 'to_customer', $quote); - $customerData = $this->_customerBuilder->mergeDataObjectWithArray($customerData, $dataArray); + $customerData = $this->_customerBuilder->mergeDataObjectWithArray($customerData, $dataArray) + ->create(); $quote->setCustomerData($customerData)->setCustomerId(true); // TODO : Eventually need to remove this legacy hack // Add billing address to quote since customer Data Object does not hold address information diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php index 59fe4b3af21..8e1305904c5 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/AddressBuilder.php @@ -27,7 +27,7 @@ use Magento\Checkout\Service\V1\Data\Cart\Address\Region; use Magento\Checkout\Service\V1\Data\Cart\Address\RegionBuilder; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * Quote address data object builder @@ -45,13 +45,13 @@ class AddressBuilder extends ExtensibleObjectBuilder /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param CustomerMetadataServiceInterface $metadataService * @param RegionBuilder $regionBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, CustomerMetadataServiceInterface $metadataService, RegionBuilder $regionBuilder ) { diff --git a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php b/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php index 9f7c98cf7f4..597442d7a1b 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php +++ b/app/code/Magento/Checkout/Service/V1/Data/Cart/Totals/Item.php @@ -28,7 +28,7 @@ namespace Magento\Checkout\Service\V1\Data\Cart\Totals; * * @codeCoverageIgnore */ -class Item extends \Magento\Framework\Api\AbstractSimpleObject +class Item extends \Magento\Framework\Api\AbstractExtensibleObject { /** * Price. diff --git a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php index 31005a60fa8..60e9f6adb8f 100644 --- a/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php +++ b/app/code/Magento/Checkout/Service/V1/Data/CartSearchResultsBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Checkout\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\AbstractSearchResultsBuilder; @@ -38,14 +38,14 @@ class CartSearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param CartBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, CartBuilder $itemObjectBuilder diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 01939494ff4..2473c609a80 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-authorization": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-gift-message": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-msrp": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-authorization": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-gift-message": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-msrp": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index 555ebf8e905..ba788947106 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-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php b/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php index 36b0da9c589..7ea1db86383 100644 --- a/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php +++ b/app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php @@ -35,7 +35,7 @@ class Actions implements RowInterface /** * Url path */ - const URL_PATH = 'cms/page/edit'; + const URL_PATH = '*/*/edit'; /** * @var UrlBuilder diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 14df5fea779..e6ef44c0fc6 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-email": "0.1.0-alpha103", - "magento/module-ui": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-email": "0.1.0-alpha104", + "magento/module-ui": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml b/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml index 274227dfd4a..b55a731a872 100644 --- a/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml +++ b/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml @@ -23,15 +23,11 @@ * @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="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <body> - <remove name="footer"/> - <remove name="left"/> - <referenceContainer name="content"> - <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content" name="wysiwyg_images.content" template="browser/content.phtml"> - <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Tree" name="wysiwyg_images.tree" template="browser/tree.phtml"/> - <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Uploader" name="wysiwyg_images.uploader" template="Magento_Cms::browser/content/uploader.phtml"/> - </block> - </referenceContainer> - </body> -</page> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd"> + <container name="root"> + <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content" name="wysiwyg_images.content" template="browser/content.phtml"> + <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Tree" name="wysiwyg_images.tree" template="browser/tree.phtml"/> + <block class="Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Uploader" name="wysiwyg_images.uploader" template="Magento_Cms::browser/content/uploader.phtml"/> + </block> + </container> +</layout> diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 7e9b6101b4f..35b70668be0 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-url-rewrite": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-url-rewrite": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json index 40df384e749..619a8ec5fc7 100644 --- a/app/code/Magento/ConfigurableImportExport/composer.json +++ b/app/code/Magento/ConfigurableImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-catalog-import-export": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-import-export": "0.1.0-alpha103", - "magento/module-configurable-product": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-catalog-import-export": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/module-configurable-product": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 1a43a63ebcb..8e10f701a52 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-catalog-rule": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-webapi": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-catalog-rule": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-webapi": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index ea086566758..44d38f24d3a 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-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index b32e8bdd5a9..9ade2b568ac 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-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index b5784bd3d38..48bc7997903 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-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index 3477e2ed64c..00be91ba472 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-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/Api/AccountManagementInterface.php b/app/code/Magento/Customer/Api/AccountManagementInterface.php index b32cb52ab15..552320ac5b5 100644 --- a/app/code/Magento/Customer/Api/AccountManagementInterface.php +++ b/app/code/Magento/Customer/Api/AccountManagementInterface.php @@ -185,6 +185,27 @@ interface AccountManagementInterface * @param int $customerWebsiteId * @param int $storeId * @return bool + * @throws \Magento\Framework\Exception\LocalizedException */ public function isCustomerInStore($customerWebsiteId, $storeId); + + /** + * Retrieve default billing address for the given customerId. + * + * @param int $customerId + * @return \Magento\Customer\Api\Data\AddressInterface|null + * @throws \Magento\Framework\Exception\NoSuchEntityException If the customer Id is invalid + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function getDefaultBillingAddress($customerId); + + /** + * Retrieve default shipping address for the given customerId. + * + * @param int $customerId + * @return \Magento\Customer\Api\Data\AddressInterface|null + * @throws \Magento\Framework\Exception\NoSuchEntityException If the customer Id is invalid + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function getDefaultShippingAddress($customerId); } diff --git a/app/code/Magento/Customer/Api/Data/AddressInterface.php b/app/code/Magento/Customer/Api/Data/AddressInterface.php index 3e616dd30f4..5452be10a56 100644 --- a/app/code/Magento/Customer/Api/Data/AddressInterface.php +++ b/app/code/Magento/Customer/Api/Data/AddressInterface.php @@ -51,6 +51,8 @@ interface AddressInterface extends ExtensibleDataInterface const PREFIX = 'prefix'; const SUFFIX = 'suffix'; const VAT_ID = 'vat_id'; + const DEFAULT_BILLING = 'default_billing'; + const DEFAULT_SHIPPING = 'default_shipping'; /**#@-*/ /** @@ -164,4 +166,18 @@ interface AddressInterface extends ExtensibleDataInterface * @return string|null */ public function getVatId(); + + /** + * Get if this address is default shipping address. + * + * @return bool|null + */ + public function isDefaultShipping(); + + /** + * Get if this address is default billing address + * + * @return bool|null + */ + public function isDefaultBilling(); } diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index ca9b2e6d75f..c463113e651 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -146,7 +146,8 @@ class Edit extends \Magento\Directory\Block\Data 'region' => $postedData['region'] ); } - $this->_address = $this->_addressBuilder->mergeDataObjectWithArray($this->_address, $postedData); + $this->_address = $this->_addressBuilder->mergeDataObjectWithArray($this->_address, $postedData) + ->create(); } return $this; diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index df78e2f6ddc..efab0d71cfd 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -73,7 +73,8 @@ class Edit extends \Magento\Customer\Controller\Account $customerId = $this->_getSession()->getCustomerId(); $customerDataObject = $this->customerAccountService->getCustomer($customerId); if (!empty($data)) { - $customerDataObject = $this->customerBuilder->mergeDataObjectWithArray($customerDataObject, $data); + $customerDataObject = $this->customerBuilder->mergeDataObjectWithArray($customerDataObject, $data) + ->create(); } $this->_getSession()->setCustomerData($customerDataObject); $this->_getSession()->setChangePassword($this->getRequest()->getParam('changepass') == 1); diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 8b68db91148..73246c71179 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -74,6 +74,8 @@ class FormPost extends \Magento\Customer\Controller\Address ->populateWithArray(array_merge($existingAddressData, $attributeValues)) ->setCustomerId($this->_getSession()->getCustomerId()) ->setRegion($region) + ->setDefaultBilling($this->getRequest()->getParam('default_billing', false)) + ->setDefaultShipping($this->getRequest()->getParam('default_shipping', false)) ->create(); } diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index ea1bbc19ff2..b2d54213fa6 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -32,7 +32,6 @@ use Magento\Customer\Helper\Data as CustomerDataHelper; use Magento\Customer\Model\Config\Share as ConfigShare; use Magento\Customer\Model\Customer as CustomerModel; use Magento\Customer\Model\CustomerFactory; -use Magento\Customer\Model\CustomerRegistry; use Magento\Customer\Model\Metadata\Validator; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -54,6 +53,7 @@ use Magento\Framework\Stdlib\String as StringHelper; use Magento\Framework\StoreManagerInterface; use Magento\Framework\UrlInterface; use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\Customer\Api\Data\AddressInterface; /** * Handle various customer account actions @@ -542,6 +542,24 @@ class AccountManagement implements AccountManagementInterface return $customer; } + /** + * {@inheritdoc} + */ + public function getDefaultBillingAddress($customerId) + { + $customer = $this->customerRepository->getById($customerId); + return $this->getAddressById($customer, $customer->getDefaultBilling()); + } + + /** + * {@inheritdoc} + */ + public function getDefaultShippingAddress($customerId) + { + $customer = $this->customerRepository->getById($customerId); + return $this->getAddressById($customer, $customer->getDefaultShipping()); + } + /** * Send either confirmation or welcome email after an account creation * @@ -750,7 +768,6 @@ class AccountManagement implements AccountManagementInterface return $customer->getDeleteable(); } - /** * Send email with new account related information * @@ -795,10 +812,12 @@ class AccountManagement implements AccountManagementInterface } /** + * Send email to customer when his password is reset + * * @param CustomerInterface $customer * @return $this */ - public function sendPasswordResetNotificationEmail($customer) + protected function sendPasswordResetNotificationEmail($customer) { $storeId = $customer->getStoreId(); if (!$storeId) { @@ -1084,6 +1103,23 @@ class AccountManagement implements AccountManagementInterface return $this; } + /** + * Get address by id + * + * @param CustomerInterface $customer + * @param int $addressId + * @return AddressInterface|null + */ + protected function getAddressById(CustomerInterface $customer, $addressId) + { + foreach ($customer->getAddresses() as $address) { + if ($address->getId() == $addressId) { + return $address; + } + } + return null; + } + /** * Create an object with data merged from Customer and CustomerSecure * diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index 9545c1ee834..0ec83e7eb9e 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -153,6 +153,10 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress $this->setDataUsingMethod($attributeCode, $attributeData); } } + // Need to explicitly set this due to discrepancy in the keys between model and data object + $this->setIsDefaultBilling($address->isDefaultBilling()); + $this->setIsDefaultShipping($address->isDefaultShipping()); + // Need to use attribute set or future updates can cause data loss if (!$this->getAttributeSetId()) { $this->setAttributeSetId(AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS); diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php index ca1553922e8..26402bb2a8b 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php @@ -43,13 +43,11 @@ class Password extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke protected $string; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\String $string */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\String $string) + public function __construct(\Magento\Framework\Stdlib\String $string) { $this->string = $string; - parent::__construct($logger); } /** 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 da9753ef73e..83494dac28c 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Store.php @@ -36,13 +36,11 @@ class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend protected $_storeManager; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) + public function __construct(\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 c8c99a5f958..5e7f4741ea8 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Website.php @@ -36,13 +36,11 @@ class Website extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken protected $_storeManager; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Customer/Model/Data/Address.php b/app/code/Magento/Customer/Model/Data/Address.php index e9f5ebbe54b..5bff296dbc3 100644 --- a/app/code/Magento/Customer/Model/Data/Address.php +++ b/app/code/Magento/Customer/Model/Data/Address.php @@ -187,4 +187,24 @@ class Address extends \Magento\Framework\Api\AbstractExtensibleObject implements { return $this->_get(self::CUSTOMER_ID); } + + /** + * Get if this address is default shipping address. + * + * @return bool|null + */ + public function isDefaultShipping() + { + return $this->_get(self::DEFAULT_SHIPPING); + } + + /** + * Get if this address is default billing address + * + * @return bool|null + */ + public function isDefaultBilling() + { + return $this->_get(self::DEFAULT_BILLING); + } } diff --git a/app/code/Magento/Customer/Model/Data/CustomerBuilder.php b/app/code/Magento/Customer/Model/Data/CustomerBuilder.php index 763a05b8288..0b4a91ba193 100644 --- a/app/code/Magento/Customer/Model/Data/CustomerBuilder.php +++ b/app/code/Magento/Customer/Model/Data/CustomerBuilder.php @@ -26,7 +26,7 @@ namespace Magento\Customer\Model\Data; use Magento\Framework\Api\AbstractExtensibleObject as ExtensibleObject; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; /** @@ -40,12 +40,12 @@ class CustomerBuilder extends ExtensibleObjectBuilder { /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param CustomerMetadataServiceInterface $metadataService */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, CustomerMetadataServiceInterface $metadataService ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); diff --git a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php index 799eb75a951..41ee039c924 100644 --- a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php +++ b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php @@ -41,9 +41,9 @@ class DepersonalizePlugin protected $customerSession; /** - * @var \Magento\Customer\Model\Customer + * @var \Magento\Customer\Model\CustomerFactory */ - protected $customer; + protected $customerFactory; /** * @var \Magento\Framework\App\RequestInterface @@ -95,7 +95,7 @@ class DepersonalizePlugin ) { $this->session = $session; $this->customerSession = $customerSession; - $this->customer = $customerFactory->create(); + $this->customerFactory = $customerFactory; $this->request = $request; $this->moduleManager = $moduleManager; $this->visitor = $visitor; @@ -140,8 +140,7 @@ class DepersonalizePlugin $this->customerSession->clearStorage(); $this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey); $this->customerSession->setCustomerGroupId($this->customerGroupId); - $this->customer->setGroupId($this->customerGroupId); - $this->customerSession->setCustomer($this->customer); + $this->customerSession->setCustomer($this->customerFactory->create()->setGroupId($this->customerGroupId)); } return $result; } diff --git a/app/code/Magento/Customer/Model/Resource/Address/Attribute/Backend/Region.php b/app/code/Magento/Customer/Model/Resource/Address/Attribute/Backend/Region.php index ae46d205a31..51456c5c874 100644 --- a/app/code/Magento/Customer/Model/Resource/Address/Attribute/Backend/Region.php +++ b/app/code/Magento/Customer/Model/Resource/Address/Attribute/Backend/Region.php @@ -36,13 +36,11 @@ class Region extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend protected $_regionFactory; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\RegionFactory $regionFactory */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Directory\Model\RegionFactory $regionFactory) + public function __construct(\Magento\Directory\Model\RegionFactory $regionFactory) { $this->_regionFactory = $regionFactory; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Customer/Model/Resource/AddressRepository.php b/app/code/Magento/Customer/Model/Resource/AddressRepository.php index 6d3fbec6018..76ba7615d26 100644 --- a/app/code/Magento/Customer/Model/Resource/AddressRepository.php +++ b/app/code/Magento/Customer/Model/Resource/AddressRepository.php @@ -126,6 +126,9 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf throw $inputException; } $this->addressResource->save($addressModel); + // Clean up the customer registry since the Address save has a + // side effect on customer : \Magento\Customer\Model\Resource\Address::_afterSave + $this->customerRegistry->remove($address->getCustomerId()); $this->addressRegistry->push($addressModel); $customerModel->getAddressesCollection()->clear(); diff --git a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php index f6af8b15aeb..abace9e1e65 100644 --- a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php @@ -142,7 +142,6 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte */ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $passwordHash = null) { - $isNewCustomer = $customer->getId() ? false : true; $this->validate($customer); $customerModel = $this->customerFactory->create( [ diff --git a/app/code/Magento/Customer/Service/V1/Data/AddressBuilder.php b/app/code/Magento/Customer/Service/V1/Data/AddressBuilder.php index 5c47d7ea441..a245af9aaa7 100644 --- a/app/code/Magento/Customer/Service/V1/Data/AddressBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/AddressBuilder.php @@ -27,7 +27,7 @@ namespace Magento\Customer\Service\V1\Data; use Magento\Customer\Service\V1\AddressMetadataServiceInterface; use Magento\Framework\Api\AbstractExtensibleObject as ExtensibleObject; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * Builder for the Address Service Data Object @@ -47,13 +47,13 @@ class AddressBuilder extends ExtensibleObjectBuilder /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param AddressMetadataServiceInterface $metadataService * @param RegionBuilder $regionBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, AddressMetadataServiceInterface $metadataService, RegionBuilder $regionBuilder ) { diff --git a/app/code/Magento/Customer/Service/V1/Data/CustomerBuilder.php b/app/code/Magento/Customer/Service/V1/Data/CustomerBuilder.php index 9940cee0230..7b1a36ea612 100644 --- a/app/code/Magento/Customer/Service/V1/Data/CustomerBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerBuilder.php @@ -26,26 +26,26 @@ namespace Magento\Customer\Service\V1\Data; use Magento\Framework\Api\AbstractExtensibleObject as ExtensibleObject; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; /** * Builder for the Customer Service Data Object * * @method Customer create() - * @method Customer mergeDataObjectWithArray(ExtensibleObject $dataObject, array $data) - * @method Customer mergeDataObjects(ExtensibleObject $firstDataObject, ExtensibleObject $secondDataObject) + * @method CustomerBuilder mergeDataObjectWithArray(ExtensibleObject $dataObject, array $data) + * @method CustomerBuilder mergeDataObjects(ExtensibleObject $firstDataObject, ExtensibleObject $secondDataObject) */ class CustomerBuilder extends ExtensibleObjectBuilder { /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param CustomerMetadataServiceInterface $metadataService */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, CustomerMetadataServiceInterface $metadataService ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); diff --git a/app/code/Magento/Customer/Service/V1/Data/CustomerDetailsBuilder.php b/app/code/Magento/Customer/Service/V1/Data/CustomerDetailsBuilder.php index 0db5a295091..4944bafcc8b 100644 --- a/app/code/Magento/Customer/Service/V1/Data/CustomerDetailsBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerDetailsBuilder.php @@ -26,7 +26,7 @@ namespace Magento\Customer\Service\V1\Data; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -50,14 +50,14 @@ class CustomerDetailsBuilder extends ExtensibleObjectBuilder /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param CustomerBuilder $customerBuilder * @param AddressBuilder $addressBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, \Magento\Customer\Service\V1\Data\AddressBuilder $addressBuilder diff --git a/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php index 7234903af3d..225512bf1c2 100644 --- a/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/CustomerGroupSearchResultsBuilder.php @@ -27,7 +27,7 @@ namespace Magento\Customer\Service\V1\Data; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\AbstractSearchResultsBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -41,14 +41,14 @@ class CustomerGroupSearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param CustomerDetailsBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, CustomerDetailsBuilder $itemObjectBuilder diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php index afeddb6b0b7..cdfb02dc0cf 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php @@ -25,7 +25,7 @@ namespace Magento\Customer\Service\V1\Data\Eav; use Magento\Framework\Api\AttributeMetadataBuilderInterface; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -49,14 +49,14 @@ class AttributeMetadataBuilder extends ExtensibleObjectBuilder implements Attrib /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param OptionBuilder $optionBuilder * @param ValidationRuleBuilder $validationRuleBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Customer\Service\V1\Data\Eav\OptionBuilder $optionBuilder, \Magento\Customer\Service\V1\Data\Eav\ValidationRuleBuilder $validationRuleBuilder diff --git a/app/code/Magento/Customer/Service/V1/Data/SearchResultsBuilder.php b/app/code/Magento/Customer/Service/V1/Data/SearchResultsBuilder.php index e93bd781654..4f7bb8b9839 100644 --- a/app/code/Magento/Customer/Service/V1/Data/SearchResultsBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/SearchResultsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Customer\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -42,14 +42,14 @@ class SearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param CustomerDetailsBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, CustomerDetailsBuilder $itemObjectBuilder diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 070aa360137..48076370811 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -3,27 +3,27 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-newsletter": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-review": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-authorization": "0.1.0-alpha103", - "magento/module-integration": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-newsletter": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-review": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-authorization": "0.1.0-alpha104", + "magento/module-integration": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index e8e2e10559f..c9bcffc7b89 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -72,6 +72,8 @@ <argument name="customerData" xsi:type="object">Magento\Customer\Helper\Data\Proxy</argument> <argument name="customerResource" xsi:type="object">Magento\Customer\Model\Resource\Customer\Proxy</argument> <argument name="storage" xsi:type="object">Magento\Customer\Model\Session\Storage</argument> + <argument name="converter" xsi:type="object">Magento\Customer\Model\Converter\Proxy</argument> + <argument name="customerAccountService" xsi:type="object">Magento\Customer\Service\V1\CustomerAccountServiceInterface\Proxy</argument> </arguments> </type> <type name="Magento\Framework\Module\Updater\SetupFactory"> @@ -104,9 +106,14 @@ <type name="Magento\Customer\Model\Customer"> <arguments> <argument name="customerData" xsi:type="object">Magento\Customer\Helper\Data\Proxy</argument> + <argument name="groupService" xsi:type="object">Magento\Customer\Service\V1\CustomerGroupServiceInterface\Proxy</argument> + </arguments> + </type> + <type name="Magento\Customer\Helper\Data"> + <arguments> + <argument name="groupService" xsi:type="object">Magento\Customer\Service\V1\CustomerGroupServiceInterface\Proxy</argument> </arguments> </type> - <type name="Magento\Customer\Model\Data\GroupBuilder" shared="false" /> <type name="Magento\Customer\Service\V1\Data\CustomerGroupBuilder" shared="false" /> <type name="Magento\Customer\Service\V1\Data\Eav\AttributeMetadataBuilder" shared="false" /> <type name="Magento\Customer\Api\Data\OptionDataBuilder" shared="false" /> @@ -126,6 +133,7 @@ <type name="Magento\Customer\Service\V1\CustomerAccountService"> <arguments> <argument name="url" xsi:type="object">Magento\Framework\Url</argument> + <argument name="converter" xsi:type="object">Magento\Customer\Model\Converter\Proxy</argument> </arguments> </type> <virtualType name="Magento\Customer\Service\Config\CustomerMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> diff --git a/app/code/Magento/CustomerImportExport/composer.json b/app/code/Magento/CustomerImportExport/composer.json index dcf167156e5..b107d8d9b56 100644 --- a/app/code/Magento/CustomerImportExport/composer.json +++ b/app/code/Magento/CustomerImportExport/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-import-export": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/DesignEditor/composer.json b/app/code/Magento/DesignEditor/composer.json index e08dbfe35a4..6283b4dc180 100644 --- a/app/code/Magento/DesignEditor/composer.json +++ b/app/code/Magento/DesignEditor/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index b1c92467670..61bec06052b 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-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Dhl/data/dhl_setup/data-install-2.0.0.0.php b/app/code/Magento/Dhl/data/dhl_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/Dhl/data/dhl_setup/data-install-2.0.0.0.php rename to app/code/Magento/Dhl/data/dhl_setup/data-install-2.0.0.php diff --git a/app/code/Magento/Dhl/etc/module.xml b/app/code/Magento/Dhl/etc/module.xml index a0e44e80765..bbdea658e89 100644 --- a/app/code/Magento/Dhl/etc/module.xml +++ b/app/code/Magento/Dhl/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Dhl" schema_version="2.0.0.0" active="true"> + <module name="Magento_Dhl" schema_version="2.0.0" active="true"> <depends> <module name="Magento_Store"/> <module name="Magento_Shipping"/> diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index fc660b3e373..33cb21f8470 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/Model/Observer.php b/app/code/Magento/Downloadable/Model/Observer.php index 4de1abcc23d..9ba58b5808d 100644 --- a/app/code/Magento/Downloadable/Model/Observer.php +++ b/app/code/Magento/Downloadable/Model/Observer.php @@ -23,6 +23,8 @@ */ namespace Magento\Downloadable\Model; +use Magento\Store\Model\ScopeInterface; + /** * Downloadable Products Observer * @@ -171,7 +173,7 @@ class Observer ->_scopeConfig ->getValue( \Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); $linkPurchased->setLinkSectionTitle($linkSectionTitle)->save(); foreach ($linkIds as $linkId) { @@ -269,7 +271,7 @@ class Observer $downloadableItemsStatuses = array(); $orderItemStatusToEnable = $this->_scopeConfig->getValue( \Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + ScopeInterface::SCOPE_STORE, $order->getStoreId() ); @@ -355,31 +357,31 @@ class Observer */ public function isAllowedGuestCheckout(\Magento\Framework\Event\Observer $observer) { - $quote = $observer->getEvent()->getQuote(); - /* @var $quote \Magento\Sales\Model\Quote */ $store = $observer->getEvent()->getStore(); $result = $observer->getEvent()->getResult(); - $isContain = false; + $result->setIsAllowed(true); + + if (!$this->_scopeConfig->isSetFlag( + self::XML_PATH_DISABLE_GUEST_CHECKOUT, + ScopeInterface::SCOPE_STORE, + $store + )) { + return $this; + } + + /* @var $quote \Magento\Sales\Model\Quote */ + $quote = $observer->getEvent()->getQuote(); foreach ($quote->getAllItems() as $item) { if (($product = $item->getProduct()) && $product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE ) { - $isContain = true; + $result->setIsAllowed(false); + break; } } - if ($isContain - && $this->_scopeConfig->isSetFlag( - self::XML_PATH_DISABLE_GUEST_CHECKOUT, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $store - ) - ) { - $result->setIsAllowed(false); - } - return $this; } diff --git a/app/code/Magento/Downloadable/composer.json b/app/code/Magento/Downloadable/composer.json index 54b051f3ba5..6ece1ac9540 100644 --- a/app/code/Magento/Downloadable/composer.json +++ b/app/code/Magento/Downloadable/composer.json @@ -3,26 +3,26 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-gift-message": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-msrp": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-gift-message": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-msrp": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Downloadable/sql/downloadable_setup/install-1.6.0.0.php b/app/code/Magento/Downloadable/sql/downloadable_setup/install-1.6.0.0.php index 8f222735004..f9156743622 100644 --- a/app/code/Magento/Downloadable/sql/downloadable_setup/install-1.6.0.0.php +++ b/app/code/Magento/Downloadable/sql/downloadable_setup/install-1.6.0.0.php @@ -249,9 +249,9 @@ $table = $installer->getConnection()->newTable( \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('downloadable_link_purchased', 'order_id', 'sales_flat_order', 'entity_id'), + $installer->getFkName('downloadable_link_purchased', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $installer->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE @@ -383,9 +383,9 @@ $table = $installer->getConnection()->newTable( \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('downloadable_link_purchased_item', 'order_item_id', 'sales_flat_order_item', 'item_id'), + $installer->getFkName('downloadable_link_purchased_item', 'order_item_id', 'sales_order_item', 'item_id'), 'order_item_id', - $installer->getTable('sales_flat_order_item'), + $installer->getTable('sales_order_item'), 'item_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index e1683939f90..c76dedfa247 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -27,16 +27,20 @@ use Magento\Eav\Model\Entity\Type; class Config { + /**#@+ + * EAV cache ids + */ const ENTITIES_CACHE_ID = 'EAV_ENTITY_TYPES'; - const ATTRIBUTES_CACHE_ID = 'EAV_ENTITY_ATTRIBUTES'; + const ATTRIBUTES_CODES_CACHE_ID = 'EAV_ENTITY_ATTRIBUTES_CODES'; + /**#@-*/ /** * Entity types data * * @var array */ - protected $_entityData; + protected $_entityTypeData; /** * Attributes data @@ -45,26 +49,12 @@ class Config */ protected $_attributeData; - /** - * Information about preloaded attributes - * - * @var array - */ - protected $_preloadedAttributes = array(); - - /** - * Information about entity types with initialized attributes - * - * @var array - */ - protected $_initializedAttributes = array(); - /** * Attribute codes cache array * * @var array */ - protected $_attributeCodes = array(); + protected $_attributeCodes; /** * Initialized objects @@ -106,11 +96,19 @@ class Config */ protected $_cache; + /** @var \Magento\Framework\App\Cache\StateInterface */ + protected $_cacheState; + /** * @var \Magento\Eav\Model\Entity\TypeFactory */ protected $_entityTypeFactory; + /** + * @var \Magento\Eav\Model\Resource\Entity\Type\CollectionFactory + */ + protected $entityTypeCollectionFactory; + /** * @var \Magento\Framework\Validator\UniversalFactory */ @@ -118,18 +116,21 @@ class Config /** * @param \Magento\Framework\App\CacheInterface $cache - * @param Entity\TypeFactory $entityTypeFactory + * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory + * @param \Magento\Eav\Model\Resource\Entity\Type\CollectionFactory $entityTypeCollectionFactory * @param \Magento\Framework\App\Cache\StateInterface $cacheState * @param \Magento\Framework\Validator\UniversalFactory $universalFactory */ public function __construct( \Magento\Framework\App\CacheInterface $cache, \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory, + \Magento\Eav\Model\Resource\Entity\Type\CollectionFactory $entityTypeCollectionFactory, \Magento\Framework\App\Cache\StateInterface $cacheState, \Magento\Framework\Validator\UniversalFactory $universalFactory ) { $this->_cache = $cache; $this->_entityTypeFactory = $entityTypeFactory; + $this->entityTypeCollectionFactory = $entityTypeCollectionFactory; $this->_cacheState = $cacheState; $this->_universalFactory = $universalFactory; } @@ -141,13 +142,17 @@ class Config */ public function clear() { - $this->_entityData = null; + $this->_entityTypeData = null; $this->_attributeData = null; $this->_objects = null; $this->_references = null; - $this->_preloadedAttributes = array(); - $this->_initializedAttributes = array(); - $this->_attributeCodes = array(); + $this->_attributeCodes = null; + $this->_cache->clean( + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ] + ); return $this; } @@ -271,17 +276,14 @@ class Config */ protected function _initEntityTypes() { - if (is_array($this->_entityData)) { + if (is_array($this->_entityTypeData)) { return $this; } \Magento\Framework\Profiler::start('EAV: ' . __METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - /** - * try load information about entity types from cache - */ if ($this->_isCacheEnabled() && ($cache = $this->_cache->load(self::ENTITIES_CACHE_ID))) { - $this->_entityData = unserialize($cache); - foreach ($this->_entityData as $typeCode => $data) { + $this->_entityTypeData = unserialize($cache); + foreach ($this->_entityTypeData as $typeCode => $data) { $typeId = $data['entity_type_id']; $this->_addEntityTypeReference($typeId, $typeCode); } @@ -289,12 +291,7 @@ class Config return $this; } - $entityTypesData = $this->_entityTypeFactory->create()->getCollection()->getData(); - $types = array(); - - /** - * prepare entity type data - */ + $entityTypesData = $this->entityTypeCollectionFactory->create()->getData(); foreach ($entityTypesData as $typeData) { if (!isset($typeData['attribute_model'])) { $typeData['attribute_model'] = 'Magento\Eav\Model\Entity\Attribute'; @@ -304,14 +301,12 @@ class Config $typeId = $typeData['entity_type_id']; $this->_addEntityTypeReference($typeId, $typeCode); - $types[$typeCode] = $typeData; + $this->_entityTypeData[$typeCode] = $typeData; } - $this->_entityData = $types; - if ($this->_isCacheEnabled()) { $this->_cache->save( - serialize($this->_entityData), + serialize($this->_entityTypeData), self::ENTITIES_CACHE_ID, array( \Magento\Eav\Model\Cache\Type::CACHE_TAG, @@ -335,6 +330,7 @@ class Config if ($code instanceof Type) { return $code; } + $this->_initEntityTypes(); \Magento\Framework\Profiler::start('EAV: ' . __METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); if (is_numeric($code)) { @@ -351,20 +347,11 @@ class Config return $entityType; } - - $entityType = $this->_entityTypeFactory->create(); - if (isset($this->_entityData[$code])) { - $entityType->setData($this->_entityData[$code]); - } else { - if (is_numeric($code)) { - $entityType->load($code); - } else { - $entityType->loadByCode($code); - } - - if (!$entityType->getId()) { - throw new \Magento\Framework\Model\Exception(__('Invalid entity_type specified: %1', $code)); - } + $entityType = $this->_entityTypeFactory->create( + ['data' => isset($this->_entityTypeData[$code]) ? $this->_entityTypeData[$code] : []] + ); + if (!$entityType->getId()) { + throw new \Magento\Framework\Model\Exception(__('Invalid entity_type specified: %1', $code)); } $this->_addEntityTypeReference($entityType->getId(), $entityType->getEntityTypeCode()); $this->_save($entityType, $entityKey); @@ -384,25 +371,46 @@ class Config $entityType = $this->getEntityType($entityType); $entityTypeCode = $entityType->getEntityTypeCode(); - if (isset($this->_initializedAttributes[$entityTypeCode])) { + if (isset($this->_attributeData[$entityTypeCode])) { return $this; } + $cacheKey = self::ATTRIBUTES_CACHE_ID . $entityTypeCode; + if ($this->_isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) { + $attributes = unserialize($attributes); + if ($attributes) { + foreach ($attributes as $attribute) { + $this->_createAttribute($entityType, $attribute); + $this->_attributeData[$entityTypeCode][$attribute['attribute_code']] = $attribute; + } + return $this; + } + } + \Magento\Framework\Profiler::start('EAV: ' . __METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); - $attributesInfo = $this->_universalFactory->create( + $attributes = $this->_universalFactory->create( $entityType->getEntityAttributeCollection() )->setEntityTypeFilter( $entityType )->getData(); - $codes = array(); - foreach ($attributesInfo as $attribute) { + foreach ($attributes as $attribute) { + if (empty($attribute['attribute_model'])) { + $attribute['attribute_model'] = $entityType->getAttributeModel(); + } $this->_createAttribute($entityType, $attribute); - $codes[] = $attribute['attribute_code']; + $this->_attributeData[$entityTypeCode][$attribute['attribute_code']] = $attribute; + } + if ($this->_isCacheEnabled()) { + $this->_cache->save( + serialize($this->_attributeData[$entityTypeCode]), + $cacheKey, + array( + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ) + ); } - - $entityType->setAttributeCodes($codes); - $this->_initializedAttributes[$entityTypeCode] = true; \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__); return $this; @@ -414,21 +422,16 @@ class Config * @param mixed $entityType * @param mixed $code * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|false + * @throws \Magento\Framework\Model\Exception */ public function getAttribute($entityType, $code) { if ($code instanceof \Magento\Eav\Model\Entity\Attribute\AttributeInterface) { return $code; } - - \Magento\Framework\Profiler::start('EAV: ' . __METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); + $this->_initAttributes($entityType); $entityTypeCode = $this->getEntityType($entityType)->getEntityTypeCode(); - $entityType = $this->getEntityType($entityType); - - /** - * Validate attribute code - */ if (is_numeric($code)) { $attributeCode = $this->_getAttributeReference($code, $entityTypeCode); if ($attributeCode) { @@ -437,39 +440,12 @@ class Config } $attributeKey = $this->_getAttributeKey($entityTypeCode, $code); - /** - * Try use loaded attribute - */ $attribute = $this->_load($attributeKey); - if ($attribute) { - \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__); - return $attribute; - } - - if (isset($this->_attributeData[$entityTypeCode][$code])) { - $data = $this->_attributeData[$entityTypeCode][$code]; - unset($this->_attributeData[$entityTypeCode][$code]); - $attribute = $this->_universalFactory->create($data['attribute_model'], array('data' => $data)); - } else { - if (is_numeric($code)) { - $attribute = $this->_universalFactory->create($entityType->getAttributeModel())->load($code); - if ($attribute->getEntityTypeId() != $entityType->getId()) { - return false; - } - $attributeKey = $this->_getAttributeKey($entityTypeCode, $attribute->getAttributeCode()); - } else { - $attribute = $this->_universalFactory->create( - $entityType->getAttributeModel() - )->loadByCode( - $entityType, - $code - )->setAttributeCode( - $code - ); - } - } - - if ($attribute) { + if (!$attribute) { + // TODO: refactor wrong method usage in: addAttributeToSelect, joinAttribute + $entityType = $this->getEntityType($entityType); + $attribute = $this->_universalFactory->create($entityType->getAttributeModel()); + $attribute->setAttributeCode($code); $entity = $entityType->getEntity(); if ($entity && in_array($attribute->getAttributeCode(), $entity->getDefaultAttributes())) { $attribute->setBackendType( @@ -478,12 +454,10 @@ class Config 1 ); } - $attribute->setEntityType($entityType)->setEntityTypeId($entityType->getId()); - $this->_addAttributeReference($attribute->getId(), $attribute->getAttributeCode(), $entityTypeCode); + $this->_addAttributeReference($code, $code, $entityTypeCode); $this->_save($attribute, $attributeKey); } \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__); - return $attribute; } @@ -498,18 +472,21 @@ class Config { $entityType = $this->getEntityType($entityType); $attributeSetId = 0; - if ($object instanceof \Magento\Framework\Object && $object->getAttributeSetId()) { - $attributeSetId = $object->getAttributeSetId(); - } $storeId = 0; - if ($object instanceof \Magento\Framework\Object && $object->getStoreId()) { - $storeId = $object->getStoreId(); + if ($object instanceof \Magento\Framework\Object) { + $attributeSetId = $object->getAttributeSetId() ?: $attributeSetId; + $storeId = $object->getStoreId() ?: $storeId; } - $cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId); + $cacheKey = self::ATTRIBUTES_CODES_CACHE_ID . $entityType->getId() . '-' . $storeId . '-' . $attributeSetId; if (isset($this->_attributeCodes[$cacheKey])) { return $this->_attributeCodes[$cacheKey]; } + if ($this->_isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) { + $this->_attributeCodes[$cacheKey] = unserialize($attributes); + return $this->_attributeCodes[$cacheKey]; + } + if ($attributeSetId) { $attributesInfo = $this->_universalFactory->create( $entityType->getEntityAttributeCollection() @@ -527,81 +504,22 @@ class Config } } else { $this->_initAttributes($entityType); - $attributes = $this->getEntityType($entityType)->getAttributeCodes(); + $attributes = array_keys($this->_attributeData[$entityType->getEntityTypeCode()]); } $this->_attributeCodes[$cacheKey] = $attributes; - - return $attributes; - } - - /** - * Preload entity type attributes for performance optimization - * - * @param mixed $entityType - * @param mixed $attributes - * @return $this - */ - public function preloadAttributes($entityType, $attributes) - { - if (is_string($attributes)) { - $attributes = array($attributes); - } - - $entityType = $this->getEntityType($entityType); - $entityTypeCode = $entityType->getEntityTypeCode(); - - if (!isset($this->_preloadedAttributes[$entityTypeCode])) { - $this->_preloadedAttributes[$entityTypeCode] = $attributes; - } else { - $attributes = array_diff($attributes, $this->_preloadedAttributes[$entityTypeCode]); - $this->_preloadedAttributes[$entityTypeCode] = array_merge( - $this->_preloadedAttributes[$entityTypeCode], - $attributes + if ($this->_isCacheEnabled()) { + $this->_cache->save( + serialize($attributes), + $cacheKey, + array( + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ) ); } - if (empty($attributes)) { - return $this; - } - \Magento\Framework\Profiler::start( - 'EAV: ' . __METHOD__ . ':' . $entityTypeCode, - array('group' => 'EAV', 'method' => __METHOD__, 'entity_type_code' => $entityTypeCode) - ); - - $attributesInfo = $this->_universalFactory->create( - $entityType->getEntityAttributeCollection() - )->setEntityTypeFilter( - $entityType - )->setCodeFilter( - $attributes - )->getData(); - - if (!$attributesInfo) { - \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__ . ':' . $entityTypeCode); - return $this; - } - - $attributesData = $codes = array(); - - foreach ($attributesInfo as $attribute) { - if (empty($attribute['attribute_model'])) { - $attribute['attribute_model'] = $entityType->getAttributeModel(); - } - - $attributeCode = $attribute['attribute_code']; - $attributeId = $attribute['attribute_id']; - - $this->_addAttributeReference($attributeId, $attributeCode, $entityTypeCode); - $attributesData[$attributeCode] = $attribute; - $codes[] = $attributeCode; - } - - $this->_attributeData[$entityTypeCode] = $attributesData; - - \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__ . ':' . $entityTypeCode); - - return $this; + return $attributes; } /** diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php index 373add3c046..2da0776686e 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php @@ -70,19 +70,6 @@ abstract class AbstractBackend implements \Magento\Eav\Model\Entity\Attribute\Ba */ protected $_defaultValue = null; - /** - * @var \Magento\Framework\Logger - */ - protected $_logger; - - /** - * @param \Magento\Framework\Logger $logger - */ - public function __construct(\Magento\Framework\Logger $logger) - { - $this->_logger = $logger; - } - /** * Set attribute instance * diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php index bf9115d096a..39d8abdca16 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php @@ -33,13 +33,11 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke protected $_localeDate; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate) + public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate) { $this->_localeDate = $localeDate; - parent::__construct($logger); } /** 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 a51cf76e66b..e3438a88897 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php @@ -31,13 +31,11 @@ class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend protected $_storeManager; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\StoreManagerInterface $storeManager) + public function __construct(\Magento\Framework\StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php index 310350b2f88..dc2af1bd314 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php @@ -34,13 +34,11 @@ class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken protected $dateTime; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\DateTime $dateTime */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\DateTime $dateTime) + public function __construct(\Magento\Framework\Stdlib\DateTime $dateTime) { $this->dateTime = $dateTime; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php index 78c10c7d76c..28227e75c34 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php @@ -34,13 +34,11 @@ class Updated extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken protected $dateTime; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Stdlib\DateTime $dateTime */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Framework\Stdlib\DateTime $dateTime) + public function __construct(\Magento\Framework\Stdlib\DateTime $dateTime) { $this->dateTime = $dateTime; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index cd9038f4bd4..9218849a134 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -357,16 +357,6 @@ class Type extends \Magento\Framework\Model\AbstractModel return isset($this->_data['entity_type_code']) ? $this->_data['entity_type_code'] : null; } - /** - * Retrieve attribute codes - * - * @return array|null - */ - public function getAttributeCodes() - { - return isset($this->_data['attribute_codes']) ? $this->_data['attribute_codes'] : null; - } - /** * Get attribute model code for entity type * diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index e7d4999e435..d31dc02270d 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -92,28 +92,6 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb return $this; } - /** - * Load all entity type attributes - * - * @param int $entityTypeId - * @return $this - */ - protected function _loadTypeAttributes($entityTypeId) - { - if (!isset(self::$_entityAttributes[$entityTypeId])) { - $adapter = $this->_getReadAdapter(); - $bind = array(':entity_type_id' => $entityTypeId); - $select = $adapter->select()->from($this->getMainTable())->where('entity_type_id = :entity_type_id'); - - $data = $adapter->fetchAll($select, $bind); - foreach ($data as $row) { - self::$_entityAttributes[$entityTypeId][$row['attribute_code']] = $row; - } - } - - return $this; - } - /** * Load attribute data by attribute code * diff --git a/app/code/Magento/Eav/Plugin/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Plugin/Model/Resource/Entity/Attribute.php new file mode 100644 index 00000000000..e78c44e6728 --- /dev/null +++ b/app/code/Magento/Eav/Plugin/Model/Resource/Entity/Attribute.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\Eav\Plugin\Model\Resource\Entity; + +class Attribute +{ + /** + * Cache key for store label attribute + */ + const STORE_LABEL_ATTRIBUTE = 'EAV_STORE_LABEL_ATTRIBUTE'; + + /** @var \Magento\Framework\App\CacheInterface */ + protected $cache; + + /** @var bool|null */ + protected $isCacheEnabled = null; + + /** + * @param \Magento\Framework\App\CacheInterface $cache + * @param \Magento\Framework\App\Cache\StateInterface $cacheState + */ + public function __construct( + \Magento\Framework\App\CacheInterface $cache, + \Magento\Framework\App\Cache\StateInterface $cacheState + ) { + $this->cache = $cache; + $this->isCacheEnabled = $cacheState->isEnabled(\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER); + } + + /** + * @param \Magento\Eav\Model\Resource\Entity\Attribute $subject + * @param callable $proceed + * @param int $attributeId + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundGetStoreLabelsByAttributeId( + \Magento\Eav\Model\Resource\Entity\Attribute $subject, + \Closure $proceed, + $attributeId + ) { + $cacheId = self::STORE_LABEL_ATTRIBUTE . $attributeId; + if ($this->isCacheEnabled && ($storeLabels = $this->cache->load($cacheId))) { + return unserialize($storeLabels); + } + $storeLabels = $proceed($attributeId); + if ($this->isCacheEnabled) { + $this->cache->save( + serialize($storeLabels), + $cacheId, + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ] + ); + } + return $storeLabels; + } +} diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 6c6d37ad2dc..8d888f993fb 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml index 6fb75afb1a9..e62f7dd9b12 100644 --- a/app/code/Magento/Eav/etc/di.xml +++ b/app/code/Magento/Eav/etc/di.xml @@ -49,4 +49,7 @@ </argument> </arguments> </type> + <type name="Magento\Eav\Model\Resource\Entity\Attribute"> + <plugin name="storeLabelCaching" type="Magento\Eav\Plugin\Model\Resource\Entity\Attribute" /> + </type> </config> diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index da9af92b589..bce2ccbaab7 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 7564c40fe84..897ffa1f176 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-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Fedex/data/fedex_setup/data-install-2.0.0.0.php b/app/code/Magento/Fedex/data/fedex_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/Fedex/data/fedex_setup/data-install-2.0.0.0.php rename to app/code/Magento/Fedex/data/fedex_setup/data-install-2.0.0.php diff --git a/app/code/Magento/Fedex/etc/module.xml b/app/code/Magento/Fedex/etc/module.xml index 8f13222ae32..2768394fd10 100644 --- a/app/code/Magento/Fedex/etc/module.xml +++ b/app/code/Magento/Fedex/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Fedex" schema_version="2.0.0.0" active="true"> + <module name="Magento_Fedex" schema_version="2.0.0" active="true"> <depends> <module name="Magento_Store"/> <module name="Magento_Shipping"/> diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index 9c69e019f8e..ce43c28f5cc 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-multishipping": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-multishipping": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 113d5f4ce54..4d26c26e60f 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-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 508dbb98670..8618b895fca 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-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 3ec25dde8df..6ac73e22387 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-alpha103", - "magento/module-google-analytics": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-google-analytics": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index e79b3cb149f..8bdd03fa899 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedImportExport/composer.json b/app/code/Magento/GroupedImportExport/composer.json index 525bf0c37c3..29a32c85321 100644 --- a/app/code/Magento/GroupedImportExport/composer.json +++ b/app/code/Magento/GroupedImportExport/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-import-export": "0.1.0-alpha103", - "magento/module-catalog-import-export": "0.1.0-alpha103", - "magento/module-grouped-product": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-import-export": "0.1.0-alpha104", + "magento/module-catalog-import-export": "0.1.0-alpha104", + "magento/module-grouped-product": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index a371019206b..a4ea85a32ee 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-msrp": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-msrp": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index ade0deb9174..cace1e17b34 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -114,9 +114,9 @@ class Import extends \Magento\ImportExport\Model\AbstractModel protected $_uploaderFactory; /** - * @var \Magento\Indexer\Model\IndexerFactory + * @var \Magento\Indexer\Model\IndexerRegistry */ - protected $indexerFactory; + protected $indexerRegistry; /** * @var \Magento\ImportExport\Model\Source\Import\Behavior\Factory @@ -134,14 +134,14 @@ class Import extends \Magento\ImportExport\Model\AbstractModel * @param \Magento\Framework\Logger\AdapterFactory $adapterFactory * @param \Magento\ImportExport\Helper\Data $importExportData * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig - * @param \Magento\ImportExport\Model\Import\ConfigInterface $importConfig - * @param \Magento\ImportExport\Model\Import\Entity\Factory $entityFactory - * @param \Magento\ImportExport\Model\Resource\Import\Data $importData - * @param \Magento\ImportExport\Model\Export\Adapter\CsvFactory $csvFactory - * @param \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory + * @param Import\ConfigInterface $importConfig + * @param Import\Entity\Factory $entityFactory + * @param Resource\Import\Data $importData + * @param Export\Adapter\CsvFactory $csvFactory + * @param FileTransferFactory $httpFactory * @param \Magento\Core\Model\File\UploaderFactory $uploaderFactory - * @param \Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory - * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory + * @param Source\Import\Behavior\Factory $behaviorFactory + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry * @param array $data */ public function __construct( @@ -157,7 +157,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory, \Magento\Core\Model\File\UploaderFactory $uploaderFactory, \Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory, - \Magento\Indexer\Model\IndexerFactory $indexerFactory, + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry, array $data = array() ) { $this->_importExportData = $importExportData; @@ -168,7 +168,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel $this->_csvFactory = $csvFactory; $this->_httpFactory = $httpFactory; $this->_uploaderFactory = $uploaderFactory; - $this->indexerFactory = $indexerFactory; + $this->indexerRegistry = $indexerRegistry; $this->_behaviorFactory = $behaviorFactory; $this->_filesystem = $filesystem; parent::__construct($logger, $filesystem, $adapterFactory, $data); @@ -573,9 +573,8 @@ class Import extends \Magento\ImportExport\Model\AbstractModel } foreach (array_keys($relatedIndexers) as $indexerId) { - $indexer = $this->indexerFactory->create(); try { - $indexer->load($indexerId); + $indexer = $this->indexerRegistry->get($indexerId); $indexer->invalidate(); } catch (\InvalidArgumentException $e) { } diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 74afea4be23..f4c145eb45b 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-indexer": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-indexer": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php index 979f028918f..f4c53bd93ec 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassChangelog.php @@ -38,13 +38,9 @@ class MassChangelog extends \Magento\Indexer\Controller\Adminhtml\Indexer $this->messageManager->addError(__('Please select indexers.')); } else { try { - foreach ($indexerIds as $indexer_id) { + foreach ($indexerIds as $indexerId) { /** @var \Magento\Indexer\Model\IndexerInterface $model */ - $model = $this->_objectManager->create( - 'Magento\Indexer\Model\IndexerInterface' - )->load( - $indexer_id - ); + $model = $this->_objectManager->get('Magento\Indexer\Model\IndexerRegistry')->get($indexerId); $model->setScheduled(true); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php index f2d6ffd32c0..48fb3319dba 100644 --- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassOnTheFly.php @@ -38,13 +38,9 @@ class MassOnTheFly extends \Magento\Indexer\Controller\Adminhtml\Indexer $this->messageManager->addError(__('Please select indexers.')); } else { try { - foreach ($indexerIds as $indexer_id) { + foreach ($indexerIds as $indexerId) { /** @var \Magento\Indexer\Model\IndexerInterface $model */ - $model = $this->_objectManager->create( - 'Magento\Indexer\Model\IndexerInterface' - )->load( - $indexer_id - ); + $model = $this->_objectManager->get('Magento\Indexer\Model\IndexerRegistry')->get($indexerId); $model->setScheduled(false); } $this->messageManager->addSuccess( diff --git a/app/code/Magento/Indexer/Model/ActionInterface.php b/app/code/Magento/Indexer/Model/ActionInterface.php index 5db6a971fc1..20d68865b9c 100644 --- a/app/code/Magento/Indexer/Model/ActionInterface.php +++ b/app/code/Magento/Indexer/Model/ActionInterface.php @@ -38,7 +38,7 @@ interface ActionInterface * @param int[] $ids * @return void */ - public function executeList($ids); + public function executeList(array $ids); /** * Execute partial indexation by ID diff --git a/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php b/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php index b5cccf62e68..3c97ac2ba10 100644 --- a/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php +++ b/app/code/Magento/Indexer/Model/Indexer/AbstractProcessor.php @@ -33,18 +33,16 @@ abstract class AbstractProcessor */ const INDEXER_ID = ''; - /** - * @var \Magento\Indexer\Model\IndexerInterface - */ - protected $_indexer; + /** @var \Magento\Indexer\Model\IndexerRegistry */ + protected $indexerRegistry; /** - * @param \Magento\Indexer\Model\IndexerFactory $indexerFactory + * @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry */ public function __construct( - \Magento\Indexer\Model\IndexerFactory $indexerFactory + \Magento\Indexer\Model\IndexerRegistry $indexerRegistry ) { - $this->_indexer = $indexerFactory->create(); + $this->indexerRegistry = $indexerRegistry; } /** @@ -54,10 +52,7 @@ abstract class AbstractProcessor */ public function getIndexer() { - if (!$this->_indexer->getId()) { - $this->_indexer->load(static::INDEXER_ID); - } - return $this->_indexer; + return $this->indexerRegistry->get(static::INDEXER_ID); } /** diff --git a/app/code/Magento/Indexer/Model/IndexerRegistry.php b/app/code/Magento/Indexer/Model/IndexerRegistry.php new file mode 100644 index 00000000000..1088c3e9c91 --- /dev/null +++ b/app/code/Magento/Indexer/Model/IndexerRegistry.php @@ -0,0 +1,60 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Indexer\Model; + +class IndexerRegistry +{ + /** + * @var \Magento\Framework\ObjectManager + */ + protected $objectManager; + + /** + * @var IndexerInterface[] + */ + protected $indexers = []; + + /** + * @param \Magento\Framework\ObjectManager $objectManager + */ + public function __construct(\Magento\Framework\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Retrieve indexer instance by id + * + * @param string $indexerId + * @return IndexerInterface + */ + public function get($indexerId) + { + if (!isset($this->indexers[$indexerId])) { + $this->indexers[$indexerId] = $this->objectManager->create('Magento\Indexer\Model\IndexerInterface') + ->load($indexerId); + } + return $this->indexers[$indexerId]; + } +} diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 4d5f4a80fd5..02434dabfb0 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-alpha103", - "magento/module-page-cache": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-page-cache": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Integration/composer.json b/app/code/Magento/Integration/composer.json index 8abd0ede0e4..6d086ae2da0 100644 --- a/app/code/Magento/Integration/composer.json +++ b/app/code/Magento/Integration/composer.json @@ -3,17 +3,17 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-user": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-authorization": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-user": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-authorization": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index 194a561b670..b019476a30b 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-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index e6decb233a9..63212cbe679 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Msrp/composer.json b/app/code/Magento/Msrp/composer.json index 2fb27823c7b..dc8eaec8526 100644 --- a/app/code/Magento/Msrp/composer.json +++ b/app/code/Magento/Msrp/composer.json @@ -3,21 +3,21 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-bundle": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-configurable-product": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-downloadable": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-grouped-product": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-bundle": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-configurable-product": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-downloadable": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-grouped-product": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index e4df9fe320e..0776bfff1a2 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -3,19 +3,19 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 2095dfd29d1..45695e6b333 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -3,20 +3,20 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-email": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-email": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 2b06806aa09..6a2a6b3a91c 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-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-payment": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflinePayments/etc/module.xml b/app/code/Magento/OfflinePayments/etc/module.xml index 24f917885db..7f24be74c19 100644 --- a/app/code/Magento/OfflinePayments/etc/module.xml +++ b/app/code/Magento/OfflinePayments/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_OfflinePayments" schema_version="1.6.0.0" active="true"> + <module name="Magento_OfflinePayments" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Core"/> <module name="Magento_Store"/> diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 3a7d0d251f5..5d34d020dde 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-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-sales-rule": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-sales-rule": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/etc/module.xml b/app/code/Magento/OfflineShipping/etc/module.xml index bd98e5a2db5..40fa442036c 100644 --- a/app/code/Magento/OfflineShipping/etc/module.xml +++ b/app/code/Magento/OfflineShipping/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_OfflineShipping" schema_version="2.0.0.0" active="true"> + <module name="Magento_OfflineShipping" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Store"/> <module name="Magento_Sales"/> diff --git a/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php b/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.php similarity index 95% rename from app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php rename to app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.php index 2432d3e6996..cf30803cb23 100644 --- a/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php +++ b/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.php @@ -108,7 +108,7 @@ $installer->getConnection()->addColumn( 'Simple Free Shipping' ); $installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order_item'), + $installer->getTable('sales_order_item'), 'free_shipping', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, @@ -116,7 +116,7 @@ $installer->getConnection()->addColumn( 'Free Shipping' ); $installer->getConnection()->addColumn( - $installer->getTable('sales_flat_quote_address'), + $installer->getTable('sales_quote_address'), 'free_shipping', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, @@ -124,7 +124,7 @@ $installer->getConnection()->addColumn( 'Free Shipping' ); $installer->getConnection()->addColumn( - $installer->getTable('sales_flat_quote_item'), + $installer->getTable('sales_quote_item'), 'free_shipping', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, @@ -132,7 +132,7 @@ $installer->getConnection()->addColumn( 'Free Shipping' ); $installer->getConnection()->addColumn( - $installer->getTable('sales_flat_quote_address_item'), + $installer->getTable('sales_quote_address_item'), 'free_shipping', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index dc6ff442783..300d6a60503 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-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/data/ogone_setup/data-install-1.6.0.0.php b/app/code/Magento/Ogone/data/ogone_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/Ogone/data/ogone_setup/data-install-1.6.0.0.php rename to app/code/Magento/Ogone/data/ogone_setup/data-install-2.0.0.php diff --git a/app/code/Magento/Ogone/etc/module.xml b/app/code/Magento/Ogone/etc/module.xml index d5a600a2aa7..875cd11e011 100644 --- a/app/code/Magento/Ogone/etc/module.xml +++ b/app/code/Magento/Ogone/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Ogone" schema_version="1.6.0.0" active="true"> + <module name="Magento_Ogone" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Sales"/> <module name="Magento_Payment"/> diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index b80a9f8d3a5..bc79d590b4e 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-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index c7e5ca5291b..f3695b31017 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-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-paypal": "0.1.0-alpha103", - "magento/module-recurring-payment": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-paypal": "0.1.0-alpha104", + "magento/module-recurring-payment": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/etc/module.xml b/app/code/Magento/PayPalRecurringPayment/etc/module.xml index c0f24a5bf82..42e091d878e 100644 --- a/app/code/Magento/PayPalRecurringPayment/etc/module.xml +++ b/app/code/Magento/PayPalRecurringPayment/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_PayPalRecurringPayment" schema_version="1.0.0.0" active="true"> + <module name="Magento_PayPalRecurringPayment" schema_version="2.0.0" active="true"> <depends> <module name="Magento_Customer"/> <module name="Magento_Directory"/> diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index b2989c643e4..01706937d07 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -217,8 +217,12 @@ class Info extends \Magento\Framework\Model\AbstractModel */ protected function _initAdditionalInformation() { - if (empty($this->_additionalInformation) && $this->_getData('additional_information')) { - $this->_additionalInformation = $this->_getData('additional_information'); + $additionalInfo = $this->_getData('additional_information'); + if (empty($this->_additionalInformation) && $additionalInfo) { + if (!is_array($additionalInfo)) { + $additionalInfo = unserialize($additionalInfo); + } + $this->_additionalInformation = $additionalInfo; } } } diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index a10ad27cc9c..8b7ad14ae65 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-centinel": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-centinel": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/etc/module.xml b/app/code/Magento/Payment/etc/module.xml index 08103caabef..0c2de188ef5 100644 --- a/app/code/Magento/Payment/etc/module.xml +++ b/app/code/Magento/Payment/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Payment" schema_version="1.6.0.0" active="true"> + <module name="Magento_Payment" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Core"/> <module name="Magento_Store"/> diff --git a/app/code/Magento/Paypal/Model/Api/AbstractApi.php b/app/code/Magento/Paypal/Model/Api/AbstractApi.php index 5f7c6e3f777..15efd4db6ad 100644 --- a/app/code/Magento/Paypal/Model/Api/AbstractApi.php +++ b/app/code/Magento/Paypal/Model/Api/AbstractApi.php @@ -306,7 +306,7 @@ abstract class AbstractApi extends \Magento\Framework\Object * @param array $publicMap * @return array|\Magento\Framework\Object */ - public function &import($to, array $publicMap = array()) + public function import($to, array $publicMap = array()) { return \Magento\Framework\Object\Mapper::accumulateByMap(array($this, 'getDataUsingMethod'), $to, $publicMap); } diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index 7cca4e58880..4302f994794 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-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-centinel": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-centinel": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/data/paypal_setup/data-install-1.6.0.0.php b/app/code/Magento/Paypal/data/paypal_setup/data-install-2.0.0.php similarity index 91% rename from app/code/Magento/Paypal/data/paypal_setup/data-install-1.6.0.0.php rename to app/code/Magento/Paypal/data/paypal_setup/data-install-2.0.0.php index c1a85daa435..779aa18f971 100644 --- a/app/code/Magento/Paypal/data/paypal_setup/data-install-1.6.0.0.php +++ b/app/code/Magento/Paypal/data/paypal_setup/data-install-2.0.0.php @@ -44,7 +44,11 @@ $installer->addAttribute( ); $data = array(); -$statuses = array('pending_paypal' => __('Pending PayPal')); +$statuses = array( + 'pending_paypal' => __('Pending PayPal'), + 'paypal_reversed' => __('PayPal Reversed'), + 'paypal_canceled_reversal' => __('PayPal Canceled Reversal') +); foreach ($statuses as $code => $info) { $data[] = array('status' => $code, 'label' => $info); } diff --git a/app/code/Magento/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php b/app/code/Magento/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php deleted file mode 100644 index b34584387c7..00000000000 --- a/app/code/Magento/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** @var $this \Magento\Sales\Model\Resource\Setup */ -$installer = $this; -$connection = $installer->getConnection(); -$installer->startSetup(); -$data = array( - array('paypal_reversed', 'PayPal Reversed'), - array('paypal_canceled_reversal', 'PayPal Canceled Reversal') -); -$connection = $installer->getConnection()->insertArray( - $installer->getTable('sales_order_status'), - array('status', 'label'), - $data -); -$installer->endSetup(); diff --git a/app/code/Magento/Paypal/etc/module.xml b/app/code/Magento/Paypal/etc/module.xml index 228996c72b5..ba80a69b3c1 100644 --- a/app/code/Magento/Paypal/etc/module.xml +++ b/app/code/Magento/Paypal/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Paypal" schema_version="1.6.0.4" active="true"> + <module name="Magento_Paypal" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Checkout"/> <module name="Magento_Sales"/> diff --git a/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php b/app/code/Magento/Paypal/sql/paypal_setup/install-2.0.0.php similarity index 88% rename from app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php rename to app/code/Magento/Paypal/sql/paypal_setup/install-2.0.0.php index b1809bf6af8..8107bd4b7c7 100644 --- a/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php +++ b/app/code/Magento/Paypal/sql/paypal_setup/install-2.0.0.php @@ -147,9 +147,9 @@ $table = $installer->getConnection()->newTable( \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('paypal_billing_agreement_order', 'order_id', 'sales_flat_order', 'entity_id'), + $installer->getFkName('paypal_billing_agreement_order', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $installer->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE @@ -313,6 +313,18 @@ $table = $installer->getConnection()->newTable( 127, array(), 'Consumer Id' +)->addColumn( + 'payment_tracking_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Payment Tracking ID' +)->addColumn( + 'store_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + array(), + 'Store ID' )->addIndex( $installer->getIdxName('paypal_settlement_report_row', array('report_id')), array('report_id') @@ -370,6 +382,47 @@ $table = $installer->getConnection()->newTable( )->setComment( 'Paypal Certificate Table' ); + +/** + * Create table 'paypal_payment_transaction' + */ +$table = $installer->getConnection()->newTable( + $installer->getTable('paypal_payment_transaction') +)->addColumn( + 'transaction_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Entity Id' +)->addColumn( + 'txn_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 100, + array(), + 'Txn Id' +)->addColumn( + 'additional_information', + \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, + '64K', + array(), + 'Additional Information' +)->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + array(), + 'Created At' +)->addIndex( + $installer->getIdxName( + 'paypal_payment_transaction', + array('txn_id'), + \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + array('txn_id'), + array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) +)->setComment( + 'PayPal Payflow Link Payment Transaction' +); $installer->getConnection()->createTable($table); /** * Prepare database after install diff --git a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php deleted file mode 100644 index 7355597d8f5..00000000000 --- a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; - -/** - * Create table 'paypal_payment_transaction' - */ -$table = $installer->getConnection()->newTable( - $installer->getTable('paypal_payment_transaction') -)->addColumn( - 'transaction_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), - 'Entity Id' -)->addColumn( - 'txn_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - array(), - 'Txn Id' -)->addColumn( - 'additional_information', - \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, - '64K', - array(), - 'Additional Information' -)->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - array(), - 'Created At' -)->addIndex( - $installer->getIdxName( - 'paypal_payment_transaction', - array('txn_id'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - array('txn_id'), - array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) -)->setComment( - 'PayPal Payflow Link Payment Transaction' -); -$installer->getConnection()->createTable($table); diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 5c946c684d0..ea9bb11020a 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-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Persistent/etc/frontend/di.xml b/app/code/Magento/Persistent/etc/frontend/di.xml index db997b25019..4e381ebb770 100644 --- a/app/code/Magento/Persistent/etc/frontend/di.xml +++ b/app/code/Magento/Persistent/etc/frontend/di.xml @@ -31,4 +31,9 @@ </argument> </arguments> </type> + <type name="Magento\Persistent\Model\Observer\EmulateQuote"> + <arguments> + <argument name="customerAccountService" xsi:type="object">Magento\Customer\Service\V1\CustomerAccountServiceInterface\Proxy</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Persistent/sql/persistent_setup/install-1.0.0.0.php b/app/code/Magento/Persistent/sql/persistent_setup/install-1.0.0.0.php index fb33978aa5d..12d2aab293d 100644 --- a/app/code/Magento/Persistent/sql/persistent_setup/install-1.0.0.0.php +++ b/app/code/Magento/Persistent/sql/persistent_setup/install-1.0.0.0.php @@ -97,11 +97,11 @@ $table = $installer->getConnection()->newTable( $installer->getConnection()->createTable($table); /** - * Alter sales_flat_quote table with is_persistent flag + * Alter sales_quote table with is_persistent flag * */ $installer->getConnection()->addColumn( - $installer->getTable('sales_flat_quote'), + $installer->getTable('sales_quote'), 'is_persistent', array( 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 838a97b3f97..6a98e206a3b 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index b4b05b2f40d..853e3e05419 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -3,22 +3,22 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php b/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php rename to app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-2.0.0.php diff --git a/app/code/Magento/RecurringPayment/etc/frontend/di.xml b/app/code/Magento/RecurringPayment/etc/frontend/di.xml new file mode 100644 index 00000000000..886edd277de --- /dev/null +++ b/app/code/Magento/RecurringPayment/etc/frontend/di.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\RecurringPayment\Model\RecurringPayment"> + <arguments> + <argument name="fields" xsi:type="object">Magento\RecurringPayment\Block\Fields\Proxy</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/RecurringPayment/etc/module.xml b/app/code/Magento/RecurringPayment/etc/module.xml index a2f6dbc541c..75e605cd693 100644 --- a/app/code/Magento/RecurringPayment/etc/module.xml +++ b/app/code/Magento/RecurringPayment/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_RecurringPayment" schema_version="1.0.0.0" active="true"> + <module name="Magento_RecurringPayment" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Sales"/> <module name="Magento_User"/> diff --git a/app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-1.0.0.0.php b/app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-2.0.0.php similarity index 99% rename from app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-1.0.0.0.php rename to app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-2.0.0.php index 06f5e086605..d7fae978e76 100644 --- a/app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-1.0.0.0.php +++ b/app/code/Magento/RecurringPayment/sql/recurringpayment_setup/install-2.0.0.php @@ -296,9 +296,9 @@ $table = $this->getConnection()->newTable( $this->getIdxName('recurring_payment_order', array('order_id')), array('order_id') )->addForeignKey( - $this->getFkName('recurring_payment_order', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('recurring_payment_order', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $this->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php index 2889c8e40a3..5c0955ec404 100644 --- a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php @@ -187,7 +187,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection } $this->getSelect()->joinLeft( - array('orders' => $this->getTable('sales_flat_order')), + array('orders' => $this->getTable('sales_order')), "orders.customer_id = e.entity_id" . $dateFilter, array() ); @@ -288,7 +288,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection $select = $this->getConnection()->select(); $select->from( - array('orders' => $this->getTable('sales_flat_order')), + array('orders' => $this->getTable('sales_order')), array( 'orders_avg_amount' => "AVG({$totalExpr})", 'orders_sum_amount' => "SUM({$totalExpr})", diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 23134cd656e..f9bc7d973b5 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -212,7 +212,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0) { - $this->setMainTable('sales_flat_order'); + $this->setMainTable('sales_order'); $adapter = $this->getConnection(); /** @@ -510,7 +510,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ protected function _calculateTotalsLive($isFilter = 0) { - $this->setMainTable('sales_flat_order'); + $this->setMainTable('sales_order'); $this->removeAllFieldsFromSelect(); $adapter = $this->getConnection(); @@ -623,7 +623,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection } $this->getSelect()->where('main_table.order_status NOT IN(?)', $statuses); } else { - $this->setMainTable('sales_flat_order'); + $this->setMainTable('sales_order'); $this->removeAllFieldsFromSelect(); $expr = $this->_getSalesAmountExpression(); diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index d255990093d..ee49c760130 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -252,10 +252,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection if ($this->_selectCountSqlType == self::SELECT_COUNT_SQL_TYPE_CART) { $countSelect = clone $this->getSelect(); $countSelect->reset()->from( - array('quote_item_table' => $this->getTable('sales_flat_quote_item')), + array('quote_item_table' => $this->getTable('sales_quote_item')), array('COUNT(DISTINCT quote_item_table.product_id)') )->join( - array('quote_table' => $this->getTable('sales_flat_quote')), + array('quote_table' => $this->getTable('sales_quote')), 'quote_table.entity_id = quote_item_table.quote_id AND quote_table.is_active = 1', array() ); @@ -285,10 +285,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $countSelect->reset(); $countSelect->from( - array('quote_items' => $this->getTable('sales_flat_quote_item')), + array('quote_items' => $this->getTable('sales_quote_item')), 'COUNT(*)' )->join( - array('quotes' => $this->getTable('sales_flat_quote')), + array('quotes' => $this->getTable('sales_quote')), 'quotes.entity_id = quote_items.quote_id AND quotes.is_active = 1', array() )->where( @@ -316,7 +316,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection */ public function addOrdersCount($from = '', $to = '') { - $orderItemTableName = $this->getTable('sales_flat_order_item'); + $orderItemTableName = $this->getTable('sales_order_item'); $productFieldName = sprintf('e.%s', $this->getProductEntityId()); $this->getSelect()->joinLeft( @@ -373,10 +373,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection } $this->getSelect()->reset()->from( - array('order_items' => $this->getTable('sales_flat_order_item')), + array('order_items' => $this->getTable('sales_order_item')), array('ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name') )->joinInner( - array('order' => $this->getTable('sales_flat_order')), + array('order' => $this->getTable('sales_order')), implode(' AND ', $orderJoinCondition), array() )->joinLeft( diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php index 984b00dfa77..4098da01538 100644 --- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php @@ -147,7 +147,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection $ordersSubSelect = clone $this->getSelect(); $ordersSubSelect->reset()->from( - array('oi' => $this->getTable('sales_flat_order_item')), + array('oi' => $this->getTable('sales_order_item')), array('orders' => new \Zend_Db_Expr('COUNT(1)'), 'product_id') )->group( 'oi.product_id' @@ -158,7 +158,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection )->reset( \Zend_Db_Select::COLUMNS )->joinInner( - array('quote_items' => $this->getTable('sales_flat_quote_item')), + array('quote_items' => $this->getTable('sales_quote_item')), 'quote_items.quote_id = main_table.entity_id', null )->joinInner( diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 2742899c658..8b4926bd206 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-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-log": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-review": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-downloadable": "0.1.0-alpha103", - "magento/module-sales-rule": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-log": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-review": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-downloadable": "0.1.0-alpha104", + "magento/module-sales-rule": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/RequireJs/composer.json b/app/code/Magento/RequireJs/composer.json index d890eb8dd64..8641f5e0b9c 100644 --- a/app/code/Magento/RequireJs/composer.json +++ b/app/code/Magento/RequireJs/composer.json @@ -3,11 +3,11 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Review/Block/Product/Review.php b/app/code/Magento/Review/Block/Product/Review.php index ed15320b73b..73714ba9919 100644 --- a/app/code/Magento/Review/Block/Product/Review.php +++ b/app/code/Magento/Review/Block/Product/Review.php @@ -47,13 +47,13 @@ class Review extends \Magento\Framework\View\Element\Template protected $_reviewsColFactory; /** - * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, + \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory, array $data = array() diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index acf1ecf72c6..47420672b60 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-newsletter": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-newsletter": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index 12d22eadd1a..beed028e0ea 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -3,14 +3,14 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Rule/Model/Condition/Combine.php b/app/code/Magento/Rule/Model/Condition/Combine.php index e079e2d2c69..87239a38323 100644 --- a/app/code/Magento/Rule/Model/Condition/Combine.php +++ b/app/code/Magento/Rule/Model/Condition/Combine.php @@ -25,13 +25,6 @@ namespace Magento\Rule\Model\Condition; class Combine extends AbstractCondition { - /** - * Store all used condition models - * - * @var array - */ - protected $_conditionModels = array(); - /** * @var \Magento\Rule\Model\ConditionFactory */ @@ -75,36 +68,6 @@ class Combine extends AbstractCondition } } - /** - * Retrieve new object for each requested model. - * If model is requested first time, store it at static array. - * - * It's made by performance reasons to avoid initialization of same models each time when rules are being processed. - * - * @param string $modelClass - * @return AbstractCondition|bool - */ - protected function _getNewConditionModelInstance($modelClass) - { - if (empty($modelClass)) { - return false; - } - - if (!array_key_exists($modelClass, $this->_conditionModels)) { - $model = $this->_conditionFactory->create($modelClass); - $this->_conditionModels[$modelClass] = $model; - } else { - $model = $this->_conditionModels[$modelClass]; - } - - if (!$model) { - return false; - } - - $newModel = clone $model; - return $newModel; - } - /* start aggregator methods */ /** * @return $this @@ -266,13 +229,11 @@ class Combine extends AbstractCondition ); if (!empty($arr[$key]) && is_array($arr[$key])) { - foreach ($arr[$key] as $condArr) { + foreach ($arr[$key] as $conditionArr) { try { - $cond = $this->_getNewConditionModelInstance($condArr['type']); - if ($cond) { - $this->addCondition($cond); - $cond->loadArray($condArr, $key); - } + $condition = $this->_conditionFactory->create($conditionArr['type']); + $this->addCondition($condition); + $condition->loadArray($conditionArr, $key); } catch (\Exception $e) { $this->_logger->logException($e); } diff --git a/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php b/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php index fda5e0744cb..3a706165d72 100644 --- a/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php +++ b/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php @@ -331,11 +331,11 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon { $attribute = $this->getAttribute(); if ('category_ids' != $attribute) { + $productCollection->addAttributeToSelect($attribute, 'left'); if ($this->getAttributeObject()->isScopeGlobal()) { $attributes = $this->getRule()->getCollectedAttributes(); $attributes[$attribute] = true; $this->getRule()->setCollectedAttributes($attributes); - $productCollection->addAttributeToSelect($attribute, 'left'); } else { $this->_entityAttributeValues = $productCollection->getAllAttributeValues($attribute); } @@ -607,14 +607,20 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon } /** - * Get field by attribute + * Get mapped sql field * * @return string */ public function getMappedSqlField() { - - return ($this->getAttribute() == 'category_ids') ? 'e.entity_id' : parent::getMappedSqlField(); + if (!$this->isAttributeSetOrCategory()) { + $mappedSqlField = $this->getEavAttributeTableAlias() . '.value'; + } elseif ($this->getAttribute() == 'category_ids') { + $mappedSqlField = 'e.entity_id'; + } else { + $mappedSqlField = parent::getMappedSqlField(); + } + return $mappedSqlField; } /** @@ -702,4 +708,26 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon return $operator; } + + /** + * Check is attribute set or category + * + * @return bool + */ + protected function isAttributeSetOrCategory() + { + return in_array($this->getAttribute(), ['attribute_set_id', 'category_ids']); + } + + /** + * Get eav attribute alias + * + * @return string + */ + protected function getEavAttributeTableAlias() + { + $attribute = $this->getAttributeObject(); + + return 'at_' . $attribute->getAttributeCode(); + } } diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index 2f2cedbea30..dac518d9a4f 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -119,7 +119,8 @@ class Builder /** @var $condition AbstractCondition */ $collection->getSelect()->joinLeft( [$alias => $collection->getResource()->getTable($joinTable['name'])], - $joinTable['condition'] + $joinTable['condition'], + isset($joinTable['columns']) ? $joinTable['columns'] : '*' ); } return $this; diff --git a/app/code/Magento/Rule/Model/ConditionFactory.php b/app/code/Magento/Rule/Model/ConditionFactory.php index e03c3f0d767..95b18789ba8 100644 --- a/app/code/Magento/Rule/Model/ConditionFactory.php +++ b/app/code/Magento/Rule/Model/ConditionFactory.php @@ -23,30 +23,48 @@ */ namespace Magento\Rule\Model; +use Magento\Framework\ObjectManager; + class ConditionFactory { /** - * @var \Magento\Framework\ObjectManager + * @var ObjectManager + */ + private $objectManager; + + /** + * Store all used condition models + * + * @var array */ - protected $_objectManager; + private $conditionModels = []; /** - * @param \Magento\Framework\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\Framework\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { - $this->_objectManager = $objectManager; + $this->objectManager = $objectManager; } /** - * Create new action object + * Create new object for each requested model. + * If model is requested first time, store it at array. + * It's made by performance reasons to avoid initialization of same models each time when rules are being processed. * * @param string $type - * @param array $data + * * @return \Magento\Rule\Model\Condition\ConditionInterface + * + * @throws \LogicException + * @throws \BadMethodCallException */ - public function create($type, array $data = array()) + public function create($type) { - return $this->_objectManager->create($type, $data); + if (!array_key_exists($type, $this->conditionModels)) { + $this->conditionModels[$type] = $this->objectManager->create($type); + } + + return clone $this->conditionModels[$type]; } } diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 02b8dfdb00a..01c7fdadc74 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-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index f3d45333bb3..897b51f3370 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -1493,7 +1493,8 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $request = $form->prepareRequest($accountData); $data = $form->extractData($request); $data = $form->restoreData($data); - $customer = $this->_customerBuilder->mergeDataObjectWithArray($customer, $data); + $customer = $this->_customerBuilder->mergeDataObjectWithArray($customer, $data) + ->create(); $this->getQuote()->updateCustomerData($customer); $data = array(); @@ -1604,7 +1605,8 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode unset($data[$key]); } } - return $this->_customerBuilder->mergeDataObjectWithArray($customerDataObject, $data); + return $this->_customerBuilder->mergeDataObjectWithArray($customerDataObject, $data) + ->create(); } /** @@ -1702,7 +1704,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $customerAddressDataObject = $this->_customerAddressBuilder->mergeDataObjects( $existingAddressDataObject, $customerAddressDataObject - ); + )->create(); } elseif ($addressType == CustomerAddressDataObject::ADDRESS_TYPE_SHIPPING) { try { $billingAddressDataObject = $this->_customerAddressService->getDefaultBillingAddress($customerId); diff --git a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotals.php b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotals.php index c88b04b27bd..f867d7fdce9 100644 --- a/app/code/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotals.php +++ b/app/code/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotals.php @@ -109,7 +109,7 @@ class CollectTotals $customerData = $this->customerBuilder->mergeDataObjectWithArray( $customerData, array('group_id' => $groupId) - ); + )->create(); $quote->setCustomerData($customerData); } } diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index 72165ecb21c..aea40921e5f 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -179,6 +179,11 @@ class Quote extends \Magento\Framework\Model\AbstractModel */ protected $_payments; + /** + * @var \Magento\Sales\Model\Quote\Payment + */ + protected $_currentPayment; + /** * Different groups of error infos * @@ -533,6 +538,10 @@ class Quote extends \Magento\Framework\Model\AbstractModel if (null !== $this->_payments) { $this->getPaymentsCollection()->save(); } + + if (null !== $this->_currentPayment) { + $this->getPayment()->save(); + } return $this; } @@ -1593,7 +1602,15 @@ class Quote extends \Magento\Framework\Model\AbstractModel */ public function getPayment() { - foreach ($this->getPaymentsCollection() as $payment) { + if (null === $this->_currentPayment || !$this->_currentPayment) { + $this->_currentPayment = $this->_quotePaymentCollectionFactory->create() + ->setQuoteFilter($this->getId()) + ->getFirstItem(); + } + if ($payment = $this->_currentPayment) { + if ($this->getId()) { + $payment->setQuote($this); + } if (!$payment->isDeleted()) { return $payment; } diff --git a/app/code/Magento/Sales/Model/Quote/Payment.php b/app/code/Magento/Sales/Model/Quote/Payment.php index b7c50268f63..6801cfccc4e 100644 --- a/app/code/Magento/Sales/Model/Quote/Payment.php +++ b/app/code/Magento/Sales/Model/Quote/Payment.php @@ -159,21 +159,16 @@ class Payment extends \Magento\Payment\Model\Info $this->setMethod($data->getMethod()); $method = $this->getMethodInstance(); + $quote = $this->getQuote(); /** * Payment availability related with quote totals. * We have to recollect quote totals before checking */ - $this->getQuote()->collectTotals(); - - if (!$method->isAvailable( - $this->getQuote() - ) || !$this->methodSpecificationFactory->create( - $data->getChecks() - )->isApplicable( - $method, - $this->getQuote() - ) + $quote->collectTotals(); + + if (!$method->isAvailable($quote) + || !$this->methodSpecificationFactory->create($data->getChecks())->isApplicable($method, $quote) ) { throw new \Magento\Framework\Model\Exception(__('The requested Payment Method is not available.')); } diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php index 01da9011b07..62f5126129f 100644 --- a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php +++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php @@ -45,12 +45,12 @@ abstract class AbstractGrid extends AbstractDb implements GridInterface /** * @var string */ - protected $orderTableName = 'sales_flat_order'; + protected $orderTableName = 'sales_order'; /** * @var string */ - protected $addressTableName = 'sales_flat_order_address'; + protected $addressTableName = 'sales_order_address'; /** * @param AppResource $resource diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php index 0950d18db32..5dcb87177f9 100644 --- a/app/code/Magento/Sales/Model/Resource/Order.php +++ b/app/code/Magento/Sales/Model/Resource/Order.php @@ -70,7 +70,7 @@ class Order extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_order', 'entity_id'); + $this->_init('sales_order', 'entity_id'); } /** @@ -108,7 +108,7 @@ class Order extends SalesResource { $adapter = $this->getReadConnection(); $select = $adapter->select()->from( - array('o' => $this->getTable('sales_flat_order_item')), + array('o' => $this->getTable('sales_order_item')), array('o.product_type', new \Zend_Db_Expr('COUNT(*)')) )->joinInner( array('p' => $this->getTable('catalog_product_entity')), diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index 1a72291fc08..e3f33bcfde3 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -76,7 +76,7 @@ class Address extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_order_address', 'entity_id'); + $this->_init('sales_order_address', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Collection.php index 8cabdec5518..3e47161e436 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Collection.php @@ -135,7 +135,7 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec } /** - * Join table sales_flat_order_address to select for billing and shipping order addresses. + * Join table sales_order_address to select for billing and shipping order addresses. * Create correlation map * * @return $this @@ -144,7 +144,7 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec { $billingAliasName = 'billing_o_a'; $shippingAliasName = 'shipping_o_a'; - $joinTable = $this->getTable('sales_flat_order_address'); + $joinTable = $this->getTable('sales_order_address'); $this->addFilterToMap( 'billing_firstname', diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php index 33b3d2cb7b4..ad3a64403da 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php @@ -51,7 +51,7 @@ class Creditmemo extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_creditmemo', 'entity_id'); + $this->_init('sales_creditmemo', 'entity_id'); } /** 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 c9db568fedf..9786250c8bc 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php @@ -71,7 +71,7 @@ class Comment extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_creditmemo_comment', 'entity_id'); + $this->_init('sales_creditmemo_comment', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php index 25669e15b31..914058cc611 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid.php @@ -35,12 +35,12 @@ class Grid extends AbstractGrid /** * @var string */ - protected $gridTableName = 'sales_flat_creditmemo_grid'; + protected $gridTableName = 'sales_creditmemo_grid'; /** * @var string */ - protected $creditmemoTableName = 'sales_flat_creditmemo'; + protected $creditmemoTableName = 'sales_creditmemo'; /** * Refresh grid row diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php index 2384f1c766f..69ef97b40b3 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Grid/Collection.php @@ -52,6 +52,6 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Creditmemo\Collecti protected function _construct() { parent::_construct(); - $this->setMainTable('sales_flat_creditmemo_grid'); + $this->setMainTable('sales_creditmemo_grid'); } } 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 04cc496aa2e..f1c8a602623 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Item.php @@ -44,6 +44,6 @@ class Item extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_creditmemo_item', 'entity_id'); + $this->_init('sales_creditmemo_item', 'entity_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Grid.php index 3d266fd5fcd..18a4efbaad2 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Grid.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid.php @@ -35,7 +35,7 @@ class Grid extends AbstractGrid /** * @var string */ - protected $gridTableName = 'sales_flat_order_grid'; + protected $gridTableName = 'sales_order_grid'; /** * Refresh grid row diff --git a/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php index 53d27423805..7b029049c93 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Grid/Collection.php @@ -59,7 +59,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected function _construct() { parent::_construct(); - $this->setMainTable('sales_flat_order_grid'); + $this->setMainTable('sales_order_grid'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php index 08e1918d8fb..3eabd12157f 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php @@ -49,7 +49,7 @@ class Invoice extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_invoice', 'entity_id'); + $this->_init('sales_invoice', 'entity_id'); } /** 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 6d3ce1e283e..41f7326e25d 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php @@ -74,7 +74,7 @@ class Comment extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_invoice_comment', 'entity_id'); + $this->_init('sales_invoice_comment', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php index 1a68f9c0537..161fffa8932 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid.php @@ -35,12 +35,12 @@ class Grid extends AbstractGrid /** * @var string */ - protected $gridTableName = 'sales_flat_invoice_grid'; + protected $gridTableName = 'sales_invoice_grid'; /** * @var string */ - protected $invoiceTableName = 'sales_flat_invoice'; + protected $invoiceTableName = 'sales_invoice'; /** * Refresh grid row diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php index 4da498d1052..828817e3475 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Grid/Collection.php @@ -52,6 +52,6 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Invoice\Collection protected function _construct() { parent::_construct(); - $this->setMainTable('sales_flat_invoice_grid'); + $this->setMainTable('sales_invoice_grid'); } } 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 0ec5acbe69a..9e51bc44094 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Item.php @@ -44,6 +44,6 @@ class Item extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_invoice_item', 'entity_id'); + $this->_init('sales_invoice_item', 'entity_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Item.php b/app/code/Magento/Sales/Model/Resource/Order/Item.php index 34a8ffca528..8881bdd83ea 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Item.php @@ -44,6 +44,6 @@ class Item extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_order_item', 'item_id'); + $this->_init('sales_order_item', 'item_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment.php b/app/code/Magento/Sales/Model/Resource/Order/Payment.php index 35a0bc2e401..e14c2515054 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment.php @@ -55,6 +55,6 @@ class Payment extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_order_payment', 'entity_id'); + $this->_init('sales_order_payment', 'entity_id'); } } 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 b5555a97b7e..a6129ef934e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction.php @@ -128,7 +128,7 @@ class Transaction extends \Magento\Sales\Model\Resource\Entity $adapter = $this->_getReadAdapter(); $bind = array(':entity_id' => $orderId); $select = $adapter->select()->from( - array('so' => $this->getTable('sales_flat_order')), + array('so' => $this->getTable('sales_order')), 'cs.website_id' )->joinInner( array('cs' => $this->getTable('store')), diff --git a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction/Collection.php index 17699d9712a..9b535ce492c 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Payment/Transaction/Collection.php @@ -215,7 +215,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection\Abstract } if ($this->_addPaymentInformation) { $this->getSelect()->joinInner( - array('sop' => $this->getTable('sales_flat_order_payment')), + array('sop' => $this->getTable('sales_order_payment')), 'main_table.payment_id = sop.entity_id', $this->_addPaymentInformation ); @@ -226,7 +226,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection\Abstract } if ($this->_addOrderInformation) { $this->getSelect()->joinInner( - array('so' => $this->getTable('sales_flat_order')), + array('so' => $this->getTable('sales_order')), 'main_table.order_id = so.entity_id', $this->_addOrderInformation ); diff --git a/app/code/Magento/Sales/Model/Resource/Order/Rss/OrderStatus.php b/app/code/Magento/Sales/Model/Resource/Order/Rss/OrderStatus.php index 005372e9f9c..e352563c0c7 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Rss/OrderStatus.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Rss/OrderStatus.php @@ -58,8 +58,8 @@ class OrderStatus $fields = array('notified' => 'is_customer_notified', 'comment', 'created_at'); $commentSelects = array(); foreach (array('invoice', 'shipment', 'creditmemo') as $entityTypeCode) { - $mainTable = $resource->getTableName('sales_flat_' . $entityTypeCode); - $slaveTable = $resource->getTableName('sales_flat_' . $entityTypeCode . '_comment'); + $mainTable = $resource->getTableName('sales_' . $entityTypeCode); + $slaveTable = $resource->getTableName('sales_' . $entityTypeCode . '_comment'); $select = $read->select()->from( array('main' => $mainTable), array('entity_id' => 'order_id', 'entity_type_code' => new \Zend_Db_Expr("'{$entityTypeCode}'")) @@ -74,7 +74,7 @@ class OrderStatus $commentSelects[] = '(' . $select . ')'; } $select = $read->select()->from( - $resource->getTableName('sales_flat_order_status_history'), + $resource->getTableName('sales_order_status_history'), array('entity_id' => 'parent_id', 'entity_type_code' => new \Zend_Db_Expr("'order'")) + $fields )->where( 'parent_id = ?', @@ -87,7 +87,7 @@ class OrderStatus $commentSelect = $read->select()->union($commentSelects, \Zend_Db_Select::SQL_UNION_ALL); $select = $read->select()->from( - array('orders' => $resource->getTableName('sales_flat_order')), + array('orders' => $resource->getTableName('sales_order')), array('increment_id') )->join( array('t' => $commentSelect), diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php index 1879a8ab1f0..508c2eeaba1 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php @@ -58,7 +58,7 @@ class Shipment extends SalesResource */ protected function _construct() { - $this->_init('sales_flat_shipment', 'entity_id'); + $this->_init('sales_shipment', 'entity_id'); } /** 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 fa21a5c0e3e..b81e3a5817a 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php @@ -71,7 +71,7 @@ class Comment extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_shipment_comment', 'entity_id'); + $this->_init('sales_shipment_comment', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php index 45d951c6757..3a7acd9f6c9 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid.php @@ -35,12 +35,12 @@ class Grid extends AbstractGrid /** * @var string */ - protected $gridTableName = 'sales_flat_shipment_grid'; + protected $gridTableName = 'sales_shipment_grid'; /** * @var string */ - protected $shipmentTableName = 'sales_flat_shipment'; + protected $shipmentTableName = 'sales_shipment'; /** * Refresh grid row diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php index 2017ee5a71c..1aeb94dde89 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Grid/Collection.php @@ -52,6 +52,6 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Shipment\Collection protected function _construct() { parent::_construct(); - $this->setMainTable('sales_flat_shipment_grid'); + $this->setMainTable('sales_shipment_grid'); } } 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 c0a09763e7e..62b8b1d20a9 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Item.php @@ -44,6 +44,6 @@ class Item extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_shipment_item', 'entity_id'); + $this->_init('sales_shipment_item', 'entity_id'); } } 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 fecd4bf1730..97aefcc1678 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php @@ -71,7 +71,7 @@ class Track extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_shipment_track', 'entity_id'); + $this->_init('sales_shipment_track', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php index b0839240f62..01cf0228166 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php @@ -253,7 +253,7 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb { return (bool)$this->_getWriteAdapter()->fetchOne( $this->_getWriteAdapter()->select() - ->from(['sfo' => $this->getTable('sales_flat_order')], []) + ->from(['sfo' => $this->getTable('sales_order')], []) ->where('status = ?', $status) ->limit(1) ->columns([new \Zend_Db_Expr(1)]) 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 2143955fb86..368803b73d5 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -71,7 +71,7 @@ class History extends \Magento\Sales\Model\Resource\Entity */ protected function _construct() { - $this->_init('sales_flat_order_status_history', 'entity_id'); + $this->_init('sales_order_status_history', 'entity_id'); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Quote.php b/app/code/Magento/Sales/Model/Resource/Quote.php index 9942477762f..b02ce7908c2 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote.php +++ b/app/code/Magento/Sales/Model/Resource/Quote.php @@ -54,7 +54,7 @@ class Quote extends AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote', 'entity_id'); + $this->_init('sales_quote', 'entity_id'); } /** @@ -184,7 +184,7 @@ class Quote extends AbstractResource $adapter = $this->_getReadAdapter(); $bind = array(':increment_id' => $orderIncrementId); $select = $adapter->select(); - $select->from($this->getTable('sales_flat_order'), 'entity_id')->where('increment_id = :increment_id'); + $select->from($this->getTable('sales_order'), 'entity_id')->where('increment_id = :increment_id'); $entity_id = $adapter->fetchOne($select, $bind); if ($entity_id > 0) { return true; @@ -200,9 +200,9 @@ class Quote extends AbstractResource */ public function markQuotesRecollectOnCatalogRules() { - $tableQuote = $this->getTable('sales_flat_quote'); + $tableQuote = $this->getTable('sales_quote'); $subSelect = $this->_getReadAdapter()->select()->from( - array('t2' => $this->getTable('sales_flat_quote_item')), + array('t2' => $this->getTable('sales_quote_item')), array('entity_id' => 'quote_id') )->from( array('t3' => $this->getTable('catalogrule_product_price')), @@ -250,7 +250,7 @@ class Quote extends AbstractResource 'items_count' => new \Zend_Db_Expr($adapter->quoteIdentifier('q.items_count') . ' - 1') ) )->join( - array('qi' => $this->getTable('sales_flat_quote_item')), + array('qi' => $this->getTable('sales_quote_item')), implode( ' AND ', array( @@ -262,7 +262,7 @@ class Quote extends AbstractResource array() ); - $updateQuery = $adapter->updateFromSelect($subSelect, array('q' => $this->getTable('sales_flat_quote'))); + $updateQuery = $adapter->updateFromSelect($subSelect, array('q' => $this->getTable('sales_quote'))); $adapter->query($updateQuery); @@ -277,8 +277,8 @@ class Quote extends AbstractResource */ public function markQuotesRecollect($productIds) { - $tableQuote = $this->getTable('sales_flat_quote'); - $tableItem = $this->getTable('sales_flat_quote_item'); + $tableQuote = $this->getTable('sales_quote'); + $tableItem = $this->getTable('sales_quote_item'); $subSelect = $this->_getReadAdapter()->select()->from( $tableItem, array('entity_id' => 'quote_id') diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address.php b/app/code/Magento/Sales/Model/Resource/Quote/Address.php index 469c1440df9..07b3e2a85b0 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address.php @@ -37,6 +37,6 @@ class Address extends \Magento\Sales\Model\Resource\AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote_address', 'address_id'); + $this->_init('sales_quote_address', 'address_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php index 8118c5ae7f9..f076e658d49 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Attribute/Backend/Region.php @@ -34,13 +34,11 @@ class Region extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend protected $_regionFactory; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\RegionFactory $regionFactory */ - public function __construct(\Magento\Framework\Logger $logger, \Magento\Directory\Model\RegionFactory $regionFactory) + public function __construct(\Magento\Directory\Model\RegionFactory $regionFactory) { $this->_regionFactory = $regionFactory; - parent::__construct($logger); } /** diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Item.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Item.php index 10d80366bda..b719a8e05b6 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Item.php @@ -37,6 +37,6 @@ class Item extends \Magento\Sales\Model\Resource\AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote_address_item', 'address_item_id'); + $this->_init('sales_quote_address_item', 'address_item_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate.php b/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate.php index 77d4c6071c6..19b57ed953e 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Address/Rate.php @@ -37,6 +37,6 @@ class Rate extends \Magento\Sales\Model\Resource\AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote_shipping_rate', 'rate_id'); + $this->_init('sales_quote_shipping_rate', 'rate_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Item.php b/app/code/Magento/Sales/Model/Resource/Quote/Item.php index 2d3ad7452d1..b83e78c5392 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Item.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Item.php @@ -37,6 +37,6 @@ class Item extends \Magento\Sales\Model\Resource\AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote_item', 'item_id'); + $this->_init('sales_quote_item', 'item_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php index 412ade472fc..742f97fe3f2 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Item/Option.php @@ -37,6 +37,6 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _construct() { - $this->_init('sales_flat_quote_item_option', 'option_id'); + $this->_init('sales_quote_item_option', 'option_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Quote/Payment.php b/app/code/Magento/Sales/Model/Resource/Quote/Payment.php index 22b0d7282e2..f1a2bf2bd5d 100644 --- a/app/code/Magento/Sales/Model/Resource/Quote/Payment.php +++ b/app/code/Magento/Sales/Model/Resource/Quote/Payment.php @@ -53,6 +53,6 @@ class Payment extends \Magento\Sales\Model\Resource\AbstractResource */ protected function _construct() { - $this->_init('sales_flat_quote_payment', 'payment_id'); + $this->_init('sales_quote_payment', 'payment_id'); } } diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php index 041bf7cdd92..52e2b866306 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php @@ -112,7 +112,7 @@ class Bestsellers extends AbstractReport try { if ($from !== null || $to !== null) { $subSelect = $this->_getTableDateRangeSelect( - $this->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'created_at', 'updated_at', $from, @@ -126,7 +126,7 @@ class Bestsellers extends AbstractReport // convert dates from UTC to current admin timezone $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( - array('source_table' => $this->getTable('sales_flat_order')), + array('source_table' => $this->getTable('sales_order')), 'source_table.created_at', $from, $to @@ -164,10 +164,10 @@ class Bestsellers extends AbstractReport ); $select->from( - array('source_table' => $this->getTable('sales_flat_order')), + array('source_table' => $this->getTable('sales_order')), $columns )->joinInner( - array('order_item' => $this->getTable('sales_flat_order_item')), + array('order_item' => $this->getTable('sales_order_item')), 'order_item.order_id = source_table.entity_id', array() )->where( diff --git a/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php b/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php index 6ca9e230b1c..053275809fe 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Invoiced.php @@ -72,8 +72,8 @@ class Invoiced extends AbstractReport protected function _aggregateByInvoiceCreatedAt($from, $to) { $table = $this->getTable('sales_invoiced_aggregated'); - $sourceTable = $this->getTable('sales_flat_invoice'); - $orderTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_invoice'); + $orderTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); @@ -195,7 +195,7 @@ class Invoiced extends AbstractReport protected function _aggregateByOrderCreatedAt($from, $to) { $table = $this->getTable('sales_invoiced_aggregated_order'); - $sourceTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); if ($from !== null || $to !== null) { diff --git a/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php b/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php index 76d39962ce1..062659b23fb 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Order/Createdat.php @@ -75,7 +75,7 @@ class Createdat extends \Magento\Sales\Model\Resource\Report\AbstractReport if ($from !== null || $to !== null) { $subSelect = $this->_getTableDateRangeSelect( - $this->getTable('sales_flat_order'), + $this->getTable('sales_order'), $aggregationField, $aggregationField, $from, @@ -88,7 +88,7 @@ class Createdat extends \Magento\Sales\Model\Resource\Report\AbstractReport $periodExpr = $adapter->getDatePartSql( $this->getStoreTZOffsetQuery( - array('o' => $this->getTable('sales_flat_order')), + array('o' => $this->getTable('sales_order')), 'o.' . $aggregationField, $from, $to @@ -221,7 +221,7 @@ class Createdat extends \Magento\Sales\Model\Resource\Report\AbstractReport 'total_qty_invoiced' => new \Zend_Db_Expr('SUM(qty_invoiced)') ); $selectOrderItem->from( - $this->getTable('sales_flat_order_item'), + $this->getTable('sales_order_item'), $cols )->where( 'parent_item_id IS NULL' @@ -230,7 +230,7 @@ class Createdat extends \Magento\Sales\Model\Resource\Report\AbstractReport ); $select->from( - array('o' => $this->getTable('sales_flat_order')), + array('o' => $this->getTable('sales_order')), $columns )->join( array('oi' => $selectOrderItem), diff --git a/app/code/Magento/Sales/Model/Resource/Report/Refunded.php b/app/code/Magento/Sales/Model/Resource/Report/Refunded.php index fc0042e8550..7be06fc1372 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Refunded.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Refunded.php @@ -72,7 +72,7 @@ class Refunded extends AbstractReport protected function _aggregateByOrderCreatedAt($from, $to) { $table = $this->getTable('sales_refunded_aggregated_order'); - $sourceTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); @@ -159,8 +159,8 @@ class Refunded extends AbstractReport protected function _aggregateByRefundCreatedAt($from, $to) { $table = $this->getTable('sales_refunded_aggregated'); - $sourceTable = $this->getTable('sales_flat_creditmemo'); - $orderTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_creditmemo'); + $orderTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); diff --git a/app/code/Magento/Sales/Model/Resource/Report/Shipping.php b/app/code/Magento/Sales/Model/Resource/Report/Shipping.php index ec939dec0c7..a8d78fe3b8e 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Shipping.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Shipping.php @@ -71,7 +71,7 @@ class Shipping extends AbstractReport protected function _aggregateByOrderCreatedAt($from, $to) { $table = $this->getTable('sales_shipping_aggregated_order'); - $sourceTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); @@ -163,8 +163,8 @@ class Shipping extends AbstractReport protected function _aggregateByShippingCreatedAt($from, $to) { $table = $this->getTable('sales_shipping_aggregated'); - $sourceTable = $this->getTable('sales_flat_invoice'); - $orderTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_invoice'); + $orderTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); diff --git a/app/code/Magento/Sales/Model/Resource/Setup.php b/app/code/Magento/Sales/Model/Resource/Setup.php index 81c2c7ba651..f5bdf638699 100644 --- a/app/code/Magento/Sales/Model/Resource/Setup.php +++ b/app/code/Magento/Sales/Model/Resource/Setup.php @@ -74,27 +74,27 @@ class Setup extends \Magento\Eav\Model\Entity\Setup * @var $_flatEntityTables array */ protected $_flatEntityTables = array( - 'quote' => 'sales_flat_quote', - 'quote_item' => 'sales_flat_quote_item', - 'quote_address' => 'sales_flat_quote_address', - 'quote_address_item' => 'sales_flat_quote_address_item', - 'quote_address_rate' => 'sales_flat_quote_shipping_rate', - 'quote_payment' => 'sales_flat_quote_payment', - 'order' => 'sales_flat_order', - 'order_payment' => 'sales_flat_order_payment', - 'order_item' => 'sales_flat_order_item', - 'order_address' => 'sales_flat_order_address', - 'order_status_history' => 'sales_flat_order_status_history', - 'invoice' => 'sales_flat_invoice', - 'invoice_item' => 'sales_flat_invoice_item', - 'invoice_comment' => 'sales_flat_invoice_comment', - 'creditmemo' => 'sales_flat_creditmemo', - 'creditmemo_item' => 'sales_flat_creditmemo_item', - 'creditmemo_comment' => 'sales_flat_creditmemo_comment', - 'shipment' => 'sales_flat_shipment', - 'shipment_item' => 'sales_flat_shipment_item', - 'shipment_track' => 'sales_flat_shipment_track', - 'shipment_comment' => 'sales_flat_shipment_comment' + 'quote' => 'sales_quote', + 'quote_item' => 'sales_quote_item', + 'quote_address' => 'sales_quote_address', + 'quote_address_item' => 'sales_quote_address_item', + 'quote_address_rate' => 'sales_quote_shipping_rate', + 'quote_payment' => 'sales_quote_payment', + 'order' => 'sales_order', + 'order_payment' => 'sales_order_payment', + 'order_item' => 'sales_order_item', + 'order_address' => 'sales_order_address', + 'order_status_history' => 'sales_order_status_history', + 'invoice' => 'sales_invoice', + 'invoice_item' => 'sales_invoice_item', + 'invoice_comment' => 'sales_invoice_comment', + 'creditmemo' => 'sales_creditmemo', + 'creditmemo_item' => 'sales_creditmemo_item', + 'creditmemo_comment' => 'sales_creditmemo_comment', + 'shipment' => 'sales_shipment', + 'shipment_item' => 'sales_shipment_item', + 'shipment_track' => 'sales_shipment_track', + 'shipment_comment' => 'sales_shipment_comment' ); /** @@ -232,28 +232,28 @@ class Setup extends \Magento\Eav\Model\Entity\Setup $entities = array( 'order' => array( 'entity_model' => 'Magento\Sales\Model\Resource\Order', - 'table' => 'sales_flat_order', + 'table' => 'sales_order', 'increment_model' => 'Magento\Eav\Model\Entity\Increment\Numeric', 'increment_per_store' => true, 'attributes' => array() ), 'invoice' => array( 'entity_model' => 'Magento\Sales\Model\Resource\Order\Invoice', - 'table' => 'sales_flat_invoice', + 'table' => 'sales_invoice', 'increment_model' => 'Magento\Eav\Model\Entity\Increment\Numeric', 'increment_per_store' => true, 'attributes' => array() ), 'creditmemo' => array( 'entity_model' => 'Magento\Sales\Model\Resource\Order\Creditmemo', - 'table' => 'sales_flat_creditmemo', + 'table' => 'sales_creditmemo', 'increment_model' => 'Magento\Eav\Model\Entity\Increment\Numeric', 'increment_per_store' => true, 'attributes' => array() ), 'shipment' => array( 'entity_model' => 'Magento\Sales\Model\Resource\Order\Shipment', - 'table' => 'sales_flat_shipment', + 'table' => 'sales_shipment', 'increment_model' => 'Magento\Eav\Model\Entity\Increment\Numeric', 'increment_per_store' => true, 'attributes' => array() diff --git a/app/code/Magento/Sales/composer.json b/app/code/Magento/Sales/composer.json index 4c296da9b42..cd8ebd2b68b 100644 --- a/app/code/Magento/Sales/composer.json +++ b/app/code/Magento/Sales/composer.json @@ -3,31 +3,31 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-authorization": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-sales-rule": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-gift-message": "0.1.0-alpha103", - "magento/module-reports": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-wishlist": "0.1.0-alpha103", - "magento/module-email": "0.1.0-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-authorization": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-sales-rule": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-gift-message": "0.1.0-alpha104", + "magento/module-reports": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-wishlist": "0.1.0-alpha104", + "magento/module-email": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/data/sales_setup/data-install-1.6.0.0.php b/app/code/Magento/Sales/data/sales_setup/data-install-2.0.0.php similarity index 71% rename from app/code/Magento/Sales/data/sales_setup/data-install-1.6.0.0.php rename to app/code/Magento/Sales/data/sales_setup/data-install-2.0.0.php index f8ca4ef8b20..d3e2be7af5d 100644 --- a/app/code/Magento/Sales/data/sales_setup/data-install-1.6.0.0.php +++ b/app/code/Magento/Sales/data/sales_setup/data-install-2.0.0.php @@ -22,13 +22,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Sales\Model\Resource\Setup */ -$installer = $this; +/** @var $this \Magento\Sales\Model\Resource\Setup */ /** * Install eav entity types to the eav/entity_type table */ -$installer->installEntities(); +$this->installEntities(); /** * Install order statuses from config @@ -48,7 +47,7 @@ $statuses = array( foreach ($statuses as $code => $info) { $data[] = array('status' => $code, 'label' => $info); } -$installer->getConnection()->insertArray($installer->getTable('sales_order_status'), array('status', 'label'), $data); +$this->getConnection()->insertArray($this->getTable('sales_order_status'), array('status', 'label'), $data); /** * Install order states from config @@ -107,8 +106,34 @@ foreach ($states as $code => $info) { } } } -$installer->getConnection()->insertArray( - $installer->getTable('sales_order_status_state'), +$this->getConnection()->insertArray( + $this->getTable('sales_order_status_state'), array('status', 'state', 'is_default'), $data ); + +$entitiesToAlter = array('quote_address', 'order_address'); + +$attributes = array( + 'vat_id' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), + 'vat_is_valid' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT), + 'vat_request_id' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), + 'vat_request_date' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), + 'vat_request_success' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT) +); + +foreach ($entitiesToAlter as $entityName) { + foreach ($attributes as $attributeCode => $attributeParams) { + $this->addAttribute($entityName, $attributeCode, $attributeParams); + } +} + +/** Update visibility for states */ +$states = array('new', 'processing', 'complete', 'closed', 'canceled', 'holded', 'payment_review'); +foreach ($states as $state) { + $this->getConnection()->update( + $this->getTable('sales_order_status_state'), + array('visible_on_front' => 1), + array('state = ?' => $state) + ); +} diff --git a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.php deleted file mode 100644 index 91eda509ce8..00000000000 --- a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.4-1.6.0.5.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) - */ - -/** @var $installer \Magento\Sales\Model\Resource\Setup */ -$installer = $this; - -$subSelect = $installer->getConnection()->select()->from( - array('citem' => $installer->getTable('sales_flat_creditmemo_item')), - array( - 'amount_refunded' => 'SUM(citem.row_total)', - 'base_amount_refunded' => 'SUM(citem.base_row_total)', - 'base_tax_refunded' => 'SUM(citem.base_tax_amount)', - 'discount_refunded' => 'SUM(citem.discount_amount)', - 'base_discount_refunded' => 'SUM(citem.base_discount_amount)' - ) -)->joinLeft( - array('c' => $installer->getTable('sales_flat_creditmemo')), - 'c.entity_id = citem.parent_id', - array() -)->joinLeft( - array('o' => $installer->getTable('sales_flat_order')), - 'o.entity_id = c.order_id', - array() -)->joinLeft( - array('oitem' => $installer->getTable('sales_flat_order_item')), - 'oitem.order_id = o.entity_id AND oitem.product_id=citem.product_id', - array('item_id') -)->group( - 'oitem.item_id' -); - -$select = $installer->getConnection()->select()->from( - array('selected' => $subSelect), - array( - 'amount_refunded' => 'amount_refunded', - 'base_amount_refunded' => 'base_amount_refunded', - 'base_tax_refunded' => 'base_tax_refunded', - 'discount_refunded' => 'discount_refunded', - 'base_discount_refunded' => 'base_discount_refunded' - ) -)->where( - 'main.item_id = selected.item_id' -); - -$updateQuery = $installer->getConnection()->updateFromSelect( - $select, - array('main' => $installer->getTable('sales_flat_order_item')) -); - -$installer->getConnection()->query($updateQuery); diff --git a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.5-1.6.0.6.php b/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.5-1.6.0.6.php deleted file mode 100644 index 65b677a8cb5..00000000000 --- a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.5-1.6.0.6.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Sales\Model\Resource\Setup */ -$installer = $this; - -$entitiesToAlter = array('quote_address', 'order_address'); - -$attributes = array( - 'vat_id' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), - 'vat_is_valid' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT), - 'vat_request_id' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), - 'vat_request_date' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT), - 'vat_request_success' => array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT) -); - -foreach ($entitiesToAlter as $entityName) { - foreach ($attributes as $attributeCode => $attributeParams) { - $installer->addAttribute($entityName, $attributeCode, $attributeParams); - } -} diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index 685910b9267..427b07dd443 100644 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Sales" schema_version="1.6.0.12" active="true"> + <module name="Magento_Sales" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Rule"/> <module name="Magento_Catalog"/> diff --git a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php similarity index 85% rename from app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php rename to app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php index 408e985eb95..ad5fb72ba01 100644 --- a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php +++ b/app/code/Magento/Sales/sql/sales_setup/install-2.0.0.php @@ -22,15 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->startSetup(); +/** @var $this \Magento\Sales\Model\Resource\Setup */ +$this->startSetup(); /** - * Create table 'sales_flat_order' + * Create table 'sales_order' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -835,62 +834,68 @@ $table = $installer->getConnection()->newTable( '12,4', array(), 'Base Shipping Incl Tax' +)->addColumn( + 'coupon_rule_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array('nullable' => true), + 'Coupon Sales Rule Name' )->addIndex( - $installer->getIdxName('sales_flat_order', array('status')), + $this->getIdxName('sales_order', array('status')), array('status') )->addIndex( - $installer->getIdxName('sales_flat_order', array('state')), + $this->getIdxName('sales_order', array('state')), array('state') )->addIndex( - $installer->getIdxName('sales_flat_order', array('store_id')), + $this->getIdxName('sales_order', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName( - 'sales_flat_order', + $this->getIdxName( + 'sales_order', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_order', array('created_at')), + $this->getIdxName('sales_order', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_order', array('customer_id')), + $this->getIdxName('sales_order', array('customer_id')), array('customer_id') )->addIndex( - $installer->getIdxName('sales_flat_order', array('ext_order_id')), + $this->getIdxName('sales_order', array('ext_order_id')), array('ext_order_id') )->addIndex( - $installer->getIdxName('sales_flat_order', array('quote_id')), + $this->getIdxName('sales_order', array('quote_id')), array('quote_id') )->addIndex( - $installer->getIdxName('sales_flat_order', array('updated_at')), + $this->getIdxName('sales_order', array('updated_at')), array('updated_at') )->addForeignKey( - $installer->getFkName('sales_flat_order', 'customer_id', 'customer_entity', 'entity_id'), + $this->getFkName('sales_order', 'customer_id', 'customer_entity', 'entity_id'), 'customer_id', - $installer->getTable('customer_entity'), + $this->getTable('customer_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_order', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_order', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_order_grid' + * Create table 'sales_order_grid' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order_grid') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_grid') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -988,78 +993,78 @@ $table = $installer->getConnection()->newTable( array(), 'Updated At' )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('status')), + $this->getIdxName('sales_order_grid', array('status')), array('status') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('store_id')), + $this->getIdxName('sales_order_grid', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('base_grand_total')), + $this->getIdxName('sales_order_grid', array('base_grand_total')), array('base_grand_total') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('base_total_paid')), + $this->getIdxName('sales_order_grid', array('base_total_paid')), array('base_total_paid') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('grand_total')), + $this->getIdxName('sales_order_grid', array('grand_total')), array('grand_total') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('total_paid')), + $this->getIdxName('sales_order_grid', array('total_paid')), array('total_paid') )->addIndex( - $installer->getIdxName( - 'sales_flat_order_grid', + $this->getIdxName( + 'sales_order_grid', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('shipping_name')), + $this->getIdxName('sales_order_grid', array('shipping_name')), array('shipping_name') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('billing_name')), + $this->getIdxName('sales_order_grid', array('billing_name')), array('billing_name') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('created_at')), + $this->getIdxName('sales_order_grid', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('customer_id')), + $this->getIdxName('sales_order_grid', array('customer_id')), array('customer_id') )->addIndex( - $installer->getIdxName('sales_flat_order_grid', array('updated_at')), + $this->getIdxName('sales_order_grid', array('updated_at')), array('updated_at') )->addForeignKey( - $installer->getFkName('sales_flat_order_grid', 'customer_id', 'customer_entity', 'entity_id'), + $this->getFkName('sales_order_grid', 'customer_id', 'customer_entity', 'entity_id'), 'customer_id', - $installer->getTable('customer_entity'), + $this->getTable('customer_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_order_grid', 'entity_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_order_grid', 'entity_id', 'sales_order', 'entity_id'), 'entity_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_order_grid', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_order_grid', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order Grid' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_order_address' + * Create table 'sales_order_address' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order_address') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_address') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -1187,26 +1192,26 @@ $table = $installer->getConnection()->newTable( array(), 'Company' )->addIndex( - $installer->getIdxName('sales_flat_order_address', array('parent_id')), + $this->getIdxName('sales_order_address', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_order_address', 'parent_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_order_address', 'parent_id', 'sales_order', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order Address' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_order_status_history' + * Create table 'sales_order_status_history' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order_status_history') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_status_history') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -1249,30 +1254,36 @@ $table = $installer->getConnection()->newTable( null, array(), 'Created At' +)->addColumn( + 'entity_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 32, + array('nullable' => true), + 'Shows what entity history is bind to.' )->addIndex( - $installer->getIdxName('sales_flat_order_status_history', array('parent_id')), + $this->getIdxName('sales_order_status_history', array('parent_id')), array('parent_id') )->addIndex( - $installer->getIdxName('sales_flat_order_status_history', array('created_at')), + $this->getIdxName('sales_order_status_history', array('created_at')), array('created_at') )->addForeignKey( - $installer->getFkName('sales_flat_order_status_history', 'parent_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_order_status_history', 'parent_id', 'sales_order', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order Status History' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_order_item' + * Create table 'sales_order_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_item') )->addColumn( 'item_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -1669,37 +1680,54 @@ $table = $installer->getConnection()->newTable( '12,4', array(), 'Tax Refunded' +)->addColumn( + 'base_tax_refunded', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + array(), + 'Base Tax Refunded' +)->addColumn( + 'discount_refunded', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + array(), + 'Discount Refunded' +)->addColumn( + 'base_discount_refunded', + \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, + '12,4', + array(), + 'Base Discount Refunded' )->addIndex( - $installer->getIdxName('sales_flat_order_item', array('order_id')), + $this->getIdxName('sales_order_item', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_order_item', array('store_id')), + $this->getIdxName('sales_order_item', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_flat_order_item', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_order_item', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_order_item', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_order_item', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order Item' ); -$installer->getConnection()->createTable($table); - +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_order_payment' + * Create table 'sales_order_payment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_order_payment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_payment') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -1950,7 +1978,7 @@ $table = $installer->getConnection()->newTable( 'cc_exp_year', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, - array(), + array('nullable' => true, 'default' => null), 'Cc Exp Year' )->addColumn( 'cc_status', @@ -2025,26 +2053,26 @@ $table = $installer->getConnection()->newTable( array(), 'Additional Information' )->addIndex( - $installer->getIdxName('sales_flat_order_payment', array('parent_id')), + $this->getIdxName('sales_order_payment', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_order_payment', 'parent_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_order_payment', 'parent_id', 'sales_order', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Order Payment' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_shipment' + * Create table 'sales_shipment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_shipment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipment') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2123,54 +2151,65 @@ $table = $installer->getConnection()->newTable( null, array(), 'Updated At' +)->addColumn( + 'packages', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + '20000', + array(), + 'Packed Products in Packages' +)->addColumn( + 'shipping_label', + \Magento\Framework\DB\Ddl\Table::TYPE_VARBINARY, + '2m', + array(), + 'Shipping Label Content' )->addIndex( - $installer->getIdxName('sales_flat_shipment', array('store_id')), + $this->getIdxName('sales_shipment', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment', array('total_qty')), + $this->getIdxName('sales_shipment', array('total_qty')), array('total_qty') )->addIndex( - $installer->getIdxName( - 'sales_flat_shipment', + $this->getIdxName( + 'sales_shipment', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_shipment', array('order_id')), + $this->getIdxName('sales_shipment', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment', array('created_at')), + $this->getIdxName('sales_shipment', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_shipment', array('updated_at')), + $this->getIdxName('sales_shipment', array('updated_at')), array('updated_at') )->addForeignKey( - $installer->getFkName('sales_flat_shipment', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_shipment', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_shipment', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_shipment', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Shipment' ); -$installer->getConnection()->createTable($table); - +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_shipment_grid' + * Create table 'sales_shipment_grid' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_shipment_grid') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipment_grid') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2232,62 +2271,62 @@ $table = $installer->getConnection()->newTable( array(), 'Shipping Name' )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('store_id')), + $this->getIdxName('sales_shipment_grid', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('total_qty')), + $this->getIdxName('sales_shipment_grid', array('total_qty')), array('total_qty') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('order_id')), + $this->getIdxName('sales_shipment_grid', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('shipment_status')), + $this->getIdxName('sales_shipment_grid', array('shipment_status')), array('shipment_status') )->addIndex( - $installer->getIdxName( - 'sales_flat_shipment_grid', + $this->getIdxName( + 'sales_shipment_grid', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('order_increment_id')), + $this->getIdxName('sales_shipment_grid', array('order_increment_id')), array('order_increment_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('created_at')), + $this->getIdxName('sales_shipment_grid', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('order_created_at')), + $this->getIdxName('sales_shipment_grid', array('order_created_at')), array('order_created_at') )->addIndex( - $installer->getIdxName('sales_flat_shipment_grid', array('shipping_name')), + $this->getIdxName('sales_shipment_grid', array('shipping_name')), array('shipping_name') )->addForeignKey( - $installer->getFkName('sales_flat_shipment_grid', 'entity_id', 'sales_flat_shipment', 'entity_id'), + $this->getFkName('sales_shipment_grid', 'entity_id', 'sales_shipment', 'entity_id'), 'entity_id', - $installer->getTable('sales_flat_shipment'), + $this->getTable('sales_shipment'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_shipment_grid', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_shipment_grid', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Shipment Grid' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_shipment_item' + * Create table 'sales_shipment_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_shipment_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipment_item') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2361,26 +2400,26 @@ $table = $installer->getConnection()->newTable( array(), 'Sku' )->addIndex( - $installer->getIdxName('sales_flat_shipment_item', array('parent_id')), + $this->getIdxName('sales_shipment_item', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_shipment_item', 'parent_id', 'sales_flat_shipment', 'entity_id'), + $this->getFkName('sales_shipment_item', 'parent_id', 'sales_shipment', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_shipment'), + $this->getTable('sales_shipment'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Shipment Item' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_shipment_track' + * Create table 'sales_shipment_track' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_shipment_track') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipment_track') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2448,32 +2487,32 @@ $table = $installer->getConnection()->newTable( array(), 'Updated At' )->addIndex( - $installer->getIdxName('sales_flat_shipment_track', array('parent_id')), + $this->getIdxName('sales_shipment_track', array('parent_id')), array('parent_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment_track', array('order_id')), + $this->getIdxName('sales_shipment_track', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_shipment_track', array('created_at')), + $this->getIdxName('sales_shipment_track', array('created_at')), array('created_at') )->addForeignKey( - $installer->getFkName('sales_flat_shipment_track', 'parent_id', 'sales_flat_shipment', 'entity_id'), + $this->getFkName('sales_shipment_track', 'parent_id', 'sales_shipment', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_shipment'), + $this->getTable('sales_shipment'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Shipment Track' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_shipment_comment' + * Create table 'sales_shipment_comment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_shipment_comment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipment_comment') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2511,29 +2550,29 @@ $table = $installer->getConnection()->newTable( array(), 'Created At' )->addIndex( - $installer->getIdxName('sales_flat_shipment_comment', array('created_at')), + $this->getIdxName('sales_shipment_comment', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_shipment_comment', array('parent_id')), + $this->getIdxName('sales_shipment_comment', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_shipment_comment', 'parent_id', 'sales_flat_shipment', 'entity_id'), + $this->getFkName('sales_shipment_comment', 'parent_id', 'sales_shipment', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_shipment'), + $this->getTable('sales_shipment'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Shipment Comment' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_invoice' + * Create table 'sales_invoice' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_invoice') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoice') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2792,54 +2831,60 @@ $table = $installer->getConnection()->newTable( '12,4', array(), 'Base Total Refunded' +)->addColumn( + 'discount_description', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Discount Description' )->addIndex( - $installer->getIdxName('sales_flat_invoice', array('store_id')), + $this->getIdxName('sales_invoice', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_invoice', array('grand_total')), + $this->getIdxName('sales_invoice', array('grand_total')), array('grand_total') )->addIndex( - $installer->getIdxName('sales_flat_invoice', array('order_id')), + $this->getIdxName('sales_invoice', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_invoice', array('state')), + $this->getIdxName('sales_invoice', array('state')), array('state') )->addIndex( - $installer->getIdxName( - 'sales_flat_invoice', + $this->getIdxName( + 'sales_invoice', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_invoice', array('created_at')), + $this->getIdxName('sales_invoice', array('created_at')), array('created_at') )->addForeignKey( - $installer->getFkName('sales_flat_invoice', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_invoice', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_invoice', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_invoice', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Invoice' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_invoice_grid' + * Create table 'sales_invoice_grid' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_invoice_grid') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoice_grid') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -2931,62 +2976,62 @@ $table = $installer->getConnection()->newTable( array(), 'Billing Name' )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('store_id')), + $this->getIdxName('sales_invoice_grid', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('grand_total')), + $this->getIdxName('sales_invoice_grid', array('grand_total')), array('grand_total') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('order_id')), + $this->getIdxName('sales_invoice_grid', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('state')), + $this->getIdxName('sales_invoice_grid', array('state')), array('state') )->addIndex( - $installer->getIdxName( - 'sales_flat_invoice_grid', + $this->getIdxName( + 'sales_invoice_grid', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('order_increment_id')), + $this->getIdxName('sales_invoice_grid', array('order_increment_id')), array('order_increment_id') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('created_at')), + $this->getIdxName('sales_invoice_grid', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('order_created_at')), + $this->getIdxName('sales_invoice_grid', array('order_created_at')), array('order_created_at') )->addIndex( - $installer->getIdxName('sales_flat_invoice_grid', array('billing_name')), + $this->getIdxName('sales_invoice_grid', array('billing_name')), array('billing_name') )->addForeignKey( - $installer->getFkName('sales_flat_invoice_grid', 'entity_id', 'sales_flat_invoice', 'entity_id'), + $this->getFkName('sales_invoice_grid', 'entity_id', 'sales_invoice', 'entity_id'), 'entity_id', - $installer->getTable('sales_flat_invoice'), + $this->getTable('sales_invoice'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_invoice_grid', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_invoice_grid', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Invoice Grid' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_invoice_item' + * Create table 'sales_invoice_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_invoice_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoice_item') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3132,26 +3177,26 @@ $table = $installer->getConnection()->newTable( array(), 'Base Hidden Tax Amount' )->addIndex( - $installer->getIdxName('sales_flat_invoice_item', array('parent_id')), + $this->getIdxName('sales_invoice_item', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_invoice_item', 'parent_id', 'sales_flat_invoice', 'entity_id'), + $this->getFkName('sales_invoice_item', 'parent_id', 'sales_invoice', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_invoice'), + $this->getTable('sales_invoice'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Invoice Item' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_invoice_comment' + * Create table 'sales_invoice_comment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_invoice_comment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoice_comment') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3189,29 +3234,29 @@ $table = $installer->getConnection()->newTable( array(), 'Created At' )->addIndex( - $installer->getIdxName('sales_flat_invoice_comment', array('created_at')), + $this->getIdxName('sales_invoice_comment', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_invoice_comment', array('parent_id')), + $this->getIdxName('sales_invoice_comment', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_invoice_comment', 'parent_id', 'sales_flat_invoice', 'entity_id'), + $this->getFkName('sales_invoice_comment', 'parent_id', 'sales_invoice', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_invoice'), + $this->getTable('sales_invoice'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Invoice Comment' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_creditmemo' + * Create table 'sales_creditmemo' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_creditmemo') +$table = $this->getConnection()->newTable( + $this->getTable('sales_creditmemo') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3494,54 +3539,60 @@ $table = $installer->getConnection()->newTable( '12,4', array(), 'Base Shipping Incl Tax' +)->addColumn( + 'discount_description', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Discount Description' )->addIndex( - $installer->getIdxName('sales_flat_creditmemo', array('store_id')), + $this->getIdxName('sales_creditmemo', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo', array('order_id')), + $this->getIdxName('sales_creditmemo', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo', array('creditmemo_status')), + $this->getIdxName('sales_creditmemo', array('creditmemo_status')), array('creditmemo_status') )->addIndex( - $installer->getIdxName( - 'sales_flat_creditmemo', + $this->getIdxName( + 'sales_creditmemo', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_creditmemo', array('state')), + $this->getIdxName('sales_creditmemo', array('state')), array('state') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo', array('created_at')), + $this->getIdxName('sales_creditmemo', array('created_at')), array('created_at') )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_creditmemo', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_creditmemo', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Creditmemo' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_creditmemo_grid' + * Create table 'sales_creditmemo_grid' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_creditmemo_grid') +$table = $this->getConnection()->newTable( + $this->getTable('sales_creditmemo_grid') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3669,68 +3720,68 @@ $table = $installer->getConnection()->newTable( array(), 'Billing Name' )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('store_id')), + $this->getIdxName('sales_creditmemo_grid', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('grand_total')), + $this->getIdxName('sales_creditmemo_grid', array('grand_total')), array('grand_total') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('base_grand_total')), + $this->getIdxName('sales_creditmemo_grid', array('base_grand_total')), array('base_grand_total') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('order_id')), + $this->getIdxName('sales_creditmemo_grid', array('order_id')), array('order_id') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('creditmemo_status')), + $this->getIdxName('sales_creditmemo_grid', array('creditmemo_status')), array('creditmemo_status') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('state')), + $this->getIdxName('sales_creditmemo_grid', array('state')), array('state') )->addIndex( - $installer->getIdxName( - 'sales_flat_creditmemo_grid', + $this->getIdxName( + 'sales_creditmemo_grid', array('increment_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ), array('increment_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('order_increment_id')), + $this->getIdxName('sales_creditmemo_grid', array('order_increment_id')), array('order_increment_id') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('created_at')), + $this->getIdxName('sales_creditmemo_grid', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('order_created_at')), + $this->getIdxName('sales_creditmemo_grid', array('order_created_at')), array('order_created_at') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_grid', array('billing_name')), + $this->getIdxName('sales_creditmemo_grid', array('billing_name')), array('billing_name') )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo_grid', 'entity_id', 'sales_flat_creditmemo', 'entity_id'), + $this->getFkName('sales_creditmemo_grid', 'entity_id', 'sales_creditmemo', 'entity_id'), 'entity_id', - $installer->getTable('sales_flat_creditmemo'), + $this->getTable('sales_creditmemo'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo_grid', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_creditmemo_grid', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Creditmemo Grid' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_creditmemo_item' + * Create table 'sales_creditmemo_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_creditmemo_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_creditmemo_item') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3876,25 +3927,25 @@ $table = $installer->getConnection()->newTable( array(), 'Base Hidden Tax Amount' )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_item', array('parent_id')), + $this->getIdxName('sales_creditmemo_item', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo_item', 'parent_id', 'sales_flat_creditmemo', 'entity_id'), + $this->getFkName('sales_creditmemo_item', 'parent_id', 'sales_creditmemo', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_creditmemo'), + $this->getTable('sales_creditmemo'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Creditmemo Item' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_creditmemo_comment' + * Create table 'sales_creditmemo_comment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_creditmemo_comment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_creditmemo_comment') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -3932,29 +3983,29 @@ $table = $installer->getConnection()->newTable( array(), 'Created At' )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_comment', array('created_at')), + $this->getIdxName('sales_creditmemo_comment', array('created_at')), array('created_at') )->addIndex( - $installer->getIdxName('sales_flat_creditmemo_comment', array('parent_id')), + $this->getIdxName('sales_creditmemo_comment', array('parent_id')), array('parent_id') )->addForeignKey( - $installer->getFkName('sales_flat_creditmemo_comment', 'parent_id', 'sales_flat_creditmemo', 'entity_id'), + $this->getFkName('sales_creditmemo_comment', 'parent_id', 'sales_creditmemo', 'entity_id'), 'parent_id', - $installer->getTable('sales_flat_creditmemo'), + $this->getTable('sales_creditmemo'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Creditmemo Comment' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote' + * Create table 'sales_quote' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote') )->addColumn( 'entity_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -4250,29 +4301,29 @@ $table = $installer->getConnection()->newTable( array(), 'Ext Shipping Info' )->addIndex( - $installer->getIdxName('sales_flat_quote', array('customer_id', 'store_id', 'is_active')), + $this->getIdxName('sales_quote', array('customer_id', 'store_id', 'is_active')), array('customer_id', 'store_id', 'is_active') )->addIndex( - $installer->getIdxName('sales_flat_quote', array('store_id')), + $this->getIdxName('sales_quote', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_quote', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_address' + * Create table 'sales_quote_address' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_address') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_address') )->addColumn( 'address_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -4604,26 +4655,26 @@ $table = $installer->getConnection()->newTable( array(), 'Base Shipping Incl Tax' )->addIndex( - $installer->getIdxName('sales_flat_quote_address', array('quote_id')), + $this->getIdxName('sales_quote_address', array('quote_id')), array('quote_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote_address', 'quote_id', 'sales_flat_quote', 'entity_id'), + $this->getFkName('sales_quote_address', 'quote_id', 'sales_quote', 'entity_id'), 'quote_id', - $installer->getTable('sales_flat_quote'), + $this->getTable('sales_quote'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Address' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_item' + * Create table 'sales_quote_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_item') )->addColumn( 'item_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -4877,55 +4928,55 @@ $table = $installer->getConnection()->newTable( array(), 'Base Hidden Tax Amount' )->addIndex( - $installer->getIdxName('sales_flat_quote_item', array('parent_item_id')), + $this->getIdxName('sales_quote_item', array('parent_item_id')), array('parent_item_id') )->addIndex( - $installer->getIdxName('sales_flat_quote_item', array('product_id')), + $this->getIdxName('sales_quote_item', array('product_id')), array('product_id') )->addIndex( - $installer->getIdxName('sales_flat_quote_item', array('quote_id')), + $this->getIdxName('sales_quote_item', array('quote_id')), array('quote_id') )->addIndex( - $installer->getIdxName('sales_flat_quote_item', array('store_id')), + $this->getIdxName('sales_quote_item', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote_item', 'parent_item_id', 'sales_flat_quote_item', 'item_id'), + $this->getFkName('sales_quote_item', 'parent_item_id', 'sales_quote_item', 'item_id'), 'parent_item_id', - $installer->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), 'item_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_quote_item', 'product_id', 'catalog_product_entity', 'entity_id'), + $this->getFkName('sales_quote_item', 'product_id', 'catalog_product_entity', 'entity_id'), 'product_id', - $installer->getTable('catalog_product_entity'), + $this->getTable('catalog_product_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_quote_item', 'quote_id', 'sales_flat_quote', 'entity_id'), + $this->getFkName('sales_quote_item', 'quote_id', 'sales_quote', 'entity_id'), 'quote_id', - $installer->getTable('sales_flat_quote'), + $this->getTable('sales_quote'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_quote_item', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_quote_item', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Item' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_address_item' + * Create table 'sales_quote_address_item' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_address_item') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_address_item') )->addColumn( 'address_item_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5155,56 +5206,56 @@ $table = $installer->getConnection()->newTable( array(), 'Base Hidden Tax Amount' )->addIndex( - $installer->getIdxName('sales_flat_quote_address_item', array('quote_address_id')), + $this->getIdxName('sales_quote_address_item', array('quote_address_id')), array('quote_address_id') )->addIndex( - $installer->getIdxName('sales_flat_quote_address_item', array('parent_item_id')), + $this->getIdxName('sales_quote_address_item', array('parent_item_id')), array('parent_item_id') )->addIndex( - $installer->getIdxName('sales_flat_quote_address_item', array('quote_item_id')), + $this->getIdxName('sales_quote_address_item', array('quote_item_id')), array('quote_item_id') )->addForeignKey( - $installer->getFkName( - 'sales_flat_quote_address_item', + $this->getFkName( + 'sales_quote_address_item', 'quote_address_id', - 'sales_flat_quote_address', + 'sales_quote_address', 'address_id' ), 'quote_address_id', - $installer->getTable('sales_flat_quote_address'), + $this->getTable('sales_quote_address'), 'address_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName( - 'sales_flat_quote_address_item', + $this->getFkName( + 'sales_quote_address_item', 'parent_item_id', - 'sales_flat_quote_address_item', + 'sales_quote_address_item', 'address_item_id' ), 'parent_item_id', - $installer->getTable('sales_flat_quote_address_item'), + $this->getTable('sales_quote_address_item'), 'address_item_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_flat_quote_address_item', 'quote_item_id', 'sales_flat_quote_item', 'item_id'), + $this->getFkName('sales_quote_address_item', 'quote_item_id', 'sales_quote_item', 'item_id'), 'quote_item_id', - $installer->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), 'item_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Address Item' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_item_option' + * Create table 'sales_quote_item_option' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_item_option') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_item_option') )->addColumn( 'option_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5236,26 +5287,26 @@ $table = $installer->getConnection()->newTable( array(), 'Value' )->addIndex( - $installer->getIdxName('sales_flat_quote_item_option', array('item_id')), + $this->getIdxName('sales_quote_item_option', array('item_id')), array('item_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote_item_option', 'item_id', 'sales_flat_quote_item', 'item_id'), + $this->getFkName('sales_quote_item_option', 'item_id', 'sales_quote_item', 'item_id'), 'item_id', - $installer->getTable('sales_flat_quote_item'), + $this->getTable('sales_quote_item'), 'item_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Item Option' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_payment' + * Create table 'sales_quote_payment' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_payment') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_payment') )->addColumn( 'payment_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5318,9 +5369,9 @@ $table = $installer->getConnection()->newTable( 'Cc Owner' )->addColumn( 'cc_exp_month', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'default' => '0'), + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array('unsigned' => true, 'default' => null, 'nullable' => true), 'Cc Exp Month' )->addColumn( 'cc_exp_year', @@ -5371,26 +5422,26 @@ $table = $installer->getConnection()->newTable( array(), 'Additional Information' )->addIndex( - $installer->getIdxName('sales_flat_quote_payment', array('quote_id')), + $this->getIdxName('sales_quote_payment', array('quote_id')), array('quote_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote_payment', 'quote_id', 'sales_flat_quote', 'entity_id'), + $this->getFkName('sales_quote_payment', 'quote_id', 'sales_quote', 'entity_id'), 'quote_id', - $installer->getTable('sales_flat_quote'), + $this->getTable('sales_quote'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Payment' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** - * Create table 'sales_flat_quote_shipping_rate' + * Create table 'sales_quote_shipping_rate' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_flat_quote_shipping_rate') +$table = $this->getConnection()->newTable( + $this->getTable('sales_quote_shipping_rate') )->addColumn( 'rate_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5464,26 +5515,26 @@ $table = $installer->getConnection()->newTable( array(), 'Method Title' )->addIndex( - $installer->getIdxName('sales_flat_quote_shipping_rate', array('address_id')), + $this->getIdxName('sales_quote_shipping_rate', array('address_id')), array('address_id') )->addForeignKey( - $installer->getFkName('sales_flat_quote_shipping_rate', 'address_id', 'sales_flat_quote_address', 'address_id'), + $this->getFkName('sales_quote_shipping_rate', 'address_id', 'sales_quote_address', 'address_id'), 'address_id', - $installer->getTable('sales_flat_quote_address'), + $this->getTable('sales_quote_address'), 'address_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Flat Quote Shipping Rate' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_invoiced_aggregated' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoiced_aggregated') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoiced_aggregated') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5539,7 +5590,7 @@ $table = $installer->getConnection()->newTable( array(), 'Invoiced Not Captured' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_invoiced_aggregated', array('period', 'store_id', 'order_status'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -5547,26 +5598,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_invoiced_aggregated', array('store_id')), + $this->getIdxName('sales_invoiced_aggregated', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_invoiced_aggregated', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_invoiced_aggregated', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Invoiced Aggregated' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_invoiced_aggregated_order' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoiced_aggregated_order') +$table = $this->getConnection()->newTable( + $this->getTable('sales_invoiced_aggregated_order') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5622,7 +5673,7 @@ $table = $installer->getConnection()->newTable( array(), 'Invoiced Not Captured' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_invoiced_aggregated_order', array('period', 'store_id', 'order_status'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -5630,26 +5681,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_invoiced_aggregated_order', array('store_id')), + $this->getIdxName('sales_invoiced_aggregated_order', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_invoiced_aggregated_order', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_invoiced_aggregated_order', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Invoiced Aggregated Order' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_order_aggregated_created' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_aggregated_created') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_aggregated_created') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5771,7 +5822,7 @@ $table = $installer->getConnection()->newTable( array('nullable' => false, 'default' => '0.0000'), 'Total Discount Amount Actual' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_order_aggregated_created', array('period', 'store_id', 'order_status'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -5779,26 +5830,33 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_order_aggregated_created', array('store_id')), + $this->getIdxName('sales_order_aggregated_created', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_order_aggregated_created', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_order_aggregated_created', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Order Aggregated Created' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); + +$this->getConnection()->createTable( + $this->getConnection()->createTableByDdl( + $this->getTable('sales_order_aggregated_created'), + $this->getTable('sales_order_aggregated_updated') + ) +); /** * Create table 'sales_payment_transaction' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_payment_transaction') +$table = $this->getConnection()->newTable( + $this->getTable('sales_payment_transaction') )->addColumn( 'transaction_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5860,7 +5918,7 @@ $table = $installer->getConnection()->newTable( array(), 'Created At' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_payment_transaction', array('order_id', 'payment_id', 'txn_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -5868,43 +5926,43 @@ $table = $installer->getConnection()->newTable( array('order_id', 'payment_id', 'txn_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_payment_transaction', array('parent_id')), + $this->getIdxName('sales_payment_transaction', array('parent_id')), array('parent_id') )->addIndex( - $installer->getIdxName('sales_payment_transaction', array('payment_id')), + $this->getIdxName('sales_payment_transaction', array('payment_id')), array('payment_id') )->addForeignKey( - $installer->getFkName('sales_payment_transaction', 'order_id', 'sales_flat_order', 'entity_id'), + $this->getFkName('sales_payment_transaction', 'order_id', 'sales_order', 'entity_id'), 'order_id', - $installer->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_payment_transaction', 'parent_id', 'sales_payment_transaction', 'transaction_id'), + $this->getFkName('sales_payment_transaction', 'parent_id', 'sales_payment_transaction', 'transaction_id'), 'parent_id', - $installer->getTable('sales_payment_transaction'), + $this->getTable('sales_payment_transaction'), 'transaction_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_payment_transaction', 'payment_id', 'sales_flat_order_payment', 'entity_id'), + $this->getFkName('sales_payment_transaction', 'payment_id', 'sales_order_payment', 'entity_id'), 'payment_id', - $installer->getTable('sales_flat_order_payment'), + $this->getTable('sales_order_payment'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Payment Transaction' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_refunded_aggregated' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_refunded_aggregated') +$table = $this->getConnection()->newTable( + $this->getTable('sales_refunded_aggregated') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -5954,7 +6012,7 @@ $table = $installer->getConnection()->newTable( array(), 'Offline Refunded' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_refunded_aggregated', array('period', 'store_id', 'order_status'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -5962,26 +6020,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_refunded_aggregated', array('store_id')), + $this->getIdxName('sales_refunded_aggregated', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_refunded_aggregated', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_refunded_aggregated', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Refunded Aggregated' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_refunded_aggregated_order' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_refunded_aggregated_order') +$table = $this->getConnection()->newTable( + $this->getTable('sales_refunded_aggregated_order') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6031,7 +6089,7 @@ $table = $installer->getConnection()->newTable( array(), 'Offline Refunded' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_refunded_aggregated_order', array('period', 'store_id', 'order_status'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6039,26 +6097,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_refunded_aggregated_order', array('store_id')), + $this->getIdxName('sales_refunded_aggregated_order', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_refunded_aggregated_order', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_refunded_aggregated_order', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Refunded Aggregated Order' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_shipping_aggregated' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipping_aggregated') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipping_aggregated') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6108,7 +6166,7 @@ $table = $installer->getConnection()->newTable( array(), 'Total Shipping Actual' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_shipping_aggregated', array('period', 'store_id', 'order_status', 'shipping_description'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6116,26 +6174,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status', 'shipping_description'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_shipping_aggregated', array('store_id')), + $this->getIdxName('sales_shipping_aggregated', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_shipping_aggregated', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_shipping_aggregated', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Shipping Aggregated' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_shipping_aggregated_order' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipping_aggregated_order') +$table = $this->getConnection()->newTable( + $this->getTable('sales_shipping_aggregated_order') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6185,7 +6243,7 @@ $table = $installer->getConnection()->newTable( array(), 'Total Shipping Actual' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_shipping_aggregated_order', array('period', 'store_id', 'order_status', 'shipping_description'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6193,26 +6251,26 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status', 'shipping_description'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_shipping_aggregated_order', array('store_id')), + $this->getIdxName('sales_shipping_aggregated_order', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_shipping_aggregated_order', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_shipping_aggregated_order', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Shipping Aggregated Order' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_bestsellers_aggregated_daily' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_daily') +$table = $this->getConnection()->newTable( + $this->getTable('sales_bestsellers_aggregated_daily') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6262,7 +6320,7 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Rating Pos' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_bestsellers_aggregated_daily', array('period', 'store_id', 'product_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6270,36 +6328,36 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'product_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_daily', array('store_id')), + $this->getIdxName('sales_bestsellers_aggregated_daily', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_daily', array('product_id')), + $this->getIdxName('sales_bestsellers_aggregated_daily', array('product_id')), array('product_id') )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_daily', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_bestsellers_aggregated_daily', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_daily', 'product_id', 'catalog_product_entity', 'entity_id'), + $this->getFkName('sales_bestsellers_aggregated_daily', 'product_id', 'catalog_product_entity', 'entity_id'), 'product_id', - $installer->getTable('catalog_product_entity'), + $this->getTable('catalog_product_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Daily' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_bestsellers_aggregated_monthly' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_monthly') +$table = $this->getConnection()->newTable( + $this->getTable('sales_bestsellers_aggregated_monthly') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6349,7 +6407,7 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Rating Pos' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_bestsellers_aggregated_monthly', array('period', 'store_id', 'product_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6357,35 +6415,35 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'product_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_monthly', array('store_id')), + $this->getIdxName('sales_bestsellers_aggregated_monthly', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_monthly', array('product_id')), + $this->getIdxName('sales_bestsellers_aggregated_monthly', array('product_id')), array('product_id') )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_monthly', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_bestsellers_aggregated_monthly', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_monthly', 'product_id', 'catalog_product_entity', 'entity_id'), + $this->getFkName('sales_bestsellers_aggregated_monthly', 'product_id', 'catalog_product_entity', 'entity_id'), 'product_id', - $installer->getTable('catalog_product_entity'), + $this->getTable('catalog_product_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Monthly' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_bestsellers_aggregated_yearly' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_yearly') +$table = $this->getConnection()->newTable( + $this->getTable('sales_bestsellers_aggregated_yearly') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6435,7 +6493,7 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Rating Pos' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'sales_bestsellers_aggregated_yearly', array('period', 'store_id', 'product_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -6443,35 +6501,35 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'product_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_yearly', array('store_id')), + $this->getIdxName('sales_bestsellers_aggregated_yearly', array('store_id')), array('store_id') )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_yearly', array('product_id')), + $this->getIdxName('sales_bestsellers_aggregated_yearly', array('product_id')), array('product_id') )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_yearly', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_bestsellers_aggregated_yearly', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_yearly', 'product_id', 'catalog_product_entity', 'entity_id'), + $this->getFkName('sales_bestsellers_aggregated_yearly', 'product_id', 'catalog_product_entity', 'entity_id'), 'product_id', - $installer->getTable('catalog_product_entity'), + $this->getTable('catalog_product_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Bestsellers Aggregated Yearly' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_order_tax' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_tax') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_tax') )->addColumn( 'tax_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -6545,19 +6603,19 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Hidden' )->addIndex( - $installer->getIdxName('sales_order_tax', array('order_id', 'priority', 'position')), + $this->getIdxName('sales_order_tax', array('order_id', 'priority', 'position')), array('order_id', 'priority', 'position') )->setComment( 'Sales Order Tax Table' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_order_status' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_status') )->addColumn( 'status', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, @@ -6573,14 +6631,14 @@ $table = $installer->getConnection()->newTable( )->setComment( 'Sales Order Status Table' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'sales_order_status_state' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status_state') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_status_state') )->addColumn( 'status', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, @@ -6599,24 +6657,29 @@ $table = $installer->getConnection()->newTable( null, array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Is Default' +)->addColumn( + 'visible_on_front', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + 1, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Visible on front' )->addForeignKey( - $installer->getFkName('sales_order_status_state', 'status', 'sales_order_status', 'status'), + $this->getFkName('sales_order_status_state', 'status', 'sales_order_status', 'status'), 'status', - $installer->getTable('sales_order_status'), + $this->getTable('sales_order_status'), 'status', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Order Status Table' ); -$installer->getConnection()->createTable($table); - +$this->getConnection()->createTable($table); /** * Create table 'sales_order_status_label' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status_label') +$table = $this->getConnection()->newTable( + $this->getTable('sales_order_status_label') )->addColumn( 'status', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, @@ -6636,25 +6699,25 @@ $table = $installer->getConnection()->newTable( array('nullable' => false), 'Label' )->addIndex( - $installer->getIdxName('sales_order_status_label', array('store_id')), + $this->getIdxName('sales_order_status_label', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('sales_order_status_label', 'status', 'sales_order_status', 'status'), + $this->getFkName('sales_order_status_label', 'status', 'sales_order_status', 'status'), 'status', - $installer->getTable('sales_order_status'), + $this->getTable('sales_order_status'), 'status', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_order_status_label', 'store_id', 'store', 'store_id'), + $this->getFkName('sales_order_status_label', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Sales Order Status Label Table' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); -$installer->endSetup(); +$this->endSetup(); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php deleted file mode 100644 index af18b0bdaa8..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.0-1.6.0.1.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; - -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order_status_history'), - 'entity_name', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 32, - 'nullable' => true, - 'comment' => 'Shows what entity history is bind to.' - ) -); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.php deleted file mode 100644 index 252edee3a82..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.1-1.6.0.2.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) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->startSetup(); -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_shipment'), - 'packages', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'comment' => 'Packed Products in Packages', 'length' => '20000') -); -$installer->endSetup(); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.11-1.6.0.12.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.11-1.6.0.12.php deleted file mode 100644 index 978444e5eee..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.11-1.6.0.12.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->startSetup(); - -$installer->getConnection()->addColumn( - $installer->getTable('sales_order_status_state'), - 'visible_on_front', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - 'length' => 1, - 'nullable' => false, - 'default' => 0, - 'comment' => 'visible_on_front' - ) -); - -$installer->endSetup(); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php deleted file mode 100644 index 8d5542163ff..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php +++ /dev/null @@ -1,37 +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) - */ - -/** - * Create aggregation tables for updated_at fields - */ - -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$connection = $installer->getConnection(); -$connection->createTable( - $connection->createTableByDdl( - $installer->getTable('sales_order_aggregated_created'), - $installer->getTable('sales_order_aggregated_updated') - ) -); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.php deleted file mode 100644 index a40b49fec9f..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.4-1.6.0.5.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) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order_item'), - 'base_tax_refunded', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - 'comment' => 'Base Tax Refunded', - 'scale' => 4, - 'precision' => 12 - ) -); -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order_item'), - 'discount_refunded', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - 'comment' => 'Discount Refunded', - 'scale' => 4, - 'precision' => 12 - ) -); -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order_item'), - 'base_discount_refunded', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - 'comment' => 'Base Discount Refunded', - 'scale' => 4, - 'precision' => 12 - ) -); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php deleted file mode 100644 index 14d993e9bc3..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.6-1.6.0.7.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; - -$installer->getConnection()->addColumn( - $installer->getTable('sales_flat_order'), - 'coupon_rule_name', - array( - 'TYPE' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'LENGTH' => 255, - 'NULLABLE' => true, - 'COMMENT' => 'Coupon Sales Rule Name' - ) -); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php deleted file mode 100644 index fdcdff51c72..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.7-1.6.0.8.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; - -$invoiceTable = $installer->getTable('sales_flat_invoice'); -$installer->getConnection()->addColumn( - $invoiceTable, - 'discount_description', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Discount Description') -); - -$creditmemoTable = $installer->getTable('sales_flat_creditmemo'); -$installer->getConnection()->addColumn( - $creditmemoTable, - 'discount_description', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Discount Description') -); diff --git a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php b/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php deleted file mode 100644 index b4dbc035aee..00000000000 --- a/app/code/Magento/Sales/sql/sales_setup/upgrade-1.6.0.8-1.6.0.9.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->startSetup(); - -$installer->getConnection()->modifyColumn( - $installer->getTable('sales_flat_quote_payment'), - 'cc_exp_year', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 255, - 'nullable' => true, - 'default' => null, - 'comment' => 'Cc Exp Year' - ) -)->modifyColumn( - $installer->getTable('sales_flat_quote_payment'), - 'cc_exp_month', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 255, - 'nullable' => true, - 'default' => null, - 'comment' => 'Cc Exp Month' - ) -); - -$installer->endSetup(); diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php index 56f6fd5b3b6..7390a72f024 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php @@ -69,7 +69,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport $this->_checkDates($from, $to); $table = $this->getMainTable(); - $sourceTable = $this->getTable('sales_flat_order'); + $sourceTable = $this->getTable('sales_order'); $adapter = $this->_getWriteAdapter(); $adapter->beginTransaction(); diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 56b42d7c447..cf6eda03156 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-alpha103", - "magento/module-rule": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-reports": "0.1.0-alpha103", - "magento/module-catalog-rule": "0.1.0-alpha103", - "magento/module-widget": "0.1.0-alpha103", - "magento/module-cron": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-rule": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-reports": "0.1.0-alpha104", + "magento/module-catalog-rule": "0.1.0-alpha104", + "magento/module-widget": "0.1.0-alpha104", + "magento/module-cron": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php b/app/code/Magento/SalesRule/data/salesrule_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/SalesRule/data/salesrule_setup/data-upgrade-1.6.0.3-1.6.0.4.php rename to app/code/Magento/SalesRule/data/salesrule_setup/data-install-2.0.0.php diff --git a/app/code/Magento/SalesRule/etc/module.xml b/app/code/Magento/SalesRule/etc/module.xml index 64ccddb8b01..df34f83da48 100644 --- a/app/code/Magento/SalesRule/etc/module.xml +++ b/app/code/Magento/SalesRule/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_SalesRule" schema_version="1.6.0.4" active="true"> + <module name="Magento_SalesRule" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Rule"/> <module name="Magento_Catalog"/> diff --git a/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php b/app/code/Magento/SalesRule/sql/salesrule_setup/install-2.0.0.php similarity index 66% rename from app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php rename to app/code/Magento/SalesRule/sql/salesrule_setup/install-2.0.0.php index 5bdfccba3fa..5b837856023 100644 --- a/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php +++ b/app/code/Magento/SalesRule/sql/salesrule_setup/install-2.0.0.php @@ -22,15 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$installer->startSetup(); +/* @var $this \Magento\Framework\Module\Setup */ +$this->startSetup(); /** * Create table 'salesrule' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule') )->addColumn( 'rule_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -53,13 +52,13 @@ $table = $installer->getConnection()->newTable( 'from_date', \Magento\Framework\DB\Ddl\Table::TYPE_DATE, null, - array(), + array('nullable' => true, 'default' => null), 'From Date' )->addColumn( 'to_date', \Magento\Framework\DB\Ddl\Table::TYPE_DATE, null, - array(), + array('nullable' => true, 'default' => null), 'To Date' )->addColumn( 'uses_per_customer', @@ -157,19 +156,33 @@ $table = $installer->getConnection()->newTable( null, array('unsigned' => true, 'nullable' => false, 'default' => '1'), 'Coupon Type' +)->addColumn( + 'use_auto_generation', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => false, 'nullable' => false, 'default' => 0), + 'Use Auto Generation' +)->addColumn( + 'uses_per_coupon', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('nullable' => false, 'default' => 0), + 'User Per Coupon' )->addIndex( - $installer->getIdxName('salesrule', array('is_active', 'sort_order', 'to_date', 'from_date')), + $this->getIdxName('salesrule', array('is_active', 'sort_order', 'to_date', 'from_date')), array('is_active', 'sort_order', 'to_date', 'from_date') )->setComment( 'Salesrule' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); + + /** * Create table 'salesrule_coupon' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule_coupon') )->addColumn( 'coupon_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -218,8 +231,20 @@ $table = $installer->getConnection()->newTable( null, array('unsigned' => true), 'Is Primary' +)->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + array('nullable' => true), + 'Coupon Code Creation Date' +)->addColumn( + 'type', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('nullable' => true, 'default' => 0), + 'Coupon Code Type' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'salesrule_coupon', array('code'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -227,7 +252,7 @@ $table = $installer->getConnection()->newTable( array('code'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'salesrule_coupon', array('rule_id', 'is_primary'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -235,25 +260,25 @@ $table = $installer->getConnection()->newTable( array('rule_id', 'is_primary'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('salesrule_coupon', array('rule_id')), + $this->getIdxName('salesrule_coupon', array('rule_id')), array('rule_id') )->addForeignKey( - $installer->getFkName('salesrule_coupon', 'rule_id', 'salesrule', 'rule_id'), + $this->getFkName('salesrule_coupon', 'rule_id', 'salesrule', 'rule_id'), 'rule_id', - $installer->getTable('salesrule'), + $this->getTable('salesrule'), 'rule_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Salesrule Coupon' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'salesrule_coupon_usage' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon_usage') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule_coupon_usage') )->addColumn( 'coupon_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -273,32 +298,32 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Times Used' )->addIndex( - $installer->getIdxName('salesrule_coupon_usage', array('customer_id')), + $this->getIdxName('salesrule_coupon_usage', array('customer_id')), array('customer_id') )->addForeignKey( - $installer->getFkName('salesrule_coupon_usage', 'coupon_id', 'salesrule_coupon', 'coupon_id'), + $this->getFkName('salesrule_coupon_usage', 'coupon_id', 'salesrule_coupon', 'coupon_id'), 'coupon_id', - $installer->getTable('salesrule_coupon'), + $this->getTable('salesrule_coupon'), 'coupon_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('salesrule_coupon_usage', 'customer_id', 'customer_entity', 'entity_id'), + $this->getFkName('salesrule_coupon_usage', 'customer_id', 'customer_entity', 'entity_id'), 'customer_id', - $installer->getTable('customer_entity'), + $this->getTable('customer_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Salesrule Coupon Usage' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'salesrule_customer' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_customer') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule_customer') )->addColumn( 'rule_customer_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -324,35 +349,35 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Times Used' )->addIndex( - $installer->getIdxName('salesrule_customer', array('rule_id', 'customer_id')), + $this->getIdxName('salesrule_customer', array('rule_id', 'customer_id')), array('rule_id', 'customer_id') )->addIndex( - $installer->getIdxName('salesrule_customer', array('customer_id', 'rule_id')), + $this->getIdxName('salesrule_customer', array('customer_id', 'rule_id')), array('customer_id', 'rule_id') )->addForeignKey( - $installer->getFkName('salesrule_customer', 'customer_id', 'customer_entity', 'entity_id'), + $this->getFkName('salesrule_customer', 'customer_id', 'customer_entity', 'entity_id'), 'customer_id', - $installer->getTable('customer_entity'), + $this->getTable('customer_entity'), 'entity_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('salesrule_customer', 'rule_id', 'salesrule', 'rule_id'), + $this->getFkName('salesrule_customer', 'rule_id', 'salesrule', 'rule_id'), 'rule_id', - $installer->getTable('salesrule'), + $this->getTable('salesrule'), 'rule_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Salesrule Customer' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'salesrule_label' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_label') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule_label') )->addColumn( 'label_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -378,7 +403,7 @@ $table = $installer->getConnection()->newTable( array(), 'Label' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'salesrule_label', array('rule_id', 'store_id'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -386,32 +411,32 @@ $table = $installer->getConnection()->newTable( array('rule_id', 'store_id'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('salesrule_label', array('store_id')), + $this->getIdxName('salesrule_label', array('store_id')), array('store_id') )->addForeignKey( - $installer->getFkName('salesrule_label', 'rule_id', 'salesrule', 'rule_id'), + $this->getFkName('salesrule_label', 'rule_id', 'salesrule', 'rule_id'), 'rule_id', - $installer->getTable('salesrule'), + $this->getTable('salesrule'), 'rule_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('salesrule_label', 'store_id', 'store', 'store_id'), + $this->getFkName('salesrule_label', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Salesrule Label' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'salesrule_product_attribute' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_product_attribute') +$table = $this->getConnection()->newTable( + $this->getTable('salesrule_product_attribute') )->addColumn( 'rule_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -437,52 +462,52 @@ $table = $installer->getConnection()->newTable( array('unsigned' => true, 'nullable' => false, 'primary' => true), 'Attribute Id' )->addIndex( - $installer->getIdxName('salesrule_product_attribute', array('website_id')), + $this->getIdxName('salesrule_product_attribute', array('website_id')), array('website_id') )->addIndex( - $installer->getIdxName('salesrule_product_attribute', array('customer_group_id')), + $this->getIdxName('salesrule_product_attribute', array('customer_group_id')), array('customer_group_id') )->addIndex( - $installer->getIdxName('salesrule_product_attribute', array('attribute_id')), + $this->getIdxName('salesrule_product_attribute', array('attribute_id')), array('attribute_id') )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'attribute_id', 'eav_attribute', 'attribute_id'), + $this->getFkName('salesrule_product_attribute', 'attribute_id', 'eav_attribute', 'attribute_id'), 'attribute_id', - $installer->getTable('eav_attribute'), + $this->getTable('eav_attribute'), 'attribute_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'customer_group_id', 'customer_group', 'customer_group_id'), + $this->getFkName('salesrule_product_attribute', 'customer_group_id', 'customer_group', 'customer_group_id'), 'customer_group_id', - $installer->getTable('customer_group'), + $this->getTable('customer_group'), 'customer_group_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'rule_id', 'salesrule', 'rule_id'), + $this->getFkName('salesrule_product_attribute', 'rule_id', 'salesrule', 'rule_id'), 'rule_id', - $installer->getTable('salesrule'), + $this->getTable('salesrule'), 'rule_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'website_id', 'store_website', 'website_id'), + $this->getFkName('salesrule_product_attribute', 'website_id', 'store_website', 'website_id'), 'website_id', - $installer->getTable('store_website'), + $this->getTable('store_website'), 'website_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION )->setComment( 'Salesrule Product Attribute' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); /** * Create table 'coupon_aggregated' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('coupon_aggregated') +$table = $this->getConnection()->newTable( + $this->getTable('coupon_aggregated') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -555,8 +580,14 @@ $table = $installer->getConnection()->newTable( array(12, 4), array('nullable' => false, 'default' => '0.0000'), 'Total Amount Actual' +)->addColumn( + 'rule_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Rule Name' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'coupon_aggregated', array('period', 'store_id', 'order_status', 'coupon_code'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -564,25 +595,35 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status', 'coupon_code'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('coupon_aggregated', array('store_id')), + $this->getIdxName('coupon_aggregated', array('store_id')), array('store_id') +)->addIndex( + $this->getIdxName('coupon_aggregated', array('rule_name')), + array('rule_name') )->addForeignKey( - $installer->getFkName('coupon_aggregated', 'store_id', 'store', 'store_id'), + $this->getFkName('coupon_aggregated', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Coupon Aggregated' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); + +$this->getConnection()->createTable( + $this->getConnection()->createTableByDdl( + $this->getTable('coupon_aggregated'), + $this->getTable('coupon_aggregated_updated') + ) +); /** * Create table 'coupon_aggregated_order' */ -$table = $installer->getConnection()->newTable( - $installer->getTable('coupon_aggregated_order') +$table = $this->getConnection()->newTable( + $this->getTable('coupon_aggregated_order') )->addColumn( 'id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, @@ -637,8 +678,14 @@ $table = $installer->getConnection()->newTable( array(12, 4), array('nullable' => false, 'default' => '0.0000'), 'Total Amount' +)->addColumn( + 'rule_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Rule Name' )->addIndex( - $installer->getIdxName( + $this->getIdxName( 'coupon_aggregated_order', array('period', 'store_id', 'order_status', 'coupon_code'), \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE @@ -646,18 +693,109 @@ $table = $installer->getConnection()->newTable( array('period', 'store_id', 'order_status', 'coupon_code'), array('type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) )->addIndex( - $installer->getIdxName('coupon_aggregated_order', array('store_id')), + $this->getIdxName('coupon_aggregated_order', array('store_id')), array('store_id') +)->addIndex( + $this->getIdxName('coupon_aggregated_order', array('rule_name')), + array('rule_name') )->addForeignKey( - $installer->getFkName('coupon_aggregated_order', 'store_id', 'store', 'store_id'), + $this->getFkName('coupon_aggregated_order', 'store_id', 'store', 'store_id'), 'store_id', - $installer->getTable('store'), + $this->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->setComment( 'Coupon Aggregated Order' ); -$installer->getConnection()->createTable($table); +$this->getConnection()->createTable($table); + +$websitesTable = $this->getTable('store_website'); +$customerGroupsTable = $this->getTable('customer_group'); +$rulesWebsitesTable = $this->getTable('salesrule_website'); +$rulesCustomerGroupsTable = $this->getTable('salesrule_customer_group'); + +/** + * Create table 'salesrule_website' if not exists. This table will be used instead of + * column website_ids of main catalog rules table + */ +$table = $this->getConnection()->newTable( + $rulesWebsitesTable +)->addColumn( + 'rule_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'primary' => true), + 'Rule Id' +)->addColumn( + 'website_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'primary' => true), + 'Website Id' +)->addIndex( + $this->getIdxName('salesrule_website', array('website_id')), + array('website_id') +)->addForeignKey( + $this->getFkName('salesrule_website', 'rule_id', 'salesrule', 'rule_id'), + 'rule_id', + $this->getTable('salesrule'), + 'rule_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +)->addForeignKey( + $this->getFkName('salesrule_website', 'website_id', 'core/website', 'website_id'), + 'website_id', + $websitesTable, + 'website_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +)->setComment( + 'Sales Rules To Websites Relations' +); + +$this->getConnection()->createTable($table); + + +/** + * Create table 'salesrule_customer_group' if not exists. This table will be used instead of + * column customer_group_ids of main catalog rules table + */ +$table = $this->getConnection()->newTable( + $rulesCustomerGroupsTable +)->addColumn( + 'rule_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'primary' => true), + 'Rule Id' +)->addColumn( + 'customer_group_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'primary' => true), + 'Customer Group Id' +)->addIndex( + $this->getIdxName('salesrule_customer_group', array('customer_group_id')), + array('customer_group_id') +)->addForeignKey( + $this->getFkName('salesrule_customer_group', 'rule_id', 'salesrule', 'rule_id'), + 'rule_id', + $this->getTable('salesrule'), + 'rule_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +)->addForeignKey( + $this->getFkName('salesrule_customer_group', 'customer_group_id', 'customer_group', 'customer_group_id'), + 'customer_group_id', + $customerGroupsTable, + 'customer_group_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE +)->setComment( + 'Sales Rules To Customer Groups Relations' +); + +$this->getConnection()->createTable($table); -$installer->endSetup(); +$this->endSetup(); diff --git a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.php deleted file mode 100644 index 656e8b88ef7..00000000000 --- a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.1-1.6.0.2.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) - */ - -/** - * @var $installer \Magento\Setup\Module\SetupModule - */ -$installer = $this; - -$installer->getConnection()->addColumn( - $installer->getTable('salesrule_coupon'), - 'created_at', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - 'comment' => 'Coupon Code Creation Date', - 'nullable' => false, - 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT - ) -); - -$installer->getConnection()->addColumn( - $installer->getTable('salesrule_coupon'), - 'type', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'comment' => 'Coupon Code Type', 'default' => 0) -); - -$installer->getConnection()->addColumn( - $installer->getTable('salesrule'), - 'use_auto_generation', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - 'comment' => 'Use Auto Generation', - 'nullable' => false, - 'default' => 0 - ) -); - -$installer->getConnection()->addColumn( - $installer->getTable('salesrule'), - 'uses_per_coupon', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - 'comment' => 'Uses Per Coupon', - 'nullable' => false, - 'default' => 0 - ) -); - -$installer->getConnection()->addColumn( - $installer->getTable('coupon_aggregated'), - 'rule_name', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Rule Name') -); - -$installer->getConnection()->addColumn( - $installer->getTable('coupon_aggregated_order'), - 'rule_name', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Rule Name') -); - -$installer->getConnection()->addColumn( - $installer->getTable('coupon_aggregated_updated'), - 'rule_name', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Rule Name') -); - -$installer->getConnection()->addIndex( - $installer->getTable('coupon_aggregated'), - $installer->getIdxName( - 'coupon_aggregated', - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX - ), - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX -); - -$installer->getConnection()->addIndex( - $installer->getTable('coupon_aggregated_order'), - $installer->getIdxName( - 'coupon_aggregated_order', - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX - ), - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX -); - -$installer->getConnection()->addIndex( - $installer->getTable('coupon_aggregated_updated'), - $installer->getIdxName( - 'coupon_aggregated_updated', - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX - ), - array('rule_name'), - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX -); diff --git a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php deleted file mode 100644 index 443d92baa25..00000000000 --- a/app/code/Magento/SalesRule/sql/salesrule_setup/upgrade-1.6.0.2-1.6.0.3.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/* @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; -$connection = $installer->getConnection(); - -$rulesTable = $installer->getTable('salesrule'); -$websitesTable = $installer->getTable('store_website'); -$customerGroupsTable = $installer->getTable('customer_group'); -$rulesWebsitesTable = $installer->getTable('salesrule_website'); -$rulesCustomerGroupsTable = $installer->getTable('salesrule_customer_group'); - -$installer->startSetup(); -/** - * Create table 'salesrule_website' if not exists. This table will be used instead of - * column website_ids of main catalog rules table - */ -$table = $connection->newTable( - $rulesWebsitesTable -)->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'primary' => true), - 'Rule Id' -)->addColumn( - 'website_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'nullable' => false, 'primary' => true), - 'Website Id' -)->addIndex( - $installer->getIdxName('salesrule_website', array('website_id')), - array('website_id') -)->addForeignKey( - $installer->getFkName('salesrule_website', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $rulesTable, - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE -)->addForeignKey( - $installer->getFkName('salesrule_website', 'website_id', 'core/website', 'website_id'), - 'website_id', - $websitesTable, - 'website_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE -)->setComment( - 'Sales Rules To Websites Relations' -); - -$connection->createTable($table); - - -/** - * Create table 'salesrule_customer_group' if not exists. This table will be used instead of - * column customer_group_ids of main catalog rules table - */ -$table = $connection->newTable( - $rulesCustomerGroupsTable -)->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - array('unsigned' => true, 'nullable' => false, 'primary' => true), - 'Rule Id' -)->addColumn( - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'nullable' => false, 'primary' => true), - 'Customer Group Id' -)->addIndex( - $installer->getIdxName('salesrule_customer_group', array('customer_group_id')), - array('customer_group_id') -)->addForeignKey( - $installer->getFkName('salesrule_customer_group', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $rulesTable, - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE -)->addForeignKey( - $installer->getFkName('salesrule_customer_group', 'customer_group_id', 'customer_group', 'customer_group_id'), - 'customer_group_id', - $customerGroupsTable, - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE -)->setComment( - 'Sales Rules To Customer Groups Relations' -); - -$connection->createTable($table); - - -/** - * Change default value to "null" for "from" and "to" dates columns - */ -$connection->modifyColumn( - $rulesTable, - 'from_date', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'nullable' => true, 'default' => null) -); - -$connection->modifyColumn( - $rulesTable, - 'to_date', - array('type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'nullable' => true, 'default' => null) -); - -$installer->endSetup(); diff --git a/app/code/Magento/Search/composer.json b/app/code/Magento/Search/composer.json index 4ceeea36119..78765ded878 100644 --- a/app/code/Magento/Search/composer.json +++ b/app/code/Magento/Search/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/framework": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index d1b5e5e445d..1cf385c9c84 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 7b306b9cec0..d785061f503 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-contact": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-payment": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-contact": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-payment": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/etc/module.xml b/app/code/Magento/Shipping/etc/module.xml index 5dec754161d..621bcec54e4 100644 --- a/app/code/Magento/Shipping/etc/module.xml +++ b/app/code/Magento/Shipping/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Shipping" schema_version="1.6.0.0" active="true"> + <module name="Magento_Shipping" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Core"/> <module name="Magento_Store"/> diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 2f74fa2dc41..ba2752d55e4 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog-url-rewrite": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog-url-rewrite": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index a83b6296445..7cbd9a016d9 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-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-ui": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-core": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-ui": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php index 86dfe45b630..0ea40e92000 100644 --- a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php +++ b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php @@ -76,7 +76,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport try { if ($from !== null || $to !== null) { $subSelect = $this->_getTableDateRangeSelect( - $this->getTable('sales_flat_order'), + $this->getTable('sales_order'), 'created_at', 'updated_at', $from, @@ -90,7 +90,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport // convert dates from UTC to current admin timezone $periodExpr = $writeAdapter->getDatePartSql( $this->getStoreTZOffsetQuery( - array('e' => $this->getTable('sales_flat_order')), + array('e' => $this->getTable('sales_order')), 'e.' . $aggregationField, $from, $to @@ -112,7 +112,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport array('tax' => $this->getTable('sales_order_tax')), $columns )->joinInner( - array('e' => $this->getTable('sales_flat_order')), + array('e' => $this->getTable('sales_order')), 'e.entity_id = tax.order_id', array() )->useStraightJoin(); diff --git a/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetails/ItemBuilder.php b/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetails/ItemBuilder.php index f96ecf5e2c1..b7ede890920 100644 --- a/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetails/ItemBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetails/ItemBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data\OrderTaxDetails; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -45,13 +45,13 @@ class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param AppliedTaxBuilder $appliedTaxBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, AppliedTaxBuilder $appliedTaxBuilder ) { diff --git a/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetailsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetailsBuilder.php index ad33bc878b2..facd6bbad98 100644 --- a/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetailsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/OrderTaxDetailsBuilder.php @@ -26,7 +26,7 @@ namespace Magento\Tax\Service\V1\Data; use \Magento\Tax\Service\V1\Data\OrderTaxDetails\AppliedTaxBuilder; use \Magento\Tax\Service\V1\Data\OrderTaxDetails\ItemBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -54,14 +54,14 @@ class OrderTaxDetailsBuilder extends \Magento\Framework\Api\ExtensibleObjectBuil * Initialize dependencies * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param AppliedTaxBuilder $appliedTaxBuilder * @param ItemBuilder $itemBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, AppliedTaxBuilder $appliedTaxBuilder, ItemBuilder $itemBuilder diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php index 4606696a560..63a5db447e9 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data\QuoteDetails; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -44,13 +44,13 @@ class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder ) { diff --git a/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php index 3ca8f0b5665..09abb8d738b 100644 --- a/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/QuoteDetailsBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -58,7 +58,7 @@ class QuoteDetailsBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies. * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param \Magento\Tax\Service\V1\Data\QuoteDetails\ItemBuilder $itemBuilder * @param \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder @@ -66,7 +66,7 @@ class QuoteDetailsBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Tax\Service\V1\Data\QuoteDetails\ItemBuilder $itemBuilder, \Magento\Tax\Service\V1\Data\TaxClassKeyBuilder $taxClassKeyBuilder, diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php index d1a5b4d6b14..aaaa826b6c7 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxClassSearchResultsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -41,14 +41,14 @@ class TaxClassSearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param TaxClassBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, TaxClassBuilder $itemObjectBuilder diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilder.php index 63155d19996..de943fb0c48 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data\TaxDetails; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -44,13 +44,13 @@ class AppliedTaxBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies. * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param AppliedTaxRateBuilder $appliedTaxRateBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, AppliedTaxRateBuilder $appliedTaxRateBuilder ) { diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxDetails/ItemBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxDetails/ItemBuilder.php index d61795ea390..373ef4f2bc9 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxDetails/ItemBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxDetails/ItemBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data\TaxDetails; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Tax\Service\V1\Data\TaxDetails; @@ -46,13 +46,13 @@ class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param AppliedTaxBuilder $appliedTaxBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Tax\Service\V1\Data\TaxDetails\AppliedTaxBuilder $appliedTaxBuilder ) { diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxDetailsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxDetailsBuilder.php index 3d52a7ab547..e3cb24abf12 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxDetailsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxDetailsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; /** @@ -52,14 +52,14 @@ class TaxDetailsBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies * * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param TaxDetails\AppliedTaxBuilder $appliedTaxBuilder * @param TaxDetails\ItemBuilder $taxDetailsItemBuilder */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, \Magento\Tax\Service\V1\Data\TaxDetails\AppliedTaxBuilder $appliedTaxBuilder, \Magento\Tax\Service\V1\Data\TaxDetails\ItemBuilder $taxDetailsItemBuilder diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxRateBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxRateBuilder.php index 0a541e6d09e..74cae8f7cfa 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxRateBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxRateBuilder.php @@ -23,7 +23,7 @@ */ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; @@ -52,14 +52,14 @@ class TaxRateBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder * Initialize dependencies. * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param ZipRangeBuilder $zipRangeBuilder * @param TaxRateTitleBuilder $taxRateTitleBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, ZipRangeBuilder $zipRangeBuilder, TaxRateTitleBuilder $taxRateTitleBuilder diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php index 47aac3fbd86..4f3c71ff406 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\AbstractSearchResultsBuilder; @@ -41,14 +41,14 @@ class TaxRateSearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param TaxRateBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, TaxRateBuilder $itemObjectBuilder diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxRuleBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxRuleBuilder.php index 6499999341d..586ed35f07d 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxRuleBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxRuleBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Tax\Service\V1\Data; use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; @@ -46,13 +46,13 @@ class TaxRuleBuilder extends ExtensibleObjectBuilder * Initialize dependencies. * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param TaxRateBuilder $taxRateBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, TaxRateBuilder $taxRateBuilder ) { diff --git a/app/code/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilder.php b/app/code/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilder.php index 41c16cbd6fd..a221af83cf4 100644 --- a/app/code/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilder.php +++ b/app/code/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilder.php @@ -24,7 +24,7 @@ namespace Magento\Tax\Service\V1\Data; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -41,14 +41,14 @@ class TaxRuleSearchResultsBuilder extends AbstractSearchResultsBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param TaxRuleBuilder $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, TaxRuleBuilder $itemObjectBuilder diff --git a/app/code/Magento/Tax/composer.json b/app/code/Magento/Tax/composer.json index 817f2a38a57..4bd259aaac0 100644 --- a/app/code/Magento/Tax/composer.json +++ b/app/code/Magento/Tax/composer.json @@ -3,23 +3,23 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-reports": "0.1.0-alpha103", - "magento/module-configurable-product": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-reports": "0.1.0-alpha104", + "magento/module-configurable-product": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Tax/etc/frontend/di.xml b/app/code/Magento/Tax/etc/frontend/di.xml new file mode 100644 index 00000000000..d62eaad3532 --- /dev/null +++ b/app/code/Magento/Tax/etc/frontend/di.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <type name="Magento\Tax\Model\Calculation"> + <arguments> + <argument name="addressService" xsi:type="object">Magento\Customer\Service\V1\CustomerAddressServiceInterface\Proxy</argument> + <argument name="groupService" xsi:type="object">Magento\Customer\Service\V1\CustomerGroupServiceInterface\Proxy</argument> + <argument name="customerAccount" xsi:type="object">Magento\Customer\Service\V1\CustomerAccountServiceInterface\Proxy</argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php index 18ef18d6db6..dc85e2b647a 100644 --- a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php +++ b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.1-1.6.0.2.php @@ -67,9 +67,9 @@ $table = $installer->getConnection()->newTable( \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE )->addForeignKey( - $installer->getFkName('sales_order_tax_item', 'item_id', 'sales_flat_order_item', 'item_id'), + $installer->getFkName('sales_order_tax_item', 'item_id', 'sales_order_item', 'item_id'), 'item_id', - $installer->getTable('sales_flat_order_item'), + $installer->getTable('sales_order_item'), 'item_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE diff --git a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.6-1.6.0.7.php b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.6-1.6.0.7.php index 557166c02d8..7f65a36603a 100644 --- a/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.6-1.6.0.7.php +++ b/app/code/Magento/Tax/sql/tax_setup/upgrade-1.6.0.6-1.6.0.7.php @@ -105,9 +105,9 @@ $connection->changeColumn( ] ); $connection->addForeignKey( - $installer->getFkName('sales_order_tax_item', 'associated_item_id', 'sales_flat_order_item', 'item_id'), + $installer->getFkName('sales_order_tax_item', 'associated_item_id', 'sales_order_item', 'item_id'), $installer->getTable('sales_order_tax_item'), 'associated_item_id', - $installer->getTable('sales_flat_order_item'), + $installer->getTable('sales_order_item'), 'item_id' ); diff --git a/app/code/Magento/TaxImportExport/composer.json b/app/code/Magento/TaxImportExport/composer.json index c84e9abf1d8..5d463084c6b 100644 --- a/app/code/Magento/TaxImportExport/composer.json +++ b/app/code/Magento/TaxImportExport/composer.json @@ -3,15 +3,15 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 6d93b9068ee..2e3dd1a6e2c 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-translation": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-translation": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Theme/etc/di.xml b/app/code/Magento/Theme/etc/di.xml index 93644313573..789c6408702 100644 --- a/app/code/Magento/Theme/etc/di.xml +++ b/app/code/Magento/Theme/etc/di.xml @@ -62,7 +62,6 @@ </arguments> </type> <preference for="Magento\Framework\App\View\Deployment\Version\StorageInterface" type="Magento\Framework\App\View\Deployment\Version\Storage\File"/> - <preference for="Magento\Framework\App\View\Deployment\Version\GeneratorInterface" type="Magento\Framework\App\View\Deployment\Version\Generator\Timestamp"/> <type name="Magento\Framework\App\View\Deployment\Version\Storage\File"> <arguments> <argument name="directoryCode" xsi:type="const">Magento\Framework\App\Filesystem\DirectoryList::STATIC_VIEW</argument> diff --git a/app/code/Magento/Theme/etc/module.xml b/app/code/Magento/Theme/etc/module.xml index 2653ba37153..0859582a9d7 100644 --- a/app/code/Magento/Theme/etc/module.xml +++ b/app/code/Magento/Theme/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Theme" schema_version="1.6.0.0" active="true"> + <module name="Magento_Theme" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Core"/> <module name="Magento_Store"/> diff --git a/app/code/Magento/Translation/composer.json b/app/code/Magento/Translation/composer.json index 1ab6d63afbd..ba56c47708d 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-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-core": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Ui/composer.json b/app/code/Magento/Ui/composer.json index 313b30b38c4..6e3c827631f 100644 --- a/app/code/Magento/Ui/composer.json +++ b/app/code/Magento/Ui/composer.json @@ -3,13 +3,13 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Ui/etc/module.xml b/app/code/Magento/Ui/etc/module.xml index d859f136d0a..3e1302245a0 100644 --- a/app/code/Magento/Ui/etc/module.xml +++ b/app/code/Magento/Ui/etc/module.xml @@ -24,14 +24,14 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Ui" schema_version="1.6.0.0" active="true"> + <module name="Magento_Ui" schema_version="2.0.0" active="true"> <sequence> <module name="Magento_Backend"/> - <module name="Magento_Directory"/> + <module name="Magento_Directory"/> </sequence> <depends> <module name="Magento_Backend"/> <module name="Magento_Store"/> </depends> </module> -</config> \ No newline at end of file +</config> diff --git a/app/code/Magento/Ups/composer.json b/app/code/Magento/Ups/composer.json index 81119a2bf50..d6a7c4e7618 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-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Ups/etc/module.xml b/app/code/Magento/Ups/etc/module.xml index ae8aab01ae5..22c05c57ca7 100644 --- a/app/code/Magento/Ups/etc/module.xml +++ b/app/code/Magento/Ups/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Ups" schema_version="2.0.0.0" active="true"> + <module name="Magento_Ups" schema_version="2.0.0" active="true"> <depends> <module name="Magento_Store"/> <module name="Magento_Core"/> diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php index e6f5bd53a66..906ba7f49f3 100644 --- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php +++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php @@ -166,7 +166,7 @@ class Save extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite $requestPath = $this->getRequest()->getParam('request_path'); $this->_objectManager->get('Magento\UrlRewrite\Helper\UrlRewrite')->validateRequestPath($requestPath); - $model->setEntityType($this->getRequest()->getParam('entity_type', self::ENTITY_TYPE_CUSTOM)) + $model->setEntityType($this->getRequest()->getParam('entity_type') ?: self::ENTITY_TYPE_CUSTOM) ->setRequestPath($requestPath) ->setTargetPath($this->getRequest()->getParam('target_path', $model->getTargetPath())) ->setRedirectType($this->getRequest()->getParam('redirect_type')) diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php index 255904c15c1..28f97eef23c 100644 --- a/app/code/Magento/UrlRewrite/Controller/Router.php +++ b/app/code/Magento/UrlRewrite/Controller/Router.php @@ -26,6 +26,7 @@ namespace Magento\UrlRewrite\Controller; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; use Magento\UrlRewrite\Model\UrlFinderInterface; use Magento\UrlRewrite\Model\OptionProvider; +use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite; /** * UrlRewrite Controller Router @@ -98,15 +99,30 @@ class Router implements \Magento\Framework\App\RouterInterface return null; } - $redirectType = $rewrite->getRedirectType(); - if ($redirectType) { - return $this->redirect($request, $rewrite->getTargetPath(), $redirectType); + if ($rewrite->getRedirectType()) { + return $this->processRedirect($request, $rewrite); } $request->setPathInfo('/' . $rewrite->getTargetPath()); return $this->actionFactory->create('Magento\Framework\App\Action\Forward', array('request' => $request)); } + /** + * @param \Magento\Framework\App\RequestInterface $request + * @param UrlRewrite $rewrite + * @return \Magento\Framework\App\ActionInterface|null + */ + protected function processRedirect($request, $rewrite) + { + $target = $rewrite->getTargetPath(); + if ($rewrite->getEntityType() !== Rewrite::ENTITY_TYPE_CUSTOM + || ($prefix = substr($target, 0, 6)) !== 'http:/' && $prefix !== 'https:' + ) { + $target = $this->url->getUrl('', array('_direct' => $target)); + } + return $this->redirect($request, $target, $rewrite->getRedirectType()); + } + /** * @param \Magento\Framework\App\RequestInterface $request * @param string $url @@ -115,7 +131,7 @@ class Router implements \Magento\Framework\App\RouterInterface */ protected function redirect($request, $url, $code) { - $this->response->setRedirect($this->url->getUrl('', array('_direct' => $url)), $code); + $this->response->setRedirect($url, $code); $request->setDispatched(true); return $this->actionFactory->create('Magento\Framework\App\Action\Redirect', array('request' => $request)); } @@ -127,11 +143,9 @@ class Router implements \Magento\Framework\App\RouterInterface */ protected function getRewrite($requestPath, $storeId) { - return $this->urlFinder->findOneByData( - [ - UrlRewrite::REQUEST_PATH => trim($requestPath, '/'), - UrlRewrite::STORE_ID => $storeId, - ] - ); + return $this->urlFinder->findOneByData([ + UrlRewrite::REQUEST_PATH => trim($requestPath, '/'), + UrlRewrite::STORE_ID => $storeId, + ]); } } diff --git a/app/code/Magento/UrlRewrite/composer.json b/app/code/Magento/UrlRewrite/composer.json index 7d14b5527fd..e1b7463e28d 100644 --- a/app/code/Magento/UrlRewrite/composer.json +++ b/app/code/Magento/UrlRewrite/composer.json @@ -3,18 +3,18 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-store": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog-url-rewrite": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-cms-url-rewrite": "0.1.0-alpha103", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-store": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog-url-rewrite": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-cms-url-rewrite": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/User/composer.json b/app/code/Magento/User/composer.json index 34af5709eb0..543ae1e6ff1 100644 --- a/app/code/Magento/User/composer.json +++ b/app/code/Magento/User/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-authorization": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-integration": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-authorization": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-integration": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index 414c0721039..bff4187f43b 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-alpha103", - "magento/module-shipping": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-shipping": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Usps/data/usps_setup/data-install-2.0.0.0.php b/app/code/Magento/Usps/data/usps_setup/data-install-2.0.0.php similarity index 100% rename from app/code/Magento/Usps/data/usps_setup/data-install-2.0.0.0.php rename to app/code/Magento/Usps/data/usps_setup/data-install-2.0.0.php diff --git a/app/code/Magento/Usps/etc/module.xml b/app/code/Magento/Usps/etc/module.xml index 8ef5554d207..da87d123165 100644 --- a/app/code/Magento/Usps/etc/module.xml +++ b/app/code/Magento/Usps/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Usps" schema_version="2.0.0.0" active="true"> + <module name="Magento_Usps" schema_version="2.0.0" active="true"> <depends> <module name="Magento_Store"/> <module name="Magento_Shipping"/> diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php index 7af9aec600d..a582647d7dd 100644 --- a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php +++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php @@ -29,7 +29,7 @@ use Magento\Framework\ObjectManager; use Magento\Framework\ObjectManager\Config as ObjectManagerConfig; use Magento\Framework\Api\Config\Reader as ServiceConfigReader; use Magento\Framework\Api\AttributeValue; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Reflection\TypeProcessor; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; @@ -55,7 +55,7 @@ class ServiceArgsSerializer /** @var ServiceConfigReader */ protected $serviceConfigReader; - /** @var AttributeValueBuilder */ + /** @var AttributeDataBuilder */ protected $attributeValueBuilder; /** @@ -64,13 +64,13 @@ class ServiceArgsSerializer * @param TypeProcessor $typeProcessor * @param DataBuilderFactory $builderFactory * @param ServiceConfigReader $serviceConfigReader - * @param AttributeValueBuilder $attributeValueBuilder + * @param AttributeDataBuilder $attributeValueBuilder */ public function __construct( TypeProcessor $typeProcessor, DataBuilderFactory $builderFactory, ServiceConfigReader $serviceConfigReader, - AttributeValueBuilder $attributeValueBuilder + AttributeDataBuilder $attributeValueBuilder ) { $this->typeProcessor = $typeProcessor; $this->builderFactory = $builderFactory; diff --git a/app/code/Magento/Webapi/composer.json b/app/code/Magento/Webapi/composer.json index 25cede30adf..34a208debd1 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-alpha103", - "magento/module-authorization": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-integration": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-user": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-authorization": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-integration": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-user": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ 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 fe7afcf1f81..3a339a0a94b 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -43,7 +43,6 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price protected $_directoryHelper; /** - * @param \Magento\Framework\Logger $logger * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData @@ -52,7 +51,6 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price * @param \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax $attributeTax */ public function __construct( - \Magento\Framework\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, @@ -63,7 +61,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price $this->_directoryHelper = $directoryHelper; $this->_storeManager = $storeManager; $this->_attributeTax = $attributeTax; - parent::__construct($logger, $currencyFactory, $storeManager, $catalogData, $config); + parent::__construct($currencyFactory, $storeManager, $catalogData, $config); } /** diff --git a/app/code/Magento/Weee/composer.json b/app/code/Magento/Weee/composer.json index d455549da8f..aa73fea5c9f 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-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-tax": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-directory": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-eav": "0.1.0-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-bundle": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-tax": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-directory": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-eav": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-bundle": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Widget/composer.json b/app/code/Magento/Widget/composer.json index 7e6a5e30b44..4758d09cccf 100644 --- a/app/code/Magento/Widget/composer.json +++ b/app/code/Magento/Widget/composer.json @@ -3,16 +3,16 @@ "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", - "magento/module-store": "0.1.0-alpha103", - "magento/module-cms": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-cms": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/code/Magento/Wishlist/composer.json b/app/code/Magento/Wishlist/composer.json index cd936a1bca3..187737e677f 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-alpha103", - "magento/module-customer": "0.1.0-alpha103", - "magento/module-catalog": "0.1.0-alpha103", - "magento/module-core": "0.1.0-alpha103", - "magento/module-checkout": "0.1.0-alpha103", - "magento/module-theme": "0.1.0-alpha103", - "magento/module-catalog-inventory": "0.1.0-alpha103", - "magento/module-rss": "0.1.0-alpha103", - "magento/module-backend": "0.1.0-alpha103", - "magento/module-bundle": "0.1.0-alpha103", - "magento/module-sales": "0.1.0-alpha103", - "magento/module-grouped-product": "0.1.0-alpha103", - "magento/module-configurable-product": "0.1.0-alpha103", - "magento/module-downloadable": "0.1.0-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/module-store": "0.1.0-alpha104", + "magento/module-customer": "0.1.0-alpha104", + "magento/module-catalog": "0.1.0-alpha104", + "magento/module-core": "0.1.0-alpha104", + "magento/module-checkout": "0.1.0-alpha104", + "magento/module-theme": "0.1.0-alpha104", + "magento/module-catalog-inventory": "0.1.0-alpha104", + "magento/module-rss": "0.1.0-alpha104", + "magento/module-backend": "0.1.0-alpha104", + "magento/module-bundle": "0.1.0-alpha104", + "magento/module-sales": "0.1.0-alpha104", + "magento/module-grouped-product": "0.1.0-alpha104", + "magento/module-configurable-product": "0.1.0-alpha104", + "magento/module-downloadable": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/composer.json b/app/design/adminhtml/Magento/backend/composer.json index ef648d9f878..c54a869c01b 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-alpha103", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/design/adminhtml/Magento/backend/theme.xml b/app/design/adminhtml/Magento/backend/theme.xml index 480251aaa9d..d5d8a9cc4ca 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-alpha103</version> + <version>0.1.0-alpha104</version> </theme> diff --git a/app/design/frontend/Magento/blank/composer.json b/app/design/frontend/Magento/blank/composer.json index 08082d03c50..70060e31e29 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-alpha103", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/blank/theme.xml b/app/design/frontend/Magento/blank/theme.xml index 777b5718e97..cef3f21f044 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-alpha103</version> + <version>0.1.0-alpha104</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 c2612610890..0d2af0efb65 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-alpha103", - "magento/framework": "0.1.0-alpha103", + "magento/theme-frontend-blank": "0.1.0-alpha104", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", - "version": "0.1.0-alpha103", + "version": "0.1.0-alpha104", "extra": { "map": [ [ diff --git a/app/design/frontend/Magento/plushe/theme.xml b/app/design/frontend/Magento/plushe/theme.xml index 2bafb85bb0e..812501a26b5 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-alpha103</version> + <version>0.1.0-alpha104</version> <parent>Magento/blank</parent> <media> <preview_image>media/preview.jpg</preview_image> diff --git a/app/etc/di.xml b/app/etc/di.xml index e8440ff4a4b..c586ec91283 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -102,7 +102,6 @@ </type> <type name="Magento\Framework\Api\FilterBuilder" shared="false" /> <type name="Magento\Framework\Api\SearchCriteriaBuilder" shared="false" /> - <type name="Magento\Framework\Api\AttributeValueBuilder" shared="false" /> <type name="Magento\Framework\View\Layout\Builder" shared="false" /> <type name="Magento\Framework\View\Page\Builder" shared="false" /> <type name="Magento\Framework\Message\Manager"> diff --git a/app/i18n/magento/de_de/composer.json b/app/i18n/magento/de_de/composer.json index 04c5fa37ffb..2f79ba8b3de 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 2da87721ec0..0bae8cff86b 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 2d4801b4d25..e8a1d9c61d9 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 dbbea826ea6..023ce244a20 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 7e8220b3a6d..2c56e12d909 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 ea16345b323..2aec74a84a6 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "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 38e1cdcc023..49e9b73e80c 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-alpha103", + "version": "0.1.0-alpha104", "require": { - "magento/framework": "0.1.0-alpha103", + "magento/framework": "0.1.0-alpha104", "magento/magento-composer-installer": "*" }, "type": "magento2-language", diff --git a/composer.json b/composer.json index 6e91b7b16cc..5429b05db8f 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-alpha103", + "version": "0.1.0-alpha104", "require": { "php": "~5.4.11|~5.5.0", "zendframework/zend-stdlib": "2.0.3" diff --git a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/ConditionsElement.php b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/ConditionsElement.php index ad185157e02..5175c113edc 100644 --- a/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/ConditionsElement.php @@ -52,6 +52,8 @@ use Mtf\ObjectManager; * [Subtotal|is|100] * {Product attribute combination|NOT FOUND|ANY:[[Attribute Set|is|Default][Attribute Set|is|Default]]} * ]} + * + * @SuppressWarnings(PHPMD.TooManyFields) */ class ConditionsElement extends AbstractElement { @@ -178,6 +180,13 @@ class ConditionsElement extends AbstractElement */ protected $chooserGridLocator = 'div[id*=chooser]'; + /** + * Rule param input selector. + * + * @var string + */ + protected $ruleParamInput = '.element [name^="rule[conditions]"]'; + /** * Set value to conditions * @@ -247,6 +256,13 @@ class ConditionsElement extends AbstractElement $newCondition = $context->find($this->newCondition, Locator::SELECTOR_XPATH); $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); + $typeNew = $this->typeNew; + $newCondition->waitUntil( + function () use ($newCondition, $typeNew) { + $element = $newCondition->find($typeNew, Locator::SELECTOR_XPATH, 'select'); + return $element->isVisible() ? true : null; + } + ); $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($condition['type']); $this->ruleParamWait(); @@ -282,7 +298,13 @@ class ConditionsElement extends AbstractElement $grid->searchAndSelect([$chooserConfig[1] => $rule]); continue; } - + $input = $this->ruleParamInput; + $param->waitUntil( + function () use ($param, $input) { + $element = $param->find($input); + return $element->isVisible() ? true : null; + } + ); $value = $param->find('select', Locator::SELECTOR_CSS, 'select'); if ($value->isVisible()) { $value->setValue($rule); 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 2b95d3fe470..7a6dd546e3b 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 @@ -41,7 +41,7 @@ class View extends \Magento\Catalog\Test\Block\Product\View * * @var string */ - protected $customizeButton = '.action.primary.customize'; + protected $customizeButton = '.action.primary.customize span'; /** * Bundle options block diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php index 1da8099492b..2e8991f6228 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertTierPriceOnBundleProductPage.php @@ -67,10 +67,10 @@ class AssertTierPriceOnBundleProductPage extends AssertProductTierPriceOnProduct { //Open product view page $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); - $viewBlock = $catalogProductView->getViewBlock(); + $viewBlock = $catalogProductView->getBundleViewBlock(); $viewBlock->clickCustomize(); //Process assertions - $this->assertPrice($product, $catalogProductView); + $this->assertPrice($product, $viewBlock); } } 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 470c1a0e668..5db58f896ee 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 @@ -32,5 +32,10 @@ </bundle> </renders> </viewBlock> + <bundleViewBlock> + <class>Magento\Bundle\Test\Block\Catalog\Product\View</class> + <locator>#maincontent</locator> + <strategy>css selector</strategy> + </bundleViewBlock> </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 57103046af3..eb34fb40c5b 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 @@ -110,7 +110,7 @@ class BundleDynamicTest extends Functional $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue( $productListBlock->isProductVisible($product->getName()), - 'Product "' . $product->getName() . '" is absent on category page' + 'Product "' . $product->getName() . '" is absent on category page' ); $productListBlock->openProductViewPage($product->getName()); //Verification on product detail page @@ -123,9 +123,8 @@ class BundleDynamicTest extends Functional 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo() ] ); - - $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); + $actualOptions = $productViewBlock->getOptions($product)['bundle_options']; 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 26025de223c..c73f0f00bef 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 @@ -120,9 +120,8 @@ class BundleFixedTest extends Functional 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo() ] ); - - $actualOptions = $productPage->getViewBlock()->getOptions($product)['bundle_options']; $expectedOptions = $product->getBundleOptions(); + $actualOptions = $productViewBlock->getOptions($product)['bundle_options']; foreach ($actualOptions as $key => $actualOption) { $this->assertContains($expectedOptions[$key]['title'], $actualOption); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/CategoryIds.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/CategoryIds.php index 822ecf09c94..28c58e94127 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/CategoryIds.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/CategoryIds.php @@ -52,7 +52,7 @@ class CategoryIds extends MultisuggestElement * * @var string */ - protected $top = './ancestor::body//form[@data-form="edit-product"]'; + protected $top = './ancestor::body//*[@class="page-main-actions"]'; /** * Set value diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ProductOnlineSwitcher.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ProductOnlineSwitcher.php index c61f192582b..dd80ac49d83 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ProductOnlineSwitcher.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ProductOnlineSwitcher.php @@ -25,6 +25,7 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails; use Mtf\Client\Driver\Selenium\Element; +use Mtf\Client\Element\Locator; /** * Class ProductOnlineSwitcher @@ -39,6 +40,13 @@ class ProductOnlineSwitcher extends Element */ protected $onlineSwitcher = '#product-online-switcher%s + [for="product-online-switcher"]'; + /** + * Selector for top page click. + * + * @var string + */ + protected $topPage = './ancestor::body//*[@class="page-main-actions"]'; + /** * Set value * @@ -56,6 +64,7 @@ class ProductOnlineSwitcher extends Element && $this->find(sprintf($this->onlineSwitcher, ':not(:checked)'))->isVisible() ) ) { + $this->find($this->topPage, Locator::SELECTOR_XPATH)->click(); $this->find(sprintf($this->onlineSwitcher, ''))->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/View.php index b056a546fb3..976a8e13c96 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/View.php @@ -25,6 +25,8 @@ namespace Magento\Catalog\Test\Block\Category; use Mtf\Block\Block; +use Mtf\Client\Element\Locator; +use Magento\Widget\Test\Fixture\Widget; /** * Class View @@ -32,6 +34,13 @@ use Mtf\Block\Block; */ class View extends Block { + /** + * Recently Viewed Products selectors + * + * @var string + */ + protected $recentlyViewedProducts = './/*[contains(@class,"widget")]//strong[@class="product-item-name"]'; + /** * Description CSS selector * @@ -39,6 +48,13 @@ class View extends Block */ protected $description = '.category-description'; + /** + * Locator for category content + * + * @var string + */ + protected $content = '.category-cms'; + /** * Get description * @@ -56,6 +72,23 @@ class View extends Block */ public function getContent() { - return $this->_rootElement->getText(); + return $this->_rootElement->find($this->content)->getText(); + } + + /** + * Get products from Recently Viewed block + * + * @return array + */ + public function getProductsFromRecentlyViewedBlock() + { + $products = []; + $this->waitForElementVisible($this->recentlyViewedProducts, Locator::SELECTOR_XPATH); + $productNames = $this->_rootElement->find($this->recentlyViewedProducts, Locator::SELECTOR_XPATH) + ->getElements(); + foreach ($productNames as $productName) { + $products[] = $productName->getText(); + } + return $products; } } 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 bc2fd6057cd..f98b1418d44 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 @@ -60,5 +60,10 @@ <locator>#maincontent</locator> <strategy>css selector</strategy> </viewBlock> + <widgetView> + <class>Magento\Widget\Test\Block\WidgetView</class> + <locator>.widget</locator> + <strategy>css selector</strategy> + </widgetView> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductCompare.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductCompare.xml index 84b218a6881..89772195b7d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductCompare.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductCompare.xml @@ -35,5 +35,10 @@ <locator>.page.messages .messages</locator> <strategy>css selector</strategy> </messagesBlock> + <widgetView> + <class>Magento\Widget\Test\Block\WidgetView</class> + <locator>.column.main .widget</locator> + <strategy>css selector</strategy> + </widgetView> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml index 53b581d68cb..3c4c81657ae 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml @@ -85,5 +85,10 @@ <locator>.page-title h1.title .base</locator> <strategy>css selector</strategy> </titleBlock> + <widgetView> + <class>Magento\Widget\Test\Block\WidgetView</class> + <locator>.column.main .widget</locator> + <strategy>css selector</strategy> + </widgetView> </blocks> </page> 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 701b6b75486..e46a8edc14b 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 @@ -27,8 +27,7 @@ namespace Magento\Catalog\Test\Repository; use Mtf\Repository\AbstractRepository; /** - * Class CatalogProductSimple - * Data for creation Catalog Product Simple + * Data for creation Catalog Product Simple. */ class CatalogProductSimple extends AbstractRepository { @@ -220,7 +219,7 @@ class CatalogProductSimple extends AbstractRepository ]; $this->_data['adc_123_simple_for_advancedsearch'] = [ - 'name' => 'adc_123', + 'name' => 'adc_123_%isolation%', 'sku' => 'adc_123', 'price' => ['value' => 100.00, 'preset' => '-'], 'tax_class_id' => ['dataSet' => 'None'], @@ -268,7 +267,7 @@ class CatalogProductSimple extends AbstractRepository ]; $this->_data['abc_dfj_simple_for_advancedsearch'] = [ - 'name' => 'abc_dfj', + 'name' => 'abc_dfj_%isolation%', 'sku' => 'abc_dfj', 'price' => ['value' => 50.00, 'preset' => '-'], 'tax_class_id' => ['dataSet' => 'Taxable Goods'], diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Handler/CatalogSearchQuery/Curl.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Handler/CatalogSearchQuery/Curl.php index 94b3ec11621..8b76fd0bc48 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Handler/CatalogSearchQuery/Curl.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Handler/CatalogSearchQuery/Curl.php @@ -32,8 +32,7 @@ use Mtf\Util\Protocol\CurlTransport\BackendDecorator; use Mtf\Handler\Curl as AbstractCurl; /** - * Class Curl - * Create new search term via curl + * Create new search term via curl. */ class Curl extends AbstractCurl implements CatalogSearchQueryInterface { @@ -51,6 +50,13 @@ class Curl extends AbstractCurl implements CatalogSearchQueryInterface ] ]; + /** + * Search term url. + * + * @var string + */ + protected $url = 'search/term/'; + /** * Post request for creating search term * @@ -67,13 +73,13 @@ class Curl extends AbstractCurl implements CatalogSearchQueryInterface } /** - * Add new search term + * Add new search term. * * @param array $data */ protected function addNewSearchTerm(array $data) { - $url = $_ENV['app_backend_url'] . 'catalog/search/save'; + $url = $_ENV['app_backend_url'] . $this->url . 'save'; $curl = new BackendDecorator(new CurlTransport(), new Config); $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $curl->read(); @@ -81,7 +87,7 @@ class Curl extends AbstractCurl implements CatalogSearchQueryInterface } /** - * Getting search term id + * Getting search term id. * * @param string $queryText * @return int @@ -90,13 +96,13 @@ class Curl extends AbstractCurl implements CatalogSearchQueryInterface protected function getNewSearchTermId($queryText) { $filter = base64_encode('search_query=' . $queryText); - $url = $_ENV['app_backend_url'] . 'catalog/search/index/filter/' . $filter; + $url = $_ENV['app_backend_url'] . $this->url . 'index/filter/' . $filter; $curl = new BackendDecorator(new CurlTransport(), new Config); $curl->write(CurlInterface::GET, $url, '1.0'); $response = $curl->read(); $curl->close(); - if (!preg_match('#search/edit/id/(\d+)/"#', $response, $matches)) { + if (!preg_match('#' . $this->url . 'edit/id/(\d+)/"#', $response, $matches)) { throw new \Exception('Search term not found in grid!'); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml index 321aea4d757..16e72e509a3 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<page mca="catalog/search/edit" module="Magento_CatalogSearch"> +<page mca="search/term/edit" module="Magento_CatalogSearch"> <blocks> <form> <class>Magento\CatalogSearch\Test\Block\Adminhtml\Edit\SearchTermForm</class> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchIndex.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchIndex.xml index 7821a3be4ee..9fb7a875ab2 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchIndex.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchIndex.xml @@ -23,11 +23,11 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<page mca="catalog/search/index" module="Magento_CatalogSearch"> +<page mca="search/term" module="Magento_CatalogSearch"> <blocks> <grid> <class>Magento\CatalogSearch\Test\Block\Adminhtml\Grid</class> - <locator>#catalog_search_grid</locator> + <locator>#search_term_grid</locator> <strategy>css selector</strategy> </grid> <gridPageActions> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml index 11b296b264b..548e9aaec7c 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml @@ -30,5 +30,10 @@ <locator>.form.search.advanced</locator> <strategy>css selector</strategy> </form> + <widgetView> + <class>Magento\Widget\Test\Block\WidgetView</class> + <locator>.widget</locator> + <strategy>css selector</strategy> + </widgetView> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.php index 5e2861cf2fc..887e6b67b1f 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.php @@ -31,8 +31,6 @@ use Magento\CatalogSearch\Test\Page\AdvancedSearch; use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** - * Test Creation for AdvancedSearchEntity - * * Test Flow: * Preconditions: * 1. Two specific simple product is created(unique sku,name,short/full description, tax class) @@ -90,7 +88,7 @@ class AdvancedSearchEntityTest extends Injectable * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function testSearch( + public function test( array $products, CatalogProductSimple $productSearch, CmsIndex $cmsIndex, diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/test.csv similarity index 77% rename from dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv rename to dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/test.csv index c48e64424e4..25bbad9bcc9 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/testSearch.csv +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest/test.csv @@ -1,13 +1,13 @@ -"products/simple_1";"products/simple_2";"productSearch/data/name";"productSearch/data/sku";"productSearch/data/description";"productSearch/data/short_description";"productSearch/data/price/value/price_from";"productSearch/data/price/value/price_to";"constraint" -"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;500;"assertAdvancedSearchProductsResult" -"Yes";"-";"abc";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" -"-";"Yes";"adc_123";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc_dfj";"-";"-";"-";"-";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"abc";"full";"-";"-";"-";"assertAdvancedSearchProductsResult" -"-";"Yes";"-";"-";"dfj_full";"-";"-";"-";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"-";"-";"short";"-";"-";"assertAdvancedSearchProductsResult" -"-";"-";"-";"-";"-";"dfj_short";"-";"-";"assertAdvancedSearchProductsResult" -"Yes";"-";"-";"-";"-";"-";50;50;"assertAdvancedSearchProductsResult" -"Yes";"Yes";"-";"-";"-";"-";"-";100;"assertAdvancedSearchProductsResult" -"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;50;"assertAdvancedSearchProductsResult" +"products/simple_1";"products/simple_2";"productSearch/data/name";"productSearch/data/sku";"productSearch/data/description";"productSearch/data/short_description";"productSearch/data/price/value/price_from";"productSearch/data/price/value/price_to";"constraint";"issue" +"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;500;"assertAdvancedSearchProductsResult";"" +"Yes";"-";"abc";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult";"MAGETWO-30318" +"-";"Yes";"adc_123";"-";"-";"-";"-";"-";"assertAdvancedSearchProductsResult";"" +"Yes";"-";"-";"abc";"-";"-";"-";"-";"assertAdvancedSearchProductsResult";"" +"Yes";"-";"-";"abc_dfj";"-";"-";"-";"-";"assertAdvancedSearchProductsResult";"" +"Yes";"-";"-";"abc";"full";"-";"-";"-";"assertAdvancedSearchProductsResult";"MAGETWO-30318" +"-";"Yes";"-";"-";"dfj_full";"-";"-";"-";"assertAdvancedSearchProductsResult";"" +"Yes";"-";"-";"-";"-";"short";"-";"-";"assertAdvancedSearchProductsResult";"MAGETWO-30318" +"-";"-";"-";"-";"-";"dfj_short";"-";"-";"assertAdvancedSearchProductsResult";"" +"Yes";"-";"-";"-";"-";"-";50;50;"assertAdvancedSearchProductsResult";"MAGETWO-30318" +"Yes";"Yes";"-";"-";"-";"-";"-";100;"assertAdvancedSearchProductsResult";"MAGETWO-30318" +"Yes";"-";"abc_dfj";"abc_dfj";"adc_Full";"abc_short";49;50;"assertAdvancedSearchProductsResult";"MAGETWO-30318" diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/EditSearchTermEntityTest/test.csv b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/EditSearchTermEntityTest/test.csv index 28764fb922a..c7e90bce0d3 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/EditSearchTermEntityTest/test.csv +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/EditSearchTermEntityTest/test.csv @@ -1,2 +1,2 @@ "searchTerm/data/query_text/value";"searchTerm/data/store_id";"searchTerm/data/num_results";"searchTerm/data/popularity";"searchTerm/data/synonym_for";"searchTerm/data/redirect";"searchTerm/data/display_in_terms";"constraint" -"catalogProductSimple::getSku";"Main Website/Main Website Store/Default Store View";1;20;"simple";"http://example.com/";"No";"assertSearchTermSuccessSaveMessage, assertSearchTermForm, assertSearchTermInGrid, assertSearchTermOnFrontend" +"catalogProductSimple::getSku";"Main Website/Main Website Store/Default Store View";1;20;"simple%isolation%";"http://example.com/";"No";"assertSearchTermSuccessSaveMessage, assertSearchTermForm, assertSearchTermInGrid, assertSearchTermOnFrontend" diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/etc/page.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/etc/page.xml index f29d5cfa112..15e18c204ae 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/etc/page.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/etc/page.xml @@ -30,12 +30,12 @@ </catalogsearchResult> <catalogSearchIndex> <area>adminhtml</area> - <mca>catalog/search/index</mca> + <mca>search/term</mca> <class>Magento\CatalogSearch\Test\Page\Adminhtml\CatalogSearchIndex</class> </catalogSearchIndex> <catalogSearchEdit> <area>adminhtml</area> - <mca>catalog/search/edit</mca> + <mca>search/term/edit</mca> <class>Magento\CatalogSearch\Test\Page\Adminhtml\CatalogSearchEdit</class> </catalogSearchEdit> </page> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml index a1a7c4ff0e0..7ea1e3ed913 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/fixture.xml @@ -26,7 +26,7 @@ <fixture> <cart module="Magento_Checkout"> <type>flat</type> - <entity_type>sales_flat_quote</entity_type> + <entity_type>sales_quote</entity_type> <collection>Magento\Checkout\Model\Resource\Cart</collection> </cart> </fixture> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/CmsIndex.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/CmsIndex.xml index 9fa7731d6c2..cbdec15ecfa 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/CmsIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/CmsIndex.xml @@ -75,5 +75,10 @@ <locator>.page.main</locator> <strategy>css selector</strategy> </cmsPageBlock> + <widgetView> + <class>Magento\Widget\Test\Block\WidgetView</class> + <locator>.widget</locator> + <strategy>css selector</strategy> + </widgetView> </blocks> </page> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesAbsentOnProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesAbsentOnProductPage.php index 6f80540e34c..66d3da9432b 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesAbsentOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesAbsentOnProductPage.php @@ -31,7 +31,7 @@ use Mtf\Constraint\AbstractConstraint; use Mtf\Client\Browser; /** - * Assert that deleted products attributes are absent on product page on frontend. + * Assert that deleted configurable attributes are absent on product page on frontend. */ class AssertConfigurableAttributesAbsentOnProductPage extends AbstractConstraint { @@ -43,7 +43,7 @@ class AssertConfigurableAttributesAbsentOnProductPage extends AbstractConstraint protected $severeness = 'low'; /** - * Assert that deleted products attributes are absent on product page on frontend. + * Assert that deleted configurable attributes are absent on product page on frontend. * * @param CatalogProductAttribute[] $deletedProductAttributes * @param Browser $browser @@ -64,7 +64,7 @@ class AssertConfigurableAttributesAbsentOnProductPage extends AbstractConstraint $attributeLabel = $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertFalse( isset($pageOptions[$attributeLabel]), - "Product attribute '$attributeLabel' found on product page on frontend." + "Configurable attribute '$attributeLabel' found on product page on frontend." ); } } @@ -76,6 +76,6 @@ class AssertConfigurableAttributesAbsentOnProductPage extends AbstractConstraint */ public function toString() { - return "Product attributes are absent on product page on frontend."; + return "Configurable attributes are absent on product page on frontend."; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesBlockIsAbsentOnProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesBlockIsAbsentOnProductPage.php index 5b89b2d82e7..65194e6d4aa 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesBlockIsAbsentOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableAttributesBlockIsAbsentOnProductPage.php @@ -42,7 +42,7 @@ class AssertConfigurableAttributesBlockIsAbsentOnProductPage extends AbstractCon protected $severeness = 'low'; /** - * Assert that all products attributes is absent on product page on frontend. + * Assert that all configurable attributes is absent on product page on frontend. * * @param Browser $browser * @param CatalogProductView $catalogProductView @@ -57,7 +57,7 @@ class AssertConfigurableAttributesBlockIsAbsentOnProductPage extends AbstractCon $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertFalse( $catalogProductView->getConfigurableAttributesBlock()->isVisible(), - "Product attributes are present on product page on frontend." + "Configurable attributes are present on product page on frontend." ); } @@ -68,6 +68,6 @@ class AssertConfigurableAttributesBlockIsAbsentOnProductPage extends AbstractCon */ public function toString() { - return "All product attributes are absent on product page on frontend."; + return "All configurable attributes are absent on product page on frontend."; } } 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 index cd507b550ae..d5ac176b9e7 100755 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductForm.php @@ -66,6 +66,11 @@ class AssertConfigurableProductForm extends AssertProductForm 'is_default', ]; + /** + * Skipped variation matrix field. + * + * @var array + */ protected $skippedVariationMatrixFields = [ 'configurable_attribute' ]; diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/TestStep/SetupConfigurationStep.php b/dev/tests/functional/tests/app/Magento/Core/Test/TestStep/SetupConfigurationStep.php index 1986caa81af..20a3f387be4 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/TestStep/SetupConfigurationStep.php +++ b/dev/tests/functional/tests/app/Magento/Core/Test/TestStep/SetupConfigurationStep.php @@ -86,9 +86,10 @@ class SetupConfigurationStep implements TestStepInterface foreach ($configData as $configDataSet) { $config = $this->fixtureFactory->createByCode('configData', ['dataSet' => $configDataSet . $prefix]); - $config->persist(); - - $result[] = $config; + if ($config->hasData('section')) { + $config->persist(); + $result[] = $config; + } } return ['config' => $result]; diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php index b379af48b64..b454ded90eb 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php @@ -27,26 +27,26 @@ namespace Magento\Customer\Test\Block\Address; use Magento\Customer\Test\Fixture\AddressInjectable; /** - * Class Renderer - * Render output from AddressInjectable fixture according to data format type + * Render output from AddressInjectable fixture according to data format type. */ class Renderer { /** - * Address format type + * Address format type. * * @var string */ protected $type; /** - * AddressInjectable fixture + * AddressInjectable fixture. * * @var AddressInjectable */ protected $address; /** + * @constructor * @param AddressInjectable $address * @param string $type */ @@ -57,7 +57,7 @@ class Renderer } /** - * Returns pattern according to address type + * Returns pattern according to address type. * * @return string */ @@ -65,6 +65,12 @@ class Renderer { $region = $this->resolveRegion(); switch ($this->type) { + case "html": + $outputPattern = "{{depend}}{{prefix}} {{/depend}}{{firstname}} {{depend}}{{middlename}} {{/depend}}" + . "{{lastname}}{{depend}} {{suffix}}{{/depend}}\n{{depend}}{{company}}\n{{/depend}}{{street}}\n" + . "{{city}}, {{{$region}}}, {{postcode}}\n{{country_id}}\n{{depend}}T: {{telephone}}{{/depend}}" + . "{{depend}}\nF: {{fax}}{{/depend}}{{depend}}\nVAT: {{vat_id}}{{/depend}}"; + break; case "oneline": default: $outputPattern = "{{depend}}{{prefix}} {{/depend}}{{firstname}} {{depend}}{{middlename}} {{/depend}}" @@ -76,7 +82,7 @@ class Renderer } /** - * Render address according to format type + * Render address according to format type. * * @return string */ @@ -85,18 +91,18 @@ class Renderer $outputPattern = $this->getPattern(); $fields = $this->getFieldsArray($outputPattern); $output = $this->preparePattern(); + $output = str_replace(['{{depend}}', '{{/depend}}', '{', '}'], '', $output); foreach ($fields as $field) { $data = $this->address->getData($field); $output = str_replace($field, $data, $output); } - $output = str_replace(['{', '}'], '', $output); return $output; } /** - * Get an array of necessary fields from pattern + * Get an array of necessary fields from pattern. * * @param string $outputPattern * @return mixed @@ -114,14 +120,14 @@ class Renderer } /** - * Purge fields from pattern which are not present in fixture + * Purge fields from pattern which are not present in fixture. * * @return string */ protected function preparePattern() { $outputPattern = $this->getPattern(); - preg_match_all('@\{\{depend\}\}(.*?)\{\{.depend\}\}@', $outputPattern, $matches); + preg_match_all('@\{\{depend\}\}(.*?)\{\{.depend\}\}@siu', $outputPattern, $matches); foreach ($matches[1] as $key => $dependPart) { preg_match_all('@\{\{(\w+)\}\}@', $dependPart, $depends); foreach ($depends[1] as $depend) { @@ -134,7 +140,7 @@ class Renderer } /** - * Check necessary field to retrieve according to address country + * Check necessary field to retrieve according to address country. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php index f9b743f4eed..4852b1a13ca 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php @@ -70,6 +70,16 @@ class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\Ch 'subtotal' => 22.43 ] ], + 'default' => [ + 'options' => [ + 'links' => [ + [ + 'label' => 'link_1', + 'value' => 'Yes' + ] + ], + ] + ], ]; return isset($presets[$name]) ? $presets[$name] : []; } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductInItemsOrderedGrid.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductInItemsOrderedGrid.php index 5b940aef244..729d0c84576 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductInItemsOrderedGrid.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedProductInItemsOrderedGrid.php @@ -59,16 +59,16 @@ class AssertGroupedProductInItemsOrderedGrid extends AbstractConstraint * Assert product was added to Items Ordered grid in customer account on Order creation page backend * * @param OrderCreateIndex $orderCreateIndex - * @param array $entityData + * @param array $products * @throws \Exception * @return void */ - public function processAssert(OrderCreateIndex $orderCreateIndex, array $entityData) + public function processAssert(OrderCreateIndex $orderCreateIndex, array $products) { - if (!isset($entityData['products'])) { + if (empty($products)) { throw new \Exception("No products"); } - $data = $this->prepareData($entityData, $orderCreateIndex->getCreateBlock()->getItemsBlock()); + $data = $this->prepareData($products, $orderCreateIndex->getCreateBlock()->getItemsBlock()); \PHPUnit_Framework_Assert::assertEquals( $data['fixtureData'], @@ -87,7 +87,7 @@ class AssertGroupedProductInItemsOrderedGrid extends AbstractConstraint protected function prepareData(array $data, Items $itemsBlock) { $fixtureData = []; - foreach ($data['products'] as $product) { + foreach ($data as $product) { $products = $product->getAssociated()['products']; foreach ($products as $key => $value) { $fixtureData[$key]['name'] = $value->getName(); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items/Product.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items/Product.php index 7e148cb7130..a998c4bbfb6 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items/Product.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Customer/Wishlist/Items/Product.php @@ -25,6 +25,7 @@ namespace Magento\Wishlist\Test\Block\Customer\Wishlist\Items; use Mtf\Block\Form; +use Mtf\Client\Element\Locator; /** * Class Product @@ -53,6 +54,13 @@ class Product extends Form */ protected $viewDetails = '.details.tooltip'; + /** + * Selector for 'Details block' element + * + * @var string + */ + protected $detailsBlock = '.product-item-tooltip'; + /** * Edit button css selector * @@ -74,6 +82,13 @@ class Product extends Form */ protected $optionValue = '.tooltip.content .values'; + /** + * Selector for click on footer block + * + * @var string + */ + protected $footer = './ancestor::body//footer'; + /** * Fill item product details * @@ -115,11 +130,15 @@ class Product extends Form { $viewDetails = $this->_rootElement->find($this->viewDetails); if ($viewDetails->isVisible()) { + $this->_rootElement->find($this->footer, Locator::SELECTOR_XPATH)->click(); $viewDetails->click(); $labels = $this->_rootElement->find($this->optionLabel)->getElements(); $values = $this->_rootElement->find($this->optionValue)->getElements(); $data = []; foreach ($labels as $key => $label) { + if (!$label->isVisible()) { + $viewDetails->click(); + } $data[] = [ 'title' => $label->getText(), 'value' => str_replace('$', '', $values[$key]->getText()) diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductDetailsInWishlist.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductDetailsInWishlist.php index 2180f8cceb3..9098a426830 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductDetailsInWishlist.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductDetailsInWishlist.php @@ -24,7 +24,7 @@ namespace Magento\Wishlist\Test\Constraint; -use Mtf\Constraint\AbstractConstraint; +use Mtf\Constraint\AbstractAssertForm; use Magento\Cms\Test\Page\CmsIndex; use Magento\Wishlist\Test\Page\WishlistIndex; use Mtf\Fixture\FixtureFactory; @@ -34,7 +34,7 @@ use Mtf\Fixture\InjectableFixture; * Class AssertBundleProductDetailsInWishlist * Assert that the correct option details are displayed on the "View Details" tool tip */ -class AssertProductDetailsInWishlist extends AbstractConstraint +class AssertProductDetailsInWishlist extends AbstractAssertForm { /** * Constraint severeness @@ -63,11 +63,8 @@ class AssertProductDetailsInWishlist extends AbstractConstraint $cartFixture = $fixtureFactory->createByCode('cart', ['data' => ['items' => ['products' => [$product]]]]); $expectedOptions = $cartFixture->getItems()[0]->getData()['options']; - \PHPUnit_Framework_Assert::assertEquals( - $expectedOptions, - $actualOptions, - "Expected product options are not equal to actual." - ); + $errors = $this->verifyData($expectedOptions, $actualOptions); + \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); } /** diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php index e41e009f833..fee9db34711 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php @@ -68,6 +68,7 @@ class AddProductsToCartFromCustomerWishlistOnFrontendTest extends AbstractWishli */ public function test(CustomerInjectable $customer, $products, $qty, Browser $browser) { + $this->markTestIncomplete("Bug: MAGETWO-30097"); // Preconditions $this->browser = $browser; $customer->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.php index e57e3a27546..8827034ea78 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.php @@ -71,6 +71,7 @@ class ConfigureProductInCustomerWishlistOnFrontendTest extends AbstractWishlistT */ public function test(CustomerInjectable $customer, $product) { + $this->markTestIncomplete("Bug: MAGETWO-30097"); // Preconditions $product = $this->createProducts($product)[0]; $this->loginCustomer($customer); 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 5fd6ded0abe..7f74f70127c 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 @@ -174,6 +174,7 @@ class ShareWishlistEntityTest extends Injectable CatalogProductSimple $product, array $sharingInfo ) { + $this->markTestIncomplete("Bug: MAGETWO-30105"); //Steps $this->loginCustomer($customer); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php index d123affbf99..25366065d1a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php @@ -36,7 +36,6 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $catalogProductOption = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Catalog\Model\Product\Option' ); - $eavConfig = $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false); $catalogProductType = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); $eventManager = $this->getMock( 'Magento\Framework\Event\ManagerInterface', @@ -55,7 +54,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase array( $productFactory, $catalogProductOption, - $eavConfig, + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config'), $catalogProductType, $eventManager, $coreData, @@ -304,22 +303,22 @@ class AbstractTest extends \PHPUnit_Framework_TestCase } /** + * @magentoDbIsolation enabled * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Catalog/_files/product_attribute_with_invalid_apply_to.php */ public function testBeforeSave() { - $this->markTestIncomplete('MAGETWO-9199'); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Catalog\Model\Product' ); $product->load(1); // fixture - $product->setData('links_purchased_separately', 'value'); - // this attribute is applicable only for downloadable + $product->setData('attribute_with_invalid_applyto', 'value'); $this->_model->beforeSave($product); $this->assertTrue($product->canAffectOptions()); - $this->assertFalse($product->hasData('links_purchased_separately')); + $this->assertFalse($product->hasData('attribute_with_invalid_applyto')); } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute_with_invalid_apply_to.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute_with_invalid_apply_to.php new file mode 100644 index 00000000000..6b74da686c0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute_with_invalid_apply_to.php @@ -0,0 +1,49 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** @var \Magento\Catalog\Model\Resource\Setup $installer */ +$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Setup', + ['resourceName' => 'catalog_setup'] +); + +/** @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ +$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Eav\Attribute' +); +$attribute->setData( + [ + 'attribute_code' => 'attribute_with_invalid_applyto', + 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), + 'apply_to' => 'invalid-type', + ] +); +$attribute->save(); + +/* Assign attribute to attribute set */ +$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId()); + +/** @var \Magento\Eav\Model\Config $eavConfig */ +$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config'); +$eavConfig->clear(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/IndexerBuilderTest.php b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/IndexerBuilderTest.php new file mode 100644 index 00000000000..9d659af73d3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/IndexerBuilderTest.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\CatalogRule\Model\Indexer; + +use Magento\TestFramework\Helper\Bootstrap; + +class IndexerBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder + */ + protected $indexerBuilder; + + /** + * @var \Magento\CatalogRule\Model\Resource\Rule + */ + protected $resourceRule; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $product; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productSecond; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $productThird; + + protected function setUp() + { + $this->indexerBuilder = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Indexer\IndexBuilder'); + $this->resourceRule = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Resource\Rule'); + $this->product = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\Product'); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/CatalogRule/_files/attribute.php + * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testReindexById() + { + $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save(); + + $this->indexerBuilder->reindexById(1); + + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, 1)); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/CatalogRule/_files/attribute.php + * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testReindexByIds() + { + $this->prepareProducts(); + + $this->indexerBuilder->reindexByIds([ + $this->product->getId(), + $this->productSecond->getId(), + $this->productThird->getId() + ]); + + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, 1)); + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, $this->productSecond->getId())); + $this->assertFalse($this->resourceRule->getRulePrice(true, 1, 1, $this->productThird->getId())); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/CatalogRule/_files/attribute.php + * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testReindexFull() + { + $this->prepareProducts(); + + $this->indexerBuilder->reindexFull(); + + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, 1)); + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, $this->productSecond->getId())); + $this->assertFalse($this->resourceRule->getRulePrice(true, 1, 1, $this->productThird->getId())); + } + + protected function prepareProducts() + { + $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save(); + $this->productSecond = clone $this->product; + $this->productSecond->setId(null)->save(); + $this->productThird = clone $this->product; + $this->productThird->setId(null)->setData('test_attribute', 'NO_test_attribute_value')->save(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/ProductRuleTest.php b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/ProductRuleTest.php new file mode 100644 index 00000000000..ebab141b58e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/ProductRuleTest.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\CatalogRule\Model\Indexer; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ +class ProductRuleTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Resource\Rule + */ + protected $resourceRule; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $product; + + protected function setUp() + { + $this->resourceRule = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Resource\Rule'); + $this->product = Bootstrap::getObjectManager()->get('Magento\Catalog\Model\Product'); + + Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor') + ->getIndexer()->isScheduled(false); + } + + /** + * @magentoDataFixture Magento/CatalogRule/_files/attribute.php + * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoAppArea adminhtml + */ + public function testReindexAfterSuitableProductSaving() + { + $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save(); + + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, 1)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/RuleProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/RuleProductTest.php new file mode 100644 index 00000000000..799fccbb78a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/Model/Indexer/RuleProductTest.php @@ -0,0 +1,76 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Model\Indexer; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ +class RuleProductTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder + */ + protected $indexBuilder; + + /** + * @var \Magento\CatalogRule\Model\Resource\Rule + */ + protected $resourceRule; + + /** + * @var \Magento\Catalog\Model\Product + */ + protected $product; + + protected function setUp() + { + $this->indexBuilder = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Indexer\IndexBuilder'); + $this->resourceRule = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\Resource\Rule'); + $this->product = Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); + } + + /** + * @magentoDataFixture Magento/CatalogRule/_files/attribute.php + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testReindexAfterRuleCreation() + { + $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save(); + $this->assertFalse($this->resourceRule->getRulePrice(true, 1, 1, 1)); + + $this->saveRule(); + // apply all rules + $this->indexBuilder->reindexFull(); + + $this->assertEquals(9.8, $this->resourceRule->getRulePrice(true, 1, 1, 1)); + } + + protected function saveRule() + { + require 'Magento/CatalogRule/_files/rule_by_attribute.php'; + } +} diff --git a/dev/tests/integration/testsuite/Magento/CatalogRule/_files/attribute.php b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/attribute.php new file mode 100644 index 00000000000..5b556d27b0a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/attribute.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) + */ + +/** @var \Magento\Catalog\Model\Resource\Setup $installer */ +$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Setup', + array('resourceName' => 'catalog_setup') +); + +/** @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ +$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Catalog\Model\Resource\Eav\Attribute' +); +$attribute->setData( + [ + 'attribute_code' => 'test_attribute', + 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), + 'is_global' => 1, + 'is_user_defined' => 1, + 'frontend_input' => 'text', + 'is_used_for_promo_rules' => 1, + 'backend_type' => 'text', + ] +); +$attribute->save(); + +/* Assign attribute to attribute set */ +$installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId()); + +/** @var \Magento\Eav\Model\Config $eavConfig */ +$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config'); +$eavConfig->clear(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php index 15605cd20c4..9487109503c 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php @@ -39,4 +39,7 @@ $catalogRule ->setSimpleAction('by_percent') ->save(); -$catalogRule->applyAll(); +/** @var \Magento\CatalogRule\Model\Indexer\IndexBuilder $indexBuilder */ +$indexBuilder = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\CatalogRule\Model\Indexer\IndexBuilder'); +$indexBuilder->reindexFull(); diff --git a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/rule_by_attribute.php similarity index 50% rename from app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php rename to dev/tests/integration/testsuite/Magento/CatalogRule/_files/rule_by_attribute.php index 03fdc17f2ea..ec66b7c44ad 100644 --- a/app/code/Magento/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php +++ b/dev/tests/integration/testsuite/Magento/CatalogRule/_files/rule_by_attribute.php @@ -22,16 +22,32 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Setup\Module\SetupModule */ -$installer = $this; +use Magento\TestFramework\Helper\Bootstrap; -$installer->getConnection() - ->addColumn( - $installer->getTable('paypal_settlement_report_row'), - 'store_id', - array( - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'comment' => 'Store ID', - 'length' => '50' - ) - ); +/** @var \Magento\CatalogRule\Model\Rule $rule */ +$rule = Bootstrap::getObjectManager()->get('Magento\CatalogRule\Model\RuleFactory')->create(); +$rule->loadPost([ + 'name' => 'test_rule', + 'is_active' => '1', + 'website_ids' => [1], + 'customer_group_ids' => [0, 1], + 'discount_amount' => 2, + 'simple_action' => 'by_percent', + 'from_date' => '', + 'to_date' => '', + 'conditions' => [ + '1' => [ + 'type' => 'Magento\CatalogRule\Model\Rule\Condition\Combine', + 'aggregator' => 'all', + 'value' => '1', + 'new_child' => '', + ], + '1--1' => [ + 'type' => 'Magento\CatalogRule\Model\Rule\Condition\Product', + 'attribute' => 'test_attribute', + 'operator' => '==', + 'value' => 'test_attribute_value', + ], + ], +]); +$rule->save(); diff --git a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.11-1.6.0.12.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/IndexTest.php similarity index 64% rename from app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.11-1.6.0.12.php rename to dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/IndexTest.php index d63f241effc..823151c6920 100644 --- a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.11-1.6.0.12.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/IndexTest.php @@ -22,17 +22,16 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** @var $installer \Magento\Sales\Model\Resource\Setup */ -$installer = $this; -$installer->startSetup(); +namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; -/** Update visibility for states */ -$states = array('new', 'processing', 'complete', 'closed', 'canceled', 'holded', 'payment_review'); -foreach ($states as $state) { - $installer->getConnection()->update( - $installer->getTable('sales_order_status_state'), - array('visible_on_front' => 1), - array('state = ?' => $state) - ); +class IndexTest extends \Magento\Backend\Utility\Controller +{ + public function testViewAction() + { + $this->dispatch('backend/cms/wysiwyg_images/index/target_element_id/page_content/store/undefined/type/image/'); + $content = $this->getResponse()->getBody(); + $this->assertNotContains('<html', $content); + $this->assertNotContains('<head', $content); + $this->assertNotContains('<body', $content); + } } -$installer->endSetup(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php index ae1c4fec817..64b2c874e4d 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php @@ -65,4 +65,11 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase $this->assertContains('title="Tax/VAT number"', $block->toHtml()); $this->assertContains('required', $block->toHtml()); } + + protected function tearDown() + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config'); + $eavConfig->clear(); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php index 13d9a87450e..49faea05afa 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php @@ -94,7 +94,9 @@ class AddressTest extends \Magento\TestFramework\TestCase\AbstractController 'postcode' => '55555', 'country_id' => 'UA', 'success_url' => '', - 'error_url' => '' + 'error_url' => '', + 'default_billing' => true, + 'default_shipping' => true ) ); // we are overwriting the address coming from the fixture @@ -112,6 +114,8 @@ class AddressTest extends \Magento\TestFramework\TestCase\AbstractController $this->assertEquals('UA', $address->getCountryId()); $this->assertEquals('Kyiv', $address->getCity()); $this->assertEquals('Kiev', $address->getRegion()->getRegion()); + $this->assertTrue($address->isDefaultBilling()); + $this->assertTrue($address->isDefaultShipping()); } /** diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php index 46ca6c18356..d8203c9d0a5 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php @@ -25,11 +25,14 @@ namespace Magento\Customer\Model; use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\AddressInterface; use Magento\Customer\Service\V1; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\State\ExpiredException; +use Magento\Framework\Reflection\DataObjectProcessor; use Magento\TestFramework\Helper\Bootstrap; /** @@ -48,8 +51,8 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase /** @var CustomerRepositoryInterface */ private $customerRepository; - /** @var CustomerAddressServiceInterface needed to setup tests */ - private $_customerAddressService; + /** @var AddressRepositoryInterface needed to setup tests */ + private $addressRepository; /** @var \Magento\Framework\ObjectManager */ private $objectManager; @@ -63,6 +66,9 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Api\Data\CustomerDataBuilder */ private $customerBuilder; + /** @var DataObjectProcessor */ + private $dataProcessor; + protected function setUp() { $this->objectManager = Bootstrap::getObjectManager(); @@ -70,20 +76,21 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase ->create('Magento\Customer\Api\AccountManagementInterface'); $this->customerRepository = $this->objectManager ->create('Magento\Customer\Api\CustomerRepositoryInterface'); - $this->_customerAddressService = - $this->objectManager->create('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); + $this->addressRepository = + $this->objectManager->create('Magento\Customer\Api\AddressRepositoryInterface'); $this->addressBuilder = $this->objectManager->create('Magento\Customer\Api\Data\AddressDataBuilder'); $this->customerBuilder = $this->objectManager->create('Magento\Customer\Api\Data\CustomerDataBuilder'); $regionBuilder = $this->objectManager->create('Magento\Customer\Api\Data\RegionDataBuilder'); - $this->addressBuilder->setId(1) + $this->addressBuilder->setId('1') ->setCountryId('US') - ->setCustomerId(1) + ->setCustomerId('1') ->setPostcode('75477') ->setRegion( $regionBuilder->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1)->create() ) + ->setCompany('CompanyName') ->setStreet(['Green str, 67']) ->setTelephone('3468676') ->setCity('CityM') @@ -91,13 +98,14 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase ->setLastname('Smith'); $address = $this->addressBuilder->create(); - $this->addressBuilder->setId(2) + $this->addressBuilder->setId('2') ->setCountryId('US') - ->setCustomerId(1) + ->setCustomerId('1') ->setPostcode('47676') ->setRegion( $regionBuilder->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1)->create() ) + ->setCompany('Company') ->setStreet(['Black str, 48']) ->setCity('CityX') ->setTelephone('3234676') @@ -106,6 +114,9 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase $address2 = $this->addressBuilder->create(); $this->_expectedAddresses = [$address, $address2]; + + $this->dataProcessor = $this->objectManager + ->create('Magento\Framework\Reflection\DataObjectProcessor'); } /** @@ -827,6 +838,108 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->accountManagement->isEmailAvailable('nonexistent@example.com', 1)); } + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php + */ + public function testGetDefaultBillingAddress() + { + $customerId = 1; + $address = $this->accountManagement->getDefaultBillingAddress($customerId); + + $expected = $this->dataProcessor->buildOutputDataArray( + $this->_expectedAddresses[0], + 'Magento\Customer\Api\Data\AddressInterface' + ); + $result = $this->dataProcessor->buildOutputDataArray($address, 'Magento\Customer\Api\Data\AddressInterface'); + /* + * TODO : Data builder / populateWithArray currently does not detect + * array type and returns street as string instead of array. Need to fix this. + */ + unset($expected[AddressInterface::STREET]); + unset($result[AddressInterface::STREET]); + $this->assertEquals($expected, $result); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testSaveNewAddressDefaults() + { + $customerId = 1; + + /** @var $addressShippingBuilder \Magento\Customer\Api\Data\AddressDataBuilder */ + $addressShippingBuilder = $this->addressBuilder->populate($this->_expectedAddresses[0])->setId(null); + $addressShippingBuilder->setDefaultShipping(true)->setDefaultBilling(false)->setCustomerId($customerId); + //TODO : Will be fixed as part of fixing populate. For now Region is set as Data Object instead of array + $addressShippingBuilder->setRegion($this->_expectedAddresses[0]->getRegion()); + $addressShipping = $addressShippingBuilder->create(); + + /** @var $addressBillingBuilder \Magento\Customer\Api\Data\AddressDataBuilder */ + $addressBillingBuilder = $this->addressBuilder->populate($this->_expectedAddresses[1])->setId(null); + $addressBillingBuilder->setDefaultBilling(true)->setDefaultShipping(false)->setCustomerId($customerId); + //TODO : Will be fixed as part of fixing populate + $addressBillingBuilder->setRegion($this->_expectedAddresses[1]->getRegion()); + $addressBilling = $addressBillingBuilder->create(); + + $addressShippingExpected = $this->addressRepository->save($addressShipping); + $addressBillingExpected = $this->addressRepository->save($addressBilling); + + // Call api under test + $shippingResponse = $this->accountManagement->getDefaultShippingAddress($customerId); + $billingResponse = $this->accountManagement->getDefaultBillingAddress($customerId); + + + // Verify if the new Shipping address created is same as returned by the api under test : + // \Magento\Customer\Api\AccountManagementInterface::getDefaultShippingAddress + $addressShippingExpected = $this->dataProcessor->buildOutputDataArray( + $addressShippingExpected, + 'Magento\Customer\Api\Data\AddressInterface' + ); + $shippingResponse = $this->dataProcessor->buildOutputDataArray( + $shippingResponse, + 'Magento\Customer\Api\Data\AddressInterface' + ); + /* + * TODO : Data builder / populateWithArray currently does not detect + * array type and returns street as string instead of array. Need to fix this. + */ + unset($addressShippingExpected[AddressInterface::STREET]); + unset($shippingResponse[AddressInterface::STREET]); + + $this->assertEquals($addressShippingExpected, $shippingResponse); + + // Verify if the new Billing address created is same as returned by the api under test : + // \Magento\Customer\Api\AccountManagementInterface::getDefaultShippingAddress + $addressBillingExpected = $this->dataProcessor->buildOutputDataArray( + $addressBillingExpected, + 'Magento\Customer\Api\Data\AddressInterface' + ); + $billingResponse = $this->dataProcessor->buildOutputDataArray( + $billingResponse, + 'Magento\Customer\Api\Data\AddressInterface' + ); + /* + * TODO : Data builder / populateWithArray currently does not detect + * array type and returns street as string instead of array. Need to fix this. + */ + unset($addressBillingExpected[AddressInterface::STREET]); + unset($billingResponse[AddressInterface::STREET]); + + $this->assertEquals($addressBillingExpected, $billingResponse); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetDefaultAddressesForNonExistentAddress() + { + $customerId = 1; + $this->assertNull($this->accountManagement->getDefaultBillingAddress($customerId)); + $this->assertNull($this->accountManagement->getDefaultShippingAddress($customerId)); + } + /** * Set Rp data to Customer in fixture * diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/CustomerDetailsBuilderTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/CustomerDetailsBuilderTest.php index 4a984761e94..40cd098a1db 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/CustomerDetailsBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/CustomerDetailsBuilderTest.php @@ -319,7 +319,8 @@ class CustomerDetailsBuilderTest extends \PHPUnit_Framework_TestCase $customerDetailsA = $this->_builder->populateWithArray( array('customer' => $customer, 'addresses' => array($address2)) )->create(); - $customerDetailsB = $this->_builder->mergeDataObjects($customerDetailsC, $customerDetailsA); + $customerDetailsB = $this->_builder->mergeDataObjects($customerDetailsC, $customerDetailsA) + ->create(); $this->assertEquals($customerDetails->__toArray(), $customerDetailsB->__toArray()); } @@ -386,7 +387,7 @@ class CustomerDetailsBuilderTest extends \PHPUnit_Framework_TestCase $customerDetailsB = $this->_builder->mergeDataObjectWithArray( $customerDetailsC, array('addresses' => array($address2)) - ); + )->create(); $this->assertEquals($customerDetails->__toArray(), $customerDetailsB->__toArray()); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilderTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilderTest.php index a1f2bc2c4ad..a528858ac62 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilderTest.php @@ -149,7 +149,8 @@ class AttributeMetadataBuilderTest extends \PHPUnit_Framework_TestCase $attributeMetadata = $this->_builder->populateWithArray($dataNoOptions)->create(); $attributeMetadataA = $this->_builder->populateWithArray($dataWithOptions)->create(); - $merged = $this->_builder->mergeDataObjects($attributeMetadata, $attributeMetadataA); + $merged = $this->_builder->mergeDataObjects($attributeMetadata, $attributeMetadataA) + ->create(); $this->assertEquals($attributeMetadataA, $merged); } @@ -180,7 +181,8 @@ class AttributeMetadataBuilderTest extends \PHPUnit_Framework_TestCase $attributeMetadata = $this->_builder->populateWithArray($dataNoOptions)->create(); $attributeMetadataA = $this->_builder->populateWithArray($dataWithOptions)->create(); - $merged = $this->_builder->mergeDataObjectWithArray($attributeMetadata, $dataWithOptions); + $merged = $this->_builder->mergeDataObjectWithArray($attributeMetadata, $dataWithOptions) + ->create(); $this->assertEquals($attributeMetadataA, $merged); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php index c9a63d38194..7580bd0cd66 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php @@ -25,6 +25,10 @@ namespace Magento\Framework\Api\Code\Generator; use Magento\Wonderland\Api\Data\FakeAddressInterface; use Magento\Wonderland\Api\Data\FakeRegionInterface; +use Magento\Wonderland\Model\Data\FakeAddress; +use Magento\Wonderland\Model\Data\FakeRegion; +use Magento\Framework\Api\ExtensibleDataInterface; +use Magento\Framework\Api\AttributeInterface; class DataBuilderTest extends \PHPUnit_Framework_TestCase { @@ -47,12 +51,100 @@ class DataBuilderTest extends \PHPUnit_Framework_TestCase ); } - public function testPopulateWithArray() + /** + * @dataProvider getBuildersToTest + */ + public function testBuilders($builderType) { + $builder = $this->_objectManager->create($builderType); + $this->assertInstanceOf($builderType, $builder); + } + + public function getBuildersToTest() + { + return [ + ['Magento\Checkout\Service\V1\Data\Cart\TotalsBuilder'], + ]; + } + + public function testDataObjectBuilder() + { + $regionBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeRegionBuilder'); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegionBuilder', $regionBuilder); + $region = $regionBuilder->setRegion('test') + ->setRegionCode('test_code') + ->setRegionId('test_id') + ->create(); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $region); + $this->assertEquals('test', $region->getRegion()); + } + + + public function testDataObjectPopulateWithArray() + { + $data = $this->getAddressArray(); + + /** @var \Magento\Wonderland\Model\Data\FakeAddressBuilder $addressBuilder */ + $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeAddressBuilder'); + /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ + $address = $addressBuilder->populateWithArray($data) + ->create(); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeAddress', $address); + $this->assertEquals('Johnes', $address->getLastname()); + $this->assertNull($address->getCustomAttribute('test')); + $this->assertEmpty($address->getCustomAttributes()); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegion()); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[0]); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[1]); + } + + + public function testDataObjectPopulate() + { + $data = $this->getAddressArray(); + + /** @var \Magento\Wonderland\Model\Data\FakeAddressBuilder $addressBuilder */ + $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeAddressBuilder'); + /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ + $address = $addressBuilder->populateWithArray($data) + ->create(); + + $addressUpdated = $addressBuilder->populate($address) + ->setCompany('RocketScience') + ->create(); + + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeAddress', $addressUpdated); + $this->assertEquals('RocketScience', $addressUpdated->getCompany()); + + $this->assertEmpty($address->getCustomAttributes()); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegion()); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[0]); + $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[1]); + } + + + public function testModelPopulateWithArray() + { + $data = $this->getAddressArray(); + /** @var \Magento\Wonderland\Api\Data\FakeAddressDataBuilder $addressBuilder */ $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Api\Data\FakeAddressDataBuilder'); + /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ + $address = $addressBuilder->populateWithArray($data) + ->create(); + $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeAddressInterface', $address); + $this->assertEquals('Johnes', $address->getLastname()); + $this->assertEquals(true, $address->isDefaultShipping()); + $this->assertEquals(false, $address->isDefaultBilling()); + $this->assertNull($address->getCustomAttribute('test')); + $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegion()); + $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[0]); + $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[1]); + } - $data = [ + public function getAddressArray() + { + return [ FakeAddressInterface::ID => 1, FakeAddressInterface::CITY => 'Kiev', FakeAddressInterface::REGION => [ @@ -84,18 +176,9 @@ class DataBuilderTest extends \PHPUnit_Framework_TestCase FakeAddressInterface::STREET => 'Oak rd.', FakeAddressInterface::TELEPHONE => '1234567', FakeAddressInterface::VAT_ID => '1', - 'test' => 'xxx' + 'test' => 'xxx', + FakeAddressInterface::DEFAULT_BILLING => false, + FakeAddressInterface::DEFAULT_SHIPPING => true, ]; - - /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ - $address = $addressBuilder->populateWithArray($data) - ->create(); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeAddressInterface', $address); - $this->assertEquals('Johnes', $address->getLastname()); - $this->assertNull($address->getCustomAttribute('test')); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegion()); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[0]); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[1]); } - -} \ No newline at end of file +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php index a717126d572..dbb7899946d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php @@ -52,6 +52,8 @@ interface FakeAddressInterface extends ExtensibleDataInterface const PREFIX = 'prefix'; const SUFFIX = 'suffix'; const VAT_ID = 'vat_id'; + const DEFAULT_BILLING = 'default_billing'; + const DEFAULT_SHIPPING = 'default_shipping'; /**#@-*/ /** @@ -172,4 +174,18 @@ interface FakeAddressInterface extends ExtensibleDataInterface * @return string|null */ public function getVatId(); + + /** + * Get if this address is default shipping address. + * + * @return bool|null + */ + public function isDefaultShipping(); + + /** + * Get if this address is default billing address + * + * @return bool|null + */ + public function isDefaultBilling(); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php new file mode 100644 index 00000000000..1f9ad5e79eb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php @@ -0,0 +1,222 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Wonderland\Model\Data; + +use Magento\Framework\Api\AbstractExtensibleObject; + +class FakeAddress extends AbstractExtensibleObject +{ + /**#@+ + * Constants for keys of data array + */ + const ID = 'id'; + const CUSTOMER_ID = 'customer_id'; + const REGION = 'region'; + const REGIONS = 'regions'; + const COUNTRY_ID = 'country_id'; + const STREET = 'street'; + const COMPANY = 'company'; + const TELEPHONE = 'telephone'; + const FAX = 'fax'; + const POSTCODE = 'postcode'; + const CITY = 'city'; + const FIRSTNAME = 'firstname'; + const LASTNAME = 'lastname'; + const MIDDLENAME = 'middlename'; + const PREFIX = 'prefix'; + const SUFFIX = 'suffix'; + const VAT_ID = 'vat_id'; + /**#@-*/ + + /** + * Get ID + * + * @return int|null + */ + public function getId() + { + return $this->_get(self::ID); + } + + /** + * Get customer ID + * + * @return int|null + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Get region + * + * @return \Magento\Wonderland\Model\Data\FakeRegion|null + */ + public function getRegion() + { + return $this->_get(self::REGION); + } + + /** + * Get region + * + * @return \Magento\Wonderland\Model\Data\FakeRegion[]|null + */ + public function getRegions() + { + return $this->_get(self::REGIONS); + } + + /** + * Two-letter country code in ISO_3166-2 format + * + * @return string|null + */ + public function getCountryId() + { + return $this->_get(self::COUNTRY_ID); + } + + /** + * Get street + * + * @return string[]|null + */ + public function getStreet() + { + return $this->_get(self::STREET); + } + + /** + * Get company + * + * @return string|null + */ + public function getCompany() + { + return $this->_get(self::COMPANY); + } + + /** + * Get telephone number + * + * @return string|null + */ + public function getTelephone() + { + return $this->_get(self::TELEPHONE); + } + + /** + * Get fax number + * + * @return string|null + */ + public function getFax() + { + return $this->_get(self::FAX); + } + + /** + * Get postcode + * + * @return string|null + */ + public function getPostcode() + { + return $this->_get(self::POSTCODE); + } + + /** + * Get city name + * + * @return string|null + */ + public function getCity() + { + return $this->_get(self::CITY); + } + + /** + * Get first name + * + * @return string|null + */ + public function getFirstname() + { + return $this->_get(self::FIRSTNAME); + } + + /** + * Get last name + * + * @return string|null + */ + public function getLastname() + { + return $this->_get(self::LASTNAME); + } + + /** + * Get middle name + * + * @return string|null + */ + public function getMiddlename() + { + return $this->_get(self::MIDDLENAME); + } + + /** + * Get prefix + * + * @return string|null + */ + public function getPrefix() + { + return $this->_get(self::PREFIX); + } + + /** + * Get suffix + * + * @return string|null + */ + public function getSuffix() + { + return $this->_get(self::SUFFIX); + } + + /** + * Get Vat id + * + * @return string|null + */ + public function getVatId() + { + return $this->_get(self::VAT_ID); + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/Version/Generator/TimestampTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php similarity index 56% rename from dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/Version/Generator/TimestampTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php index 5f981048d3e..6338ff41e36 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/Version/Generator/TimestampTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php @@ -1,5 +1,6 @@ <?php /** + * * Magento * * NOTICE OF LICENSE @@ -21,27 +22,47 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Wonderland\Model\Data; -namespace Magento\Framework\App\View\Deployment\Version\Generator; +use Magento\Framework\Api\AbstractExtensibleObject; -class TimestampTest extends \PHPUnit_Framework_TestCase +class FakeRegion extends AbstractExtensibleObject { + /**#@+ + * Constants for keys of data array + */ + const REGION_CODE = 'region_code'; + const REGION = 'region'; + const REGION_ID = 'region_id'; + /**#@-*/ + /** - * @var Timestamp + * Get region + * + * @return string */ - private $object; + public function getRegion() + { + return $this->_get(self::REGION); + } - protected function setUp() + /** + * Get region code + * + * @return string + */ + public function getRegionCode() { - $this->object = new Timestamp(); + return $this->_get(self::REGION_CODE); } - public function testGenerate() + /** + * Get region id + * + * @return int + */ + public function getRegionId() { - $result = $this->object->generate(); - $this->assertNotEmpty($result); - $this->assertInternalType('string', $result); - sleep(1); - $this->assertNotEquals($result, $this->object->generate(), 'Unique value is expected'); + return $this->_get(self::REGION_ID); } -} +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php index d6f31fabd22..a9026a0909b 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php @@ -62,7 +62,7 @@ class FakeAddress extends AbstractExtensibleModel implements FakeAddressInterfac /** * Get region * - * @return \Magento\Wonderland\Api\Data\FakeRegionInterface|null + * @return \Magento\Wonderland\Api\Data\FakeRegionInterface[]|null */ public function getRegions() { @@ -198,4 +198,24 @@ class FakeAddress extends AbstractExtensibleModel implements FakeAddressInterfac { return $this->getData(self::VAT_ID); } -} \ No newline at end of file + + /** + * Get if this address is default shipping address. + * + * @return bool|null + */ + public function isDefaultShipping() + { + return $this->getData(self::DEFAULT_SHIPPING); + } + + /** + * Get if this address is default billing address + * + * @return bool|null + */ + public function isDefaultBilling() + { + return $this->getData(self::DEFAULT_BILLING); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php new file mode 100644 index 00000000000..5cebeeb3a70 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php @@ -0,0 +1,114 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Framework\Filter\Template\Tokenizer; + +class ParameterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @param string $string + * @param array $values + * @dataProvider getValueDataProvider + */ + public function testGetValue($string, $values) + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Framework\Filter\Template\Tokenizer\Parameter $parameter */ + $parameter = $objectManager->create('Magento\Framework\Filter\Template\Tokenizer\Parameter'); + $parameter->setString($string); + + foreach ($values as $value) { + $this->assertEquals($value, $parameter->getValue()); + } + } + + /** + * @dataProvider tokenizeDataProvider + * @param string $string + * @param array $params + */ + public function testTokenize($string, $params) + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Framework\Filter\Template\Tokenizer\Parameter $parameter */ + $parameter = $objectManager->create('Magento\Framework\Filter\Template\Tokenizer\Parameter'); + $parameter->setString($string); + $this->assertEquals($params, $parameter->tokenize()); + } + + /** + * @return array + */ + public function tokenizeDataProvider() + { + return [ + [ + ' type="Magento\\Catalog\\Block\\Product\\Widget\\NewWidget" display_type="all_products"' + . ' products_count="10" template="product/widget/new/content/new_grid.phtml"', + [ + 'type' => 'Magento\Catalog\Block\Product\Widget\NewWidget', + 'display_type' => 'all_products', + 'products_count' => 10, + 'template' => 'product/widget/new/content/new_grid.phtml' + ] + ], + [ + ' type="Magento\Catalog\Block\Product\Widget\NewWidget" display_type="all_products"' + . ' products_count="10" template="product/widget/new/content/new_grid.phtml"', + [ + 'type' => 'Magento\Catalog\Block\Product\Widget\NewWidget', + 'display_type' => 'all_products', + 'products_count' => 10, + 'template' => 'product/widget/new/content/new_grid.phtml' + ] + ] + ]; + } + + /** + * @return array + */ + public function getValueDataProvider() + { + return [ + [ + ' type="Magento\\Catalog\\Block\\Product\\Widget\\NewWidget" display_type="all_products"' + . ' products_count="10" template="product/widget/new/content/new_grid.phtml"', + [ + 'type="Magento\Catalog\Block\Product\Widget\NewWidget"', + 'display_type="all_products"', + 'products_count="10"' + ] + ], + [ + ' type="Magento\Catalog\Block\Product\Widget\NewWidget" display_type="all_products"' + . ' products_count="10" template="product/widget/new/content/new_grid.phtml"', + [ + 'type="Magento\Catalog\Block\Product\Widget\NewWidget"', + 'display_type="all_products"', + 'products_count="10"' + ] + ] + ]; + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment.php index 2bf266baadc..5f2d5bb560a 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/quote_payment.php @@ -26,7 +26,6 @@ $quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Ma $quote->load('test01', 'reserved_order_id'); $payment = $quote->getPayment(); -$payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS); -$payment->setAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, 123); - +$payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS) + ->setAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, 123); $quote->collectTotals()->save(); 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 ff87ee92e4d..bb1997f8843 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 @@ -120,7 +120,7 @@ $quote->collectTotals()->save(); $payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order\Payment'); $payment->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); -$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); +$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS)->save(); /** @var $service \Magento\Sales\Model\Service\Quote */ $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 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 308e524ab2f..749426b94ec 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 @@ -116,7 +116,7 @@ $quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); $quote->getShippingAddress()->setCollectShippingRates(true); $quote->collectTotals()->save(); -$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS); +$quote->getPayment()->setMethod(\Magento\Paypal\Model\Config::METHOD_WPS)->save(); $quote->setCustomerEmail('admin@example.com'); /** @var $service \Magento\Sales\Model\Service\Quote */ diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php index 0b498eb4917..494242ecbe7 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -577,7 +577,7 @@ class CreateTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals( $paymentMethod, - $this->_model->getQuote()->getPaymentsCollection()->getItems()[0]->getData('method'), + $this->_model->getQuote()->getPayment()->getData('method'), 'Precondition failed: Payment method data is invalid in create order model' ); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php index 3e417f80252..7cdeb97df9d 100755 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php @@ -129,7 +129,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase $customerData = $this->_customerBuilder->mergeDataObjectWithArray( $customerData, array(CustomerData::EMAIL => 'new@example.com') - ); + )->create(); $addresses = $this->_customerAddressService->getAddresses($existingCustomerId); $this->_serviceQuote->getQuote()->setCustomerData($customerData); $this->_serviceQuote->getQuote()->setCustomerAddressData($addresses); diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/Model/Resource/Report/CollectionTest.php b/dev/tests/integration/testsuite/Magento/SalesRule/Model/Resource/Report/CollectionTest.php index 8f855558094..b6a9d7ad316 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/Model/Resource/Report/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/Model/Resource/Report/CollectionTest.php @@ -96,20 +96,36 @@ class CollectionTest extends \PHPUnit_Framework_TestCase 'period' => 'day', 'date_from' => null, 'date_to' => null, - 'expected_period' => date('Y-m-d', time()) + 'expected_period' => $this->getNow() ], [ 'period' => 'undefinedPeriod', 'date_from' => null, 'date_to' => null, - 'expected_period' => date('Y-m-d', time()) + 'expected_period' => $this->getNow() ], [ 'period' => null, 'date_from' => date('Y-m-d', strtotime('-1 year', time())), 'date_to' => date('Y-m-d', time()), - 'expected_period' => date('Y-m-d', time()) + 'expected_period' => $this->getNow() ] ); } + + /** + * Retrieve date in MySQL timezone + * + * @return string + */ + protected function getNow() + { + /** @var \Magento\Framework\App\Resource $resources */ + $resources = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Framework\App\Resource' + ); + $connection = $resources->getConnection('salesrule_read'); + $now = $connection->fetchOne("SELECT CURDATE()"); + return $now; + } } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilderTest.php index 7b418c04238..90ec5364aff 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetails/ItemBuilderTest.php @@ -99,7 +99,8 @@ class ItemBuilderTest extends \PHPUnit_Framework_TestCase $itemExpected = $this->quoteDetailsItemBuilder->populateWithArray($data['dataMerged'])->create(); $itemSomeFields = $this->quoteDetailsItemBuilder->populateWithArray($data['data1'])->create(); $itemMoreFields = $this->quoteDetailsItemBuilder->populateWithArray($data['data2'])->create(); - $itemMerged = $this->quoteDetailsItemBuilder->mergeDataObjects($itemSomeFields, $itemMoreFields); + $itemMerged = $this->quoteDetailsItemBuilder->mergeDataObjects($itemSomeFields, $itemMoreFields) + ->create(); $this->assertEquals($itemExpected->__toArray(), $itemMerged->__toArray()); } @@ -108,7 +109,8 @@ class ItemBuilderTest extends \PHPUnit_Framework_TestCase $data = $this->getData(); $itemExpected = $this->quoteDetailsItemBuilder->populateWithArray($data['dataMerged'])->create(); $itemSomeFields = $this->quoteDetailsItemBuilder->populateWithArray($data['data1'])->create(); - $itemMerged = $this->quoteDetailsItemBuilder->mergeDataObjectWithArray($itemSomeFields, $data['data2']); + $itemMerged = $this->quoteDetailsItemBuilder->mergeDataObjectWithArray($itemSomeFields, $data['data2']) + ->create(); $this->assertEquals($itemExpected->__toArray(), $itemMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetailsBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetailsBuilderTest.php index 10138b0ca3a..dd69938b3cf 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetailsBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/QuoteDetailsBuilderTest.php @@ -98,7 +98,8 @@ class QuoteDetailsBuilderTest extends \PHPUnit_Framework_TestCase $taxRate = $this->builder->populateWithArray($data['dataMerged'])->create(); $taxRate1 = $this->builder->populateWithArray($data['data1'])->create(); $taxRate2 = $this->builder->populateWithArray($data['data2'])->create(); - $taxRateMerged = $this->builder->mergeDataObjects($taxRate1, $taxRate2); + $taxRateMerged = $this->builder->mergeDataObjects($taxRate1, $taxRate2) + ->create(); $this->assertEquals($taxRate->__toArray(), $taxRateMerged->__toArray()); } @@ -108,7 +109,8 @@ class QuoteDetailsBuilderTest extends \PHPUnit_Framework_TestCase $taxRate = $this->builder->populateWithArray($data['dataMerged'])->create(); $taxRate1 = $this->builder->populateWithArray($data['data1'])->create(); - $taxRateMerged = $this->builder->mergeDataObjectWithArray($taxRate1, $data['data2']); + $taxRateMerged = $this->builder->mergeDataObjectWithArray($taxRate1, $data['data2']) + ->create(); $this->assertEquals($taxRate->__toArray(), $taxRateMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilderTest.php index 1c5c3aa521d..c77d2961292 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxDetails/AppliedTaxBuilderTest.php @@ -164,7 +164,8 @@ class AppliedTaxBuilderTest extends \PHPUnit_Framework_TestCase $appliedTax = $this->builder->populateWithArray($dataMerged)->create(); $appliedTax1 = $this->builder->populateWithArray($data1)->create(); $appliedTax2 = $this->builder->populateWithArray($data2)->create(); - $appliedTaxMerged = $this->builder->mergeDataObjects($appliedTax1, $appliedTax2); + $appliedTaxMerged = $this->builder->mergeDataObjects($appliedTax1, $appliedTax2) + ->create(); $this->assertEquals($appliedTax->__toArray(), $appliedTaxMerged->__toArray()); } @@ -211,7 +212,8 @@ class AppliedTaxBuilderTest extends \PHPUnit_Framework_TestCase $appliedTax = $this->builder->populateWithArray($dataMerged)->create(); $appliedTax1 = $this->builder->populateWithArray($data1)->create(); - $appliedTaxMerged = $this->builder->mergeDataObjectWithArray($appliedTax1, $data2); + $appliedTaxMerged = $this->builder->mergeDataObjectWithArray($appliedTax1, $data2) + ->create(); $this->assertEquals($appliedTax->__toArray(), $appliedTaxMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateBuilderTest.php index 0a94d37f9e7..4750e289ff0 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateBuilderTest.php @@ -116,7 +116,8 @@ class TaxRateBuilderTest extends \PHPUnit_Framework_TestCase $expectedTaxRate = $this->builder->populateWithArray($expectedResultsArray)->create(); $taxRate1 = $this->builder->populateWithArray($firstRateArray)->create(); $taxRate2 = $this->builder->populateWithArray($secondRateArray)->create(); - $taxRateMerged = $this->builder->mergeDataObjects($taxRate1, $taxRate2); + $taxRateMerged = $this->builder->mergeDataObjects($taxRate1, $taxRate2) + ->create(); $this->assertEquals($expectedTaxRate->__toArray(), $taxRateMerged->__toArray()); } @@ -128,7 +129,8 @@ class TaxRateBuilderTest extends \PHPUnit_Framework_TestCase $taxRate = $this->builder->populateWithArray($expectedResultsArray)->create(); $taxRate1 = $this->builder->populateWithArray($firstRateArray)->create(); - $taxRateMerged = $this->builder->mergeDataObjectWithArray($taxRate1, $secondRateArray); + $taxRateMerged = $this->builder->mergeDataObjectWithArray($taxRate1, $secondRateArray) + ->create(); $this->assertEquals($taxRate->__toArray(), $taxRateMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilderTest.php index d9f00a2d473..00f707e44af 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRateSearchResultsBuilderTest.php @@ -110,7 +110,7 @@ class TaxRateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase $taxRateSearchResultsMerged = $this->taxRateSearchResultsBuilder->mergeDataObjects( $taxRateSearchResults1, $taxRateSearchResults2 - ); + )->create(); $this->assertEquals($taxRateSearchResults->__toArray(), $taxRateSearchResultsMerged->__toArray()); } @@ -124,7 +124,7 @@ class TaxRateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase $taxRateSearchResultsMerged = $this->taxRateSearchResultsBuilder->mergeDataObjectWithArray( $taxRateSearchResults1, $secondDataSet - ); + )->create(); $this->assertEquals($taxRateSearchResults->__toArray(), $taxRateSearchResultsMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleBuilderTest.php index 5855de2e250..a201cbd32d9 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleBuilderTest.php @@ -147,7 +147,8 @@ class TaxRuleBuilderTest extends \PHPUnit_Framework_TestCase $taxRuleExpected = $this->builder->populateWithArray($taxRuleDataExpected)->create(); $taxRuleSomeFields = $this->builder->populateWithArray($taxRuleDataSomeFields)->create(); $taxRuleMoreFields = $this->builder->populateWithArray($taxRuleDataMoreFields)->create(); - $taxRuleMerged = $this->builder->mergeDataObjects($taxRuleSomeFields, $taxRuleMoreFields); + $taxRuleMerged = $this->builder->mergeDataObjects($taxRuleSomeFields, $taxRuleMoreFields) + ->create(); $this->assertEquals($taxRuleExpected->__toArray(), $taxRuleMerged->__toArray()); } @@ -180,7 +181,8 @@ class TaxRuleBuilderTest extends \PHPUnit_Framework_TestCase $taxRuleExpected = $this->builder->populateWithArray($taxRuleDataExpected)->create(); $taxRuleSomeFields = $this->builder->populateWithArray($taxRuleDataSomeFields)->create(); - $taxRuleMerged = $this->builder->mergeDataObjectWithArray($taxRuleSomeFields, $taxRuleDataMoreFields); + $taxRuleMerged = $this->builder->mergeDataObjectWithArray($taxRuleSomeFields, $taxRuleDataMoreFields) + ->create(); $this->assertEquals($taxRuleExpected->__toArray(), $taxRuleMerged->__toArray()); } diff --git a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilderTest.php b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilderTest.php index e436e650b94..34923ed3227 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilderTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Service/V1/Data/TaxRuleSearchResultsBuilderTest.php @@ -191,7 +191,8 @@ class TaxRuleSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase $taxRuleSearchResults = $this->builder->populateWithArray($dataMerged)->create(); $taxRuleSearchResults1 = $this->builder->populateWithArray($data1)->create(); $taxRuleSearchResults2 = $this->builder->populateWithArray($data2)->create(); - $taxRuleSearchResultsMerged = $this->builder->mergeDataObjects($taxRuleSearchResults1, $taxRuleSearchResults2); + $taxRuleSearchResultsMerged = $this->builder->mergeDataObjects($taxRuleSearchResults1, $taxRuleSearchResults2) + ->create(); $this->assertEquals($taxRuleSearchResults->__toArray(), $taxRuleSearchResultsMerged->__toArray()); } @@ -252,7 +253,8 @@ class TaxRuleSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase $taxRuleSearchResults = $this->builder->populateWithArray($dataMerged)->create(); $taxRuleSearchResults1 = $this->builder->populateWithArray($data1)->create(); - $taxRuleSearchResultsMerged = $this->builder->mergeDataObjectWithArray($taxRuleSearchResults1, $data2); + $taxRuleSearchResultsMerged = $this->builder->mergeDataObjectWithArray($taxRuleSearchResults1, $data2) + ->create(); $this->assertEquals($taxRuleSearchResults->__toArray(), $taxRuleSearchResultsMerged->__toArray()); } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index 005a517f8d1..d0cd5f25232 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -337,6 +337,8 @@ class CompilerTest extends \PHPUnit_Framework_TestCase => 'Magento\Framework\Api\Code\Generator\DataBuilder', \Magento\Framework\Api\Code\Generator\SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', + \Magento\Framework\Api\Code\Generator\DataBuilder::ENTITY_TYPE_BUILDER + => 'Magento\Framework\Api\Code\Generator\DataBuilder', \Magento\Framework\ObjectManager\Code\Generator\Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', \Magento\Framework\ObjectManager\Code\Generator\Repository::ENTITY_TYPE @@ -345,8 +347,6 @@ class CompilerTest extends \PHPUnit_Framework_TestCase => 'Magento\Framework\ObjectManager\Code\Generator\Converter', \Magento\Framework\Api\Code\Generator\Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', - \Magento\Framework\Api\Code\Generator\Builder::ENTITY_TYPE - => 'Magento\Framework\Api\Code\Generator\Builder', \Magento\Framework\Api\Code\Generator\SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults' ) diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index 84301c26bb5..29c77a9f6d2 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -25,6 +25,8 @@ dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/ dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/coupling.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/cyclomatic_complexity.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/descendant_count.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 02d265b3e8b..1d55de7b275 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -33,4 +33,7 @@ DbTest Model1 Model3 \Magento\Wonderland\Api\Data\FakeRegionInterface +\Magento\Wonderland\Api\Data\FakeAddressInterface +\Magento\Wonderland\Model\Data\FakeRegion +\Magento\Wonderland\Model\Data\FakeAddress \Magento\Framework\Error\Processor 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 553d2482c1e..ae3641ceaa0 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 @@ -257,53 +257,49 @@ return array( 'sales_bestsellers_aggregated_yearly' => 'Magento_Sales', 'paypal_billing_agreement' => 'Magento_Paypal', 'paypal_billing_agreement_order' => 'Magento_Paypal', - 'sales_flat_creditmemo' => 'Magento_Sales', - 'sales_flat_creditmemo_comment' => 'Magento_Sales', - 'sales_flat_creditmemo_grid' => 'Magento_Sales', - 'sales_flat_creditmemo_item' => 'Magento_Sales', - 'sales_flat_invoice' => 'Magento_Sales', - 'sales_flat_invoice_comment' => 'Magento_Sales', - 'sales_flat_invoice_grid' => 'Magento_Sales', - 'sales_flat_invoice_item' => 'Magento_Sales', + 'sales_creditmemo' => 'Magento_Sales', + 'sales_creditmemo_comment' => 'Magento_Sales', + 'sales_creditmemo_grid' => 'Magento_Sales', + 'sales_creditmemo_item' => 'Magento_Sales', + 'sales_invoice' => 'Magento_Sales', + 'sales_invoice_comment' => 'Magento_Sales', + 'sales_invoice_grid' => 'Magento_Sales', + 'sales_invoice_item' => 'Magento_Sales', 'sales_invoiced_aggregated' => 'Magento_Sales', 'sales_invoiced_aggregated_order' => 'Magento_Sales', - 'sales_flat_order' => 'Magento_Sales', - 'sales_flat_order_address' => 'Magento_Sales', + 'sales_order' => 'Magento_Sales', + 'sales_order_address' => 'Magento_Sales', 'sales_order_aggregated_created' => 'Magento_Sales', 'sales_order_aggregated_updated' => 'Magento_Sales', - 'sales_flat_order_grid' => 'Magento_Sales', - 'sales_flat_order_item' => 'Magento_Sales', - 'sales_flat_order_item_option' => 'Magento_Sales', - 'sales_flat_order_payment' => 'Magento_Sales', + 'sales_order_grid' => 'Magento_Sales', + 'sales_order_item' => 'Magento_Sales', + 'sales_order_item_option' => 'Magento_Sales', + 'sales_order_payment' => 'Magento_Sales', 'sales_order_status' => 'Magento_Sales', - 'sales_flat_order_status_history' => 'Magento_Sales', + 'sales_order_status_history' => 'Magento_Sales', 'sales_order_status_label' => 'Magento_Sales', 'sales_order_status_state' => 'Magento_Sales', 'sales_order_tax' => 'Magento_Tax', 'sales_payment_transaction' => 'Magento_Sales', - 'sales_flat_quote' => 'Magento_Sales', - 'sales_flat_quote_address' => 'Magento_Sales', - 'sales_flat_quote_address_item' => 'Magento_Sales', - 'sales_flat_quote_shipping_rate' => 'Magento_Sales', - 'sales_flat_quote_item' => 'Magento_Sales', - 'sales_flat_quote_item_option' => 'Magento_Sales', - 'sales_flat_quote_payment' => 'Magento_Sales', + 'sales_quote' => 'Magento_Sales', + 'sales_quote_address' => 'Magento_Sales', + 'sales_quote_address_item' => 'Magento_Sales', + 'sales_quote_shipping_rate' => 'Magento_Sales', + 'sales_quote_item' => 'Magento_Sales', + 'sales_quote_item_option' => 'Magento_Sales', + 'sales_quote_payment' => 'Magento_Sales', 'recurring_payment' => 'Magento_RecurringPayment', 'recurring_payment_order' => 'Magento_RecurringPayment', 'sales_refunded_aggregated' => 'Magento_Sales', 'sales_refunded_aggregated_order' => 'Magento_Sales', - 'sales_flat_shipment' => 'Magento_Sales', - 'sales_flat_shipment_comment' => 'Magento_Sales', - 'sales_flat_shipment_grid' => 'Magento_Sales', - 'sales_flat_shipment_item' => 'Magento_Sales', - 'sales_flat_shipment_track' => 'Magento_Sales', + 'sales_shipment' => 'Magento_Sales', + 'sales_shipment_comment' => 'Magento_Sales', + 'sales_shipment_grid' => 'Magento_Sales', + 'sales_shipment_item' => 'Magento_Sales', + 'sales_shipment_track' => 'Magento_Sales', 'sales_shipping_aggregated' => 'Magento_Sales', 'sales_shipping_aggregated_order' => 'Magento_Sales', - 'sales_order' => 'Magento_Sales', - 'sales_quote' => 'Magento_Sales', - 'sales_quote_address' => 'Magento_Sales', 'sales_quote_entity' => 'Magento_Sales', - 'sales_quote_item' => 'Magento_Sales', 'sales_quote_temp' => 'Magento_Sales', 'salesrule_coupon' => 'Magento_SalesRule', 'coupon_aggregated' => 'Magento_SalesRule', 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 13ba81bc77a..4d1eb0440e0 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 @@ -2843,4 +2843,6 @@ return array( ['Magento\Framework\Filesystem\WrapperInterface'], ['Magento\Install'], ['Magento\Install\Model\Resource\Resource', 'Magento\Framework\Module\Resource'], + ['Magento\Framework\App\View\Deployment\Version\Generator\Timestamp', 'Magento\Framework\Stdlib\DateTime'], + ['Magento\Framework\App\View\Deployment\Version\GeneratorInterface'], ); 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 8a856de5d7b..1f18ce64679 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 @@ -32,6 +32,9 @@ return array( array('_addTaxPercents', 'Magento\Catalog\Model\Resource\Product\Collection'), array('_afterSaveCommit', 'Magento\Framework\Model\AbstractModel'), array('_afterSetConfig', 'Magento\Eav\Model\Entity\AbstractEntity'), + array('getAttributeCodes', 'Magento\Eav\Model\Entity\Type'), + array('_loadTypeAttributes', 'Magento\Eav\Model\Resource\Entity\Attribute'), + array('preloadAttributes', 'Magento\Eav\Model\Entity\Type\Config'), array('_aggregateByOrderCreatedAt', 'Magento\SalesRule\Model\Resource\Report\Rule'), array('_amountByCookies', 'Magento\Sendfriend\Model\Sendfriend'), array('setCookie', 'Magento\Sendfriend\Model\Sendfriend'), @@ -48,6 +51,8 @@ return array( array('_avoidDoubleTransactionProcessing'), array('_beforeChildToHtml'), array('_beforeMove', 'Magento\Catalog\Model\Resource\Category\Tree'), + array('_getIsActiveAttributeId', 'Magento\Catalog\Model\Resource\Category\Tree', 'Magento\Catalog\Model\Resource\Category::getIsActiveAttributeId'), + array('_getIsActiveAttributeId', 'Magento\Catalog\Model\Resource\Category', 'Magento\Catalog\Model\Resource\Category::getIsActiveAttributeId'), array('_bytesToMbytes', 'Magento\Catalog\Model\Product\Option\Type\File'), array('_calculatePrice', 'Magento\Sales\Model\Quote\Item\AbstractItem'), array('_canBeStoreCodeInUrl', 'Magento\Framework\App\Request\Http'), @@ -2052,4 +2057,14 @@ return array( ['_getAllowedActions', 'Magento\Customer\Controller\Account', 'Magento\Customer\Controller\Account::getAllowedActions'], ['isRegistrationAllowed', 'Magento\Customer\Controller\Account\CreatePost'], ['isRegistrationAllowed', 'Magento\Invitation\Controller\Customer\Account\CreatePost'], + ['getFlatIndexer', 'Magento\Catalog\Model\Category'], + ['getProductIndexer', 'Magento\Catalog\Model\Category'], + ['getFlatIndexer', 'Magento\Catalog\Model\Indexer\AbstractFlatState'], + ['getIndexer', 'Magento\Catalog\Model\Indexer\Category\Product\Plugin\StoreGroup'], + ['getIndexer', 'Magento\Catalog\Model\Indexer\Category\Flat\Plugin\StoreGroup'], + ['getIndexer', 'Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin'], + ['getCategoryIndexer', 'Magento\Catalog\Model\Product'], + ['getCategoryIndexer', 'Magento\Catalog\Model\Product\Action'], + ['getIndexer', 'Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\AbstractPlugin'], + ['_getNewConditionModelInstance', 'Magento\Rule\Model\Condition\Combine'], ); 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 de6a39980f6..3ef0f559c99 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 @@ -361,4 +361,5 @@ return array( ['_openActions', 'Magento\Customer\Controller\Account', 'Magento\Customer\Controller\Account::openActions'], ['_session', 'Magento\Customer\Controller\Account', 'Magento\Customer\Controller\Account::session'], ['_directoryData', 'Magento\Customer\Model\Attribute\Data\Postcode', 'Magento\Customer\Model\Attribute\Data\Postcode::directoryHelper'], + ['_conditionModels', 'Magento\Rule\Model\Condition\Combine'], ); diff --git a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php index 51c4520f07b..a35b7a99c64 100644 --- a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php @@ -170,7 +170,9 @@ class ObjectManager */ public function getObject($className, array $arguments = array()) { - if (is_subclass_of($className, '\Magento\Framework\Api\AbstractSimpleObjectBuilder')) { + if (is_subclass_of($className, '\Magento\Framework\Api\AbstractSimpleObjectBuilder') + || is_subclass_of($className, '\Magento\Framework\Api\Builder') + ) { return $this->getBuilder($className, $arguments); } $constructArguments = $this->getConstructArguments($className, $arguments); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Widget/LinkTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Widget/LinkTest.php index 84b58dcd75e..0dd593aaf19 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Block/Widget/LinkTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Widget/LinkTest.php @@ -44,6 +44,11 @@ class LinkTest extends \PHPUnit_Framework_TestCase */ protected $block; + /** + * @var \Magento\Catalog\Model\Resource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityResource; + protected function setUp() { $this->storeManager = $this->getMock('Magento\Framework\StoreManagerInterface'); @@ -54,9 +59,12 @@ class LinkTest extends \PHPUnit_Framework_TestCase ->method('getStoreManager') ->will($this->returnValue($this->storeManager)); + $this->entityResource = $this->getMock('Magento\Catalog\Model\Resource\AbstractResource', [], [], '', false); + $this->block = (new ObjectManager($this))->getObject('Magento\Catalog\Block\Widget\Link', [ 'context' => $context, 'urlFinder' => $this->urlFinder, + 'entityResource' => $this->entityResource ]); } @@ -157,6 +165,27 @@ class LinkTest extends \PHPUnit_Framework_TestCase $this->assertEquals($url . $separator . '___store=' . $storeCode, $this->block->getHref()); } + public function testGetLabelWithCustomText() + { + $customText = 'Some text'; + $this->block->setData('anchor_text', $customText); + $this->assertEquals($customText, $this->block->getLabel()); + } + + public function testGetLabelWithoutCustomText() + { + $category = 'Some text'; + $id = 1; + $idPath = 'id/' . $id; + $store = 1; + + $this->block->setData('id_path', $idPath); + $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); + $this->entityResource->expects($this->once())->method('getAttributeRawValue')->with($id, 'name', $store) + ->will($this->returnValue($category)); + $this->assertEquals($category, $this->block->getLabel()); + } + /** * @return array */ diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php index 434af4d436c..03c586d6eda 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php @@ -99,11 +99,14 @@ class SaveTest extends \PHPUnit_Framework_TestCase $this->stockItemBuilder = $this->getMock( 'Magento\CatalogInventory\Service\V1\Data\StockItemBuilder', - ['mergeDataObjectWithArray'], + ['mergeDataObjectWithArray', 'create'], [], '', false ); + $this->stockItemBuilder->expects($this->any()) + ->method('mergeDataObjectWithArray') + ->willReturn($this->stockItemBuilder); $this->stockIndexerProcessor = $this->getMock( 'Magento\CatalogInventory\Model\Indexer\Stock\Processor', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php index 724476e993a..23f1a85972b 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php @@ -45,6 +45,11 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var \Closure */ @@ -85,14 +90,20 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase $this->closureMock = function () { return false; }; - $this->model = new StoreGroup($this->indexerMock, $this->stateMock); + + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + + $this->model = new StoreGroup($this->indexerRegistryMock, $this->stateMock); } public function testAroundSave() { $this->stateMock->expects($this->once())->method('isFlatEnabled')->will($this->returnValue(true)); - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); $this->groupMock->expects( $this->once() )->method( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php index 0f66723ed9c..038425b8193 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php @@ -40,6 +40,11 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var \Closure */ @@ -72,7 +77,8 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase return false; }; $this->subjectMock = $this->getMock('Magento\Store\Model\Resource\Store', array(), array(), '', false); - $this->model = new StoreView($this->indexerMock, $this->stateMock); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new StoreView($this->indexerRegistryMock, $this->stateMock); } public function testAroundSaveNewObject() @@ -117,8 +123,11 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function mockIndexerMethods() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); } protected function mockConfigFlatEnabled() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php index 85788f0448a..6d03bfc346b 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php @@ -40,6 +40,11 @@ class StateTest extends \PHPUnit_Framework_TestCase */ protected $flatIndexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + protected function setUp() { $this->scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); @@ -53,6 +58,8 @@ class StateTest extends \PHPUnit_Framework_TestCase true, array('getId', 'getState', '__wakeup') ); + + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); } public function testIsFlatEnabled() @@ -69,7 +76,7 @@ class StateTest extends \PHPUnit_Framework_TestCase $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State( $this->scopeConfigMock, - $this->flatIndexerMock + $this->indexerRegistryMock ); $this->assertEquals(true, $this->model->isFlatEnabled()); } @@ -83,9 +90,12 @@ class StateTest extends \PHPUnit_Framework_TestCase */ public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result) { - $this->flatIndexerMock->expects($this->any())->method('getId')->will($this->returnValue(null)); $this->flatIndexerMock->expects($this->any())->method('load')->with('catalog_category_flat'); $this->flatIndexerMock->expects($this->any())->method('isValid')->will($this->returnValue($isValid)); + $this->indexerRegistryMock->expects($this->any()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) + ->will($this->returnValue($this->flatIndexerMock)); $this->scopeConfigMock->expects( $this->any() @@ -99,7 +109,7 @@ class StateTest extends \PHPUnit_Framework_TestCase $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State( $this->scopeConfigMock, - $this->flatIndexerMock, + $this->indexerRegistryMock, $isAvailable ); $this->assertEquals($result, $this->model->isAvailable()); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/ModeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/ModeTest.php index e1e58ca39ef..5ae836ad25d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/ModeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/ModeTest.php @@ -40,10 +40,15 @@ class ModeTest extends \PHPUnit_Framework_TestCase */ protected $indexerStateMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistry; + /** * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $flatIndexerMock; + protected $flatIndexer; protected function setUp() { @@ -55,15 +60,9 @@ class ModeTest extends \PHPUnit_Framework_TestCase '', false ); - $this->flatIndexerMock = $this->getMockForAbstractClass( - 'Magento\Indexer\Model\IndexerInterface', - array(), - '', - false, - false, - true, - array('load', 'setScheduled', '__wakeup') - ); + $this->indexerRegistry = $this->getMock('Magento\Indexer\Model\IndexerRegistry', [], [], '', false); + + $this->flatIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->model = $objectManager->getObject( @@ -71,7 +70,7 @@ class ModeTest extends \PHPUnit_Framework_TestCase array( 'config' => $this->configMock, 'indexerState' => $this->indexerStateMock, - 'flatIndexer' => $this->flatIndexerMock + 'indexerRegistry' => $this->indexerRegistry ) ); } @@ -105,8 +104,8 @@ class ModeTest extends \PHPUnit_Framework_TestCase $this->indexerStateMock->expects($this->never())->method('setStatus'); $this->indexerStateMock->expects($this->never())->method('save'); - $this->flatIndexerMock->expects($this->never())->method('load'); - $this->flatIndexerMock->expects($this->never())->method('setScheduled'); + $this->indexerRegistry->expects($this->never())->method('load'); + $this->indexerRegistry->expects($this->never())->method('setScheduled'); $this->model->processValue(); } @@ -156,8 +155,8 @@ class ModeTest extends \PHPUnit_Framework_TestCase ); $this->indexerStateMock->expects($this->once())->method('save')->will($this->returnSelf()); - $this->flatIndexerMock->expects($this->never())->method('load'); - $this->flatIndexerMock->expects($this->never())->method('setScheduled'); + $this->indexerRegistry->expects($this->never())->method('load'); + $this->indexerRegistry->expects($this->never())->method('setScheduled'); $this->model->processValue(); } @@ -191,16 +190,9 @@ class ModeTest extends \PHPUnit_Framework_TestCase $this->indexerStateMock->expects($this->never())->method('setStatus'); $this->indexerStateMock->expects($this->never())->method('save'); - $this->flatIndexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'catalog_category_flat' - )->will( - $this->returnSelf() - ); - $this->flatIndexerMock->expects($this->once())->method('setScheduled')->with(false); + $this->indexerRegistry->expects($this->once())->method('get')->with('catalog_category_flat') + ->willReturn($this->flatIndexer); + $this->flatIndexer->expects($this->once())->method('setScheduled')->with(false); $this->model->processValue(); } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php index 21a358a5e32..a61d489428c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php @@ -45,6 +45,11 @@ class FlatTest extends \PHPUnit_Framework_TestCase */ protected $indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + protected function setUp() { $this->fullMock = $this->getMock( @@ -73,25 +78,19 @@ class FlatTest extends \PHPUnit_Framework_TestCase array('getId', 'load', 'isInvalid', 'isWorking', '__wakeup') ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat( $this->fullMock, $this->rowsMock, - $this->indexerMock + $this->indexerRegistryMock ); } public function testExecuteWithIndexerInvalid() { - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - \Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isInvalid')->will($this->returnValue(true)); + $this->prepareIndexer(); $this->rowsMock->expects($this->never())->method('create'); @@ -102,17 +101,9 @@ class FlatTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - \Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isInvalid')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(true)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', @@ -133,17 +124,9 @@ class FlatTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - \Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isInvalid')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', @@ -158,4 +141,12 @@ class FlatTest extends \PHPUnit_Framework_TestCase $this->model->execute($ids); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php index 78108d26713..e84ca575b21 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php @@ -40,6 +40,11 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase */ protected $subject; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var StoreView */ @@ -56,8 +61,10 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase true, array('getId', 'getState', '__wakeup') ); - $this->model = new StoreGroup($this->indexerMock); $this->subject = $this->getMock('Magento\Store\Model\Resource\Group', array(), array(), '', false); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + + $this->model = new StoreGroup($this->indexerRegistryMock); } /** @@ -135,8 +142,11 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function mockIndexerMethods() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); } protected function mockPluginProceed($returnValue = false) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php index 3d1c930b450..abd21437676 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php @@ -40,6 +40,11 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -56,8 +61,10 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase true, array('getId', 'getState', '__wakeup') ); - $this->model = new StoreView($this->indexerMock); $this->subject = $this->getMock('Magento\Store\Model\Resource\Group', array(), array(), '', false); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + + $this->model = new StoreView($this->indexerRegistryMock); } public function testAroundSaveNewObject() @@ -77,6 +84,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase public function testAroundSaveHasChanged() { + $this->mockIndexerMethods(); $storeMock = $this->getMock( 'Magento\Store\Model\Store', array('isObjectNew', 'dataHasChangedFor', '__wakeup'), @@ -139,8 +147,11 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected function mockIndexerMethods() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); } protected function mockPluginProceed($returnValue = false) diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php index e0a96d8d76d..5c64afc0c46 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php @@ -45,6 +45,11 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ protected $indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + protected function setUp() { $this->fullMock = $this->getMock( @@ -73,10 +78,12 @@ class ProductTest extends \PHPUnit_Framework_TestCase array('getId', 'load', 'isInvalid', 'isWorking', '__wakeup') ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new \Magento\Catalog\Model\Indexer\Category\Product( $this->fullMock, $this->rowsMock, - $this->indexerMock + $this->indexerRegistryMock ); } @@ -84,16 +91,8 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'catalog_category_product' - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(true)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Product\Action\Rows', @@ -114,16 +113,8 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'catalog_category_product' - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Product\Action\Rows', @@ -138,4 +129,12 @@ class ProductTest extends \PHPUnit_Framework_TestCase $this->model->execute($ids); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->any()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/CategoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/CategoryTest.php index e1d3a3ee1c6..63104731cdd 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/CategoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/CategoryTest.php @@ -45,6 +45,11 @@ class CategoryTest extends \PHPUnit_Framework_TestCase */ protected $indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + protected function setUp() { $this->fullMock = $this->getMock( @@ -73,10 +78,12 @@ class CategoryTest extends \PHPUnit_Framework_TestCase array('getId', 'load', 'isInvalid', 'isWorking', '__wakeup') ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new \Magento\Catalog\Model\Indexer\Product\Category( $this->fullMock, $this->rowsMock, - $this->indexerMock + $this->indexerRegistryMock ); } @@ -84,16 +91,8 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'catalog_product_category' - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(true)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Category\Action\Rows', @@ -114,16 +113,8 @@ class CategoryTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - 'catalog_product_category' - )->will( - $this->returnSelf() - ); $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false)); + $this->prepareIndexer(); $rowMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Category\Action\Rows', @@ -138,4 +129,12 @@ class CategoryTest extends \PHPUnit_Framework_TestCase $this->model->execute($ids); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php index 11d55081e84..3bd416af67a 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php @@ -41,14 +41,14 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase protected $_indexerMock; /** - * @var \Magento\Indexer\Model\IndexerFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject */ - protected $_indexerFactoryMock; + protected $_stateMock; /** - * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ - protected $_stateMock; + protected $indexerRegistryMock; public function setUp() { @@ -63,15 +63,6 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase ); $this->_indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); - $this->_indexerFactoryMock = $this->getMock( - 'Magento\Indexer\Model\IndexerFactory', array('create'), array(), '', false - ); - - $this->_indexerFactoryMock - ->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_indexerMock)); - $this->_stateMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Flat\State', array('isFlatEnabled'), @@ -79,8 +70,9 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase '', false ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); $this->_model = $this->_objectManager->getObject('Magento\Catalog\Model\Indexer\Product\Flat\Processor', array( - 'indexerFactory' => $this->_indexerFactoryMock, + 'indexerRegistry' => $this->indexerRegistryMock, 'state' => $this->_stateMock )); } @@ -90,6 +82,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase */ public function testGetIndexer() { + $this->prepareIndexer(); $this->assertInstanceOf('\Magento\Indexer\Model\Indexer', $this->_model->getIndexer()); } @@ -100,6 +93,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase { $this->_stateMock->expects($this->once())->method('isFlatEnabled')->will($this->returnValue(true)); $this->_indexerMock->expects($this->once())->method('invalidate'); + $this->prepareIndexer(); $this->_model->markIndexerAsInvalid(); } @@ -112,4 +106,12 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase $this->_indexerMock->expects($this->never())->method('invalidate'); $this->_model->markIndexerAsInvalid(); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID) + ->will($this->returnValue($this->_indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php deleted file mode 100644 index 11a6da24e40..00000000000 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CatalogRuleTest.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Catalog\Model\Indexer\Product\Price\Plugin; - - -class CatalogRuleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\Plugin\CatalogRule - */ - protected $_model; - - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_priceProcessorMock; - - protected function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $this->_priceProcessorMock = $this->getMock( - 'Magento\Catalog\Model\Indexer\Product\Price\Processor', array(), array(), '', false - ); - - $this->_model = $this->_objectManager->getObject( - '\Magento\Catalog\Model\Indexer\Product\Price\Plugin\CatalogRule', - array( - 'processor' => $this->_priceProcessorMock - ) - ); - } - - public function testAfterApplyAll() - { - $this->_priceProcessorMock->expects($this->once()) - ->method('markIndexerAsInvalid'); - - $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); - $this->_model->afterApplyAll($ruleMock); - } - - /** - * @param int|\Magento\Catalog\Model\Product $product - * @param int $expectedIdCall - * @dataProvider affectedProductsDataProvider - */ - public function testAroundApplyToProduct($product, $expectedIdCall) - { - $this->_priceProcessorMock->expects($this->once()) - ->method('reindexRow') - ->with($expectedIdCall); - - $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); - $this->_model->aroundApplyToProduct( - $ruleMock, - function () { - - }, - $product - ); - } - - /** - * @param int|\Magento\Catalog\Model\Product $product - * @param int $expectedIdCall - * @dataProvider affectedProductsDataProvider - */ - public function testAroundApplyAllRulesToProduct($product, $expectedIdCall) - { - $this->_priceProcessorMock->expects($this->once()) - ->method('reindexRow') - ->with($expectedIdCall); - - $ruleMock = $this->getMock('Magento\CatalogRule\Model\Rule', array(), array(), '', false); - $this->_model->aroundApplyToProduct( - $ruleMock, - function () { - - }, - $product - ); - } - - /** - * @return array - */ - public function affectedProductsDataProvider() - { - $productId = 11; - $productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); - $productMock->expects($this->any()) - ->method('getId') - ->will($this->returnValue($productId)); - - return array( - array($productId, $productId), - array($productMock, $productId) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php index 9dc1cf35202..915cda1b3c3 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Price/Plugin/CustomerGroupTest.php @@ -40,6 +40,11 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase */ protected $_subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + public function setUp() { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -55,12 +60,16 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase '', false ); - $indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) + ->will($this->returnValue($indexerMock)); $this->_model = $this->_objectManager->getObject( '\Magento\Catalog\Model\Indexer\Product\Price\Plugin\CustomerGroup', - array('indexer' => $indexerMock) + array('indexerRegistry' => $this->indexerRegistryMock) ); } 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 e1e7dc87034..c32e4a143cc 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 @@ -40,6 +40,11 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase */ protected $_indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + public function setUp() { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -51,7 +56,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_indexerMock->expects($this->any())->method('load')->will($this->returnValue($this->_indexerMock)); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); $contextMock = $this->getMock('Magento\Framework\Model\Context', array(), array(), '', false); $registryMock = $this->getMock('Magento\Framework\Registry', array(), array(), '', false); @@ -66,7 +71,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase 'registry' => $registryMock, 'storeManager' => $storeManagerMock, 'config' => $configMock, - 'indexer' => $this->_indexerMock + 'indexerRegistry' => $this->indexerRegistryMock ) ); } @@ -74,6 +79,7 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase public function testProcessValue() { $this->_indexerMock->expects($this->once())->method('invalidate'); + $this->prepareIndexer(1); $this->_model->setValue('1'); $this->_model->processValue(); } @@ -81,6 +87,18 @@ class PriceScopeTest extends \PHPUnit_Framework_TestCase public function testProcessValueNotChanged() { $this->_indexerMock->expects($this->never())->method('invalidate'); + $this->prepareIndexer(0); $this->_model->processValue(); } + + /** + * @param int $countCall + */ + protected function prepareIndexer($countCall) + { + $this->indexerRegistryMock->expects($this->exactly($countCall)) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) + ->will($this->returnValue($this->_indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ActionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ActionTest.php index f7a42576989..9ceaa1b72e0 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ActionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/ActionTest.php @@ -60,6 +60,11 @@ class ActionTest extends \PHPUnit_Framework_TestCase */ protected $eavAttribute; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + public function setUp() { $eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); @@ -109,6 +114,8 @@ class ActionTest extends \PHPUnit_Framework_TestCase '', false ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->model = $objectManager->getObject( '\Magento\Catalog\Model\Product\Action', @@ -116,7 +123,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase 'eventDispatcher' => $eventManagerMock, 'resource' => $this->resource, 'productWebsiteFactory' => $this->productWebsiteFactory, - 'categoryIndexer' => $this->categoryIndexer, + 'indexerRegistry' => $this->indexerRegistryMock, 'eavConfig' => $this->eavConfig ] ); @@ -134,15 +141,6 @@ class ActionTest extends \PHPUnit_Framework_TestCase ->with($productIds, $attrData, $storeId) ->will($this->returnSelf()); - $this->categoryIndexer - ->expects($this->any()) - ->method('getId') - ->will($this->returnValue(false)); - $this->categoryIndexer - ->expects($this->any()) - ->method('load') - ->with('catalog_product_category') - ->will($this->returnSelf()); $this->categoryIndexer ->expects($this->any()) ->method('isScheduled') @@ -151,6 +149,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase ->expects($this->any()) ->method('reindexList') ->will($this->returnValue($productIds)); + $this->prepareIndexer(); $this->eavConfig ->expects($this->any()) ->method('getAttribute') @@ -181,15 +180,6 @@ class ActionTest extends \PHPUnit_Framework_TestCase ->with($websiteIds, $productIds) ->will($this->returnSelf()); - $this->categoryIndexer - ->expects($this->any()) - ->method('getId') - ->will($this->returnValue(false)); - $this->categoryIndexer - ->expects($this->any()) - ->method('load') - ->with('catalog_product_category') - ->will($this->returnSelf()); $this->categoryIndexer ->expects($this->any()) ->method('isScheduled') @@ -198,6 +188,7 @@ class ActionTest extends \PHPUnit_Framework_TestCase ->expects($this->any()) ->method('reindexList') ->will($this->returnValue($productIds)); + $this->prepareIndexer(); $this->model->updateWebsites($productIds, $websiteIds, $type); $this->assertEquals($this->model->getDataByKey('product_ids'), $productIdsUnique); $this->assertEquals($this->model->getDataByKey('website_ids'), $websiteIds); @@ -211,4 +202,12 @@ class ActionTest extends \PHPUnit_Framework_TestCase ['$type' => 'remove', '$methodName' => 'removeProducts'] ]; } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID) + ->will($this->returnValue($this->categoryIndexer)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/CategoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/CategoryTest.php index edc76ac7c54..d769f281d80 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/CategoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/CategoryTest.php @@ -43,8 +43,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase $this->returnValue('category_ids') ); - $logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); - $model = new \Magento\Catalog\Model\Product\Attribute\Backend\Category($logger); + $model = new \Magento\Catalog\Model\Product\Attribute\Backend\Category(); $model->setAttribute($categoryAttribute); $model->afterLoad($product); 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 a11d85e686c..e73a980a912 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 @@ -42,7 +42,6 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->_helper = $this->getMock('Magento\Catalog\Helper\Data', array('isPriceGlobal'), array(), '', false); $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true)); - $loggerMock = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); $currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); $storeManagerMock = $this->getMock('Magento\Framework\StoreManagerInterface', array(), array(), '', false); $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); @@ -51,7 +50,6 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->_model = $this->getMockForAbstractClass( 'Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice', array( - 'logger' => $loggerMock, 'currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index 6803d90bc60..30ac0a1b706 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -101,6 +101,11 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ private $website; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -193,6 +198,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $storeManager->expects($this->any()) ->method('getWebsite') ->will($this->returnValue($this->website)); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( @@ -200,7 +206,6 @@ class ProductTest extends \PHPUnit_Framework_TestCase [ 'context' => $contextMock, 'catalogProductType' => $this->productTypeInstanceMock, - 'categoryIndexer' => $this->categoryIndexerMock, 'productFlatIndexerProcessor' => $this->productFlatProcessor, 'productPriceIndexerProcessor' => $this->productPriceProcessor, 'catalogProductOption' => $this->optionInstanceMock, @@ -208,6 +213,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase 'resource' => $this->resource, 'registry' => $this->registry, 'categoryFactory' => $this->categoryFactory, + 'indexerRegistry' => $this->indexerRegistryMock, 'data' => array('id' => 1) ] ); @@ -318,6 +324,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $this->categoryIndexerMock->expects($this->once())->method('reindexRow'); $this->productFlatProcessor->expects($this->once())->method('reindexRow'); $this->productPriceProcessor->expects($this->once())->method('reindexRow'); + $this->prepareCategoryIndexer(); $this->assertSame($this->model, $this->model->delete()); } @@ -325,6 +332,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $this->categoryIndexerMock->expects($this->once())->method('reindexRow'); $this->productFlatProcessor->expects($this->once())->method('reindexRow'); + $this->prepareCategoryIndexer(); $this->assertNull($this->model->reindex()); } @@ -465,4 +473,12 @@ class ProductTest extends \PHPUnit_Framework_TestCase $this->model->getResource()->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); $this->model->getResource()->expects($this->any())->method('commit')->will($this->returnSelf()); } + + protected function prepareCategoryIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID) + ->will($this->returnValue($this->categoryIndexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Plugin/Model/Resource/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Plugin/Model/Resource/ConfigTest.php new file mode 100644 index 00000000000..aee4e934944 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Plugin/Model/Resource/ConfigTest.php @@ -0,0 +1,199 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Plugin\Model\Resource; + +use Magento\TestFramework\Helper\ObjectManager; + +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Catalog\Plugin\Model\Resource\Config */ + protected $config; + + /** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $cache; + + /** @var \Magento\Framework\App\Cache\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheState; + + /** @var \Magento\Catalog\Model\Resource\Config|\PHPUnit_Framework_MockObject_MockObject */ + protected $subject; + + protected function setUp() + { + $this->cache = $this->getMock('Magento\Framework\App\CacheInterface'); + $this->cacheState = $this->getMock('Magento\Framework\App\Cache\StateInterface'); + $this->subject = $this->getMock('Magento\Catalog\Model\Resource\Config', [], [], '', false); + } + + public function testGetAttributesUsedInListingOnCacheDisabled() + { + $this->cache->expects($this->never())->method('load'); + + $this->assertEquals( + ['attributes'], + $this->getConfig(false)->aroundGetAttributesUsedInListing( + $this->subject, + $this->mockPluginProceed(['attributes']) + ) + ); + } + + public function testGetAttributesUsedInListingFromCache() + { + $entityTypeId = 'type'; + $storeId = 'store'; + $attributes = ['attributes']; + $this->subject->expects($this->any())->method('getEntityTypeId')->willReturn($entityTypeId); + $this->subject->expects($this->any())->method('getStoreId')->willReturn($storeId); + $cacheId = \Magento\Catalog\Plugin\Model\Resource\Config::PRODUCT_LISTING_ATTRIBUTES_CACHE_ID . $entityTypeId + . '_' . $storeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(serialize($attributes)); + + $this->assertEquals( + $attributes, + $this->getConfig(true)->aroundGetAttributesUsedInListing( + $this->subject, + $this->mockPluginProceed() + ) + ); + } + + public function testGetAttributesUsedInListingWithCacheSave() + { + $entityTypeId = 'type'; + $storeId = 'store'; + $attributes = ['attributes']; + $this->subject->expects($this->any())->method('getEntityTypeId')->willReturn($entityTypeId); + $this->subject->expects($this->any())->method('getStoreId')->willReturn($storeId); + $cacheId = \Magento\Catalog\Plugin\Model\Resource\Config::PRODUCT_LISTING_ATTRIBUTES_CACHE_ID . $entityTypeId + . '_' . $storeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(false); + $this->cache->expects($this->any())->method('save')->with( + serialize($attributes), + $cacheId, + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ] + ); + + $this->assertEquals( + $attributes, + $this->getConfig(true)->aroundGetAttributesUsedInListing( + $this->subject, + $this->mockPluginProceed($attributes) + ) + ); + } + + public function testGetAttributesUsedForSortByOnCacheDisabled() + { + $this->cache->expects($this->never())->method('load'); + + $this->assertEquals( + ['attributes'], + $this->getConfig(false)->aroundGetAttributesUsedForSortBy( + $this->subject, + $this->mockPluginProceed(['attributes']) + ) + ); + } + + public function testGetAttributesUsedForSortByFromCache() + { + $entityTypeId = 'type'; + $storeId = 'store'; + $attributes = ['attributes']; + $this->subject->expects($this->any())->method('getEntityTypeId')->willReturn($entityTypeId); + $this->subject->expects($this->any())->method('getStoreId')->willReturn($storeId); + $cacheId = \Magento\Catalog\Plugin\Model\Resource\Config::PRODUCT_LISTING_SORT_BY_ATTRIBUTES_CACHE_ID + . $entityTypeId . '_' . $storeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(serialize($attributes)); + + $this->assertEquals( + $attributes, + $this->getConfig(true)->aroundGetAttributesUsedForSortBy( + $this->subject, + $this->mockPluginProceed() + ) + ); + } + + public function testGetAttributesUsedForSortByWithCacheSave() + { + $entityTypeId = 'type'; + $storeId = 'store'; + $attributes = ['attributes']; + $this->subject->expects($this->any())->method('getEntityTypeId')->willReturn($entityTypeId); + $this->subject->expects($this->any())->method('getStoreId')->willReturn($storeId); + $cacheId = \Magento\Catalog\Plugin\Model\Resource\Config::PRODUCT_LISTING_SORT_BY_ATTRIBUTES_CACHE_ID + . $entityTypeId . '_' . $storeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(false); + $this->cache->expects($this->any())->method('save')->with( + serialize($attributes), + $cacheId, + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ] + ); + + $this->assertEquals( + $attributes, + $this->getConfig(true)->aroundGetAttributesUsedForSortBy( + $this->subject, + $this->mockPluginProceed($attributes) + ) + ); + } + + /** + * @param bool $cacheEnabledFlag + * @return \Magento\Catalog\Plugin\Model\Resource\Config + */ + protected function getConfig($cacheEnabledFlag) + { + $this->cacheState->expects($this->any())->method('isEnabled') + ->with(\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER)->willReturn($cacheEnabledFlag); + return (new ObjectManager($this))->getObject( + 'Magento\Catalog\Plugin\Model\Resource\Config', + [ + 'cache' => $this->cache, + 'cacheState' => $this->cacheState + ] + ); + } + + /** + * @param mixed $returnValue + * @return callable + */ + protected function mockPluginProceed($returnValue = null) + { + return function () use ($returnValue) { + return $returnValue; + }; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductBuilderTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductBuilderTest.php index 6b4218d093f..3959cc47c86 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductBuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Service/V1/Data/ProductBuilderTest.php @@ -34,7 +34,7 @@ class ProductBuilderTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Service\V1\MetadataService */ private $_productMetadataService; - /** @var \Magento\Framework\Api\AttributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder */ private $_valueBuilder; protected function setUp() @@ -57,7 +57,7 @@ class ProductBuilderTest extends \PHPUnit_Framework_TestCase ) ); $this->_valueBuilder = $this->_objectManager->getObject( - 'Magento\Framework\Api\AttributeValueBuilder' + 'Magento\Framework\Api\AttributeDataBuilder' ); $this->_productBuilder = $this->_objectManager->getObject( 'Magento\Catalog\Service\V1\Data\ProductBuilder', diff --git a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/ImportTest.php b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/ImportTest.php index 01cd873bcad..4a30b74e6b7 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/ImportTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/ImportTest.php @@ -40,6 +40,11 @@ class ImportTest extends \PHPUnit_Framework_TestCase */ protected $_indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + public function setUp() { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -51,17 +56,21 @@ class ImportTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_indexerMock->expects($this->any())->method('getId')->will($this->returnValue(1)); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); $this->_model = $this->_objectManager->getObject( 'Magento\CatalogImportExport\Model\Indexer\Product\Price\Plugin\Import', - array('indexer' => $this->_indexerMock) + array('indexerRegistry' => $this->indexerRegistryMock) ); } public function testAfterImportSource() { $this->_indexerMock->expects($this->once())->method('invalidate'); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) + ->will($this->returnValue($this->_indexerMock)); $importMock = $this->getMock('Magento\ImportExport\Model\Import', array(), array(), '', false); $this->assertEquals('return_value', $this->_model->afterImportSource($importMock, 'return_value')); diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php index d1a843d44b1..f99ebeee9f9 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Service/V1/StockItemServiceTest.php @@ -496,28 +496,29 @@ class StockItemServiceTest extends \PHPUnit_Framework_TestCase $this->stockItemRegistry->expects($this->any())->method('retrieve') ->will($this->returnValueMap([[$productId, $stockItem]])); - $this->stockItemBuilder->expects($this->any()) - ->method('create') - ->will($this->returnValue($stockItemDataObject)); - $stockItemDetailsDo->expects($this->any()) ->method('__toArray') ->will($this->returnValue($stockItemDetailsDoData)); - $this->stockItemBuilder->expects($this->any()) - ->method('mergeDataObjectWithArray') - ->will($this->returnValue($stockItemDataObjectMerged)); - $stockItemDataObjectMerged->expects($this->any()) ->method('__toArray') ->will($this->returnValue($dataToSave)); // 3. Set expectations $stockItem->expects($this->any())->method('setData')->with($dataToSave)->will($this->returnSelf()); - $this->stockItemBuilder->expects($this->any()) + $this->stockItemBuilder->expects($this->at(0)) ->method('populateWithArray') ->with($stockItemData) ->will($this->returnSelf()); + $this->stockItemBuilder->expects($this->at(1)) + ->method('create') + ->will($this->returnValue($stockItemDataObject)); + $this->stockItemBuilder->expects($this->at(2)) + ->method('mergeDataObjectWithArray') + ->will($this->returnValue($this->stockItemBuilder)); + $this->stockItemBuilder->expects($this->at(3)) + ->method('create') + ->will($this->returnValue($stockItemDataObjectMerged)); // 4. Run tested method $result = $this->model->saveStockItemBySku($productSku, $stockItemDetailsDo); diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/CronTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/CronTest.php new file mode 100644 index 00000000000..6680b635a89 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/CronTest.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\CatalogRule\Model; + +use Magento\TestFramework\Helper\ObjectManager; + +class CronTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleProductProcessor; + + /** + * @var \Magento\CatalogRule\Model\Cron + */ + protected $cron; + + protected function setUp() + { + $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], [], '', false); + + $this->cron = (new ObjectManager($this))->getObject('Magento\CatalogRule\Model\Cron', [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ]); + } + + public function testDailyCatalogUpdate() + { + $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->cron->dailyCatalogUpdate(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/AbstractIndexerTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/AbstractIndexerTest.php new file mode 100644 index 00000000000..6a3f0d3e024 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/AbstractIndexerTest.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\CatalogRule\Model\Indexer; + +class AbstractIndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexBuilder; + + /** + * @var \Magento\CatalogRule\Model\Indexer\AbstractIndexer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexer; + + protected function setUp() + { + $this->indexBuilder = $this->getMock('Magento\CatalogRule\Model\Indexer\IndexBuilder', [], [], '', false); + + $this->indexer = $this->getMockForAbstractClass( + 'Magento\CatalogRule\Model\Indexer\AbstractIndexer', + [$this->indexBuilder] + ); + } + + public function testExecute() + { + $ids = [1, 2, 5]; + $this->indexer->expects($this->once())->method('doExecuteList')->with($ids); + + $this->indexer->execute($ids); + } + + public function testExecuteFull() + { + $this->indexBuilder->expects($this->once())->method('reindexFull'); + + $this->indexer->executeFull(); + } + + /** + * @expectedException \Magento\CatalogRule\CatalogRuleException + * @expectedExceptionMessage Could not rebuild index for empty products array + */ + public function testExecuteListWithEmptyIds() + { + $this->indexer->executeList([]); + } + + public function testExecuteList() + { + $ids = [1, 2, 5]; + $this->indexer->expects($this->once())->method('doExecuteList')->with($ids); + + $this->indexer->executeList($ids); + } + + /** + * @expectedException \Magento\CatalogRule\CatalogRuleException + * @expectedExceptionMessage Could not rebuild index for undefined product + */ + public function testExecuteRowWithEmptyId() + { + $this->indexer->executeRow(null); + } + + public function testExecuteRow() + { + $id = 5; + $this->indexer->expects($this->once())->method('doExecuteRow')->with($id); + + $this->indexer->executeRow($id); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexerTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexerTest.php new file mode 100644 index 00000000000..ccc438ebffa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexerTest.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\CatalogRule\Model\Indexer\Product; + +use Magento\TestFramework\Helper\ObjectManager; + +class ProductRuleIndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexBuilder; + + /** + * @var \Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer + */ + protected $indexer; + + protected function setUp() + { + $this->indexBuilder = $this->getMock('Magento\CatalogRule\Model\Indexer\IndexBuilder', [], [], '', false); + + $this->indexer = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer', + [ + 'indexBuilder' => $this->indexBuilder, + ] + ); + } + /** + * @param array $ids + * @param array $idsForIndexer + * @dataProvider dataProviderForExecuteList + */ + public function testDoExecuteList($ids, $idsForIndexer) + { + $this->indexBuilder->expects($this->once())->method('reindexByIds')->with($idsForIndexer); + + $this->indexer->executeList($ids); + } + + /** + * @return array + */ + public function dataProviderForExecuteList() + { + return [ + [ + [1, 2, 3, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + ], + ]; + } + + public function testDoExecuteRow() + { + $id = 5; + $this->indexBuilder->expects($this->once())->method('reindexById')->with($id); + + $this->indexer->executeRow($id); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexerTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexerTest.php new file mode 100644 index 00000000000..5e71cbe9ffa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Indexer/Rule/RuleProductIndexerTest.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\CatalogRule\Model\Indexer\Rule; + +use Magento\TestFramework\Helper\ObjectManager; + +class RuleProductIndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexBuilder; + + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer + */ + protected $indexer; + + protected function setUp() + { + $this->indexBuilder = $this->getMock('Magento\CatalogRule\Model\Indexer\IndexBuilder', [], [], '', false); + + $this->indexer = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer', + [ + 'indexBuilder' => $this->indexBuilder, + ] + ); + } + + public function testDoExecuteList() + { + $this->indexBuilder->expects($this->once())->method('reindexFull'); + + $this->indexer->executeList([1, 2, 5]); + } + + public function testDoExecuteRow() + { + $this->indexBuilder->expects($this->once())->method('reindexFull'); + + $this->indexer->executeRow(5); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/Condition/ProductTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/Condition/ProductTest.php index 95ffddf34d3..b76cfac9289 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/Condition/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/Condition/ProductTest.php @@ -58,7 +58,8 @@ class ProductTest extends \PHPUnit_Framework_TestCase 'getData', 'getId', 'getStoreId', - 'getResource' + 'getResource', + 'addAttributeToSelect', ), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/JobTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/JobTest.php index a169032d5b7..8cb2e927033 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/JobTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Model/Rule/JobTest.php @@ -28,21 +28,45 @@ class JobTest extends \PHPUnit_Framework_TestCase /** * Test for method applyAll * - * Checks that dispatch event with param value "catalogrule_apply_all" runs while applying all rules + * Checks that invalidate Rule indexer + * + * @return void */ public function testApplyAll() { - $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - - $eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', array(), array(), '', false); - $eventManager->expects($this->once())->method('dispatch')->with($this->equalTo('catalogrule_apply_all')); - - /** @var $jobModel \Magento\CatalogRule\Model\Rule\Job */ - $jobModel = $objectManagerHelper->getObject( - 'Magento\CatalogRule\Model\Rule\Job', - array('eventManager' => $eventManager) + $ruleProcessorMock = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + ['markIndexerAsInvalid'], + [], + '', + false ); + $ruleProcessorMock->expects($this->once())->method('markIndexerAsInvalid'); + $jobModel = new Job($ruleProcessorMock); + $jobModel->applyAll(); + } + /** + * @return void + */ + public function testExceptionApplyAll() + { + $ruleProcessorMock = $this->getMock( + 'Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + ['markIndexerAsInvalid'], + [], + '', + false + ); + $exceptionMessage = 'Test exception message'; + $exceptionCallback = function () use ($exceptionMessage) { + throw new \Magento\Framework\Model\Exception($exceptionMessage); + }; + $ruleProcessorMock->expects($this->once()) + ->method('markIndexerAsInvalid') + ->will($this->returnCallback($exceptionCallback)); + $jobModel = new Job($ruleProcessorMock); $jobModel->applyAll(); + $this->assertEquals($exceptionMessage, $jobModel->getError()); } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CategoryTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CategoryTest.php new file mode 100644 index 00000000000..cea3a53a36d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CategoryTest.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\CatalogRule\Plugin\Indexer; + +use Magento\TestFramework\Helper\ObjectManager; + +class CategoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productRuleProcessor; + + /** + * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + + /** + * @var \Magento\CatalogRule\Plugin\Indexer\Category + */ + protected $plugin; + + protected function setUp() + { + $this->productRuleProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor', + [], [], '', false); + $this->subject = $this->getMock('Magento\Catalog\Model\Category', ['getAffectedProductIds', '__wakeUp'], [], + '', false); + + $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Category', [ + 'productRuleProcessor' => $this->productRuleProcessor, + ]); + } + + public function testAfterSaveWithoutAffectedProductIds() + { + $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue([])); + $this->productRuleProcessor->expects($this->never())->method('reindexList'); + + $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); + } + + public function testAfterSave() + { + $productIds = [1, 2, 3]; + + $this->subject->expects($this->any())->method('getAffectedProductIds')->will($this->returnValue($productIds)); + $this->productRuleProcessor->expects($this->once())->method('reindexList')->with($productIds); + + $this->assertEquals($this->subject, $this->plugin->afterSave($this->subject, $this->subject)); + } + + public function testAfterDelete() + { + $this->productRuleProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CustomerGroupTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CustomerGroupTest.php new file mode 100644 index 00000000000..ee9ab84ffad --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/CustomerGroupTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Plugin\Indexer; + +use Magento\TestFramework\Helper\ObjectManager; + +class CustomerGroupTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleProductProcessor; + + /** + * @var \Magento\Customer\Model\Group|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + + /** + * @var \Magento\CatalogRule\Plugin\Indexer\CustomerGroup + */ + protected $plugin; + + protected function setUp() + { + $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], [], '', false); + $this->subject = $this->getMock('Magento\Customer\Model\Group', [], [], '', false); + + $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\CustomerGroup', [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ]); + } + + public function testAfterDelete() + { + $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/ImportExportTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/ImportExportTest.php new file mode 100644 index 00000000000..ed16297c096 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/ImportExportTest.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\CatalogRule\Plugin\Indexer; + +use Magento\TestFramework\Helper\ObjectManager; + +class ImportExportTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleProductProcessor; + + /** + * @var \Magento\ImportExport\Model\Import|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + + /** + * @var \Magento\CatalogRule\Plugin\Indexer\ImportExport + */ + protected $plugin; + + protected function setUp() + { + $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], [], '', false); + $this->subject = $this->getMock('Magento\ImportExport\Model\Import', [], [], '', false); + + $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\ImportExport', [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ]); + } + + public function testAfterImportSource() + { + $result = true; + + $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->assertEquals($result, $this->plugin->afterImportSource($this->subject, $result)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexerTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexerTest.php new file mode 100644 index 00000000000..fbb9194b94f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/Product/PriceIndexerTest.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\CatalogRule\Plugin\Indexer\Product; + +use Magento\TestFramework\Helper\ObjectManager; + +class PriceIndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $priceProcessor; + + /** + * @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + + /** + * @var \Magento\CatalogRule\Plugin\Indexer\Product\PriceIndexer + */ + protected $plugin; + + protected function setUp() + { + $this->priceProcessor = $this->getMock( + 'Magento\Catalog\Model\Indexer\Product\Price\Processor', + [], + [], + '', + false + ); + $this->subject = $this->getMock('Magento\CatalogRule\Model\Indexer\IndexBuilder', [], [], '', false); + + $this->plugin = (new ObjectManager($this))->getObject( + 'Magento\CatalogRule\Plugin\Indexer\Product\PriceIndexer', + [ + 'priceProcessor' => $this->priceProcessor, + ] + ); + } + + public function testAfterSaveWithoutAffectedProductIds() + { + $this->priceProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->plugin->afterReindexFull($this->subject, $this->subject); + } + + public function testReindexRow() + { + $productIds = [1,2,3]; + $proceed = function () { + return; + }; + $this->priceProcessor->expects($this->once())->method('reindexList')->with($productIds); + $this->plugin->aroundReindexByIds($this->subject, $proceed, $productIds); + } + + public function testReindexRows() + { + $productId = 1; + $this->priceProcessor->expects($this->once())->method('reindexRow')->with($productId); + $proceed = function () { + return; + }; + $this->plugin->aroundReindexById($this->subject, $proceed, $productId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/WebsiteTest.php new file mode 100644 index 00000000000..7f7657f5f96 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogRule/Plugin/Indexer/WebsiteTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CatalogRule\Plugin\Indexer; + +use Magento\TestFramework\Helper\ObjectManager; + +class WebsiteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $ruleProductProcessor; + + /** + * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + + /** + * @var \Magento\CatalogRule\Plugin\Indexer\Website + */ + protected $plugin; + + protected function setUp() + { + $this->ruleProductProcessor = $this->getMock('Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], [], '', false); + $this->subject = $this->getMock('Magento\Store\Model\Website', [], [], '', false); + + $this->plugin = (new ObjectManager($this))->getObject('Magento\CatalogRule\Plugin\Indexer\Website', [ + 'ruleProductProcessor' => $this->ruleProductProcessor, + ]); + } + + public function testAfterDelete() + { + $this->ruleProductProcessor->expects($this->once())->method('markIndexerAsInvalid'); + + $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AttributeTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AttributeTest.php index 3b63d00e220..73eaa529d4f 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AttributeTest.php @@ -35,6 +35,11 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var Attribute */ @@ -52,7 +57,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase true, ['getId', 'getState', '__wakeup'] ); - $this->model = new Attribute($this->indexerMock); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new Attribute($this->indexerRegistryMock); } /** @@ -82,8 +88,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase return $this->subjectMock; }; - $this->indexerMock->expects($this->exactly($invalidateCounter))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->exactly($invalidateCounter))->method('invalidate'); + $this->prepareIndexer($invalidateCounter); $this->assertEquals( $this->subjectMock, @@ -128,8 +134,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase return $this->subjectMock; }; - $this->indexerMock->expects($this->exactly($invalidateCounter))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->exactly($invalidateCounter))->method('invalidate'); + $this->prepareIndexer($invalidateCounter); $this->assertEquals( $this->subjectMock, @@ -149,4 +155,15 @@ class AttributeTest extends \PHPUnit_Framework_TestCase [true, true, 0], ]; } + + /** + * @param $invalidateCounter + */ + protected function prepareIndexer($invalidateCounter) + { + $this->indexerRegistryMock->expects($this->exactly($invalidateCounter)) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php index 62262f4d238..320f3ccfca6 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/ActionTest.php @@ -38,6 +38,11 @@ class ActionTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var Action */ @@ -56,15 +61,16 @@ class ActionTest extends \PHPUnit_Framework_TestCase true, array('getId', 'getState', '__wakeup') ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); - $this->model = new Action($this->indexerMock); + $this->model = new Action($this->indexerRegistryMock); } public function testAroundUpdateAttributesNonScheduled() { - $this->indexerMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('reindexList')->with(array(1, 2, 3)); + $this->prepareIndexer(); $closureMock = function ($productIds, $attrData, $storeId) { $this->assertEquals(array(1, 2, 3), $productIds); @@ -81,9 +87,9 @@ class ActionTest extends \PHPUnit_Framework_TestCase public function testAroundUpdateAttributesScheduled() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(true)); $this->indexerMock->expects($this->never())->method('reindexList'); + $this->prepareIndexer(); $closureMock = function ($productIds, $attrData, $storeId) { $this->assertEquals(array(1, 2, 3), $productIds); @@ -100,9 +106,9 @@ class ActionTest extends \PHPUnit_Framework_TestCase public function testAroundUpdateWebsitesNonScheduled() { - $this->indexerMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('reindexList')->with(array(1, 2, 3)); + $this->prepareIndexer(); $closureMock = function ($productIds, $websiteIds, $type) { $this->assertEquals(array(1, 2, 3), $productIds); @@ -116,9 +122,9 @@ class ActionTest extends \PHPUnit_Framework_TestCase public function testAroundUpdateWebsitesScheduled() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(true)); $this->indexerMock->expects($this->never())->method('reindexList'); + $this->prepareIndexer(); $closureMock = function ($productIds, $websiteIds, $type) { $this->assertEquals(array(1, 2, 3), $productIds); @@ -129,4 +135,12 @@ class ActionTest extends \PHPUnit_Framework_TestCase $this->model->aroundUpdateWebsites($this->subjectMock, $closureMock, array(1, 2, 3), array(4, 5, 6), 'type'); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/ProductTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/ProductTest.php index 14f65c8d4e4..636d013684c 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/ProductTest.php @@ -38,6 +38,11 @@ class ProductTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var Product */ @@ -57,14 +62,16 @@ class ProductTest extends \PHPUnit_Framework_TestCase array('getId', 'getState', '__wakeup') ); - $this->model = new Product($this->indexerMock); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + + $this->model = new Product($this->indexerRegistryMock); } public function testAfterSaveNonScheduled() { - $this->indexerMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('reindexRow')->with(1); + $this->prepareIndexer(); $this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1)); @@ -73,9 +80,9 @@ class ProductTest extends \PHPUnit_Framework_TestCase public function testAfterSaveScheduled() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(true)); $this->indexerMock->expects($this->never())->method('reindexRow'); + $this->prepareIndexer(); $this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1)); @@ -84,9 +91,9 @@ class ProductTest extends \PHPUnit_Framework_TestCase public function testAfterDeleteNonScheduled() { - $this->indexerMock->expects($this->exactly(2))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(false)); $this->indexerMock->expects($this->once())->method('reindexRow')->with(1); + $this->prepareIndexer(); $this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1)); @@ -95,12 +102,20 @@ class ProductTest extends \PHPUnit_Framework_TestCase public function testAfterDeleteScheduled() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('isScheduled')->will($this->returnValue(true)); $this->indexerMock->expects($this->never())->method('reindexRow'); + $this->prepareIndexer(); $this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->assertEquals($this->subjectMock, $this->model->afterDelete($this->subjectMock)); } + + protected function prepareIndexer() + { + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php index cadbac0a0aa..b7fbc93277a 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/GroupTest.php @@ -35,6 +35,11 @@ class GroupTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var Group */ @@ -52,7 +57,8 @@ class GroupTest extends \PHPUnit_Framework_TestCase true, ['getId', 'getState', '__wakeup'] ); - $this->model = new Group($this->indexerMock); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new Group($this->indexerRegistryMock); } /** @@ -82,8 +88,8 @@ class GroupTest extends \PHPUnit_Framework_TestCase return $this->subjectMock; }; - $this->indexerMock->expects($this->exactly($invalidateCounter))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->exactly($invalidateCounter))->method('invalidate'); + $this->prepareIndexer($invalidateCounter); $this->assertEquals( $this->subjectMock, @@ -109,12 +115,23 @@ class GroupTest extends \PHPUnit_Framework_TestCase */ public function testAfterDelete() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->prepareIndexer(1); $this->assertEquals( $this->subjectMock, $this->model->afterDelete($this->subjectMock, $this->subjectMock) ); } + + /** + * @param int $invalidateCounter + */ + protected function prepareIndexer($invalidateCounter) + { + $this->indexerRegistryMock->expects($this->exactly($invalidateCounter)) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php index d8235f922d6..9b892621f0e 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/ViewTest.php @@ -35,6 +35,11 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected $subjectMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + /** * @var View */ @@ -52,7 +57,8 @@ class ViewTest extends \PHPUnit_Framework_TestCase true, ['getId', 'getState', '__wakeup'] ); - $this->model = new View($this->indexerMock); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new View($this->indexerRegistryMock); } /** @@ -77,8 +83,8 @@ class ViewTest extends \PHPUnit_Framework_TestCase return $this->subjectMock; }; - $this->indexerMock->expects($this->exactly($invalidateCounter))->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->exactly($invalidateCounter))->method('invalidate'); + $this->prepareIndexer($invalidateCounter); $this->assertEquals( $this->subjectMock, @@ -102,12 +108,23 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testAfterDelete() { - $this->indexerMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->indexerMock->expects($this->once())->method('invalidate'); + $this->prepareIndexer(1); $this->assertEquals( $this->subjectMock, $this->model->afterDelete($this->subjectMock, $this->subjectMock) ); } + + /** + * @param int $invalidateCounter + */ + protected function prepareIndexer($invalidateCounter) + { + $this->indexerRegistryMock->expects($this->exactly($invalidateCounter)) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); + } } diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php index 2018abe258a..aac6c01dac9 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Model/Indexer/FulltextTest.php @@ -45,6 +45,11 @@ class FulltextTest extends \PHPUnit_Framework_TestCase */ protected $indexerMock; + /** + * @var \Magento\Indexer\Model\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerRegistryMock; + protected function setUp() { $this->fullMock = $this->getMock( @@ -73,10 +78,12 @@ class FulltextTest extends \PHPUnit_Framework_TestCase array('getId', 'load', 'isInvalid', 'isWorking', '__wakeup') ); + $this->indexerRegistryMock = $this->getMock('Magento\Indexer\Model\IndexerRegistry', ['get'], [], '', false); + $this->model = new \Magento\CatalogSearch\Model\Indexer\Fulltext( $this->fullMock, $this->rowsMock, - $this->indexerMock + $this->indexerRegistryMock ); } @@ -84,15 +91,10 @@ class FulltextTest extends \PHPUnit_Framework_TestCase { $ids = array(1, 2, 3); - $this->indexerMock->expects( - $this->once() - )->method( - 'load' - )->with( - \Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID - )->will( - $this->returnSelf() - ); + $this->indexerRegistryMock->expects($this->once()) + ->method('get') + ->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID) + ->will($this->returnValue($this->indexerMock)); $rowMock = $this->getMock( 'Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Rows', 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 83be2df63c1..63644bbb2ae 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php @@ -399,6 +399,7 @@ class OnepageTest extends \PHPUnit_Framework_TestCase $addressMock->expects($this->any())->method('getData')->will($this->returnValue([])); $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock)); $quoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($quoteCustomerId)); + $quoteMock->expects($this->once())->method('save'); $formMock = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false); $formMock->expects($this->atLeastOnce())->method('validateData')->will($this->returnValue($validateDataResult)); $this->requestMock diff --git a/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/EditTest.php b/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/EditTest.php new file mode 100644 index 00000000000..07d483b5dcf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/EditTest.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\Cms\Block\Adminhtml\Block; + +/** + * @covers \Magento\Cms\Block\Adminhtml\Block\Edit + */ +class EditTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Block\Adminhtml\Block\Edit + */ + protected $this; + + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $escaperMock; + + /** + * @var \Magento\Cms\Model\Block|\PHPUnit_Framework_MockObject_MockObject + */ + protected $modelBlockMock; + + protected function setUp() + { + $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + $this->escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + ->disableOriginalConstructor() + ->getMock(); + $this->modelBlockMock = $this->getMockBuilder('Magento\Cms\Model\Block') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getId', + 'getTitle' + ] + ) + ->getMock(); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->this = $objectManager->getObject( + 'Magento\Cms\Block\Adminhtml\Block\Edit', + [ + 'registry' => $this->registryMock, + 'escaper' => $this->escaperMock + ] + ); + } + + /** + * @covers \Magento\Cms\Block\Adminhtml\Block\Edit::getHeaderText + * @param integer|null $modelBlockId + * + * @dataProvider getHeaderTextDataProvider + */ + public function testGetHeaderText($modelBlockId) + { + $title = 'some title'; + $escapedTitle = 'escaped title'; + + $this->registryMock->expects($this->atLeastOnce()) + ->method('registry') + ->with('cms_block') + ->willReturn($this->modelBlockMock); + $this->modelBlockMock->expects($this->atLeastOnce()) + ->method('getId') + ->willReturn($modelBlockId); + $this->modelBlockMock->expects($this->any()) + ->method('getTitle') + ->willReturn($title); + $this->escaperMock->expects($this->any()) + ->method('escapeHtml') + ->with($title) + ->willReturn($escapedTitle); + + $this->assertInternalType('string', $this->this->getHeaderText()); + } + + public function getHeaderTextDataProvider() + { + return [ + 'modelBlockId NOT EMPTY' => ['modelBlockId' => 1], + 'modelBlockId IS EMPTY' => ['modelBlockId' => null] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/Widget/ChooserTest.php b/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/Widget/ChooserTest.php new file mode 100644 index 00000000000..f78e828d2b3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/Widget/ChooserTest.php @@ -0,0 +1,265 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Cms\Block\Adminhtml\Block\Widget; + +/** + * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser + */ +class ChooserTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser + */ + protected $this; + + /** + * @var \Magento\Backend\Block\Template\Context + */ + protected $context; + + /** + * @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject + */ + protected $mathRandomMock; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilderMock; + + /** + * @var \Magento\Cms\Model\BlockFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $blockFactoryMock; + + /** + * @var \Magento\Framework\Data\Form\Element\AbstractElement|\PHPUnit_Framework_MockObject_MockObject + */ + protected $elementMock; + + /** + * @var \Magento\Cms\Model\Block|\PHPUnit_Framework_MockObject_MockObject + */ + protected $modelBlockMock; + + /** + * @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $chooserMock; + + protected function setUp() + { + $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random') + ->disableOriginalConstructor() + ->getMock(); + $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->blockFactoryMock = $this->getMockBuilder('Magento\Cms\Model\BlockFactory') + ->setMethods( + [ + 'create' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + $this->elementMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\AbstractElement') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getId', + 'getValue', + 'setData' + ] + ) + ->getMock(); + $this->modelBlockMock = $this->getMockBuilder('Magento\Cms\Model\Block') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getTitle', + 'load' + ] + ) + ->getMock(); + $this->chooserMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + ->disableOriginalConstructor() + ->setMethods( + [ + 'setElement', + 'setConfig', + 'setFieldsetId', + 'setSourceUrl', + 'setUniqId', + 'setLabel', + 'toHtml' + ] + ) + ->getMock(); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->context = $objectManager->getObject( + 'Magento\Backend\Block\Template\Context', + [ + 'layout' => $this->layoutMock, + 'mathRandom' => $this->mathRandomMock, + 'urlBuilder' => $this->urlBuilderMock + ] + ); + $this->this = $objectManager->getObject( + 'Magento\Cms\Block\Adminhtml\Block\Widget\Chooser', + [ + 'context' => $this->context, + 'blockFactory' => $this->blockFactoryMock + ] + ); + } + + /** + * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml + * @param string $elementValue + * @param integer|null $modelBlockId + * + * @dataProvider prepareElementHtmlDataProvider + */ + public function testPrepareElementHtml($elementValue, $modelBlockId) + { + $elementId = 1; + $uniqId = '126hj4h3j73hk7b347jhkl37gb34'; + $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34'; + $config = ['key1' => 'value1']; + $fieldsetId = 2; + $html = 'some html'; + $title = 'some title'; + + $this->this->setConfig($config); + $this->this->setFieldsetId($fieldsetId); + + $this->elementMock->expects($this->atLeastOnce()) + ->method('getId') + ->willReturn($elementId); + $this->mathRandomMock->expects($this->atLeastOnce()) + ->method('getUniqueHash') + ->with($elementId) + ->willReturn($uniqId); + $this->urlBuilderMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->with('cms/block_widget/chooser', ['uniq_id' => $uniqId]) + ->willReturn($sourceUrl); + $this->layoutMock->expects($this->atLeastOnce()) + ->method('createBlock') + ->with('Magento\Widget\Block\Adminhtml\Widget\Chooser') + ->willReturn($this->chooserMock); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('setElement') + ->with($this->elementMock) + ->willReturnSelf(); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('setConfig') + ->with($config) + ->willReturnSelf(); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('setFieldsetId') + ->with($fieldsetId) + ->willReturnSelf(); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('setSourceUrl') + ->with($sourceUrl) + ->willReturnSelf(); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('setUniqId') + ->with($uniqId) + ->willReturnSelf(); + $this->elementMock->expects($this->atLeastOnce()) + ->method('getValue') + ->willReturn($elementValue); + $this->blockFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->modelBlockMock); + $this->modelBlockMock->expects($this->any()) + ->method('load') + ->with($elementValue) + ->willReturnSelf(); + $this->modelBlockMock->expects($this->any()) + ->method('getId') + ->willReturn($modelBlockId); + $this->modelBlockMock->expects($this->any()) + ->method('getTitle') + ->willReturn($title); + $this->chooserMock->expects($this->any()) + ->method('setLabel') + ->with($title) + ->willReturnSelf(); + $this->chooserMock->expects($this->atLeastOnce()) + ->method('toHtml') + ->willReturn($html); + $this->elementMock->expects($this->atLeastOnce()) + ->method('setData') + ->with('after_element_html', $html) + ->willReturnSelf(); + + $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock)); + } + + public function prepareElementHtmlDataProvider() + { + return [ + 'elementValue NOT EMPTY, modelBlockId NOT EMPTY' => [ + 'elementValue' => 'some value', + 'modelBlockId' => 1 + ], + 'elementValue NOT EMPTY, modelBlockId IS EMPTY' => [ + 'elementValue' => 'some value', + 'modelBlockId' => null + ], + 'elementValue IS EMPTY, modelBlockId NEVER REACHED' => [ + 'elementValue' => '', + 'modelBlockId' => 1 + ] + ]; + } + + /** + * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::getGridUrl + */ + public function testGetGridUrl() + { + $url = 'some url'; + + $this->urlBuilderMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->with('cms/block_widget/chooser', ['_current' => true]) + ->willReturn($url); + + $this->assertEquals($url, $this->this->getGridUrl()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Helper/PageTest.php b/dev/tests/unit/testsuite/Magento/Cms/Helper/PageTest.php new file mode 100644 index 00000000000..b09ffb1d7e2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Helper/PageTest.php @@ -0,0 +1,550 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Cms\Helper; + +/** + * @covers \Magento\Cms\Helper\Page + */ +class PageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Helper\Page + */ + protected $this; + + /** + * @var \Magento\Framework\App\Helper\Context + */ + protected $context; + + /** + * @var \Magento\Framework\App\Action\Action|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionMock; + + /** + * @var \Magento\Cms\Model\PageFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $pageFactoryMock; + + /** + * @var \Magento\Cms\Model\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $pageMock; + + /** + * @var \Magento\Framework\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDateMock; + + /** + * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $designMock; + + /** + * @var \Magento\Framework\View\Page\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $pageConfigMock; + + /** + * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $escaperMock; + + /** + * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManagerMock; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilderMock; + + /** + * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeMock; + + /** + * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultPageMock; + + /** + * @var \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \Magento\Framework\View\Layout\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutProcessorMock; + + /** + * @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $blockMock; + + /** + * @var \Magento\Framework\View\Element\Messages|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messagesBlockMock; + + /** + * @var \Magento\Framework\Message\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $messageCollectionMock; + + protected function setUp() + { + $this->actionMock = $this->getMockBuilder('Magento\Framework\App\Action\Action') + ->disableOriginalConstructor() + ->getMock(); + $this->pageFactoryMock = $this->getMockBuilder('Magento\Cms\Model\PageFactory') + ->disableOriginalConstructor() + ->setMethods( + [ + 'create' + ] + ) + ->getMock(); + $this->pageMock = $this->getMockBuilder('Magento\Cms\Model\Page') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getId', + 'setStoreId', + 'load', + 'getCustomThemeFrom', + 'getCustomThemeTo', + 'getCustomTheme', + 'getPageLayout', + 'getIdentifier', + 'getCustomPageLayout', + 'getCustomLayoutUpdateXml', + 'getLayoutUpdateXml', + 'getContentHeading' + ] + ) + ->getMock(); + $this->storeManagerMock = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->localeDateMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->pageConfigMock = $this->getMockBuilder('Magento\Framework\View\Page\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\Framework\App\ViewInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->escaperMock = $this->getMockBuilder('Magento\Framework\Escaper') + ->disableOriginalConstructor() + ->getMock(); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->getMock(); + $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\LayoutInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->layoutProcessorMock = $this->getMockBuilder('Magento\Framework\View\Layout\ProcessorInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->blockMock = $this->getMockBuilder('Magento\Framework\View\Element\BlockInterface') + ->disableOriginalConstructor() + ->setMethods( + [ + 'setContentHeading', + 'toHtml' + ] + ) + ->getMock(); + $this->messagesBlockMock = $this->getMockBuilder('Magento\Framework\View\Element\Messages') + ->disableOriginalConstructor() + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->messageCollectionMock = $this->getMockBuilder('Magento\Framework\Message\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->context = $objectManager->getObject( + 'Magento\Framework\App\Helper\Context', + [ + 'eventManager' => $this->eventManagerMock, + 'urlBuilder' => $this->urlBuilderMock + ] + ); + $this->this = $objectManager->getObject( + 'Magento\Cms\Helper\Page', + [ + 'context' => $this->context, + 'pageFactory' => $this->pageFactoryMock, + 'page' => $this->pageMock, + 'storeManager' => $this->storeManagerMock, + 'localeDate' => $this->localeDateMock, + 'design' => $this->designMock, + 'pageConfig' => $this->pageConfigMock, + 'view' => $this->viewMock, + 'escaper' => $this->escaperMock, + 'messageManager' => $this->messageManagerMock + ] + ); + } + + /** + * @covers \Magento\Cms\Helper\Page::renderPageExtended + * @param integer|null $pageId + * @param integer|null $internalPageId + * @param integer $pageLoadResultIndex + * @param string $customPageLayout + * @param string $handle + * @param string $customLayoutUpdateXml + * @param string $layoutUpdate + * @param boolean $expectedResult + * + * @dataProvider renderPageExtendedDataProvider + */ + public function testRenderPageExtended( + $pageId, + $internalPageId, + $pageLoadResultIndex, + $customPageLayout, + $handle, + $customLayoutUpdateXml, + $layoutUpdate, + $expectedResult + ) { + $storeId = 321; + $customThemeFrom = 'customThemeFrom'; + $customThemeTo = 'customThemeTo'; + $isScopeDateInInterval = true; + $customTheme = 'customTheme'; + $pageLayout = 'pageLayout'; + $pageIdentifier = 111; + $layoutUpdateXml = 'layoutUpdateXml'; + $contentHeading = 'contentHeading'; + $escapedContentHeading = 'escapedContentHeading'; + $defaultGroup = 'defaultGroup'; + $pageLoadResultCollection = [ + null, + $this->pageMock + ]; + + $this->pageMock->expects($this->any()) + ->method('getId') + ->willReturn($internalPageId); + $this->storeManagerMock->expects($this->any()) + ->method('getStore') + ->willReturn($this->storeMock); + $this->storeMock->expects($this->any()) + ->method('getId') + ->willReturn($storeId); + $this->pageMock->expects($this->any()) + ->method('setStoreId') + ->with($storeId) + ->willReturnSelf(); + $this->pageMock->expects($this->any()) + ->method('load') + ->with($pageId) + ->willReturn($pageLoadResultCollection[$pageLoadResultIndex]); + $this->pageMock->expects($this->any()) + ->method('getCustomThemeFrom') + ->willReturn($customThemeFrom); + $this->pageMock->expects($this->any()) + ->method('getCustomThemeTo') + ->willReturn($customThemeTo); + $this->localeDateMock->expects($this->any()) + ->method('isScopeDateInInterval') + ->with(null, $customThemeFrom, $customThemeTo) + ->willReturn($isScopeDateInInterval); + $this->pageMock->expects($this->any()) + ->method('getCustomTheme') + ->willReturn($customTheme); + $this->designMock->expects($this->any()) + ->method('setDesignTheme') + ->with($customTheme) + ->willReturnSelf(); + $this->pageMock->expects($this->any()) + ->method('getPageLayout') + ->willReturn($pageLayout); + $this->pageMock->expects($this->any()) + ->method('getCustomPageLayout') + ->willReturn($customPageLayout); + $this->resultPageMock->expects($this->any()) + ->method('getConfig') + ->willReturn($this->pageConfigMock); + $this->pageConfigMock->expects($this->any()) + ->method('setPageLayout') + ->with($handle) + ->willReturnSelf(); + $this->viewMock->expects($this->any()) + ->method('getPage') + ->willReturn($this->resultPageMock); + $this->resultPageMock->expects($this->any()) + ->method('initLayout') + ->willReturnSelf(); + $this->resultPageMock->expects($this->any()) + ->method('getLayout') + ->willReturn($this->layoutMock); + $this->layoutMock->expects($this->any()) + ->method('getUpdate') + ->willReturn($this->layoutProcessorMock); + $this->layoutProcessorMock->expects($this->any()) + ->method('addHandle') + ->with('cms_page_view') + ->willReturnSelf(); + $this->pageMock->expects($this->any()) + ->method('getIdentifier') + ->willReturn($pageIdentifier); + $this->viewMock->expects($this->any()) + ->method('addPageLayoutHandles') + ->with(['id' => $pageIdentifier]) + ->willReturn(true); + $this->eventManagerMock->expects($this->any()) + ->method('dispatch') + ->with( + 'cms_page_render', + [ + 'page' => $this->pageMock, + 'controller_action' => $this->actionMock + ] + ); + $this->viewMock->expects($this->any()) + ->method('loadLayoutUpdates') + ->willReturnSelf(); + $this->pageMock->expects($this->any()) + ->method('getCustomLayoutUpdateXml') + ->willReturn($customLayoutUpdateXml); + $this->pageMock->expects($this->any()) + ->method('getLayoutUpdateXml') + ->willReturn($layoutUpdateXml); + $this->layoutProcessorMock->expects($this->any()) + ->method('addUpdate') + ->with($layoutUpdate) + ->willReturnSelf(); + $this->viewMock->expects($this->any()) + ->method('generateLayoutXml') + ->willReturnSelf(); + $this->viewMock->expects($this->any()) + ->method('generateLayoutBlocks') + ->willReturnSelf(); + $this->layoutMock->expects($this->any()) + ->method('getBlock') + ->with('page_content_heading') + ->willReturn($this->blockMock); + $this->pageMock->expects($this->any()) + ->method('getContentHeading') + ->willReturn($contentHeading); + $this->escaperMock->expects($this->any()) + ->method('escapeHtml') + ->with($contentHeading) + ->willReturn($escapedContentHeading); + $this->blockMock->expects($this->any()) + ->method('setContentHeading') + ->with($escapedContentHeading) + ->willReturnSelf(); + $this->layoutMock->expects($this->any()) + ->method('getMessagesBlock') + ->willReturn($this->messagesBlockMock); + $this->messageManagerMock->expects($this->any()) + ->method('getDefaultGroup') + ->willReturn($defaultGroup); + $this->messagesBlockMock->expects($this->any()) + ->method('addStorageType') + ->with($defaultGroup); + $this->messageManagerMock->expects($this->any()) + ->method('getMessages') + ->with(true) + ->willReturn($this->messageCollectionMock); + $this->messagesBlockMock->expects($this->any()) + ->method('addMessages') + ->with($this->messageCollectionMock) + ->willReturnSelf(); + $this->viewMock->expects($this->any()) + ->method('renderLayout') + ->willReturnSelf(); + + $this->assertEquals( + $expectedResult, + $this->this->renderPageExtended($this->actionMock, $pageId) + ); + } + + public function renderPageExtendedDataProvider() + { + return [ + 'ids NOT EQUAL BUT page->load() NOT SUCCESSFUL' => [ + 'pageId' => 123, + 'internalPageId' => 234, + 'pageLoadResultIndex' => 0, + 'customPageLayout' => 'DOES NOT MATTER', + 'handle' => 'DOES NOT MATTER', + 'customLayoutUpdateXml' => 'DOES NOT MATTER', + 'layoutUpdate' => 'DOES NOT MATTER', + 'expectedResult' => false + ], + 'page->load IS SUCCESSFUL BUT internalPageId IS EMPTY' => [ + 'pageId' => 123, + 'internalPageId' => null, + 'pageLoadResultIndex' => 1, + 'customPageLayout' => 'DOES NOT MATTER', + 'handle' => 'DOES NOT MATTER', + 'customLayoutUpdateXml' => 'DOES NOT MATTER', + 'layoutUpdate' => 'DOES NOT MATTER', + 'expectedResult' => false + ], + 'getPageLayout() AND getLayoutUpdateXml() ARE USED' => [ + 'pageId' => 123, + 'internalPageId' => 234, + 'pageLoadResultIndex' => 1, + 'customPageLayout' => 'empty', + 'handle' => 'pageLayout', + 'customLayoutUpdateXml' => '', + 'layoutUpdate' => 'layoutUpdateXml', + 'expectedResult' => true + ], + 'getCustomPageLayout() AND getCustomLayoutUpdateXml() ARE USED' => [ + 'pageId' => 123, + 'internalPageId' => 234, + 'pageLoadResultIndex' => 1, + 'customPageLayout' => 'customPageLayout', + 'handle' => 'customPageLayout', + 'customLayoutUpdateXml' => 'customLayoutUpdateXml', + 'layoutUpdate' => 'customLayoutUpdateXml', + 'expectedResult' => true + ] + ]; + } + + /** + * @covers \Magento\Cms\Helper\Page::getPageUrl + * @param integer|null $pageId + * @param integer|null $internalPageId + * @param integer $pageLoadResultIndex + * @param string|null $expectedResult + * + * @dataProvider getPageUrlDataProvider + */ + public function testGetPageUrl( + $pageId, + $internalPageId, + $pageLoadResultIndex, + $expectedResult + ) { + $storeId = 321; + $pageIdentifier = 111; + $url = '/some/url'; + $pageLoadResultCollection = [ + null, + $this->pageMock + ]; + + $this->pageFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->pageMock); + $this->pageMock->expects($this->any()) + ->method('getId') + ->willReturn($internalPageId); + $this->storeManagerMock->expects($this->any()) + ->method('getStore') + ->willReturn($this->storeMock); + $this->storeMock->expects($this->any()) + ->method('getId') + ->willReturn($storeId); + $this->pageMock->expects($this->any()) + ->method('setStoreId') + ->with($storeId) + ->willReturnSelf(); + $this->pageMock->expects($this->any()) + ->method('load') + ->with($pageId) + ->willReturn($pageLoadResultCollection[$pageLoadResultIndex]); + $this->pageMock->expects($this->any()) + ->method('getIdentifier') + ->willReturn($pageIdentifier); + $this->urlBuilderMock->expects($this->any()) + ->method('getUrl') + ->with(null, ['_direct' => $pageIdentifier]) + ->willReturn($url); + + $this->assertEquals($expectedResult, $this->this->getPageUrl($pageId)); + } + + public function getPageUrlDataProvider() + { + return [ + 'ids NOT EQUAL BUT page->load() NOT SUCCESSFUL' => [ + 'pageId' => 123, + 'internalPageId' => 234, + 'pageLoadResultIndex' => 0, + 'expectedResult' => null + ], + 'page->load() IS SUCCESSFUL BUT internalId IS EMPTY' => [ + 'pageId' => 123, + 'internalPageId' => null, + 'pageLoadResultIndex' => 1, + 'expectedResult' => null + ], + 'SUCCESS' => [ + 'pageId' => 123, + 'internalPageId' => 234, + 'pageLoadResultIndex' => 1, + 'expectedResult' => '/some/url' + ] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Model/Config/Source/PageTest.php b/dev/tests/unit/testsuite/Magento/Cms/Model/Config/Source/PageTest.php new file mode 100644 index 00000000000..60b841eb6d4 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Model/Config/Source/PageTest.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\Cms\Model\Config\Source; + +/** + * @covers \Magento\Cms\Model\Config\Source\Page + */ +class PageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Model\Config\Source\Page + */ + protected $this; + + /** + * @var \Magento\Cms\Model\Resource\Page\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $pageCollectionFactory; + + /** + * @var \Magento\Cms\Model\Resource\Page\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $pageCollection; + + protected function setUp() + { + $this->pageCollectionFactory = $this + ->getMockBuilder('Magento\Cms\Model\Resource\Page\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods( + [ + 'create' + ] + ) + ->getMock(); + $this->pageCollection = $this + ->getMockBuilder('Magento\Cms\Model\Resource\Page\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->this = $objectManager->getObject( + 'Magento\Cms\Model\Config\Source\Page', + [ + 'pageCollectionFactory' => $this->pageCollectionFactory + ] + ); + + $reflection = new \ReflectionClass($this->this); + $mathRandomProperty = $reflection->getProperty('_options'); + $mathRandomProperty->setAccessible(true); + $mathRandomProperty->setValue($this->this, null); + } + + /** + * @covers \Magento\Cms\Model\Config\Source\Page::toOptionArray + */ + public function testToOptionArray() + { + $resultOptions = ['val1' => 'val2']; + + $this->pageCollectionFactory + ->expects($this->atLeastOnce()) + ->method('create') + ->willReturn($this->pageCollection); + $this->pageCollection + ->expects($this->atLeastOnce()) + ->method('load') + ->willReturnSelf(); + $this->pageCollection + ->expects($this->atLeastOnce()) + ->method('toOptionIdArray') + ->willReturn($resultOptions); + + $this->assertEquals($resultOptions, $this->this->toOptionArray()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Cms/Model/ObserverTest.php new file mode 100644 index 00000000000..00ee0630c11 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Model/ObserverTest.php @@ -0,0 +1,207 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Cms\Model; + +/** + * @covers \Magento\Cms\Model\Observer + */ +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Model\Observer + */ + protected $this; + + /** + * @var \Magento\Cms\Helper\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cmsPageMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $observerMock; + + /** + * @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventMock; + + /** + * @var \Magento\Framework\Object|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectMock; + + protected function setUp() + { + $this->cmsPageMock = $this + ->getMockBuilder('Magento\Cms\Helper\Page') + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfigMock = $this + ->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->observerMock = $this + ->getMockBuilder('Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->getMock(); + $this->eventMock = $this + ->getMockBuilder('Magento\Framework\Event') + ->setMethods( + [ + 'getStatus', + 'getRedirect' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + $this->objectMock = $this + ->getMockBuilder('Magento\Framework\Object') + ->setMethods( + [ + 'setLoaded', + 'setForwardModule', + 'setForwardController', + 'setForwardAction', + 'setRedirectUrl', + 'setRedirect', + 'setPath', + 'setArguments' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->this = $objectManager->getObject( + 'Magento\Cms\Model\Observer', + [ + 'cmsPage' => $this->cmsPageMock, + 'scopeConfig' => $this->scopeConfigMock + ] + ); + } + + /** + * @covers \Magento\Cms\Model\Observer::noRoute + */ + public function testNoRoute() + { + $this->observerMock + ->expects($this->atLeastOnce()) + ->method('getEvent') + ->willReturn($this->eventMock); + $this->eventMock + ->expects($this->atLeastOnce()) + ->method('getStatus') + ->willReturn($this->objectMock); + $this->objectMock + ->expects($this->atLeastOnce()) + ->method('setLoaded') + ->with(true) + ->willReturnSelf(); + $this->objectMock + ->expects($this->atLeastOnce()) + ->method('setForwardModule') + ->with('cms') + ->willReturnSelf(); + $this->objectMock + ->expects($this->atLeastOnce()) + ->method('setForwardController') + ->with('index') + ->willReturnSelf(); + $this->objectMock + ->expects($this->atLeastOnce()) + ->method('setForwardAction') + ->with('noroute') + ->willReturnSelf(); + + $this->assertEquals($this->this, $this->this->noRoute($this->observerMock)); + } + + /** + * @covers \Magento\Cms\Model\Observer::noCookies + * @param string $pageUrl + * @dataProvider noCookiesDataProvider + */ + public function testNoCookies($pageUrl) + { + $pageId = 1; + + $this->observerMock + ->expects($this->atLeastOnce()) + ->method('getEvent') + ->willReturn($this->eventMock); + $this->eventMock + ->expects($this->atLeastOnce()) + ->method('getRedirect') + ->willReturn($this->objectMock); + $this->scopeConfigMock + ->expects($this->atLeastOnce()) + ->method('getValue') + ->with('web/default/cms_no_cookies', 'store') + ->willReturn($pageId); + $this->cmsPageMock + ->expects($this->atLeastOnce()) + ->method('getPageUrl') + ->with($pageId) + ->willReturn($pageUrl); + $this->objectMock + ->expects($this->any()) + ->method('setRedirectUrl') + ->with($pageUrl) + ->willReturnSelf(); + $this->objectMock + ->expects($this->any()) + ->method('setRedirect') + ->with(true) + ->willReturnSelf(); + $this->objectMock + ->expects($this->any()) + ->method('setPath') + ->with('cms/index/noCookies') + ->willReturnSelf(); + $this->objectMock + ->expects($this->any()) + ->method('setArguments') + ->with([]) + ->willReturnSelf(); + + $this->assertEquals($this->this, $this->this->noCookies($this->observerMock)); + } + + public function noCookiesDataProvider() + { + return [ + 'url IS empty' => ['pageUrl' => ''], + 'url NOT empty' => ['pageUrl' => '/some/url'] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Model/PageTest.php b/dev/tests/unit/testsuite/Magento/Cms/Model/PageTest.php new file mode 100644 index 00000000000..a7ed38aa7fa --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Model/PageTest.php @@ -0,0 +1,135 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Cms\Model; + +/** + * @covers \Magento\Cms\Model\Page + */ +class PageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Model\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $thisMock; + + /** + * @var \Magento\Backend\Block\Template\Context + */ + protected $context; + + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \Magento\Cms\Model\Resource\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourcePageMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->context = $objectManager->getObject( + 'Magento\Framework\Model\Context', + [ + 'eventDispatcher' => $this->eventManagerMock + ] + ); + $this->resourcePageMock = $this->getMockBuilder('Magento\Cms\Model\Resource\Page') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getIdFieldName', + 'checkIdentifier' + ] + ) + ->getMock(); + $this->thisMock = $this->getMockBuilder('Magento\Cms\Model\Page') + ->setConstructorArgs( + [ + $this->context, + $this->getMockBuilder('Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('Magento\Framework\Model\Resource\AbstractResource') + ->disableOriginalConstructor() + ->setMethods( + [ + '_construct', + '_getReadAdapter', + '_getWriteAdapter' + ] + ) + ->getMock(), + $this->getMockBuilder('Magento\Framework\Data\Collection\Db') + ->disableOriginalConstructor() + ->getMock() + ] + ) + ->setMethods( + [ + '_construct', + '_getResource', + 'load' + ] + ) + ->getMock(); + + $this->thisMock->expects($this->any()) + ->method('_getResource') + ->willReturn($this->resourcePageMock); + $this->thisMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); + } + + /** + * @covers \Magento\Cms\Model\Page::noRoutePage + */ + public function testNoRoutePage() + { + $this->assertEquals($this->thisMock, $this->thisMock->noRoutePage()); + } + + /** + * @covers \Magento\Cms\Model\Page::checkIdentifier + */ + public function testCheckIdentifier() + { + $identifier = 1; + $storeId = 2; + $fetchOneResult = 'some result'; + + $this->resourcePageMock->expects($this->atLeastOnce()) + ->method('checkIdentifier') + ->with($identifier, $storeId) + ->willReturn($fetchOneResult); + + $this->assertInternalType('string', $this->thisMock->checkIdentifier($identifier, $storeId)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php new file mode 100644 index 00000000000..e790c58ede6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php @@ -0,0 +1,251 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Cms\Model\Wysiwyg; + +/** + * @covers \Magento\Cms\Model\Wysiwyg\Config + */ +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Model\Wysiwyg\Config + */ + protected $this; + + /** + * @var \Magento\Backend\Model\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $backendUrlMock; + + /** + * @var \Magento\Framework\View\Asset\Repository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $assetRepoMock; + + /** + * @var \Magento\Framework\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $authorizationMock; + + /** + * @var \Magento\Core\Model\Variable\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $variableConfigMock; + + /** + * @var \Magento\Widget\Model\Widget\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $widgetConfigMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var array + */ + protected $windowSize = []; + + protected function setUp() + { + $this->backendUrlMock = $this->getMockBuilder('Magento\Backend\Model\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->assetRepoMock = $this->getMockBuilder('Magento\Framework\View\Asset\Repository') + ->disableOriginalConstructor() + ->getMock(); + $this->authorizationMock = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->variableConfigMock = $this->getMockBuilder('Magento\Core\Model\Variable\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->widgetConfigMock = $this->getMockBuilder('Magento\Widget\Model\Widget\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->windowSize = [ + 'width' => 1200, + 'height' => 800 + ]; + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->this = $objectManager->getObject( + 'Magento\Cms\Model\Wysiwyg\Config', + [ + 'backendUrl' => $this->backendUrlMock, + 'assetRepo' => $this->assetRepoMock, + 'authorization' => $this->authorizationMock, + 'variableConfig' => $this->variableConfigMock, + 'widgetConfig' => $this->widgetConfigMock, + 'scopeConfig' => $this->scopeConfigMock, + 'windowSize' => $this->windowSize + ] + ); + } + + /** + * @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig + * @param array $data + * @param boolean $isAuthorizationAllowed + * @param array $expectedResults + * + * @dataProvider getConfigDataProvider + */ + public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults) + { + $wysiwygPluginSettings = [ + 'wysiwygPluginSettings' => 'wysiwyg is here' + ]; + + $pluginSettings = [ + 'pluginSettings' => 'plugins are here' + ]; + + $this->backendUrlMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->withConsecutive( + ['cms/wysiwyg/directive'], + ['cms/wysiwyg_images/index'] + ); + $this->assetRepoMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->withConsecutive( + ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], + ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'] + ); + $this->authorizationMock->expects($this->atLeastOnce()) + ->method('isAllowed') + ->with('Magento_Cms::media_gallery') + ->willReturn($isAuthorizationAllowed); + $this->variableConfigMock->expects($this->any()) + ->method('getWysiwygPluginSettings') + ->willReturn($wysiwygPluginSettings); + $this->widgetConfigMock->expects($this->any()) + ->method('getPluginSettings') + ->willReturn($pluginSettings); + + $config = $this->this->getConfig($data); + $this->assertInstanceOf('Magento\Framework\Object', $config); + $this->assertEquals($expectedResults[0], $config->getData('someData')); + $this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings')); + $this->assertEquals($expectedResults[2], $config->getData('pluginSettings')); + } + + public function getConfigDataProvider() + { + return [ + 'add_variables IS FALSE, add_widgets IS FALSE, isAuthorizationAllowed IS FALSE' => [ + 'data' => [ + 'add_variables' => false, + 'add_widgets' => false + ], + 'isAuthorizationAllowed' => false, + 'expectedResults' => [null, null, null] + ], + 'add_variables IS TRUE, add_widgets IS TRUE, isAuthorizationAllowed IS TRUE' => [ + 'data' => [ + 'someData' => 'important data', + 'add_variables' => true, + 'add_widgets' => true + ], + 'isAuthorizationAllowed' => true, + 'expectedResults' => ['important data', 'wysiwyg is here', 'plugins are here'] + ] + ]; + } + + /** + * @covers \Magento\Cms\Model\Wysiwyg\Config::getSkinImagePlaceholderUrl + */ + public function testGetSkinImagePlaceholderUrl() + { + $url = '/some/url'; + + $this->assetRepoMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->with('Magento_Cms::images/wysiwyg_skin_image.png') + ->willReturn($url); + + $this->assertEquals($url, $this->this->getSkinImagePlaceholderUrl()); + } + + /** + * @covers \Magento\Cms\Model\Wysiwyg\Config::isEnabled + * @param string $wysiwygState + * @param boolean $expectedResult + * + * @dataProvider isEnabledDataProvider + */ + public function testIsEnabled($wysiwygState, $expectedResult) + { + $storeId = 1; + $this->this->setStoreId($storeId); + + $this->scopeConfigMock->expects($this->atLeastOnce()) + ->method('getValue') + ->with('cms/wysiwyg/enabled', 'store', $storeId) + ->willReturn($wysiwygState); + + $this->assertEquals($expectedResult, $this->this->isEnabled()); + } + + public function isEnabledDataProvider() + { + return [ + ['wysiwygState' => 'enabled', 'expectedResult' => true], + ['wysiwygState' => 'hidden', 'expectedResult' => true], + ['wysiwygState' => 'masked', 'expectedResult' => false] + ]; + } + + /** + * @covers \Magento\Cms\Model\Wysiwyg\Config::isHidden + * @param string $status + * @param boolean $expectedResult + * + * @dataProvider isHiddenDataProvider + */ + public function testIsHidden($status, $expectedResult) + { + $this->scopeConfigMock->expects($this->atLeastOnce()) + ->method('getValue') + ->with('cms/wysiwyg/enabled', 'store') + ->willReturn($status); + + $this->assertEquals($expectedResult, $this->this->isHidden()); + } + + public function isHiddenDataProvider() + { + return [ + ['status' => 'hidden', 'expectedResult' => true], + ['status' => 'enabled', 'expectedResult' => false], + ['status' => 'masked', 'expectedResult' => false] + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php index d8904af20d8..4c2a71c03e4 100644 --- a/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Contact/Helper/DataTest.php @@ -96,7 +96,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $objectBuilder = $this->getMockForAbstractClass( - '\Magento\Framework\Api\AbstractSimpleObjectBuilder', + '\Magento\Framework\Api\ExtensibleObjectBuilder', ['getData'], '', false diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php index 9fee2ea16f2..ddbffcc5204 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php @@ -28,7 +28,7 @@ namespace Magento\Customer\Model; use Magento\Customer\Service\V1\Data\Eav\AttributeMetadata; use Magento\Customer\Service\V1\Data\CustomerBuilder; use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; class ConverterTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/PasswordTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/PasswordTest.php index 05880064c98..919e1a00a71 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/PasswordTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Customer/Attribute/Backend/PasswordTest.php @@ -35,10 +35,8 @@ class PasswordTest extends \PHPUnit_Framework_TestCase public function setUp() { - $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); $string = new String(); - /** @var \Magento\Framework\Logger $logger */ - $this->testable = new Password($logger, $string); + $this->testable = new Password($string); } public function testValidatePositive() 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 11cfa14ff07..41fa4c9a13f 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 @@ -38,12 +38,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function setUp() { - $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); - /** @var \Magento\Framework\Logger $logger */ $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); /** @var \Magento\Framework\StoreManagerInterface $storeManager */ - $this->testable = new Store($logger, $storeManager); + $this->testable = new Store($storeManager); } public function testBeforeSaveWithId() 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 7247b735f50..efad936ac75 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 @@ -38,12 +38,10 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase public function setUp() { - $logger = $this->getMockBuilder('Magento\Framework\Logger')->disableOriginalConstructor()->getMock(); - /** @var \Magento\Framework\Logger $logger */ $storeManager = $this->storeManager = $this->getMockBuilder('Magento\Framework\StoreManagerInterface') ->getMock(); /** @var \Magento\Framework\StoreManagerInterface $storeManager */ - $this->testable = new Website($logger, $storeManager); + $this->testable = new Website($storeManager); } public function testBeforeSaveWithId() 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 826708a45bf..649237cc942 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php @@ -116,7 +116,7 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase ); $this->moduleManagerMock = $this->getMock('Magento\Framework\Module\Manager', array(), array(), '', false); $this->visitorMock = $this->getMock('Magento\Customer\Model\Visitor', array(), array(), '', false); - $this->customerFactoryMock->expects($this->once()) + $this->customerFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->customerMock)); $this->cacheConfigMock = $this->getMock('Magento\PageCache\Model\Config', array(), array(), '', false); @@ -274,7 +274,8 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase $this->customerMock ->expects($this->once()) ->method('setGroupId') - ->with($this->equalTo(null)); + ->with($this->equalTo(null)) + ->willReturnSelf(); $this->sessionMock ->expects($this->once()) ->method('setData') 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 37555bc3c3d..1879111bbed 100755 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -30,7 +30,7 @@ use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\Data\CustomerBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\FilterBuilder; use Magento\Framework\Mail\Exception as MailException; use Magento\Framework\Api\ExtensibleDataObjectConverter; 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 1b37a67682c..a698d471b5e 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php @@ -27,7 +27,7 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\Data\RegionBuilder; use Magento\Customer\Service\V1\Data\CustomerBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; /** * \Magento\Customer\Service\V1\CustomerAddressService diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressConverterTest.php index 9660223cb5c..7be2d3ddb89 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressConverterTest.php @@ -127,7 +127,7 @@ class AddressConverterTest extends \PHPUnit_Framework_TestCase ); $addressData = $this->_sampleAddressDataObject(); - $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeValueBuilder'); + $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); /** @var \Magento\Customer\Service\V1\Data\AddressBuilder $addressDataBuilder */ $addressDataBuilder = $this->_objectManager->getObject( 'Magento\Customer\Service\V1\Data\AddressBuilder', @@ -137,7 +137,8 @@ class AddressConverterTest extends \PHPUnit_Framework_TestCase 'metadataService' => $this->addressMetadataService ] ); - $addressData = $addressDataBuilder->mergeDataObjectWithArray($addressData, $updatedAddressData); + $addressData = $addressDataBuilder->mergeDataObjectWithArray($addressData, $updatedAddressData) + ->create(); $result = AddressConverter::toFlatArray($addressData); $this->assertEquals($expected, $result); @@ -150,7 +151,7 @@ class AddressConverterTest extends \PHPUnit_Framework_TestCase { $regionBuilder = $this->_objectManager->getObject('\Magento\Customer\Service\V1\Data\RegionBuilder') ->setRegion('Texas')->setRegionId(1)->setRegionCode('TX'); - $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeValueBuilder'); + $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); /** @var \Magento\Customer\Service\V1\Data\AddressBuilder $addressData */ $addressData = $this->_objectManager->getObject( 'Magento\Customer\Service\V1\Data\AddressBuilder', diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressTest.php index 5c075fdff02..6128c7e4ab5 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/AddressTest.php @@ -27,7 +27,7 @@ use Magento\Customer\Service\V1\Data\Address; use Magento\Customer\Service\V1\Data\AddressBuilder; use Magento\Customer\Service\V1\Data\RegionBuilder; use Magento\Framework\Api\AttributeValue; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\AttributeDataBuilder; class AddressTest extends \PHPUnit_Framework_TestCase { @@ -94,7 +94,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Service\V1\CustomerMetadataService */ private $_customerMetadataService; - /** @var \Magento\Framework\Api\AttributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder */ private $_valueBuilder; /** @@ -125,7 +125,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase ) ); $this->_valueBuilder = $this->objectManagerHelper - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $this->_addressBuilder = $this->objectManagerHelper->getObject( 'Magento\Customer\Service\V1\Data\AddressBuilder', [ @@ -313,10 +313,12 @@ class AddressTest extends \PHPUnit_Framework_TestCase ]; $attributeValue1 = $this->_valueBuilder - ->populateWithArray($customerAttributes['warehouse_zip']) + ->setValue('78777') + ->setAttributeCode('warehouse_zip') ->create(); $attributeValue2 = $this->_valueBuilder - ->populateWithArray($customerAttributes['warehouse_alternate']) + ->setValue('90051') + ->setAttributeCode('warehouse_alternate') ->create(); $address = $this->_addressBuilder diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerBuilderTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerBuilderTest.php index e987df4569d..8d7774cb6be 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerBuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerBuilderTest.php @@ -39,7 +39,7 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Service\V1\AddressMetadataService */ private $_addressMetadataService; - /** @var \Magento\Framework\Api\AttributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder */ private $_valueBuilder; protected function setUp() @@ -81,7 +81,7 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase ) ); $this->_valueBuilder = $this->_objectManager->getObject( - 'Magento\Framework\Api\AttributeValueBuilder' + 'Magento\Framework\Api\AttributeDataBuilder' ); $this->_customerBuilder = $this->_objectManager->getObject( 'Magento\Customer\Service\V1\Data\CustomerBuilder', @@ -110,7 +110,8 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase $middlename2 = 'Middlename2'; $secondDataObject = $this->_customerBuilder->setLastname($lastname2)->setMiddlename($middlename2)->create(); - $mergedDataObject = $this->_customerBuilder->mergeDataObjects($firstDataObject, $secondDataObject); + $mergedDataObject = $this->_customerBuilder->mergeDataObjects($firstDataObject, $secondDataObject) + ->create(); $this->assertNotSame( $firstDataObject, $mergedDataObject, @@ -147,11 +148,13 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase $email1 )->create(); + $lastname2 = 'Lastname2'; $middlename2 = 'Middlename2'; $dataForMerge = array('lastname' => $lastname2, 'middlename' => $middlename2); - $mergedDataObject = $this->_customerBuilder->mergeDataObjectWithArray($firstDataObject, $dataForMerge); + $mergedDataObject = $this->_customerBuilder->mergeDataObjectWithArray($firstDataObject, $dataForMerge) + ->create(); $this->assertNotSame( $firstDataObject, $mergedDataObject, @@ -286,10 +289,12 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase ]; $attributeValue1 = $this->_valueBuilder - ->populateWithArray($customerAttributes['warehouse_zip']) + ->setValue('78777') + ->setAttributeCode('warehouse_zip') ->create(); $attributeValue2 = $this->_valueBuilder - ->populateWithArray($customerAttributes['warehouse_alternate']) + ->setValue('90051') + ->setAttributeCode('warehouse_alternate') ->create(); $address = $this->_customerBuilder->setCustomAttributes([$attributeValue1, $attributeValue2]) @@ -362,7 +367,7 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase ] ] ] - ); + )->create(); $expectedData = array( 'email' => 'test@example.com', @@ -438,7 +443,8 @@ class CustomerBuilderTest extends \PHPUnit_Framework_TestCase ); $customer1 = $this->_customerBuilder->populateWithArray($customer1Data)->create(); $customer2 = $this->_customerBuilder->populateWithArray($customer2Data)->create(); - $customer3 = $this->_customerBuilder->mergeDataObjects($customer1, $customer2); + $customer3 = $this->_customerBuilder->mergeDataObjects($customer1, $customer2) + ->create(); $this->assertEquals('78666', $customer3->getCustomAttribute('warehouse_zip')->getValue()); $this->assertEquals('90051', $customer3->getCustomAttribute('warehouse_alternate')->getValue()); foreach ($customer3->getCustomAttributes() as $customAttribute) { diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerTest.php index 91bab28761a..a19e6ce5831 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Data/CustomerTest.php @@ -95,7 +95,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase new \Magento\Framework\Object(['attribute_code' => 'locale']) ]) ); - $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeValueBuilder'); + $valueBuilder = $this->_objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); $this->_customerBuilder = $this->_objectManager->getObject( 'Magento\Customer\Service\V1\Data\CustomerBuilder', [ diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Model/ObserverTest.php new file mode 100644 index 00000000000..258d9187293 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Model/ObserverTest.php @@ -0,0 +1,288 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Downloadable\Model; + +use Magento\Downloadable\Model\Observer; +use Magento\Downloadable\Model\Product\Type; +use Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory; +use Magento\Store\Model\ScopeInterface; +use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper; + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** @var Observer */ + private $observer; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Helper\Data + */ + private $coreData; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Config + */ + private $scopeConfig; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Downloadable\Model\Link\PurchasedFactory + */ + private $purchasedFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Catalog\Model\ProductFactory + */ + private $productFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Downloadable\Model\Link\Purchased\ItemFactory + */ + private $itemFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Checkout\Model\Session + */ + private $checkoutSession; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | CollectionFactory + */ + private $itemsFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Object\Copy + */ + private $objectCopyService; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Object + */ + private $resultMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Object + */ + private $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Event + */ + private $eventMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Event\Observer + */ + private $observerMock; + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + */ + public function setUp() + { + $this->coreData = $this->getMockBuilder('\Magento\Core\Helper\Data') + ->disableOriginalConstructor() + ->getMock(); + + $this->scopeConfig = $this->getMockBuilder('\Magento\Framework\App\Config') + ->disableOriginalConstructor() + ->setMethods(['isSetFlag']) + ->getMock(); + + $this->purchasedFactory = $this->getMockBuilder('\Magento\Downloadable\Model\Link\PurchasedFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->productFactory = $this->getMockBuilder('\Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->itemFactory = $this->getMockBuilder('\Magento\Downloadable\Model\Link\Purchased\ItemFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->checkoutSession = $this->getMockBuilder('\Magento\Checkout\Model\Session') + ->disableOriginalConstructor() + ->getMock(); + + $this->itemsFactory = $this->getMockBuilder( + '\Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory' + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->objectCopyService = $this->getMockBuilder('\Magento\Framework\Object\Copy') + ->disableOriginalConstructor() + ->getMock(); + + $this->resultMock = $this->getMockBuilder('\Magento\Framework\Object') + ->disableOriginalConstructor() + ->setMethods(['setIsAllowed']) + ->getMock(); + + $this->storeMock = $this->getMockBuilder('\Magento\Framework\Object') + ->disableOriginalConstructor() + ->getMock(); + + $this->eventMock = $this->getMockBuilder('\Magento\Framework\Event') + ->disableOriginalConstructor() + ->setMethods(['getStore', 'getResult', 'getQuote']) + ->getMock(); + + $this->observerMock = $this->getMockBuilder('\Magento\Framework\Event\Observer') + ->disableOriginalConstructor() + ->setMethods(['getEvent']) + ->getMock(); + + $this->observer = (new ObjectManagerHelper($this))->getObject( + '\Magento\Downloadable\Model\Observer', + array( + 'coreData' => $this->coreData, + 'scopeConfig' => $this->scopeConfig, + 'purchasedFactory' => $this->purchasedFactory, + 'productFactory' => $this->productFactory, + 'itemFactory' => $this->itemFactory, + 'checkoutSession' => $this->checkoutSession, + 'itemsFactory' => $this->itemsFactory, + 'objectCopyService' => $this->objectCopyService + ) + ); + } + + /** + * + * @dataProvider dataProviderForTestisAllowedGuestCheckoutConfigSetToTrue + * + * @param $productType + * @param $isAllowed + */ + public function testIsAllowedGuestCheckoutConfigSetToTrue($productType, $isAllowed) + { + $this->resultMock->expects($this->at(0)) + ->method('setIsAllowed') + ->with(true); + + if ($isAllowed) { + $this->resultMock->expects($this->at(1)) + ->method('setIsAllowed') + ->with(false); + } + + $product = $this->getMockBuilder('\Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->setMethods(['getTypeId']) + ->getMock(); + + $product->expects($this->once()) + ->method('getTypeId') + ->willReturn($productType); + + $item = $this->getMockBuilder('\Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['getProduct']) + ->getMock(); + + $item->expects($this->once()) + ->method('getProduct') + ->willReturn($product); + + $quote = $this->getMockBuilder('\Magento\Sales\Model\Quote') + ->disableOriginalConstructor() + ->setMethods(['getAllItems']) + ->getMock(); + + $quote->expects($this->once()) + ->method('getAllItems') + ->willReturn([$item]); + + $this->eventMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->eventMock->expects($this->once()) + ->method('getResult') + ->will($this->returnValue($this->resultMock)); + + $this->eventMock->expects($this->once()) + ->method('getQuote') + ->will($this->returnValue($quote)); + + $this->scopeConfig->expects($this->exactly(1)) + ->method('isSetFlag') + ->with(Observer::XML_PATH_DISABLE_GUEST_CHECKOUT, ScopeInterface::SCOPE_STORE, $this->storeMock) + ->willReturn(true); + + $this->observerMock->expects($this->exactly(3)) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + + $this->assertInstanceOf( + '\Magento\Downloadable\Model\Observer', + $this->observer->isAllowedGuestCheckout($this->observerMock) + ); + } + + /** + * @return array + */ + public function dataProviderForTestisAllowedGuestCheckoutConfigSetToTrue() + { + return [ + 1 => [Type::TYPE_DOWNLOADABLE, true], + 2 => ['unknown', false], + ]; + } + + /** + * + */ + public function testIsAllowedGuestCheckoutConfigSetToFalse() + { + $this->resultMock->expects($this->once()) + ->method('setIsAllowed') + ->with(true); + + $this->eventMock->expects($this->once()) + ->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->eventMock->expects($this->once()) + ->method('getResult') + ->will($this->returnValue($this->resultMock)); + + $this->scopeConfig->expects($this->exactly(1)) + ->method('isSetFlag') + ->with(Observer::XML_PATH_DISABLE_GUEST_CHECKOUT, ScopeInterface::SCOPE_STORE, $this->storeMock) + ->willReturn(false); + + $this->observerMock->expects($this->exactly(2)) + ->method('getEvent') + ->will($this->returnValue($this->eventMock)); + + $this->assertInstanceOf( + '\Magento\Downloadable\Model\Observer', + $this->observer->isAllowedGuestCheckout($this->observerMock) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php index c815194b56b..f25d75da2a9 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php @@ -112,12 +112,10 @@ class AbstractTest extends \PHPUnit_Framework_TestCase ); $mock->setAttributeId($code); - $logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); /** @var $backendModel \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ $backendModel = $this->getMock( 'Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', - array('getBackend', 'getBackendTable'), - array($logger) + array('getBackend', 'getBackendTable') ); $backendModel->setAttribute($mock); @@ -249,7 +247,6 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $attribute = $this->_getAttributeMock($attributeCode, $attributeSetId); - $logger = $this->getMock('Magento\Framework\Logger', array(), array(), '', false); /** @var $backendModel \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ $backendModel = $this->getMock( 'Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', @@ -260,8 +257,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase 'isStatic', 'getEntityValueId', 'getEntityIdField' - ), - array($logger) + ) ); $backendModel->expects( diff --git a/dev/tests/unit/testsuite/Magento/Eav/Plugin/Model/Resource/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Plugin/Model/Resource/Entity/AttributeTest.php new file mode 100644 index 00000000000..30b8cbb836f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Eav/Plugin/Model/Resource/Entity/AttributeTest.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\Eav\Plugin\Model\Resource\Entity; + +use Magento\TestFramework\Helper\ObjectManager; + +class AttributeTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $cache; + + /** @var \Magento\Framework\App\Cache\StateInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $cacheState; + + /** @var \Magento\Eav\Model\Resource\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject */ + protected $subject; + + protected function setUp() + { + $this->cache = $this->getMock('Magento\Framework\App\CacheInterface'); + $this->cacheState = $this->getMock('Magento\Framework\App\Cache\StateInterface'); + $this->subject = $this->getMock('Magento\Eav\Model\Resource\Entity\Attribute', [], [], '', false); + } + + public function testGetStoreLabelsByAttributeIdOnCacheDisabled() + { + $this->cache->expects($this->never())->method('load'); + + $this->assertEquals( + 'attributeId', + $this->getAttribute(false)->aroundGetStoreLabelsByAttributeId( + $this->subject, + $this->mockPluginProceed('attributeId'), + 'attributeId' + ) + ); + } + + public function testGetStoreLabelsByAttributeIdFromCache() + { + $attributeId = 1; + $attributes = ['k' => 'v']; + $cacheId = \Magento\Eav\Plugin\Model\Resource\Entity\Attribute::STORE_LABEL_ATTRIBUTE . $attributeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(serialize($attributes)); + + $this->assertEquals( + $attributes, + $this->getAttribute(true)->aroundGetStoreLabelsByAttributeId( + $this->subject, + $this->mockPluginProceed(), + $attributeId + ) + ); + } + + public function testGetStoreLabelsByAttributeIdWithCacheSave() + { + $attributeId = 1; + $cacheId = \Magento\Eav\Plugin\Model\Resource\Entity\Attribute::STORE_LABEL_ATTRIBUTE . $attributeId; + $this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(false); + $this->cache->expects($this->any())->method('save')->with( + serialize([$attributeId]), + $cacheId, + [ + \Magento\Eav\Model\Cache\Type::CACHE_TAG, + \Magento\Eav\Model\Entity\Attribute::CACHE_TAG + ] + ); + + $this->assertEquals( + [$attributeId], + $this->getAttribute(true)->aroundGetStoreLabelsByAttributeId( + $this->subject, + $this->mockPluginProceed([$attributeId]), + $attributeId + ) + ); + } + + /** + * @param bool $cacheEnabledFlag + * @return \Magento\Eav\Plugin\Model\Resource\Entity\Attribute + */ + protected function getAttribute($cacheEnabledFlag) + { + $this->cacheState->expects($this->any())->method('isEnabled') + ->with(\Magento\Eav\Model\Cache\Type::TYPE_IDENTIFIER)->willReturn($cacheEnabledFlag); + return (new ObjectManager($this))->getObject( + 'Magento\Eav\Plugin\Model\Resource\Entity\Attribute', + [ + 'cache' => $this->cache, + 'cacheState' => $this->cacheState + ] + ); + } + + /** + * @param mixed $returnValue + * @return callable + */ + protected function mockPluginProceed($returnValue = null) + { + return function () use ($returnValue) { + return $returnValue; + }; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/BuilderTest.php deleted file mode 100644 index 2d4ccee5d96..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/BuilderTest.php +++ /dev/null @@ -1,156 +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\Api\Code\Generator; - -use Magento\Framework\Code\Generator\Io; -use Magento\TestFramework\Helper\ObjectManager; - -/** - * Class BuilderTest - */ -class BuilderTest extends \PHPUnit_Framework_TestCase -{ - const SOURCE_CLASS_NAME = 'Magento\Framework\Api\Code\Generator\Sample'; - const RESULT_CLASS_NAME = 'Magento\Framework\Api\Code\Generator\SampleBuilder'; - const GENERATOR_CLASS_NAME = 'Magento\Framework\Api\Code\Generator\Builder'; - const OUTPUT_FILE_NAME = 'SampleBuilder.php'; - /** - * @var Io | \PHPUnit_Framework_MockObject_MockObject - */ - protected $ioObjectMock; - - /** - * @var \Magento\Framework\Code\Generator\EntityAbstract - */ - protected $generator; - - /** - * @var \Magento\Framework\Code\Generator\FileResolver | \PHPUnit_Framework_MockObject_MockObject - */ - protected $fileResolverMock; - - /** - * @var \Magento\Framework\Code\Generator\CodeGenerator\Zend | \PHPUnit_Framework_MockObject_MockObject - */ - protected $classGenerator; - - protected function setUp() - { - require_once __DIR__ . '/_files/Sample.php'; - $this->ioObjectMock = $this->getMock( - 'Magento\Framework\Code\Generator\Io', - [], - [], - '', - false - ); - $this->fileResolverMock = $this->getMock( - 'Magento\Framework\Code\Generator\FileResolver', - [], - [], - '', - false - ); - $this->classGenerator = $this->getMock( - 'Magento\Framework\Code\Generator\CodeGenerator\Zend', - [], - [], - '', - false - ); - - $objectManager = new ObjectManager($this); - $this->generator = $objectManager->getObject( - self::GENERATOR_CLASS_NAME, - [ - 'sourceClassName' => self::SOURCE_CLASS_NAME, - 'resultClassName' => self::RESULT_CLASS_NAME, - 'ioObject' => $this->ioObjectMock, - 'classGenerator' => $this->classGenerator, - 'fileResolver' => $this->fileResolverMock - ] - ); - } - - /** - * generate repository name - */ - public function testGenerate() - { - $generatedCode = 'Generated code'; - $sourceFileName = 'Sample.php'; - $resultFileName = self::OUTPUT_FILE_NAME; - - //Mocking _validateData call - $this->fileResolverMock->expects($this->at(0)) - ->method('getFile') - ->with(self::SOURCE_CLASS_NAME) - ->will($this->returnValue($sourceFileName)); - $this->fileResolverMock->expects($this->at(1)) - ->method('getFile') - ->with(self::RESULT_CLASS_NAME) - ->will($this->returnValue(false)); - - $this->ioObjectMock->expects($this->once()) - ->method('makeGenerationDirectory') - ->will($this->returnValue(true)); - $this->ioObjectMock->expects($this->once()) - ->method('makeResultFileDirectory') - ->with(self::RESULT_CLASS_NAME) - ->will($this->returnValue(true)); - $this->ioObjectMock->expects($this->once()) - ->method('fileExists') - ->with($resultFileName) - ->will($this->returnValue(false)); - - //Mocking _generateCode call - $this->classGenerator->expects($this->once()) - ->method('setName') - ->with(self::RESULT_CLASS_NAME) - ->will($this->returnSelf()); - $this->classGenerator->expects($this->once()) - ->method('addProperties') - ->will($this->returnSelf()); - $this->classGenerator->expects($this->once()) - ->method('addMethods') - ->will($this->returnSelf()); - $this->classGenerator->expects($this->once()) - ->method('setClassDocBlock') - ->will($this->returnSelf()); - $this->classGenerator->expects($this->once()) - ->method('generate') - ->will($this->returnValue($generatedCode)); - - //Mocking generation - $this->ioObjectMock->expects($this->any()) - ->method('getResultFileName') - ->with(self::RESULT_CLASS_NAME) - ->will($this->returnValue($resultFileName)); - $this->ioObjectMock->expects($this->once()) - ->method('writeResultFile') - ->with($resultFileName, $generatedCode); - - $this->assertTrue($this->generator->generate()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php index eeb35b66f7a..2470fc9dbb4 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php @@ -146,8 +146,9 @@ class DataBuilderTest extends \PHPUnit_Framework_TestCase //Verify if the generated code is as expected $this->ioObjectMock->expects($this->once()) ->method('writeResultFile') - ->with($resultFileName, $generatedCode); + ->with($resultFileName, $generatedCode) + ->will($this->returnValue(true)); - $this->assertTrue($this->generator->generate()); + $this->assertTrue($this->generator->generate(), implode("\n", $this->generator->getErrors())); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateBuilderTest.php deleted file mode 100644 index c2f7d9ccea9..00000000000 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateBuilderTest.php +++ /dev/null @@ -1,84 +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\Api\Code\Generator; - -/** - * Class BuilderTest - */ -class GenerateBuilderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $ioObjectMock; - - /** - * Prepare test env - */ - protected function setUp() - { - $this->ioObjectMock = $this->getMock( - '\Magento\Framework\Code\Generator\Io', - [], - [], - '', - false - ); - } - - /** - * generate repository class - */ - public function testGenerate() - { - require_once __DIR__ . '/_files/Sample.php'; - /** @var \Magento\Framework\Api\Code\Generator\Builder $model */ - $model = $this->getMock( - '\Magento\Framework\Api\Code\Generator\Builder', - [ - '_validateData' - ], - [ - '\Magento\Framework\Api\Code\Generator\Sample', - null, - $this->ioObjectMock, - null, - null - ] - ); - $sampleBuilderCode = file_get_contents(__DIR__ . '/_files/SampleBuilder.txt'); - $this->ioObjectMock->expects($this->once()) - ->method('getResultFileName') - ->with('\Magento\Framework\Api\Code\Generator\SampleBuilder') - ->will($this->returnValue('SampleBuilder.php')); - $this->ioObjectMock->expects($this->once()) - ->method('writeResultFile') - ->with('SampleBuilder.php', $sampleBuilderCode); - - $model->expects($this->once()) - ->method('_validateData') - ->will($this->returnValue(true)); - $this->assertTrue($model->generate()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateSearchResultsBuilderTest.php b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateSearchResultsBuilderTest.php index 0a991beb96c..3f9381ad6d8 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateSearchResultsBuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/GenerateSearchResultsBuilderTest.php @@ -55,6 +55,7 @@ class GenerateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase public function testGenerate() { require_once __DIR__ . '/_files/Sample.php'; + /** @var \Magento\Framework\Api\Code\Generator\SearchResultsBuilder $model */ $model = $this->getMock( 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', [ @@ -80,6 +81,6 @@ class GenerateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase $model->expects($this->once()) ->method('_validateData') ->will($this->returnValue(true)); - $this->assertTrue($model->generate()); + $this->assertTrue($model->generate(), implode("\n", $model->getErrors())); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/ExtensibleSampleDataBuilder.txt b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/ExtensibleSampleDataBuilder.txt index 5fd08f8ccfc..829ed168b5d 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/ExtensibleSampleDataBuilder.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/ExtensibleSampleDataBuilder.txt @@ -4,7 +4,7 @@ namespace Magento\Framework\Api\Code\Generator; * DataBuilder class for * \Magento\Framework\Api\Code\Generator\ExtensibleSampleInterface */ -class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\CompositeExtensibleDataBuilder +class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\Builder { /** * @param array $items @@ -12,7 +12,7 @@ class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\CompositeExtens */ public function setItems($items) { - $this->set('items', $items); + $this->_set('items', $items); return $this; } @@ -22,7 +22,7 @@ class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\CompositeExtens */ public function setName($name) { - $this->set('name', $name); + $this->_set('name', $name); return $this; } @@ -32,7 +32,7 @@ class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\CompositeExtens */ public function setCount($count) { - $this->set('count', $count); + $this->_set('count', $count); return $this; } @@ -42,19 +42,24 @@ class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\CompositeExtens */ public function setCreatedAt($createdAt) { - $this->set('created_at', $createdAt); + $this->_set('created_at', $createdAt); return $this; } /** * Initialize the builder * - * @param \Magento\Framework\ObjectManager $objectManager + * @param \Magento\Framework\Api\ObjectFactory $objectFactory * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder + * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor + * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor + * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory * @param \Magento\Framework\ObjectManager\Config $objectManagerConfig + * @param string|null $modelClassInterface */ - public function __construct(\Magento\Framework\ObjectManager $objectManager, \Magento\Framework\Api\MetadataServiceInterface $metadataService, \Magento\Framework\ObjectManager\Config $objectManagerConfig) + public function __construct(\Magento\Framework\Api\ObjectFactory $objectFactory, \Magento\Framework\Api\MetadataServiceInterface $metadataService, \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder, \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, \Magento\Framework\Reflection\TypeProcessor $typeProcessor, \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, \Magento\Framework\ObjectManager\Config $objectManagerConfig, $modelClassInterface = null) { - parent::__construct($objectManager, $metadataService, $objectManagerConfig, 'Magento\Framework\Api\Code\Generator\ExtensibleSampleInterface'); + parent::__construct($objectFactory, $metadataService, $attributeValueBuilder, $objectProcessor, $typeProcessor, $dataBuilderFactory, $objectManagerConfig, 'Magento\Framework\Api\Code\Generator\ExtensibleSampleInterface'); } } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleSearchResultsBuilder.txt b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleSearchResultsBuilder.txt index 4bacbf1bd8f..96578961ade 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleSearchResultsBuilder.txt +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Code/Generator/_files/SampleSearchResultsBuilder.txt @@ -10,7 +10,7 @@ class SampleSearchResultsBuilder extends \Magento\Framework\Api\AbstractSearchRe * * @param */ - public function __construct(\Magento\Framework\Api\ObjectFactory $objectFactory, \Magento\Framework\Api\AttributeValueBuilder $valueBuilder, \Magento\Framework\Api\Config\MetadataConfig $metadataService, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\Code\Generator\SampleBuilder $itemObjectBuilder) + public function __construct(\Magento\Framework\Api\ObjectFactory $objectFactory, \Magento\Framework\Api\AttributeDataBuilder $valueBuilder, \Magento\Framework\Api\Config\MetadataConfig $metadataService, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\Code\Generator\SampleBuilder $itemObjectBuilder) { parent::__construct($objectFactory, $valueBuilder, $metadataService, $searchCriteriaBuilder, $itemObjectBuilder); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Api/Data/AttributeValueTest.php b/dev/tests/unit/testsuite/Magento/Framework/Api/Data/AttributeValueTest.php index c748e9820c3..8505df47f31 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Api/Data/AttributeValueTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Api/Data/AttributeValueTest.php @@ -40,7 +40,7 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithString() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeValueBuilder') + $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeDataBuilder') ->setAttributeCode(self::ATTRIBUTE_CODE) ->setValue(self::STRING_VALUE); $attribute = new AttributeValue($attributeBuilder); @@ -52,7 +52,7 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithInteger() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeValueBuilder') + $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeDataBuilder') ->setAttributeCode(self::ATTRIBUTE_CODE) ->setValue(self::INTEGER_VALUE); $attribute = new AttributeValue($attributeBuilder); @@ -64,7 +64,7 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithFloat() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeValueBuilder') + $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeDataBuilder') ->setAttributeCode(self::ATTRIBUTE_CODE) ->setValue(self::FLOAT_VALUE); $attribute = new AttributeValue($attributeBuilder); @@ -76,7 +76,7 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithBoolean() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeValueBuilder') + $attributeBuilder = $helper->getObject('\Magento\Framework\Api\AttributeDataBuilder') ->setAttributeCode(self::ATTRIBUTE_CODE) ->setValue(self::BOOLEAN_VALUE); $attribute = new AttributeValue($attributeBuilder); diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php index 2cf42e36ab5..d788d532e7c 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php @@ -44,16 +44,16 @@ class VersionTest extends \PHPUnit_Framework_TestCase private $versionStorage; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Stdlib\DateTime|\PHPUnit_Framework_MockObject_MockObject */ - private $versionGenerator; + private $dateTime; protected function setUp() { $this->appState = $this->getMock('Magento\Framework\App\State', array(), array(), '', false); $this->versionStorage = $this->getMock('Magento\Framework\App\View\Deployment\Version\StorageInterface'); - $this->versionGenerator = $this->getMock('Magento\Framework\App\View\Deployment\Version\GeneratorInterface'); - $this->object = new Version($this->appState, $this->versionStorage, $this->versionGenerator); + $this->dateTime = $this->getMock('Magento\Framework\Stdlib\DateTime'); + $this->object = new Version($this->appState, $this->versionStorage, $this->dateTime); } public function testGetValueDeveloperMode() @@ -64,7 +64,7 @@ class VersionTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER)) ; $this->versionStorage->expects($this->never())->method($this->anything()); - $this->versionGenerator->expects($this->once())->method('generate')->will($this->returnValue('123')); + $this->dateTime->expects($this->once())->method('toTimestamp')->will($this->returnValue('123')); $this->assertEquals('123', $this->object->getValue()); $this->object->getValue(); // Ensure computation occurs only once and result is cached in memory } @@ -82,7 +82,7 @@ class VersionTest extends \PHPUnit_Framework_TestCase ; $this->versionStorage->expects($this->once())->method('load')->will($this->returnValue('123')); $this->versionStorage->expects($this->never())->method('save'); - $this->versionGenerator->expects($this->never())->method('generate'); + $this->dateTime->expects($this->never())->method('toTimestamp'); $this->assertEquals('123', $this->object->getValue()); $this->object->getValue(); // Ensure caching in memory } @@ -109,7 +109,7 @@ class VersionTest extends \PHPUnit_Framework_TestCase ->method('load') ->will($this->throwException($storageException)) ; - $this->versionGenerator->expects($this->once())->method('generate')->will($this->returnValue('123')); + $this->dateTime->expects($this->once())->method('toTimestamp')->will($this->returnValue('123')); $this->versionStorage->expects($this->once())->method('save')->with('123'); $this->assertEquals('123', $this->object->getValue()); $this->object->getValue(); // Ensure caching in memory diff --git a/dev/tests/unit/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php b/dev/tests/unit/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php index 7fbeaa0c98e..cf97f4bbf09 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Filter/Template/Tokenizer/ParameterTest.php @@ -61,7 +61,8 @@ class ParameterTest extends \PHPUnit_Framework_TestCase { return [ [" direct_url='about-magento-demo-store'", ['direct_url' => 'about-magento-demo-store']], - [" direct_url='about-magento-demo-store\\[newDemo]", ['direct_url' => 'about-magento-demo-store[newDemo]']], + [" direct_url='about-magento-demo-store\\[newDemo]", + ['direct_url' => 'about-magento-demo-store\\[newDemo]']], [" ", []] ]; } @@ -70,7 +71,7 @@ class ParameterTest extends \PHPUnit_Framework_TestCase { return [ [" direct_url='about-magento-demo-store'", "direct_url='about-magento-demo-store'"], - [" direct_url='about-magento-demo-store\\[newDemo]", "direct_url='about-magento-demo-store[newDemo]"], + [" direct_url='about-magento-demo-store\\[newDemo]", "direct_url='about-magento-demo-store\\[newDemo]"], [' ', ''] ]; } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Model/AbstractExtensibleModelTest.php b/dev/tests/unit/testsuite/Magento/Framework/Model/AbstractExtensibleModelTest.php index b0984d320f7..634f28525ab 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Model/AbstractExtensibleModelTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Model/AbstractExtensibleModelTest.php @@ -158,7 +158,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase */ public function testRestrictedCustomAttributesGet() { - $this->model->getData(\Magento\Framework\Model\AbstractExtensibleModel::CUSTOM_ATTRIBUTES_KEY); + $this->model->getData(\Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES); } /** @@ -166,7 +166,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase */ public function testRestrictedCustomAttributesSet() { - $this->model->setData(\Magento\Framework\Model\AbstractExtensibleModel::CUSTOM_ATTRIBUTES_KEY, 'value'); + $this->model->setData(\Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES, 'value'); } /** @@ -177,8 +177,8 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase protected function addCustomAttributesToModel($attributesAsArray, $model) { $objectManager = new ObjectManagerHelper($this); - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ - $attributeValueBuilder = $objectManager->getObject('Magento\Framework\Api\AttributeValueBuilder'); + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ + $attributeValueBuilder = $objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); $addedAttributes = []; foreach ($attributesAsArray as $attributeCode => $attributeValue) { $addedAttributes[$attributeCode] = $attributeValueBuilder diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerRegistryTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerRegistryTest.php new file mode 100644 index 00000000000..70fb6e837d7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerRegistryTest.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\Indexer\Model; + +class IndexerRegistryTest extends \PHPUnit_Framework_TestCase +{ + public function testGetCreatesIndexerInstancesAndReusesExistingOnes() + { + $firstIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $firstIndexer->expects($this->once())->method('load')->with('first-indexer')->willReturnSelf(); + + $secondIndexer = $this->getMock('Magento\Indexer\Model\IndexerInterface'); + $secondIndexer->expects($this->once())->method('load')->with('second-indexer')->willReturnSelf(); + + $objectManager = $this->getMock('Magento\Framework\ObjectManager', [], [], '', false); + $objectManager->expects($this->at(0))->method('create')->willReturn($firstIndexer); + $objectManager->expects($this->at(1))->method('create')->willReturn($secondIndexer); + + $unit = new IndexerRegistry($objectManager); + $this->assertSame($firstIndexer, $unit->get('first-indexer')); + $this->assertSame($secondIndexer, $unit->get('second-indexer')); + $this->assertSame($firstIndexer, $unit->get('first-indexer')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/InfoTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/InfoTest.php index 1b68e249709..c70b6db1d42 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/InfoTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/InfoTest.php @@ -239,4 +239,12 @@ class InfoTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->info->hasAdditionalInformation('key2')); $this->assertTrue($this->info->hasAdditionalInformation()); } + + public function testInitAdditionalInformationWithUnserialize() + { + $data = serialize(['key1' => 'data1', 'key2' => 'data2']); + $this->info->setData('additional_information', $data); + + $this->assertEquals(unserialize($data), $this->info->getAdditionalInformation()); + } } 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 9320cabcfb8..5805a04fdd4 100644 --- a/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/Condition/CombineTest.php @@ -29,46 +29,139 @@ 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 | \PHPUnit_Framework_MockObject_MockObject */ - protected $_combine; + private $combine; /** - * @var ObjectManagerHelper + * @var \Magento\Rule\Model\ConditionFactory | \PHPUnit_Framework_MockObject_MockObject */ - protected $_objectManagerHelper; + private $conditionFactoryMock; /** - * @var \Magento\Rule\Model\Condition\Context|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Logger | \PHPUnit_Framework_MockObject_MockObject */ - protected $_contextMock; + private $loggerMock; + /** + * @var \Magento\SalesRule\Model\Rule\Condition\Product | \PHPUnit_Framework_MockObject_MockObject + */ + private $conditionObjectMock; + + /** + * Sets up the Mocks. + * This method is called before a test is executed. + */ protected function setUp() { - $this->_objectManagerHelper = new ObjectManagerHelper($this); - $this->_combine = $this->_objectManagerHelper->getObject('Magento\Rule\Model\Condition\Combine'); + $this->conditionFactoryMock = $this->getMockBuilder('\Magento\Rule\Model\ConditionFactory') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->loggerMock = $this->getMockBuilder('\Magento\Framework\Logger') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->conditionObjectMock = $this->getMockBuilder('\Magento\SalesRule\Model\Rule\Condition\Product') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->combine = (new ObjectManagerHelper($this))->getObject( + '\Magento\Rule\Model\Condition\Combine', + [ + "conditionFactory" => $this->conditionFactoryMock, + "logger" => $this->loggerMock, + ] + ); } /** + * * @covers \Magento\Rule\Model\Condition\AbstractCondition::getValueName + * * @dataProvider optionValuesData + * * @param string|array $value * @param string $expectingData */ public function testGetValueName($value, $expectingData) { - $this->_combine->setValueOption(array('option_key' => 'option_value'))->setValue($value); - $this->assertEquals($expectingData, $this->_combine->getValueName()); + $this->combine + ->setValueOption(['option_key' => 'option_value']) + ->setValue($value); + + $this->assertEquals($expectingData, $this->combine->getValueName()); } + /** + * @return array + */ public function optionValuesData() { - return array( - array('option_key', 'option_value'), - array('option_value', 'option_value'), - array(array('option_key'), 'option_value'), - array('', '...'), - ); + return [ + ['option_key', 'option_value'], + ['option_value', 'option_value'], + [['option_key'], 'option_value'], + ['', '...'], + ]; + } + + public function testLoadArray() + { + $array['conditions'] = [ + [ + 'type' => 'test', + 'attribute' => '', + 'operator' => '', + 'value' => '', + ] + ]; + + $this->conditionObjectMock->expects($this->once()) + ->method('loadArray') + ->with($array['conditions'][0], 'conditions'); + + $this->conditionFactoryMock->expects($this->once()) + ->method('create') + ->with($array['conditions'][0]['type']) + ->willReturn($this->conditionObjectMock); + + $this->loggerMock->expects($this->never()) + ->method('logException'); + + $result = $this->combine->loadArray($array); + + $this->assertInstanceOf('\Magento\Rule\Model\Condition\Combine', $result); } + public function testLoadArrayLoggerCatchException() + { + $array['conditions'] = [ + [ + 'type' => '', + 'attribute' => '', + 'operator' => '', + 'value' => '', + ] + ]; + + $this->conditionObjectMock->expects($this->never()) + ->method('loadArray'); + + $this->conditionFactoryMock->expects($this->once()) + ->method('create') + ->with($array['conditions'][0]['type']) + ->willThrowException(new \Exception('everything is fine, it is test')); + + $this->loggerMock->expects($this->once()) + ->method('logException') + ->with(); + + $result = $this->combine->loadArray($array); + + $this->assertInstanceOf('\Magento\Rule\Model\Condition\Combine', $result); + } } diff --git a/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php index c9189658941..d9f6fcde1a5 100644 --- a/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Rule/Model/ConditionFactoryTest.php @@ -56,11 +56,29 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ); } - public function testCreate() + public function testExceptingToCallMethodCreateInObjectManager() { - $type = '1'; - $data = ['data2', 'data3']; - $this->objectManagerMock->expects($this->once())->method('create')->with($type, $data); - $this->conditionFactory->create($type, $data); + $type = 'type'; + $this->objectManagerMock + ->expects($this->once()) + ->method('create') + ->with($type) + ->willReturn(new \stdClass()); + + $this->conditionFactory->create($type); + } + + public function testExceptingClonedObject() + { + $origin = new \stdClass(); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with('clone') + ->willReturn($origin); + + $cloned = $this->conditionFactory->create('clone'); + + $this->assertNotSame($cloned, $origin); } } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php index 3112c42692d..a79c683beb1 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -196,7 +196,7 @@ class CreateTest extends \PHPUnit_Framework_TestCase )->method( 'mergeDataObjectWithArray' )->will( - $this->returnArgument(0) + $this->returnValue($this->customerBuilderMock) ); $this->customerGroupServiceMock->expects( diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php index 77d2fdf6184..1ffc4468220 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php @@ -95,7 +95,7 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase $this->customerHelperMock = $this->getMock('Magento\Customer\Helper\Data', array(), array(), '', false); $this->customerBuilderMock = $this->getMock( 'Magento\Customer\Service\V1\Data\CustomerBuilder', - array('mergeDataObjectWithArray'), + array('mergeDataObjectWithArray', 'create'), array(), '', false @@ -165,9 +165,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase public function testDispatchWithDisableAutoGroupChange() { - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ $attributeValueBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $attributeValueBuilder->setAttributeCode('disable_auto_group_change')->setValue(true); $this->customerDataMock->expects( $this->exactly(2) @@ -184,9 +184,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase public function testDispatchWithDisableVatValidator() { - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ $attributeValueBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $attributeValueBuilder->setAttributeCode('disable_auto_group_change')->setValue(false); $this->customerDataMock->expects( $this->exactly(2) @@ -213,9 +213,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase public function testDispatchWithCustomerCountryNotInEUAndNotLoggedCustomerInGroup() { - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ $attributeValueBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $attributeValueBuilder->setAttributeCode('disable_auto_group_change')->setValue(false); /** Preconditions */ $this->customerDataMock->expects( @@ -271,9 +271,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase public function testDispatchWithDefaultCustomerGroupId() { - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ $attributeValueBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $attributeValueBuilder->setAttributeCode('disable_auto_group_change')->setValue(false); /** Preconditions */ $this->customerDataMock->expects( @@ -339,6 +339,13 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase )->with( $this->customerDataMock, array('group_id' => 'defaultCustomerGroupId') + )->will( + $this->returnValue($this->customerBuilderMock) + ); + $this->customerBuilderMock->expects( + $this->once() + )->method( + 'create' )->will( $this->returnValue($this->customerDataMock) ); @@ -351,9 +358,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase public function testDispatchWithCustomerCountryInEU() { - /** @var \Magento\Framework\Api\AttributeValueBuilder $attributeValueBuilder */ + /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ $attributeValueBuilder = $this->objectManager - ->getObject('Magento\Framework\Api\AttributeValueBuilder'); + ->getObject('Magento\Framework\Api\AttributeDataBuilder'); $attributeValueBuilder->setAttributeCode('disable_auto_group_change')->setValue(false); /** Preconditions */ $this->customerDataMock->expects($this->exactly(2)) @@ -402,6 +409,9 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase $this->customerBuilderMock->expects($this->once()) ->method('mergeDataObjectWithArray') ->with($this->customerDataMock, array('group_id' => 'customerGroupId')) + ->will($this->returnValue($this->customerBuilderMock)); + $this->customerBuilderMock->expects($this->once()) + ->method('create') ->will($this->returnValue($this->customerDataMock)); $this->model->dispatch($this->observerMock); } diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php index d1ce3fd60c7..6687dd630de 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php @@ -104,6 +104,16 @@ class QuoteTest extends \PHPUnit_Framework_TestCase */ protected $quoteItemCollectionFactoryMock; + /** + * @var \Magento\Sales\Model\Quote\PaymentFactory + */ + protected $paymentFactoryMock; + + /** + * @var \Magento\Sales\Model\Resource\Quote\Payment\CollectionFactory + */ + protected $quotePaymentCollectionFactoryMock; + /** * @var \Magento\Framework\App\Config | \PHPUnit_Framework_MockObject_MockObject */ @@ -183,6 +193,20 @@ class QuoteTest extends \PHPUnit_Framework_TestCase '', false ); + $this->quotePaymentCollectionFactoryMock = $this->getMock( + 'Magento\Sales\Model\Resource\Quote\Payment\CollectionFactory', + ['create'], + [], + '', + false + ); + $this->paymentFactoryMock = $this->getMock( + 'Magento\Sales\Model\Quote\PaymentFactory', + ['create'], + [], + '', + false + ); $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config') ->disableOriginalConstructor() ->getMock(); @@ -202,6 +226,8 @@ class QuoteTest extends \PHPUnit_Framework_TestCase 'customerGroupService' => $this->customerGroupServiceMock, 'objectFactory' => $this->objectFactoryMock, 'quoteItemCollectionFactory' => $this->quoteItemCollectionFactoryMock, + 'quotePaymentCollectionFactory' => $this->quotePaymentCollectionFactoryMock, + 'quotePaymentFactory' => $this->paymentFactoryMock, 'scopeConfig' => $this->scopeConfig ] ); @@ -871,4 +897,83 @@ class QuoteTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->quote->validateMinimumAmount()); } + + public function testGetPaymentIsNotDeleted() + { + $this->quote->setId(1); + $payment = $this->getMock( + 'Magento\Sales\Model\Quote\Payment', + ['setQuote', 'isDeleted', '__wakeup'], + [], + '', + false + ); + $payment->expects($this->once()) + ->method('setQuote'); + $payment->expects($this->once()) + ->method('isDeleted') + ->willReturn(false); + $quotePaymentCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Quote\Payment\Collection', + ['setQuoteFilter', 'getFirstItem'], + [], + '', + false + ); + $quotePaymentCollectionMock->expects($this->once()) + ->method('setQuoteFilter') + ->with(1) + ->will($this->returnSelf()); + $quotePaymentCollectionMock->expects($this->once()) + ->method('getFirstItem') + ->willReturn($payment); + $this->quotePaymentCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($quotePaymentCollectionMock); + + $this->assertInstanceOf('\Magento\Sales\Model\Quote\Payment', $this->quote->getPayment()); + } + + public function testGetPaymentIsDeleted() + { + $this->quote->setId(1); + $payment = $this->getMock( + 'Magento\Sales\Model\Quote\Payment', + ['setQuote', 'isDeleted', 'getId', '__wakeup'], + [], + '', + false + ); + $payment->expects($this->exactly(2)) + ->method('setQuote'); + $payment->expects($this->once()) + ->method('isDeleted') + ->willReturn(true); + $payment->expects($this->once()) + ->method('getId') + ->willReturn(1); + $quotePaymentCollectionMock = $this->getMock( + 'Magento\Sales\Model\Resource\Quote\Payment\Collection', + ['setQuoteFilter', 'getFirstItem'], + [], + '', + false + ); + $quotePaymentCollectionMock->expects($this->once()) + ->method('setQuoteFilter') + ->with(1) + ->will($this->returnSelf()); + $quotePaymentCollectionMock->expects($this->once()) + ->method('getFirstItem') + ->willReturn($payment); + $this->quotePaymentCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($quotePaymentCollectionMock); + + $this->paymentFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($payment); + + $this->assertInstanceOf('\Magento\Sales\Model\Quote\Payment', $this->quote->getPayment()); + } } 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 index de530ce459e..d7f45cb70a1 100644 --- 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 @@ -118,7 +118,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->any()) ->method('getTableName') - ->will($this->returnValue('sales_flat_creditmemo_grid')); + ->will($this->returnValue('sales_creditmemo_grid')); $this->adapterMock->expects($this->once()) ->method('select') ->will($this->returnValue($this->selectMock)); @@ -144,7 +144,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->statementMock)); $this->adapterMock->expects($this->once()) ->method('insertFromSelect') - ->with($this->selectMock, 'sales_flat_creditmemo_grid', [], 1) + ->with($this->selectMock, 'sales_creditmemo_grid', [], 1) ->will($this->returnValue('sql-query')); $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); } @@ -159,10 +159,10 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->once()) ->method('getTableName') - ->will($this->returnValue('sales_flat_creditmemo_grid')); + ->will($this->returnValue('sales_creditmemo_grid')); $this->adapterMock->expects($this->once()) ->method('delete') - ->with('sales_flat_creditmemo_grid', ['fi.field = ?' => 1]) + ->with('sales_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 index cc1f2f4b558..58a808b550e 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php @@ -118,7 +118,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->any()) ->method('getTableName') - ->will($this->returnValue('sales_flat_order_grid')); + ->will($this->returnValue('sales_order_grid')); $this->adapterMock->expects($this->once()) ->method('select') ->will($this->returnValue($this->selectMock)); @@ -141,7 +141,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->statementMock)); $this->adapterMock->expects($this->once()) ->method('insertFromSelect') - ->with($this->selectMock, 'sales_flat_order_grid', [], 1) + ->with($this->selectMock, 'sales_order_grid', [], 1) ->will($this->returnValue('sql-query')); $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); } @@ -156,10 +156,10 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->once()) ->method('getTableName') - ->will($this->returnValue('sales_flat_order_grid')); + ->will($this->returnValue('sales_order_grid')); $this->adapterMock->expects($this->once()) ->method('delete') - ->with('sales_flat_order_grid', ['fi.field = ?' => 1]) + ->with('sales_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/Invoice/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php index f769982945d..07bf8902b2f 100644 --- 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 @@ -118,7 +118,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->any()) ->method('getTableName') - ->will($this->returnValue('sales_flat_invoice_grid')); + ->will($this->returnValue('sales_invoice_grid')); $this->adapterMock->expects($this->once()) ->method('select') ->will($this->returnValue($this->selectMock)); @@ -144,7 +144,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->statementMock)); $this->adapterMock->expects($this->once()) ->method('insertFromSelect') - ->with($this->selectMock, 'sales_flat_invoice_grid', [], 1) + ->with($this->selectMock, 'sales_invoice_grid', [], 1) ->will($this->returnValue('sql-query')); $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); } @@ -159,10 +159,10 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->once()) ->method('getTableName') - ->will($this->returnValue('sales_flat_invoice_grid')); + ->will($this->returnValue('sales_invoice_grid')); $this->adapterMock->expects($this->once()) ->method('delete') - ->with('sales_flat_invoice_grid', ['fi.field = ?' => 1]) + ->with('sales_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 index bcc51895cf1..83ff86ee8f9 100644 --- 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 @@ -118,7 +118,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->any()) ->method('getTableName') - ->will($this->returnValue('sales_flat_shipment_grid')); + ->will($this->returnValue('sales_shipment_grid')); $this->adapterMock->expects($this->once()) ->method('select') ->will($this->returnValue($this->selectMock)); @@ -144,7 +144,7 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->statementMock)); $this->adapterMock->expects($this->once()) ->method('insertFromSelect') - ->with($this->selectMock, 'sales_flat_shipment_grid', [], 1) + ->with($this->selectMock, 'sales_shipment_grid', [], 1) ->will($this->returnValue('sql-query')); $this->assertEquals($this->statementMock, $this->grid->refresh(1, 'fi.field')); } @@ -159,10 +159,10 @@ class GridTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->adapterMock)); $this->appResourceMock->expects($this->once()) ->method('getTableName') - ->will($this->returnValue('sales_flat_shipment_grid')); + ->will($this->returnValue('sales_shipment_grid')); $this->adapterMock->expects($this->once()) ->method('delete') - ->with('sales_flat_shipment_grid', ['fi.field = ?' => 1]) + ->with('sales_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/SalesRule/Model/Quote/Nominal/DiscountTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php index 9ce463b7600..461567d1384 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/Quote/Nominal/DiscountTest.php @@ -23,6 +23,8 @@ */ namespace Magento\SalesRule\Model\Quote\Nominal; +use Magento\TestFramework\Helper\ObjectManager; + /** * Class DiscountTest */ @@ -34,14 +36,64 @@ class DiscountTest extends \PHPUnit_Framework_TestCase protected $discount; /** - * @var \Magento\TestFramework\Helper\ObjectManager + * @var ObjectManager */ protected $objectManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManager + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\SalesRule\Model\Validator + */ + protected $validatorMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Event\Manager + */ + protected $eventManagerMock; + public function setUp() { - $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->discount = $this->objectManager->getObject('Magento\SalesRule\Model\Quote\Nominal\Discount', []); + $this->objectManager = new ObjectManager($this); + + $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->getMock(); + + $this->validatorMock = $this->getMockBuilder('Magento\SalesRule\Model\Validator') + ->disableOriginalConstructor() + ->setMethods( + [ + 'canApplyRules', + 'reset', + 'init', + 'initTotals', + 'sortItemsByPriority', + 'setSkipActionsValidation', + 'process', + 'processShippingAmount', + 'canApplyDiscount', + '__wakeup' + ] + ) + ->getMock(); + + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\Manager') + ->disableOriginalConstructor() + ->getMock(); + + /** @var \Magento\SalesRule\Model\Quote\Nominal\Discount $discount */ + $this->discount = $this->objectManager->getObject( + 'Magento\SalesRule\Model\Quote\Nominal\Discount', + [ + 'storeManager' => $this->storeManagerMock, + 'validator' => $this->validatorMock, + 'eventManager' => $this->eventManagerMock + ] + ); } public function testFetch() @@ -52,33 +104,50 @@ class DiscountTest extends \PHPUnit_Framework_TestCase $this->assertInternalType('array', $this->discount->fetch($addressMock)); } - public function testGetAddressItems() + public function testGetNominalAddressItems() { + $item = $this->getMockBuilder('Magento\Sales\Model\Quote\Item') + ->disableOriginalConstructor() + ->setMethods(['__wakeup']) + ->getMock(); + + $this->validatorMock->expects($this->once()) + ->method('sortItemsByPriority') + ->willReturnArgument(0); + + $storeMock = $this->getMockBuilder('Magento\Store\Model\Store') + ->disableOriginalConstructor() + ->setMethods(['getStore', '__wakeup']) + ->getMock(); + + $this->storeManagerMock->expects($this->once()) + ->method('getStore') + ->willReturn($storeMock); + $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote') ->disableOriginalConstructor() ->getMock(); + $addressMock = $this->getMockBuilder('Magento\Sales\Model\Quote\Address') ->disableOriginalConstructor() + ->setMethods(['getQuote', 'getAllNominalItems', 'getShippingAmount', '__wakeup']) ->getMock(); + $addressMock->expects($this->any()) ->method('getQuote') ->willReturn($quoteMock); - $storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManager') - ->disableOriginalConstructor() - ->getMock(); - $validatorMock = $this->getMockBuilder('Magento\SalesRule\Model\Validator') - ->disableOriginalConstructor() - ->getMock(); - /** @var \Magento\SalesRule\Model\Quote\Discount $discount */ - $discount = $this->objectManager->getObject( - 'Magento\SalesRule\Model\Quote\Discount', - ['storeManager' => $storeManagerMock, 'validator' => $validatorMock] - ); + $addressMock->expects($this->once()) + ->method('getAllNominalItems') + ->willReturn([$item]); + + $addressMock->expects($this->once()) + ->method('getShippingAmount') + ->willReturn(true); $this->assertInstanceOf( - 'Magento\Sales\Model\Quote\Address\Total\AbstractTotal', - $discount->collect($addressMock) + 'Magento\SalesRule\Model\Quote\Discount', + $this->discount->collect($addressMock) ); } } diff --git a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxClassServiceTest.php b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxClassServiceTest.php index 86aae952ca9..823f6004631 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxClassServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Service/V1/TaxClassServiceTest.php @@ -550,6 +550,10 @@ class TaxClassServiceTest extends \PHPUnit_Framework_TestCase )->disableOriginalConstructor() ->getMock(); + $filterBuilder = $this->objectManager->getObject( + 'Magento\Framework\Api\FilterBuilder' + ); + $taxClassService = $this->objectManager->getObject( 'Magento\Tax\Service\V1\TaxClassService', [ @@ -557,7 +561,8 @@ class TaxClassServiceTest extends \PHPUnit_Framework_TestCase 'taxClassCollectionFactory' => $this->taxClassCollectionFactory, 'classModelRegistry' => $this->classModelRegistryMock, 'searchResultsBuilder' => $this->searchResultBuilder, - 'converter' => $this->converterMock + 'converter' => $this->converterMock, + 'filterBuilder' => $filterBuilder ] ); diff --git a/dev/tests/unit/testsuite/Magento/UrlRewrite/Controller/RouterTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/Controller/RouterTest.php index 13776038190..1a8757d6189 100644 --- a/dev/tests/unit/testsuite/Magento/UrlRewrite/Controller/RouterTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/Controller/RouterTest.php @@ -84,7 +84,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); $this->store->expects($this->any())->method('getId')->will($this->returnValue('current-store-id')); - $this->assertEquals(null, $this->router->match($this->request)); + $this->assertNull($this->router->match($this->request)); } public function testRewriteAfterStoreSwitcher() @@ -107,28 +107,24 @@ class RouterTest extends \PHPUnit_Framework_TestCase $urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('new-request-path')); $this->urlFinder->expects($this->any())->method('findOneByData')->will( - $this->returnValueMap( + $this->returnValueMap([ + [ + [UrlRewrite::REQUEST_PATH => 'request-path', UrlRewrite::STORE_ID => 'old-store-id'], + $oldUrlRewrite + ], [ [ - [UrlRewrite::REQUEST_PATH => 'request-path', UrlRewrite::STORE_ID => 'old-store-id'], - $oldUrlRewrite + UrlRewrite::ENTITY_TYPE => 'entity-type', + UrlRewrite::ENTITY_ID => 'entity-id', + UrlRewrite::STORE_ID => 'current-store-id', + UrlRewrite::IS_AUTOGENERATED => 1, ], - [ - [ - UrlRewrite::ENTITY_TYPE => 'entity-type', - UrlRewrite::ENTITY_ID => 'entity-id', - UrlRewrite::STORE_ID => 'current-store-id', - UrlRewrite::IS_AUTOGENERATED => 1, - ], - $urlRewrite - ] + $urlRewrite ] - ) + ]) ); $this->response->expects($this->once())->method('setRedirect') - ->with('request-path-302', OptionProvider::TEMPORARY); - $this->url->expects($this->once())->method('getUrl')->with('', array('_direct' => 'new-request-path')) - ->will($this->returnValue('request-path-302')); + ->with('new-request-path', OptionProvider::TEMPORARY); $this->request->expects($this->once())->method('setDispatched')->with(true); $this->actionFactory->expects($this->once())->method('create') ->with('Magento\Framework\App\Action\Redirect', ['request' => $this->request]); @@ -136,7 +132,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->router->match($this->request); } - public function testNoRewriteAfterStoreSwitcher() + public function testNoRewriteAfterStoreSwitcherWhenNoOldRewrite() { $this->request->expects($this->any())->method('getPathInfo')->will($this->returnValue('request-path')); $this->request->expects($this->any())->method('getParam')->with('___from_store') @@ -155,7 +151,47 @@ class RouterTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor()->getMock(); $urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('request-path')); - $this->assertEquals(null, $this->router->match($this->request)); + $this->assertNull($this->router->match($this->request)); + } + + public function testNoRewriteAfterStoreSwitcherWhenOldRewriteEqualsToNewOne() + { + $this->request->expects($this->any())->method('getPathInfo')->will($this->returnValue('request-path')); + $this->request->expects($this->any())->method('getParam')->with('___from_store') + ->will($this->returnValue('old-store')); + $oldStore = $this->getMockBuilder('Magento\Store\Model\Store')->disableOriginalConstructor()->getMock(); + $this->storeManager->expects($this->any())->method('getStore') + ->will($this->returnValueMap([['old-store', $oldStore], [null, $this->store]])); + $oldStore->expects($this->any())->method('getId')->will($this->returnValue('old-store-id')); + $this->store->expects($this->any())->method('getId')->will($this->returnValue('current-store-id')); + $oldUrlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') + ->disableOriginalConstructor()->getMock(); + $oldUrlRewrite->expects($this->any())->method('getEntityType')->will($this->returnValue('entity-type')); + $oldUrlRewrite->expects($this->any())->method('getEntityId')->will($this->returnValue('entity-id')); + $oldUrlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('old-request-path')); + $urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') + ->disableOriginalConstructor()->getMock(); + $urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('old-request-path')); + + $this->urlFinder->expects($this->any())->method('findOneByData')->will( + $this->returnValueMap([ + [ + [UrlRewrite::REQUEST_PATH => 'request-path', UrlRewrite::STORE_ID => 'old-store-id'], + $oldUrlRewrite + ], + [ + [ + UrlRewrite::ENTITY_TYPE => 'entity-type', + UrlRewrite::ENTITY_ID => 'entity-id', + UrlRewrite::STORE_ID => 'current-store-id', + UrlRewrite::IS_AUTOGENERATED => 1, + ], + $urlRewrite + ] + ]) + ); + + $this->assertNull($this->router->match($this->request)); } public function testMatchWithRedirect() @@ -177,6 +213,57 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->router->match($this->request); } + public function testMatchWithCustomInternalRedirect() + { + $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); + $urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') + ->disableOriginalConstructor()->getMock(); + $urlRewrite->expects($this->any())->method('getEntityType')->will($this->returnValue('custom')); + $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue('redirect-code')); + $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue('target-path')); + $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); + $this->response->expects($this->once())->method('setRedirect')->with('a', 'redirect-code'); + $this->url->expects($this->once())->method('getUrl')->with('', ['_direct' => 'target-path'])->willReturn('a'); + $this->request->expects($this->once())->method('setDispatched')->with(true); + $this->actionFactory->expects($this->once())->method('create') + ->with('Magento\Framework\App\Action\Redirect', ['request' => $this->request]); + + $this->router->match($this->request); + } + + /** + * @param string $targetPath + * @dataProvider externalRedirectTargetPathDataProvider + */ + public function testMatchWithCustomExternalRedirect($targetPath) + { + $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); + $urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') + ->disableOriginalConstructor()->getMock(); + $urlRewrite->expects($this->any())->method('getEntityType')->will($this->returnValue('custom')); + $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue('redirect-code')); + $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue($targetPath)); + $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); + $this->response->expects($this->once())->method('setRedirect')->with($targetPath, 'redirect-code'); + $this->url->expects($this->never())->method('getUrl'); + $this->request->expects($this->once())->method('setDispatched')->with(true); + $this->actionFactory->expects($this->once())->method('create') + ->with('Magento\Framework\App\Action\Redirect', ['request' => $this->request]); + + $this->router->match($this->request); + } + + /** + * @return array + */ + public function externalRedirectTargetPathDataProvider() + { + return [ + ['http://example.com'], + ['https://example.com'], + ]; + } + public function testMatch() { $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store)); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/WebapiBuilderFactory.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/WebapiBuilderFactory.php index dead3735e8a..901e832d4ef 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/WebapiBuilderFactory.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/WebapiBuilderFactory.php @@ -37,7 +37,7 @@ class WebapiBuilderFactory extends \Magento\Framework\Serialization\DataBuilderF * Returns a builder for a given class name. * * @param string $className - * @return \Magento\Framework\Api\ExtensibleDataBuilderInterface Builder Instance + * @return \Magento\Framework\Api\BuilderInterface Builder Instance */ public function getDataBuilder($className) { diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index 91aac919d29..ebb368ecd9f 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -34,7 +34,6 @@ use Magento\Tools\Di\Compiler\Directory; use Magento\Tools\Di\Code\Scanner; use Magento\Tools\Di\Definition\Compressor; use Magento\Tools\Di\Definition\Serializer; -use Magento\Framework\Api\Code\Generator\Builder; use Magento\Framework\Api\Code\Generator\Mapper; use Magento\Framework\Api\Code\Generator\SearchResults; use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; @@ -108,9 +107,9 @@ try { \Magento\Framework\Interception\Code\Generator\Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', + DataBuilder::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', - Builder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Builder', Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', diff --git a/dev/tools/Magento/Tools/Di/entity_generator.php b/dev/tools/Magento/Tools/Di/entity_generator.php index 58e72db1b02..c917c8f1de5 100644 --- a/dev/tools/Magento/Tools/Di/entity_generator.php +++ b/dev/tools/Magento/Tools/Di/entity_generator.php @@ -29,7 +29,6 @@ use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Proxy; use Magento\Framework\Interception\Code\Generator\Interceptor; use Magento\Framework\Exception; -use Magento\Framework\Api\Code\Generator\Builder; use Magento\Framework\Api\Code\Generator\DataBuilder; use Magento\Framework\Api\Code\Generator\Mapper; use Magento\Framework\ObjectManager\Code\Generator\Repository; @@ -97,14 +96,13 @@ $generator = new Generator( DataBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\DataBuilder', SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', + DataBuilder::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', - Builder::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\Builder', Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', Repository::ENTITY_TYPE => diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/blacklist_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/blacklist_ce.php index da13cd6e98c..8e67cfa4f18 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/blacklist_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/blacklist_ce.php @@ -37,7 +37,7 @@ return array( 'cat_pro', 'table_name', 'rule_customer', - 'sales_flat_', + 'sales_', 'catalog_product_link_attribute_', 'catalog_category_flat_', 'catalog_category_entity_', diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php index adddc992860..6148df634c4 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php @@ -298,47 +298,47 @@ return array( 'sales/bestsellers_aggregated_yearly' => 'sales_bestsellers_aggregated_yearly', 'sales/billing_agreement' => 'paypal_billing_agreement', 'sales/billing_agreement_order' => 'paypal_billing_agreement_order', - 'sales/creditmemo' => 'sales_flat_creditmemo', - 'sales/creditmemo_comment' => 'sales_flat_creditmemo_comment', - 'sales/creditmemo_grid' => 'sales_flat_creditmemo_grid', - 'sales/creditmemo_item' => 'sales_flat_creditmemo_item', - 'sales/invoice' => 'sales_flat_invoice', - 'sales/invoice_comment' => 'sales_flat_invoice_comment', - 'sales/invoice_grid' => 'sales_flat_invoice_grid', - 'sales/invoice_item' => 'sales_flat_invoice_item', + 'sales/creditmemo' => 'sales_creditmemo', + 'sales/creditmemo_comment' => 'sales_creditmemo_comment', + 'sales/creditmemo_grid' => 'sales_creditmemo_grid', + 'sales/creditmemo_item' => 'sales_creditmemo_item', + 'sales/invoice' => 'sales_invoice', + 'sales/invoice_comment' => 'sales_invoice_comment', + 'sales/invoice_grid' => 'sales_invoice_grid', + 'sales/invoice_item' => 'sales_invoice_item', 'sales/invoiced_aggregated' => 'sales_invoiced_aggregated', 'sales/invoiced_aggregated_order' => 'sales_invoiced_aggregated_order', - 'sales/order' => 'sales_flat_order', - 'sales/order_address' => 'sales_flat_order_address', + 'sales/order' => 'sales_order', + 'sales/order_address' => 'sales_order_address', 'sales/order_aggregated_created' => 'sales_order_aggregated_created', 'sales/order_aggregated_updated' => 'sales_order_aggregated_updated', 'sales/order_entity' => 'sales_order_entity', - 'sales/order_grid' => 'sales_flat_order_grid', - 'sales/order_item' => 'sales_flat_order_item', - 'sales/order_item_option' => 'sales_flat_order_item_option', - 'sales/order_payment' => 'sales_flat_order_payment', + 'sales/order_grid' => 'sales_order_grid', + 'sales/order_item' => 'sales_order_item', + 'sales/order_item_option' => 'sales_order_item_option', + 'sales/order_payment' => 'sales_order_payment', 'sales/order_status' => 'sales_order_status', - 'sales/order_status_history' => 'sales_flat_order_status_history', + 'sales/order_status_history' => 'sales_order_status_history', 'sales/order_status_label' => 'sales_order_status_label', 'sales/order_status_state' => 'sales_order_status_state', 'sales/order_tax' => 'sales_order_tax', 'sales/payment_transaction' => 'sales_payment_transaction', - 'sales/quote' => 'sales_flat_quote', - 'sales/quote_address' => 'sales_flat_quote_address', - 'sales/quote_address_item' => 'sales_flat_quote_address_item', - 'sales/quote_address_shipping_rate' => 'sales_flat_quote_shipping_rate', - 'sales/quote_item' => 'sales_flat_quote_item', - 'sales/quote_item_option' => 'sales_flat_quote_item_option', - 'sales/quote_payment' => 'sales_flat_quote_payment', + 'sales/quote' => 'sales_quote', + 'sales/quote_address' => 'sales_quote_address', + 'sales/quote_address_item' => 'sales_quote_address_item', + 'sales/quote_address_shipping_rate' => 'sales_quote_shipping_rate', + 'sales/quote_item' => 'sales_quote_item', + 'sales/quote_item_option' => 'sales_quote_item_option', + 'sales/quote_payment' => 'sales_quote_payment', 'sales/recurring_payment' => 'recurring_payment', 'sales/recurring_payment_order' => 'recurring_payment_order', 'sales/refunded_aggregated' => 'sales_refunded_aggregated', 'sales/refunded_aggregated_order' => 'sales_refunded_aggregated_order', - 'sales/shipment' => 'sales_flat_shipment', - 'sales/shipment_comment' => 'sales_flat_shipment_comment', - 'sales/shipment_grid' => 'sales_flat_shipment_grid', - 'sales/shipment_item' => 'sales_flat_shipment_item', - 'sales/shipment_track' => 'sales_flat_shipment_track', + 'sales/shipment' => 'sales_shipment', + 'sales/shipment_comment' => 'sales_shipment_comment', + 'sales/shipment_grid' => 'sales_shipment_grid', + 'sales/shipment_item' => 'sales_shipment_item', + 'sales/shipment_track' => 'sales_shipment_track', 'sales/shipping_aggregated' => 'sales_shipping_aggregated', 'sales/shipping_aggregated_order' => 'sales_shipping_aggregated_order', 'sales_entity/order' => 'sales_order', diff --git a/dev/tools/Magento/Tools/View/Deployer.php b/dev/tools/Magento/Tools/View/Deployer.php index 2db6fbe0718..1ef9dad1c2a 100644 --- a/dev/tools/Magento/Tools/View/Deployer.php +++ b/dev/tools/Magento/Tools/View/Deployer.php @@ -47,8 +47,8 @@ class Deployer /** @var Version\StorageInterface */ private $versionStorage; - /** @var Version\GeneratorInterface */ - private $versionGenerator; + /** @var \Magento\Framework\Stdlib\DateTime */ + private $dateTime; /** @var \Magento\Framework\View\Asset\Repository */ private $assetRepo; @@ -68,21 +68,21 @@ class Deployer /** * @param Files $filesUtil * @param Deployer\Log $logger + * @param Version\StorageInterface $versionStorage + * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param bool $isDryRun - * @param \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage - * @param \Magento\Framework\App\View\Deployment\Version\GeneratorInterface $versionGenerator */ public function __construct( Files $filesUtil, Deployer\Log $logger, Version\StorageInterface $versionStorage, - Version\GeneratorInterface $versionGenerator, + \Magento\Framework\Stdlib\DateTime $dateTime, $isDryRun = false ) { $this->filesUtil = $filesUtil; $this->logger = $logger; $this->versionStorage = $versionStorage; - $this->versionGenerator = $versionGenerator; + $this->dateTime = $dateTime; $this->isDryRun = $isDryRun; } @@ -121,7 +121,7 @@ class Deployer } } } - $version = $this->versionGenerator->generate(); + $version = $this->dateTime->toTimestamp(true); $this->logger->logMessage("New version of deployed files: {$version}"); if (!$this->isDryRun) { $this->versionStorage->save($version); diff --git a/dev/tools/performance-toolkit/benchmark.jmx b/dev/tools/performance-toolkit/benchmark.jmx index 5a31d4e0c48..b6686c0670a 100644 --- a/dev/tools/performance-toolkit/benchmark.jmx +++ b/dev/tools/performance-toolkit/benchmark.jmx @@ -116,6 +116,36 @@ <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> + <elementProp name="jmeter_agent_port" elementType="Argument"> + <stringProp name="Argument.name">jmeter_agent_port</stringProp> + <stringProp name="Argument.value">${__P(jmeter_agent_port,3450)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="db_server_ip" elementType="Argument"> + <stringProp name="Argument.name">db_server_ip</stringProp> + <stringProp name="Argument.value">${__P(db_server_ip,10.62.51.150)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="web_server_1_ip" elementType="Argument"> + <stringProp name="Argument.name">web_server_1_ip</stringProp> + <stringProp name="Argument.value">${__P(web_server_1_ip,10.62.51.185)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="web_server_2_ip" elementType="Argument"> + <stringProp name="Argument.name">web_server_2_ip</stringProp> + <stringProp name="Argument.value">${__P(web_server_2_ip,10.62.51.186)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="performance_metrics_collector_file_name" elementType="Argument"> + <stringProp name="Argument.name">performance_metrics_collector_file_name</stringProp> + <stringProp name="Argument.value">${__P(performance_metrics_collector_file_name,performance_metrics_collector_file)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="response_time_file_name" elementType="Argument"> + <stringProp name="Argument.name">response_time_file_name</stringProp> + <stringProp name="Argument.value">${__P(response_time_file_name,response_time_file_name)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="TestPlan.user_define_classpath"></stringProp> @@ -2275,12 +2305,26 @@ vars.put("category_name", props.get("category_name"));</stri <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="method" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.name">method</stringProp> <stringProp name="Argument.value">guest</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -2300,6 +2344,15 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="HTTPSampler.embedded_url_re"></stringProp> </HTTPSamplerProxy> <hashTree> + <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> + <collectionProp name="HeaderManager.headers"> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Referer</stringProp> + <stringProp name="Header.value">http://mage2.com/checkout/onepage/</stringProp> + </elementProp> + </collectionProp> + </HeaderManager> + <hashTree/> <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert success" enabled="true"> <collectionProp name="Asserion.test_strings"> <stringProp name="2914">[]</stringProp> @@ -2310,35 +2363,6 @@ vars.put("category_name", props.get("category_name"));</stri </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to billing(GuestChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">billing</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding"></stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout billing addresses(GuestChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> @@ -2349,23 +2373,37 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[firstname]" elementType="HTTPArgument"> + <elementProp name="billing[city]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[firstname]</stringProp> - <stringProp name="Argument.value">Name</stringProp> + <stringProp name="Argument.name">billing[city]</stringProp> + <stringProp name="Argument.value">Culver City</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[lastname]" elementType="HTTPArgument"> + <elementProp name="billing[company]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[lastname]</stringProp> - <stringProp name="Argument.value">Lastname</stringProp> + <stringProp name="Argument.name">billing[company]</stringProp> + <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[company]" elementType="HTTPArgument"> + <elementProp name="billing[confirm_password]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[company]</stringProp> + <stringProp name="Argument.name">billing[confirm_password]</stringProp> + <stringProp name="Argument.value"></stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + </elementProp> + <elementProp name="billing[country_id]" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.name">billing[country_id]</stringProp> + <stringProp name="Argument.value">US</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + </elementProp> + <elementProp name="billing[customer_password]" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.name">billing[customer_password]</stringProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> @@ -2377,31 +2415,31 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[street][]" elementType="HTTPArgument"> + <elementProp name="billing[fax]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[street][]</stringProp> - <stringProp name="Argument.value">10441 Jefferson Blvd, ste 200</stringProp> + <stringProp name="Argument.name">billing[fax]</stringProp> + <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[street][]" elementType="HTTPArgument"> + <elementProp name="billing[firstname]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[street][]</stringProp> - <stringProp name="Argument.value"></stringProp> + <stringProp name="Argument.name">billing[firstname]</stringProp> + <stringProp name="Argument.value">Name</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[city]" elementType="HTTPArgument"> + <elementProp name="billing[lastname]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[city]</stringProp> - <stringProp name="Argument.value">Culver City</stringProp> + <stringProp name="Argument.name">billing[lastname]</stringProp> + <stringProp name="Argument.value">Lastname</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[region_id]" elementType="HTTPArgument"> + <elementProp name="billing[postcode]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[region_id]</stringProp> - <stringProp name="Argument.value">12</stringProp> + <stringProp name="Argument.name">billing[postcode]</stringProp> + <stringProp name="Argument.value">90232</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> @@ -2412,61 +2450,61 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[postcode]" elementType="HTTPArgument"> + <elementProp name="billing[region_id]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[postcode]</stringProp> - <stringProp name="Argument.value">90232</stringProp> + <stringProp name="Argument.name">billing[region_id]</stringProp> + <stringProp name="Argument.value">12</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[country_id]" elementType="HTTPArgument"> + <elementProp name="billing[save_in_address_book]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[country_id]</stringProp> - <stringProp name="Argument.value">US</stringProp> + <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">billing[save_in_address_book]</stringProp> </elementProp> - <elementProp name="billing[telephone]" elementType="HTTPArgument"> + <elementProp name="billing[street][]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[telephone]</stringProp> - <stringProp name="Argument.value">1-310-945-0345</stringProp> + <stringProp name="Argument.name">billing[street][]</stringProp> + <stringProp name="Argument.value">10441 Jefferson Blvd, ste 200</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[fax]" elementType="HTTPArgument"> + <elementProp name="billing[street][]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[fax]</stringProp> + <stringProp name="Argument.name">billing[street][]</stringProp> <stringProp name="Argument.value"></stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[customer_password]" elementType="HTTPArgument"> + <elementProp name="billing[telephone]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[customer_password]</stringProp> - <stringProp name="Argument.value"></stringProp> + <stringProp name="Argument.name">billing[telephone]</stringProp> + <stringProp name="Argument.value">1-310-945-0345</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[confirm_password]" elementType="HTTPArgument"> + <elementProp name="billing[use_for_shipping]" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[confirm_password]</stringProp> - <stringProp name="Argument.value"></stringProp> + <stringProp name="Argument.name">billing[use_for_shipping]</stringProp> + <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> - <elementProp name="billing[use_for_shipping]" elementType="HTTPArgument"> + <elementProp name="ajax" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">billing[use_for_shipping]</stringProp> <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> </elementProp> - <elementProp name="billing[save_in_address_book]" elementType="HTTPArgument"> + <elementProp name="isAjax" elementType="HTTPArgument"> <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">1</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">billing[save_in_address_book]</stringProp> + <stringProp name="Argument.name">isAjax</stringProp> </elementProp> </collectionProp> </elementProp> @@ -2487,6 +2525,15 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="HTTPSampler.embedded_url_re"></stringProp> </HTTPSamplerProxy> <hashTree> + <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> + <collectionProp name="HeaderManager.headers"> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Referer</stringProp> + <stringProp name="Header.value">http://mage2.com/checkout/onepage/</stringProp> + </elementProp> + </collectionProp> + </HeaderManager> + <hashTree/> <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert success" enabled="true"> <collectionProp name="Asserion.test_strings"> <stringProp name="-1549408881">"goto_section":"shipping_method"</stringProp> @@ -2497,45 +2544,30 @@ vars.put("category_name", props.get("category_name"));</stri </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to shipping method(GuestChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">shipping_method</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding"></stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout shipping method(GuestChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="shipping_method" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.name">shipping_method</stringProp> <stringProp name="Argument.value">flatrate_flatrate</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -2555,6 +2587,15 @@ vars.put("category_name", props.get("category_name"));</stri <stringProp name="HTTPSampler.embedded_url_re"></stringProp> </HTTPSamplerProxy> <hashTree> + <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> + <collectionProp name="HeaderManager.headers"> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Referer</stringProp> + <stringProp name="Header.value">http://mage2.com/checkout/onepage/</stringProp> + </elementProp> + </collectionProp> + </HeaderManager> + <hashTree/> <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"> <collectionProp name="Asserion.test_strings"> <stringProp name="-1344413285">"goto_section":"payment"</stringProp> @@ -2565,35 +2606,6 @@ vars.put("category_name", props.get("category_name"));</stri </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progressto payment(GuestChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">payment</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout payment method(GuestChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> @@ -2611,6 +2623,20 @@ vars.put("category_name", props.get("category_name"));</stri <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">form_key</stringProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -2640,53 +2666,38 @@ vars.put("category_name", props.get("category_name"));</stri </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to review(GuestChkt)" enabled="true"> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout place order(GuestChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">review</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout place order(GuestChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="payment[method]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.name">payment[method]</stringProp> - <stringProp name="Argument.value">checkmo</stringProp> + <elementProp name="payment[method]" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.name">payment[method]</stringProp> + <stringProp name="Argument.value">checkmo</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">${form_key}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">form_key</stringProp> <stringProp name="Argument.desc">false</stringProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -3306,28 +3317,28 @@ if (emailsCount < 1) { <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="context" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.name">context</stringProp> <stringProp name="Argument.value">checkout</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> <elementProp name="login[username]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">${customer_email}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">login[username]</stringProp> </elementProp> <elementProp name="login[password]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">${customer_password}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">login[password]</stringProp> </elementProp> <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">${form_key}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> @@ -3472,6 +3483,20 @@ if (emailsCount < 1) { <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">billing[save_in_address_book]</stringProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -3501,90 +3526,44 @@ if (emailsCount < 1) { </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout shipping method additional (CustomerChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"/> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/getAdditional/</stringProp> - <stringProp name="HTTPSampler.method">POST</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert success" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="-336696320"><!-- BLOCK shipping_method_additional --></stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to shipping method(CustomerChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">shipping_method</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding"></stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout shipping method(CustomerChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> <elementProp name="giftoptions[1496][type]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">quote_item</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">giftoptions[1496][type]</stringProp> </elementProp> <elementProp name="giftoptions[451][type]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">quote</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">giftoptions[451][type]</stringProp> </elementProp> <elementProp name="shipping_method" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.name">shipping_method</stringProp> <stringProp name="Argument.value">flatrate_flatrate</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -3614,35 +3593,6 @@ if (emailsCount < 1) { </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to payment(CustomerChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">payment</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout payment method(CustomerChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> @@ -3660,6 +3610,20 @@ if (emailsCount < 1) { <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">form_key</stringProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -3689,35 +3653,6 @@ if (emailsCount < 1) { </ResponseAssertion> <hashTree/> </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout progress to review(CustomerChkt)" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="toStep" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> - <stringProp name="Argument.value">review</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toStep</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"></stringProp> - <stringProp name="HTTPSampler.port"></stringProp> - <stringProp name="HTTPSampler.connect_timeout"></stringProp> - <stringProp name="HTTPSampler.response_timeout"></stringProp> - <stringProp name="HTTPSampler.protocol">http</stringProp> - <stringProp name="HTTPSampler.contentEncoding">UTF-8</stringProp> - <stringProp name="HTTPSampler.path">${base_path}checkout/onepage/progress/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"></stringProp> - </HTTPSamplerProxy> - <hashTree/> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout place order(CustomerChkt)" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> @@ -3729,13 +3664,27 @@ if (emailsCount < 1) { <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">false</boolProp> + <boolProp name="HTTPArgument.always_encode">true</boolProp> <stringProp name="Argument.value">${form_key}</stringProp> <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> <stringProp name="Argument.name">form_key</stringProp> <stringProp name="Argument.desc">false</stringProp> </elementProp> + <elementProp name="ajax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">ajax</stringProp> + </elementProp> + <elementProp name="isAjax" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">true</boolProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">isAjax</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> @@ -4571,6 +4520,148 @@ props.remove("customer_emails_list");</stringProp> <stringProp name="exclude_sample_labels"></stringProp> </kg.apc.jmeter.vizualizers.CorrectedResultCollector> <hashTree/> + <kg.apc.jmeter.perfmon.PerfMonCollector guiclass="kg.apc.jmeter.vizualizers.PerfMonGui" testclass="kg.apc.jmeter.perfmon.PerfMonCollector" testname="Performance Metrics Collector" enabled="true"> + <boolProp name="ResultCollector.error_logging">false</boolProp> + <objProp> + <name>saveConfig</name> + <value class="SampleSaveConfiguration"> + <time>true</time> + <latency>true</latency> + <timestamp>true</timestamp> + <success>true</success> + <label>true</label> + <code>true</code> + <message>true</message> + <threadName>true</threadName> + <dataType>true</dataType> + <encoding>false</encoding> + <assertions>true</assertions> + <subresults>true</subresults> + <responseData>false</responseData> + <samplerData>false</samplerData> + <xml>false</xml> + <fieldNames>false</fieldNames> + <responseHeaders>false</responseHeaders> + <requestHeaders>false</requestHeaders> + <responseDataOnError>false</responseDataOnError> + <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage> + <assertionsResultsToSave>0</assertionsResultsToSave> + <bytes>true</bytes> + </value> + </objProp> + <stringProp name="filename">${performance_metrics_collector_file_name}</stringProp> + <longProp name="interval_grouping">1000</longProp> + <boolProp name="graph_aggregated">false</boolProp> + <stringProp name="include_sample_labels"></stringProp> + <stringProp name="exclude_sample_labels"></stringProp> + <collectionProp name="metricConnections"> + <collectionProp name="-837026933"> + <stringProp name="430480420">${db_server_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="66952">CPU</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="1157226042"> + <stringProp name="430480420">${db_server_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="-1993889503">Memory</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="757813414"> + <stringProp name="430480420">${db_server_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="541420523">unit=kb:readbytes</stringProp> + </collectionProp> + <collectionProp name="1511609822"> + <stringProp name="816265486">${web_server_1_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="66952">CPU</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="-789104499"> + <stringProp name="816265486">${web_server_1_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="-1993889503">Memory</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="-1188517127"> + <stringProp name="816265486">${web_server_1_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="541420523">unit=kb:readbytes</stringProp> + </collectionProp> + <collectionProp name="840790980"> + <stringProp name="817189007">${web_server_2_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="66952">CPU</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="-1459923341"> + <stringProp name="817189007">${web_server_2_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="-1993889503">Memory</stringProp> + <stringProp name="0"></stringProp> + </collectionProp> + <collectionProp name="-1859335969"> + <stringProp name="817189007">${web_server_2_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="541420523">unit=kb:readbytes</stringProp> + </collectionProp> + <collectionProp name="1158424422"> + <stringProp name="430480420">${db_server_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="-962924714">unit=kb:writebytes</stringProp> + </collectionProp> + <collectionProp name="-787906119"> + <stringProp name="816265486">${web_server_1_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="-962924714">unit=kb:writebytes</stringProp> + </collectionProp> + <collectionProp name="-1458724961"> + <stringProp name="817189007">${web_server_2_ip}</stringProp> + <stringProp name="2061224089">${jmeter_agent_port}</stringProp> + <stringProp name="2112896831">Disks I/O</stringProp> + <stringProp name="-962924714">unit=kb:writebytes</stringProp> + </collectionProp> + </collectionProp> + </kg.apc.jmeter.perfmon.PerfMonCollector> + <hashTree/> + <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Response Time" enabled="true"> + <boolProp name="ResultCollector.error_logging">false</boolProp> + <objProp> + <name>saveConfig</name> + <value class="SampleSaveConfiguration"> + <time>true</time> + <latency>true</latency> + <timestamp>true</timestamp> + <success>true</success> + <label>true</label> + <code>true</code> + <message>true</message> + <threadName>true</threadName> + <dataType>true</dataType> + <encoding>false</encoding> + <assertions>true</assertions> + <subresults>true</subresults> + <responseData>false</responseData> + <samplerData>false</samplerData> + <xml>true</xml> + <fieldNames>false</fieldNames> + <responseHeaders>false</responseHeaders> + <requestHeaders>false</requestHeaders> + <responseDataOnError>false</responseDataOnError> + <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage> + <assertionsResultsToSave>0</assertionsResultsToSave> + <bytes>true</bytes> + </value> + </objProp> + <stringProp name="filename">${response_time_file_name}</stringProp> + </ResultCollector> + <hashTree/> </hashTree> </hashTree> </jmeterTestPlan> diff --git a/dev/tools/performance-toolkit/fixtures/eav_variations.php b/dev/tools/performance-toolkit/fixtures/eav_variations.php index 1b5ce595984..0dd001ff26a 100644 --- a/dev/tools/performance-toolkit/fixtures/eav_variations.php +++ b/dev/tools/performance-toolkit/fixtures/eav_variations.php @@ -96,3 +96,9 @@ $model->setAttributeSetId(ATTRIBUTE_SET_ID) $model->setAttributeSetId(ATTRIBUTE_SET_ID); $model->save(); + +/* @var $cache \Magento\Framework\App\CacheInterface */ +$cache = $this->getObjectManager()->get('Magento\Framework\App\CacheInterface'); + +$cacheKey = \Magento\Eav\Model\Config::ATTRIBUTES_CACHE_ID . \Magento\Catalog\Model\Product::ENTITY; +$cache->remove($cacheKey); diff --git a/dev/tools/performance-toolkit/fixtures/stores.php b/dev/tools/performance-toolkit/fixtures/stores.php index 9c958b7d363..bc9a50c8a42 100644 --- a/dev/tools/performance-toolkit/fixtures/stores.php +++ b/dev/tools/performance-toolkit/fixtures/stores.php @@ -55,13 +55,14 @@ for ($i = 0; $i < $websitesCount; $i++) { $websiteId = $defaultWebsiteId; } $website = clone $defaultWebsite; - $websiteCode = sprintf('website_%d', $i+1); - $websiteName = sprintf('Website %d', $i+1); + $websiteCode = sprintf('website_%d', $i + 1); + $websiteName = sprintf('Website %d', $i + 1); $website->addData( array( - 'website_id' => $websiteId, - 'code' => $websiteCode, - 'name' => $websiteName + 'website_id' => $websiteId, + 'code' => $websiteCode, + 'name' => $websiteName, + 'is_default' => (int)$i == 0, ) ); $website->save(); @@ -77,7 +78,7 @@ for ($i = 0; $i < $storeGroupsCount; $i++) { $parentCategoryId = null; $categoryPath = '1'; - $storeGroupName = sprintf('Store Group %d - website_id_%d', $i+1, $websiteId); + $storeGroupName = sprintf('Store Group %d - website_id_%d', $i + 1, $websiteId); if ($i == 0 && $websiteId == $defaultWebsiteId) { $groupId = $defaultStoreGroupId; @@ -124,8 +125,8 @@ for ($i = 0; $i < $storesCount; $i++) { $storeId = $defaultStoreViewId; } $store = clone $defaultStoreView; - $storeCode = sprintf('store_view_%d_w_%d_g_%d', $i+1, $websiteId, $groupId); - $storeName = sprintf('Store view %d - website_id_%d - group_id_%d', $i+1, $websiteId, $groupId); + $storeCode = sprintf('store_view_%d_w_%d_g_%d', $i + 1, $websiteId, $groupId); + $storeName = sprintf('Store view %d - website_id_%d - group_id_%d', $i + 1, $websiteId, $groupId); $store->addData( array( 'store_id' => $storeId, diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php index cbaf3b9e39a..f9f8fa97e96 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php +++ b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php @@ -34,7 +34,7 @@ class Application /** * Area code */ - const AREA_CODE = 'install'; + const AREA_CODE = 'adminhtml'; /** * Application object @@ -186,6 +186,7 @@ class Application public function resetObjectManager() { $this->_objectManager = null; + $this->bootstrap(); return $this; } } diff --git a/dev/tools/performance-toolkit/framework/labels.xml b/dev/tools/performance-toolkit/framework/labels.xml index 6aa5360ebb6..585a2782c96 100644 --- a/dev/tools/performance-toolkit/framework/labels.xml +++ b/dev/tools/performance-toolkit/framework/labels.xml @@ -33,6 +33,6 @@ <categories>Categories</categories> <catalog_price_rules>Catalog Price Rules</catalog_price_rules> <cart_price_rules>Cart Price Rules</cart_price_rules> - <customers>Regitered Customers</customers> + <customers>Registered Customers</customers> </labels> </config> diff --git a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php index 6281d9a6425..ffff1e55e19 100644 --- a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php +++ b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php @@ -40,23 +40,23 @@ abstract class AbstractExtensibleObject extends AbstractSimpleObject implements * Get an attribute value. * * @param string $attributeCode - * @return \Magento\Framework\Api\AttributeValue|null null if the attribute has not been set + * @return \Magento\Framework\Api\AttributeInterface|null null if the attribute has not been set */ public function getCustomAttribute($attributeCode) { - return isset($this->_data[self::CUSTOM_ATTRIBUTES_KEY]) - && isset($this->_data[self::CUSTOM_ATTRIBUTES_KEY][$attributeCode]) - ? $this->_data[self::CUSTOM_ATTRIBUTES_KEY][$attributeCode] + return isset($this->_data[self::CUSTOM_ATTRIBUTES]) + && isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]) + ? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] : null; } /** * Retrieve custom attributes values. * - * @return \Magento\Framework\Api\AttributeValue[]|null + * @return \Magento\Framework\Api\AttributeInterface[]|null */ public function getCustomAttributes() { - return isset($this->_data[self::CUSTOM_ATTRIBUTES_KEY]) ? $this->_data[self::CUSTOM_ATTRIBUTES_KEY] : array(); + return isset($this->_data[self::CUSTOM_ATTRIBUTES]) ? $this->_data[self::CUSTOM_ATTRIBUTES] : []; } } diff --git a/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php index bb6c00ef7b8..bf6dea476f8 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php @@ -24,11 +24,6 @@ namespace Magento\Framework\Api; -use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\ObjectFactory; - /** * Builder for the SearchResults Service Data Object * @@ -46,7 +41,7 @@ abstract class AbstractSearchResultsBuilder extends ExtensibleObjectBuilder /** * Item data object builder * - * @var ExtensibleObjectBuilder $itemObjectBuilder + * @var BuilderInterface $itemObjectBuilder */ protected $itemObjectBuilder; @@ -54,17 +49,17 @@ abstract class AbstractSearchResultsBuilder extends ExtensibleObjectBuilder * Constructor * * @param ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param SearchCriteriaBuilder $searchCriteriaBuilder - * @param ExtensibleObjectBuilder $itemObjectBuilder + * @param BuilderInterface $itemObjectBuilder */ public function __construct( ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, SearchCriteriaBuilder $searchCriteriaBuilder, - ExtensibleObjectBuilder $itemObjectBuilder + BuilderInterface $itemObjectBuilder ) { parent::__construct($objectFactory, $valueBuilder, $metadataService); $this->searchCriteriaBuilder = $searchCriteriaBuilder; diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php index 5910f4db1ce..d34e48b4e19 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php @@ -37,9 +37,9 @@ abstract class AbstractSimpleObject /** * Initialize internal storage * - * @param AbstractSimpleObjectBuilder $builder + * @param SimpleBuilderInterface $builder */ - public function __construct(AbstractSimpleObjectBuilder $builder) + public function __construct(SimpleBuilderInterface $builder) { $this->_data = $builder->getData(); } diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index 1b025c16317..1ea3f9428d2 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -27,7 +27,7 @@ namespace Magento\Framework\Api; * Base Builder Class for simple data Objects * @SuppressWarnings(PHPMD.NumberOfChildren) */ -abstract class AbstractSimpleObjectBuilder +abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface { /** * @var array @@ -48,37 +48,6 @@ abstract class AbstractSimpleObjectBuilder $this->objectFactory = $objectFactory; } - /** - * Populates the fields with an existing entity. - * - * @param AbstractSimpleObject $prototype the prototype to base on - * @return $this - * @throws \LogicException If $prototype object class is not the same type as object that is constructed - */ - public function populate(AbstractSimpleObject $prototype) - { - $objectType = $this->_getDataObjectType(); - if (!($prototype instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - return $this->populateWithArray($prototype->__toArray()); - } - - /** - * Populates the fields with data from the array. - * - * Keys for the map are snake_case attribute/field names. - * - * @param array $data - * @return $this - */ - public function populateWithArray(array $data) - { - $this->data = array(); - $this->_setDataValues($data); - return $this; - } - /** * Initializes Data Object with the data from array * @@ -101,46 +70,6 @@ abstract class AbstractSimpleObjectBuilder return $this; } - /** - * Merge second Data Object data with first Data Object data and create new Data Object object based on merge - * result. - * - * @param AbstractSimpleObject $firstDataObject - * @param AbstractSimpleObject $secondDataObject - * @return AbstractSimpleObject - * @throws \LogicException - */ - public function mergeDataObjects(AbstractSimpleObject $firstDataObject, AbstractSimpleObject $secondDataObject) - { - $objectType = $this->_getDataObjectType(); - if (get_class($firstDataObject) != $objectType || get_class($secondDataObject) != $objectType) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $this->_setDataValues($firstDataObject->__toArray()); - $this->_setDataValues($secondDataObject->__toArray()); - return $this->create(); - } - - /** - * Merged data provided in array format with Data Object data and create new Data Object object based on merge - * result. - * - * @param AbstractSimpleObject $dataObject - * @param array $data - * @return AbstractSimpleObject - * @throws \LogicException - */ - public function mergeDataObjectWithArray(AbstractSimpleObject $dataObject, array $data) - { - $objectType = $this->_getDataObjectType(); - if (!($dataObject instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $this->_setDataValues($dataObject->__toArray()); - $this->_setDataValues($data); - return $this->create(); - } - /** * Builds the Data Object * diff --git a/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php b/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php index 11bb7df9639..1acde511030 100644 --- a/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php +++ b/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php @@ -26,7 +26,7 @@ namespace Magento\Framework\Api; /** * Custom Attribute Data object builder */ -class AttributeDataBuilder extends CompositeExtensibleDataBuilder +class AttributeDataBuilder extends AbstractSimpleObjectBuilder { /** * Set attribute code @@ -36,7 +36,7 @@ class AttributeDataBuilder extends CompositeExtensibleDataBuilder */ public function setAttributeCode($attributeCode) { - return $this->set(AttributeInterface::ATTRIBUTE_CODE, $attributeCode); + return $this->_set(AttributeValue::ATTRIBUTE_CODE, $attributeCode); } /** @@ -47,26 +47,16 @@ class AttributeDataBuilder extends CompositeExtensibleDataBuilder */ public function setValue($value) { - return $this->set(AttributeInterface::VALUE, $value); + return $this->_set(AttributeValue::VALUE, $value); } /** - * Initialize the builder + * Return the Data type class name * - * @param \Magento\Framework\ObjectManager $objectManager - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\ObjectManager\Config $objectManagerConfig + * @return string */ - public function __construct( - \Magento\Framework\ObjectManager $objectManager, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\ObjectManager\Config $objectManagerConfig - ) { - parent::__construct( - $objectManager, - $metadataService, - $objectManagerConfig, - 'Magento\Framework\Api\AttributeInterface' - ); + protected function _getDataObjectType() + { + return '\Magento\Framework\Api\AttributeValue'; } } diff --git a/lib/internal/Magento/Framework/Api/AttributeValue.php b/lib/internal/Magento/Framework/Api/AttributeValue.php index d2c95712568..a7a2f0e8684 100644 --- a/lib/internal/Magento/Framework/Api/AttributeValue.php +++ b/lib/internal/Magento/Framework/Api/AttributeValue.php @@ -24,13 +24,22 @@ namespace Magento\Framework\Api; -use Magento\Framework\Api\AttributeInterface; - /** * Custom Attribute Data object */ class AttributeValue extends AbstractSimpleObject implements AttributeInterface { + + /** + * Initialize internal storage + * + * @param AttributeDataBuilder $builder + */ + public function __construct(AttributeDataBuilder $builder) + { + $this->_data = $builder->getData(); + } + /** * Get attribute code * diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataBuilder.php b/lib/internal/Magento/Framework/Api/Builder.php similarity index 50% rename from lib/internal/Magento/Framework/Api/ExtensibleDataBuilder.php rename to lib/internal/Magento/Framework/Api/Builder.php index 229e95ee06c..3d77405ca30 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataBuilder.php +++ b/lib/internal/Magento/Framework/Api/Builder.php @@ -24,15 +24,18 @@ namespace Magento\Framework\Api; -use Magento\Framework\Api\ExtensibleDataBuilderInterface; -use Magento\Framework\Model\AbstractExtensibleModel; -use Magento\Framework\ObjectManager; - /** - * Implementation for \Magento\Framework\Api\ExtensibleDataBuilderInterface. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface +class Builder implements BuilderInterface { + /**#@+ + * Constant which defines if builder is created for building data objects or data models. + */ + const TYPE_DATA_OBJECT = 'data_object'; + const TYPE_DATA_MODEL = 'data_model'; + /**#@-*/ + /** * @var string */ @@ -44,9 +47,9 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface protected $data; /** - * @var ObjectManager + * @var ObjectFactory */ - protected $objectManager; + protected $objectFactory; /** * @var MetadataServiceInterface @@ -84,32 +87,38 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface protected $dataBuilderFactory; /** - * Initialize the builder - * - * @param ObjectManager $objectManager + * @var \Magento\Framework\ObjectManager\Config + */ + protected $objectManagerConfig; + + /** + * @param ObjectFactory $objectFactory * @param MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder + * @param AttributeDataBuilder $attributeValueBuilder * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory + * @param \Magento\Framework\ObjectManager\Config $objectManagerConfig * @param string $modelClassInterface */ public function __construct( - ObjectManager $objectManager, + ObjectFactory $objectFactory, MetadataServiceInterface $metadataService, \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder, \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, \Magento\Framework\Reflection\TypeProcessor $typeProcessor, \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - $modelClassInterface + \Magento\Framework\ObjectManager\Config $objectManagerConfig, + $modelClassInterface = null ) { - $this->objectManager = $objectManager; + $this->objectFactory = $objectFactory; $this->metadataService = $metadataService; $this->modelClassInterface = $modelClassInterface; $this->objectProcessor = $objectProcessor; $this->attributeValueBuilder = $attributeValueBuilder; $this->typeProcessor = $typeProcessor; $this->dataBuilderFactory = $dataBuilderFactory; + $this->objectManagerConfig = $objectManagerConfig; } /** @@ -117,12 +126,15 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface */ public function setCustomAttribute($attributeCode, $attributeValue) { - $attribute = $this->attributeValueBuilder - ->setAttributeCode($attributeCode) - ->setValue($attributeValue) - ->create(); - // Store as an associative array for easier lookup and processing - $this->data[AbstractExtensibleModel::CUSTOM_ATTRIBUTES_KEY][$attributeCode] = $attribute; + $customAttributesCodes = $this->getCustomAttributesCodes(); + if (in_array($attributeCode, $customAttributesCodes)) { + $attribute = $this->attributeValueBuilder + ->setAttributeCode($attributeCode) + ->setValue($attributeValue) + ->create(); + //Stores as an associative array for easier lookup and processing + $this->data[ExtensibleDataInterface::CUSTOM_ATTRIBUTES][$attributeCode] = $attribute; + } return $this; } @@ -131,9 +143,16 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface */ public function setCustomAttributes(array $attributes) { + $customAttributesCodes = $this->getCustomAttributesCodes(); /** @var \Magento\Framework\Api\AttributeInterface $attribute */ foreach ($attributes as $attribute) { - $this->data[AbstractExtensibleModel::CUSTOM_ATTRIBUTES_KEY][$attribute->getAttributeCode()] = $attribute; + if (!$attribute instanceof AttributeValue) { + throw new \LogicException('Custom Attribute array elements can only be type of AttributeValue'); + } + $attributeCode = $attribute->getAttributeCode(); + if (in_array($attributeCode, $customAttributesCodes)) { + $this->data[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY][$attributeCode] = $attribute; + } } return $this; } @@ -143,19 +162,24 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface */ public function create() { - return $this->objectManager->create( - $this->modelClassInterface, - ['data' => $this->data] - ); + if ($this->getDataType() == self::TYPE_DATA_MODEL) { + $dataObject = $this->objectFactory->create( + $this->_getDataObjectType(), + ['data' => $this->data] + ); + } else { + $dataObjectType = $this->_getDataObjectType(); + $dataObject = $this->objectFactory->create( + $dataObjectType, + ['builder' => $this] + ); + } + $this->data = array(); + return $dataObject; } /** - * Populates the fields with data from the array. - * - * Keys for the map are snake_case attribute/field names. - * - * @param array $data - * @return $this + * {@inheritdoc} */ public function populateWithArray(array $data) { @@ -164,6 +188,106 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface return $this; } + /** + * {@inheritdoc} + */ + public function populate(ExtensibleDataInterface $prototype) + { + $objectType = $this->_getDataObjectType(); + if (!($prototype instanceof $objectType)) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + $prototypeArray = $this->objectProcessor->buildOutputDataArray($prototype, $objectType); + return $this->populateWithArray($prototypeArray); + } + + /** + * {@inheritdoc} + */ + public function mergeDataObjects( + ExtensibleDataInterface $firstDataObject, + ExtensibleDataInterface $secondDataObject + ) { + $objectType = $this->_getDataObjectType(); + if (get_class($firstDataObject) != $objectType || get_class($secondDataObject) != $objectType) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + $firstObjectArray = $this->objectProcessor->buildOutputDataArray($firstDataObject, $objectType); + $secondObjectArray = $this->objectProcessor->buildOutputDataArray($secondDataObject, $objectType); + $this->_setDataValues($firstObjectArray); + $this->_setDataValues($secondObjectArray); + return $this; + } + + /** + * {@inheritdoc} + */ + public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data) + { + $objectType = $this->_getDataObjectType(); + if (!($dataObject instanceof $objectType)) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + $dataArray = $this->objectProcessor->buildOutputDataArray($dataObject, $objectType); + $this->_setDataValues($dataArray); + $this->_setDataValues($data); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getData() + { + return $this->data; + } + + /** + * @param string $key + * @param mixed $value + * + * @return $this + */ + protected function _set($key, $value) + { + $this->data[$key] = $value; + return $this; + } + + /** + * Identify type of objects which should be built with generated builder. Value can be one of self::TYPE_DATA_*. + * + * @return string + * @throws \LogicException + */ + protected function getDataType() + { + $dataType = $this->_getDataObjectType(); + if (is_subclass_of($dataType, '\Magento\Framework\Api\AbstractSimpleObject')) { + return self::TYPE_DATA_OBJECT; + } else if (is_subclass_of($dataType, '\Magento\Framework\Model\AbstractExtensibleModel')) { + return self::TYPE_DATA_MODEL; + } + + $sourceClassPreference = $this->objectManagerConfig->getPreference($dataType); + if (empty($sourceClassPreference)) { + throw new \LogicException( + "Preference for {$this->_getDataObjectType()} is not defined." + ); + } + + if (is_subclass_of($sourceClassPreference, '\Magento\Framework\Api\AbstractSimpleObject')) { + return self::TYPE_DATA_OBJECT; + } else if (is_subclass_of($sourceClassPreference, '\Magento\Framework\Model\AbstractExtensibleModel')) { + return self::TYPE_DATA_MODEL; + } else { + throw new \LogicException( + 'Preference of ' . $this->_getDataObjectType() + . ' must extend from AbstractSimpleObject or AbstractExtensibleModel' + ); + } + } + /** * Template method used to configure the attribute codes for the custom attributes * @@ -177,7 +301,7 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface $attributeCodes = []; /** @var \Magento\Framework\Api\MetadataObjectInterface[] $customAttributesMetadata */ $customAttributesMetadata = $this->metadataService - ->getCustomAttributesMetadata($this->modelClassInterface); + ->getCustomAttributesMetadata($this->_getDataObjectType()); if (is_array($customAttributesMetadata)) { foreach ($customAttributesMetadata as $attribute) { $attributeCodes[] = $attribute->getAttributeCode(); @@ -187,20 +311,6 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface return $attributeCodes; } - /** - * Set data item value. - * - * @param string $key - * @param mixed $value - * @return $this - * @deprecated This method should not be used in the client code and will be removed after Service Layer refactoring - */ - public function set($key, $value) - { - $this->data[$key] = $value; - return $this; - } - /** * Initializes Data Object with the data from array * @@ -209,7 +319,7 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface */ protected function _setDataValues(array $data) { - $dataObjectMethods = get_class_methods($this->modelClassInterface); + $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\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); @@ -217,14 +327,14 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface 'get' . $camelCaseKey, 'is' . $camelCaseKey ); - if ($key == AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY + if ($key === ExtensibleDataInterface::CUSTOM_ATTRIBUTES && is_array($data[$key]) && !empty($data[$key]) ) { foreach ($data[$key] as $customAttribute) { $this->setCustomAttribute( - $customAttribute[AttributeValue::ATTRIBUTE_CODE], - $customAttribute[AttributeValue::VALUE] + $customAttribute[AttributeInterface::ATTRIBUTE_CODE], + $customAttribute[AttributeInterface::VALUE] ); } } elseif ($methodName = array_intersect($possibleMethods, $dataObjectMethods)) { @@ -249,7 +359,7 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface */ protected function setComplexValue($methodName, $key, array $value) { - $returnType = $this->objectProcessor->getMethodReturnType($this->modelClassInterface, $methodName); + $returnType = $this->objectProcessor->getMethodReturnType($this->_getDataObjectType(), $methodName); if ($this->typeProcessor->isTypeSimple($returnType)) { $this->data[$key] = $value; return $this; @@ -273,4 +383,25 @@ class ExtensibleDataBuilder implements ExtensibleDataBuilderInterface $this->data[$key] = $object; return $this; } + + /** + * Get data object type based on suffix + * + * @return string + */ + protected function _getDataObjectType() + { + if ($this->modelClassInterface) { + return $this->modelClassInterface; + } + $currentClass = get_class($this); + $dataBuilderSuffix = 'DataBuilder'; + if (substr($currentClass, -strlen($dataBuilderSuffix)) === $dataBuilderSuffix) { + $dataObjectType = substr($currentClass, 0, -strlen($dataBuilderSuffix)) . 'Interface'; + } else { + $builderSuffix = 'Builder'; + $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix)); + } + return $dataObjectType; + } } diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataBuilderInterface.php b/lib/internal/Magento/Framework/Api/BuilderInterface.php similarity index 60% rename from lib/internal/Magento/Framework/Api/ExtensibleDataBuilderInterface.php rename to lib/internal/Magento/Framework/Api/BuilderInterface.php index d7de617e06e..58f730c6404 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataBuilderInterface.php +++ b/lib/internal/Magento/Framework/Api/BuilderInterface.php @@ -24,10 +24,7 @@ namespace Magento\Framework\Api; -/** - * Base builder interface for \Magento\Framework\Api\ExtensibleDataInterface types. - */ -interface ExtensibleDataBuilderInterface +interface BuilderInterface extends SimpleBuilderInterface { /** * Set custom attribute value. @@ -48,7 +45,7 @@ interface ExtensibleDataBuilderInterface public function setCustomAttributes(array $attributes); /** - * Return created DataInterface object + * Return created ExtensibleDataInterface object * * @return \Magento\Framework\Api\ExtensibleDataInterface */ @@ -63,4 +60,36 @@ interface ExtensibleDataBuilderInterface * @return $this */ public function populateWithArray(array $data); + + /** + * Populates the fields with an existing entity. + * + * @param ExtensibleDataInterface $prototype the prototype to base on + * @return $this + * @throws \LogicException If $prototype object class is not the same type as object that is constructed + */ + public function populate(ExtensibleDataInterface $prototype); + + /** + * Populate builder with the two data interfaces, merging them + * + * @param ExtensibleDataInterface $firstDataObject + * @param ExtensibleDataInterface $secondDataObject + * @return $this + * @throws \LogicException + */ + public function mergeDataObjects( + ExtensibleDataInterface $firstDataObject, + ExtensibleDataInterface $secondDataObject + ); + + /** + * Populate builder with the data interface and array, merging them + * + * @param ExtensibleDataInterface $dataObject + * @param array $data + * @return $this + * @throws \LogicException + */ + public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data); } diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/Builder.php b/lib/internal/Magento/Framework/Api/Code/Generator/Builder.php deleted file mode 100644 index 76928c8432c..00000000000 --- a/lib/internal/Magento/Framework/Api/Code/Generator/Builder.php +++ /dev/null @@ -1,158 +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. - * - * @category Magento - * @package Magento_Code - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Framework\Api\Code\Generator; - -use Magento\Framework\Code\Generator\EntityAbstract; - -/** - * Class Builder - * - * @deprecated Use DataBuilder instead - */ -class Builder extends EntityAbstract -{ - /** - * Entity type - */ - const ENTITY_TYPE = 'builder'; - - /** - * Retrieve class properties - * - * @return array - */ - protected function _getClassProperties() - { - return []; - } - - /** - * Get default constructor definition for generated class - * - * @return array - */ - protected function _getDefaultConstructorDefinition() - { - return []; - } - - /** - * Return a list of methods for class generator - * - * @return array - */ - protected function _getClassMethods() - { - $methods = []; - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); - $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if (!($method->isConstructor() || - $method->isFinal() || - $method->isStatic() || - $method->isDestructor()) && - !in_array( - $method->getName(), - array('__sleep', '__wakeup', '__clone') - ) && - $method->class !== 'Magento\Framework\Api\AbstractExtensibleObject' - ) { - if (substr($method->getName(), 0, 3) == 'get') { - $methods[] = $this->_getMethodInfo($reflectionClass, $method); - } - - } - } - return $methods; - } - - /** - * Retrieve method info - * - * @param \ReflectionClass $class - * @param \ReflectionMethod $method - * @return array - */ - protected function _getMethodInfo(\ReflectionClass $class, \ReflectionMethod $method) - { - $methodInfo = [ - 'name' => 'set' . substr($method->getName(), 3), - 'parameters' => [ - ['name' => lcfirst(substr($method->getName(), 3))] - ], - 'body' => "return \$this->_set(" - . '\\' . $class->getName() . "::" - . strtoupper(preg_replace('/(.)([A-Z])/', "$1_$2", substr($method->getName(), 3))) - . ", \$" . lcfirst(substr($method->getName(), 3)) . ");", - 'docblock' => array('shortDescription' => '{@inheritdoc}') - ]; - - return $methodInfo; - } - - /** - * Validate data - * - * @return bool - */ - protected function _validateData() - { - $result = parent::_validateData(); - - if ($result) { - $sourceClassName = $this->_getSourceClassName(); - $resultClassName = $this->_getResultClassName(); - - if ($resultClassName !== $sourceClassName . 'Builder') { - $this->_addError( - 'Invalid Builder class name [' . $resultClassName . ']. Use ' . $sourceClassName . 'Builder' - ); - $result = false; - } - } - return $result; - } - - /** - * Generate code - * - * @return string - */ - protected function _generateCode() - { - $this->_classGenerator->setName( - $this->_getResultClassName() - )->addProperties( - $this->_getClassProperties() - )->addMethods( - $this->_getClassMethods() - )->setClassDocBlock( - $this->_getClassDocBlock() - )->setExtendedClass('\\Magento\Framework\Api\ExtensibleObjectBuilder'); - - return $this->_getGeneratedCode(); - } -} diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php b/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php index 2bb68f6c98c..1dcb973cbd1 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php @@ -37,10 +37,15 @@ use Zend\Code\Reflection\ClassReflection; class DataBuilder extends EntityAbstract { /** - * Entity type + * Builder Entity, used for a builders built based on Data Objects */ const ENTITY_TYPE = 'dataBuilder'; + /** + * Builder Entity, used for a builders built based on API interfaces + */ + const ENTITY_TYPE_BUILDER = 'builder'; + /** * Data Model property name */ @@ -102,30 +107,60 @@ class DataBuilder extends EntityAbstract protected function _getDefaultConstructorDefinition() { $constructorDefinition = [ - 'name' => '__construct', - 'parameters' => [ - ['name' => 'objectManager', 'type' => '\Magento\Framework\ObjectManager'], - ['name' => 'metadataService', 'type' => '\Magento\Framework\Api\MetadataServiceInterface'], - ['name' => 'objectManagerConfig', 'type' => '\Magento\Framework\ObjectManager\Config'], - ], - 'docblock' => [ - 'shortDescription' => 'Initialize the builder', - 'tags' => [ - [ - 'name' => 'param', - 'description' => '\Magento\Framework\ObjectManager $objectManager' - ], + 'name' => '__construct', + 'parameters' => [ + ['name' => 'objectFactory', 'type' => '\Magento\Framework\Api\ObjectFactory'], + ['name' => 'metadataService', 'type' => '\Magento\Framework\Api\MetadataServiceInterface'], + ['name' => 'attributeValueBuilder', 'type' => '\Magento\Framework\Api\AttributeDataBuilder'], + ['name' => 'objectProcessor', 'type' => '\Magento\Framework\Reflection\DataObjectProcessor'], + ['name' => 'typeProcessor', 'type' => '\Magento\Framework\Reflection\TypeProcessor'], + ['name' => 'dataBuilderFactory', 'type' => '\Magento\Framework\Serialization\DataBuilderFactory'], + ['name' => 'objectManagerConfig', 'type' => '\Magento\Framework\ObjectManager\Config'], [ - 'name' => 'param', - 'description' => '\Magento\Framework\Api\MetadataServiceInterface $metadataService' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\ObjectManager\Config $objectManagerConfig' + 'name' => 'modelClassInterface', + 'type' => 'string', + 'defaultValue' => $this->_getNullDefaultValue() ] - ] - ], - 'body' => "parent::__construct(\$objectManager, \$metadataService, \$objectManagerConfig, " + ], + 'docblock' => [ + 'shortDescription' => 'Initialize the builder', + 'tags' => [ + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Api\ObjectFactory $objectFactory' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Api\MetadataServiceInterface $metadataService' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Reflection\DataObjectProcessor $objectProcessor' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Reflection\TypeProcessor $typeProcessor' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory' + ], + [ + 'name' => 'param', + 'description' => '\Magento\Framework\ObjectManager\Config $objectManagerConfig' + ], + [ + 'name' => 'param', + 'description' => 'string|null $modelClassInterface' + ] + ] + ], + 'body' => "parent::__construct(\$objectFactory, \$metadataService, \$attributeValueBuilder, " + . "\$objectProcessor, \$typeProcessor, \$dataBuilderFactory, \$objectManagerConfig, " . "'{$this->_getSourceClassName()}');" ]; return $constructorDefinition; @@ -162,7 +197,7 @@ class DataBuilder extends EntityAbstract */ protected function canUseMethodForGeneration($method) { - $isGetter = (substr($method->getName(), 0, 3) == 'get'); + $isGetter = substr($method->getName(), 0, 3) == 'get' || substr($method->getName(), 0, 2) == 'is'; $isSuitableMethodType = !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()); $isMagicMethod = in_array($method->getName(), array('__sleep', '__wakeup', '__clone')); @@ -178,7 +213,11 @@ class DataBuilder extends EntityAbstract */ protected function _getMethodInfo(\ReflectionMethod $method) { - $propertyName = substr($method->getName(), 3); + if (substr($method->getName(), 0, 2) == 'is') { + $propertyName = substr($method->getName(), 2); + } else { + $propertyName = substr($method->getName(), 3); + } $returnType = (new ClassReflection($this->_getSourceClassName())) ->getMethod($method->getName()) ->getDocBlock() @@ -190,7 +229,7 @@ class DataBuilder extends EntityAbstract 'parameters' => [ ['name' => lcfirst($propertyName)] ], - 'body' => "\$this->set('{$fieldName}', \$" . lcfirst($propertyName) . ");" + 'body' => "\$this->_set('{$fieldName}', \$" . lcfirst($propertyName) . ");" . PHP_EOL . "return \$this;", 'docblock' => [ 'tags' => [ @@ -202,31 +241,6 @@ class DataBuilder extends EntityAbstract return $methodInfo; } - /** - * Validate data - * - * @return bool - */ - protected function _validateData() - { - $result = parent::_validateData(); - - if ($result) { - $sourceClassName = $this->_getSourceClassName(); - $resultClassName = $this->_getResultClassName(); - - if ($resultClassName !== str_replace('Interface', ucfirst(self::ENTITY_TYPE), $sourceClassName)) { - $this->_addError( - 'Invalid Builder class name [' . $resultClassName . ']. Use ' - . $sourceClassName - . ucfirst(self::ENTITY_TYPE) - ); - $result = false; - } - } - return $result; - } - /** * Generate code * @@ -239,7 +253,7 @@ class DataBuilder extends EntityAbstract ->addProperties($this->_getClassProperties()) ->addMethods($this->_getClassMethods()) ->setClassDocBlock($this->_getClassDocBlock()) - ->setExtendedClass('\Magento\Framework\Api\CompositeExtensibleDataBuilder'); + ->setExtendedClass('\Magento\Framework\Api\Builder'); return $this->_getGeneratedCode(); } @@ -248,7 +262,25 @@ class DataBuilder extends EntityAbstract */ protected function _getSourceClassName() { - return parent::_getSourceClassName() . 'Interface'; + return $this->_getDataObjectType(); + } + + /** + * Get data object type based on suffix + * + * @return string + */ + protected function _getDataObjectType() + { + $currentBuilderClass = $this->_getResultClassName(); + $dataBuilderSuffix = 'DataBuilder'; + if (substr($currentBuilderClass, -strlen($dataBuilderSuffix)) === $dataBuilderSuffix) { + $dataObjectType = substr($currentBuilderClass, 0, -strlen($dataBuilderSuffix)) . 'Interface'; + } else { + $builderSuffix = 'Builder'; + $dataObjectType = substr($currentBuilderClass, 0, -strlen($builderSuffix)); + } + return $dataObjectType; } /** diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php index a668fbbeb50..eb97dffa621 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php @@ -68,7 +68,7 @@ class SearchResultsBuilder extends EntityAbstract ], [ 'name' => 'valueBuilder', - 'type' => '\\Magento\Framework\Api\AttributeValueBuilder' + 'type' => '\\Magento\Framework\Api\AttributeDataBuilder' ], [ 'name' => 'metadataService', diff --git a/lib/internal/Magento/Framework/Api/CompositeExtensibleDataBuilder.php b/lib/internal/Magento/Framework/Api/CompositeExtensibleDataBuilder.php deleted file mode 100644 index 15726b43411..00000000000 --- a/lib/internal/Magento/Framework/Api/CompositeExtensibleDataBuilder.php +++ /dev/null @@ -1,168 +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\Api; - -use Magento\Framework\Model\AbstractExtensibleModel; -use Magento\Framework\ObjectManager; -use Magento\Framework\ObjectManager\Config as ObjectManagerConfig; - -/** - * Composite extensible data builder. - */ -class CompositeExtensibleDataBuilder implements ExtensibleDataBuilderInterface -{ - /**#@+ - * Constant which defines if builder is created for building data objects or data models. - */ - const TYPE_DATA_OBJECT = 'data_object'; - const TYPE_DATA_MODEL = 'data_model'; - /**#@-*/ - - /** @var string */ - protected $modelClassInterface; - - /** @var ExtensibleDataBuilderInterface */ - protected $currentBuilder; - - /** @var ObjectManagerConfig */ - protected $objectManagerConfig; - - /** - * Initialize dependencies. - * - * @param ObjectManager $objectManager - * @param MetadataServiceInterface $metadataService - * @param ObjectManagerConfig $objectManagerConfig - * @param string $modelClassInterface - */ - public function __construct( - ObjectManager $objectManager, - MetadataServiceInterface $metadataService, - ObjectManagerConfig $objectManagerConfig, - $modelClassInterface - ) { - $this->modelClassInterface = $modelClassInterface; - $this->objectManagerConfig = $objectManagerConfig; - $arguments = [ - 'metadataService' => $metadataService, - 'modelClassInterface' => $modelClassInterface - ]; - $builderClass = ($this->getDataType() == self::TYPE_DATA_MODEL) - ? 'Magento\Framework\Api\ExtensibleDataBuilder' - : 'Magento\Framework\Api\ExtensibleObjectBuilder'; - $this->currentBuilder = $objectManager->create($builderClass, $arguments); - } - - /** - * {@inheritdoc} - */ - public function setCustomAttribute($attributeCode, $attributeValue) - { - $this->currentBuilder->setCustomAttribute($attributeCode, $attributeValue); - return $this; - } - - /** - * {@inheritdoc} - */ - public function setCustomAttributes(array $attributes) - { - $this->currentBuilder->setCustomAttributes($attributes); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - return $this->currentBuilder->create(); - } - - /** - * Proxy all calls to current builder. - * - * @param string $name - * @param array $arguments - * @return mixed - */ - public function __call($name, $arguments) - { - call_user_func_array([$this->currentBuilder, $name], $arguments); - return $this; - } - - /** - * Identify type of objects which should be built with generated builder. Value can be one of self::TYPE_DATA_*. - * - * @return string - * @throws \LogicException - */ - protected function getDataType() - { - $sourceClassPreference = $this->objectManagerConfig->getPreference($this->modelClassInterface); - if (empty($sourceClassPreference)) { - throw new \LogicException( - "Preference for {$this->modelClassInterface} is not defined." - ); - } - if (is_subclass_of($sourceClassPreference, '\Magento\Framework\Api\AbstractSimpleObject')) { - return self::TYPE_DATA_OBJECT; - } else if (is_subclass_of($sourceClassPreference, '\Magento\Framework\Model\AbstractExtensibleModel')) { - return self::TYPE_DATA_MODEL; - } else { - throw new \LogicException( - 'Preference of ' . $this->modelClassInterface - . ' must extend from AbstractSimpleObject or AbstractExtensibleModel' - ); - } - } - - /** - * Populates the fields with data from the array. - * - * Keys for the map are snake_case attribute/field names. - * - * @param array $data - * @return $this - */ - public function populateWithArray(array $data) - { - $this->currentBuilder->populateWithArray($data); - return $this; - } - - /** - * Populates the fields with data from the prototype. - * - * @param AbstractSimpleObject $prototype - * @return $this - */ - public function populate(AbstractSimpleObject $prototype) - { - $this->currentBuilder->populate($prototype); - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php index 88cd4f2f40c..30feb685e95 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php +++ b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php @@ -29,6 +29,11 @@ namespace Magento\Framework\Api; */ interface ExtensibleDataInterface { + /** + * Array key for custom attributes + */ + const CUSTOM_ATTRIBUTES = 'custom_attributes'; + /** * Get an attribute value. * diff --git a/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php b/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php index b596533bea7..548d6a00c6b 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php @@ -28,10 +28,10 @@ namespace Magento\Framework\Api; * Base Builder Class for extensible data Objects * @SuppressWarnings(PHPMD.NumberOfChildren) */ -class ExtensibleObjectBuilder extends AbstractSimpleObjectBuilder implements ExtensibleDataBuilderInterface +class ExtensibleObjectBuilder extends AbstractSimpleObjectBuilder implements BuilderInterface { /** - * @var AttributeValueBuilder + * @var AttributeDataBuilder */ protected $attributeValueBuilder; @@ -52,13 +52,13 @@ class ExtensibleObjectBuilder extends AbstractSimpleObjectBuilder implements Ext /** * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param AttributeDataBuilder $valueBuilder * @param MetadataServiceInterface $metadataService * @param string|null $modelClassInterface */ public function __construct( \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + AttributeDataBuilder $valueBuilder, MetadataServiceInterface $metadataService, $modelClassInterface = null ) { @@ -103,6 +103,81 @@ class ExtensibleObjectBuilder extends AbstractSimpleObjectBuilder implements Ext return $this; } + + /** + * Populates the fields with an existing entity. + * + * @param ExtensibleDataInterface $prototype the prototype to base on + * @return $this + * @throws \LogicException If $prototype object class is not the same type as object that is constructed + */ + public function populate(ExtensibleDataInterface $prototype) + { + $objectType = $this->_getDataObjectType(); + if (!($prototype instanceof $objectType)) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + return $this->populateWithArray($prototype->__toArray()); + } + + /** + * Populates the fields with data from the array. + * + * Keys for the map are snake_case attribute/field names. + * + * @param array $data + * @return $this + */ + public function populateWithArray(array $data) + { + $this->data = array(); + $this->_setDataValues($data); + return $this; + } + + + /** + * Merge second Data Object data with first Data Object data and create new Data Object object based on merge + * result. + * + * @param ExtensibleDataInterface $firstDataObject + * @param ExtensibleDataInterface $secondDataObject + * @return $this + * @throws \LogicException + */ + public function mergeDataObjects( + ExtensibleDataInterface $firstDataObject, + ExtensibleDataInterface $secondDataObject + ) { + $objectType = $this->_getDataObjectType(); + if (get_class($firstDataObject) != $objectType || get_class($secondDataObject) != $objectType) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + $this->_setDataValues($firstDataObject->__toArray()); + $this->_setDataValues($secondDataObject->__toArray()); + return $this; + } + + /** + * Merged data provided in array format with Data Object data and create new Data Object object based on merge + * result. + * + * @param ExtensibleDataInterface $dataObject + * @param array $data + * @return $this + * @throws \LogicException + */ + public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data) + { + $objectType = $this->_getDataObjectType(); + if (!($dataObject instanceof $objectType)) { + throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); + } + $this->_setDataValues($dataObject->__toArray()); + $this->_setDataValues($data); + return $this; + } + /** * Template method used to configure the attribute codes for the custom attributes * diff --git a/lib/internal/Magento/Framework/Api/Filter.php b/lib/internal/Magento/Framework/Api/Filter.php index 5d106584dc3..70680d19f59 100644 --- a/lib/internal/Magento/Framework/Api/Filter.php +++ b/lib/internal/Magento/Framework/Api/Filter.php @@ -27,7 +27,7 @@ namespace Magento\Framework\Api; /** * Filter which can be used by any methods from service layer. */ -class Filter extends \Magento\Framework\Api\AbstractExtensibleObject +class Filter extends AbstractExtensibleObject { /** * Get field diff --git a/lib/internal/Magento/Framework/Api/FilterBuilder.php b/lib/internal/Magento/Framework/Api/FilterBuilder.php index 506f3258778..92c7a870121 100644 --- a/lib/internal/Magento/Framework/Api/FilterBuilder.php +++ b/lib/internal/Magento/Framework/Api/FilterBuilder.php @@ -29,7 +29,7 @@ namespace Magento\Framework\Api; * * @method Filter create() */ -class FilterBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder +class FilterBuilder extends \Magento\Framework\Api\Builder { /** * Set field diff --git a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php index da0fbfc8f22..21798355167 100644 --- a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php +++ b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php @@ -24,15 +24,16 @@ namespace Magento\Framework\Api\Search; -use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; +use Magento\Framework\Api\Builder; +use Magento\Framework\Api\ObjectFactory; +use Magento\Framework\Api\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\FilterBuilder; /** * Builder for FilterGroup Data. */ -class FilterGroupBuilder extends ExtensibleObjectBuilder +class FilterGroupBuilder extends Builder { /** * @var FilterBuilder @@ -40,18 +41,37 @@ class FilterGroupBuilder extends ExtensibleObjectBuilder protected $_filterBuilder; /** - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param ObjectFactory $objectFactory * @param MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $attributeValueBuilder + * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor + * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor + * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory + * @param \Magento\Framework\ObjectManager\Config $objectManagerConfig * @param FilterBuilder $filterBuilder + * @param string|null $modelClassInterface */ public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + ObjectFactory $objectFactory, MetadataServiceInterface $metadataService, - FilterBuilder $filterBuilder + \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder, + \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, + \Magento\Framework\Reflection\TypeProcessor $typeProcessor, + \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, + \Magento\Framework\ObjectManager\Config $objectManagerConfig, + FilterBuilder $filterBuilder, + $modelClassInterface = null ) { - parent::__construct($objectFactory, $valueBuilder, $metadataService); + parent::__construct( + $objectFactory, + $metadataService, + $attributeValueBuilder, + $objectProcessor, + $typeProcessor, + $dataBuilderFactory, + $objectManagerConfig, + $modelClassInterface + ); $this->_filterBuilder = $filterBuilder; } diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php index c97d5a94e19..2521a8d8d00 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php @@ -24,16 +24,12 @@ namespace Magento\Framework\Api; -use Magento\Framework\Api\ExtensibleObjectBuilder; -use Magento\Framework\Api\AttributeValueBuilder; -use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\Search\FilterGroupBuilder; -use Magento\Framework\Api\SortOrder; /** * Builder for SearchCriteria Service Data Object */ -class SearchCriteriaBuilder extends ExtensibleObjectBuilder +class SearchCriteriaBuilder extends Builder { /** * @var FilterGroupBuilder @@ -41,18 +37,37 @@ class SearchCriteriaBuilder extends ExtensibleObjectBuilder protected $_filterGroupBuilder; /** - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param AttributeValueBuilder $valueBuilder + * @param ObjectFactory $objectFactory * @param MetadataServiceInterface $metadataService + * @param AttributeDataBuilder $attributeValueBuilder + * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor + * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor + * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory + * @param \Magento\Framework\ObjectManager\Config $objectManagerConfig * @param FilterGroupBuilder $filterGroupBuilder + * @param string|null $modelClassInterface */ public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - AttributeValueBuilder $valueBuilder, + ObjectFactory $objectFactory, MetadataServiceInterface $metadataService, - FilterGroupBuilder $filterGroupBuilder + AttributeDataBuilder $attributeValueBuilder, + \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, + \Magento\Framework\Reflection\TypeProcessor $typeProcessor, + \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, + \Magento\Framework\ObjectManager\Config $objectManagerConfig, + FilterGroupBuilder $filterGroupBuilder, + $modelClassInterface = null ) { - parent::__construct($objectFactory, $valueBuilder, $metadataService); + parent::__construct( + $objectFactory, + $metadataService, + $attributeValueBuilder, + $objectProcessor, + $typeProcessor, + $dataBuilderFactory, + $objectManagerConfig, + $modelClassInterface + ); $this->_filterGroupBuilder = $filterGroupBuilder; } diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version/GeneratorInterface.php b/lib/internal/Magento/Framework/Api/SimpleBuilderInterface.php similarity index 74% rename from lib/internal/Magento/Framework/App/View/Deployment/Version/GeneratorInterface.php rename to lib/internal/Magento/Framework/Api/SimpleBuilderInterface.php index 5dc9b87c7ce..fe4a420473c 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version/GeneratorInterface.php +++ b/lib/internal/Magento/Framework/Api/SimpleBuilderInterface.php @@ -22,17 +22,25 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Framework\App\View\Deployment\Version; +namespace Magento\Framework\Api; + /** - * Algorithm of generation of deployment version of static files + * Base Builder interface for simple data Objects */ -interface GeneratorInterface +interface SimpleBuilderInterface { /** - * Return deployment version of static files that is unique enough for the current deployment + * Builds the Data Object + * + * @return AbstractSimpleObject + */ + public function create(); + + /** + * Return data Object data. * - * @return string + * @return array */ - public function generate(); + public function getData(); } diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version.php b/lib/internal/Magento/Framework/App/View/Deployment/Version.php index d88c37aaf56..0de9bf9a693 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version.php +++ b/lib/internal/Magento/Framework/App/View/Deployment/Version.php @@ -39,10 +39,8 @@ class Version */ private $versionStorage; - /** - * @var \Magento\Framework\App\View\Deployment\Version\GeneratorInterface - */ - private $versionGenerator; + /** @var \Magento\Framework\Stdlib\DateTime */ + private $dateTime; /** * @var string @@ -51,17 +49,17 @@ class Version /** * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage - * @param \Magento\Framework\App\View\Deployment\Version\GeneratorInterface $versionGenerator + * @param Version\StorageInterface $versionStorage + * @param \Magento\Framework\Stdlib\DateTime $dateTime */ public function __construct( \Magento\Framework\App\State $appState, \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage, - \Magento\Framework\App\View\Deployment\Version\GeneratorInterface $versionGenerator + \Magento\Framework\Stdlib\DateTime $dateTime ) { $this->appState = $appState; $this->versionStorage = $versionStorage; - $this->versionGenerator = $versionGenerator; + $this->dateTime = $dateTime; } /** @@ -90,13 +88,13 @@ class Version try { $result = $this->versionStorage->load(); } catch (\UnexpectedValueException $e) { - $result = $this->versionGenerator->generate(); + $result = $this->dateTime->toTimestamp(true); $this->versionStorage->save($result); } break; case \Magento\Framework\App\State::MODE_DEVELOPER: - $result = $this->versionGenerator->generate(); + $result = $this->dateTime->toTimestamp(true); break; default: diff --git a/lib/internal/Magento/Framework/AppInterface.php b/lib/internal/Magento/Framework/AppInterface.php index cc6d1fa9c40..744daa8ff87 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-alpha103'; + const VERSION = '0.1.0-alpha104'; /** * Launch application diff --git a/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Parameter.php b/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Parameter.php index 56065edfcba..d089aff195a 100644 --- a/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Parameter.php +++ b/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Parameter.php @@ -79,6 +79,9 @@ class Parameter extends \Magento\Framework\Filter\Template\Tokenizer\AbstractTok break; } elseif ($this->char() == '\\') { $this->next(); + if ($this->char() != '\\') { + $value .= '\\'; + } $value .= $this->char(); } else { $value .= $this->char(); diff --git a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php index da46448e795..db4e2d18c19 100644 --- a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php @@ -35,8 +35,6 @@ use Magento\Framework\Api\ExtensibleDataInterface; */ abstract class AbstractExtensibleModel extends AbstractModel implements ExtensibleDataInterface { - const CUSTOM_ATTRIBUTES_KEY = 'custom_attributes'; - /** * @var MetadataServiceInterface */ @@ -76,25 +74,25 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib */ protected function filterCustomAttributes($data) { - if (empty($data[self::CUSTOM_ATTRIBUTES_KEY])) { + if (empty($data[self::CUSTOM_ATTRIBUTES])) { return $data; } $customAttributesCodes = $this->getCustomAttributesCodes(); - $data[self::CUSTOM_ATTRIBUTES_KEY] = - array_intersect_key($data[self::CUSTOM_ATTRIBUTES_KEY], $customAttributesCodes); + $data[self::CUSTOM_ATTRIBUTES] = + array_intersect_key($data[self::CUSTOM_ATTRIBUTES], $customAttributesCodes); return $data; } /** * Retrieve custom attributes values. * - * @return \Magento\Framework\Api\AttributeValue[]|null + * @return \Magento\Framework\Api\AttributeInterface[]|null */ public function getCustomAttributes() { // Returning as a sequential array (instead of stored associative array) to be compatible with the interface - return isset($this->_data[self::CUSTOM_ATTRIBUTES_KEY]) - ? array_values($this->_data[self::CUSTOM_ATTRIBUTES_KEY]) + return isset($this->_data[self::CUSTOM_ATTRIBUTES]) + ? array_values($this->_data[self::CUSTOM_ATTRIBUTES]) : []; } @@ -102,12 +100,12 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib * Get an attribute value. * * @param string $attributeCode - * @return \Magento\Framework\Api\AttributeValue|null null if the attribute has not been set + * @return \Magento\Framework\Api\AttributeInterface|null null if the attribute has not been set */ public function getCustomAttribute($attributeCode) { - return isset($this->_data[self::CUSTOM_ATTRIBUTES_KEY][$attributeCode]) - ? $this->_data[self::CUSTOM_ATTRIBUTES_KEY][$attributeCode] + return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]) + ? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] : null; } @@ -125,7 +123,7 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib */ public function setData($key, $value = null) { - if ($key == self::CUSTOM_ATTRIBUTES_KEY) { + if ($key == self::CUSTOM_ATTRIBUTES) { throw new \LogicException("Custom attributes must be set only using setCustomAttribute() method."); } return parent::setData($key, $value); @@ -150,17 +148,17 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib */ public function getData($key = '', $index = null) { - if ($key == self::CUSTOM_ATTRIBUTES_KEY) { + if ($key == self::CUSTOM_ATTRIBUTES) { throw new \LogicException("Custom attributes array should be retrieved via getCustomAttributes() only."); } else if ($key == '') { /** Represent model data and custom attributes as a flat array */ $data = array_merge($this->_data, $this->getCustomAttributes()); - unset($data[self::CUSTOM_ATTRIBUTES_KEY]); + unset($data[self::CUSTOM_ATTRIBUTES]); } else { $data = parent::getData($key, $index); if ($data === null) { /** Try to find necessary data in custom attributes */ - $data = parent::getData(self::CUSTOM_ATTRIBUTES_KEY . "/{$key}", $index); + $data = parent::getData(self::CUSTOM_ATTRIBUTES . "/{$key}", $index); } } return $data; diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index b1e1da7b074..f2f11b58ed3 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -269,7 +269,7 @@ abstract class AbstractModel extends \Magento\Framework\Object /** * Get collection instance * - * @deplacated + * @deprecated * @throws \Magento\Framework\Model\Exception * @return \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection */ diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index 2ebbe7ed3df..db2e5ca7a37 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -31,7 +31,6 @@ use Magento\Framework\ObjectManager\Definition\Runtime; use Magento\Framework\ObjectManager\Relations; use Magento\Framework\ObjectManager\Code\Generator; use Magento\Framework\Interception\Code\Generator as InterceptionGenerator; -use Magento\Framework\Api\Code\Generator\Builder as BuilderGenerator; use Magento\Framework\Api\Code\Generator\DataBuilder as DataBuilderGenerator; use Magento\Framework\Api\Code\Generator\Mapper as MapperGenerator; use Magento\Framework\ObjectManager\Code\Generator\Converter as ConverterGenerator; @@ -140,8 +139,7 @@ class DefinitionFactory => '\Magento\Framework\Interception\Code\Generator\Interceptor', DataBuilderGenerator::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\DataBuilder', - BuilderGenerator::ENTITY_TYPE - => '\Magento\Framework\Api\Code\Generator\Builder', + DataBuilderGenerator::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', MapperGenerator::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\Mapper', SearchResults::ENTITY_TYPE diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php index 66dd749bef1..d041da84a47 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php @@ -150,16 +150,17 @@ class Log { $this->stats['used'] = count($this->used); $this->stats['unused'] = $this->stats['total'] - $this->stats['used']; - echo '<table border="1" cellspacing="0" cellpadding="2">' . PHP_EOL; - echo "<caption>Creation chain (Red items are never used) Total: {$this->stats['total']}\n"; - echo "Used: {$this->stats['used']} Not used: {$this->stats['unused']}</caption>"; - echo '<tbody>'; - echo "<tr><th>Instance class</th></tr>"; + echo '<table border="1" cellspacing="0" cellpadding="2">', + '<thead><tr><th>', + "Creation chain (Red items are never used) Total: {$this->stats['total']}\n", + "Used: {$this->stats['used']} Not used: {$this->stats['unused']}", + '</th></tr></thead>', + '<tbody>', + '<tr><th>Instance class</th></tr>'; foreach ($this->roots as $root) { $this->displayItem($root); } - echo '</tbody>'; - echo '</table>'; + echo '</tbody></table>'; } /** diff --git a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php index b50045e3020..4b27b18f1f4 100644 --- a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php @@ -28,7 +28,7 @@ use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; use Magento\Framework\Api\SimpleDataObjectConverter; use Magento\Framework\Api\AttributeValue; -use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\Framework\ObjectManager; /** @@ -118,7 +118,7 @@ class DataObjectProcessor continue; } $key = SimpleDataObjectConverter::camelCaseToSnakeCase(substr($methodName, 3)); - if ($key === AbstractExtensibleModel::CUSTOM_ATTRIBUTES_KEY) { + if ($key === ExtensibleDataInterface::CUSTOM_ATTRIBUTES) { $value = $this->convertCustomAttributes($value); } else if (is_object($value)) { $value = $this->buildOutputDataArray($value, $returnType); diff --git a/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php b/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php index c996d3a8b64..2ef905716aa 100644 --- a/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php +++ b/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php @@ -48,7 +48,7 @@ class DataBuilderFactory * Returns a builder for a given class name. * * @param string $className - * @return \Magento\Framework\Api\ExtensibleDataBuilderInterface Builder Instance + * @return \Magento\Framework\Api\BuilderInterface Builder Instance */ public function getDataBuilder($className) { diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 41d9cff4101..493b906ecf3 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-alpha103", + "version": "0.1.0-alpha104", "require": { "php": "~5.4.11|~5.5.0", "ext-spl": "*", diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js index f9b00e89127..9c82575627f 100644 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js @@ -310,6 +310,7 @@ define([ return content.gsub(/\{\{widget(.*?)\}\}/i, function(match){ var attributes = this.parseAttributesString(match[1]); if (attributes.type) { + attributes.type = attributes.type.replace(/\\\\/g, "\\"); var imageSrc = this.config.widget_placeholders[attributes.type]; var imageHtml = '<img'; imageHtml+= ' id="' + Base64.idEncode(match[0]) + '"'; -- GitLab